[FFmpeg-devel] [RFC/PATCH] Pass PRIVATE_STREAM_2 MPEG-PS packets to caller

Richard peper03 at yahoo.com
Fri Mar 8 21:41:50 CET 2013


On 08/03/13 11:26, Richard wrote:
> On 08/03/13 02:00, Michael Niedermayer wrote:
>> On Fri, Mar 08, 2013 at 01:18:21AM +0100, Richard wrote:
>>> +            uint8_t firstbyte = avio_r8(s->pb);
>>> +            avio_skip(s->pb, -1);
>>> +
>>> +            while (len >= 6) {
>>> +                len--;
>>>                   if (avio_r8(s->pb) == 'S') {
>>
>> this reads a byte then seeks back and reads it again
>> this sure can be done without the seek
>
> Well, it can but it then ends up looking pretty ugly:
>
> uint8_t firstbyte = avio_r8(s->pb);
> len--;
>
> while (len >= 6) {
>      if (firstbyte == 'S' || avio_r8(s->pb) == 'S') {
>          if (firstbyte != 'S')
>              len--;
>
>          uint8_t buf[5];
>          avio_read(s->pb, buf, sizeof(buf));
>          m->sofdec = !memcmp(buf, "ofdec", 5);
>          len -= sizeof(buf);
>          break;
>      }
>      len--;
> }
>
> Since (to my understanding) the avio buffer must have a size of at least
> 1, a seek of -1 should never be a problem.

<snip>

>>> +                avio_skip(s->pb, -((origlen-len) + 2));
>>
>> this needs a failure check and the failure must be handled

Ok, I've checked for failure at this point.  I've left the 'skip -1' as 
that should never cause a physical read.

Patch attached.

Richard.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-passing-DVD-navigation-packets-startcode-0x1bf-t.patch
Type: text/x-patch
Size: 11415 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130308/f967aadb/attachment.bin>


More information about the ffmpeg-devel mailing list