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

Michael Niedermayer michaelni
Tue Jun 1 15:02:59 CEST 2010


On Fri, May 28, 2010 at 01:21:06PM -0400, James Zern wrote:
> On Fri, May 28, 2010 at 05:23, Diego Biurrun <diego at biurrun.de> wrote:
> > On Thu, May 27, 2010 at 08:20:38AM -0400, John Koleszar wrote:
> >> On Thu, May 27, 2010 at 7:45 AM, Diego Biurrun <diego at biurrun.de> wrote:
> >> > On Wed, May 26, 2010 at 01:01:23PM -0400, James Zern wrote:
> >> >> On Tue, May 25, 2010 at 20:42, Diego Biurrun <diego at biurrun.de> wrote:
> >> >> > 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.
> >> >> >
> >> >> --disable-vp8-decoder/--disable-vp8-encoder
> >> >
> >> > If this was an attempt at answering my question, it failed, I'm no better
> >> > informed than before. ?Again:
> >> >
> >> > Does libvpx support both encoding and decoding, yes or no?
> >> >
> >> > What are you trying to achieve here by adding split options?
> >>
> >> libvpx can be built decode-only, encode-only, or have both compiled
> >> in. This is probably supporting building an ffmpeg that can link
> >> against a libvpx that's decode-only, for example. Might be able to
> >> autodetect this with nm or something like that.
> >
> > I suspect the same can be done with libdirac and libschroedinger, but we
> > refrain from doing so. ?AFAICT this is not a common configuration.
> > Leave this complication out for now, we can discuss it again once
> > the basic encoding support is merged.
> >
> I noticed those two as well, but as you mention it is a less common
> configuration.
> Updated with the above removed.

[...]
> +
> +static av_cold void dump_enc_cfg(AVCodecContext *avctx,
> +                                 const struct vpx_codec_enc_cfg *cfg)
> +{
> +    int width = -30;
> +    int level = AV_LOG_DEBUG;
> +
> +    av_log(avctx, level, "vpx_codec_enc_cfg\n");
> +    av_log(avctx, level, " %*s%u\n", width, " g_usage:", cfg->g_usage);
> +    av_log(avctx, level, " %*s%u\n", width, " g_threads:", cfg->g_threads);
> +    av_log(avctx, level, " %*s%u\n", width, " g_profile:", cfg->g_profile);
> +    av_log(avctx, level, " %*s%u\n", width, " g_w:", cfg->g_w);
> +    av_log(avctx, level, " %*s%u\n", width, " g_h:", cfg->g_h);
> +    av_log(avctx, level, " %*s{%u/%u}\n", width, " g_timebase:",
> +           cfg->g_timebase.num, cfg->g_timebase.den);
> +    av_log(avctx, level, " %*s%u\n", width, " g_error_resilient:",
> +           cfg->g_error_resilient);
> +    av_log(avctx, level, " %*s%d\n", width, " g_pass:", cfg->g_pass);
> +    av_log(avctx, level, " %*s%u\n", width, " g_lag_in_frames:",
> +           cfg->g_lag_in_frames);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_dropframe_thresh:",
> +           cfg->rc_dropframe_thresh);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_resize_allowed:",
> +           cfg->rc_resize_allowed);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_resize_up_thresh:",
> +           cfg->rc_resize_up_thresh);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_resize_down_thresh:",
> +           cfg->rc_resize_down_thresh);
> +    av_log(avctx, level, " %*s%d\n", width, " rc_end_usage:",
> +           cfg->rc_end_usage);
> +    av_log(avctx, level, " %*s%p(%zu)\n", width, " rc_twopass_stats_in:",
> +           cfg->rc_twopass_stats_in.buf, cfg->rc_twopass_stats_in.sz);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_target_bitrate:",
> +           cfg->rc_target_bitrate);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_min_quantizer:",
> +           cfg->rc_min_quantizer);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_max_quantizer:",
> +           cfg->rc_max_quantizer);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_undershoot_pct:",
> +           cfg->rc_undershoot_pct);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_overshoot_pct:",
> +           cfg->rc_overshoot_pct);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_buf_sz:", cfg->rc_buf_sz);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_buf_initial_sz:",
> +           cfg->rc_buf_initial_sz);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_buf_optimal_sz:",
> +           cfg->rc_buf_optimal_sz);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_2pass_vbr_bias_pct:",
> +           cfg->rc_2pass_vbr_bias_pct);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_2pass_vbr_minsection_pct:",
> +           cfg->rc_2pass_vbr_minsection_pct);
> +    av_log(avctx, level, " %*s%u\n", width, " rc_2pass_vbr_maxsection_pct:",
> +           cfg->rc_2pass_vbr_maxsection_pct);
> +    av_log(avctx, level, " %*s%d\n", width, " kf_mode:", cfg->kf_mode);
> +    av_log(avctx, level, " %*s%u\n", width, " kf_min_dist:", cfg->kf_min_dist);
> +    av_log(avctx, level, " %*s%u\n", width, " kf_max_dist:", cfg->kf_max_dist);
> +    av_log(avctx, level, "\n");

i think this would be more readable without the linebreaks before 80
also maybe it could be done with fewer av_log()


[...]
> +static av_cold int vp8_init(AVCodecContext *avctx)
> +{
> +    VP8Context *ctx = avctx->priv_data;
> +    const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo;
> +    int cpuused = 3;
> +    struct vpx_codec_enc_cfg enccfg;
> +    int res;
> +
> +    av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
> +    av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
> +
> +    if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
> +        av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
> +               vpx_codec_err_to_string(res));
> +        return AVERROR(EINVAL);
> +    }
> +    dump_enc_cfg(avctx, &enccfg);
> +
> +    enccfg.g_w            = avctx->width;
> +    enccfg.g_h            = avctx->height;
> +    enccfg.g_timebase.num = avctx->time_base.num;
> +    enccfg.g_timebase.den = avctx->time_base.den;

> +    enccfg.g_threads      = FFMIN(avctx->thread_count, 64);

why?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100601/8e20071c/attachment.pgp>



More information about the ffmpeg-devel mailing list