]> git.sesse.net Git - vlc/blobdiff - modules/codec/sdl_image.c
Added support for explicit HeV2 LOAS/LATM stream in packetizer.
[vlc] / modules / codec / sdl_image.c
index 610696f174e642294910ce05a95bbdb88fa84a77..d4eb387ab17cf7a65ad8be146747b01bbdde7af5 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_vout.h>
 
@@ -49,15 +54,15 @@ static picture_t *DecodeBlock  ( decoder_t *, block_t ** );
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_VCODEC );
-    set_shortname( _("SDL Image decoder"));
-    set_description( _("SDL_image video decoder") );
-    set_capability( "decoder", 60 );
-    set_callbacks( OpenDecoder, CloseDecoder );
-    add_shortcut( "sdl_image" );
-vlc_module_end();
+vlc_module_begin ()
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_VCODEC )
+    set_shortname( N_("SDL Image decoder"))
+    set_description( N_("SDL_image video decoder") )
+    set_capability( "decoder", 60 )
+    set_callbacks( OpenDecoder, CloseDecoder )
+    add_shortcut( "sdl_image" )
+vlc_module_end ()
 
 static const struct supported_fmt_t
 {
@@ -103,10 +108,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
-    {
-        msg_Err( p_dec, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
     p_sys->psz_sdl_type = p_supported_fmt[i].psz_sdl_type;
 
     /* Set output properties - this is a decoy and isn't used anywhere */
@@ -135,6 +137,12 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     if( pp_block == NULL || *pp_block == NULL ) return NULL;
     p_block = *pp_block;
 
+    if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
+    {
+        block_Release( p_block ); *pp_block = NULL;
+        return NULL;
+    }
+
     p_rw = SDL_RWFromConstMem( p_block->p_buffer, p_block->i_buffer );
 
     /* Decode picture. */
@@ -169,7 +177,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
                                      / p_surface->h;
 
     /* Get a new picture. */
-    p_pic = p_dec->pf_vout_buffer_new( p_dec );
+    p_pic = decoder_NewPicture( p_dec );
     if ( p_pic == NULL ) goto error;
 
     switch ( p_surface->format->BitsPerPixel )
@@ -181,7 +189,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             uint8_t r, g, b;
             for ( i = 0; i < p_surface->h; i++ )
             {
-                p_src = p_surface->pixels + i * p_surface->pitch;
+                p_src = (uint8_t*)p_surface->pixels + i * p_surface->pitch;
                 p_dst = p_pic->p[0].p_pixels + i * p_pic->p[0].i_pitch;
                 for ( j = 0; j < p_surface->w; j++ )
                 {
@@ -204,7 +212,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
             for ( i = 0; i < p_surface->h; i++ )
             {
-                p_dec->p_libvlc->pf_memcpy( p_dst, p_src, i_pitch );
+                vlc_memcpy( p_dst, p_src, i_pitch );
                 p_src += p_surface->pitch;
                 p_dst += p_pic->p[0].i_pitch;
             }
@@ -217,7 +225,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             uint8_t r, g, b;
             for ( i = 0; i < p_surface->h; i++ )
             {
-                p_src = p_surface->pixels + i * p_surface->pitch;
+                p_src = (uint8_t*)p_surface->pixels + i * p_surface->pitch;
                 p_dst = p_pic->p[0].p_pixels + i * p_pic->p[0].i_pitch;
                 for ( j = 0; j < p_surface->w; j++ )
                 {
@@ -238,7 +246,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             uint8_t r, g, b, a;
             for ( i = 0; i < p_surface->h; i++ )
             {
-                p_src = p_surface->pixels + i * p_surface->pitch;
+                p_src = (uint8_t*)p_surface->pixels + i * p_surface->pitch;
                 p_dst = p_pic->p[0].p_pixels + i * p_pic->p[0].i_pitch;
                 for ( j = 0; j < p_surface->w; j++ )
                 {
@@ -255,6 +263,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         }
     }
 
+    p_pic->date = p_block->i_pts > 0 ? p_block->i_pts : p_block->i_dts;
+
     SDL_FreeSurface( p_surface );
     block_Release( p_block ); *pp_block = NULL;
     return p_pic;