This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 53a26f7d41ca7543776590345acd86b41a7856ba
Author:     Andreas Rheinhardt <[email protected]>
AuthorDate: Sun Apr 12 12:53:22 2026 +0200
Commit:     Andreas Rheinhardt <[email protected]>
CommitDate: Thu Apr 16 07:36:01 2026 +0200

    avcodec/mpegvideo_dec: Use C version of h264chroma mc2 functions
    
    H.264 only uses these functions with height 2 or 4 and
    the aarch64, arm and mips versions of them optimize based
    on this. Yet this is not true when these functions are used
    by the lowres code in mpegvideo_dec.c. So revert back to
    the C versions of these functions for mpegvideo_dec so that
    the H.264 decoder can still use fully optimized functions.
    
    Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/h264chroma.c          | 18 +++++++++++-------
 libavcodec/h264chroma.h          |  5 +++++
 libavcodec/h264chroma_template.c |  2 +-
 libavcodec/mpegvideo_dec.c       |  6 ++++++
 4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/libavcodec/h264chroma.c b/libavcodec/h264chroma.c
index 0d152de59d..37ec09dfae 100644
--- a/libavcodec/h264chroma.c
+++ b/libavcodec/h264chroma.c
@@ -21,20 +21,24 @@
 #include "h264chroma.h"
 
 #define BIT_DEPTH 8
+#define MC2_STATIC
 #include "h264chroma_template.c"
+#undef MC2_STATIC
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 16
+#define MC2_STATIC static
 #include "h264chroma_template.c"
+#undef MC2_STATIC
 #undef BIT_DEPTH
 
-#define SET_CHROMA(depth)                                                   \
-    c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_ ## depth ## _c; \
-    c->put_h264_chroma_pixels_tab[1] = put_h264_chroma_mc4_ ## depth ## _c; \
-    c->put_h264_chroma_pixels_tab[2] = put_h264_chroma_mc2_ ## depth ## _c; \
-    c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_ ## depth ## _c; \
-    c->avg_h264_chroma_pixels_tab[1] = avg_h264_chroma_mc4_ ## depth ## _c; \
-    c->avg_h264_chroma_pixels_tab[2] = avg_h264_chroma_mc2_ ## depth ## _c; \
+#define SET_CHROMA(depth)                                                      
\
+    c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_ ## depth ## _c;    
\
+    c->put_h264_chroma_pixels_tab[1] = put_h264_chroma_mc4_ ## depth ## _c;    
\
+    c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_ ## depth ## _c; 
\
+    c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_ ## depth ## _c;    
\
+    c->avg_h264_chroma_pixels_tab[1] = avg_h264_chroma_mc4_ ## depth ## _c;    
\
+    c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_ ## depth ## _c; 
\
 
 av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
 {
diff --git a/libavcodec/h264chroma.h b/libavcodec/h264chroma.h
index 9c81c18a76..80a82e4b25 100644
--- a/libavcodec/h264chroma.h
+++ b/libavcodec/h264chroma.h
@@ -39,4 +39,9 @@ void ff_h264chroma_init_mips(H264ChromaContext *c, int 
bit_depth);
 void ff_h264chroma_init_loongarch(H264ChromaContext *c, int bit_depth);
 void ff_h264chroma_init_riscv(H264ChromaContext *c, int bit_depth);
 
+void ff_put_h264_chroma_mc2_8_c(uint8_t *dst, const uint8_t *src,
+                                ptrdiff_t srcStride, int h, int x, int y);
+void ff_avg_h264_chroma_mc2_8_c(uint8_t *dst, const uint8_t *src,
+                                ptrdiff_t srcStride, int h, int x, int y);
+
 #endif /* AVCODEC_H264CHROMA_H */
diff --git a/libavcodec/h264chroma_template.c b/libavcodec/h264chroma_template.c
index b58be192cd..f6e6d4a2ec 100644
--- a/libavcodec/h264chroma_template.c
+++ b/libavcodec/h264chroma_template.c
@@ -26,7 +26,7 @@
 #include "bit_depth_template.c"
 
 #define H264_CHROMA_MC(OPNAME, OP)\
-static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst /*align 8*/, const 
uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
+MC2_STATIC void FUNCC(ff_ ## OPNAME ## h264_chroma_mc2)(uint8_t *_dst /*align 
8*/, const uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
 {\
     pixel *dst = (pixel*)_dst;\
     const pixel *src = (const pixel*)_src;\
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index ad27180efd..6018e532df 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -101,6 +101,12 @@ av_cold int ff_mpv_decode_init(MpegEncContext *s, 
AVCodecContext *avctx)
     ff_mpv_idct_init(s);
 
     ff_h264chroma_init(&s->h264chroma, 8); //for lowres
+    // lowres may use the following width 2 functions with a height of 1,
+    // yet the H.264 decoder uses them with at least two rows.
+    // Override them with the C versions so that ASM functions can process
+    // two rows at a time.
+    s->h264chroma.avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_8_c;
+    s->h264chroma.put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_8_c;
     s->h264chroma.avg_h264_chroma_pixels_tab[3] = avg_h264_chroma_mc1;
     s->h264chroma.put_h264_chroma_pixels_tab[3] = put_h264_chroma_mc1;
 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to