This is needed because not all players (e.g. MPlayer) are able to distinguish
two different Bink audio decoders when codec_tag is set.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
| ... | ... |
@@ -90,7 +90,7 @@ static av_cold int decode_init(AVCodecContext *avctx) |
| 90 | 90 |
return -1; |
| 91 | 91 |
} |
| 92 | 92 |
|
| 93 |
- s->version_b = avctx->codec_tag == MKTAG('B','I','K','b');
|
|
| 93 |
+ s->version_b = avctx->extradata && avctx->extradata[3] == 'b'; |
|
| 94 | 94 |
|
| 95 | 95 |
if (avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) {
|
| 96 | 96 |
// audio is already interleaved for the RDFT format variant |
| ... | ... |
@@ -134,13 +134,18 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 134 | 134 |
if (!ast) |
| 135 | 135 |
return AVERROR(ENOMEM); |
| 136 | 136 |
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
| 137 |
- ast->codec->codec_tag = vst->codec->codec_tag; |
|
| 137 |
+ ast->codec->codec_tag = 0; |
|
| 138 | 138 |
ast->codec->sample_rate = avio_rl16(pb); |
| 139 | 139 |
av_set_pts_info(ast, 64, 1, ast->codec->sample_rate); |
| 140 | 140 |
flags = avio_rl16(pb); |
| 141 | 141 |
ast->codec->codec_id = flags & BINK_AUD_USEDCT ? |
| 142 | 142 |
CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT; |
| 143 | 143 |
ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1; |
| 144 |
+ ast->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE); |
|
| 145 |
+ if (!ast->codec->extradata) |
|
| 146 |
+ return AVERROR(ENOMEM); |
|
| 147 |
+ ast->codec->extradata_size = 4; |
|
| 148 |
+ AV_WL32(ast->codec->extradata, vst->codec->codec_tag); |
|
| 144 | 149 |
} |
| 145 | 150 |
|
| 146 | 151 |
for (i = 0; i < bink->num_audio_tracks; i++) |