[MPlayer-dev-eng] [PATCH] spudec.c: packets with multiple alpha commands

Tobias Diedrich td at sim.uni-hannover.de
Sun Feb 16 01:15:54 CET 2003


I have recently bought the Korean DVD "My Sassy Girl" and was surprised
that the subtitles would not show up in mplayer. Further research showed
that they are being processed, but the alpha values are always 0 because
the packet commands look like this:

date=0
cmd=3  Palette 1, 0, 2, 3
cmd=4  Alpha 0, 8, 8, 0
cmd=5  Coords  col: 0 - 719  row: 2 - 472  (720x470)
cmd=6  Graphic offset 1: 6  offset 2: 981
cmd=1  Start display!
date=2048
cmd=3  Palette 1, 0, 2, 3
cmd=4  Alpha 0, 15, 15, 0
date=368640
cmd=3  Palette 1, 0, 2, 3
cmd=4  Alpha 0, 8, 8, 0
date=371712
cmd=3  Palette 1, 0, 2, 3
cmd=4  Alpha 0, 0, 0, 0
cmd=2  Stop display!

All these are processed at the same time, so only the last alpha quad is
used, which is all zeroes.

The patch changes this so that for each alpha entry the maximum of all
alpha subpackets is used, which in this example would be 0,15,15,0 .

Comments?
OK to apply?

-- 
Tobias								PGP: 0x9AC7E0BC
This mail is made of 100% recycled bits
-------------- next part --------------
Index: spudec.c
===================================================================
RCS file: /cvsroot/mplayer/main/spudec.c,v
retrieving revision 1.38
diff -u -r1.38 spudec.c
--- spudec.c	24 Jan 2003 10:24:07 -0000	1.38
+++ spudec.c	16 Feb 2003 00:16:52 -0000
@@ -345,6 +345,8 @@
   unsigned int off;
   unsigned int start_off = 0;
   unsigned int next_off;
+  unsigned int first_alpha = 1;
+  unsigned int alpha[4];
   unsigned int pts100 = packet->process_pts;
 
   packet->control_start = get_be16(packet->data + 2);
@@ -388,16 +390,28 @@
 	break;
       case 0x04:
 	/* Alpha */
-	this->alpha[0] = packet->data[off] >> 4;
-	this->alpha[1] = packet->data[off] & 0xf;
-	this->alpha[2] = packet->data[off + 1] >> 4;
-	this->alpha[3] = packet->data[off + 1] & 0xf;
-	if (this->auto_palette) { 
-	  compute_palette(this);
-	  this->auto_palette = 0;
+	alpha[0] = packet->data[off] >> 4;
+	alpha[1] = packet->data[off] & 0xf;
+	alpha[2] = packet->data[off + 1] >> 4;
+	alpha[3] = packet->data[off + 1] & 0xf;
+	if (first_alpha) {
+		this->alpha[0] = alpha[0];
+		this->alpha[1] = alpha[1];
+		this->alpha[2] = alpha[2];
+		this->alpha[3] = alpha[3];
+		first_alpha=0;
+	} else {
+		if (this->alpha[0] < alpha[0])
+			this->alpha[0] = alpha[0];
+		if (this->alpha[1] < alpha[1])
+			this->alpha[1] = alpha[1];
+		if (this->alpha[2] < alpha[2])
+			this->alpha[2] = alpha[2];
+		if (this->alpha[3] < alpha[3])
+			this->alpha[3] = alpha[3];
 	}
 	mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Alpha %d, %d, %d, %d\n",
-	       this->alpha[0], this->alpha[1], this->alpha[2], this->alpha[3]);
+	       alpha[0], alpha[1], alpha[2], alpha[3]);
 	off+=2;
 	break;
       case 0x05:
@@ -438,6 +452,10 @@
   next_control:
     ;
   }
+  if (!first_alpha && this->auto_palette) {
+    compute_palette(this);
+    this->auto_palette = 0;
+  }
 }
 
 static void spudec_decode(spudec_handle_t *this, packet_t *queued_packet)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20030216/97601329/attachment.pgp>


More information about the MPlayer-dev-eng mailing list