[FFmpeg-cvslog] sws: fix rgb -> 16bit

Michael Niedermayer git at videolan.org
Mon Jul 11 04:12:59 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jul  3 02:08:45 2011 +0200| [987e4c1787f18d97a39a5bce17b9c1f19a0996c9] | committer: Michael Niedermayer

sws: fix rgb -> 16bit

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

 libswscale/swscale.c              |   11 +++++++----
 libswscale/x86/swscale_template.c |    2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index d1cb371..c39f1b6 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1979,6 +1979,9 @@ static void hScale16_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_s
     int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1;
     int sh = (bits <= 7) ? 11 : (bits - 4);
 
+    if((isAnyRGB(c->srcFormat) || c->srcFormat==PIX_FMT_PAL8) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)
+        sh= 9;
+
     for (i = 0; i < dstW; i++) {
         int j;
         int srcPos = filterPos[i];
@@ -2154,7 +2157,7 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth,
         src= formatConvBuffer;
     }
 
-    if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) {
+    if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16 && !isAnyRGB(c->srcFormat)) {
         c->scale8To16Rv((uint16_t *) formatConvBuffer, src, srcW);
         src = formatConvBuffer;
     }
@@ -2208,7 +2211,7 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2
         src2= buf2;
     }
 
-    if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16) {
+    if (av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1 < 8 && c->scalingBpp == 16 && !isAnyRGB(c->srcFormat)) {
         uint8_t *buf2 = (formatConvBuffer + FFALIGN(srcW * 2+78, 16));
         c->scale8To16Rv((uint16_t *) formatConvBuffer, src1, srcW);
         c->scale8To16Rv((uint16_t *) buf2,             src2, srcW);
@@ -2878,8 +2881,8 @@ static av_cold void sws_init_swScale_c(SwsContext *c)
         }
     }
 
-    if((isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)
-       || c->srcFormat == PIX_FMT_PAL8)
+    if(((isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)
+       || c->srcFormat == PIX_FMT_PAL8) && c->scalingBpp == 8)
         c->hScale16= hScale16N_c;
 
     if (c->scalingBpp == 8) {
diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c
index 7603f1a..8ab5556 100644
--- a/libswscale/x86/swscale_template.c
+++ b/libswscale/x86/swscale_template.c
@@ -2438,6 +2438,6 @@ static av_cold void RENAME(sws_init_swScale)(SwsContext *c)
         }
     }
 #endif /* !COMPILE_TEMPLATE_MMX2 */
-    if(isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)
+    if(isAnyRGB(c->srcFormat) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15 && c->scalingBpp == 8)
         c->hScale16= RENAME(hScale16);
 }



More information about the ffmpeg-cvslog mailing list