diff mbox series

[FFmpeg-devel,2/2] libavcodec/libaomenc.c: Support lossless encoding

Message ID 20200404095341.128020-2-ryo.hirafuji@gmail.com
State Superseded
Headers show
Series None | expand

Commit Message

Ryo Hirafuji April 4, 2020, 9:53 a.m. UTC
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(-)

Comments

Moritz Barsnick April 5, 2020, 10:28 a.m. UTC | #1
On Sat, Apr 04, 2020 at 18:53:41 +0900, Ryo Hirafuji wrote:
> AV1 support lossless encoding.
> In this patch, I added a command line flag to enable it.

> @@ -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,

Shouldn't this be part of the gray patch?

Moritz
Ryo Hirafuji April 5, 2020, 10:41 a.m. UTC | #2
Hi, Moritz.

Yeah, you are right! And sorry.

After the discussion, I will move this change from "lossless patch" to
"gray patch".

Thanks.

2020年4月5日(日) 19:28 Moritz Barsnick <barsnick@gmx.net>:

> On Sat, Apr 04, 2020 at 18:53:41 +0900, Ryo Hirafuji wrote:
> > AV1 support lossless encoding.
> > In this patch, I added a command line flag to enable it.
>
> > @@ -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,
>
> Shouldn't this be part of the gray patch?
>
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Carl Eugen Hoyos April 5, 2020, 10:45 a.m. UTC | #3
Am So., 5. Apr. 2020 um 12:42 Uhr schrieb Ryo Hirafuji
<ryo.hirafuji@link-u.co.jp>:
>
> Hi, Moritz.
>
> Yeah, you are right! And sorry.
>
> After the discussion, I will move this change from "lossless patch" to
> "gray patch".

And please mention "Fixes ticket #7599" for the gray patch,
"Fixes ticket #7600" for the lossless patch.

Thank you!

Carl Eugen
Ryo Hirafuji April 5, 2020, 10:47 a.m. UTC | #4
OK, I will.
Thanks!

2020年4月5日(日) 19:45 Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Am So., 5. Apr. 2020 um 12:42 Uhr schrieb Ryo Hirafuji
> <ryo.hirafuji@link-u.co.jp>:
> >
> > Hi, Moritz.
> >
> > Yeah, you are right! And sorry.
> >
> > After the discussion, I will move this change from "lossless patch" to
> > "gray patch".
>
> And please mention "Fixes ticket #7599" for the gray patch,
> "Fixes ticket #7600" for the lossless patch.
>
> Thank you!
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

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},
     { NULL },
 };