r16884 - trunk/libavformat/utils.c
Author: bcoudurier Date: Sat Jan 31 07:01:58 2009 New Revision: 16884 Log: split av_interleave_per_dts, to avoid code duplication Modified: trunk/libavformat/utils.c Modified: trunk/libavformat/utils.c ============================================================================== --- trunk/libavformat/utils.c Sat Jan 31 06:53:04 2009 (r16883) +++ trunk/libavformat/utils.c Sat Jan 31 07:01:58 2009 (r16884) @@ -2585,34 +2585,45 @@ int av_write_frame(AVFormatContext *s, A return ret; } +void ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, + int (*compare)(AVFormatContext *, AVPacket *, AVPacket *)) +{ + AVPacketList **next_point, *this_pktl; + + this_pktl = av_mallocz(sizeof(AVPacketList)); + this_pktl->pkt= *pkt; + if(pkt->destruct == av_destruct_packet) + pkt->destruct= NULL; // not shared -> must keep original from being freed + else + av_dup_packet(&this_pktl->pkt); //shared -> must dup + + next_point = &s->packet_buffer; + while(*next_point){ + if(compare(s, &(*next_point)->pkt, pkt)) + break; + next_point= &(*next_point)->next; + } + this_pktl->next= *next_point; + *next_point= this_pktl; +} + +int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacket *pkt) +{ + AVStream *st = s->streams[ pkt ->stream_index]; + AVStream *st2= s->streams[ next->stream_index]; + int64_t left = st2->time_base.num * (int64_t)st ->time_base.den; + int64_t right= st ->time_base.num * (int64_t)st2->time_base.den; + + return next->dts * left > pkt->dts * right; //FIXME this can overflow +} + int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){ - AVPacketList *pktl, **next_point, *this_pktl; + AVPacketList *pktl; int stream_count=0; int streams[MAX_STREAMS]; if(pkt){ - AVStream *st= s->streams[ pkt->stream_index]; - -// assert(pkt->destruct != av_destruct_packet); //FIXME - - this_pktl = av_mallocz(sizeof(AVPacketList)); - this_pktl->pkt= *pkt; - if(pkt->destruct == av_destruct_packet) - pkt->destruct= NULL; // not shared -> must keep original from being freed - else - av_dup_packet(&this_pktl->pkt); //shared -> must dup - - next_point = &s->packet_buffer; - while(*next_point){ - AVStream *st2= s->streams[ (*next_point)->pkt.stream_index]; - int64_t left= st2->time_base.num * (int64_t)st ->time_base.den; - int64_t right= st ->time_base.num * (int64_t)st2->time_base.den; - if((*next_point)->pkt.dts * left > pkt->dts * right) //FIXME this can overflow - break; - next_point= &(*next_point)->next; - } - this_pktl->next= *next_point; - *next_point= this_pktl; + ff_interleave_add_packet(s, pkt, ff_interleave_compare_dts); } memset(streams, 0, sizeof(streams));
bcoudurier <subversion <at> mplayerhq.hu> writes:
Author: bcoudurier Date: Sat Jan 31 07:01:58 2009 New Revision: 16884 [...] +void ff_interleave_add_packet(
While there is no header declaration for this function, it is used in mxfenc.c and oggenc.c (This is part of issue823) Carl Eugen
Hi Carl Eugen, On 2/6/2009 7:49 AM, Carl Eugen Hoyos wrote:
bcoudurier <subversion <at> mplayerhq.hu> writes:
Author: bcoudurier Date: Sat Jan 31 07:01:58 2009 New Revision: 16884 [...] +void ff_interleave_add_packet(
While there is no header declaration for this function, it is used in mxfenc.c and oggenc.c (This is part of issue823)
True, in the mean time, should we declare it in avcodec.h ? -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no FFmpeg maintainer http://www.ffmpeg.org
On Fri, Feb 06, 2009 at 03:49:38PM +0000, Carl Eugen Hoyos wrote:
bcoudurier <subversion <at> mplayerhq.hu> writes:
[...]
+void ff_interleave_add_packet(
While there is no header declaration for this function, it is used in mxfenc.c and oggenc.c (This is part of issue823)
Yes, please fix this ugly warning before the release :) Diego
Diego Biurrun wrote:
On Fri, Feb 06, 2009 at 03:49:38PM +0000, Carl Eugen Hoyos wrote:
bcoudurier <subversion <at> mplayerhq.hu> writes:
[...]
+void ff_interleave_add_packet( While there is no header declaration for this function, it is used in mxfenc.c and oggenc.c (This is part of issue823)
Yes, please fix this ugly warning before the release :)
I declared it in avformat.h -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no FFmpeg maintainer http://www.ffmpeg.org
participants (4)
-
baptiste.coudurier@gmail.com -
cehoyos@ag.or.at -
diego@biurrun.de -
subversion@mplayerhq.hu