[PR] avcodec/cavs: Avoid loads for initializing motion vectors (PR #24040)

mkver via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178609898943.59.8717724455485092594@29965ddac10e>
PR #24040 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24040
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24040.patch


>From e446b102e110cb5c07fb31c20c135de28529935f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Fri, 7 Aug 2026 12:33:43 +0200
Subject: [PATCH] avcodec/cavs: Avoid loads for initializing motion vectors

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/cavs.c     | 4 ++--
 libavcodec/cavs.h     | 8 ++++++--
 libavcodec/cavsdata.c | 7 -------
 libavcodec/cavsdec.c  | 8 ++++----
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index 034819d5c7..455f3e5d9e 100644
--- a/libavcodec/cavs.c
+++ b/libavcodec/cavs.c
@@ -726,9 +726,9 @@ int ff_cavs_init_pic(AVSContext *h)
     /* clear some predictors */
     for (i = 0; i <= 20; i += 4)
         h->mv[i] = un_mv;
-    h->mv[MV_BWD_X0] = ff_cavs_dir_mv;
+    h->mv[MV_BWD_X0] = CAVS_DIR_MV;
     set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
-    h->mv[MV_FWD_X0] = ff_cavs_dir_mv;
+    h->mv[MV_FWD_X0] = CAVS_DIR_MV;
     set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
     h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
     h->cy             = h->cur.f->data[0];
diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h
index d25864d530..fc80bf5aa9 100644
--- a/libavcodec/cavs.h
+++ b/libavcodec/cavs.h
@@ -250,8 +250,12 @@ typedef struct AVSContext {
 
 extern const uint8_t     ff_cavs_chroma_qp[64];
 extern const uint8_t     ff_cavs_partition_flags[30];
-extern const cavs_vector ff_cavs_intra_mv;
-extern const cavs_vector ff_cavs_dir_mv;
+
+/** mark block as using intra prediction */
+#define CAVS_DIR_MV   (cavs_vector){ 0, 0, 1, REF_DIR }
+/** mark block as "no prediction from this direction"
+    e.g. forward motion vector in BWD partition */
+#define CAVS_INTRA_MV (cavs_vector){ 0, 0, 1, REF_INTRA }
 
 static inline void set_mvs(cavs_vector *mv, enum cavs_block size) {
     switch(size) {
diff --git a/libavcodec/cavsdata.c b/libavcodec/cavsdata.c
index 2835a4be09..85434906ad 100644
--- a/libavcodec/cavsdata.c
+++ b/libavcodec/cavsdata.c
@@ -60,10 +60,3 @@ const uint8_t ff_cavs_chroma_qp[64] = {
   32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 42, 43, 43, 44, 44,
   45, 45, 46, 46, 47, 47, 48, 48, 48, 49, 49, 49, 50, 50, 50, 51
 };
-
-/** mark block as "no prediction from this direction"
-    e.g. forward motion vector in BWD partition */
-const cavs_vector ff_cavs_dir_mv   = {0,0,1,REF_DIR};
-
-/** mark block as using intra prediction */
-const cavs_vector ff_cavs_intra_mv = {0,0,1,REF_INTRA};
diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index b6dd5f2d3f..54be9ae857 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -645,9 +645,9 @@ static inline int decode_residual_inter(AVSContext *h)
 
 static inline void set_mv_intra(AVSContext *h)
 {
-    h->mv[MV_FWD_X0] = ff_cavs_intra_mv;
+    h->mv[MV_FWD_X0] = CAVS_INTRA_MV;
     set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
-    h->mv[MV_BWD_X0] = ff_cavs_intra_mv;
+    h->mv[MV_BWD_X0] = CAVS_INTRA_MV;
     set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
     if (h->cur.f->pict_type != AV_PICTURE_TYPE_B)
         h->col_type_base[h->mbidx] = I_8X8;
@@ -792,9 +792,9 @@ static int decode_mb_b(AVSContext *h, enum cavs_mb mb_type)
     ff_cavs_init_mb(h);
 
     /* reset all MVs */
-    h->mv[MV_FWD_X0] = ff_cavs_dir_mv;
+    h->mv[MV_FWD_X0] = CAVS_DIR_MV;
     set_mvs(&h->mv[MV_FWD_X0], BLK_16X16);
-    h->mv[MV_BWD_X0] = ff_cavs_dir_mv;
+    h->mv[MV_BWD_X0] = CAVS_DIR_MV;
     set_mvs(&h->mv[MV_BWD_X0], BLK_16X16);
     switch (mb_type) {
     case B_SKIP:
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.