[MPlayer-dev-eng] altivec patch 5/5: don't output the wrong format

Alan Curry pacman at world.std.com
Tue Feb 7 11:56:24 CET 2006


altivec_yuv2packedX() ignores the requested output format and unconditionally
outputs RGBA. That's obviously not good. This patch supports 6 output formats
and prints an error message if it is asked to provide an output format it is
not capable of.

-------------- next part --------------
diff -u postproc/yuv2rgb_altivec.c postproc/yuv2rgb_altivec.c
--- postproc/yuv2rgb_altivec.c	2006-02-06 18:10:02.000000000 -0500
+++ postproc/yuv2rgb_altivec.c	2006-02-06 19:46:11.000000000 -0500
@@ -868,7 +868,25 @@
     G  = vec_packclp (G0,G1);
     B  = vec_packclp (B0,B1);
 
-    out_rgba (R,G,B,out);
+    switch(c->dstFormat) {
+      case IMGFMT_ABGR: out_abgr (R,G,B,out); break;
+      case IMGFMT_BGRA: out_bgra (R,G,B,out); break;
+      case IMGFMT_RGBA: out_rgba (R,G,B,out); break;
+      case IMGFMT_ARGB: out_argb (R,G,B,out); break;
+      case IMGFMT_RGB24: out_rgb24 (R,G,B,out); break;
+      case IMGFMT_BGR24: out_bgr24 (R,G,B,out); break;
+      default:
+        {
+          /* FIXME: either write more out_* macros or punt to yuv2packedXinC */
+          static int printed_error_message;
+          if(!printed_error_message) {
+            MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
+                    vo_format_name(c->dstFormat));
+            printed_error_message=1;
+          }
+          return;
+        }
+    }
   }
 
   if (i < dstW) {
@@ -928,7 +946,19 @@
     B  = vec_packclp (B0,B1);
 
     nout = (vector unsigned char *)scratch;
-    out_rgba (R,G,B,nout);
+    switch(c->dstFormat) {
+      case IMGFMT_ABGR: out_abgr (R,G,B,nout); break;
+      case IMGFMT_BGRA: out_bgra (R,G,B,nout); break;
+      case IMGFMT_RGBA: out_rgba (R,G,B,nout); break;
+      case IMGFMT_ARGB: out_argb (R,G,B,nout); break;
+      case IMGFMT_RGB24: out_rgb24 (R,G,B,nout); break;
+      case IMGFMT_BGR24: out_bgr24 (R,G,B,nout); break;
+      default:
+        /* Unreachable, I think. */
+        MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
+                vo_format_name(c->dstFormat));
+        return;
+    }
 
     memcpy (&((uint32_t*)dest)[i], scratch, (dstW-i)/4);
   }


More information about the MPlayer-dev-eng mailing list