[FFmpeg-devel] [Ffmpeg-devel] [PATCH] DTS multichannel

Justin Ruggles justinruggles
Wed May 2 22:42:40 CEST 2007


Kostya wrote:
> On Wed, Apr 25, 2007 at 04:25:18PM -0400, Justin Ruggles wrote:
> 
>>Hi,
>>
>>Here is a patch to add multichannel support to the native DTS decoder.
>>It also utilizes the downmixing coeffients, which is not done currently.
>> The default coefficients are based on the comments at the bottom of
>>dtsdata.h.
>>
>>downmix 5.1 to stereo:
>>ffmpeg -f dts -i stream.dts -acodec pcm_s16le -ac 2 stream-stereo.wav
>>
>>copy 5.1 direct to wav:
>>ffmpeg -f dts -i stream.dts -acodec pcm_s16le -ac 6 stream-5p1.wav
>>
>>Note that channel reordering is not done yet, so the multichannel output
>>would be in MPEG-2/4 channel order (C,L,R,LS,RS,LFE).
>>
>>-Justin
> 
> 
> Looks ok except minor nitpick: 
> 
> 
>>@@ -1140,10 +1156,24 @@
>>     }
>>     //set AVCodec values with parsed data
>>     avctx->sample_rate = s->sample_rate;
>>-    avctx->channels = 2; //FIXME
>>+
>>+    channels = s->prim_channels + !!s->lfe;
>>+    if(avctx->channels == 0) {
>>+        avctx->channels = channels;
>>+    } else if(channels < avctx->channels) {
>>+        av_log(avctx, AV_LOG_ERROR, "DTS source channels are less than specified: output to %d channels.\n", channels);
>>+        avctx->channels = channels;
> 
> 
> This should be IMHO av_log(avctx, AV_LOG_DEBUG, "Downmixing to %d channels\n", channels)
> or dropped at all

In this case, no downmixing is actually done.  It is an error because
the user is requesting more channels than exist in the source stream.
The FFmpeg liba52 decoder uses AV_LOG_ERROR for this case.  I downgraded
it to AV_LOG_WARNING here since the decoding proceeds even with the
invalid user input.

> 
>>+    }
>>+    if(avctx->channels == 2) {
>>+        s->output = DCA_STEREO;
>>+    } else if(avctx->channels != channels) {
>>+        av_log(avctx, AV_LOG_ERROR, "Cannot downmix DTS to %d channels.\n", avctx->channels);
>>+        return -1;
>>+    }
>>+
> 
> 
> And feel free to work on multichannel code in DCA decoder.

Applied in 2 separate commits, one for multichannel output and one for
utilizing the downmixing coefficients.

-Justin




More information about the ffmpeg-devel mailing list