[FFmpeg-devel] Correct libvorbis.c behaviour with >2 channels
James Darnley
james.darnley
Fri May 28 19:57:54 CEST 2010
I fail hard at sending out correct patches. New one, git format-patch
-------------- next part --------------
>From 1325bfbc5240cec90937f3d26f2663073050ccda Mon Sep 17 00:00:00 2001
From: James Darnley <james.darnley at gmail.com>
Date: Fri, 28 May 2010 14:36:53 +0200
Subject: [PATCH 2/3] Fix libvorbis encoding with more than 2 channels
---
libavcodec/Makefile | 2 +-
libavcodec/libvorbis.c | 12 +++++-------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 764555e..d209657 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -535,7 +535,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \
libdirac_libschro.o
OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o
OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o
-OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o
+OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o
OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvidff.o libxvid_rc.o
diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c
index 81d328a..92396bf 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 <assert.h>
@@ -144,16 +145,13 @@ 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 = ff_vorbis_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 {
--
1.6.1.2
More information about the ffmpeg-devel
mailing list