diff mbox series

[FFmpeg-devel,v4,1/2] lavc/cbs_av1: fill in ref_frame_sign_bias and order_hints

Message ID NqNj-B_--3-9@lynne.ee
State New
Headers show
Series [FFmpeg-devel,v4,1/2] lavc/cbs_av1: fill in ref_frame_sign_bias and order_hints | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Lynne Feb. 11, 2024, 3:14 p.m. UTC
Needed for Vulkan AV1.
diff mbox series

Patch

From 67beae754b839398287499d51134cc40d7cf8ad4 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Fri, 2 Feb 2024 03:54:06 +0100
Subject: [PATCH v4 1/2] lavc/cbs_av1: fill in ref_frame_sign_bias and
 order_hints

Needed for Vulkan AV1.
---
 libavcodec/cbs_av1.h                 |  2 ++
 libavcodec/cbs_av1_syntax_template.c | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index a5402f069d..0ed49e03ca 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -465,6 +465,8 @@  typedef struct CodedBitstreamAV1Context {
     int tile_num;
 
     AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES];
+    uint8_t ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME];
+    uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME];
 
     // AVOptions
     int operating_point;
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 3be1f2d30f..20eed7ff9e 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1572,6 +1572,17 @@  static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
     }
 
     if (!frame_is_intra) {
+        for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+            uint8_t ref_frame = AV1_REF_FRAME_LAST + i;
+            if (seq->enable_order_hint) {
+                uint8_t hint = current->ref_order_hint[current->ref_frame_idx[i]];
+                uint8_t sign_bias = cbs_av1_get_relative_dist(seq, hint, priv->order_hint) > 0;
+                priv->order_hints[ref_frame] = hint;
+                priv->ref_frame_sign_bias[ref_frame] = sign_bias;
+            } else {
+                priv->ref_frame_sign_bias[ref_frame] = 0;
+            }
+        }
         // Derive reference frame sign biases.
     }
 
-- 
2.43.0.381.gb435a96ce8