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

Found-by: Ayoub Nabil Boubagrat <[email protected]>


>From cef6004c07dca06c91e84b379570827c16477c01 Mon Sep 17 00:00:00 2001
From: Ayoub Nabil Boubagrat <[email protected]>
Date: Wed, 9 Sep 2026 21:50:00 +0200
Subject: [PATCH 1/3] avcodec/tdsc: clear newly allocated reference frames

A TDSF packet can allocate a reference frame without covering it with any
tiles. The decoder then copies the whole uninitialized reference frame to
the output frame.

Clear new reference frames before decoding the tiles.

Fixes: read of uninitialized memory
Fixes: BhqRF844Pmu5
Found-by: Ayoub Nabil Boubagrat <[email protected]>

Use of uninitialized memory Replicated through UnModified FFmpeg with Valgrind
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/tdsc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c
index 976b67b8f9..9f66ba9e18 100644
--- a/libavcodec/tdsc.c
+++ b/libavcodec/tdsc.c
@@ -34,6 +34,7 @@
  */
 
 #include <stdint.h>
+#include <string.h>
 #include <zlib.h>
 
 #include "libavutil/attributes_internal.h"
@@ -498,6 +499,8 @@ static int tdsc_parse_tdsf(AVCodecContext *avctx, int 
number_tiles)
         ret = av_frame_get_buffer(ctx->refframe, 0);
         if (ret < 0)
             return ret;
+        memset(ctx->refframe->data[0], 0,
+               (size_t)ctx->refframe->linesize[0] * ctx->refframe->height);
     }
 
     /* Decode all tiles in a frame */
-- 
2.52.0


>From 14d43c47a0fff9132606b89d8ec4add311653671 Mon Sep 17 00:00:00 2001
From: Ayoub Nabil Boubagrat <[email protected]>
Date: Wed, 9 Sep 2026 21:50:01 +0200
Subject: [PATCH 2/3] avcodec/tiff: clear the separated intermediate buffer

Strip decoding errors are tolerated unless AV_EF_EXPLODE is set. The
separated-to-RGBA conversion still consumes the full intermediate buffer,
including lines that the failed strip did not initialize.

Allocate the buffer with av_calloc() so undecoded lines cannot expose heap
contents in the output frame.

Fixes: read of uninitialized memory
Fixes: 6nbtoGQYPUjZ
Found-by: Ayoub Nabil Boubagrat <[email protected]>

Use of uninitialized memory Replicated through UnModified FFmpeg with Valgrind
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/tiff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 41db29d6e2..efe7ae7056 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -2216,7 +2216,7 @@ again:
             s->avctx->pix_fmt == AV_PIX_FMT_RGBA) {
             stride = stride * 5 / 4;
             five_planes =
-            dst = av_malloc(stride * s->height);
+            dst = av_calloc(s->height, stride);
             if (!dst)
                 return AVERROR(ENOMEM);
         }
-- 
2.52.0


>From c34adec1860a3474f881e321be1b021506515242 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 10 Oct 2026 08:41:49 +0200
Subject: [PATCH 3/3] libswscale: handle any width in the planar to packed YUV
 converters

Fixes: out of array read
Fixes: out of array write
Fixes: RTjjU0p47d8Y
Found-by: Ayoub Nabil Boubagrat <[email protected]>

Out of array read and write Replicated through API with Valgrind and ASAN
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libswscale/rgb2rgb.h          |  30 ++---
 libswscale/rgb2rgb_template.c |  20 +---
 libswscale/x86/rgb2rgb.c      | 200 ++++++++++++++++------------------
 3 files changed, 114 insertions(+), 136 deletions(-)

diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h
index ed6e08a565..6f16f95fa6 100644
--- a/libswscale/rgb2rgb.h
+++ b/libswscale/rgb2rgb.h
@@ -93,32 +93,18 @@ void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, 
uint8_t *udst,
                       uint8_t *vdst, int width, int height, int lumStride,
                       int chromStride, int srcStride, const int32_t *rgb2yuv);
 
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
 extern void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const 
uint8_t *vsrc, uint8_t *dst,
                           int width, int height,
                           int lumStride, int chromStride, int dstStride);
 
