[Ffmpeg-devel] [RFC] Yet Another downmixer

Kostya kostya.shishkov
Sun Feb 18 15:20:58 CET 2007


I'm working on DCA decoder and it also needs downminxing.
In order not to duplicate code and efforts I present my
vision of channel converting (based on imgconvert).

Please give opinions if this approach is acceptable and
should be developed or not.
-------------- next part --------------
/*
 * Downmixing routines
 * Copyright (C) 2007 Konstantin Shishkov
 *
 * based on downmixing code from GSoC AC3 decoder
 * Copyright (c) 2006 Kartikey Mahendra BHATT (bhattkm at gmail dot com).
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
#include "avcodec.h"
#include "downmix.h"

static const int fmt_strides[AV_DM_COUNT] = {
  1, 2, 3, 3, 4, 4, 5, 6
};

#define DEFINE_DOWNMIXER(inname, outname, sinc, dinc, op, zerostart, zeroend) \
static void mix_ ## inname ## _to_ ## outname (int count, float *src, float *dst){ \
    int i, j; \
	for(i = 0; i < count; i++) { \
	    op; \
		for(j = zerostart; j < zeroend; j++) dst[j] = 0; \
		src += sinc; \
		dst += dinc; \
	}\
}

DEFINE_DOWNMIXER(stereo, mono, 2, 1, dst[0] = (dst[0] + dst[1])/2, 0, 0)

typedef void (*Downmixer)(int count, float *src, float *dst);
static const Downmixer downmixers[AV_DM_COUNT][AV_DM_COUNT] = {
    [AV_DM_STEREO] = {
	    [AV_DM_MONO] = mix_stereo_to_mono,
	},
};

void av_downmix(int count, float *src, int src_fmt, float *dst, int dst_fmt)
{


}



More information about the ffmpeg-devel mailing list