Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: Nasty bug in StillPicture()



On 17 Oct 2003 Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:

Jut a few comments:

> void cDvbDevice::StillPicture(const uchar *Data, int Length)
> {
> #define VIDEO_STILLPICTURE_WORKS_WITH_VDR_FRAMES
> #ifdef VIDEO_STILLPICTURE_WORKS_WITH_VDR_FRAMES
>   if (Data[0] == 0x00 && Data[1] == 0x00 && Data[2] == 0x01 && (Data[3] & 0xF0) == 0xE0) {
>      // PES data
>      char *buf = MALLOC(char, Length);
>      if (!buf)
>         return;
>      int i = 0;
>      int blen = 0;
>      while (i < Length - 6) {
>            if (Data[i] == 0x00 && Data[i + 1] == 0x00 && Data[i + 2] == 0x01) {
>               int len = Data[i + 4] * 256 + Data[i + 5];
>               if ((Data[i + 3] & 0xF0) == 0xE0) { // video packet
>                  // skip PES header
>                  int offs = i + 6;
>                  // skip header extension
>                  if ((Data[i + 6] & 0xC0) == 0x80) {
>                     // MPEG-2 PES header
>                     offs += 3;
>                     offs += Data[i + 8];
>                     len -= 3;
>                     len -= Data[i + 8];
>                     }
>                  else {
>                     // MPEG-1 PES header

>                     while (offs < Length && len > 0 && Data[offs] == 0xFF) {
>                           offs++;
>                           len--;
>                           }

This skips the stuffing bytes. I think mpeg2 can have stuffing
bytes too, so IMO this should be moved before the mpeg1/mpeg2
decision (before skip header extension).

>                     if ((Data[offs] & 0xC0) == 0x40) {
>                        offs += 2;
>                        len -= 2;
>                        }

>                     if ((Data[offs] & 0xF0) == 0x20) {
>                        offs += 5;
>                        len -= 5;
>                        }
>                     else if ((Data[offs] & 0xF0) == 0x30) {
>                        offs += 10;
>                        len -= 10;
>                        }
>                     else if (Data[offs] == 0x0F) {
>                        offs++;
>                        len--;
>                        }

This skips the PTS/DTS infos. To be prepared for faulty streams
the last "else if" should be a simple "else" (the indicator byte has
to be skipped in any case).

Regards.

-- 
Stefan Huelswitt
huels@iname.com  | http://home.pages.de/~nathan


-- 
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index