[FFmpeg-devel] [PATCH] VP8 de/encode via libvpx

Diego Biurrun diego
Wed May 26 02:42:18 CEST 2010


On Tue, May 25, 2010 at 07:36:40PM -0400, James Zern wrote:
> On Wed, May 19, 2010 at 18:22, Diego Biurrun <diego at biurrun.de> wrote:
> > On Wed, May 19, 2010 at 02:28:10PM -0400, James Zern wrote:
> >>
> >> The attached will enable decode and basic encode of VP8 through
> >> libvpx.
> >
> Attached is another pass at a basic encode wrapper. Formatting similar
> to the decoder has been applied.
> 
> --- configure	(revision 23330)
> +++ configure	(working copy)
> @@ -184,6 +184,8 @@ External library support:
>    --enable-libvorbis       enable Vorbis encoding via libvorbis,
>                             native implementation exists [no]
>    --enable-libvpx          enable VP8 support via libvpx [no]
> +  --enable-libvpx-decode   enable VP8 decode via libvpx [no]
> +  --enable-libvpx-encode   enable VP8 encode via libvpx [no]

I'm not sure what you are trying to achieve here.  AFAIU libvpx supports
both encoding and decoding, right?  Then you do not need to introduce
split options.

> --- libavcodec/libvpxenc.c	(revision 0)
> +++ libavcodec/libvpxenc.c	(revision 0)
> @@ -0,0 +1,459 @@
> +
> +    enccfg.rc_target_bitrate =
> +        (unsigned int)av_rescale_rnd(avctx->bit_rate, 1, 1000,
> +                                     AV_ROUND_NEAR_INF);

> +    enccfg.rc_target_bitrate = (unsigned int)av_rescale_rnd(avctx->bit_rate, 1, 1000,
> +                                                            AV_ROUND_NEAR_INF);

Are these casts needed?

> +        decode_size =
> +            av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
> +                             ctx->twopass_stats.sz);

  decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
                                 ctx->twopass_stats.sz);

> +    //codec control failures are currently treated only as warnings
> +    av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
> +#define codecctl(id,val)\
> +    do if(av_log(avctx,AV_LOG_DEBUG,"%*s%d\n",log_field_width," "#id":",val),\
> +          (res= vpx_codec_control(&ctx->encoder,id,val))!=VPX_CODEC_OK) {\
> +      log_encoder_error(avctx,"Failed to set "#id" codec control");\
> +    } while(0);
> +    codecctl(VP8E_SET_CPUUSED,           cpuused);
> +    codecctl(VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
> +#undef codecctl

I don't like this macro.  IMO it only obfuscates the code.

Diego



More information about the ffmpeg-devel mailing list