[FFmpeg-devel] [PATCH v2 4/5] avformat/wavdec: s337m support
Nicolas Gaullier
nicolas.gaullier at arkena.com
Tue Aug 6 14:50:43 EEST 2019
Enabled by AVOption dolbyeprobe
Requires stereo
---
libavformat/s337m.h | 1 +
libavformat/wavdec.c | 41 ++++++++++++++++++++++++++++++++++-------
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/libavformat/s337m.h b/libavformat/s337m.h
index bfe2a5d457..0c3fbf1990 100644
--- a/libavformat/s337m.h
+++ b/libavformat/s337m.h
@@ -32,6 +32,7 @@
#define S337M_MIN_OFFSET 1601*4
#define S337M_MAX_OFFSET 2002*6
+#define S337M_MAX_RECOMMENDED_PROBE_SIZE 2*S337M_MAX_OFFSET
#define S337M_PHASE_PROBE_MIN 0.000000
#define DOLBY_E_PHASE_MIN 0.000610
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 52194f54ef..fdcd7233f7 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -41,6 +41,9 @@
#include "riff.h"
#include "w64.h"
#include "spdif.h"
+#if CONFIG_S337M_DEMUXER
+#include "s337m.h"
+#endif
typedef struct WAVDemuxContext {
const AVClass *class;
@@ -59,6 +62,9 @@ typedef struct WAVDemuxContext {
int smv_given_first;
int unaligned; // e.g. if an odd number of bytes ID3 tag was prepended
int rifx; // RIFX: integer byte order for parameters is big endian
+#if CONFIG_S337M_DEMUXER
+ int dolby_e_probe;
+#endif
} WAVDemuxContext;
static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
@@ -593,6 +599,10 @@ 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 CONFIG_S337M_DEMUXER
+ if (wav->dolby_e_probe)
+ avpriv_s337m_probe_stream((void *)s, s->pb, &st, FFMIN(S337M_MAX_RECOMMENDED_PROBE_SIZE, wav->data_end - avio_tell(pb)));
+#endif
ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
@@ -701,14 +711,24 @@ smv_out:
wav->data_end = avio_tell(s->pb) + left;
}
- size = MAX_SIZE;
- if (st->codecpar->block_align > 1) {
- if (size < st->codecpar->block_align)
- size = st->codecpar->block_align;
- size = (size / st->codecpar->block_align) * st->codecpar->block_align;
+#if CONFIG_S337M_DEMUXER
+ if (st->codecpar->codec_id != AV_CODEC_ID_DOLBY_E) {
+#endif
+ size = MAX_SIZE;
+ if (st->codecpar->block_align > 1) {
+ if (size < st->codecpar->block_align)
+ size = st->codecpar->block_align;
+ size = (size / st->codecpar->block_align) * st->codecpar->block_align;
+ }
+ size = FFMIN(size, left);
+ ret = av_get_packet(s->pb, pkt, size);
+#if CONFIG_S337M_DEMUXER
+ } else {
+ size = FFMIN(S337M_MAX_RECOMMENDED_PROBE_SIZE, left);
+ ret = avpriv_s337m_get_packet((void *)s, s->pb, pkt, size, 0);
}
- size = FFMIN(size, left);
- ret = av_get_packet(s->pb, pkt, size);
+#endif
+
if (ret < 0)
return ret;
pkt->stream_index = 0;
@@ -754,6 +774,9 @@ static int wav_read_seek(AVFormatContext *s,
#define DEC AV_OPT_FLAG_DECODING_PARAM
static const AVOption demux_options[] = {
{ "ignore_length", "Ignore length", OFFSET(ignore_length), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
+#if CONFIG_S337M_DEMUXER
+ {"dolbyeprobe", "probe Dolby E in pcm/stereo streams", OFFSET(dolby_e_probe), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC },
+#endif
{ NULL },
};
@@ -895,6 +918,10 @@ static int w64_read_header(AVFormatContext *s)
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
avio_seek(pb, data_ofs, SEEK_SET);
+#if CONFIG_S337M_DEMUXER
+ if (wav->dolby_e_probe)
+ avpriv_s337m_probe_stream((void *)s, s->pb, &st, FFMIN(S337M_MAX_RECOMMENDED_PROBE_SIZE, wav->data_end - avio_tell(pb)));
+#endif
set_spdif(s, wav);
--
2.14.1.windows.1
More information about the ffmpeg-devel
mailing list