[FFmpeg-devel] [PATCH 1/5] avcodec/libaomenc.c: Add super-resolution options to libaom wrapper

James Zern jzern at google.com
Mon Jun 29 21:12:02 EEST 2020


On Mon, Jun 29, 2020 at 11:05 AM James Zern <jzern at google.com> wrote:
>
> On Thu, Jun 25, 2020 at 5:55 PM Wang Cao <doubleecao at gmail.com> wrote:
> >
> > From: Wang Cao <doubleecao at gmail.com>
> >
> > Signed-off-by: Wang Cao <wangcao at google.com>
> > ---
> >  doc/encoders.texi      | 39 +++++++++++++++++++++++++++++++++++++++
> >  libavcodec/libaomenc.c | 38 ++++++++++++++++++++++++++++++++++++++
> >  libavcodec/version.h   |  2 +-
> >  3 files changed, 78 insertions(+), 1 deletion(-)
> >
> > [...]
> > @@ -688,6 +713,8 @@ static av_cold int aom_init(AVCodecContext *avctx,
> >      // codec control failures are currently treated only as warnings
> >      av_log(avctx, AV_LOG_DEBUG, "aom_codec_control\n");
> >      codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
> > +    if (ctx->enable_superres >= 0)
>
> I think you can just check whether superres_mode has been set to avoid
> this additional option.
>
> > +        codecctl_int(avctx, AV1E_SET_ENABLE_SUPERRES, ctx->enable_superres);
> >      if (ctx->auto_alt_ref >= 0)
> >          codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
> >      if (ctx->arnr_max_frames >= 0)
> > @@ -1107,6 +1134,17 @@ static const AVOption options[] = {
> >      { "tune",            "The metric that the encoder tunes for. Automatically chosen by the encoder by default", OFFSET(tune), AV_OPT_TYPE_INT, {.i64 = -1}, -1, AOM_TUNE_SSIM, VE, "tune"},
> >      { "psnr",            NULL,         0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_PSNR}, 0, 0, VE, "tune"},
> >      { "ssim",            NULL,         0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_SSIM}, 0, 0, VE, "tune"},
> > +    { "enable-superres", "Enable super-resolution mode", OFFSET(enable_superres), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
> > +    { "superres-mode",   "Select super-resultion mode", OFFSET(superres_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, AOM_SUPERRES_AUTO, VE, "superres_mode"},
>
> resolution
>
> > +    { "none",            "No frame superres allowed",                                      0, AV_OPT_TYPE_CONST, {.i64 = AOM_SUPERRES_NONE},    0, 0, VE, "superres_mode"},

The AOM_SUPERRES_* enum values are a recent addition, for
compatibility you can use integer constants. If there was an abi bump
after they were added you can check that and keep the enum values for
current versions of the library.

> > +    { "fixed",           "All frames are coded at the specified scale and super-resolved", 0, AV_OPT_TYPE_CONST, {.i64 = AOM_SUPERRES_FIXED},   0, 0, VE, "superres_mode"},
> > +    { "random",          "All frames are coded at a random scale and super-resolved.",     0, AV_OPT_TYPE_CONST, {.i64 = AOM_SUPERRES_RANDOM},  0, 0, VE, "superres_mode"},
> > +    { "qthresh",         "Superres scale for a frame is determined based on q_index",      0, AV_OPT_TYPE_CONST, {.i64 = AOM_SUPERRES_QTHRESH}, 0, 0, VE, "superres_mode"},
> > +    { "auto",            "Automatically select superres for appropriate frames",           0, AV_OPT_TYPE_CONST, {.i64 = AOM_SUPERRES_AUTO},    0, 0, VE, "superres_mode"},
> > +    { "superres-denominator",    "The denominator for superres to use, range [8, 16]",                               OFFSET(superres_denominator),    AV_OPT_TYPE_INT, {.i64 = 8}, 8, 16, VE},
> > +    { "superres-qthresh",        "The q level threshold after which superres is used, range [1, 63]",                OFFSET(superres_qthresh),        AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, VE},
> > +    { "superres-kf-denominator", "The denominator for superres to use on key frames, range [8, 16]",                 OFFSET(superres_kf_denominator), AV_OPT_TYPE_INT, {.i64 = 8}, 8, 16, VE},
> > +    { "superres-kf-qthresh",     "The q level threshold after which superres is used for key frames, range [1, 63]", OFFSET(superres_kf_qthresh),     AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, VE},
> >      { NULL },
> >  };
> >


More information about the ffmpeg-devel mailing list