[Ffmpeg-devel] [PATCH] DVR-MS probe audio format - was DVR-MS bug (MP2 decoding)

John Donaghy johnfdonaghy
Tue Mar 20 18:24:17 CET 2007


Thanks for the comments.

including a random mp3 related header from libavcodec in libavformat/utils.c
> is something i would like to avoid, please remove this
> also isnt the frame size from the asf-wav header correct?


I need that header in order to be able to set the frame_size to
MPA_FRAME_SIZE if it's MP2. I wont know if it is MP2 or AC3 until this point
so I'm not sure how else to do it.


> > +    pd->filename = "";
> > +    pd->buf = NULL;
> > +    pd->buf_size = 0;
>
> this data must be per stream


I see what you mean.


> > +                pd->buf = av_realloc(pd->buf, read_size);
>
> read_size is the size of all streams not of a specific stream


agreed - my mistake.

> +                if (mp3_read_probe(pd) > 1) {
> > +                    st->codec->codec_id = CODEC_ID_MP3;
> > +                    st->codec->frame_size = MPA_FRAME_SIZE;
> > +                } else if (ac3_probe(pd) > 1){
> > +                    st->codec->codec_id = CODEC_ID_AC3;
>
> > +                    st->codec->frame_size = 1;
>
> this frame size is wrong


Yes, I wasn't reading the asf demuxer code carefully enough. For
CODEC_ID_AC3 I think it will set framesize to 1 via the 'default' limb of
the case statement. Is that a bug in the asf demuxer then? Should I not set
the frame_size here for AC3 at all?

> +                }
> > +                st->codec->codec_tag =
> codec_get_wav_tag(st->codec->codec_id);
>
> this is wrong you cannot just override codec_tag at will
> also i dont see why that would be needed


Well, in a dvr-ms file the audio stream header appears at the end of the
extended stream header for the audio stream. This audio stream header is not
the same as a normal audio stream header either. It has 64 bytes of unknown
data followed by what appears to be a WAVEFORMATEX structure. Directly
reading that structure using get_wav_header worked for a lot of SD samples
with MP2 audio. Subsequently some samples appeared where the WAVEFORMATEX
indicated MP2 yet the audio was AC3 (always from Australia for some reason).
Also, in many other HD sampes, with AC3 audio, the wFormat tag field is set
to '1' rather than 0x2000 as you might have expected. I dont know why this
is the case and it could be that all the data in the header is entirely
useless... if wFormat is wrong them maybe the other fields are wrong too.
However, setting the tag at this point, and thus overriding what is in the
stream header, is the only way I know of to get the audio to play in all
cases. If you still dont think the code_tag should be set here do you have
any suggestions about how to proceed?

John




More information about the ffmpeg-devel mailing list