]> git.sesse.net Git - vlc/blobdiff - modules/codec/subtitles/subsusf.c
Added and used text_style_* methods.
[vlc] / modules / codec / subtitles / subsusf.c
index 2d6837b1b8e7565fd4e28a5876d21183ff036fac..717f8da1272fa517d270a0d7c036781d8f531ff7 100644 (file)
@@ -47,15 +47,15 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, subpicture_t *p
  * Module descriptor.
  *****************************************************************************/
 
-vlc_module_begin();
-    set_capability( "decoder", 40 );
-    set_shortname( N_("USFSubs"));
-    set_description( N_("USF subtitles decoder") );
-    set_callbacks( OpenDecoder, CloseDecoder );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_SCODEC );
+vlc_module_begin ()
+    set_capability( "decoder", 40 )
+    set_shortname( N_("USFSubs"))
+    set_description( N_("USF subtitles decoder") )
+    set_callbacks( OpenDecoder, CloseDecoder )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_SCODEC )
     /* We inherit subsdec-align and subsdec-formatted from subsdec.c */
-vlc_module_end();
+vlc_module_end ()
 
 /*****************************************************************************
  * OpenDecoder: probe the decoder and return score
@@ -76,6 +76,8 @@ static int OpenDecoder( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     p_dec->pf_decode_sub = DecodeBlock;
+    p_dec->fmt_out.i_cat = SPU_ES;
+    p_dec->fmt_out.i_codec = 0;
 
     /* Unused fields of p_sys - not needed for USF decoding */
     p_sys->b_ass = false;
@@ -84,8 +86,8 @@ static int OpenDecoder( vlc_object_t *p_this )
 
     /* init of p_sys */
     p_sys->i_align = 0;
-    p_sys->i_original_height = -1;
-    p_sys->i_original_width = -1;
+    p_sys->i_original_height = 0;
+    p_sys->i_original_width = 0;
     TAB_INIT( p_sys->i_ssa_styles, p_sys->pp_ssa_styles );
     TAB_INIT( p_sys->i_images, p_sys->pp_images );
 
@@ -118,8 +120,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         return NULL;
 
     p_block = *pp_block;
-    if( p_block->i_rate != 0 )
-        p_block->i_length = p_block->i_length * p_block->i_rate / INPUT_RATE_DEFAULT;
 
     p_spu = ParseText( p_dec, p_block );
 
@@ -146,6 +146,7 @@ static void CloseDecoder( vlc_object_t *p_this )
                 continue;
 
             free( p_sys->pp_ssa_styles[i]->psz_stylename );
+            //FIXME: Make font_style a pointer and use text_style_* functions
             free( p_sys->pp_ssa_styles[i]->font_style.psz_fontname );
             free( p_sys->pp_ssa_styles[i] );
         }
