[FFmpeg-devel] [PATCH] wavdec: Only set the codec ID in read_header

Michael Niedermayer michael at niedermayer.cc
Sat Apr 2 19:14:44 CEST 2016


On Sat, Apr 02, 2016 at 04:57:25PM +0100, Derek Buitenhuis wrote:
> WAV is not a NOHEADER format, and thus should not be changing
> stream codec IDs and probing in read_packet.
> 
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
> Output is unchanged. FATE has been run, and I have also
> run Michael's new fate-wav-ac3 test, and it passes.
> ---
>  libavformat/wavdec.c | 28 ++++++++++++++++------------
>  1 file changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> index d95596f..db1af4f 100644
> --- a/libavformat/wavdec.c
> +++ b/libavformat/wavdec.c
> @@ -62,6 +62,18 @@ typedef struct WAVDemuxContext {
>  
>  #if CONFIG_WAV_DEMUXER
>  
> +#define CHECK_SPDIF do { \
> +    if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codec->codec_tag == 1) { \
> +        enum AVCodecID codec; \
> +        ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer, \
> +                             &codec); \
> +        if (ret > AVPROBE_SCORE_EXTENSION) { \
> +            s->streams[0]->codec->codec_id = codec; \
> +            wav->spdif = 1; \
> +        } \
> +    } \
> +    } while (0)
> +
>  static int64_t next_tag(AVIOContext *pb, uint32_t *tag, int big_endian)
>  {
>      *tag = avio_rl32(pb);
> @@ -528,6 +540,8 @@ break_loop:
>      ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
>      ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
>  
> +    CHECK_SPDIF;
> +
>      return 0;
>  }

this seems to work in practice, iam not sure though if this and even
teh code before this is really "correct"

i dont think theres a gurantee that s->pb->buffer will ever contain
data that allows probing to succeed

maybe a note saying that direct use of s->pb->buffer should be avoided
could be added

also a function is probably cleaner and eaier to understand than a
macro, having properly passed parameters
(should be ok with these changes)

it might be safer to explicitly read some data into a buffer and use
that for probing after ffio_ensure_seekback()
but maybe theres something i miss that otherwise ensures that
s->pb->buffer would contain data with which probing would succeed

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160402/5ea674df/attachment.sig>


More information about the ffmpeg-devel mailing list