]> git.sesse.net Git - vlc/blobdiff - modules/codec/kate.c
Add avparser packetizer for VP9 handling
[vlc] / modules / codec / kate.c
index 7f697bdf8759d288bae5a1b60e8ccffd00cd6baf..3c648566530b6047ffb5f848f697ad2b868ff5be 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * kate.c : a decoder for the kate bitstream format
  *****************************************************************************
- * Copyright (C) 2000-2008 the VideoLAN team
+ * Copyright (C) 2000-2008 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Vincent Penquerc'h <ogg.k.ogg.k@googlemail.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -277,47 +277,46 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_INPUT_SCODEC )
     add_shortcut( "kate" )
 
-    add_bool( "kate-formatted", true, NULL, FORMAT_TEXT, FORMAT_LONGTEXT,
+    add_bool( "kate-formatted", true, FORMAT_TEXT, FORMAT_LONGTEXT,
               true )
 
 #ifdef HAVE_TIGER
-    add_bool( "kate-use-tiger", true, NULL, TIGER_TEXT, TIGER_LONGTEXT,
+    add_bool( "kate-use-tiger", true, TIGER_TEXT, TIGER_LONGTEXT,
               true )
     add_float_with_range( "kate-tiger-quality",
-                          TIGER_QUALITY_DEFAULT, 0.0f, 1.0f, TigerConfigurationCallback,
+                          TIGER_QUALITY_DEFAULT, 0.0f, 1.0f,
                           TIGER_QUALITY_TEXT, TIGER_QUALITY_LONGTEXT,
                           true )
 
     set_section( N_("Tiger rendering defaults"), NULL );
-    add_string( "kate-tiger-default-font-desc",
-                TIGER_DEFAULT_FONT_DESC_DEFAULT, TigerConfigurationCallback,
+    add_string( "kate-tiger-default-font-desc", TIGER_DEFAULT_FONT_DESC_DEFAULT,
                 TIGER_DEFAULT_FONT_DESC_TEXT, TIGER_DEFAULT_FONT_DESC_LONGTEXT, true);
     add_integer_with_range( "kate-tiger-default-font-effect",
                             TIGER_DEFAULT_FONT_EFFECT_DEFAULT,
-                            0, sizeof(pi_font_effects)/sizeof(pi_font_effects[0])-1, TigerConfigurationCallback,
+                            0, sizeof(pi_font_effects)/sizeof(pi_font_effects[0])-1,
                             TIGER_DEFAULT_FONT_EFFECT_TEXT, TIGER_DEFAULT_FONT_EFFECT_LONGTEXT,
                             true )
-    change_integer_list( pi_font_effects, ppsz_font_effect_names, NULL );
+    change_integer_list( pi_font_effects, ppsz_font_effect_names );
     add_float_with_range( "kate-tiger-default-font-effect-strength",
-              TIGER_DEFAULT_FONT_EFFECT_STRENGTH_DEFAULT, 0.0f, 1.0f, TigerConfigurationCallback,
+              TIGER_DEFAULT_FONT_EFFECT_STRENGTH_DEFAULT, 0.0f, 1.0f,
               TIGER_DEFAULT_FONT_EFFECT_STRENGTH_TEXT, TIGER_DEFAULT_FONT_EFFECT_STRENGTH_LONGTEXT,
               true )
     add_integer_with_range( "kate-tiger-default-font-color",
-                            TIGER_DEFAULT_FONT_COLOR_DEFAULT, 0, 0x00ffffff, TigerConfigurationCallback,
+                            TIGER_DEFAULT_FONT_COLOR_DEFAULT, 0, 0x00ffffff,
                             TIGER_DEFAULT_FONT_COLOR_TEXT, TIGER_DEFAULT_FONT_COLOR_LONGTEXT,
                             true);
-    change_integer_list( pi_color_values, ppsz_color_descriptions, NULL );
+    change_integer_list( pi_color_values, ppsz_color_descriptions );
     add_integer_with_range( "kate-tiger-default-font-alpha",
-                            TIGER_DEFAULT_FONT_ALPHA_DEFAULT, 0, 255, TigerConfigurationCallback,
+                            TIGER_DEFAULT_FONT_ALPHA_DEFAULT, 0, 255,
                             TIGER_DEFAULT_FONT_ALPHA_TEXT, TIGER_DEFAULT_FONT_ALPHA_LONGTEXT,
                             true);
     add_integer_with_range( "kate-tiger-default-background-color",
-                            TIGER_DEFAULT_BACKGROUND_COLOR_DEFAULT, 0, 0x00ffffff, TigerConfigurationCallback,
+                            TIGER_DEFAULT_BACKGROUND_COLOR_DEFAULT, 0, 0x00ffffff,
                             TIGER_DEFAULT_BACKGROUND_COLOR_TEXT, TIGER_DEFAULT_BACKGROUND_COLOR_LONGTEXT,
                             true);
-    change_integer_list( pi_color_values, ppsz_color_descriptions, NULL );
+    change_integer_list( pi_color_values, ppsz_color_descriptions );
     add_integer_with_range( "kate-tiger-default-background-alpha",
-                            TIGER_DEFAULT_BACKGROUND_ALPHA_DEFAULT, 0, 255, TigerConfigurationCallback,
+                            TIGER_DEFAULT_BACKGROUND_ALPHA_DEFAULT, 0, 255,
                             TIGER_DEFAULT_BACKGROUND_ALPHA_TEXT, TIGER_DEFAULT_BACKGROUND_ALPHA_LONGTEXT,
                             true);
 #endif
@@ -405,14 +404,15 @@ static int OpenDecoder( vlc_object_t *p_this )
             p_sys->p_tr = NULL;
             p_sys->b_use_tiger = false;
         }
-
-        CHECK_TIGER_RET( tiger_renderer_set_surface_clear_color( p_sys->p_tr, 1, 0, 0, 0, 0 ) );
-
-        UpdateTigerFontEffect( p_dec );
-        UpdateTigerFontColor( p_dec );
-        UpdateTigerBackgroundColor( p_dec );
-        UpdateTigerQuality( p_dec );
-        UpdateTigerFontDesc( p_dec );
+        else {
+            CHECK_TIGER_RET( tiger_renderer_set_surface_clear_color( p_sys->p_tr, 1, 0, 0, 0, 0 ) );
+
+            UpdateTigerFontEffect( p_dec );
+            UpdateTigerFontColor( p_dec );
+            UpdateTigerBackgroundColor( p_dec );
+            UpdateTigerQuality( p_dec );
+            UpdateTigerFontDesc( p_dec );
+        }
     }
 
 #else
@@ -515,21 +515,18 @@ static int ProcessHeaders( decoder_t *p_dec )
     if( xiph_SplitHeaders( pi_size, pp_data, &i_count,
                            p_dec->fmt_in.i_extra, p_dec->fmt_in.p_extra) )
         return VLC_EGENERIC;
-    int i_ret = VLC_SUCCESS;
+
     if( i_count < 1 )
-    {
-        i_ret = VLC_EGENERIC;
-        goto end;
-    }
+        return VLC_EGENERIC;
 
     /* Take care of the initial Kate header */
     kp.nbytes = pi_size[0];
     kp.data   = pp_data[0];
-    i_ret = kate_decode_headerin( &p_sys->ki, &p_sys->kc, &kp );
+    int i_ret = kate_decode_headerin( &p_sys->ki, &p_sys->kc, &kp );
     if( i_ret < 0 )
     {
         msg_Err( p_dec, "this bitstream does not contain Kate data (%d)", i_ret );
-        goto end;
+        return VLC_EGENERIC;
     }
 
     msg_Dbg( p_dec, "%s %s text, granule rate %f, granule shift %d",
@@ -546,7 +543,7 @@ static int ProcessHeaders( decoder_t *p_dec )
         if( i_ret < 0 )
         {
             msg_Err( p_dec, "Kate header %d is corrupted: %d", i_headeridx, i_ret );
-            goto end;
+            return VLC_EGENERIC;
         }
 
         /* header 1 is comments */
@@ -581,10 +578,7 @@ static int ProcessHeaders( decoder_t *p_dec )
     }
 #endif
 
-end:
-    for( unsigned i = 0; i < i_count; i++ )
-        free( pp_data[i] );
-    return i_ret < 0 ? VLC_EGENERIC : VLC_SUCCESS;
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -653,7 +647,6 @@ static void GetVideoSize( decoder_t *p_dec, int *w, int *h )
 {
     /* searching for vout to get its size is frowned upon, so we don't and
        use a default size if the original canvas size is not specified. */
-#if 1
     decoder_sys_t *p_sys = p_dec->p_sys;
     if( p_sys->ki.original_canvas_width > 0 && p_sys->ki.original_canvas_height > 0 )
     {
@@ -667,30 +660,6 @@ static void GetVideoSize( decoder_t *p_dec, int *w, int *h )
         /* nothing, leave defaults */
         msg_Dbg( p_dec, "original canvas size unknown");
     }
-#else
-    /* keep this just in case it might be allowed one day ;) */
-    vout_thread_t *p_vout;
-    p_vout = vlc_object_find( (vlc_object_t*)p_dec, VLC_OBJECT_VOUT, FIND_CHILD );
-    if( p_vout )
-    {
-        decoder_sys_t *p_sys = p_dec->p_sys;
-        if( p_sys->ki.original_canvas_width > 0 && p_sys->ki.original_canvas_height > 0 )
-        {
-            *w = p_sys->ki.original_canvas_width;
-            *h = p_sys->ki.original_canvas_height;
-        }
-        else
-        {
-            *w = p_vout->fmt_in.i_width;
-            *h = p_vout->fmt_in.i_height;
-        }
-        msg_Dbg( p_dec, "video: in %d %d, out %d %d, original canvas %zu %zu",
-                 p_vout->fmt_in.i_width, p_vout->fmt_in.i_height,
-                 p_vout->fmt_out.i_width, p_vout->fmt_out.i_height,
-                 p_sys->ki.original_canvas_width, p_sys->ki.original_canvas_height );
-        vlc_object_release( p_vout );
-    }
-#endif
 }
 
 static void CreateKateBitmap( picture_t *pic, const kate_bitmap *bitmap )
@@ -822,6 +791,8 @@ static int TigerValidateSubpicture( subpicture_t *p_subpic,
                                     bool b_fmt_dst, const video_format_t *p_fmt_dst,
                                     mtime_t ts )
 {
+    VLC_UNUSED(p_fmt_src); VLC_UNUSED(p_fmt_dst);
+
     decoder_sys_t *p_sys = p_subpic->updater.p_sys->p_dec_sys;
 
     if( b_fmt_src || b_fmt_dst )
@@ -1199,7 +1170,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, kate_packet *p_kp, block_t
     }
 
     p_spu->i_start = p_block->i_pts;
-    p_spu->i_stop = p_block->i_pts + INT64_C(1000000)*ev->duration*p_sys->ki.gps_denominator/p_sys->ki.gps_numerator;
+    p_spu->i_stop = p_block->i_pts + CLOCK_FREQ *
+        ev->duration * p_sys->ki.gps_denominator / p_sys->ki.gps_numerator;
     p_spu->b_ephemer = false;
     p_spu->b_absolute = false;
 
@@ -1289,7 +1261,7 @@ static subpicture_t *SetupSimpleKateSPU( decoder_t *p_dec, subpicture_t *p_spu,
         if( !p_bitmap_region )
         {
             msg_Err( p_dec, "cannot allocate SPU region" );
-            decoder_DeleteSubpicture( p_dec, p_spu );
+            subpicture_Delete( p_spu );
             return NULL;
         }
 
@@ -1309,7 +1281,9 @@ static subpicture_t *SetupSimpleKateSPU( decoder_t *p_dec, subpicture_t *p_spu,
     if( !p_spu->p_region )
     {
         msg_Err( p_dec, "cannot allocate SPU region" );
-        decoder_DeleteSubpicture( p_dec, p_spu );
+        if( p_bitmap_region )
+            subpicture_region_Delete( p_bitmap_region );
+        subpicture_Delete( p_spu );
         return NULL;
     }