Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2 1/2] lavc/av1: Record reference ordering information for each frame
@ 2024-04-13 19:05 Mark Thompson
  2024-04-13 19:06 ` [FFmpeg-devel] [PATCH v2 2/2] lavc/vulkan_av1: Use av1dec reference order hint information Mark Thompson
  2024-04-14 20:13 ` [FFmpeg-devel] [PATCH v2 1/2] lavc/av1: Record reference ordering information for each frame Mark Thompson
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Thompson @ 2024-04-13 19:05 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

This is needed by Vulkan.  Constructing this can't be delegated to CBS
because packets might contain multiple frames (when non-shown frames are
present) but we need separate snapshots immediately before each frame
for the decoder.
---
Changes over v1: rename the order hint field and document exactly what the new fields contain.

  libavcodec/av1dec.c | 26 ++++++++++++++++++++++++++
  libavcodec/av1dec.h |  8 ++++++++
  2 files changed, 34 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 824725c031..b4b741054a 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -359,6 +359,25 @@ static void coded_lossless_param(AV1DecContext *s)
      }
  }

+static void order_hint_info(AV1DecContext *s)
+{
+    const AV1RawFrameHeader *header = s->raw_frame_header;
+    const AV1RawSequenceHeader *seq = s->raw_seq;
+    AV1Frame *frame = &s->cur_frame;
+
+    frame->order_hint = header->order_hint;
+
+    for (int i = 0; i < AV1_REFS_PER_FRAME; i++) {
+        int ref_name = i + AV1_REF_FRAME_LAST;
+        int ref_slot = header->ref_frame_idx[i];
+        int ref_order_hint = s->ref[ref_slot].order_hint;
+
+        frame->order_hints[ref_name] = ref_order_hint;
+        frame->ref_frame_sign_bias[ref_name] =
+            get_relative_dist(seq, ref_order_hint, frame->order_hint);
+    }
+}
+
  static void load_grain_params(AV1DecContext *s)
  {
      const AV1RawFrameHeader *header = s->raw_frame_header;
@@ -701,6 +720,12 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s
             sizeof(dst->film_grain));
      dst->coded_lossless = src->coded_lossless;

+    dst->order_hint = src->order_hint;
+    memcpy(dst->ref_frame_sign_bias, src->ref_frame_sign_bias,
+           sizeof(dst->ref_frame_sign_bias));
+    memcpy(dst->order_hints, src->order_hints,
+           sizeof(dst->order_hints));
+
      return 0;

  fail:
@@ -1257,6 +1282,7 @@ static int get_current_frame(AVCodecContext *avctx)
      global_motion_params(s);
      skip_mode_params(s);
      coded_lossless_param(s);
+    order_hint_info(s);
      load_grain_params(s);

      return ret;
diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h
index 336eb61359..79a0be510b 100644
--- a/libavcodec/av1dec.h
+++ b/libavcodec/av1dec.h
@@ -53,6 +53,14 @@ typedef struct AV1Frame {
      AV1RawFilmGrainParams film_grain;

      uint8_t coded_lossless;
+
+    // OrderHint for this frame.
+    uint8_t order_hint;
+    // RefFrameSignBias[] used when decoding this frame.
+    uint8_t ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME];
+    // OrderHints[] when this is the current frame, otherwise
+    // SavedOrderHints[s][] when is the reference frame in slot s.
+    uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME];
  } AV1Frame;

  typedef struct TileGroupInfo {
-- 
2.43.0
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] [PATCH v2 2/2] lavc/vulkan_av1: Use av1dec reference order hint information
  2024-04-13 19:05 [FFmpeg-devel] [PATCH v2 1/2] lavc/av1: Record reference ordering information for each frame Mark Thompson
@ 2024-04-13 19:06 ` Mark Thompson
  2024-04-14 20:13 ` [FFmpeg-devel] [PATCH v2 1/2] lavc/av1: Record reference ordering information for each frame Mark Thompson
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Thompson @ 2024-04-13 19:06 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

---
Changes over v1: fix the OrderHints field as well; move things into the loop over reference names rather than the loop over reference slots.

  libavcodec/vulkan_av1.c | 23 ++++++++++-------------
  1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c
