*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <vlc/vlc.h>
-#include <vlc/decoder.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>
#include SDL_IMAGE_INCLUDE_FILE
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-vlc_module_begin();
- set_category( CAT_INPUT );
- set_subcategory( SUBCAT_INPUT_VCODEC );
- set_description( _("SDL_image video decoder") );
- set_capability( "decoder", 900 );
- 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
{
vlc_fourcc_t i_fourcc;
- char *psz_sdl_type;
+ const char *psz_sdl_type;
} p_supported_fmt[] =
{
{ VLC_FOURCC('t','g','a',' '), "TGA" },
/* 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 */
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. */
/ 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 )
case 8:
{
int i, j;
- uint8_t *r = p_pic->p[0].p_pixels;
- uint8_t *g = p_pic->p[0].p_pixels + 1;
- uint8_t *b = p_pic->p[0].p_pixels + 2;
- SDL_Palette *p_palette = p_surface->format->palette;
-
+ uint8_t *p_src, *p_dst;
+ uint8_t r, g, b;
for ( i = 0; i < p_surface->h; i++ )
{
+ 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++ )
{
- uint8_t i_index = ((uint8_t *)p_surface->pixels)[j];
- SDL_Color *p_color = &p_palette->colors[i_index];
- r[j] = p_color->r;
- g[j] = p_color->g;
- b[j] = p_color->b;
+ SDL_GetRGB( *(p_src++), p_surface->format,
+ &r, &g, &b );
+ *(p_dst++) = r;
+ *(p_dst++) = g;
+ *(p_dst++) = b;
}
}
- r += p_pic->p[0].i_pitch;
- g += p_pic->p[0].i_pitch;
- b += p_pic->p[0].i_pitch;
break;
}
case 16:
for ( i = 0; i < p_surface->h; i++ )
{
- p_dec->p_vlc->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;
}
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++ )
{
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++ )
{
}
}
+ 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;