Message ID | 1479506517-731-2-git-send-email-alex.converse@gmail.com |
---|---|
State | Superseded |
Headers | show |
On Fri, Nov 18, 2016 at 2:01 PM, Alex Converse <alex.converse@gmail.com> wrote: > Report the actual level of the encoded output if a level is > targeted or the level is passively tracked with a target of 0. > --- > libavcodec/libvpxenc.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > lgtm. I don't know if there's a better way to report this at the stream level (AV_PKT_DATA_STRINGS_METADATA?), there doesn't seem to be anything specific right now. This info can be translated quickly if someone wants to make this more structured or has any opinion now. > + > static av_cold int vpx_free(AVCodecContext *avctx) > { > VPxContext *ctx = avctx->priv_data; > + int level_out = 0; could relocate this to avoid unused warnings against older libs. > + > +#if VPX_ENCODER_ABI_VERSION >= 12 > + if (ctx->level >= 0 && !(avctx->flags & AV_CODEC_FLAG_PASS1) && > + !codecctl_intp(avctx, VP9E_GET_LEVEL, &level_out)) > + av_log(avctx, AV_LOG_INFO, "Encoded level %.1f\n", level_out * 0.1); indent is off. > +#endif > > vpx_codec_destroy(&ctx->encoder); > if (ctx->is_alpha) > -- > 2.8.0.rc3.226.g39d4020 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Tue, Nov 22, 2016 at 12:04 PM, James Zern <jzern@google.com> wrote: > On Fri, Nov 18, 2016 at 2:01 PM, Alex Converse <alex.converse@gmail.com> wrote: >> Report the actual level of the encoded output if a level is >> targeted or the level is passively tracked with a target of 0. >> --- >> libavcodec/libvpxenc.c | 31 +++++++++++++++++++++++++++++++ >> 1 file changed, 31 insertions(+) >> > > lgtm. > I don't know if there's a better way to report this at the stream > level (AV_PKT_DATA_STRINGS_METADATA?), there doesn't seem to be > anything specific right now. This info can be translated quickly if > someone wants to make this more structured or has any opinion now. > I forgot that there was some discussion around adding this to the codec extradata in webm. That could be a followup if there's documentation on the format for that.
On Tue, Nov 22, 2016 at 12:08 PM, James Zern <jzern@google.com> wrote: > On Tue, Nov 22, 2016 at 12:04 PM, James Zern <jzern@google.com> wrote: >> On Fri, Nov 18, 2016 at 2:01 PM, Alex Converse <alex.converse@gmail.com> wrote: >>> Report the actual level of the encoded output if a level is >>> targeted or the level is passively tracked with a target of 0. >>> --- >>> libavcodec/libvpxenc.c | 31 +++++++++++++++++++++++++++++++ >>> 1 file changed, 31 insertions(+) >>> >> >> lgtm. >> I don't know if there's a better way to report this at the stream >> level (AV_PKT_DATA_STRINGS_METADATA?), there doesn't seem to be >> anything specific right now. This info can be translated quickly if >> someone wants to make this more structured or has any opinion now. >> > > I forgot that there was some discussion around adding this to the > codec extradata in webm. That could be a followup if there's > documentation on the format for that. http://wiki.webmproject.org/vp9-codecprivate
On Tue, Nov 22, 2016 at 3:10 PM, James Zern <jzern@google.com> wrote: > On Tue, Nov 22, 2016 at 12:08 PM, James Zern <jzern@google.com> wrote: >> On Tue, Nov 22, 2016 at 12:04 PM, James Zern <jzern@google.com> wrote: >>> On Fri, Nov 18, 2016 at 2:01 PM, Alex Converse <alex.converse@gmail.com> wrote: >>>> Report the actual level of the encoded output if a level is >>>> targeted or the level is passively tracked with a target of 0. >>>> --- >>>> libavcodec/libvpxenc.c | 31 +++++++++++++++++++++++++++++++ >>>> 1 file changed, 31 insertions(+) >>>> >>> >>> lgtm. >>> I don't know if there's a better way to report this at the stream >>> level (AV_PKT_DATA_STRINGS_METADATA?), there doesn't seem to be >>> anything specific right now. This info can be translated quickly if >>> someone wants to make this more structured or has any opinion now. >>> >> >> I forgot that there was some discussion around adding this to the >> codec extradata in webm. That could be a followup if there's >> documentation on the format for that. > > http://wiki.webmproject.org/vp9-codecprivate Are there any tools that read or write this data. libavformat and libvpx/webmenc.cc don't seem to implement it. I'd rather not be the guinea pig for this.
On Mon, Nov 28, 2016 at 10:32 AM, Alex Converse <alex.converse@gmail.com> wrote: > On Tue, Nov 22, 2016 at 3:10 PM, James Zern <jzern@google.com> wrote: >> On Tue, Nov 22, 2016 at 12:08 PM, James Zern <jzern@google.com> wrote: >>> On Tue, Nov 22, 2016 at 12:04 PM, James Zern <jzern@google.com> wrote: >>>> On Fri, Nov 18, 2016 at 2:01 PM, Alex Converse <alex.converse@gmail.com> wrote: >>>>> Report the actual level of the encoded output if a level is >>>>> targeted or the level is passively tracked with a target of 0. >>>>> --- >>>>> libavcodec/libvpxenc.c | 31 +++++++++++++++++++++++++++++++ >>>>> 1 file changed, 31 insertions(+) >>>>> >>>> >>>> lgtm. >>>> I don't know if there's a better way to report this at the stream >>>> level (AV_PKT_DATA_STRINGS_METADATA?), there doesn't seem to be >>>> anything specific right now. This info can be translated quickly if >>>> someone wants to make this more structured or has any opinion now. >>>> >>> >>> I forgot that there was some discussion around adding this to the >>> codec extradata in webm. That could be a followup if there's >>> documentation on the format for that. >> >> http://wiki.webmproject.org/vp9-codecprivate > > Are there any tools that read or write this data. libavformat and > libvpx/webmenc.cc don't seem to implement it. I'd rather not be the > guinea pig for this. libwebm has support in the muxer sample and webm_info for reporting: https://chromium.googlesource.com/webm/libwebm/+/master/mkvmuxer_sample.cc#471 https://chromium.googlesource.com/webm/libwebm/+/master/webm_info.cc#381
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 51f423a..a2fb82e 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -137,6 +137,7 @@ static const char *const ctlidstr[] = { #endif #if VPX_ENCODER_ABI_VERSION >= 12 [VP9E_SET_TARGET_LEVEL] = "VP9E_SET_TARGET_LEVEL", + [VP9E_GET_LEVEL] = "VP9E_GET_LEVEL", #endif #endif }; @@ -264,9 +265,39 @@ static av_cold int codecctl_int(AVCodecContext *avctx, return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL); } +#if VPX_ENCODER_ABI_VERSION >= 12 +static av_cold int codecctl_intp(AVCodecContext *avctx, + enum vp8e_enc_control_id id, int *val) +{ + VPxContext *ctx = avctx->priv_data; + char buf[80]; + int width = -30; + int res; + + snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]); + av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, *val); + + res = vpx_codec_control(&ctx->encoder, id, val); + if (res != VPX_CODEC_OK) { + snprintf(buf, sizeof(buf), "Failed to set %s codec control", + ctlidstr[id]); + log_encoder_error(avctx, buf); + } + + return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL); +} +#endif + static av_cold int vpx_free(AVCodecContext *avctx) { VPxContext *ctx = avctx->priv_data; + int level_out = 0; + +#if VPX_ENCODER_ABI_VERSION >= 12 + if (ctx->level >= 0 && !(avctx->flags & AV_CODEC_FLAG_PASS1) && + !codecctl_intp(avctx, VP9E_GET_LEVEL, &level_out)) + av_log(avctx, AV_LOG_INFO, "Encoded level %.1f\n", level_out * 0.1); +#endif vpx_codec_destroy(&ctx->encoder); if (ctx->is_alpha)