[FFmpeg-devel] [PATCH 2/2] lavc/libaomenc: Support lossless encoding

Ryo Hirafuji ryo.hirafuji at link-u.co.jp
Sat Apr 4 13:09:46 EEST 2020


> Is it possible to use "cfr 0" instead?

Unfortunately, crf=0 is not lossless.
"lossless" flag uses "quantisation matrices", which is different from the
default quantizer determined by "-crf", to achieve lossless encoding.


2020年4月4日(土) 18:59 Carl Eugen Hoyos <ceffmpeg at gmail.com>:

> Am Sa., 4. Apr. 2020 um 11:57 Uhr schrieb Ryo Hirafuji <
> ryo.hirafuji at gmail.com>:
> >
> > From: Ryo Hirafuji <ryo.hirafuji at link-u.co.jp>
> >
> > AV1 support lossless encoding.
> > In this patch, I added a command line flag to enable it.
> >
> > ---
> >  libavcodec/libaomenc.c | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> > index fb61ce82e2..4a7f4b662a 100644
> > --- a/libavcodec/libaomenc.c
> > +++ b/libavcodec/libaomenc.c
> > @@ -94,6 +94,7 @@ typedef struct AOMEncoderContext {
> >      int enable_intrabc;
> >      int enable_restoration;
> >      int usage;
> > +    int lossless;
> >  } AOMContext;
> >
> >  static const char *const ctlidstr[] = {
> > @@ -130,6 +131,9 @@ static const char *const ctlidstr[] = {
> >  #endif
> >  #ifdef AOM_CTRL_AV1E_SET_ENABLE_INTRABC
> >      [AV1E_SET_ENABLE_INTRABC]   = "AV1E_SET_ENABLE_INTRABC",
> > +#endif
> > +#ifdef AOM_CTRL_AV1E_SET_LOSSLESS
> > +    [AV1E_SET_LOSSLESS]   = "AOM_CTRL_AV1E_SET_LOSSLESS",
> >  #endif
> >      [AV1E_SET_ENABLE_CDEF]      = "AV1E_SET_ENABLE_CDEF",
> >  };
> > @@ -154,7 +158,7 @@ static av_cold void dump_enc_cfg(AVCodecContext
> *avctx,
> >      av_log(avctx, level, "aom_codec_enc_cfg\n");
> >      av_log(avctx, level, "generic settings\n"
> >                           "  %*s%u\n  %*s%u\n  %*s%u\n  %*s%u\n  %*s%u\n"
> > -                         "  %*s%u\n  %*s%u\n"
> > +                         "  %*s%u\n  %*s%u\n  %*s%u\n"
> >                           "  %*s{%u/%u}\n  %*s%u\n  %*s%d\n  %*s%u\n",
> >             width, "g_usage:",           cfg->g_usage,
> >             width, "g_threads:",         cfg->g_threads,
> > @@ -163,6 +167,7 @@ static av_cold void dump_enc_cfg(AVCodecContext
> *avctx,
> >             width, "g_h:",               cfg->g_h,
> >             width, "g_bit_depth:",       cfg->g_bit_depth,
> >             width, "g_input_bit_depth:", cfg->g_input_bit_depth,
> > +           width, "monochrome:",        cfg->monochrome,
> >             width, "g_timebase:",        cfg->g_timebase.num,
> cfg->g_timebase.den,
> >             width, "g_error_resilient:", cfg->g_error_resilient,
> >             width, "g_pass:",            cfg->g_pass,
> > @@ -751,6 +756,10 @@ static av_cold int aom_init(AVCodecContext *avctx,
> >          codecctl_int(avctx, AV1E_SET_MAX_REFERENCE_FRAMES, avctx->refs);
> >      }
> >  #endif
> > +#ifdef AOM_CTRL_AV1E_SET_LOSSLESS
> > +    if (ctx->lossless >= 0)
> > +        codecctl_int(avctx, AV1E_SET_LOSSLESS, ctx->lossless);
> > +#endif
> >  #ifdef AOM_CTRL_AV1E_SET_ROW_MT
> >      if (ctx->row_mt >= 0)
> >          codecctl_int(avctx, AV1E_SET_ROW_MT, ctx->row_mt);
> > @@ -1132,6 +1141,7 @@ static const AVOption options[] = {
> >      { "usage",           "Quality and compression efficiency vs speed
> tradeof", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE,
> "usage"},
> >      { "good",            "Good quality",      0, AV_OPT_TYPE_CONST,
> {.i64 = 0 /* AOM_USAGE_GOOD_QUALITY */}, 0, 0, VE, "usage"},
> >      { "realtime",        "Realtime encoding", 0, AV_OPT_TYPE_CONST,
> {.i64 = 1 /* AOM_USAGE_REALTIME */},     0, 0, VE, "usage"},
>
> > +    { "lossless",        "Lossless encoding", OFFSET(lossless),
> AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
>
> Is it possible to use "cfr 0" instead?
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list