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

Michael Niedermayer michaelni
Sun Oct 26 17:43:43 CET 2008


On Sun, Oct 26, 2008 at 10:36:30AM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> aboved patch adds parsing for rule-number parsing, as previously
> submitted but not reviewed. RDT inputs are enumerated by their stream
> number (usually 0 for video, 1 for audio or so) and the respective
> stream's rule number (an enumeration of the possible bitrates).
> Although you usually would download one, it is possible (and I have
> locally implemented) the downloading of multiple rules at the same
> time, thus allowing a complete backup where your bandwidth allows it.
> This particular patch just parses the rule number, sot hat subsequent
> patches can use that feature to request multiple streams (instead of
> the current "rule 0" request), thus enabling stream selection.
> 
[...]
>          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);
>          return rv;
>      }
>  
>      if (len < 12)
>          return -1;
> -    rv = ff_rdt_parse_header(buf, len, &sn, &seq, &rule, &timestamp);
> +    rv = ff_rdt_parse_header(buf, len, &sn, &seq, &s->rule, &timestamp);
>      if (rv < 0)
>          return rv;
> -    if (!(rule & 1) && (sn != s->prev_sn || timestamp != s->prev_ts)) {
> +    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);

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081026/73da94c0/attachment.pgp>



More information about the ffmpeg-devel mailing list