From patchwork Thu Mar 5 21:56:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18056 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5E0DC44AB1F for ; Thu, 5 Mar 2020 23:56:41 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 38A1E6897D6; Thu, 5 Mar 2020 23:56:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E72F6897CD for ; Thu, 5 Mar 2020 23:56:35 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 419FBE3947; Thu, 5 Mar 2020 22:56:35 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 46AKO7jE-J-V; Thu, 5 Mar 2020 22:56:33 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0BEBEE333E; Thu, 5 Mar 2020 22:56:33 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Mar 2020 22:56:22 +0100 Message-Id: <20200305215628.19514-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH v2 1/7] avformat/audiointerleave: disallow using a samples_per_frame array X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Only MXF used an actual sample array, and that is unneeded there because simple rounding rules can be used instead. Signed-off-by: Marton Balint --- libavformat/audiointerleave.c | 24 +++++++++++------------- libavformat/audiointerleave.h | 7 ++++--- libavformat/gxfenc.c | 2 +- libavformat/mxfenc.c | 7 ++----- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c index 6797546a44..2e83031bd6 100644 --- a/libavformat/audiointerleave.c +++ b/libavformat/audiointerleave.c @@ -39,14 +39,11 @@ void ff_audio_interleave_close(AVFormatContext *s) } int ff_audio_interleave_init(AVFormatContext *s, - const int *samples_per_frame, + const int samples_per_frame, AVRational time_base) { int i; - if (!samples_per_frame) - return AVERROR(EINVAL); - if (!time_base.num) { av_log(s, AV_LOG_ERROR, "timebase not set for audio interleave\n"); return AVERROR(EINVAL); @@ -56,6 +53,8 @@ int ff_audio_interleave_init(AVFormatContext *s, AudioInterleaveContext *aic = st->priv_data; if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + int max_samples = samples_per_frame ? samples_per_frame : + av_rescale_rnd(st->codecpar->sample_rate, time_base.num, time_base.den, AV_ROUND_UP); aic->sample_size = (st->codecpar->channels * av_get_bits_per_sample(st->codecpar->codec_id)) / 8; if (!aic->sample_size) { @@ -63,12 +62,11 @@ int ff_audio_interleave_init(AVFormatContext *s, return AVERROR(EINVAL); } aic->samples_per_frame = samples_per_frame; - aic->samples = aic->samples_per_frame; aic->time_base = time_base; - aic->fifo_size = 100* *aic->samples; - if (!(aic->fifo= av_fifo_alloc_array(100, *aic->samples))) + if (!(aic->fifo = av_fifo_alloc_array(100, max_samples))) return AVERROR(ENOMEM); + aic->fifo_size = 100 * max_samples; } } @@ -81,7 +79,9 @@ static int interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st = s->streams[stream_index]; AudioInterleaveContext *aic = st->priv_data; int ret; - int frame_size = *aic->samples * aic->sample_size; + int nb_samples = aic->samples_per_frame ? aic->samples_per_frame : + (av_rescale_q(aic->n + 1, av_make_q(st->codecpar->sample_rate, 1), av_inv_q(aic->time_base)) - aic->nb_samples); + int frame_size = nb_samples * aic->sample_size; int size = FFMIN(av_fifo_size(aic->fifo), frame_size); if (!size || (!flush && size == av_fifo_size(aic->fifo))) return 0; @@ -95,13 +95,11 @@ static int interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt, memset(pkt->data + size, 0, pkt->size - size); pkt->dts = pkt->pts = aic->dts; - pkt->duration = av_rescale_q(*aic->samples, st->time_base, aic->time_base); + pkt->duration = av_rescale_q(nb_samples, st->time_base, aic->time_base); pkt->stream_index = stream_index; aic->dts += pkt->duration; - - aic->samples++; - if (!*aic->samples) - aic->samples = aic->samples_per_frame; + aic->nb_samples += nb_samples; + aic->n++; return pkt->size; } diff --git a/libavformat/audiointerleave.h b/libavformat/audiointerleave.h index f28d5fefcc..0933310f4c 100644 --- a/libavformat/audiointerleave.h +++ b/libavformat/audiointerleave.h @@ -29,14 +29,15 @@ typedef struct AudioInterleaveContext { AVFifoBuffer *fifo; unsigned fifo_size; ///< size of currently allocated FIFO + int64_t n; ///< number of generated packets + int64_t nb_samples; ///< number of generated samples uint64_t dts; ///< current dts int sample_size; ///< size of one sample all channels included - const int *samples_per_frame; ///< must be 0-terminated - const int *samples; ///< current samples per frame, pointer to samples_per_frame + int samples_per_frame; ///< samples per frame if fixed, 0 otherwise AVRational time_base; ///< time base of output audio packets } AudioInterleaveContext; -int ff_audio_interleave_init(AVFormatContext *s, const int *samples_per_frame, AVRational time_base); +int ff_audio_interleave_init(AVFormatContext *s, const int samples_per_frame, AVRational time_base); void ff_audio_interleave_close(AVFormatContext *s); /** diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 9eebefc683..e7536a6a7e 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -663,7 +663,7 @@ static int gxf_write_umf_packet(AVFormatContext *s) return updatePacketSize(pb, pos); } -static const int GXF_samples_per_frame[] = { 32768, 0 }; +static const int GXF_samples_per_frame = 32768; static void gxf_init_timecode_track(GXFStreamContext *sc, GXFStreamContext *vsc) { diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 5e0dc0e889..bf7abe4f1c 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1747,7 +1747,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s) avio_wb32(pb, KAG_SIZE); // system item size including klv fill } else { // audio or data track if (!audio_frame_size) { - audio_frame_size = sc->aic.samples[0]*sc->aic.sample_size; + audio_frame_size = sc->frame_size; audio_frame_size += klv_fill_size(audio_frame_size); } avio_w8(pb, 1); @@ -2650,10 +2650,7 @@ static int mxf_write_header(AVFormatContext *s) return AVERROR(ENOMEM); mxf->timecode_track->index = -1; - if (!spf) - spf = ff_mxf_get_samples_per_frame(s, (AVRational){ 1, 25 }); - - if (ff_audio_interleave_init(s, spf->samples_per_frame, mxf->time_base) < 0) + if (ff_audio_interleave_init(s, 0, av_inv_q(mxf->tc.rate)) < 0) return -1; return 0; From patchwork Thu Mar 5 21:56:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18057 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 333DC44AB1F for ; Thu, 5 Mar 2020 23:56:44 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1666968ABC2; Thu, 5 Mar 2020 23:56:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1C66768ABAC for ; Thu, 5 Mar 2020 23:56:37 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 004B7E3AEF; Thu, 5 Mar 2020 22:56:37 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Dr962EBeyJPZ; Thu, 5 Mar 2020 22:56:35 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5A18DE333E; Thu, 5 Mar 2020 22:56:35 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Mar 2020 22:56:23 +0100 Message-Id: <20200305215628.19514-2-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200305215628.19514-1-cus@passwd.hu> References: <20200305215628.19514-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 2/7] avformat/mxf: get rid of samples per frame array usage X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/mxf.c | 44 ++++---------------------------------------- libavformat/mxf.h | 6 ------ libavformat/mxfdec.c | 23 +++-------------------- libavformat/mxfenc.c | 22 ++++++++++------------ 4 files changed, 17 insertions(+), 78 deletions(-) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 451cbcfb2c..10ccd770e3 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -131,16 +131,6 @@ int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat * return -1; } -static const MXFSamplesPerFrame mxf_spf[] = { - { { 1001, 24000 }, { 2002, 0, 0, 0, 0, 0 } }, // FILM 23.976 - { { 1, 24}, { 2000, 0, 0, 0, 0, 0 } }, // FILM 24 - { { 1001, 30000 }, { 1602, 1601, 1602, 1601, 1602, 0 } }, // NTSC 29.97 - { { 1001, 60000 }, { 801, 801, 800, 801, 801, 0 } }, // NTSC 59.94 - { { 1, 25 }, { 1920, 0, 0, 0, 0, 0 } }, // PAL 25 - { { 1, 50 }, { 960, 0, 0, 0, 0, 0 } }, // PAL 50 - { { 1, 60 }, { 800, 0, 0, 0, 0, 0 } }, -}; - static const AVRational mxf_time_base[] = { { 1001, 24000 }, { 1, 24}, @@ -152,40 +142,14 @@ static const AVRational mxf_time_base[] = { { 0, 0} }; -const MXFSamplesPerFrame *ff_mxf_get_samples_per_frame(AVFormatContext *s, - AVRational time_base) -{ - int idx = av_find_nearest_q_idx(time_base, mxf_time_base); - AVRational diff = av_sub_q(time_base, mxf_time_base[idx]); - - diff.num = FFABS(diff.num); - - if (av_cmp_q(diff, (AVRational){1, 1000}) >= 0) - return NULL; - - if (av_cmp_q(time_base, mxf_time_base[idx])) - av_log(s, AV_LOG_WARNING, - "%d/%d input time base matched %d/%d container time base\n", - time_base.num, time_base.den, - mxf_spf[idx].time_base.num, - mxf_spf[idx].time_base.den); - - return &mxf_spf[idx]; -} - static const int mxf_content_package_rates[] = { 3, 2, 7, 13, 4, 10, 12, }; int ff_mxf_get_content_package_rate(AVRational time_base) { - int idx = av_find_nearest_q_idx(time_base, mxf_time_base); - AVRational diff = av_sub_q(time_base, mxf_time_base[idx]); - - diff.num = FFABS(diff.num); - - if (av_cmp_q(diff, (AVRational){1, 1000}) >= 0) - return -1; - - return mxf_content_package_rates[idx]; + for (int i = 0; mxf_time_base[i].num; i++) + if (!av_cmp_q(time_base, mxf_time_base[i])) + return mxf_content_package_rates[i]; + return 0; } diff --git a/libavformat/mxf.h b/libavformat/mxf.h index f32124f772..2669269830 100644 --- a/libavformat/mxf.h +++ b/libavformat/mxf.h @@ -82,18 +82,12 @@ typedef struct MXFCodecUL { MXFWrappingIndicatorType wrapping_indicator_type; } MXFCodecUL; -typedef struct { - struct AVRational time_base; - int samples_per_frame[6]; -} MXFSamplesPerFrame; - extern const MXFCodecUL ff_mxf_data_definition_uls[]; extern const MXFCodecUL ff_mxf_codec_uls[]; extern const MXFCodecUL ff_mxf_pixel_format_uls[]; extern const MXFCodecUL ff_mxf_codec_tag_uls[]; int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *pix_fmt); -const MXFSamplesPerFrame *ff_mxf_get_samples_per_frame(AVFormatContext *s, AVRational time_base); int ff_mxf_get_content_package_rate(AVRational time_base); diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 9a48e2d2d1..9113e2a09c 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3307,20 +3307,17 @@ static int mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_ static int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream *st, int64_t edit_unit) { - int i, total = 0, size = 0; MXFTrack *track = st->priv_data; AVRational time_base = av_inv_q(track->edit_rate); AVRational sample_rate = av_inv_q(st->time_base); - const MXFSamplesPerFrame *spf = NULL; - int64_t sample_count; // For non-audio sample_count equals current edit unit if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) return edit_unit; - if ((sample_rate.num / sample_rate.den) == 48000) - spf = ff_mxf_get_samples_per_frame(mxf->fc, time_base); - if (!spf) { + if ((sample_rate.num / sample_rate.den) == 48000) { + return av_rescale_q(edit_unit, sample_rate, track->edit_rate); + } else { int remainder = (sample_rate.num * time_base.num) % (time_base.den * sample_rate.den); if (remainder) @@ -3331,20 +3328,6 @@ static int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream *st, sample_rate.num, sample_rate.den); return av_rescale_q(edit_unit, sample_rate, track->edit_rate); } - - while (spf->samples_per_frame[size]) { - total += spf->samples_per_frame[size]; - size++; - } - - av_assert2(size); - - sample_count = (edit_unit / size) * (uint64_t)total; - for (i = 0; i < edit_unit % size; i++) { - sample_count += spf->samples_per_frame[i]; - } - - return sample_count; } /** diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index bf7abe4f1c..93d840ebbf 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -2425,7 +2425,6 @@ static int mxf_write_header(AVFormatContext *s) MXFContext *mxf = s->priv_data; int i, ret; uint8_t present[FF_ARRAY_ELEMS(mxf_essence_container_uls)] = {0}; - const MXFSamplesPerFrame *spf = NULL; int64_t timestamp = 0; if (!s->nb_streams) @@ -2479,15 +2478,14 @@ static int mxf_write_header(AVFormatContext *s) case AVCHROMA_LOC_CENTER: sc->color_siting = 3; break; } - mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num; - spf = ff_mxf_get_samples_per_frame(s, tbc); - if (!spf) { + mxf->content_package_rate = ff_mxf_get_content_package_rate(tbc); + if (!mxf->content_package_rate) { av_log(s, AV_LOG_ERROR, "Unsupported video frame rate %d/%d\n", tbc.den, tbc.num); return AVERROR(EINVAL); } - mxf->content_package_rate = ff_mxf_get_content_package_rate(tbc); - mxf->time_base = spf->time_base; + mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num; + mxf->time_base = tbc; rate = av_inv_q(mxf->time_base); avpriv_set_pts_info(st, 64, mxf->time_base.num, mxf->time_base.den); if((ret = mxf_init_timecode(s, st, rate)) < 0) @@ -2552,7 +2550,7 @@ static int mxf_write_header(AVFormatContext *s) } sc->index = INDEX_D10_AUDIO; sc->container_ul = ((MXFStreamContext*)s->streams[0]->priv_data)->container_ul; - sc->frame_size = 4 + 8 * spf[0].samples_per_frame[0] * 4; + sc->frame_size = 4 + 8 * av_rescale_rnd(st->codecpar->sample_rate, mxf->time_base.num, mxf->time_base.den, AV_ROUND_UP) * 4; } else if (s->oformat == &ff_mxf_opatom_muxer) { AVRational tbc = av_inv_q(mxf->audio_edit_rate); @@ -2566,14 +2564,13 @@ static int mxf_write_header(AVFormatContext *s) return AVERROR(EINVAL); } - spf = ff_mxf_get_samples_per_frame(s, tbc); - if (!spf) { + if (!ff_mxf_get_content_package_rate(tbc)) { av_log(s, AV_LOG_ERROR, "Unsupported timecode frame rate %d/%d\n", tbc.den, tbc.num); return AVERROR(EINVAL); } mxf->time_base = st->time_base; - if((ret = mxf_init_timecode(s, st, av_inv_q(spf->time_base))) < 0) + if((ret = mxf_init_timecode(s, st, av_inv_q(tbc))) < 0) return ret; mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num; @@ -2581,8 +2578,9 @@ static int mxf_write_header(AVFormatContext *s) sc->index = INDEX_WAV; } else { mxf->slice_count = 1; - sc->frame_size = (st->codecpar->channels * spf[0].samples_per_frame[0] * - av_get_bits_per_sample(st->codecpar->codec_id)) / 8; + sc->frame_size = st->codecpar->channels * + av_rescale_rnd(st->codecpar->sample_rate, mxf->time_base.num, mxf->time_base.den, AV_ROUND_UP) * + av_get_bits_per_sample(st->codecpar->codec_id) / 8; } } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { AVDictionaryEntry *e = av_dict_get(st->metadata, "data_type", NULL, 0); From patchwork Thu Mar 5 21:56:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18058 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 256D144AB1F for ; Thu, 5 Mar 2020 23:56:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0836A68ABF7; Thu, 5 Mar 2020 23:56:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9654868ABE7 for ; Thu, 5 Mar 2020 23:56:39 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5CACEE333E; Thu, 5 Mar 2020 22:56:39 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xEMZuRGMg0JM; Thu, 5 Mar 2020 22:56:38 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 11884E3953; Thu, 5 Mar 2020 22:56:37 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Mar 2020 22:56:24 +0100 Message-Id: <20200305215628.19514-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200305215628.19514-1-cus@passwd.hu> References: <20200305215628.19514-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 3/7] avformat/mxfenc: move content package rates and timebase combinations to a separate struct X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/mxf.c | 32 ++++++++++++++++---------------- libavformat/mxf.h | 5 +++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 10ccd770e3..80626e2a16 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -131,25 +131,25 @@ int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat * return -1; } -static const AVRational mxf_time_base[] = { - { 1001, 24000 }, - { 1, 24}, - { 1001, 30000 }, - { 1001, 60000 }, - { 1, 25 }, - { 1, 50 }, - { 1, 60 }, - { 0, 0} -}; - -static const int mxf_content_package_rates[] = { - 3, 2, 7, 13, 4, 10, 12, +/** + * See SMPTE 326M-2000 Section 7.2 Content package rate + * MXFContentPackageRate->rate is bits b5..b0. + */ +static const MXFContentPackageRate mxf_content_package_rates[] = { + { 2, { 1, 24 } }, + { 3, { 1001, 24000 } }, + { 4, { 1, 25 } }, + { 7, { 1001, 30000 } }, + { 10, { 1, 50 } }, + { 12, { 1, 60 } }, + { 13, { 1001, 60000 } }, + {0} }; int ff_mxf_get_content_package_rate(AVRational time_base) { - for (int i = 0; mxf_time_base[i].num; i++) - if (!av_cmp_q(time_base, mxf_time_base[i])) - return mxf_content_package_rates[i]; + for (int i = 0; mxf_content_package_rates[i].rate; i++) + if (!av_cmp_q(time_base, mxf_content_package_rates[i].tb)) + return mxf_content_package_rates[i].rate; return 0; } diff --git a/libavformat/mxf.h b/libavformat/mxf.h index 2669269830..f2fff2781e 100644 --- a/libavformat/mxf.h +++ b/libavformat/mxf.h @@ -59,6 +59,11 @@ enum MXFFrameLayout { SegmentedFrame, }; +typedef struct MXFContentPackageRate { + int rate; + AVRational tb; +} MXFContentPackageRate; + typedef struct KLVPacket { UID key; int64_t offset; From patchwork Thu Mar 5 21:56:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18059 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2BEAB44AB1F for ; Thu, 5 Mar 2020 23:56:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1040A68AC4C; Thu, 5 Mar 2020 23:56:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ABC8C68809B for ; Thu, 5 Mar 2020 23:56:42 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 934CEE3947; Thu, 5 Mar 2020 22:56:42 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WC9k6sgkI3Jm; Thu, 5 Mar 2020 22:56:41 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B059AE3953; Thu, 5 Mar 2020 22:56:39 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Mar 2020 22:56:25 +0100 Message-Id: <20200305215628.19514-4-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200305215628.19514-1-cus@passwd.hu> References: <20200305215628.19514-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 4/7] avformat/mxfenc: add some missing content package rates X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes ticket #8523. Signed-off-by: Marton Balint --- libavformat/mxf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libavformat/mxf.c b/libavformat/mxf.c index 80626e2a16..7d154ca9d3 100644 --- a/libavformat/mxf.c +++ b/libavformat/mxf.c @@ -139,10 +139,23 @@ static const MXFContentPackageRate mxf_content_package_rates[] = { { 2, { 1, 24 } }, { 3, { 1001, 24000 } }, { 4, { 1, 25 } }, + { 6, { 1, 30 } }, { 7, { 1001, 30000 } }, + { 8, { 1 , 48 } }, + { 9, { 1001, 48000 } }, { 10, { 1, 50 } }, { 12, { 1, 60 } }, { 13, { 1001, 60000 } }, + { 14, { 1, 72 } }, + { 15, { 1001, 72000 } }, + { 16, { 1, 75 } }, + { 18, { 1, 90 } }, + { 19, { 1001, 90000 } }, + { 20, { 1, 96 } }, + { 21, { 1001, 96000 } }, + { 22, { 1, 100 } }, + { 24, { 1, 120 } }, + { 25, { 1001, 120000} }, {0} }; From patchwork Thu Mar 5 21:56:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18060 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2768D44AB1F for ; Thu, 5 Mar 2020 23:56:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E97D68AD32; Thu, 5 Mar 2020 23:56:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3E20168AC2D for ; Thu, 5 Mar 2020 23:56:43 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 28A97E3953; Thu, 5 Mar 2020 22:56:43 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z3RuXd5APV6K; Thu, 5 Mar 2020 22:56:41 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id BDC55E3B73; Thu, 5 Mar 2020 22:56:41 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Mar 2020 22:56:26 +0100 Message-Id: <20200305215628.19514-5-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200305215628.19514-1-cus@passwd.hu> References: <20200305215628.19514-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 5/7] avformat/mxfenc: factorize timecode checking and setting X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavformat/mxfenc.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 93d840ebbf..51e2dc5f31 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -2407,17 +2407,24 @@ static void mxf_gen_umid(AVFormatContext *s) mxf->instance_number = seed & 0xFFFFFF; } -static int mxf_init_timecode(AVFormatContext *s, AVStream *st, AVRational rate) +static int mxf_init_timecode(AVFormatContext *s, AVStream *st, AVRational tbc) { MXFContext *mxf = s->priv_data; AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); + + if (!ff_mxf_get_content_package_rate(tbc)) { + av_log(s, AV_LOG_ERROR, "Unsupported frame rate %d/%d\n", tbc.den, tbc.num); + return AVERROR(EINVAL); + } + + mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num; if (!tcr) tcr = av_dict_get(st->metadata, "timecode", NULL, 0); if (tcr) - return av_timecode_init_from_string(&mxf->tc, rate, tcr->value, s); + return av_timecode_init_from_string(&mxf->tc, av_inv_q(tbc), tcr->value, s); else - return av_timecode_init(&mxf->tc, rate, 0, 0, s); + return av_timecode_init(&mxf->tc, av_inv_q(tbc), 0, 0, s); } static int mxf_write_header(AVFormatContext *s) @@ -2454,7 +2461,7 @@ static int mxf_write_header(AVFormatContext *s) if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(st->codecpar->format); // TODO: should be avg_frame_rate - AVRational rate, tbc = st->time_base; + AVRational tbc = st->time_base; // Default component depth to 8 sc->component_depth = 8; sc->h_chroma_sub_sample = 2; @@ -2479,16 +2486,9 @@ static int mxf_write_header(AVFormatContext *s) } mxf->content_package_rate = ff_mxf_get_content_package_rate(tbc); - if (!mxf->content_package_rate) { - av_log(s, AV_LOG_ERROR, "Unsupported video frame rate %d/%d\n", - tbc.den, tbc.num); - return AVERROR(EINVAL); - } - mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num; mxf->time_base = tbc; - rate = av_inv_q(mxf->time_base); avpriv_set_pts_info(st, 64, mxf->time_base.num, mxf->time_base.den); - if((ret = mxf_init_timecode(s, st, rate)) < 0) + if((ret = mxf_init_timecode(s, st, tbc)) < 0) return ret; if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO) { @@ -2564,16 +2564,10 @@ static int mxf_write_header(AVFormatContext *s) return AVERROR(EINVAL); } - if (!ff_mxf_get_content_package_rate(tbc)) { - av_log(s, AV_LOG_ERROR, "Unsupported timecode frame rate %d/%d\n", tbc.den, tbc.num); - return AVERROR(EINVAL); - } - mxf->time_base = st->time_base; - if((ret = mxf_init_timecode(s, st, av_inv_q(tbc))) < 0) + if((ret = mxf_init_timecode(s, st, tbc)) < 0) return ret; - mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num; mxf->edit_unit_byte_count = (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3; sc->index = INDEX_WAV; } else { From patchwork Thu Mar 5 21:56:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18062 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 06D9A44AB1F for ; Thu, 5 Mar 2020 23:56:53 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E9A8668ADC8; Thu, 5 Mar 2020 23:56:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1C0EC68AD7C for ; Thu, 5 Mar 2020 23:56:47 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0722DE333E; Thu, 5 Mar 2020 22:56:47 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nT8yVameCW2D; Thu, 5 Mar 2020 22:56:45 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 6B431E39CF; Thu, 5 Mar 2020 22:56:45 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Mar 2020 22:56:27 +0100 Message-Id: <20200305215628.19514-6-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200305215628.19514-1-cus@passwd.hu> References: <20200305215628.19514-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 6/7] avformat/mxfenc: allow all frame rates if -strict mode is set to unofficial or lower X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" There was no consensus wheter or not to allow unofficial frame rates due to possible interoperability issues, a compromise is to only allow it if -strict mode is set to unofficial. Signed-off-by: Marton Balint --- libavformat/mxfenc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 51e2dc5f31..6279ba9d6d 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -2413,8 +2413,12 @@ static int mxf_init_timecode(AVFormatContext *s, AVStream *st, AVRational tbc) AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); if (!ff_mxf_get_content_package_rate(tbc)) { - av_log(s, AV_LOG_ERROR, "Unsupported frame rate %d/%d\n", tbc.den, tbc.num); - return AVERROR(EINVAL); + if (s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { + av_log(s, AV_LOG_ERROR, "Unsupported frame rate %d/%d. Set -strict option to 'unofficial' or lower in order to allow it!\n", tbc.den, tbc.num); + return AVERROR(EINVAL); + } else { + av_log(s, AV_LOG_WARNING, "Unofficial frame rate %d/%d.\n", tbc.den, tbc.num); + } } mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num; From patchwork Thu Mar 5 21:56:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18061 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1649A44AB1F for ; Thu, 5 Mar 2020 23:56:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 053B568AD52; Thu, 5 Mar 2020 23:56:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1492168ACBF for ; Thu, 5 Mar 2020 23:56:49 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F00E2E3947; Thu, 5 Mar 2020 22:56:48 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hGSLe4ZJ9Jya; Thu, 5 Mar 2020 22:56:47 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 6EA82E39CF; Thu, 5 Mar 2020 22:56:47 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Mar 2020 22:56:28 +0100 Message-Id: <20200305215628.19514-7-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200305215628.19514-1-cus@passwd.hu> References: <20200305215628.19514-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH v2 7/7] avformat/audiointerleave: use a fixed frame duration for non-audio packets X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The packet durations might not be set properly which can cause the MXF muxer to write more than one packet of a stream to an edit unit messing up the constant byte per element index... Also use nb_samples directly to calculate dts of audio packets because adding packet durations might not be precise. Signed-off-by: Marton Balint --- libavformat/audiointerleave.c | 12 +++++++++--- libavformat/audiointerleave.h | 3 ++- libavformat/gxfenc.c | 2 +- libavformat/mxfenc.c | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c index 2e83031bd6..0643159770 100644 --- a/libavformat/audiointerleave.c +++ b/libavformat/audiointerleave.c @@ -40,6 +40,7 @@ void ff_audio_interleave_close(AVFormatContext *s) int ff_audio_interleave_init(AVFormatContext *s, const int samples_per_frame, + const int frame_duration, AVRational time_base) { int i; @@ -48,6 +49,10 @@ int ff_audio_interleave_init(AVFormatContext *s, av_log(s, AV_LOG_ERROR, "timebase not set for audio interleave\n"); return AVERROR(EINVAL); } + if (!frame_duration) { + av_log(s, AV_LOG_ERROR, "frame_duration not set for audio interleave\n"); + return AVERROR(EINVAL); + } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; AudioInterleaveContext *aic = st->priv_data; @@ -67,6 +72,8 @@ int ff_audio_interleave_init(AVFormatContext *s, if (!(aic->fifo = av_fifo_alloc_array(100, max_samples))) return AVERROR(ENOMEM); aic->fifo_size = 100 * max_samples; + } else { + aic->frame_duration = frame_duration; } } @@ -94,10 +101,9 @@ static int interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt, if (size < pkt->size) memset(pkt->data + size, 0, pkt->size - size); - pkt->dts = pkt->pts = aic->dts; + pkt->dts = pkt->pts = av_rescale_q(aic->nb_samples, st->time_base, aic->time_base); pkt->duration = av_rescale_q(nb_samples, st->time_base, aic->time_base); pkt->stream_index = stream_index; - aic->dts += pkt->duration; aic->nb_samples += nb_samples; aic->n++; @@ -124,7 +130,7 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt } else { // rewrite pts and dts to be decoded time line position pkt->pts = pkt->dts = aic->dts; - aic->dts += pkt->duration; + aic->dts += aic->frame_duration; if ((ret = ff_interleave_add_packet(s, pkt, compare_ts)) < 0) return ret; } diff --git a/libavformat/audiointerleave.h b/libavformat/audiointerleave.h index 0933310f4c..0c284dedb6 100644 --- a/libavformat/audiointerleave.h +++ b/libavformat/audiointerleave.h @@ -34,10 +34,11 @@ typedef struct AudioInterleaveContext { uint64_t dts; ///< current dts int sample_size; ///< size of one sample all channels included int samples_per_frame; ///< samples per frame if fixed, 0 otherwise + int frame_duration; ///< frame duration for non-audio data AVRational time_base; ///< time base of output audio packets } AudioInterleaveContext; -int ff_audio_interleave_init(AVFormatContext *s, const int samples_per_frame, AVRational time_base); +int ff_audio_interleave_init(AVFormatContext *s, const int samples_per_frame, const int frame_duration, AVRational time_base); void ff_audio_interleave_close(AVFormatContext *s); /** diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index e7536a6a7e..552cc57a3f 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -818,7 +818,7 @@ static int gxf_write_header(AVFormatContext *s) sc->order = s->nb_streams - st->index; } - if (ff_audio_interleave_init(s, GXF_samples_per_frame, (AVRational){ 1, 48000 }) < 0) + if (ff_audio_interleave_init(s, GXF_samples_per_frame, 2, (AVRational){ 1, 48000 }) < 0) return -1; if (tcr && vsc) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 6279ba9d6d..ac409d9ccf 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -2646,7 +2646,7 @@ static int mxf_write_header(AVFormatContext *s) return AVERROR(ENOMEM); mxf->timecode_track->index = -1; - if (ff_audio_interleave_init(s, 0, av_inv_q(mxf->tc.rate)) < 0) + if (ff_audio_interleave_init(s, 0, 1, av_inv_q(mxf->tc.rate)) < 0) return -1; return 0;