[FFmpeg-cvslog] Fix bink audio playback outside of FFmpeg.

Ivan Kalvachev git at videolan.org
Tue Jun 21 03:22:01 CEST 2011


ffmpeg | branch: master | Ivan Kalvachev <ikalvachev at gmail.com> | Thu Jun 16 19:35:33 2011 +0300| [093768c9a4855b82c13124f835b655dd70883012] | committer: Michael Niedermayer

Fix bink audio playback outside of FFmpeg.

There are 2 known Bink audio codecs. Additionally they have
a different flavor if they are found inside Bink-b "BIKb" file.
In order to guess the correct flavor, the demuxer sets the audio
codec_tag to be the same as the file format tag.
This causes problem because same tag is used for both audio codecs.
The hack works in FFmpeg because audio codecs are identified by their
codec_id, but other players rely on standard behavior.

This fix removes the codec_tag hack and instead uses artificial
extradata format to signal the codec flavor. This would also
allow proper embedding of Bink audio in other containers.

Signed-off-by: Ivan Kalvachev <ikalvachev at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=093768c9a4855b82c13124f835b655dd70883012
---

 libavcodec/binkaudio.c |    3 ++-
 libavformat/bink.c     |    4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index bf1d412..ff36458 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -90,7 +90,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
         return -1;
     }
 
-    s->version_b = avctx->codec_tag == MKTAG('B','I','K','b');
+    if (avctx->extradata && avctx->extradata_size > 0)
+        s->version_b = avctx->extradata[0];
 
     if (avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) {
         // audio is already interleaved for the RDFT format variant
diff --git a/libavformat/bink.c b/libavformat/bink.c
index 3bcaff3..eed52cd 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -134,13 +134,15 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
             if (!ast)
                 return AVERROR(ENOMEM);
             ast->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-            ast->codec->codec_tag   = vst->codec->codec_tag;
             ast->codec->sample_rate = avio_rl16(pb);
             av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
             flags = avio_rl16(pb);
             ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
                                    CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT;
             ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1;
+            ast->codec->extradata  = av_mallocz(1 + FF_INPUT_BUFFER_PADDING_SIZE);
+            ast->codec->extradata_size = 1;
+            ast->codec->extradata[0] = vst->codec->codec_tag == MKTAG('B','I','K','b');
         }
 
         for (i = 0; i < bink->num_audio_tracks; i++)



More information about the ffmpeg-cvslog mailing list