[FFmpeg-devel] Make ffmpeg.c and ffplay.c use avctx->request_channels
Michael Niedermayer
michaelni
Wed Dec 12 11:53:08 CET 2007
On Wed, Dec 12, 2007 at 10:11:52AM +0100, Andreas ?man wrote:
> Hi
>
> Patch does $subj.
>
> I'm not sure if this change affects something that i'm not aware of.
> I've tested it with DTS and AC3 audio in various downmix scenarios.
> Regression tests passes as well.
>
> I assume this is the way forward (and what was meant by adding
> request_channels in the first place)
>
> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c (revision 11202)
> +++ ffmpeg.c (working copy)
> @@ -1615,31 +1615,23 @@
> if (av_fifo_init(&ost->fifo, 2 * MAX_AUDIO_PACKET_SIZE))
> goto fail;
>
> - if (codec->channels == icodec->channels &&
> - codec->sample_rate == icodec->sample_rate) {
> - ost->audio_resample = 0;
> - } else {
> - if (codec->channels != icodec->channels &&
> - (icodec->codec_id == CODEC_ID_AC3 ||
> - icodec->codec_id == CODEC_ID_DTS)) {
> - /* Special case for 5:1 AC3 and DTS input */
> - /* and mono or stereo output */
> - /* Request specific number of channels */
> - icodec->channels = codec->channels;
> - if (codec->sample_rate == icodec->sample_rate)
> - ost->audio_resample = 0;
> - else {
> - ost->audio_resample = 1;
> - }
> - } else {
> - ost->audio_resample = 1;
> - }
> - }
> + if (codec->sample_rate != icodec->sample_rate)
> + ost->audio_resample = 1;
> +
> + j = icodec->channels;
> +
> + if (icodec->channels > 2 && codec->channels < icodec->channels)
> + /* Ask codec to do multichannel downmix for us */
> + j = icodec->request_channels = codec->channels;
> + else if (codec->channels != icodec->channels)
> + /* Let audio_resample() try to mix channels */
> + ost->audio_resample = 1;
> +
> if(audio_sync_method>1)
> ost->audio_resample = 1;
>
> if(ost->audio_resample){
> - ost->resample = audio_resample_init(codec->channels, icodec->channels,
> + ost->resample = audio_resample_init(codec->channels, j,
> codec->sample_rate, icodec->sample_rate);
you assume that every codec with >2 chans can downmix this is likely not the
case
a CODEC_CAP_DOWNMIX could be added or just check the channels number after
avcodec_open()
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071212/15c99e4b/attachment.pgp>
More information about the ffmpeg-devel
mailing list