]> git.sesse.net Git - vlc/blobdiff - modules/codec/cvdsub.c
Clean up a bit subpicture region API.
[vlc] / modules / codec / cvdsub.c
index eb934b5ca75143e70f1ad277c1779ac3410f2b43..e5f31496b523847a2e0b774135c3a8a492cc31cb 100644 (file)
@@ -498,6 +498,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     subpicture_t  *p_spu;
     subpicture_region_t *p_region;
     video_format_t fmt;
+    video_palette_t palette;
     int i;
 
     /* Allocate the subpicture internal data. */
@@ -515,11 +516,22 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     fmt.i_width = fmt.i_visible_width = p_sys->i_width;
     fmt.i_height = fmt.i_visible_height = p_sys->i_height;
     fmt.i_x_offset = fmt.i_y_offset = 0;
-    p_region = p_spu->pf_create_region( VLC_OBJECT(p_dec), &fmt );
+    fmt.p_palette = &palette;
+    fmt.p_palette->i_entries = 4;
+    for( i = 0; i < fmt.p_palette->i_entries; i++ )
+    {
+        fmt.p_palette->palette[i][0] = p_sys->p_palette[i][0];
+        fmt.p_palette->palette[i][1] = p_sys->p_palette[i][1];
+        fmt.p_palette->palette[i][2] = p_sys->p_palette[i][2];
+        fmt.p_palette->palette[i][3] = p_sys->p_palette[i][3];
+    }
+
+    p_region = subpicture_region_New( &fmt );
     if( !p_region )
     {
         msg_Err( p_dec, "cannot allocate SPU region" );
-        //goto error;
+        p_dec->pf_spu_buffer_del( p_dec, p_spu );
+        return NULL;
     }
 
     p_spu->p_region = p_region;
@@ -527,16 +539,6 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     p_region->i_x = p_region->i_x * 3 / 4; /* FIXME: use aspect ratio for x? */
     p_region->i_y = p_sys->i_y_start;
 
-    /* Build palette */
-    fmt.p_palette->i_entries = 4;
-    for( i = 0; i < fmt.p_palette->i_entries; i++ )
-    {
-        fmt.p_palette->palette[i][0] = p_sys->p_palette[i][0];
-        fmt.p_palette->palette[i][1] = p_sys->p_palette[i][1];
-        fmt.p_palette->palette[i][2] = p_sys->p_palette[i][2];
-        fmt.p_palette->palette[i][3] = p_sys->p_palette[i][3];
-    }
-
     RenderImage( p_dec, p_data, p_region );
 
     return p_spu;