[MPlayer-cvslog] r38227 - trunk/sub/spudec.c

reimar subversion at mplayerhq.hu
Wed Jan 20 21:45:32 EET 2021


Author: reimar
Date: Wed Jan 20 21:45:32 2021
New Revision: 38227

Log:
sub/spudec.c: support swapped interlacing.

The code assumed that the data for the top field
would be first, however it is also possible that
the data for the bottom field is encoded first.

Fixes trac issue #2365.

Modified:
   trunk/sub/spudec.c

Modified: trunk/sub/spudec.c
==============================================================================
--- trunk/sub/spudec.c	Wed Jan 20 20:35:02 2021	(r38226)
+++ trunk/sub/spudec.c	Wed Jan 20 21:45:32 2021	(r38227)
@@ -354,7 +354,7 @@ int spudec_apply_palette_crop(void *this
 
 static void spudec_process_data(spudec_handle_t *this, packet_t *packet)
 {
-  unsigned int i, x, y;
+  unsigned int limit0, limit1, x, y;
   uint8_t *dst;
 
   if (!spudec_alloc_image(this, packet->stride, packet->height))
@@ -368,12 +368,17 @@ static void spudec_process_data(spudec_h
   memcpy(this->palette, packet->palette, sizeof(this->palette));
   memcpy(this->alpha,   packet->alpha,   sizeof(this->alpha));
 
-  i = packet->current_nibble[1];
+  limit0 = packet->current_nibble[1];
+  limit1 = 2*packet->control_start;
+  if (packet->current_nibble[0] > packet->current_nibble[1]) {
+    limit0 = limit1;
+    limit1 = packet->current_nibble[0];
+  }
   x = 0;
   y = 0;
   dst = this->pal_image;
-  while (packet->current_nibble[0] < i
-	 && packet->current_nibble[1] / 2 < packet->control_start
+  while (packet->current_nibble[0] < limit0
+	 && packet->current_nibble[1] < limit1
 	 && y < this->pal_height) {
     unsigned int len, color;
     unsigned int rle = 0;


More information about the MPlayer-cvslog mailing list