[PATCH] RDT: implement rule-number parsing
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. Thanks, Ronald
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, ×tamp, NULL, 0, flags); + s->ic->streams[s->st->index + s->rule], + pkt, ×tamp, NULL, 0, flags); return rv; }
if (len < 12) return -1; - rv = ff_rdt_parse_header(buf, len, &sn, &seq, &rule, ×tamp); + rv = ff_rdt_parse_header(buf, len, &sn, &seq, &s->rule, ×tamp); 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, ×tamp, buf, len, flags); + s->ic->streams[s->st->index + s->rule], + pkt, ×tamp, buf, len, flags);
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Asymptotically faster algorithms should always be preferred if you have asymptotical amounts of data
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, ×tamp, NULL, 0, flags); + s->ic->streams[s->st->index + s->rule], + pkt, ×tamp, 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, ×tamp, buf, len, flags); + s->ic->streams[s->st->index + s->rule], + pkt, ×tamp, 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
Hi, On Sun, Oct 26, 2008 at 2:23 PM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
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.
Ping? Ronald
Hi, On Wed, Oct 29, 2008 at 6:46 PM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
On Sun, Oct 26, 2008 at 2:23 PM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
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.
Ping?
Ping2? Ronald
participants (2)
-
michaelni@gmx.at -
rsbultje@gmail.com