[FFmpeg-cvslog] r23818 - in trunk/libavcodec: Makefile libvorbis.c vorbis.h vorbis_data.c
mstorsjo
subversion
Sun Jun 27 11:25:05 CEST 2010
Author: mstorsjo
Date: Sun Jun 27 11:25:05 2010
New Revision: 23818
Log:
Fix libvorbis encoding with more than 2 channels
Patch by James Darnley, james dot darnley at gmail
Modified:
trunk/libavcodec/Makefile
trunk/libavcodec/libvorbis.c
trunk/libavcodec/vorbis.h
trunk/libavcodec/vorbis_data.c
Modified: trunk/libavcodec/Makefile
==============================================================================
--- trunk/libavcodec/Makefile Sun Jun 27 11:07:35 2010 (r23817)
+++ trunk/libavcodec/Makefile Sun Jun 27 11:25:05 2010 (r23818)
@@ -540,7 +540,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER)
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_LIBVPX_ENCODER) += libvpxenc.o
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
Modified: trunk/libavcodec/libvorbis.c
==============================================================================
--- trunk/libavcodec/libvorbis.c Sun Jun 27 11:07:35 2010 (r23817)
+++ trunk/libavcodec/libvorbis.c Sun Jun 27 11:25:05 2010 (r23818)
@@ -28,6 +28,7 @@
#include "avcodec.h"
#include "bytestream.h"
+#include "vorbis.h"
#undef NDEBUG
#include <assert.h>
@@ -146,16 +147,14 @@ static int oggvorbis_encode_frame(AVCode
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 {
Modified: trunk/libavcodec/vorbis.h
==============================================================================
--- trunk/libavcodec/vorbis.h Sun Jun 27 11:07:35 2010 (r23817)
+++ trunk/libavcodec/vorbis.h Sun Jun 27 11:25:05 2010 (r23818)
@@ -26,6 +26,7 @@
extern const float ff_vorbis_floor1_inverse_db_table[256];
extern const float * const ff_vorbis_vwin[8];
extern const uint8_t ff_vorbis_channel_layout_offsets[8][8];
+extern const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8];
extern const int64_t ff_vorbis_channel_layouts[9];
typedef struct {
Modified: trunk/libavcodec/vorbis_data.c
==============================================================================
--- trunk/libavcodec/vorbis_data.c Sun Jun 27 11:07:35 2010 (r23817)
+++ trunk/libavcodec/vorbis_data.c Sun Jun 27 11:25:05 2010 (r23818)
@@ -32,6 +32,17 @@ const uint8_t ff_vorbis_channel_layout_o
{ 0, 2, 1, 7, 5, 6, 3, 4},
};
+const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8] = {
+ { 0, },
+ { 0, 1, },
+ { 0, 2, 1, },
+ { 0, 1, 2, 3, },
+ { 0, 2, 1, 3, 4, },
+ { 0, 2, 1, 4, 5, 3, },
+ { 0, 2, 1, 5, 6, 4, 3, },
+ { 0, 2, 1, 6, 7, 4, 5, 3 }
+};
+
const int64_t ff_vorbis_channel_layouts[9] = {
CH_LAYOUT_MONO,
CH_LAYOUT_STEREO,
More information about the ffmpeg-cvslog
mailing list