Generic retime functionality is replaced by a few lines of code directly in the muxers which used it, which seems a lot easier to understand and this way the retiming is not dependant of the input durations.
Signed-off-by: Marton Balint <c...@passwd.hu> --- libavformat/Makefile | 4 ++-- libavformat/gxfenc.c | 21 ++++++++++++++------- libavformat/mxfenc.c | 14 +++++++++----- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 56ca55fbd5..0a2edffc86 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -205,7 +205,7 @@ OBJS-$(CONFIG_GIF_DEMUXER) += gifdec.o OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o OBJS-$(CONFIG_GSM_MUXER) += rawenc.o OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o -OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o retimeinterleave.o +OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o OBJS-$(CONFIG_G722_DEMUXER) += g722.o rawdec.o OBJS-$(CONFIG_G722_MUXER) += rawenc.o OBJS-$(CONFIG_G723_1_DEMUXER) += g723_1.o @@ -347,7 +347,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER) += musx.o OBJS-$(CONFIG_MV_DEMUXER) += mvdec.o OBJS-$(CONFIG_MVI_DEMUXER) += mvi.o OBJS-$(CONFIG_MXF_DEMUXER) += mxfdec.o mxf.o -OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o retimeinterleave.o avc.o +OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o avc.o OBJS-$(CONFIG_MXG_DEMUXER) += mxg.o OBJS-$(CONFIG_NC_DEMUXER) += ncdec.o OBJS-$(CONFIG_NISTSPHERE_DEMUXER) += nistspheredec.o pcm.o diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 60468c36ce..6d4df894f6 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -27,7 +27,6 @@ #include "avformat.h" #include "internal.h" #include "gxf.h" -#include "retimeinterleave.h" #define GXF_SAMPLES_PER_FRAME 32768 #define GXF_AUDIO_PACKET_SIZE 65536 @@ -45,7 +44,7 @@ typedef struct GXFTimecode{ } GXFTimecode; typedef struct GXFStreamContext { - RetimeInterleaveContext aic; + int64_t pkt_cnt; uint32_t track_type; uint32_t sample_size; uint32_t sample_rate; @@ -815,7 +814,6 @@ static int gxf_write_header(AVFormatContext *s) return -1; } } - ff_retime_interleave_init(&sc->aic, st->time_base); /* FIXME first 10 audio tracks are 0 to 9 next 22 are A to V */ sc->media_info = media_info<<8 | ('0'+tracks[media_info]++); sc->order = s->nb_streams - st->index; @@ -1012,10 +1010,19 @@ static int gxf_compare_field_nb(AVFormatContext *s, const AVPacket *next, static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush) { - if (pkt && s->streams[pkt->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) - pkt->duration = 2; // enforce 2 fields - return ff_retime_interleave(s, out, pkt, flush, - ff_interleave_packet_per_dts, gxf_compare_field_nb); + int ret; + if (pkt) { + AVStream *st = s->streams[pkt->stream_index]; + GXFStreamContext *sc = st->priv_data; + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) + pkt->pts = pkt->dts = sc->pkt_cnt * 2; // enforce 2 fields + else + pkt->pts = pkt->dts = sc->pkt_cnt * GXF_SAMPLES_PER_FRAME; + sc->pkt_cnt++; + if ((ret = ff_interleave_add_packet(s, pkt, gxf_compare_field_nb)) < 0) + return ret; + } + return ff_interleave_packet_per_dts(s, out, NULL, flush); } AVOutputFormat ff_gxf_muxer = { diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 63a2799b08..c3b6809e98 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -52,7 +52,6 @@ #include "libavcodec/h264_ps.h" #include "libavcodec/golomb.h" #include "libavcodec/internal.h" -#include "retimeinterleave.h" #include "avformat.h" #include "avio_internal.h" #include "internal.h" @@ -79,7 +78,7 @@ typedef struct MXFIndexEntry { } MXFIndexEntry; typedef struct MXFStreamContext { - RetimeInterleaveContext aic; + int64_t pkt_cnt; ///< pkt counter for muxed packets UID track_essence_element_key; int index; ///< index in mxf_essence_container_uls table const UID *codec_ul; @@ -2598,7 +2597,6 @@ static int mxf_write_header(AVFormatContext *s) return -1; } } - ff_retime_interleave_init(&sc->aic, av_inv_q(mxf->tc.rate)); if (sc->index == -1) { sc->index = mxf_get_essence_container_ul_index(st->codecpar->codec_id); @@ -3087,8 +3085,14 @@ static int mxf_compare_timestamps(AVFormatContext *s, const AVPacket *next, static int mxf_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush) { - return ff_retime_interleave(s, out, pkt, flush, - mxf_interleave_get_packet, mxf_compare_timestamps); + int ret; + if (pkt) { + MXFStreamContext *sc = s->streams[pkt->stream_index]->priv_data; + pkt->pts = pkt->dts = sc->pkt_cnt++; + if ((ret = ff_interleave_add_packet(s, pkt, mxf_compare_timestamps)) < 0) + return ret; + } + return mxf_interleave_get_packet(s, out, NULL, flush); } #define MXF_COMMON_OPTIONS \ -- 2.16.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".