[vlc-devel] [PATCH] avformat: use avcodec codec_tag as original fourcc

Daniel Verkamp daniel at drv.nu
Thu Feb 6 05:14:57 CET 2014


On Fri, Jan 31, 2014 at 5:01 AM, Rafaël Carré <funman at videolan.org> wrote:
> Hello,
>
> On 01/30/14 08:31, Daniel Verkamp wrote:
>> On Thu, Jan 30, 2014 at 12:27 AM, Daniel Verkamp <daniel at drv.nu> wrote:
>>> Fixes Bink video playback. The Bink video decoder in libavcodec relies
>>> on the fourcc to determine the version of the codec.
>>> ---
>>>  modules/demux/avformat/demux.c | 9 +++++++++
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
>>> index 6e8086e..6bb61f4 100644
>>> --- a/modules/demux/avformat/demux.c
>>> +++ b/modules/demux/avformat/demux.c
>>> @@ -96,6 +96,11 @@ static block_t *BuildSsaFrame( const AVPacket *p_pkt, unsigned i_order );
>>>  static void UpdateSeekPoint( demux_t *p_demux, int64_t i_time );
>>>  static void ResetTime( demux_t *p_demux, int64_t i_time );
>>>
>>> +static vlc_fourcc_t CodecTagToFourcc( uint32_t codec_tag )
>>> +{
>>> +    return VLC_FOURCC( codec_tag & 0xFF, (codec_tag >> 8) & 0xFF, (codec_tag >> 16) & 0xFF, codec_tag >> 24 );
>>> +}
>>
>> Based on the usage of ffmpeg_CodecTag to convert i_original_fourcc in
>> the avcodec module, I added a corresponding function to convert from
>> codec_tag to vlc_fourcc_t; I couldn't find the equivalent function
>> anywhere, but if I missed one, please let me know.
>
> avcodec.h doc says it is a little-endian number, so something like:
>
> #ifdef WORDS_BIGENDIAN
> return bswap32(codec_tag);
> #else
> return codec_tag;
> #endif
>
> Will work as vlc_fourcc_t is an uint32_t already

I will send an updated patch.

> Maybe the need for setting i_original_fourcc = VLC_FOURCC('a','v','c','1')
>  is made obsolete by your patch and you can move
> fmt.i_original_fourcc = CodecTagToFourcc( cc->codec_tag );
> after the switch (cc->codec_type) ?

Unfortunately, it appears the workaround is still needed; the avformat
flv demuxer only sets codec_tag for unknown codec IDs.

Thanks,
-- Daniel Verkamp



More information about the vlc-devel mailing list