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

Daniel Verkamp daniel at drv.nu
Thu Jan 30 08:27:31 CET 2014


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 );
+}
+
 /*****************************************************************************
  * Open
  *****************************************************************************/
@@ -293,6 +298,7 @@ int OpenDemux( vlc_object_t *p_this )
         {
         case AVMEDIA_TYPE_AUDIO:
             es_format_Init( &fmt, AUDIO_ES, fcc );
+            fmt.i_original_fourcc = CodecTagToFourcc( cc->codec_tag );
             fmt.i_bitrate = cc->bit_rate;
             fmt.audio.i_channels = cc->channels;
             fmt.audio.i_rate = cc->sample_rate;
@@ -303,6 +309,7 @@ int OpenDemux( vlc_object_t *p_this )
 
         case AVMEDIA_TYPE_VIDEO:
             es_format_Init( &fmt, VIDEO_ES, fcc );
+            fmt.i_original_fourcc = CodecTagToFourcc( cc->codec_tag );
 
             fmt.video.i_bits_per_pixel = cc->bits_per_coded_sample;
             /* Special case for raw video data */
@@ -344,6 +351,7 @@ int OpenDemux( vlc_object_t *p_this )
 
         case AVMEDIA_TYPE_SUBTITLE:
             es_format_Init( &fmt, SPU_ES, fcc );
+            fmt.i_original_fourcc = CodecTagToFourcc( cc->codec_tag );
             if( strncmp( p_sys->ic->iformat->name, "matroska", 8 ) == 0 &&
                 cc->codec_id == AV_CODEC_ID_DVD_SUBTITLE &&
                 cc->extradata != NULL &&
@@ -391,6 +399,7 @@ int OpenDemux( vlc_object_t *p_this )
 
         default:
             es_format_Init( &fmt, UNKNOWN_ES, 0 );
+            fmt.i_original_fourcc = CodecTagToFourcc( cc->codec_tag );
 #ifdef HAVE_AVUTIL_CODEC_ATTACHMENT
             if( cc->codec_type == AVMEDIA_TYPE_ATTACHMENT )
             {
-- 
1.8.5.3




More information about the vlc-devel mailing list