From 9577838f2f5439a8dd50ec549d6e21cf88e71b02 Mon Sep 17 00:00:00 2001 From: James Darnley Date: Sun, 27 Jun 2010 09:25:05 +0000 Subject: Fix libvorbis encoding with more than 2 channels Fixes issue 1325. Patch by James Darnley, james dot darnley at gmail Originally committed as revision 23818 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/libvorbis.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'libavcodec/libvorbis.c') diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c index 5926d98fbe..f6872b2001 100644 --- a/libavcodec/libvorbis.c +++ b/libavcodec/libvorbis.c @@ -28,6 +28,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "vorbis.h" #undef NDEBUG #include @@ -146,16 +147,14 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext, if(data) { int samples = OGGVORBIS_FRAME_SIZE; float **buffer ; + int c, channels = context->vi.channels; buffer = vorbis_analysis_buffer(&context->vd, samples) ; - if(context->vi.channels == 1) { + for (c = 0; c < channels; c++) { + int co = (channels > 8) ? c : + ff_vorbis_encoding_channel_layout_offsets[channels-1][c]; for(l = 0 ; l < samples ; l++) - buffer[0][l]=audio[l]/32768.f; - } else { - for(l = 0 ; l < samples ; l++){ - buffer[0][l]=audio[l*2]/32768.f; - buffer[1][l]=audio[l*2+1]/32768.f; - } + buffer[c][l]=audio[l*channels+co]/32768.f; } vorbis_analysis_wrote(&context->vd, samples) ; } else { -- cgit v1.2.3