From: Hendrik Leppkes Date: Thu, 17 Dec 2015 12:33:20 +0000 (+0100) Subject: Merge commit '03afb62e83516141ba999536fc97575faefb98af' X-Git-Tag: n3.1-dev~1010 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/d6322710c5ec51086aefef9037311922c7aa646c Merge commit '03afb62e83516141ba999536fc97575faefb98af' * commit '03afb62e83516141ba999536fc97575faefb98af': libvpxenc: export CPB props side data Merged-by: Hendrik Leppkes --- d6322710c5ec51086aefef9037311922c7aa646c diff --cc libavcodec/libvpxenc.c index 6e1e915,a3f7b6c..96b1ac6 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@@ -373,13 -212,8 +373,14 @@@ static av_cold int vpx_init(AVCodecCont { VP8Context *ctx = avctx->priv_data; struct vpx_codec_enc_cfg enccfg = { 0 }; + struct vpx_codec_enc_cfg enccfg_alpha; + vpx_codec_flags_t flags = (avctx->flags & AV_CODEC_FLAG_PSNR) ? VPX_CODEC_USE_PSNR : 0; + AVCPBProperties *cpb_props; int res; + vpx_img_fmt_t img_fmt = VPX_IMG_FMT_I420; +#if CONFIG_LIBVPX_VP9_ENCODER + vpx_codec_caps_t codec_caps = vpx_codec_get_caps(iface); +#endif av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str()); av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config()); @@@ -594,43 -357,24 +595,55 @@@ FF_ENABLE_DEPRECATION_WARNINGS #endif codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, ctx->static_thresh); - codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf); + if (ctx->crf >= 0) + codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf); + if (ctx->max_intra_rate >= 0) + codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx->max_intra_rate); + +#if CONFIG_LIBVPX_VP9_ENCODER + if (avctx->codec_id == AV_CODEC_ID_VP9) { + if (ctx->lossless >= 0) + codecctl_int(avctx, VP9E_SET_LOSSLESS, ctx->lossless); + if (ctx->tile_columns >= 0) + codecctl_int(avctx, VP9E_SET_TILE_COLUMNS, ctx->tile_columns); + if (ctx->tile_rows >= 0) + codecctl_int(avctx, VP9E_SET_TILE_ROWS, ctx->tile_rows); + if (ctx->frame_parallel >= 0) + codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING, ctx->frame_parallel); + if (ctx->aq_mode >= 0) + codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx->aq_mode); +#if VPX_ENCODER_ABI_VERSION > 8 + set_colorspace(avctx); +#endif + } +#endif + + av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline); //provide dummy value to initialize wrapper, values will be updated each _encode() - vpx_img_wrap(&ctx->rawimg, ff_vpx_pixfmt_to_imgfmt(avctx->pix_fmt), - avctx->width, avctx->height, 1, (unsigned char *)1); + vpx_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1, + (unsigned char*)1); +#if CONFIG_LIBVPX_VP9_ENCODER && defined(VPX_IMG_FMT_HIGHBITDEPTH) + if (avctx->codec_id == AV_CODEC_ID_VP9 && (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)) + ctx->rawimg.bit_depth = enccfg.g_bit_depth; +#endif + + if (ctx->is_alpha) + vpx_img_wrap(&ctx->rawimg_alpha, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1, + (unsigned char*)1); + cpb_props = ff_add_cpb_side_data(avctx); + if (!cpb_props) + return AVERROR(ENOMEM); + + if (enccfg.rc_end_usage == VPX_CBR || + enccfg.g_pass != VPX_RC_ONE_PASS) { + cpb_props->max_bitrate = avctx->rc_max_rate; + cpb_props->min_bitrate = avctx->rc_min_rate; + cpb_props->avg_bitrate = avctx->bit_rate; + } + cpb_props->buffer_size = avctx->rc_buffer_size; + return 0; }