[FFmpeg-devel] [PATCH] RDT: implement rule-number parsing

Ronald S. Bultje rsbultje
Sun Oct 26 19:23:09 CET 2008


Hi Michael,

On Sun, Oct 26, 2008 at 12:43 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Sun, Oct 26, 2008 at 10:36:30AM -0400, Ronald S. Bultje wrote:
> [...]
>>          rv= s->parse_packet(s->dynamic_protocol_context,
>> -                            s->st, pkt, &timestamp, NULL, 0, flags);
>> +                            s->ic->streams[s->st->index + s->rule],
>> +                            pkt, &timestamp, NULL, 0, flags);
[..]
>> +    if (!(s->rule & 1) && (sn != s->prev_sn || timestamp != s->prev_ts ||
>> +                           (s->rule >> 1) != s->prev_rn)) {
>>          flags |= PKT_FLAG_KEY;
>>          s->prev_sn = sn;
>>          s->prev_ts = timestamp;
>> +        s->prev_rn = s->rule >> 1;
>>      }
>>      buf += rv;
>>      len -= rv;
>> +    s->rule >>= 1;
>> +
>
>> +    if (s->st->index + s->rule >= s->ic->nb_streams ||
>> +        s->st->priv_data != s->ic->streams[s->st->index + s->rule]->priv_data)
>> +        return -1;
>
> from this if() i would guess that s->rule can be invalid, if so it does
> not appear that this if() is sufficient to prevent the of an invalid s->rule
> it really only protects from one use below
>
>>      rv = s->parse_packet(s->dynamic_protocol_context,
>> -                         s->st, pkt, &timestamp, buf, len, flags);
>> +                         s->ic->streams[s->st->index + s->rule],
>> +                         pkt, &timestamp, buf, len, flags);

You're right, this was written based on the assumption that
s->parse_packet() is rdt_parse_packet(), since that one only actually
acess the AVStream if there was a previously succesful call to
rdt_parse_packet() (which automatically means that s->rule is valid).
However, with the function pointer, I can't assume that. New patch
attached with the above fixed.

I removed s->rule here and just use a local variable for comparison
against s->prev_rn. I also removed the prev_ prefix from all
s->prev_{rn,sn,ts} since they are also accesses for the current
packet, not just the previous one.

Ronald
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rdt-rn_parsing.patch
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081026/d937b313/attachment.asc>



More information about the ffmpeg-devel mailing list