On 06/17/2011 05:06 AM, Kostya wrote:

> On Fri, Jun 17, 2011 at 09:54:43AM +0100, Måns Rullgård wrote:
>> Kostya Shishkov <[email protected]> writes:
>>
>>> This is needed because not all players (e.g. MPlayer) are able to 
>>> distinguish
>>> two different Bink audio decoders when codec_tag is set.
>>> ---
>>>  libavcodec/binkaudio.c |    2 +-
>>>  libavformat/bink.c     |    7 ++++++-
>>>  2 files changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
>>> index a05b0b5..9722bdf 100644
>>> --- a/libavcodec/binkaudio.c
>>> +++ b/libavcodec/binkaudio.c
>>> @@ -90,7 +90,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>>>          return -1;
>>>      }
>>>
>>> -    s->version_b = avctx->codec_tag == MKTAG('B','I','K','b');
>>> +    s->version_b = avctx->extradata && avctx->extradata[3] == 'b';
>>>
>>>      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 76b457c..0676738 100644
>>> --- a/libavformat/bink.c
>>> +++ b/libavformat/bink.c
>>> @@ -134,13 +134,18 @@ 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->codec_tag   = 0;
>>>              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(4 + 
>>> FF_INPUT_BUFFER_PADDING_SIZE);
>>> +            if (!ast->codec->extradata)
>>> +                return AVERROR(ENOMEM);
>>> +            ast->codec->extradata_size = 4;
>>> +            AV_WL32(ast->codec->extradata, vst->codec->codec_tag);
>>>          }
>>>
>>>          for (i = 0; i < bink->num_audio_tracks; i++)
>>> -- 
>>
>> I'm not sure which abuse is worse.
> 
> Flip a coin then. I don't know myself.
> But feel free to read doxy for codec_tag in avcodec.h to make it even more
> confusing.


This solution isn't too bad. At least it is using actual data from the
global header.

-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to