-/**
- * Width should be a multiple of 16.
- */
 extern void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const 
uint8_t *vsrc, uint8_t *dst,
                              int width, int height,
                              int lumStride, int chromStride, int dstStride);
 
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
 extern void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const 
uint8_t *vsrc, uint8_t *dst,
                           int width, int height,
                           int lumStride, int chromStride, int dstStride);
 
-/**
- * Width should be a multiple of 16.
- */
 extern void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const 
uint8_t *vsrc, uint8_t *dst,
                              int width, int height,
                              int lumStride, int chromStride, int dstStride);
@@ -157,6 +143,22 @@ extern void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, 
uint8_t *vdst, const u
 
 void ff_sws_rgb2rgb_init(void);
 
+/**
+ * Packs the chroma positions from..to-1 of one line as YUYV when
+ * luma_first is set and as UYVY otherwise.
+ */
+static inline void ff_pack_yuv422_line(uint8_t *dst, const uint8_t *ysrc,
+                                       const uint8_t *usrc, const uint8_t 
*vsrc,
+                                       int from, int to, int luma_first)
+{
+    for (int i = from; i < to; i++) {
+        dst[4 * i +     !luma_first] = ysrc[2 * i];
+        dst[4 * i + 2 + !luma_first] = ysrc[2 * i + 1];
+        dst[4 * i +      luma_first] = usrc[i];
+        dst[4 * i + 2 +  luma_first] = vsrc[i];
+    }
+}
+
 void rgb2rgb_init_aarch64(void);
 void rgb2rgb_init_riscv(void);
 void rgb2rgb_init_x86(void);
diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c
index df439783d6..d857b74afb 100644
--- a/libswscale/rgb2rgb_template.c
+++ b/libswscale/rgb2rgb_template.c
@@ -389,7 +389,7 @@ static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, 
const uint8_t *usrc,
 #if HAVE_FAST_64BIT
         uint64_t *ldst = (uint64_t *)dst;
         const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
-        for (i = 0; i < chromWidth; i += 2) {
+        for (i = 0; i < (chromWidth & ~1); i += 2) {
             uint64_t k = yc[0] + (uc[0] << 8) +
                          (yc[1] << 16) + ((unsigned) vc[0] << 24);
             uint64_t l = yc[2] + (uc[1] << 8) +
@@ -399,6 +399,7 @@ static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, 
const uint8_t *usrc,
             uc     += 2;
             vc     += 2;
         }
+        ff_pack_yuv422_line(dst, ysrc, usrc, vsrc, chromWidth & ~1, 
chromWidth, 1);
 
 #else
         int *idst = (int32_t *)dst;
@@ -426,10 +427,6 @@ static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, 
const uint8_t *usrc,
     }
 }
 
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
 static inline void yv12toyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
                                 const uint8_t *vsrc, uint8_t *dst,
                                 int width, int height, int lumStride,
@@ -453,7 +450,7 @@ static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, 
const uint8_t *usrc,
 #if HAVE_FAST_64BIT
         uint64_t *ldst = (uint64_t *)dst;
         const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
-        for (i = 0; i < chromWidth; i += 2) {
+        for (i = 0; i < (chromWidth & ~1); i += 2) {
             uint64_t k = uc[0] + (yc[0] << 8) +
                          (vc[0] << 16) + ((unsigned) yc[1] << 24);
             uint64_t l = uc[1] + (yc[2] << 8) +
@@ -463,6 +460,7 @@ static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, 
const uint8_t *usrc,
             uc     += 2;
             vc     += 2;
         }
+        ff_pack_yuv422_line(dst, ysrc, usrc, vsrc, chromWidth & ~1, 
chromWidth, 0);
 
 #else
         int *idst = (int32_t *)dst;
@@ -490,10 +488,6 @@ static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, 
const uint8_t *usrc,
     }
 }
 
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
 static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
                                 const uint8_t *vsrc, uint8_t *dst,
                                 int width, int height, int lumStride,
@@ -504,9 +498,6 @@ static inline void yv12touyvy_c(const uint8_t *ysrc, const 
uint8_t *usrc,
                       chromStride, dstStride, 2);
 }
 
