From patchwork Fri Jul 26 16:45:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaullier Nicolas X-Patchwork-Id: 14088 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 B61C2449EBD for ; Fri, 26 Jul 2019 19:45:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A3BB368AC9A; Fri, 26 Jul 2019 19:45:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp-2.arkena.net (smtp-2.arkena.net [95.81.173.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 207E268AC68 for ; Fri, 26 Jul 2019 19:45:22 +0300 (EEST) Received: from secu2 (unknown [10.180.103.10]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-2.arkena.net (Postfix) with ESMTPSA id 45wFLn5F1gzHh91; Fri, 26 Jul 2019 16:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arkena.com; s=20150421; t=1564159521; bh=ScO57zCPR2P50QZTFnkFerpbDNEfdKirUEuzJJPR+NA=; h=From:To:Cc:Subject:Date:Message-Id; b=MXRHBDM/+BP5L4kmnvA46PfMOtWcrbHg9bwyhUM7WSDhayYsfADec+Wh7rH+Nrsi6 DDpU4ulIGxjdj7x3cMiH2I9TW6Yv59IcZa9ktRm6aio6RD3FUguSzOyy2lV5NLb3ge QzOKx64dEbituPi9LEWCpHPejWhEI5qLMNYBVBgk= Received: from arkena.com (unknown [172.16.3.159]) by secu2 (Postfix) with ESMTP id 4DD6F3FA6D; Fri, 26 Jul 2019 18:23:12 +0200 (CEST) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Jul 2019 18:45:16 +0200 Message-Id: <20190726164517.8428-3-nicolas.gaullier@arkena.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20190726164517.8428-1-nicolas.gaullier@arkena.com> References: <20190726164517.8428-1-nicolas.gaullier@arkena.com> Subject: [FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64 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: Nicolas Gaullier MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/avformat.h | 7 +++++++ libavformat/mxfdec.c | 20 +++++++++++++++++++- libavformat/options_table.h | 1 + libavformat/wavdec.c | 7 ++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6eb329f13f..42bb094d81 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1951,6 +1951,13 @@ typedef struct AVFormatContext { * - decoding: set by user */ int skip_estimate_duration_from_pts; + + /** + * Probe dolby_e in PCM streams + * - encoding: unused + * - decoding: set by user + */ + int dolby_e_probe; } AVFormatContext; #if FF_API_FORMAT_GET_SET diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index bb72fb9841..5b6eb9d756 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -56,6 +56,7 @@ #include "avformat.h" #include "internal.h" #include "mxf.h" +#include "s337m.h" #define MXF_MAX_CHUNK_SIZE (32 << 20) @@ -302,6 +303,8 @@ typedef struct MXFMetadataReadTableEntry { enum MXFMetadataSetType type; } MXFMetadataReadTableEntry; +static int mxf_read_packet_init = 0; +static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt); static int mxf_read_close(AVFormatContext *s); /* partial keys to match */ @@ -3247,6 +3250,19 @@ static int mxf_read_header(AVFormatContext *s) if ((ret = mxf_parse_structural_metadata(mxf)) < 0) goto fail; + if (mxf->fc->dolby_e_probe) + { + int i; + AVPacket *pkt = av_packet_alloc(); + av_init_packet(pkt); + mxf_read_packet_init = 1; + for (i = 0; i < mxf->fc->nb_streams; i++) + mxf_read_packet(mxf->fc, pkt); + mxf_read_packet_init = 0; + av_freep(pkt); + avio_seek(s->pb, essence_offset, SEEK_SET); + } + for (int i = 0; i < s->nb_streams; i++) mxf_handle_missing_index_segment(mxf, s->streams[i]); @@ -3539,7 +3555,9 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt) return ret; } } else { - ret = av_get_packet(s->pb, pkt, klv.length); + if (mxf_read_packet_init) + s337m_probe_stream(mxf->fc, &st); + ret = st->codecpar->codec_id == AV_CODEC_ID_DOLBY_E ? s337m_read_packet(s, pkt) : av_get_packet(s->pb, pkt, klv.length); if (ret < 0) { mxf->current_klv_data = (KLVPacket){{0}}; return ret; diff --git a/libavformat/options_table.h b/libavformat/options_table.h index f2f077b34f..7f3c22d6bb 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -111,6 +111,7 @@ static const AVOption avformat_options[] = { {"protocol_blacklist", "List of protocols that are not allowed to be used", OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D }, {"max_streams", "maximum number of streams", OFFSET(max_streams), AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D }, {"skip_estimate_duration_from_pts", "skip duration calculation in estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D}, +{"dolbyeprobe", "probe dolby_e in PCM streams", OFFSET(dolby_e_probe), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, D}, {NULL}, }; diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 52194f54ef..501c21f220 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -41,6 +41,7 @@ #include "riff.h" #include "w64.h" #include "spdif.h" +#include "s337m.h" typedef struct WAVDemuxContext { const AVClass *class; @@ -593,6 +594,8 @@ break_loop: } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->channels > 2) { st->codecpar->block_align *= st->codecpar->channels; } + if (s->dolby_e_probe) + s337m_probe_stream(s, &st); ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv); @@ -708,7 +711,7 @@ smv_out: size = (size / st->codecpar->block_align) * st->codecpar->block_align; } size = FFMIN(size, left); - ret = av_get_packet(s->pb, pkt, size); + ret = st->codecpar->codec_id == AV_CODEC_ID_DOLBY_E ? s337m_read_packet(s, pkt) : av_get_packet(s->pb, pkt, size); if (ret < 0) return ret; pkt->stream_index = 0; @@ -895,6 +898,8 @@ static int w64_read_header(AVFormatContext *s) st->need_parsing = AVSTREAM_PARSE_FULL_RAW; avio_seek(pb, data_ofs, SEEK_SET); + if (s->dolby_e_probe) + s337m_probe_stream(s, &st); set_spdif(s, wav);