[FFmpeg-cvslog] Split out yuv2yuv1 luma and chroma in order to make them generic DSP functions

Kieran Kunhya git at videolan.org
Sun Oct 23 05:53:10 CEST 2011


ffmpeg | branch: master | Kieran Kunhya <kieran at kunhya.com> | Fri Sep 30 13:50:49 2011 +0100| [34e8d147b31c5c8429799fe05b87a5f83bab333c] | committer: Ronald S. Bultje

Split out yuv2yuv1 luma and chroma in order to make them generic DSP functions

Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34e8d147b31c5c8429799fe05b87a5f83bab333c
---

 libswscale/swscale.c              |   42 +++++++++++++-----------------------
 libswscale/swscale_internal.h     |   26 ++++++++--------------
 libswscale/x86/swscale_template.c |    8 +++---
 3 files changed, 29 insertions(+), 47 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 227f65e..bac2932 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -386,34 +386,14 @@ static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter,
         }
 }
 
-static void yuv2yuv1_c(SwsContext *c, const int16_t *lumSrc,
-                       const int16_t *chrUSrc, const int16_t *chrVSrc,
-                       const int16_t *alpSrc,
-                       uint8_t *dest[4], int dstW, int chrDstW)
+static void yuv2yuv1_c(const int16_t *src, uint8_t *dest, int dstW,
+                       const uint8_t *dither, int offset)
 {
-    uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2],
-            *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL;
     int i;
-    const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8;
-
     for (i=0; i<dstW; i++) {
-        int val = (lumSrc[i]+  lumDither[i & 7]) >> 7;
-        yDest[i]= av_clip_uint8(val);
+        int val = (src[i] + dither[(i + offset) & 7]) >> 7;
+        dest[i]= av_clip_uint8(val);
     }
-
-    if (uDest)
-        for (i=0; i<chrDstW; i++) {
-            int u = (chrUSrc[i] + chrDither[i & 7])       >> 7;
-            int v = (chrVSrc[i] + chrDither[(i + 3) & 7]) >> 7;
-            uDest[i]= av_clip_uint8(u);
-            vDest[i]= av_clip_uint8(v);
-        }
-
-    if (CONFIG_SWSCALE_ALPHA && aDest)
-        for (i=0; i<dstW; i++) {
-            int val = (alpSrc[i] + lumDither[i & 7]) >> 7;
-            aDest[i]= av_clip_uint8(val);
-        }
 }
 
 static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter,
@@ -2582,10 +2562,18 @@ static int swScale(SwsContext *c, const uint8_t* src[],
                 const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
                 if ((dstY&chrSkipMask) || isGray(dstFormat))
                     dest[1] = dest[2] = NULL; //FIXME split functions in lumi / chromi
+                const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;
+
                 if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12
-                    const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;
-                    yuv2yuv1(c, lumSrcPtr[0], chrUSrcPtr[0], chrVSrcPtr[0], alpBuf,
-                             dest, dstW, chrDstW);
+                    yuv2yuv1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0);
+
+                    if (dest[1]){
+                        yuv2yuv1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0);
+                        yuv2yuv1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3);
+                    }
+
+                    if (alpBuf && dest[3])
+                        yuv2yuv1(alpBuf, dest[3], dstW, c->lumDither8, 0);
                 } else { //General YV12
                     yuv2yuvX(c, vLumFilter + dstY * vLumFilterSize,
                              lumSrcPtr, vLumFilterSize,
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 9b895b1..7253c83 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -59,28 +59,22 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[],
                        int srcStride[], int srcSliceY, int srcSliceH,
                        uint8_t* dst[], int dstStride[]);
 
+
 /**
- * Write one line of horizontally scaled Y/U/V/A to planar output
+ * Write one line of horizontally scaled data to planar output
  * without any additional vertical scaling (or point-scaling).
  *
- * @param c       SWS scaling context
- * @param lumSrc  scaled luma (Y) source data, 15bit for 8-10bit output,
- *                19-bit for 16bit output (in int32_t)
- * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
+ * @param src     scaled source data, 15bit for 8-10bit output,
  *                19-bit for 16bit output (in int32_t)
- * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
- *                19-bit for 16bit output (in int32_t)
- * @param alpSrc  scaled alpha (A) source data, 15bit for 8-10bit output,
- *                19-bit for 16bit output (in int32_t)
- * @param dest    pointer to the 4 output planes (Y/U/V/A). For >8bit
+ * @param dest    pointer to the output plane. For >8bit
  *                output, this is in uint16_t
- * @param dstW    width of dest[0], dest[3], lumSrc and alpSrc in pixels
- * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc
+ * @param dstW    width of destination in pixels
+ * @param dither  ordered dither array of type int16_t and size 8
+ * @param offset  Dither offset
  */
-typedef void (*yuv2planar1_fn) (struct SwsContext *c,
-                                const int16_t *lumSrc, const int16_t *chrUSrc,
-                                const int16_t *chrVSrc, const int16_t *alpSrc,
-                                uint8_t *dest[4], int dstW, int chrDstW);
+typedef void (*yuv2planar1_fn) (const int16_t *src, uint8_t *dest, int dstW,
+                                const uint8_t *dither, int offset);
+
 /**
  * Write one line of horizontally scaled Y/U/V/A to planar output
  * with multi-point vertical scaling between input pixels.
diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c
index 50e4e4a..ccf4f74 100644
--- a/libswscale/x86/swscale_template.c
+++ b/libswscale/x86/swscale_template.c
@@ -2103,8 +2103,8 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c)
         dstFormat != PIX_FMT_NV12 && dstFormat != PIX_FMT_NV21) {
         if (!(c->flags & SWS_BITEXACT)) {
             if (c->flags & SWS_ACCURATE_RND) {
-                c->yuv2yuv1 = RENAME(yuv2yuv1_ar    );
-                c->yuv2yuvX = RENAME(yuv2yuvX_ar    );
+                //c->yuv2yuv1 = RENAME(yuv2yuv1_ar    );
+                //c->yuv2yuvX = RENAME(yuv2yuvX_ar    );
                 if (!(c->flags & SWS_FULL_CHR_H_INT)) {
                     switch (c->dstFormat) {
                     case PIX_FMT_RGB32:   c->yuv2packedX = RENAME(yuv2rgb32_X_ar);   break;
@@ -2116,8 +2116,8 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c)
                     }
                 }
             } else {
-                c->yuv2yuv1 = RENAME(yuv2yuv1    );
-                c->yuv2yuvX = RENAME(yuv2yuvX    );
+                //c->yuv2yuv1 = RENAME(yuv2yuv1    );
+                //c->yuv2yuvX = RENAME(yuv2yuvX    );
                 if (!(c->flags & SWS_FULL_CHR_H_INT)) {
                     switch (c->dstFormat) {
                     case PIX_FMT_RGB32:   c->yuv2packedX = RENAME(yuv2rgb32_X);   break;



More information about the ffmpeg-cvslog mailing list