fre 2020-01-03 klockan 16:56 +0100 skrev Nicolas Gaullier: > Similar to ff_spdif_probe() with two additionnal parameters: > - an AVClass for logging > - the bit resolution of the container as it may be 16 or 24 for s337m > --- > libavformat/s337m.c | 35 +++++++++++++++++++++++++++++++++++ > libavformat/s337m.h | 19 +++++++++++++++++++ > 2 files changed, 54 insertions(+) > > diff --git a/libavformat/s337m.c b/libavformat/s337m.c > index 5c8ab2649c..dc62d6ab98 100644 > --- a/libavformat/s337m.c > +++ b/libavformat/s337m.c > @@ -133,6 +133,41 @@ static int s337m_probe(const AVProbeData *p) > return 0; > } > > +int ff_s337m_probe(const uint8_t *buf, int size, enum AVCodecID *codec, void > *avc, int container_word_bits) > +{ > + int pos = 0; > + int consecutive_codes = 0; > + > + if ( size < S337M_MIN_OFFSET) > + return 0; > + size = FFMIN(2 * S337M_MAX_OFFSET, size); > + > + do { > + uint64_t state; > + int data_type, data_size, offset; > + while (pos < size - 12 && !buf[pos]) { > + pos++; > + } > + if (pos >= size - 12 || pos < S337M_PROBE_GUARDBAND_MIN_BYTES) > + return 0; > + state = container_word_bits == 16 ? AV_RB32(buf + pos) : AV_RB48(buf > + pos); > + if (!IS_LE_MARKER(state)) > + return 0; > + data_type = container_word_bits == 16 ? AV_RL16(buf + pos + 4) : > AV_RL24(buf + pos + 6); > + data_size = container_word_bits == 16 ? AV_RL16(buf + pos + 6) : > AV_RL24(buf + pos + 9); > + if (s337m_get_offset_and_codec(avc, state, data_type, data_size, > container_word_bits, &offset, codec)) > + return 0;
Looks OK > + if (avc) { > + double s337m_phase = pos * 4. / container_word_bits / 48000; > + av_log(avc, AV_LOG_INFO, "s337m sample %d detected with phase = > %.6fs\n", consecutive_codes, s337m_phase); > + if (*codec == AV_CODEC_ID_DOLBY_E && (s337m_phase < > DOLBY_E_PHASE_MIN || s337m_phase > DOLBY_E_PHASE_MAX)) > + av_log(avc, AV_LOG_WARNING, "Dolby E phase is out of > valid range (%.6fs-%.6fs)\n", DOLBY_E_PHASE_MIN, DOLBY_E_PHASE_MAX); Still not a huge fan of this "phase" notion here, but I suppose it's nothing to get hung up about /Tomas _______________________________________________ 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".