-/**
- * Width should be a multiple of 16.
- */
 static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
                                    const uint8_t *vsrc, uint8_t *dst,
                                    int width, int height, int lumStride,
@@ -516,9 +507,6 @@ static inline void yuv422ptouyvy_c(const uint8_t *ysrc, 
const uint8_t *usrc,
                       chromStride, dstStride, 1);
 }
 
-/**
- * Width should be a multiple of 16.
- */
 static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
                                    const uint8_t *vsrc, uint8_t *dst,
                                    int width, int height, int lumStride,
diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c
index 699d341ce9..f22a919575 100644
--- a/libswscale/x86/rgb2rgb.c
+++ b/libswscale/x86/rgb2rgb.c
@@ -1124,46 +1124,100 @@ static inline void rgb24tobgr24_mmxext(const uint8_t 
*src, uint8_t *dst, int src
     }
 }
 
-static inline void yuvPlanartoyuy2_mmxext(const uint8_t *ysrc, const uint8_t 
*usrc, const uint8_t *vsrc, uint8_t *dst,
-                                           int width, int height,
-                                           int lumStride, int chromStride, int 
dstStride, int vertLumPerChroma)
+static inline void yuvPlanartoyuy2_line_mmxext(uint8_t *dst, const uint8_t 
*ysrc, const uint8_t *usrc, const uint8_t *vsrc,
+                                           x86_reg chromWidth)
+{
+    __asm__ volatile(
+        "xor                 %%"FF_REG_a", %%"FF_REG_a" \n\t"
+        ".p2align                    4              \n\t"
+        "1:                                         \n\t"
+        PREFETCH" 32(%1, %%"FF_REG_a", 2)           \n\t"
+        PREFETCH" 32(%2, %%"FF_REG_a")              \n\t"
+        PREFETCH" 32(%3, %%"FF_REG_a")              \n\t"
+        "movq       (%2, %%"FF_REG_a"), %%mm0       \n\t" // U(0)
+        "movq                    %%mm0, %%mm2       \n\t" // U(0)
+        "movq       (%3, %%"FF_REG_a"), %%mm1       \n\t" // V(0)
+        "punpcklbw               %%mm1, %%mm0       \n\t" // UVUV UVUV(0)
+        "punpckhbw               %%mm1, %%mm2       \n\t" // UVUV UVUV(8)
+
+        "movq     (%1, %%"FF_REG_a",2), %%mm3       \n\t" // Y(0)
+        "movq    8(%1, %%"FF_REG_a",2), %%mm5       \n\t" // Y(8)
+        "movq                    %%mm3, %%mm4       \n\t" // Y(0)
+        "movq                    %%mm5, %%mm6       \n\t" // Y(8)
+        "punpcklbw               %%mm0, %%mm3       \n\t" // YUYV YUYV(0)
+        "punpckhbw               %%mm0, %%mm4       \n\t" // YUYV YUYV(4)
+        "punpcklbw               %%mm2, %%mm5       \n\t" // YUYV YUYV(8)
+        "punpckhbw               %%mm2, %%mm6       \n\t" // YUYV YUYV(12)
+
+        MOVNTQ"                  %%mm3,   (%0, %%"FF_REG_a", 4)    \n\t"
+        MOVNTQ"                  %%mm4,  8(%0, %%"FF_REG_a", 4)    \n\t"
+        MOVNTQ"                  %%mm5, 16(%0, %%"FF_REG_a", 4)    \n\t"
+        MOVNTQ"                  %%mm6, 24(%0, %%"FF_REG_a", 4)    \n\t"
+
+        "add                        $8, %%"FF_REG_a" \n\t"
+        "cmp                        %4, %%"FF_REG_a" \n\t"
+        " jb                        1b               \n\t"
+        ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
+        : "%"FF_REG_a
+    );
+}
+
+static inline void yuvPlanartouyvy_line_mmxext(uint8_t *dst, const uint8_t 
*ysrc, const uint8_t *usrc, const uint8_t *vsrc,
+                                           x86_reg chromWidth)
+{
+    __asm__ volatile(
+        "xor             %%"FF_REG_a", %%"FF_REG_a" \n\t"
+        ".p2align                   4               \n\t"
+        "1:                                         \n\t"
+        PREFETCH" 32(%1, %%"FF_REG_a", 2)           \n\t"
+        PREFETCH" 32(%2, %%"FF_REG_a")              \n\t"
+        PREFETCH" 32(%3, %%"FF_REG_a")              \n\t"
+        "movq      (%2, %%"FF_REG_a"), %%mm0        \n\t" // U(0)
+        "movq                   %%mm0, %%mm2        \n\t" // U(0)
+        "movq      (%3, %%"FF_REG_a"), %%mm1        \n\t" // V(0)
+        "punpcklbw              %%mm1, %%mm0        \n\t" // UVUV UVUV(0)
+        "punpckhbw              %%mm1, %%mm2        \n\t" // UVUV UVUV(8)
+
+        "movq    (%1, %%"FF_REG_a",2), %%mm3        \n\t" // Y(0)
+        "movq   8(%1, %%"FF_REG_a",2), %%mm5        \n\t" // Y(8)
+        "movq                   %%mm0, %%mm4        \n\t" // Y(0)
+        "movq                   %%mm2, %%mm6        \n\t" // Y(8)
+        "punpcklbw              %%mm3, %%mm0        \n\t" // YUYV YUYV(0)
+        "punpckhbw              %%mm3, %%mm4        \n\t" // YUYV YUYV(4)
+        "punpcklbw              %%mm5, %%mm2        \n\t" // YUYV YUYV(8)
+        "punpckhbw              %%mm5, %%mm6        \n\t" // YUYV YUYV(12)
+
+        MOVNTQ"                 %%mm0,   (%0, %%"FF_REG_a", 4)     \n\t"
+        MOVNTQ"                 %%mm4,  8(%0, %%"FF_REG_a", 4)     \n\t"
+        MOVNTQ"                 %%mm2, 16(%0, %%"FF_REG_a", 4)     \n\t"
+        MOVNTQ"                 %%mm6, 24(%0, %%"FF_REG_a", 4)     \n\t"
+
+        "add                       $8, %%"FF_REG_a" \n\t"
+        "cmp                       %4, %%"FF_REG_a" \n\t"
+        " jb                       1b               \n\t"
+        ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
+        : "%"FF_REG_a
+    );
+}
+
+static inline void yuvPlanartopacked_mmxext(void (*pack_line)(uint8_t *, const 
uint8_t *, const uint8_t *, const uint8_t *, x86_reg),
+                                            int luma_first,
+                                            const uint8_t *ysrc, const uint8_t 
*usrc, const uint8_t *vsrc, uint8_t *dst,
+                                            int width, int height,
+                                            int lumStride, int chromStride, 
int dstStride, int vertLumPerChroma)
 {
     const x86_reg chromWidth= width>>1;
     for (int y = 0; y < height; y++) {
         //FIXME handle 2 lines at once (fewer prefetches, reuse some chroma, 
but very likely memory-limited anyway)
-        __asm__ volatile(
-            "xor                 %%"FF_REG_a", %%"FF_REG_a" \n\t"
-            ".p2align                    4              \n\t"
-            "1:                                         \n\t"
-            PREFETCH" 32(%1, %%"FF_REG_a", 2)           \n\t"
-            PREFETCH" 32(%2, %%"FF_REG_a")              \n\t"
-            PREFETCH" 32(%3, %%"FF_REG_a")              \n\t"
-            "movq       (%2, %%"FF_REG_a"), %%mm0       \n\t" // U(0)
-            "movq                    %%mm0, %%mm2       \n\t" // U(0)
-            "movq       (%3, %%"FF_REG_a"), %%mm1       \n\t" // V(0)
-            "punpcklbw               %%mm1, %%mm0       \n\t" // UVUV UVUV(0)
-            "punpckhbw               %%mm1, %%mm2       \n\t" // UVUV UVUV(8)
-
-            "movq     (%1, %%"FF_REG_a",2), %%mm3       \n\t" // Y(0)
-            "movq    8(%1, %%"FF_REG_a",2), %%mm5       \n\t" // Y(8)
-            "movq                    %%mm3, %%mm4       \n\t" // Y(0)
-            "movq                    %%mm5, %%mm6       \n\t" // Y(8)
-            "punpcklbw               %%mm0, %%mm3       \n\t" // YUYV YUYV(0)
-            "punpckhbw               %%mm0, %%mm4       \n\t" // YUYV YUYV(4)
-            "punpcklbw               %%mm2, %%mm5       \n\t" // YUYV YUYV(8)
-            "punpckhbw               %%mm2, %%mm6       \n\t" // YUYV YUYV(12)
-
-            MOVNTQ"                  %%mm3,   (%0, %%"FF_REG_a", 4)    \n\t"
-            MOVNTQ"                  %%mm4,  8(%0, %%"FF_REG_a", 4)    \n\t"
-            MOVNTQ"                  %%mm5, 16(%0, %%"FF_REG_a", 4)    \n\t"
-            MOVNTQ"                  %%mm6, 24(%0, %%"FF_REG_a", 4)    \n\t"
-
-            "add                        $8, %%"FF_REG_a" \n\t"
-            "cmp                        %4, %%"FF_REG_a" \n\t"
-            " jb                        1b               \n\t"
-            ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
-            : "%"FF_REG_a
-        );
+        if (chromWidth < 8) {
+            ff_pack_yuv422_line(dst, ysrc, usrc, vsrc, 0, chromWidth, 
luma_first);
+        } else {
+            pack_line(dst, ysrc, usrc, vsrc, chromWidth & ~7);
+            if (chromWidth & 7) {
+                x86_reg i = chromWidth - 8;
+                pack_line(dst + 4 * i, ysrc + 2 * i, usrc + i, vsrc + i, 8);
+            }
+        }
         if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
             usrc += chromStride;
             vsrc += chromStride;
@@ -1176,100 +1230,34 @@ static inline void yuvPlanartoyuy2_mmxext(const 
uint8_t *ysrc, const uint8_t *us
             :::"memory");
 }
 
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
 static inline void yv12toyuy2_mmxext(const uint8_t *ysrc, const uint8_t *usrc, 
const uint8_t *vsrc, uint8_t *dst,
                                       int width, int height,
                                       int lumStride, int chromStride, int 
dstStride)
 {
     //FIXME interpolate chroma
-    yuvPlanartoyuy2_mmxext(ysrc, usrc, vsrc, dst, width, height, lumStride, 
chromStride, dstStride, 2);
+    yuvPlanartopacked_mmxext(yuvPlanartoyuy2_line_mmxext, 1, ysrc, usrc, vsrc, 
dst, width, height, lumStride, chromStride, dstStride, 2);
 }
 
