tis 2019-08-06 klockan 17:08 +0200 skrev Nicolas Gaullier: > +int avpriv_s337m_probe_stream(void *avc, AVIOContext *pb, AVStream **st, int > size) > +{ > + if ( size >= S337M_MIN_OFFSET && > + ((*st)->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE || > (*st)->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE) && > + (*st)->codecpar->channels == 2) { > + uint8_t *buf; > + int64_t data_offset; > + int pos = 0; > + > + size = FFMIN(size, S337M_MAX_OFFSET); > + if (!(buf = av_mallocz(size))) { > + return AVERROR(ENOMEM); > + } > + data_offset = avio_tell(pb); > + if (avio_read(pb, buf, size) != size) { > + av_freep(&buf); > + return AVERROR(EIO); > + } > + avio_seek(pb, data_offset, SEEK_SET); > + > + while (pos < size - 9 && !buf[pos]) { > + pos++; > + } > + if (pos < size - 9 && pos >= S337M_PROBE_GUARDBAND_MIN_BYTES) {
I think this 9 should be an 11 or 12.. > + uint64_t state; > + int data_type = -1, data_size, offset; > + > + if ((*st)->codecpar->bits_per_coded_sample == 16) { > + state = AV_RB32(buf + pos); > + if (IS_16LE_MARKER(state)) { > + data_type = AV_RL16(buf + pos + 4); > + data_size = AV_RL16(buf + pos + 6); > + } > + } else if ((*st)->codecpar->bits_per_coded_sample == 24) { > + state = AV_RB48(buf + pos); > + if (IS_20LE_MARKER(state) || IS_24LE_MARKER(state)) { > + data_type = AV_RL24(buf + pos + 6); > + data_size = AV_RL24(buf + pos + 9); .. because of this read > + } > + } > + if (data_type >= 0 && !s337m_get_offset_and_codec(avc, state, > data_type, data_size, &offset, &(*st)->codecpar->codec_id)) { > + double s337m_phase = pos * 4 / > (*st)->codecpar->bits_per_coded_sample / (*st)->codecpar->sample_rate; This isn't quite what I meant by turning it into an integer test :) this will likely just be rounded to zero. I meant that things could likely be rearranged so there's no divisions, so the probing isn't subject to the vaguaries of float rounding > +#define DOLBY_E_PHASE_MIN 0.000610 > +#define DOLBY_E_PHASE_MAX 0.001050 Where do these phase values come from? Is there a spec somewhere? I notice the ratios DOLBY_E_PHASE_MAX/DOLBY_E_PHASE_MIN and S337M_MAX_OFFSET/S337M_MIN_OFFSET are within 9% of eachother, which doesn't feel like a coincidence /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".