index c9e398eaec..fcc9a4f03b 100644
--- a/libavcodec/vulkan_av1.c
+++ b/libavcodec/vulkan_av1.c
@@ -76,7 +76,7 @@ static int vk_av1_fill_pict(AVCodecContext *avctx, const AV1Frame **ref_src,
                              StdVideoDecodeAV1ReferenceInfo *vkav1_std_ref,
                              VkVideoDecodeAV1DpbSlotInfoKHR *vkav1_ref, /* Goes in ^ */
                              const AV1Frame *pic, int is_current, int has_grain,
-                            int *saved_order_hints)
+                            const uint8_t *saved_order_hints)
  {
      FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
      AV1VulkanDecodePicture *hp = pic->hwaccel_picture_private;
@@ -242,7 +242,6 @@ static int vk_av1_start_frame(AVCodecContext          *avctx,

      const AV1RawFrameHeader *frame_header = s->raw_frame_header;
      const AV1RawFilmGrainParams *film_grain = &s->cur_frame.film_grain;
-    CodedBitstreamAV1Context *cbs_ctx = (CodedBitstreamAV1Context *)(s->cbc->priv_data);

      const int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
                              film_grain->apply_grain;
@@ -272,7 +271,7 @@ static int vk_av1_start_frame(AVCodecContext          *avctx,

      ap->ref_frame_sign_bias_mask = 0x0;
      for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
-        ap->ref_frame_sign_bias_mask |= cbs_ctx->ref_frame_sign_bias[i] << i;
+        ap->ref_frame_sign_bias_mask |= pic->ref_frame_sign_bias[i] << i;

      for (int i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) {
          const int idx = pic->raw_frame_header->ref_frame_idx[i];
@@ -294,7 +293,7 @@ static int vk_av1_start_frame(AVCodecContext          *avctx,

          err = vk_av1_fill_pict(avctx, &ap->ref_src[ref_count], &vp->ref_slots[ref_count],
                                 &vp->refs[ref_count], &ap->std_refs[ref_count], &ap->vkav1_refs[ref_count],
-                               ref_frame, 0, 0, cbs_ctx->ref[idx].saved_order_hints);
+                               ref_frame, 0, 0, ref_frame->order_hints);
          if (err < 0)
              return err;

@@ -491,8 +490,14 @@ static int vk_av1_start_frame(AVCodecContext          *avctx,
          }
      }

-    for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
+    for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) {
+        ap->std_pic_info.OrderHints[i] = pic->order_hints[i];
          ap->loop_filter.loop_filter_ref_deltas[i] = frame_header->loop_filter_ref_deltas[i];
+        ap->global_motion.GmType[i] = s->cur_frame.gm_type[i];
+        for (int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) {
+            ap->global_motion.gm_params[i][j] = s->cur_frame.gm_params[i][j];
+        }
+    }

      for (int i = 0; i < STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS; i++) {
          ap->cdef.cdef_y_pri_strength[i] = frame_header->cdef_y_pri_strength[i];
@@ -501,14 +506,6 @@ static int vk_av1_start_frame(AVCodecContext          *avctx,
          ap->cdef.cdef_uv_sec_strength[i] = frame_header->cdef_uv_sec_strength[i];
      }

-    for (int i = 0; i < STD_VIDEO_AV1_NUM_REF_FRAMES; i++) {
-        ap->std_pic_info.OrderHints[i] = frame_header->ref_order_hint[i];
-        ap->global_motion.GmType[i] = s->cur_frame.gm_type[i];
-        for (int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) {
-            ap->global_motion.gm_params[i][j] = s->cur_frame.gm_params[i][j];
-        }
-    }
-
      if (apply_grain) {
          for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_Y_POINTS; i++) {
              ap->film_grain.point_y_value[i] = film_grain->point_y_value[i];
-- 
2.43.0
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/2] lavc/av1: Record reference ordering information for each frame
  2024-04-13 19:05 [FFmpeg-devel] [PATCH v2 1/2] lavc/av1: Record reference ordering information for each frame Mark Thompson
  2024-04-13 19:06 ` [FFmpeg-devel] [PATCH v2 2/2] lavc/vulkan_av1: Use av1dec reference order hint information Mark Thompson
@ 2024-04-14 20:13 ` Mark Thompson
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Thompson @ 2024-04-14 20:13 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On 13/04/2024 20:05, Mark Thompson wrote:
> This is needed by Vulkan.  Constructing this can't be delegated to CBS
> because packets might contain multiple frames (when non-shown frames are
> present) but we need separate snapshots immediately before each frame
> for the decoder.
> ---
> Changes over v1: rename the order hint field and document exactly what the new fields contain.
> 
>  libavcodec/av1dec.c | 26 ++++++++++++++++++++++++++
>  libavcodec/av1dec.h |  8 ++++++++
>  2 files changed, 34 insertions(+)
> > ---
> Changes over v1: fix the OrderHints field as well; move things into the loop over reference names rather than the loop over reference slots.
>
>  libavcodec/vulkan_av1.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
>

Both pushed with approval from Lynne.

Thanks,

- Mark
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-14 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-13 19:05 [FFmpeg-devel] [PATCH v2 1/2] lavc/av1: Record reference ordering information for each frame Mark Thompson
2024-04-13 19:06 ` [FFmpeg-devel] [PATCH v2 2/2] lavc/vulkan_av1: Use av1dec reference order hint information Mark Thompson
2024-04-14 20:13 ` [FFmpeg-devel] [PATCH v2 1/2] lavc/av1: Record reference ordering information for each frame Mark Thompson

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git