@@ -210,7 +211,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Create the subpicture unit */
-    p_spu = p_dec->pf_spu_buffer_new( p_dec );
+    p_spu = decoder_NewSubpicture( p_dec );
     if( !p_spu )
     {
         msg_Warn( p_dec, "can't get spu buffer" );
@@ -261,7 +262,7 @@ static char *GrabAttributeValue( const char *psz_attribute,
 
 static ssa_style_t *ParseStyle( decoder_sys_t *p_sys, char *psz_subtitle )
 {
-    ssa_style_t *p_style   = NULL;
+    ssa_style_t *p_ssa_style = NULL;
     char        *psz_style = GrabAttributeValue( "style", psz_subtitle );
 
     if( psz_style )
@@ -271,11 +272,11 @@ static ssa_style_t *ParseStyle( decoder_sys_t *p_sys, char *psz_subtitle )
         for( i = 0; i < p_sys->i_ssa_styles; i++ )
         {
             if( !strcmp( p_sys->pp_ssa_styles[i]->psz_stylename, psz_style ) )
-                p_style = p_sys->pp_ssa_styles[i];
+                p_ssa_style = p_sys->pp_ssa_styles[i];
         }
         free( psz_style );
     }
-    return p_style;
+    return p_ssa_style;
 }
 
 static int ParsePositionAttributeList( char *psz_subtitle, int *i_align,
@@ -386,48 +387,48 @@ static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
     fmt.i_aspect = 0;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
-    p_text_region = p_spu->pf_create_region( VLC_OBJECT(p_dec), &fmt );
+    p_text_region = subpicture_region_New( &fmt );
 
     if( p_text_region != NULL )
     {
-        ssa_style_t  *p_style = NULL;
+        ssa_style_t  *p_ssa_style = NULL;
 
         p_text_region->psz_text = NULL;
         p_text_region->psz_html = strndup( psz_subtitle, i_len );
         if( ! p_text_region->psz_html )
         {
-            p_spu->pf_destroy_region( VLC_OBJECT(p_dec), p_text_region );
+            subpicture_region_Delete( p_text_region );
             return NULL;
         }
 
-        p_style = ParseStyle( p_sys, p_text_region->psz_html );
-        if( !p_style )
+        p_ssa_style = ParseStyle( p_sys, p_text_region->psz_html );
+        if( !p_ssa_style )
         {
             int i;
 
             for( i = 0; i < p_sys->i_ssa_styles; i++ )
             {
                 if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) )
-                    p_style = p_sys->pp_ssa_styles[i];
+                    p_ssa_style = p_sys->pp_ssa_styles[i];
             }
         }
 
-        if( p_style )
+        if( p_ssa_style )
         {
-            msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename );
+            msg_Dbg( p_dec, "style is: %s", p_ssa_style->psz_stylename );
 
-            p_text_region->p_style = &p_style->font_style;
-            p_text_region->i_align = p_style->i_align;
+            p_text_region->p_style = text_style_Duplicate( &p_ssa_style->font_style );
+            p_text_region->i_align = p_ssa_style->i_align;
 
             /* TODO: Setup % based offsets properly, without adversely affecting
              *       everything else in vlc. Will address with separate patch,
              *       to prevent this one being any more complicated.
 
-                     * p_style->i_margin_percent_h;
-                     * p_style->i_margin_percent_v;
+                     * p_ssa_style->i_margin_percent_h;
+                     * p_ssa_style->i_margin_percent_v;
              */
-            p_text_region->i_x         = p_style->i_margin_h;
-            p_text_region->i_y         = p_style->i_margin_v;
+            p_text_region->i_x         = p_ssa_style->i_margin_h;
+            p_text_region->i_y         = p_ssa_style->i_margin_v;
 
         }
         else
