Commit 77336a5e authored by Michael Niedermayer's avatar Michael Niedermayer

Allow setting the impulse block bias for libvorbis through a private codec parameter.

First example and test of private codec parameters.

Originally committed as revision 25258 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent dc51a72b
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <vorbis/vorbisenc.h> #include <vorbis/vorbisenc.h>
#include "libavutil/opt.h"
#include "avcodec.h" #include "avcodec.h"
#include "bytestream.h" #include "bytestream.h"
#include "vorbis.h" #include "vorbis.h"
...@@ -38,6 +39,7 @@ ...@@ -38,6 +39,7 @@
#define BUFFER_SIZE (1024*64) #define BUFFER_SIZE (1024*64)
typedef struct OggVorbisContext { typedef struct OggVorbisContext {
AVClass *av_class;
vorbis_info vi ; vorbis_info vi ;
vorbis_dsp_state vd ; vorbis_dsp_state vd ;
vorbis_block vb ; vorbis_block vb ;
...@@ -48,10 +50,18 @@ typedef struct OggVorbisContext { ...@@ -48,10 +50,18 @@ typedef struct OggVorbisContext {
/* decoder */ /* decoder */
vorbis_comment vc ; vorbis_comment vc ;
ogg_packet op; ogg_packet op;
double iblock;
} OggVorbisContext ; } OggVorbisContext ;
static const AVOption options[]={
{"iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), FF_OPT_TYPE_DOUBLE, 0, -15, 0, AV_OPT_FLAG_ENCODING_PARAM},
{NULL}
};
static const AVClass class = { "libvorbis", NULL, options, LIBAVUTIL_VERSION_INT };
static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) { static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) {
OggVorbisContext *context = avccontext->priv_data ;
double cfreq; double cfreq;
if(avccontext->flags & CODEC_FLAG_QSCALE) { if(avccontext->flags & CODEC_FLAG_QSCALE) {
...@@ -82,6 +92,10 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avcco ...@@ -82,6 +92,10 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avcco
return -1; return -1;
} }
if(context->iblock){
vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock);
}
return vorbis_encode_setup_init(vi); return vorbis_encode_setup_init(vi);
} }
...@@ -240,4 +254,5 @@ AVCodec libvorbis_encoder = { ...@@ -240,4 +254,5 @@ AVCodec libvorbis_encoder = {
.capabilities= CODEC_CAP_DELAY, .capabilities= CODEC_CAP_DELAY,
.sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("libvorbis Vorbis"), .long_name= NULL_IF_CONFIG_SMALL("libvorbis Vorbis"),
.priv_class= &class,
} ; } ;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment