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

Daniel Verkamp git at videolan.org
Fri Feb 7 16:03:40 CET 2014


vlc | branch: master | Daniel Verkamp <daniel at drv.nu> | Wed Feb  5 21:17:14 2014 -0700| [9d30f924d9e55cdf157218d3b7047db88e1010ac] | committer: Jean-Baptiste Kempf

avformat: use avcodec codec_tag as original fourcc

Fixes Bink video playback. The Bink video decoder in libavcodec relies
on the fourcc to determine the version of the codec.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9d30f924d9e55cdf157218d3b7047db88e1010ac
---

 modules/demux/avformat/demux.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 6e8086e..b550ca9 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -96,6 +96,16 @@ 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 )
+{
+    // convert from little-endian avcodec codec_tag to VLC native-endian fourcc
+#ifdef WORDS_BIGENDIAN
+    return bswap32(codec_tag);
+#else
+    return codec_tag;
+#endif
+}
+
 /*****************************************************************************
  * Open
  *****************************************************************************/
@@ -293,6 +303,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 +314,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 +356,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 +404,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 )
             {



More information about the vlc-commits mailing list