PR #24113 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24113
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24113.patch

May fix https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22423


>From e34ae3085270eb200d9662a0af3cd9ac12b8ed22 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 12 Aug 2026 05:10:03 +0200
Subject: [PATCH 1/3] avcodec/mips/hevcdsp: declare the biweight functions with
 the offset they take

---
 libavcodec/mips/hevcdsp_mips.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/mips/hevcdsp_mips.h b/libavcodec/mips/hevcdsp_mips.h
index 0498938028..7dcff001b2 100644
--- a/libavcodec/mips/hevcdsp_mips.h
+++ b/libavcodec/mips/hevcdsp_mips.h
@@ -356,8 +356,7 @@ void 
ff_hevc_put_hevc_bi_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,          \
                                                           int denom,           
\
                                                           int weight0,         
\
                                                           int weight1,         
\
-                                                          int offset0,         
\
-                                                          int offset1,         
\
+                                                          int offset,          
\
                                                           intptr_t mx,         
\
                                                           intptr_t my,         
\
                                                           int width)
-- 
2.52.0


>From 71ecd4606815bca76597d84a3f6bf0ded1f73af6 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 12 Aug 2026 05:33:15 +0200
Subject: [PATCH 2/3] avcodec/huffyuv: seed the median predictor endian
 independently

---
 libavcodec/huffyuv.h    | 2 ++
 libavcodec/huffyuvdec.c | 2 +-
 libavcodec/huffyuvenc.c | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/huffyuv.h b/libavcodec/huffyuv.h
index 62866b7a48..1e792196ad 100644
--- a/libavcodec/huffyuv.h
+++ b/libavcodec/huffyuv.h
@@ -55,6 +55,8 @@ typedef enum Predictor {
     MEDIAN,
 } Predictor;
 
+#define READ_LOWBYTE(plane, bps) ((bps) <= 8 ? (plane)[0] : *(const uint16_t 
*)(plane) & 0xFF)
+
 int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, 
int n);
 
 #endif /* AVCODEC_HUFFYUV_H */
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 89430511dd..39959c1c8b 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -985,7 +985,7 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, 
int height,
                         break;
                 }
 
-                lefttop = p->data[plane][0];
+                lefttop = READ_LOWBYTE(p->data[plane], s->bps);
                 decode_plane_bitstream(s, w, plane);
                 add_median_prediction(s, p->data[plane] + fake_stride, 
p->data[plane], s->temp[0], w, &left, &lefttop);
                 y++;
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index dd3ed9a996..9aec2cc462 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -911,7 +911,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
                     y++;
                 }
 
-                lefttop = p->data[plane][0];
+                lefttop = READ_LOWBYTE(p->data[plane], s->bps);
 
                 for (; y < h; y++) {
                     const uint8_t *dst = p->data[plane] + p->linesize[plane] * 
y;
-- 
2.52.0


>From b11bc23c82ca25aa3999520b5ace05353234bb2a Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 12 Aug 2026 05:38:19 +0200
Subject: [PATCH 3/3] avcodec/ppc/vp8dsp: store the 16 pixel wide rows at any
 alignment

---
 libavcodec/ppc/vp8dsp_altivec.c | 12 ++++++------
 libavutil/ppc/util_altivec.h    | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/libavcodec/ppc/vp8dsp_altivec.c b/libavcodec/ppc/vp8dsp_altivec.c
index 9d637af00b..2898868ba9 100644
--- a/libavcodec/ppc/vp8dsp_altivec.c
+++ b/libavcodec/ppc/vp8dsp_altivec.c
@@ -136,7 +136,7 @@ void put_vp8_epel_h_altivec_core(uint8_t *dst, ptrdiff_t 
dst_stride,
         if (w == 16) {
             FILTER_H(f16l, 8);
             filt = vec_packsu(f16h, f16l);
-            vec_st(filt, 0, dst);
+            unaligned_store(filt, dst);
         } else {
             filt = vec_packsu(f16h, f16h);
             vec_ste((vec_u32)filt, 0, (uint32_t*)dst);
@@ -235,7 +235,7 @@ void put_vp8_epel_v_altivec_core(uint8_t *dst, ptrdiff_t 
dst_stride,
         if (w == 16) {
             FILTER_V(f16l, vec_mulo);
             filt = vec_packsu(f16h, f16l);
-            vec_st(filt, 0, dst);
+            unaligned_store(filt, dst);
         } else {
             filt = vec_packsu(f16h, f16h);
             if (w == 4)
@@ -317,10 +317,10 @@ static void put_vp8_pixels16_altivec(uint8_t *dst, 
ptrdiff_t dstride, const uint
 // -funroll-loops w/ this is bad - 74 cycles again.
 // all this is on a 7450, tuning for the 7450
     for (i = 0; i < h; i += 4) {
-        vec_st(load_with_perm_vec(0, src, perm), 0, dst);
-        vec_st(load_with_perm_vec(sstride, src, perm), dstride, dst);
-        vec_st(load_with_perm_vec(sstride2, src, perm), dstride2, dst);
-        vec_st(load_with_perm_vec(sstride3, src, perm), dstride3, dst);
+        unaligned_store(load_with_perm_vec(0, src, perm), dst);
+        unaligned_store(load_with_perm_vec(sstride, src, perm), dst + dstride);
+        unaligned_store(load_with_perm_vec(sstride2, src, perm), dst + 
dstride2);
+        unaligned_store(load_with_perm_vec(sstride3, src, perm), dst + 
dstride3);
         src += sstride4;
         dst += dstride4;
     }
diff --git a/libavutil/ppc/util_altivec.h b/libavutil/ppc/util_altivec.h
index 2548011be5..9d9c6f7705 100644
--- a/libavutil/ppc/util_altivec.h
+++ b/libavutil/ppc/util_altivec.h
@@ -144,6 +144,24 @@ static inline vec_u8 load_with_perm_vec(int offset, const 
uint8_t *src, vec_u8 p
 #define load_with_perm_vec(a,b,c) VEC_LD(a,b)
 #endif
 
+#if HAVE_BIGENDIAN
+static inline void unaligned_store(vec_u8 v, uint8_t *dst)
+{
+    vec_u8 lo    = vec_ld(0, dst);
+    vec_u8 hi    = vec_ld(15, dst);
+    vec_u8 edges = vec_perm(hi, lo, vec_lvsl(0, dst));
+    vec_u8 align = vec_lvsr(0, dst);
+
+    vec_st(vec_perm(v, edges, align), 15, dst);
+    vec_st(vec_perm(edges, v, align), 0, dst);
+}
+#else
+static inline void unaligned_store(vec_u8 v, uint8_t *dst)
+{
+    vec_vsx_st(v, 0, dst);
+}
+#endif
+
 
 /**
  * loads vector known misalignment
-- 
2.52.0

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

Reply via email to