-static inline void yuvPlanartouyvy_mmxext(const uint8_t *ysrc, const uint8_t 
*usrc, const uint8_t *vsrc, uint8_t *dst,
-                                           int width, int height,
-                                           int lumStride, int chromStride, int 
dstStride, int vertLumPerChroma)
-{
-    const x86_reg chromWidth= width>>1;
-    for (int y = 0; y < height; y++) {
-        //FIXME handle 2 lines at once (fewer prefetches, reuse some chroma, 
but very likely memory-limited anyway)
-        __asm__ volatile(
-            "xor             %%"FF_REG_a", %%"FF_REG_a" \n\t"
-            ".p2align                   4               \n\t"
-            "1:                                         \n\t"
-            PREFETCH" 32(%1, %%"FF_REG_a", 2)           \n\t"
-            PREFETCH" 32(%2, %%"FF_REG_a")              \n\t"
-            PREFETCH" 32(%3, %%"FF_REG_a")              \n\t"
-            "movq      (%2, %%"FF_REG_a"), %%mm0        \n\t" // U(0)
-            "movq                   %%mm0, %%mm2        \n\t" // U(0)
-            "movq      (%3, %%"FF_REG_a"), %%mm1        \n\t" // V(0)
-            "punpcklbw              %%mm1, %%mm0        \n\t" // UVUV UVUV(0)
-            "punpckhbw              %%mm1, %%mm2        \n\t" // UVUV UVUV(8)
-
-            "movq    (%1, %%"FF_REG_a",2), %%mm3        \n\t" // Y(0)
-            "movq   8(%1, %%"FF_REG_a",2), %%mm5        \n\t" // Y(8)
-            "movq                   %%mm0, %%mm4        \n\t" // Y(0)
-            "movq                   %%mm2, %%mm6        \n\t" // Y(8)
-            "punpcklbw              %%mm3, %%mm0        \n\t" // YUYV YUYV(0)
-            "punpckhbw              %%mm3, %%mm4        \n\t" // YUYV YUYV(4)
-            "punpcklbw              %%mm5, %%mm2        \n\t" // YUYV YUYV(8)
-            "punpckhbw              %%mm5, %%mm6        \n\t" // YUYV YUYV(12)
-
-            MOVNTQ"                 %%mm0,   (%0, %%"FF_REG_a", 4)     \n\t"
-            MOVNTQ"                 %%mm4,  8(%0, %%"FF_REG_a", 4)     \n\t"
-            MOVNTQ"                 %%mm2, 16(%0, %%"FF_REG_a", 4)     \n\t"
-            MOVNTQ"                 %%mm6, 24(%0, %%"FF_REG_a", 4)     \n\t"
-
-            "add                       $8, %%"FF_REG_a" \n\t"
-            "cmp                       %4, %%"FF_REG_a" \n\t"
-            " jb                       1b               \n\t"
-            ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
-            : "%"FF_REG_a
-        );
-        if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
-            usrc += chromStride;
-            vsrc += chromStride;
-        }
-        ysrc += lumStride;
-        dst += dstStride;
-    }
-    __asm__(EMMS"       \n\t"
-            SFENCE"     \n\t"
-            :::"memory");
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
 static inline void yv12touyvy_mmxext(const uint8_t *ysrc, const uint8_t *usrc, 
const uint8_t *vsrc, uint8_t *dst,
                                       int width, int height,
                                       int lumStride, int chromStride, int 
dstStride)
 {
     //FIXME interpolate chroma
-    yuvPlanartouyvy_mmxext(ysrc, usrc, vsrc, dst, width, height, lumStride, 
chromStride, dstStride, 2);
+    yuvPlanartopacked_mmxext(yuvPlanartouyvy_line_mmxext, 0, ysrc, usrc, vsrc, 
dst, width, height, lumStride, chromStride, dstStride, 2);
 }
 
