[FFmpeg-devel] [PATCH] ffmpeg2theora 6to2channel-resample.patch
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun May 1 19:50:47 CEST 2011
Just some quick comments
On Sun, May 01, 2011 at 07:38:27PM +0200, Michael Niedermayer wrote:
> +/*
> +*/
> +static short clip_short(int v) {
> + if (v < -32768)
> + v = -32768;
> + else if (v > 32767)
> + v = 32767;
> + return (short) v;
> +}
Looks like a bad reimplementation of av_clip_int16,
and generally "short" shouldn't be used but that's
already in existing code...
> for(i=0;i<n;i++) {
> - *output1++ = *input++;
> - *output2++ = *input++;
> + if (channels == 2) {
> + /* simple stereo to stereo. Input is: l, r */
> + l = input[0];
> + r = input[1];
> + } else if (channels == 6) {
> + /* 5.1 to stereo input: [fl, fr, c, lfe, rl, rr] */
> + int fl,fr,c,rl,rr,lfe;
> + fl = input[0];
> + fr = input[1];
> + c = input[2];
> + lfe = input[3];
> + rl = input[4];
> + rr = input[5];
> +
> + l = clip_short(fl + (0.5 * rl) + (0.7 * c));
> + r = clip_short(fr + (0.5 * rr) + (0.7 * c));
> + } else {
> + /* channels must be 3-5, or >= 7. l, c, r, ? */
> + l = input[0];
> + r = input[2];
> + }
The ifs should hardly be inside the loop.
> @@ -150,9 +190,9 @@
> {
> ReSampleContext *s;
>
> - if ( input_channels > 2)
> + if ((input_channels > 2) && (input_channels != 6))
> {
> - av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.\n");
> + av_log(NULL, AV_LOG_ERROR, "Resampling with input channels other than 1,2, or 6 is unsupported.\n");
Tabs.
More information about the ffmpeg-devel
mailing list