[FFmpeg-devel] [PATCH] libavcodec/libaomenc.c: Added code for computing PSNR/SSIM for libaom encoder.
--- libavcodec/libaomenc.c | 117 + 1 file changed, 96 insertions(+), 21 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 9431179886..e62057177d 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -50,6 +50,9 @@ struct FrameListData { unsigned long duration; /**< duration to show frame (in timebase units) */ uint32_t flags; /**< flags for this frame */ +uint64_t sse[4]; +int have_sse;/**< true if we have pending sse[] */ +uint64_t frame_number; struct FrameListData *next; }; @@ -68,6 +71,9 @@ typedef struct AOMEncoderContext { int static_thresh; int drop_threshold; int noise_sensitivity; +uint64_t sse[4]; +int have_sse; /**< true if we have pending sse[] */ +uint64_t frame_number; } AOMContext; static const char *const ctlidstr[] = { @@ -289,7 +295,8 @@ static av_cold int aom_init(AVCodecContext *avctx, { AOMContext *ctx = avctx->priv_data; struct aom_codec_enc_cfg enccfg = { 0 }; -aom_codec_flags_t flags = 0; +aom_codec_flags_t flags = +(avctx->flags & AV_CODEC_FLAG_PSNR) ? AOM_CODEC_USE_PSNR : 0; AVCPBProperties *cpb_props; int res; aom_img_fmt_t img_fmt; @@ -499,13 +506,30 @@ static av_cold int aom_init(AVCodecContext *avctx, } static inline void cx_pktcpy(struct FrameListData *dst, - const struct aom_codec_cx_pkt *src) + const struct aom_codec_cx_pkt *src, + AOMContext *ctx) { dst->pts = src->data.frame.pts; dst->duration = src->data.frame.duration; dst->flags= src->data.frame.flags; dst->sz = src->data.frame.sz; dst->buf = src->data.frame.buf; +dst->have_sse = 0; +/* For alt-ref frame, don't store PSNR or increment frame_number */ +if (!(dst->flags & AOM_FRAME_IS_INVISIBLE)) { +dst->frame_number = ++ctx->frame_number; +dst->have_sse = ctx->have_sse; +if (ctx->have_sse) { +/* associate last-seen SSE to the frame. */ +/* Transfers ownership from ctx to dst. */ +/* WARNING! This makes the assumption that PSNR_PKT comes + just before the frame it refers to! */ +memcpy(dst->sse, ctx->sse, sizeof(dst->sse)); +ctx->have_sse = 0; +} +} else { +dst->frame_number = -1; /* sanity marker */ +} } /** @@ -524,26 +548,68 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %"SIZE_SPECIFIER".\n", cx_frame->sz); return ret; -} -memcpy(pkt->data, cx_frame->buf, pkt->size); -pkt->pts = pkt->dts = cx_frame->pts; +} else { +int pict_type; +memcpy(pkt->data, cx_frame->buf, pkt->size); +pkt->pts = pkt->dts = cx_frame->pts; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS +avctx->coded_frame->pts = cx_frame->pts; +avctx->coded_frame->key_frame = !!(cx_frame->flags & AOM_FRAME_IS_KEY); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + +if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) { +pict_type = AV_PICTURE_TYPE_I; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS +avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +#endif +pkt->flags |= AV_PKT_FLAG_KEY; +} else { +pict_type = AV_PICTURE_TYPE_P; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS +avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +#endif +} -if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) -pkt->flags |= AV_PKT_FLAG_KEY; +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { +ret = av_bsf_send_packet(ctx->bsf, pkt); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "extract_extradata filter " +"failed to send input packet\n"); +return ret; +} +ret = av_bsf_receive_packet(ctx->bsf, pkt); -if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { -ret = av_bsf_send_packet(ctx->bsf, pkt); -if (ret < 0) { -av_log(avctx, AV_LOG_ERROR, "extract_extradata filter " - "failed to send input packet\n"); -return ret; +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "extract_extradata filter " +"failed to receive output packet\n"); +return ret; +} } -ret = av_bsf_receive_packet(ctx->bsf, pkt); -if (ret < 0) { -av_log(avctx, AV_LOG_ERROR, "extract_extradata filter " - "failed to receive output packet\n"); -
Re: [FFmpeg-devel] [PATCH] libavcodec/libaomenc.c: Added code for computing PSNR/SSIM for libaom encoder.
James, > Did you copy this chunk from the libvpxenc wrapper? Because I don't >think this is valid at all for libaom. A quick grep on their tree shows >that AOM_FRAME_IS_INVISIBLE is never set anywhere. It looks like a >leftover flag they forgot to remove from the libvpx codebase I used the same logic as libvpx. The flag AOM_FRAME_IS_INVISIBLE is not set at present. But I hope that this flag will be updated soon. I will update the code to remove this flag from my patch for now. > Does libaom have a flag or field to signal the type of the visible frame > in the returned packet? At present libaom doesn't set the flag for the INTRA_ONLY in the returned packet. Until this flag is updated, we can use the same logic as libvpx. I will make these corrections and update the patch for review. On Sat, Sep 8, 2018 at 12:23 PM James Almer wrote: > On 9/7/2018 8:51 PM, Sam John wrote: > > --- > > libavcodec/libaomenc.c | 117 + > > 1 file changed, 96 insertions(+), 21 deletions(-) > > > > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c > > index 9431179886..e62057177d 100644 > > --- a/libavcodec/libaomenc.c > > +++ b/libavcodec/libaomenc.c > > @@ -50,6 +50,9 @@ struct FrameListData { > > unsigned long duration; /**< duration to show frame > >(in timebase units) */ > > uint32_t flags; /**< flags for this frame */ > > +uint64_t sse[4]; > > +int have_sse;/**< true if we have pending sse[] > */ > > +uint64_t frame_number; > > struct FrameListData *next; > > }; > > > > @@ -68,6 +71,9 @@ typedef struct AOMEncoderContext { > > int static_thresh; > > int drop_threshold; > > int noise_sensitivity; > > +uint64_t sse[4]; > > +int have_sse; /**< true if we have pending sse[] */ > > +uint64_t frame_number; > > } AOMContext; > > > > static const char *const ctlidstr[] = { > > @@ -289,7 +295,8 @@ static av_cold int aom_init(AVCodecContext *avctx, > > { > > AOMContext *ctx = avctx->priv_data; > > struct aom_codec_enc_cfg enccfg = { 0 }; > > -aom_codec_flags_t flags = 0; > > +aom_codec_flags_t flags = > > +(avctx->flags & AV_CODEC_FLAG_PSNR) ? AOM_CODEC_USE_PSNR : 0; > > AVCPBProperties *cpb_props; > > int res; > > aom_img_fmt_t img_fmt; > > @@ -499,13 +506,30 @@ static av_cold int aom_init(AVCodecContext *avctx, > > } > > > > static inline void cx_pktcpy(struct FrameListData *dst, > > - const struct aom_codec_cx_pkt *src) > > + const struct aom_codec_cx_pkt *src, > > + AOMContext *ctx) > > { > > dst->pts = src->data.frame.pts; > > dst->duration = src->data.frame.duration; > > dst->flags= src->data.frame.flags; > > dst->sz = src->data.frame.sz; > > dst->buf = src->data.frame.buf; > > +dst->have_sse = 0; > > +/* For alt-ref frame, don't store PSNR or increment frame_number */ > > +if (!(dst->flags & AOM_FRAME_IS_INVISIBLE)) { > > Did you copy this chunk from the libvpxenc wrapper? Because I don't > think this is valid at all for libaom. A quick grep on their tree shows > that AOM_FRAME_IS_INVISIBLE is never set anywhere. It looks like a > leftover flag they forgot to remove from the libvpx codebase. > > > +dst->frame_number = ++ctx->frame_number; > > +dst->have_sse = ctx->have_sse; > > +if (ctx->have_sse) { > > +/* associate last-seen SSE to the frame. */ > > +/* Transfers ownership from ctx to dst. */ > > +/* WARNING! This makes the assumption that PSNR_PKT comes > > + just before the frame it refers to! */ > > +memcpy(dst->sse, ctx->sse, sizeof(dst->sse)); > > +ctx->have_sse = 0; > > +} > > +} else { > > +dst->frame_number = -1; /* sanity marker */ > > +} > > } > > > > /** > > @@ -524,26 +548,68 @@ static int storeframe(AVCodecContext *avctx, > struct FrameListData *cx_frame, > > av_log(avctx, AV_LOG_ERROR, > > "Error getting output packet of size > %"SIZE_SPECIFIER".\n", cx_frame->sz); > > return ret; > > -} > > -memcpy(pkt->dat
[FFmpeg-devel] [PATCH] libavcodec/libaomenc.c: Added code for computing PSNR/SSIM for libaom encoder.Updated the patch to read the AV_PICTURE_TYPE_I flag for AOM.
--- libavcodec/libaomenc.c | 83 ++ 1 file changed, 75 insertions(+), 8 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 6a79d9b873..4e75ca0b18 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -50,6 +50,9 @@ struct FrameListData { unsigned long duration; /**< duration to show frame (in timebase units) */ uint32_t flags; /**< flags for this frame */ +uint64_t sse[4]; +int have_sse;/**< true if we have pending sse[] */ +uint64_t frame_number; struct FrameListData *next; }; @@ -68,6 +71,9 @@ typedef struct AOMEncoderContext { int static_thresh; int drop_threshold; int noise_sensitivity; +uint64_t sse[4]; +int have_sse; /**< true if we have pending sse[] */ +uint64_t frame_number; } AOMContext; static const char *const ctlidstr[] = { @@ -289,7 +295,8 @@ static av_cold int aom_init(AVCodecContext *avctx, { AOMContext *ctx = avctx->priv_data; struct aom_codec_enc_cfg enccfg = { 0 }; -aom_codec_flags_t flags = 0; +aom_codec_flags_t flags = +(avctx->flags & AV_CODEC_FLAG_PSNR) ? AOM_CODEC_USE_PSNR : 0; AVCPBProperties *cpb_props; int res; aom_img_fmt_t img_fmt; @@ -499,13 +506,23 @@ static av_cold int aom_init(AVCodecContext *avctx, } static inline void cx_pktcpy(struct FrameListData *dst, - const struct aom_codec_cx_pkt *src) + const struct aom_codec_cx_pkt *src, + AOMContext *ctx) { dst->pts = src->data.frame.pts; dst->duration = src->data.frame.duration; dst->flags= src->data.frame.flags; dst->sz = src->data.frame.sz; dst->buf = src->data.frame.buf; +dst->have_sse = 0; +dst->frame_number = ++ctx->frame_number; +dst->have_sse = ctx->have_sse; +if (ctx->have_sse) { +/* associate last-seen SSE to the frame. */ +/* Transfers ownership from ctx to dst. */ +memcpy(dst->sse, ctx->sse, sizeof(dst->sse)); +ctx->have_sse = 0; +} } /** @@ -519,6 +536,7 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, AVPacket *pkt) { AOMContext *ctx = avctx->priv_data; +int pict_type; int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, @@ -527,11 +545,51 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, } memcpy(pkt->data, cx_frame->buf, pkt->size); pkt->pts = pkt->dts = cx_frame->pts; - -if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) +FF_DISABLE_DEPRECATION_WARNINGS +avctx->coded_frame->pts = cx_frame->pts; +avctx->coded_frame->key_frame = !!(cx_frame->flags & AOM_FRAME_IS_KEY); +FF_ENABLE_DEPRECATION_WARNINGS + +if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) { +pict_type = AV_PICTURE_TYPE_I; +FF_DISABLE_DEPRECATION_WARNINGS +avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS pkt->flags |= AV_PKT_FLAG_KEY; +} else { +#ifdef AOM_FRAME_IS_INTRAONLY +if (cx_frame->flags & AOM_FRAME_IS_INTRAONLY) +pict_type = AV_PICTURE_TYPE_I; +else +pict_type = AV_PICTURE_TYPE_P; +#else +pict_type = AV_PICTURE_TYPE_P; +#endif + +FF_DISABLE_DEPRECATION_WARNINGS +avctx->coded_frame->pict_type = pict_type; +FF_ENABLE_DEPRECATION_WARNINGS +} -if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { +ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1, + cx_frame->have_sse ? 3 : 0, pict_type); + +if (cx_frame->have_sse) { +int i; +/* Beware of the Y/U/V/all order! */ +FF_DISABLE_DEPRECATION_WARNINGS +avctx->coded_frame->error[0] = cx_frame->sse[1]; +avctx->coded_frame->error[1] = cx_frame->sse[2]; +avctx->coded_frame->error[2] = cx_frame->sse[3]; +avctx->coded_frame->error[3] = 0;// alpha +FF_ENABLE_DEPRECATION_WARNINGS +for (i = 0; i < 3; ++i) { +avctx->error[i] += cx_frame->sse[i + 1]; +} +cx_frame->have_sse = 0; +} + + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { ret = av_bsf_send_packet(ctx->bsf, pkt); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "extract_extradata filter " @@ -585,7 +643,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out) /* avoid storing the frame when the list is empty and we haven't yet * provided a frame for output */ av_assert0(!ctx->coded_frame_list); -cx_pktcpy(&cx_frame, pkt); +cx_pktcpy(&cx_frame, pkt, ctx); size = storeframe(avctx, &cx_frame, pkt_out); if (
[FFmpeg-devel] [PATCH] libavcodec/libaomenc.c: Added code for computing PSNR/SSIM for libaom encoder.Updated the patch to read the AV_PICTURE_TYPE_I flag for AOM.
--- libavcodec/libaomenc.c | 60 +- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 6a79d9b873..481338406c 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -50,6 +50,9 @@ struct FrameListData { unsigned long duration; /**< duration to show frame (in timebase units) */ uint32_t flags; /**< flags for this frame */ +uint64_t sse[4]; +int have_sse;/**< true if we have pending sse[] */ +uint64_t frame_number; struct FrameListData *next; }; @@ -68,6 +71,9 @@ typedef struct AOMEncoderContext { int static_thresh; int drop_threshold; int noise_sensitivity; +uint64_t sse[4]; +int have_sse; /**< true if we have pending sse[] */ +uint64_t frame_number; } AOMContext; static const char *const ctlidstr[] = { @@ -289,7 +295,8 @@ static av_cold int aom_init(AVCodecContext *avctx, { AOMContext *ctx = avctx->priv_data; struct aom_codec_enc_cfg enccfg = { 0 }; -aom_codec_flags_t flags = 0; +aom_codec_flags_t flags = +(avctx->flags & AV_CODEC_FLAG_PSNR) ? AOM_CODEC_USE_PSNR : 0; AVCPBProperties *cpb_props; int res; aom_img_fmt_t img_fmt; @@ -499,13 +506,23 @@ static av_cold int aom_init(AVCodecContext *avctx, } static inline void cx_pktcpy(struct FrameListData *dst, - const struct aom_codec_cx_pkt *src) + const struct aom_codec_cx_pkt *src, + AOMContext *ctx) { dst->pts = src->data.frame.pts; dst->duration = src->data.frame.duration; dst->flags= src->data.frame.flags; dst->sz = src->data.frame.sz; dst->buf = src->data.frame.buf; +dst->have_sse = 0; +dst->frame_number = ++ctx->frame_number; +dst->have_sse = ctx->have_sse; +if (ctx->have_sse) { +/* associate last-seen SSE to the frame. */ +/* Transfers ownership from ctx to dst. */ +memcpy(dst->sse, ctx->sse, sizeof(dst->sse)); +ctx->have_sse = 0; +} } /** @@ -519,6 +536,7 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, AVPacket *pkt) { AOMContext *ctx = avctx->priv_data; +int pict_type; int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, @@ -528,8 +546,29 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, memcpy(pkt->data, cx_frame->buf, pkt->size); pkt->pts = pkt->dts = cx_frame->pts; -if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) +if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) { +pict_type = AV_PICTURE_TYPE_I; pkt->flags |= AV_PKT_FLAG_KEY; +} else { +#ifdef AOM_FRAME_IS_INTRAONLY +if (cx_frame->flags & AOM_FRAME_IS_INTRAONLY) +pict_type = AV_PICTURE_TYPE_I; +else +#else +pict_type = AV_PICTURE_TYPE_P; +#endif +} + +ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1, + cx_frame->have_sse ? 3 : 0, pict_type); + +if (cx_frame->have_sse) { +int i; +for (i = 0; i < 3; ++i) { +avctx->error[i] += cx_frame->sse[i + 1]; +} +cx_frame->have_sse = 0; +} if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { ret = av_bsf_send_packet(ctx->bsf, pkt); @@ -585,7 +624,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out) /* avoid storing the frame when the list is empty and we haven't yet * provided a frame for output */ av_assert0(!ctx->coded_frame_list); -cx_pktcpy(&cx_frame, pkt); +cx_pktcpy(&cx_frame, pkt, ctx); size = storeframe(avctx, &cx_frame, pkt_out); if (size < 0) return size; @@ -598,7 +637,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out) "Frame queue element alloc failed\n"); return AVERROR(ENOMEM); } -cx_pktcpy(cx_frame, pkt); +cx_pktcpy(cx_frame, pkt, ctx); cx_frame->buf = av_malloc(cx_frame->sz); if (!cx_frame->buf) { @@ -628,7 +667,16 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out) stats->sz += pkt->data.twopass_stats.sz; break; } -case AOM_CODEC_PSNR_PKT: // FIXME add support for AV_CODEC_FLAG_PSNR +case AOM_CODEC_PSNR_PKT: +{ +av_assert0(!ctx->have_sse); +ctx->sse[0] = pkt->data.psnr.sse[0]; +ctx->sse[1] = pkt->data.psnr.sse[1]; +ctx->sse[2] = pkt->data.psnr.sse[2]; +ctx->sse[3] = p
Re: [FFmpeg-devel] [PATCH] libavcodec/libaomenc.c: Added code for computing PSNR/SSIM for libaom encoder.Updated the patch to read the AV_PICTURE_TYPE_I flag for AOM.
James, Is there anything to be done for this patch? Can you please approve this change and apply the patch to ffmpeg head. On Fri, Sep 28, 2018 at 3:09 PM Sam John wrote: > --- > libavcodec/libaomenc.c | 60 +- > 1 file changed, 54 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c > index 6a79d9b873..481338406c 100644 > --- a/libavcodec/libaomenc.c > +++ b/libavcodec/libaomenc.c > @@ -50,6 +50,9 @@ struct FrameListData { > unsigned long duration; /**< duration to show frame >(in timebase units) */ > uint32_t flags; /**< flags for this frame */ > +uint64_t sse[4]; > +int have_sse;/**< true if we have pending sse[] */ > +uint64_t frame_number; > struct FrameListData *next; > }; > > @@ -68,6 +71,9 @@ typedef struct AOMEncoderContext { > int static_thresh; > int drop_threshold; > int noise_sensitivity; > +uint64_t sse[4]; > +int have_sse; /**< true if we have pending sse[] */ > +uint64_t frame_number; > } AOMContext; > > static const char *const ctlidstr[] = { > @@ -289,7 +295,8 @@ static av_cold int aom_init(AVCodecContext *avctx, > { > AOMContext *ctx = avctx->priv_data; > struct aom_codec_enc_cfg enccfg = { 0 }; > -aom_codec_flags_t flags = 0; > +aom_codec_flags_t flags = > +(avctx->flags & AV_CODEC_FLAG_PSNR) ? AOM_CODEC_USE_PSNR : 0; > AVCPBProperties *cpb_props; > int res; > aom_img_fmt_t img_fmt; > @@ -499,13 +506,23 @@ static av_cold int aom_init(AVCodecContext *avctx, > } > > static inline void cx_pktcpy(struct FrameListData *dst, > - const struct aom_codec_cx_pkt *src) > + const struct aom_codec_cx_pkt *src, > + AOMContext *ctx) > { > dst->pts = src->data.frame.pts; > dst->duration = src->data.frame.duration; > dst->flags= src->data.frame.flags; > dst->sz = src->data.frame.sz; > dst->buf = src->data.frame.buf; > +dst->have_sse = 0; > +dst->frame_number = ++ctx->frame_number; > +dst->have_sse = ctx->have_sse; > +if (ctx->have_sse) { > +/* associate last-seen SSE to the frame. */ > +/* Transfers ownership from ctx to dst. */ > +memcpy(dst->sse, ctx->sse, sizeof(dst->sse)); > +ctx->have_sse = 0; > +} > } > > /** > @@ -519,6 +536,7 @@ static int storeframe(AVCodecContext *avctx, struct > FrameListData *cx_frame, >AVPacket *pkt) > { > AOMContext *ctx = avctx->priv_data; > +int pict_type; > int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0); > if (ret < 0) { > av_log(avctx, AV_LOG_ERROR, > @@ -528,8 +546,29 @@ static int storeframe(AVCodecContext *avctx, struct > FrameListData *cx_frame, > memcpy(pkt->data, cx_frame->buf, pkt->size); > pkt->pts = pkt->dts = cx_frame->pts; > > -if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) > +if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) { > +pict_type = AV_PICTURE_TYPE_I; > pkt->flags |= AV_PKT_FLAG_KEY; > +} else { > +#ifdef AOM_FRAME_IS_INTRAONLY > +if (cx_frame->flags & AOM_FRAME_IS_INTRAONLY) > +pict_type = AV_PICTURE_TYPE_I; > +else > +#else > +pict_type = AV_PICTURE_TYPE_P; > +#endif > +} > + > +ff_side_data_set_encoder_stats(pkt, 0, cx_frame->sse + 1, > + cx_frame->have_sse ? 3 : 0, pict_type); > + > +if (cx_frame->have_sse) { > +int i; > +for (i = 0; i < 3; ++i) { > +avctx->error[i] += cx_frame->sse[i + 1]; > +} > +cx_frame->have_sse = 0; > +} > > if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { > ret = av_bsf_send_packet(ctx->bsf, pkt); > @@ -585,7 +624,7 @@ static int queue_frames(AVCodecContext *avctx, > AVPacket *pkt_out) > /* avoid storing the frame when the list is empty and we > haven't yet > * provided a frame for output */ > av_assert0(!ctx->coded_frame_list); > -cx_pktcpy(&cx_frame, pkt); > +cx_pktcpy(&cx_frame, pkt, ctx); > size = storeframe(avctx, &cx_frame, pkt_out); > if (size < 0) >
[FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.
The following are the newly added options: arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, denoise_block_size, rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, frame_parallel, enable_cdef, and enable_global_motion. --- libavcodec/libaomenc.c | 71 -- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index faec61cacd..687ea5f2c7 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -66,36 +66,57 @@ typedef struct AOMEncoderContext { struct FrameListData *coded_frame_list; int cpu_used; int auto_alt_ref; +int arnr_max_frames; +int arnr_strength; +int aq_mode; int lag_in_frames; int error_resilient; int crf; int static_thresh; int drop_threshold; +int denoise_noise_level; +int denoise_block_size; uint64_t sse[4]; int have_sse; /**< true if we have pending sse[] */ uint64_t frame_number; +int rc_undershoot_pct; +int rc_overshoot_pct; +int minsection_pct; +int maxsection_pct; +int frame_parallel; int tile_cols, tile_rows; int tile_cols_log2, tile_rows_log2; aom_superblock_size_t superblock_size; int uniform_tiles; int row_mt; +int enable_cdef; +int enable_global_motion; } AOMContext; static const char *const ctlidstr[] = { [AOME_SET_CPUUSED] = "AOME_SET_CPUUSED", [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL", [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF", +[AOME_SET_ARNR_MAXFRAMES] = "AOME_SET_ARNR_MAXFRAMES", +[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH", [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD", [AV1E_SET_COLOR_RANGE] = "AV1E_SET_COLOR_RANGE", [AV1E_SET_COLOR_PRIMARIES] = "AV1E_SET_COLOR_PRIMARIES", +[AV1E_SET_DENOISE_NOISE_LEVEL] = "AV1E_SET_DENOISE_NOISE_LEVEL", +[AV1E_SET_DENOISE_BLOCK_SIZE] = "AV1E_SET_DENOISE_BLOCK_SIZE", [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS", [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS", +[AV1E_SET_AQ_MODE] = "AV1E_SET_AQ_MODE", +[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING", [AV1E_SET_SUPERBLOCK_SIZE] = "AV1E_SET_SUPERBLOCK_SIZE", [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS", [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS", +[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES", #ifdef AOM_CTRL_AV1E_SET_ROW_MT [AV1E_SET_ROW_MT] = "AV1E_SET_ROW_MT", #endif +[AV1E_SET_ENABLE_CDEF] = "AV1E_SET_ENABLE_CDEF", +[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION", }; static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) @@ -567,10 +588,14 @@ static av_cold int aom_init(AVCodecContext *avctx, // 0-100 (0 => CBR, 100 => VBR) enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100); -if (avctx->bit_rate) +if (ctx->minsection_pct >= 0) +enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct; +else if (avctx->bit_rate) enccfg.rc_2pass_vbr_minsection_pct = avctx->rc_min_rate * 100LL / avctx->bit_rate; -if (avctx->rc_max_rate) +if (ctx->maxsection_pct >= 0) +enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct; +else if (avctx->rc_max_rate) enccfg.rc_2pass_vbr_maxsection_pct = avctx->rc_max_rate * 100LL / avctx->bit_rate; @@ -582,6 +607,11 @@ static av_cold int aom_init(AVCodecContext *avctx, avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate; enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6; +if (ctx->rc_undershoot_pct >= 0) +enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct; +if (ctx->rc_overshoot_pct >= 0) +enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct; + // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size) enccfg.kf_min_dist = avctx->keyint_min; @@ -643,14 +673,30 @@ static av_cold int aom_init(AVCodecContext *avctx, codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used); if (ctx->auto_alt_ref >= 0) codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref); - +if (ctx->arnr_max_frames >= 0) +codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames); +if (ctx->arnr_strength >= 0) +codecctl_int(avctx, AOME_SET_ARNR_STRENGTH,ctx->arnr_strength); +if (ctx->enable_cdef >= 0) +codecctl_int(avctx, AV1E_SET_ENABLE_CDEF, ctx->enable_cdef); +if (ctx->enable_global_motion >= 0) +codecctl_int(avctx, AV1E_SET_ENABLE_GLOBAL_MOTION, ctx->enable_global_motion); codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh); if (c
[FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.
The following are the newly added options: arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, denoise_block_size, rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, frame_parallel, enable_cdef, and enable_global_motion. Also added macros for compiling for aom 1.0.0. --- libavcodec/libaomenc.c | 86 -- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index faec61cacd..8e0ba7241e 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -66,36 +66,65 @@ typedef struct AOMEncoderContext { struct FrameListData *coded_frame_list; int cpu_used; int auto_alt_ref; +int arnr_max_frames; +int arnr_strength; +int aq_mode; int lag_in_frames; int error_resilient; int crf; int static_thresh; int drop_threshold; +int denoise_noise_level; +int denoise_block_size; uint64_t sse[4]; int have_sse; /**< true if we have pending sse[] */ uint64_t frame_number; +int rc_undershoot_pct; +int rc_overshoot_pct; +int minsection_pct; +int maxsection_pct; +int frame_parallel; int tile_cols, tile_rows; int tile_cols_log2, tile_rows_log2; aom_superblock_size_t superblock_size; int uniform_tiles; int row_mt; +int enable_cdef; +int enable_global_motion; } AOMContext; static const char *const ctlidstr[] = { [AOME_SET_CPUUSED] = "AOME_SET_CPUUSED", [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL", [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF", +[AOME_SET_ARNR_MAXFRAMES] = "AOME_SET_ARNR_MAXFRAMES", +[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH", [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD", [AV1E_SET_COLOR_RANGE] = "AV1E_SET_COLOR_RANGE", [AV1E_SET_COLOR_PRIMARIES] = "AV1E_SET_COLOR_PRIMARIES", [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS", [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS", +[AV1E_SET_AQ_MODE] = "AV1E_SET_AQ_MODE", +[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING", [AV1E_SET_SUPERBLOCK_SIZE] = "AV1E_SET_SUPERBLOCK_SIZE", [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS", [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS", #ifdef AOM_CTRL_AV1E_SET_ROW_MT [AV1E_SET_ROW_MT] = "AV1E_SET_ROW_MT", #endif +#ifdef AV1E_SET_DENOISE_NOISE_LEVEL +[AV1E_SET_DENOISE_NOISE_LEVEL] = "AV1E_SET_DENOISE_NOISE_LEVEL", +#endif +#ifdef AV1E_SET_DENOISE_BLOCK_SIZE +[AV1E_SET_DENOISE_BLOCK_SIZE] = "AV1E_SET_DENOISE_BLOCK_SIZE", +#endif +#ifdef AV1E_SET_MAX_REFERENCE_FRAMES +[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES", +#endif +#ifdef AV1E_SET_ENABLE_GLOBAL_MOTION +[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION", +#endif +[AV1E_SET_ENABLE_CDEF] = "AV1E_SET_ENABLE_CDEF", }; static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) @@ -567,10 +596,14 @@ static av_cold int aom_init(AVCodecContext *avctx, // 0-100 (0 => CBR, 100 => VBR) enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100); -if (avctx->bit_rate) +if (ctx->minsection_pct >= 0) +enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct; +else if (avctx->bit_rate) enccfg.rc_2pass_vbr_minsection_pct = avctx->rc_min_rate * 100LL / avctx->bit_rate; -if (avctx->rc_max_rate) +if (ctx->maxsection_pct >= 0) +enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct; +else if (avctx->rc_max_rate) enccfg.rc_2pass_vbr_maxsection_pct = avctx->rc_max_rate * 100LL / avctx->bit_rate; @@ -582,6 +615,11 @@ static av_cold int aom_init(AVCodecContext *avctx, avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate; enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6; +if (ctx->rc_undershoot_pct >= 0) +enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct; +if (ctx->rc_overshoot_pct >= 0) +enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct; + // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size) enccfg.kf_min_dist = avctx->keyint_min; @@ -643,7 +681,12 @@ static av_cold int aom_init(AVCodecContext *avctx, codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used); if (ctx->auto_alt_ref >= 0) codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref); - +if (ctx->arnr_max_frames >= 0) +codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames); +if (ctx->arnr_strength >= 0) +codecctl_int(avctx, AOME_SET_ARNR_STRENGTH,ctx->arnr_strength); +if (ctx->enable_cdef >= 0) +codecctl_int(avctx, AV1E_SET_ENABLE_CDEF, c
Re: [FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.
Thank you James and Moritz. For many of these parameters, the default value within the codec is '1'. So we want to add the option for disabling it also. I would like to follow the method used for "frame-parallel", after changing the default value to -1. { "frame-parallel", "Enable frame parallel decodability features", OFFSET(frame_parallel), AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1, VE}, if (frame_parallel >= 0) { .. } I will send the updated patch soon. On Tue, Mar 12, 2019 at 9:14 AM Moritz Barsnick wrote: > On Tue, Mar 12, 2019 at 11:45:06 -0300, James Almer wrote: > > > +{ "frame-parallel", "Enable frame parallel decodability > features", OFFSET(frame_parallel), AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1, > VE}, > > > > A bool with three values is weird. If this is meant to be disabled by > > default, then just make it 0 and remove the >= 0 condition above. > > It's actually quite common with ffmpeg options. Such an option can only > be assigned true or false, but if it isn't assigned, it will be e.g. -1 > and can be used to trigger a default mode, as is apparently done here > (by not setting this option through the API, probably letting the > library do whatever it considers default). > > Cheers, > Moritz > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.
The following are the newly added options: arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, denoise_block_size, rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, frame_parallel, enable_cdef, and enable_global_motion. Also added macros for compiling for aom 1.0.0 and fixed the default values. --- libavcodec/libaomenc.c | 88 -- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index faec61cacd..7d4a5ac447 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -66,36 +66,65 @@ typedef struct AOMEncoderContext { struct FrameListData *coded_frame_list; int cpu_used; int auto_alt_ref; +int arnr_max_frames; +int arnr_strength; +int aq_mode; int lag_in_frames; int error_resilient; int crf; int static_thresh; int drop_threshold; +int denoise_noise_level; +int denoise_block_size; uint64_t sse[4]; int have_sse; /**< true if we have pending sse[] */ uint64_t frame_number; +int rc_undershoot_pct; +int rc_overshoot_pct; +int minsection_pct; +int maxsection_pct; +int frame_parallel; int tile_cols, tile_rows; int tile_cols_log2, tile_rows_log2; aom_superblock_size_t superblock_size; int uniform_tiles; int row_mt; +int enable_cdef; +int enable_global_motion; } AOMContext; static const char *const ctlidstr[] = { [AOME_SET_CPUUSED] = "AOME_SET_CPUUSED", [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL", [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF", +[AOME_SET_ARNR_MAXFRAMES] = "AOME_SET_ARNR_MAXFRAMES", +[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH", [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD", [AV1E_SET_COLOR_RANGE] = "AV1E_SET_COLOR_RANGE", [AV1E_SET_COLOR_PRIMARIES] = "AV1E_SET_COLOR_PRIMARIES", [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS", [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS", +[AV1E_SET_AQ_MODE] = "AV1E_SET_AQ_MODE", +[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING", [AV1E_SET_SUPERBLOCK_SIZE] = "AV1E_SET_SUPERBLOCK_SIZE", [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS", [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS", #ifdef AOM_CTRL_AV1E_SET_ROW_MT [AV1E_SET_ROW_MT] = "AV1E_SET_ROW_MT", #endif +#ifdef AV1E_SET_DENOISE_NOISE_LEVEL +[AV1E_SET_DENOISE_NOISE_LEVEL] = "AV1E_SET_DENOISE_NOISE_LEVEL", +#endif +#ifdef AV1E_SET_DENOISE_BLOCK_SIZE +[AV1E_SET_DENOISE_BLOCK_SIZE] = "AV1E_SET_DENOISE_BLOCK_SIZE", +#endif +#ifdef AV1E_SET_MAX_REFERENCE_FRAMES +[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES", +#endif +#ifdef AV1E_SET_ENABLE_GLOBAL_MOTION +[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION", +#endif +[AV1E_SET_ENABLE_CDEF] = "AV1E_SET_ENABLE_CDEF", }; static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) @@ -567,10 +596,14 @@ static av_cold int aom_init(AVCodecContext *avctx, // 0-100 (0 => CBR, 100 => VBR) enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100); -if (avctx->bit_rate) +if (ctx->minsection_pct >= 0) +enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct; +else if (avctx->bit_rate) enccfg.rc_2pass_vbr_minsection_pct = avctx->rc_min_rate * 100LL / avctx->bit_rate; -if (avctx->rc_max_rate) +if (ctx->maxsection_pct >= 0) +enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct; +else if (avctx->rc_max_rate) enccfg.rc_2pass_vbr_maxsection_pct = avctx->rc_max_rate * 100LL / avctx->bit_rate; @@ -582,6 +615,11 @@ static av_cold int aom_init(AVCodecContext *avctx, avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate; enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6; +if (ctx->rc_undershoot_pct >= 0) +enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct; +if (ctx->rc_overshoot_pct >= 0) +enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct; + // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size) enccfg.kf_min_dist = avctx->keyint_min; @@ -643,7 +681,12 @@ static av_cold int aom_init(AVCodecContext *avctx, codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used); if (ctx->auto_alt_ref >= 0) codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref); - +if (ctx->arnr_max_frames >= 0) +codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames); +if (ctx->arnr_strength >= 0) +codecctl_int(avctx, AOME_SET_ARNR_STRENGTH,ctx->arnr_strength); +if (ctx->enable_cdef >= 0) +codecctl_int(a
[FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.
The following are the newly added options: arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, denoise_block_size, rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, frame_parallel, enable_cdef, enable_global_motion, and intrabc. Also added macros for compiling for aom 1.0.0 and fixed the default values. --- libavcodec/libaomenc.c | 97 -- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index faec61cacd..6d2441b4ed 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -66,36 +66,69 @@ typedef struct AOMEncoderContext { struct FrameListData *coded_frame_list; int cpu_used; int auto_alt_ref; +int arnr_max_frames; +int arnr_strength; +int aq_mode; int lag_in_frames; int error_resilient; int crf; int static_thresh; int drop_threshold; +int denoise_noise_level; +int denoise_block_size; uint64_t sse[4]; int have_sse; /**< true if we have pending sse[] */ uint64_t frame_number; +int rc_undershoot_pct; +int rc_overshoot_pct; +int minsection_pct; +int maxsection_pct; +int frame_parallel; int tile_cols, tile_rows; int tile_cols_log2, tile_rows_log2; aom_superblock_size_t superblock_size; int uniform_tiles; int row_mt; +int enable_cdef; +int enable_global_motion; +int enable_intrabc; } AOMContext; static const char *const ctlidstr[] = { [AOME_SET_CPUUSED] = "AOME_SET_CPUUSED", [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL", [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF", +[AOME_SET_ARNR_MAXFRAMES] = "AOME_SET_ARNR_MAXFRAMES", +[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH", [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD", [AV1E_SET_COLOR_RANGE] = "AV1E_SET_COLOR_RANGE", [AV1E_SET_COLOR_PRIMARIES] = "AV1E_SET_COLOR_PRIMARIES", [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS", [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS", +[AV1E_SET_AQ_MODE] = "AV1E_SET_AQ_MODE", +[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING", [AV1E_SET_SUPERBLOCK_SIZE] = "AV1E_SET_SUPERBLOCK_SIZE", [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS", [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS", #ifdef AOM_CTRL_AV1E_SET_ROW_MT [AV1E_SET_ROW_MT] = "AV1E_SET_ROW_MT", #endif +#ifdef AV1E_SET_DENOISE_NOISE_LEVEL +[AV1E_SET_DENOISE_NOISE_LEVEL] = "AV1E_SET_DENOISE_NOISE_LEVEL", +#endif +#ifdef AV1E_SET_DENOISE_BLOCK_SIZE +[AV1E_SET_DENOISE_BLOCK_SIZE] = "AV1E_SET_DENOISE_BLOCK_SIZE", +#endif +#ifdef AV1E_SET_MAX_REFERENCE_FRAMES +[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES", +#endif +#ifdef AV1E_SET_ENABLE_GLOBAL_MOTION +[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION", +#endif +#ifdef AV1E_SET_ENABLE_INTRABC +[AV1E_SET_ENABLE_INTRABC] = "AV1E_SET_ENABLE_INTRABC", +#endif +[AV1E_SET_ENABLE_CDEF] = "AV1E_SET_ENABLE_CDEF", }; static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc) @@ -567,10 +600,14 @@ static av_cold int aom_init(AVCodecContext *avctx, // 0-100 (0 => CBR, 100 => VBR) enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100); -if (avctx->bit_rate) +if (ctx->minsection_pct >= 0) +enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct; +else if (avctx->bit_rate) enccfg.rc_2pass_vbr_minsection_pct = avctx->rc_min_rate * 100LL / avctx->bit_rate; -if (avctx->rc_max_rate) +if (ctx->maxsection_pct >= 0) +enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct; +else if (avctx->rc_max_rate) enccfg.rc_2pass_vbr_maxsection_pct = avctx->rc_max_rate * 100LL / avctx->bit_rate; @@ -582,6 +619,11 @@ static av_cold int aom_init(AVCodecContext *avctx, avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate; enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6; +if (ctx->rc_undershoot_pct >= 0) +enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct; +if (ctx->rc_overshoot_pct >= 0) +enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct; + // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size) enccfg.kf_min_dist = avctx->keyint_min; @@ -643,7 +685,12 @@ static av_cold int aom_init(AVCodecContext *avctx, codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used); if (ctx->auto_alt_ref >= 0) codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref); - +if (ctx->arnr_max_frames >= 0) +codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames); +if (ctx->arnr_strength >= 0
[FFmpeg-devel] [PATCH] Updated the documentation about the encoding options for libaom-av1 encoder.
--- doc/encoders.texi | 46 ++ 1 file changed, 46 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 94337d009c..a669ac3739 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1434,6 +1434,12 @@ value is 1, which will be slow and high quality. Enable use of alternate reference frames. Defaults to the internal default of the library. +@item arnr-max-frames +Set altref noise reduction max frame count. + +@item arnr-strength +Set altref noise reduction filter strength. + @item lag-in-frames Set the maximum number of frames which the encoder may keep in flight at any one time for lookahead purposes. Defaults to the internal @@ -1466,6 +1472,33 @@ buffer falls below this percentage, frames will be dropped until it has refilled above the threshold. Defaults to zero (no frames are dropped). +@item denoise-noise-level +Amount of noise to be removed for grain synthesis. Grain synthesis is disabled if +it is not set or set to 0. + +@item denoise-block-size +Block size used for denoising for grain synthesis. If not set, AV1 codec +uses the default value of 32. + +@item undershoot-pct +Set datarate undershoot (min) percentage of the target bitrate. + +@item overshoot-pct +Set datarate overshoot (max) percentage of the target bitrate. + +@item maxrate (@emph{maxsection-pct}) +Set GOP max bitrate in bits/s. Note @command{libaom-av1}'s option maxsection-pct is +specified as a percentage of the target bitrate. If maxsection-pct is not set, the +libaomenc wrapper computes it as follows: @code{(maxrate * 100 / bitrate)}. + +@item minrate (@emph{minsection-pct}) +Set GOP min bitrate in bits/s. Note @command{libaom-av1}'s option minsection-pct is +specified as a percentage of the target bitrate. If minsection-pct is not set, the +libaomenc wrapper computes it as follows: @code{(minrate * 100 / bitrate)}. + +@item frame-parallel @var{boolean} +Enable frame parallel decodability features. The default value is true. + @item tiles Set the number of tiles to encode the input video with, as columns x rows. Larger numbers allow greater parallelism in both encoding and @@ -1480,6 +1513,19 @@ Provided for compatibility with libvpx/VP9. @item row-mt (Requires libaom >= 1.0.0-759-g90a15f4f2) Enable row based multi-threading. Disabled by default. +@item enable-cdef @var{boolean} +Flag to enable or disable Constrianed Directional Enhancement Filter. The libaom-av1 +encoder enables CDEF by default. + +@item enable-global-motion @var{boolean} +Flag to enable or disable the use of global motion for block prediction. +The default value is true. + +@item enable-intrabc @var{boolean} +Flag to enable or disable block copy mode for intra block prediction. This mode is +useful for screen content. The default value is true. + + @end table @section libkvazaar -- 2.21.0.392.gf8f6787159e-goog ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] Updated the documentation for libaom encoder options.
--- doc/encoders.texi | 47 +++ 1 file changed, 47 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 94337d009c..15b9199549 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1434,6 +1434,16 @@ value is 1, which will be slow and high quality. Enable use of alternate reference frames. Defaults to the internal default of the library. +@item arnr-max-frames +Set altref noise reduction max frame count. + +@item arnr-strength +Set altref noise reduction filter strength. + +@item aq-mode +Set adaptive quantization mode (0: off (default), 1: variance 2: complexity, 3: +cyclic refresh). + @item lag-in-frames Set the maximum number of frames which the encoder may keep in flight at any one time for lookahead purposes. Defaults to the internal @@ -1466,6 +1476,31 @@ buffer falls below this percentage, frames will be dropped until it has refilled above the threshold. Defaults to zero (no frames are dropped). +@item denoise-noise-level +Amount of noise to be removed for grain synthesis. Grain synthesis is disabled if +this option is not set or set to 0. + +@item denoise-block-size +Block size used for denoising for grain synthesis. If not set, AV1 codec +uses the default value of 32. + +@item undershoot-pct +Set datarate undershoot (min) percentage of the target bitrate. + +@item overshoot-pct +Set datarate overshoot (max) percentage of the target bitrate. + +@item maxsection-pct +Maximum percentage variation of the GOP bitrate from the target bitrate. If maxsection-pct +is not set, the libaomenc wrapper computes it as follows: @code{(maxrate * 100 / bitrate)}. + +@item minrate +Minimum percentage variation of the GOP bitrate from the target bitrate. If minsection-pct +is not set, the libaomenc wrapper computes it as follows: @code{(minrate * 100 / bitrate)}. + +@item frame-parallel @var{boolean} +Enable frame parallel decodability features. The default value is true. + @item tiles Set the number of tiles to encode the input video with, as columns x rows. Larger numbers allow greater parallelism in both encoding and @@ -1480,6 +1515,18 @@ Provided for compatibility with libvpx/VP9. @item row-mt (Requires libaom >= 1.0.0-759-g90a15f4f2) Enable row based multi-threading. Disabled by default. +@item enable-cdef @var{boolean} +Flag to enable or disable Constrained Directional Enhancement Filter. The libaom-av1 +encoder enables CDEF by default. + +@item enable-global-motion @var{boolean} +Flag to enable or disable the use of global motion for block prediction. +The default value is true. + +@item enable-intrabc @var{boolean} +Flag to enable or disable block copy mode for intra block prediction. This mode is +useful for screen content. The default value is true. + @end table @section libkvazaar -- 2.21.0.392.gf8f6787159e-goog ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Updated the documentation about the encoding options for libaom-av1 encoder.
James, Thanks for the review. I am sending the updated patch now. libaom-av1 enables global-motion/intrabc by default. These options were added to enable/disable these tools to reduce the complexity. The default value is set to -1. On Thu, Apr 4, 2019 at 10:31 AM James Almer wrote: > On 4/2/2019 9:49 PM, Sam John via ffmpeg-devel wrote: > > --- > > doc/encoders.texi | 46 ++ > > 1 file changed, 46 insertions(+) > > > > diff --git a/doc/encoders.texi b/doc/encoders.texi > > index 94337d009c..a669ac3739 100644 > > --- a/doc/encoders.texi > > +++ b/doc/encoders.texi > > @@ -1434,6 +1434,12 @@ value is 1, which will be slow and high quality. > > Enable use of alternate reference frames. Defaults to the internal > > default of the library. > > > > +@item arnr-max-frames > > +Set altref noise reduction max frame count. > > + > > +@item arnr-strength > > +Set altref noise reduction filter strength. > > + > > @item lag-in-frames > > Set the maximum number of frames which the encoder may keep in flight > > at any one time for lookahead purposes. Defaults to the internal > > @@ -1466,6 +1472,33 @@ buffer falls below this percentage, frames will > be dropped until it > > has refilled above the threshold. Defaults to zero (no frames are > > dropped). > > > > +@item denoise-noise-level > > +Amount of noise to be removed for grain synthesis. Grain synthesis is > disabled if > > +it is not set or set to 0. > > + > > +@item denoise-block-size > > +Block size used for denoising for grain synthesis. If not set, AV1 codec > > +uses the default value of 32. > > + > > +@item undershoot-pct > > +Set datarate undershoot (min) percentage of the target bitrate. > > + > > +@item overshoot-pct > > +Set datarate overshoot (max) percentage of the target bitrate. > > + > > +@item maxrate (@emph{maxsection-pct}) > > +Set GOP max bitrate in bits/s. Note @command{libaom-av1}'s option > maxsection-pct is > > +specified as a percentage of the target bitrate. If maxsection-pct is > not set, the > > +libaomenc wrapper computes it as follows: @code{(maxrate * 100 / > bitrate)}. > > + > > +@item minrate (@emph{minsection-pct}) > > +Set GOP min bitrate in bits/s. Note @command{libaom-av1}'s option > minsection-pct is > > +specified as a percentage of the target bitrate. If minsection-pct is > not set, the > > +libaomenc wrapper computes it as follows: @code{(minrate * 100 / > bitrate)}. > > + > > +@item frame-parallel @var{boolean} > > +Enable frame parallel decodability features. The default value is true. > > + > > @item tiles > > Set the number of tiles to encode the input video with, as columns x > > rows. Larger numbers allow greater parallelism in both encoding and > > @@ -1480,6 +1513,19 @@ Provided for compatibility with libvpx/VP9. > > @item row-mt (Requires libaom >= 1.0.0-759-g90a15f4f2) > > Enable row based multi-threading. Disabled by default. > > > > +@item enable-cdef @var{boolean} > > +Flag to enable or disable Constrianed Directional Enhancement Filter. > The libaom-av1 > > +encoder enables CDEF by default. > > + > > +@item enable-global-motion @var{boolean} > > +Flag to enable or disable the use of global motion for block > prediction. > > +The default value is true. > > + > > +@item enable-intrabc @var{boolean} > > +Flag to enable or disable block copy mode for intra block prediction. > This mode is > > +useful for screen content. The default value is true. > > Maybe "The libaom-av1 encoder enables global-motion/intrabc by default" > like you did for cdef. For all three the default value is -1, meaning up > to the library. > > > + > > + > > @end table > > > > @section libkvazaar > > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Updated the documentation for libaom encoder options.
Hi, Is there anything to be done for this patch ? Thanks Sam John On Tue, Apr 9, 2019 at 5:55 PM Sam John wrote: > --- > doc/encoders.texi | 47 +++ > 1 file changed, 47 insertions(+) > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index 94337d009c..15b9199549 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -1434,6 +1434,16 @@ value is 1, which will be slow and high quality. > Enable use of alternate reference frames. Defaults to the internal > default of the library. > > +@item arnr-max-frames > +Set altref noise reduction max frame count. > + > +@item arnr-strength > +Set altref noise reduction filter strength. > + > +@item aq-mode > +Set adaptive quantization mode (0: off (default), 1: variance 2: > complexity, 3: > +cyclic refresh). > + > @item lag-in-frames > Set the maximum number of frames which the encoder may keep in flight > at any one time for lookahead purposes. Defaults to the internal > @@ -1466,6 +1476,31 @@ buffer falls below this percentage, frames will be > dropped until it > has refilled above the threshold. Defaults to zero (no frames are > dropped). > > +@item denoise-noise-level > +Amount of noise to be removed for grain synthesis. Grain synthesis is > disabled if > +this option is not set or set to 0. > + > +@item denoise-block-size > +Block size used for denoising for grain synthesis. If not set, AV1 codec > +uses the default value of 32. > + > +@item undershoot-pct > +Set datarate undershoot (min) percentage of the target bitrate. > + > +@item overshoot-pct > +Set datarate overshoot (max) percentage of the target bitrate. > + > +@item maxsection-pct > +Maximum percentage variation of the GOP bitrate from the target bitrate. > If maxsection-pct > +is not set, the libaomenc wrapper computes it as follows: @code{(maxrate > * 100 / bitrate)}. > + > +@item minrate > +Minimum percentage variation of the GOP bitrate from the target bitrate. > If minsection-pct > +is not set, the libaomenc wrapper computes it as follows: @code{(minrate > * 100 / bitrate)}. > + > +@item frame-parallel @var{boolean} > +Enable frame parallel decodability features. The default value is true. > + > @item tiles > Set the number of tiles to encode the input video with, as columns x > rows. Larger numbers allow greater parallelism in both encoding and > @@ -1480,6 +1515,18 @@ Provided for compatibility with libvpx/VP9. > @item row-mt (Requires libaom >= 1.0.0-759-g90a15f4f2) > Enable row based multi-threading. Disabled by default. > > +@item enable-cdef @var{boolean} > +Flag to enable or disable Constrained Directional Enhancement Filter. The > libaom-av1 > +encoder enables CDEF by default. > + > +@item enable-global-motion @var{boolean} > +Flag to enable or disable the use of global motion for block prediction. > +The default value is true. > + > +@item enable-intrabc @var{boolean} > +Flag to enable or disable block copy mode for intra block prediction. > This mode is > +useful for screen content. The default value is true. > + > @end table > > @section libkvazaar > -- > 2.21.0.392.gf8f6787159e-goog > > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".