r25258 - trunk/libavcodec/libvorbis.c
Author: michael Date: Wed Sep 29 17:09:38 2010 New Revision: 25258 Log: Allow setting the impulse block bias for libvorbis through a private codec parameter. First example and test of private codec parameters. Modified: trunk/libavcodec/libvorbis.c Modified: trunk/libavcodec/libvorbis.c ============================================================================== --- trunk/libavcodec/libvorbis.c Wed Sep 29 17:05:47 2010 (r25257) +++ trunk/libavcodec/libvorbis.c Wed Sep 29 17:09:38 2010 (r25258) @@ -26,6 +26,7 @@ #include <vorbis/vorbisenc.h> +#include "libavutil/opt.h" #include "avcodec.h" #include "bytestream.h" #include "vorbis.h" @@ -38,6 +39,7 @@ #define BUFFER_SIZE (1024*64) typedef struct OggVorbisContext { + AVClass *av_class; vorbis_info vi ; vorbis_dsp_state vd ; vorbis_block vb ; @@ -48,10 +50,18 @@ typedef struct OggVorbisContext { /* decoder */ vorbis_comment vc ; ogg_packet op; + + double iblock; } 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) { + OggVorbisContext *context = avccontext->priv_data ; double cfreq; if(avccontext->flags & CODEC_FLAG_QSCALE) { @@ -82,6 +92,10 @@ static av_cold int oggvorbis_init_encode return -1; } + if(context->iblock){ + vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock); + } + return vorbis_encode_setup_init(vi); } @@ -240,4 +254,5 @@ AVCodec libvorbis_encoder = { .capabilities= CODEC_CAP_DELAY, .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("libvorbis Vorbis"), + .priv_class= &class, } ;
On date Wednesday 2010-09-29 17:09:39 +0200, michael wrote:
Author: michael Date: Wed Sep 29 17:09:38 2010 New Revision: 25258
Log: Allow setting the impulse block bias for libvorbis through a private codec parameter. First example and test of private codec parameters.
Modified: trunk/libavcodec/libvorbis.c
Modified: trunk/libavcodec/libvorbis.c ============================================================================== --- trunk/libavcodec/libvorbis.c Wed Sep 29 17:05:47 2010 (r25257) +++ trunk/libavcodec/libvorbis.c Wed Sep 29 17:09:38 2010 (r25258) @@ -26,6 +26,7 @@
#include <vorbis/vorbisenc.h>
+#include "libavutil/opt.h" #include "avcodec.h" #include "bytestream.h" #include "vorbis.h" @@ -38,6 +39,7 @@ #define BUFFER_SIZE (1024*64)
typedef struct OggVorbisContext { + AVClass *av_class; vorbis_info vi ; vorbis_dsp_state vd ; vorbis_block vb ; @@ -48,10 +50,18 @@ typedef struct OggVorbisContext { /* decoder */ vorbis_comment vc ; ogg_packet op; + + double iblock; } 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 };
That's cool, now we should also try to document it. Some volunteer to create and fill a doc/codecs.texi?
static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) { + OggVorbisContext *context = avccontext->priv_data ;
for avoiding horrible confusion I suggest to call the private context something along the lines of the private context itself, e.g. it may be vorbis in this case, that's similiar to what it's done in lavfi filters.
double cfreq;
if(avccontext->flags & CODEC_FLAG_QSCALE) { @@ -82,6 +92,10 @@ static av_cold int oggvorbis_init_encode return -1; }
+ if(context->iblock){ + vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock); + }
Please avoid if(...){ in favor of if_(...)_{ for karma bonus. Regards. -- FFmpeg = Fancy and Frightening Most Plastic Ecumenical Governor
On Wed, Sep 29, 2010 at 06:05:47PM +0200, Stefano Sabatini wrote:
On date Wednesday 2010-09-29 17:09:39 +0200, michael wrote:
Author: michael Date: Wed Sep 29 17:09:38 2010 New Revision: 25258
Log: Allow setting the impulse block bias for libvorbis through a private codec parameter. First example and test of private codec parameters.
Modified: trunk/libavcodec/libvorbis.c
Modified: trunk/libavcodec/libvorbis.c ============================================================================== --- trunk/libavcodec/libvorbis.c Wed Sep 29 17:05:47 2010 (r25257) +++ trunk/libavcodec/libvorbis.c Wed Sep 29 17:09:38 2010 (r25258) @@ -26,6 +26,7 @@
#include <vorbis/vorbisenc.h>
+#include "libavutil/opt.h" #include "avcodec.h" #include "bytestream.h" #include "vorbis.h" @@ -38,6 +39,7 @@ #define BUFFER_SIZE (1024*64)
typedef struct OggVorbisContext { + AVClass *av_class; vorbis_info vi ; vorbis_dsp_state vd ; vorbis_block vb ; @@ -48,10 +50,18 @@ typedef struct OggVorbisContext { /* decoder */ vorbis_comment vc ; ogg_packet op; + + double iblock; } 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 };
That's cool, now we should also try to document it. Some volunteer to create and fill a doc/codecs.texi?
if noone else does it remind me in a week or 2 and i see what i can do
static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) { + OggVorbisContext *context = avccontext->priv_data ;
for avoiding horrible confusion I suggest to call the private context something along the lines of the private context itself, e.g. it may be vorbis in this case, that's similiar to what it's done in lavfi filters.
its called context in the whole file, i just tried to be consistent. That said i agree that vorbis or v or c would be better
double cfreq;
if(avccontext->flags & CODEC_FLAG_QSCALE) { @@ -82,6 +92,10 @@ static av_cold int oggvorbis_init_encode return -1; }
+ if(context->iblock){ + vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock); + }
Please avoid if(...){ in favor of if_(...)_{ for karma bonus.
i have better things to do than learning and applying indent -kr to the last whitespace [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Everything should be made as simple as possible, but not simpler. -- Albert Einstein
On Wed, Sep 29, 2010 at 07:18:33PM +0200, Michael Niedermayer wrote:
On Wed, Sep 29, 2010 at 06:05:47PM +0200, Stefano Sabatini wrote:
On date Wednesday 2010-09-29 17:09:39 +0200, michael wrote:
Log: Allow setting the impulse block bias for libvorbis through a private codec parameter. First example and test of private codec parameters.
--- trunk/libavcodec/libvorbis.c Wed Sep 29 17:05:47 2010 (r25257) +++ trunk/libavcodec/libvorbis.c Wed Sep 29 17:09:38 2010 (r25258) @@ -82,6 +92,10 @@ static av_cold int oggvorbis_init_encode
+ if(context->iblock){ + vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock); + }
Please avoid if(...){ in favor of if_(...)_{ for karma bonus.
i have better things to do than learning and applying indent -kr to the last whitespace
I disagree that this qualifies as a minor part of K&R. I also think it would only require a small effort on your part to try to get used to writing code in K&R style and once you have done that, it will be completely natural. So I would like to politely suggest that you try to place a space after keywords, i.e. after if/for/while/switch/do and between ')' and '{'. if (...) { for (...) { while (...) { switch (...) { Everybody else is now using this style, in the long run FFmpeg would benefit from being written in a more consistent style. Thanks, Diego
participants (4)
-
diego@biurrun.de -
michaelni@gmx.at -
stefano.sabatini-lala@poste.it -
subversion@mplayerhq.hu