diff mbox series

[FFmpeg-devel,1/2] libavcodec/ffv1enc: Add option to select the quantization table

Message ID 20241014224650.221839-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/2] libavcodec/ffv1enc: Add option to select the quantization table | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed

Commit Message

Michael Niedermayer Oct. 14, 2024, 10:46 p.m. UTC
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/ffv1.h    | 1 +
 libavcodec/ffv1enc.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Oct. 16, 2024, 7:36 p.m. UTC | #1
On Tue, Oct 15, 2024 at 12:46:49AM +0200, Michael Niedermayer wrote:
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ffv1.h    | 1 +
>  libavcodec/ffv1enc.c | 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index b98f0b36855..18f002c6312 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -136,6 +136,7 @@  typedef struct FFV1Context {
     int intra;
     int key_frame_ok;
     int context_model;
+    int qtable;
 
     int bits_per_raw_sample;
     int packed_at_lsb;
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index f1228c5252f..2743331701d 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -728,7 +728,7 @@  static av_cold int encode_init(AVCodecContext *avctx)
 
     for (i = 0; i < 256; i++) {
         s->quant_table_count = 2;
-        if (s->bits_per_raw_sample <= 8) {
+        if ((s->qtable == -1 && s->bits_per_raw_sample <= 8) || s->qtable == 1) {
             s->quant_tables[0][0][i]=           quant11[i];
             s->quant_tables[0][1][i]=        11*quant11[i];
             s->quant_tables[0][2][i]=     11*11*quant11[i];
@@ -1289,6 +1289,8 @@  static const AVOption options[] = {
             { .i64 = 1 }, INT_MIN, INT_MAX, VE, .unit = "coder" },
     { "context", "Context model", OFFSET(context_model), AV_OPT_TYPE_INT,
             { .i64 = 0 }, 0, 1, VE },
+    { "qtable", "Quantization table", OFFSET(qtable), AV_OPT_TYPE_INT,
+            { .i64 = -1 }, -1, 2, VE },
 
     { NULL }
 };