@@ -460,36 +461,7 @@ static int ParseImageAttachments( decoder_t *p_dec )
     {
         input_attachment_t *p_attach = pp_attachments[k];
 
-        vlc_fourcc_t  type  = 0;
-
-        if( ( !strcmp( p_attach->psz_mime, "image/bmp" ) )      || /* BMP */
-            ( !strcmp( p_attach->psz_mime, "image/x-bmp" ) )    ||
-            ( !strcmp( p_attach->psz_mime, "image/x-bitmap" ) ) ||
-            ( !strcmp( p_attach->psz_mime, "image/x-ms-bmp" ) ) )
-        {
-             type = VLC_FOURCC('b','m','p',' ');
-        }
-        else if( ( !strcmp( p_attach->psz_mime, "image/x-portable-anymap" ) )  || /* PNM */
-                 ( !strcmp( p_attach->psz_mime, "image/x-portable-bitmap" ) )  || /* PBM */
-                 ( !strcmp( p_attach->psz_mime, "image/x-portable-graymap" ) ) || /* PGM */
-                 ( !strcmp( p_attach->psz_mime, "image/x-portable-pixmap" ) ) )   /* PPM */
-        {
-            type = VLC_FOURCC('p','n','m',' ');
-        }
-        else if ( !strcmp( p_attach->psz_mime, "image/gif" ) )         /* GIF */
-            type = VLC_FOURCC('g','i','f',' ');
-        else if ( !strcmp( p_attach->psz_mime, "image/jpeg" ) )        /* JPG, JPEG */
-            type = VLC_FOURCC('j','p','e','g');
-        else if ( !strcmp( p_attach->psz_mime, "image/pcx" ) )         /* PCX */
-            type = VLC_FOURCC('p','c','x',' ');
-        else if ( !strcmp( p_attach->psz_mime, "image/png" ) )         /* PNG */
-            type = VLC_FOURCC('p','n','g',' ');
-        else if ( !strcmp( p_attach->psz_mime, "image/tiff" ) )        /* TIF, TIFF */
-            type = VLC_FOURCC('t','i','f','f');
-        else if ( !strcmp( p_attach->psz_mime, "image/x-tga" ) )       /* TGA */
-            type = VLC_FOURCC('t','g','a',' ');
-        else if ( !strcmp( p_attach->psz_mime, "image/x-xpixmap") )    /* XPM */
-            type = VLC_FOURCC('x','p','m',' ');
+        vlc_fourcc_t type = image_Mime2Fourcc( p_attach->psz_mime );
 
         if( ( type != 0 ) &&
             ( p_attach->i_data > 0 ) &&
@@ -519,7 +491,7 @@ static int ParseImageAttachments( decoder_t *p_dec )
                     fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
 
                     /* Find a suitable decoder module */
-                    if( module_Exists( p_dec, "sdl_image" ) )
+                    if( module_exists( "sdl_image" ) )
                     {
                         /* ffmpeg thinks it can handle bmp properly but it can't (at least
                          * not all of them), so use sdl_image if it is available */
@@ -561,7 +533,7 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     char *psz_node;
-    ssa_style_t *p_style = NULL;
+    ssa_style_t *p_ssa_style = NULL;
     int i_style_level = 0;
     int i_metadata_level = 0;
 
@@ -594,9 +566,9 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                     case 2:
                         if( !strcasecmp( "style", psz_node ) )
                         {
-                            TAB_APPEND( p_sys->i_ssa_styles, p_sys->pp_ssa_styles, p_style );
+                            TAB_APPEND( p_sys->i_ssa_styles, p_sys->pp_ssa_styles, p_ssa_style );
 
-                            p_style = NULL;
+                            p_ssa_style = NULL;
                             i_style_level--;
                         }
                         break;
@@ -641,11 +613,11 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                 {
                     i_style_level++;
 
-                    p_style = calloc( 1, sizeof(ssa_style_t) );
-                    if( ! p_style )
+                    p_ssa_style = calloc( 1, sizeof(ssa_style_t) );
+                    if( !p_ssa_style )
                     {
                         free( psz_node );
-                        break;
+                        return;
                     }
                     /* All styles are supposed to default to Default, and then
                      * one or more settings are over-ridden.
@@ -659,9 +631,11 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                         {
                             ssa_style_t *p_default_style = p_sys->pp_ssa_styles[i];
 
-                            memcpy( p_style, p_default_style, sizeof( ssa_style_t ) );
-                            p_style->font_style.psz_fontname = strdup( p_style->font_style.psz_fontname );
-                            p_style->psz_stylename = NULL;
+                            memcpy( p_ssa_style, p_default_style, sizeof( ssa_style_t ) );
+                            //FIXME: Make font_style a pointer. Actually we double copy some data here,
+                            //   we use text_style_Copy to avoid copying psz_fontname, though .
+                            text_style_Copy( &p_ssa_style->font_style, &p_default_style->font_style );
+                            p_ssa_style->psz_stylename = NULL;
                         }
                     }
 
@@ -673,7 +647,7 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                         if( psz_name && psz_value )
                         {
                             if( !strcasecmp( "name", psz_name ) )
-                                p_style->psz_stylename = strdup( psz_value);
+                                p_ssa_style->psz_stylename = strdup( psz_value );
                         }
                         free( psz_name );
                         free( psz_value );
@@ -690,8 +664,8 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                         {
                             if( !strcasecmp( "face", psz_name ) )
                             {
-                                free( p_style->font_style.psz_fontname );
-                                p_style->font_style.psz_fontname = strdup( psz_value );
+                                free( p_ssa_style->font_style.psz_fontname );
+                                p_ssa_style->font_style.psz_fontname = strdup( psz_value );
                             }
                             else if( !strcasecmp( "size", psz_name ) )
                             {
@@ -700,44 +674,44 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                                     int i_value = atoi( psz_value );
 
                                     if( ( i_value >= -5 ) && ( i_value <= 5 ) )
-                                        p_style->font_style.i_font_size  +=
-                                            ( i_value * p_style->font_style.i_font_size ) / 10;
+                                        p_ssa_style->font_style.i_font_size  +=
+                                            ( i_value * p_ssa_style->font_style.i_font_size ) / 10;
                                     else if( i_value < -5 )
-                                        p_style->font_style.i_font_size  = - i_value;
+                                        p_ssa_style->font_style.i_font_size  = - i_value;
                                     else if( i_value > 5 )
-                                        p_style->font_style.i_font_size  = i_value;
+                                        p_ssa_style->font_style.i_font_size  = i_value;
                                 }
                                 else
-                                    p_style->font_style.i_font_size  = atoi( psz_value );
+                                    p_ssa_style->font_style.i_font_size  = atoi( psz_value );
                             }
                             else if( !strcasecmp( "italic", psz_name ) )
                             {
                                 if( !strcasecmp( "yes", psz_value ))
-                                    p_style->font_style.i_style_flags |= STYLE_ITALIC;
+                                    p_ssa_style->font_style.i_style_flags |= STYLE_ITALIC;
                                 else
-                                    p_style->font_style.i_style_flags &= ~STYLE_ITALIC;
+                                    p_ssa_style->font_style.i_style_flags &= ~STYLE_ITALIC;
                             }
                             else if( !strcasecmp( "weight", psz_name ) )
                             {
                                 if( !strcasecmp( "bold", psz_value ))
-                                    p_style->font_style.i_style_flags |= STYLE_BOLD;
+                                    p_ssa_style->font_style.i_style_flags |= STYLE_BOLD;
                                 else
-                                    p_style->font_style.i_style_flags &= ~STYLE_BOLD;
+                                    p_ssa_style->font_style.i_style_flags &= ~STYLE_BOLD;
                             }
                             else if( !strcasecmp( "underline", psz_name ) )
                             {
                                 if( !strcasecmp( "yes", psz_value ))
-                                    p_style->font_style.i_style_flags |= STYLE_UNDERLINE;
+                                    p_ssa_style->font_style.i_style_flags |= STYLE_UNDERLINE;
                                 else
-                                    p_style->font_style.i_style_flags &= ~STYLE_UNDERLINE;
+                                    p_ssa_style->font_style.i_style_flags &= ~STYLE_UNDERLINE;
                             }
                             else if( !strcasecmp( "color", psz_name ) )
                             {
                                 if( *psz_value == '#' )
                                 {
                                     unsigned long col = strtol(psz_value+1, NULL, 16);
-                                    p_style->font_style.i_font_color = (col & 0x00ffffff);
-                                    p_style->font_style.i_font_alpha = (col >> 24) & 0xff;
+                                    p_ssa_style->font_style.i_font_color = (col & 0x00ffffff);
+                                    p_ssa_style->font_style.i_font_alpha = (col >> 24) & 0xff;
                                 }
                             }
                             else if( !strcasecmp( "outline-color", psz_name ) )
@@ -745,39 +719,39 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                                 if( *psz_value == '#' )
                                 {
                                     unsigned long col = strtol(psz_value+1, NULL, 16);
-                                    p_style->font_style.i_outline_color = (col & 0x00ffffff);
-                                    p_style->font_style.i_outline_alpha = (col >> 24) & 0xff;
+                                    p_ssa_style->font_style.i_outline_color = (col & 0x00ffffff);
+                                    p_ssa_style->font_style.i_outline_alpha = (col >> 24) & 0xff;
                                 }
                             }
                             else if( !strcasecmp( "outline-level", psz_name ) )
                             {
-                                p_style->font_style.i_outline_width = atoi( psz_value );
+                                p_ssa_style->font_style.i_outline_width = atoi( psz_value );
                             }
                             else if( !strcasecmp( "shadow-color", psz_name ) )
                             {
                                 if( *psz_value == '#' )
                                 {
                                     unsigned long col = strtol(psz_value+1, NULL, 16);
-                                    p_style->font_style.i_shadow_color = (col & 0x00ffffff);
-                                    p_style->font_style.i_shadow_alpha = (col >> 24) & 0xff;
+                                    p_ssa_style->font_style.i_shadow_color = (col & 0x00ffffff);
+                                    p_ssa_style->font_style.i_shadow_alpha = (col >> 24) & 0xff;
                                 }
                             }
                             else if( !strcasecmp( "shadow-level", psz_name ) )
                             {
-                                p_style->font_style.i_shadow_width = atoi( psz_value );
+                                p_ssa_style->font_style.i_shadow_width = atoi( psz_value );
                             }
                             else if( !strcasecmp( "back-color", psz_name ) )
                             {
                                 if( *psz_value == '#' )
                                 {
                                     unsigned long col = strtol(psz_value+1, NULL, 16);
-                                    p_style->font_style.i_karaoke_background_color = (col & 0x00ffffff);
-                                    p_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff;
+                                    p_ssa_style->font_style.i_karaoke_background_color = (col & 0x00ffffff);
+                                    p_ssa_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff;
                                 }
                             }
                             else if( !strcasecmp( "spacing", psz_name ) )
                             {
-                                p_style->font_style.i_spacing = atoi( psz_value );
+                                p_ssa_style->font_style.i_spacing = atoi( psz_value );
                             }
                         }
                         free( psz_name );
@@ -796,48 +770,48 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                             if( !strcasecmp( "alignment", psz_name ) )
                             {
                                 if( !strcasecmp( "TopLeft", psz_value ) )
-                                    p_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
+                                    p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
                                 else if( !strcasecmp( "TopCenter", psz_value ) )
-                                    p_style->i_align = SUBPICTURE_ALIGN_TOP;
+                                    p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP;
                                 else if( !strcasecmp( "TopRight", psz_value ) )
-                                    p_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT;
+                                    p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT;
                                 else if( !strcasecmp( "MiddleLeft", psz_value ) )
-                                    p_style->i_align = SUBPICTURE_ALIGN_LEFT;
+                                    p_ssa_style->i_align = SUBPICTURE_ALIGN_LEFT;
                                 else if( !strcasecmp( "MiddleCenter", psz_value ) )
-                                    p_style->i_align = 0;
+                                    p_ssa_style->i_align = 0;
                                 else if( !strcasecmp( "MiddleRight", psz_value ) )
-                                    p_style->i_align = SUBPICTURE_ALIGN_RIGHT;
+                                    p_ssa_style->i_align = SUBPICTURE_ALIGN_RIGHT;
                                 else if( !strcasecmp( "BottomLeft", psz_value ) )
-                                    p_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;
+                                    p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;
                                 else if( !strcasecmp( "BottomCenter", psz_value ) )
-                                    p_style->i_align = SUBPICTURE_ALIGN_BOTTOM;
+                                    p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM;
                                 else if( !strcasecmp( "BottomRight", psz_value ) )
-                                    p_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;
+                                    p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;
                             }
                             else if( !strcasecmp( "horizontal-margin", psz_name ) )
                             {
                                 if( strchr( psz_value, '%' ) )
                                 {
-                                    p_style->i_margin_h = 0;
-                                    p_style->i_margin_percent_h = atoi( psz_value );
+                                    p_ssa_style->i_margin_h = 0;
+                                    p_ssa_style->i_margin_percent_h = atoi( psz_value );
                                 }
                                 else
                                 {
-                                    p_style->i_margin_h = atoi( psz_value );
-                                    p_style->i_margin_percent_h = 0;
+                                    p_ssa_style->i_margin_h = atoi( psz_value );
+                                    p_ssa_style->i_margin_percent_h = 0;
                                 }
                             }
                             else if( !strcasecmp( "vertical-margin", psz_name ) )
                             {
                                 if( strchr( psz_value, '%' ) )
                                 {
-                                    p_style->i_margin_v = 0;
-                                    p_style->i_margin_percent_v = atoi( psz_value );
+                                    p_ssa_style->i_margin_v = 0;
+                                    p_ssa_style->i_margin_percent_v = atoi( psz_value );
                                 }
                                 else
                                 {
-                                    p_style->i_margin_v = atoi( psz_value );
-                                    p_style->i_margin_percent_v = 0;
+                                    p_ssa_style->i_margin_v = atoi( psz_value );
+                                    p_ssa_style->i_margin_percent_v = 0;
                                 }
                             }
                         }
@@ -850,7 +824,7 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                 break;
         }
     }
-    free( p_style );
+    free( p_ssa_style );
 }
 
 
@@ -1201,14 +1175,15 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
     fmt_out.i_height =
         fmt_out.i_visible_height = p_pic->format.i_visible_height;
 
-    p_region = p_spu->pf_create_region( VLC_OBJECT(p_dec), &fmt_out );
+    p_region = subpicture_region_New( &fmt_out );
     if( !p_region )
     {
         msg_Err( p_dec, "cannot allocate SPU region" );
         return NULL;
     }
     assert( p_pic->format.i_chroma == VLC_FOURCC('Y','U','V','A') );
-    picture_CopyPixels( &p_region->picture, p_pic );
+    /* FIXME the copy is probably not needed anymore */
+    picture_CopyPixels( p_region->p_picture, p_pic );
 
     /* This isn't the best way to do this - if you really want transparency, then
      * you're much better off using an image type that supports it like PNG. The
@@ -1231,11 +1206,11 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
         {
             for( unsigned int x = 0; x < p_region->fmt.i_width; x++ )
             {
-                if( p_region->picture.Y_PIXELS[y*p_region->picture.Y_PITCH + x] != i_y ||
-                    p_region->picture.U_PIXELS[y*p_region->picture.U_PITCH + x] != i_u ||
-                    p_region->picture.V_PIXELS[y*p_region->picture.V_PITCH + x] != i_v )
+                if( p_region->p_picture->Y_PIXELS[y*p_region->p_picture->Y_PITCH + x] != i_y ||
+                    p_region->p_picture->U_PIXELS[y*p_region->p_picture->U_PITCH + x] != i_u ||
+                    p_region->p_picture->V_PIXELS[y*p_region->p_picture->V_PITCH + x] != i_v )
                     continue;
-                p_region->picture.A_PIXELS[y*p_region->picture.A_PITCH + x] = 0;
+                p_region->p_picture->A_PIXELS[y*p_region->p_picture->A_PITCH + x] = 0;
 
             }
         }