-/**
- * Width should be a multiple of 16.
- */
 static inline void yuv422ptouyvy_mmxext(const uint8_t *ysrc, const uint8_t 
*usrc, const uint8_t *vsrc, uint8_t *dst,
                                          int width, int height,
                                          int lumStride, int chromStride, int 
dstStride)
 {
-    yuvPlanartouyvy_mmxext(ysrc, usrc, vsrc, dst, width, height, lumStride, 
chromStride, dstStride, 1);
+    yuvPlanartopacked_mmxext(yuvPlanartouyvy_line_mmxext, 0, ysrc, usrc, vsrc, 
dst, width, height, lumStride, chromStride, dstStride, 1);
 }
 
-/**
- * Width should be a multiple of 16.
- */
 static inline void yuv422ptoyuy2_mmxext(const uint8_t *ysrc, const uint8_t 
*usrc, const uint8_t *vsrc, uint8_t *dst,
                                          int width, int height,
                                          int lumStride, int chromStride, int 
dstStride)
 {
-    yuvPlanartoyuy2_mmxext(ysrc, usrc, vsrc, dst, width, height, lumStride, 
chromStride, dstStride, 1);
+    yuvPlanartopacked_mmxext(yuvPlanartoyuy2_line_mmxext, 1, ysrc, usrc, vsrc, 
dst, width, height, lumStride, chromStride, dstStride, 1);
 }
 
 static inline void planar2x_mmxext(const uint8_t *src, uint8_t *dst, int 
srcWidth, int srcHeight, int srcStride, int dstStride)
-- 
2.52.0

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

Reply via email to