Michael Niedermayer <[EMAIL PROTECTED]> added the comment: On Sun, Nov 16, 2008 at 09:30:00AM +0000, Benjamin Larsson wrote: > > Benjamin Larsson <[EMAIL PROTECTED]> added the comment: > > Aurelien Jacobs wrote: > > Aurelien Jacobs <[EMAIL PROTECTED]> added the comment: > > > > On Sat, 15 Nov 2008 22:02:50 +0000 > > Benjamin Larsson <[EMAIL PROTECTED]> wrote: > > > >> New submission from Benjamin Larsson <[EMAIL PROTECTED]>: > >> > >> avcodec_get_channel_layout_string() is always called before the proper > >> channel_mask is set for > >> ftp://upload.mplayerhq.hu/incoming/DTS-48-24-4.0/Edward.Scissorhands.x264.DTS-4.0-48_24.mkv > > > > The reason is that the DTS decoder has to decode at least one frame > > to set correct channel_mask. For raw DTS, ffmpeg decode one frame > > to get stream parameters. For mkv, ffmpeg already have all parameters > > (except channel_mask), and thus, it don't try to decode a frame > > before displaying stream parameters. > > The follwing patch add channel_layout to the list of essential > > parameters. This forces ffmpeg to decode an audio frame to get > > channel_layout before using it. It fixes the issue with above mentionned > > sample file. But I guess it could have bad effects with other codecs > > which still don't implement channel_layout (untested). > > > > Index: libavformat/utils.c > > =================================================================== > > --- libavformat/utils.c (revision 15839) > > +++ libavformat/utils.c (working copy) > > @@ -1856,7 +1856,7 @@ static int has_codec_parameters(...) > > int val; > > switch(enc->codec_type) { > > case CODEC_TYPE_AUDIO: > > - val = enc->sample_rate && enc->channels && enc->sample_fmt != > > SAMPLE_FMT_NONE; > > + val = enc->sample_rate && enc->channels && enc->channel_layout && > > enc->sample_fmt != SAMPLE_FMT_NONE; > > if(!enc->frame_size && > > (enc->codec_id == CODEC_ID_VORBIS || > > enc->codec_id == CODEC_ID_AAC)) > > > > Aurel > > > > Yeah, I found out that this also worked. But this solution will brake > remuxing (most likely) when the dca decoder isn't available. > > Index: libavformat/matroskadec.c > =================================================================== > --- libavformat/matroskadec.c (revision 15829) > +++ libavformat/matroskadec.c (working copy) > @@ -1278,6 +1278,8 @@ > extradata_offset = 78; > track->codec_priv.size -= extradata_offset; > } > + } else if (codec_id == CODEC_ID_DTS) { > + track->audio.out_samplerate = 0; > } > > if (codec_id == CODEC_ID_NONE) > > I guess that the right way to do it is to add layout to all codecs. > > Michael do you have a comment on this ?
Well, if all decoders can always set channel_layout than aurels patch should be ok (after all codecs are updated) otherwise we need to think of something else maybe a simple field in AVCodecContext by which a decoder could indicate that it hasnt yet found a/all headers. But then maybe this is overkill and simply breaking out if channel_mask is still uavailable after the first frame is decoded would do. I dont really know what is best, but i surely prefer simple solutions... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I hate to see young programmers poisoned by the kind of thinking Ulrich Drepper puts forward since it is simply too narrow -- Roman Shaposhnik ______________________________________________________ FFmpeg issue tracker <[EMAIL PROTECTED]> <https://roundup.mplayerhq.hu/roundup/ffmpeg/issue715> ______________________________________________________
