[FFmpeg-devel] [PATCH] asf.c: move packet_time_start=0 statement
Ronald S. Bultje
rsbultje
Thu Dec 4 14:17:20 CET 2008
Hi,
On Thu, Dec 4, 2008 at 6:09 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Wed, Dec 03, 2008 at 11:46:01PM -0500, Ronald S. Bultje wrote:
>> $subj, is only used once directly after get_packet(), unconditionally,
>> this patch moves it at the end of get_packet().
>
> could you explain why you want to move this line?
All other such statements are already in asf_get_packet(), so I
figured it would look nice to move this one also.
Of course, I couldn't care less, but I wanted to refactor the piece of
code that it comes from (in asf_read_packet()). Right now, the ASF
demuxer is basically pull-based, i.e. it "pulls" packets whenever
needed to return 1 data packet. By extracting the piece of code that
it comes from (i.e. unrelated to this patch), I can make it work both
pull- and push-based (i.e. provide it with one ASF packet, or not, and
have it return a frame when it's there). I use this for RTSP-MS. It
might be useful for MMS and HTTP-MS (yes, that exists) also. However,
before refactoring, I wanted to clean it up a bit also...
Current:
asf_read_packet() {
for (;;) {
if (not enough data) {
if (asf_get_packet() < 0)
return -1;
}
//parse packet
if (fail)
return -1;
else if (have data)
break;
}
return 0;
}
What I want:
asf_parse_packet() {
for (;;) {
if (not enough data)
return 1;
//parse packet
if (fail)
return -1;
else if (have data)
break;
}
return 0;
}
asf_read_packet(){
for (;;)
if ((ret = asf_parse_packet()) <= 0)
return ret;
else if (ret = asf_get_packet()) < 0)
return ret;
}
}
and then the RTSP-MS code does the exact same thing, except that it
only has a single packet per iteration. For this, I need
asf_get_packet() out of asf_read_packet() and asf_parse/get_packet()
(plus asf_parse_header()) will be made public so the RTSP-MS code can
use it.
Ronald
More information about the ffmpeg-devel
mailing list