* transcode.c: transcoding stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
- * $Id: transcode.c,v 1.80 2004/02/24 17:42:07 gbazin Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
# include <avcodec.h>
#endif
+#if LIBAVCODEC_BUILD < 4704
+# define AV_NOPTS_VALUE 0
+#endif
+
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
id->p_encoder->fmt_out.i_bitrate = id->f_dst.i_bitrate;
id->p_encoder->p_module =
- module_Need( id->p_encoder, "encoder", NULL );
+ module_Need( id->p_encoder, "encoder", NULL, 0 );
if( !id->p_encoder->p_module )
{
vlc_object_destroy( id->p_encoder );
id->ff_dec_c = avcodec_alloc_context();
id->ff_dec_c->width = id->f_src.video.i_width;
id->ff_dec_c->height = id->f_src.video.i_height;
+ id->ff_dec_c->bits_per_sample=id->f_src.video.i_bits_per_pixel;
/* id->ff_dec_c->bit_rate = id->f_src.i_bitrate; */
- id->ff_dec_c->extradata_size= id->f_src.i_extra;
- id->ff_dec_c->extradata = id->f_src.p_extra;
+
+ if( id->f_src.i_extra > 0 )
+ {
+ if( i_ff_codec == CODEC_ID_SVQ3 )
+ {
+ int i_size = id->f_src.i_extra;
+ uint8_t *p;
+
+ id->ff_dec_c->extradata_size = i_size + 12;
+ p = id->ff_dec_c->extradata = malloc( i_size + 12 );
+
+ memcpy( &p[0], "SVQ3", 4 );
+ memset( &p[4], 0, 8 );
+ memcpy( &p[12], id->f_src.p_extra, i_size );
+
+ /* Now remove all atoms before the SMI one */
+ if( id->ff_dec_c->extradata_size > 0x5a && strncmp( &p[0x56], "SMI ", 4 ) )
+ {
+ uint8_t *psz = &p[0x52];
+
+ while( psz < &p[id->ff_dec_c->extradata_size - 8] )
+ {
+ int i_size = GetDWBE( psz );
+ if( i_size <= 1 )
+ {
+ /* FIXME handle 1 as long size */
+ break;
+ }
+ if( !strncmp( &psz[4], "SMI ", 4 ) )
+ {
+ memmove( &p[0x52], psz, &p[id->ff_dec_c->extradata_size] - psz );
+ break;
+ }
+ psz += i_size;
+ }
+ }
+ }
+ else
+ {
+ id->ff_dec_c->extradata_size= id->f_src.i_extra;
+ id->ff_dec_c->extradata = malloc( id->f_src.i_extra + FF_INPUT_BUFFER_PADDING_SIZE );
+
+ memcpy( id->ff_dec_c->extradata, id->f_src.p_extra, id->f_src.i_extra );
+ memset( (uint8_t*)id->ff_dec_c->extradata + id->f_src.i_extra, 0, FF_INPUT_BUFFER_PADDING_SIZE );
+ }
+ }
id->ff_dec_c->workaround_bugs = FF_BUG_AUTODETECT;
id->ff_dec_c->error_resilience= -1;
id->ff_dec_c->get_buffer = transcode_video_ffmpeg_getframebuf;
msg_Err( p_stream, "cannot open decoder" );
return VLC_EGENERIC;
}
-
+#if 0
if( i_ff_codec == CODEC_ID_MPEG4 && id->ff_dec_c->extradata_size > 0 )
{
int b_gotpicture;
id->ff_dec_c->extradata_size );
free( p_vol );
}
+#endif
}
/* Open encoder */
id->p_vresample = NULL;
id->p_encoder->p_module =
- module_Need( id->p_encoder, "encoder", NULL );
+ module_Need( id->p_encoder, "encoder", NULL, 0 );
if( !id->p_encoder->p_module )
{
b_gotpicture = 1;
/* Set PTS */
- frame->pts = p_sys->i_input_pts;
+ frame->pts = p_sys->i_input_pts ? p_sys->i_input_pts :
+ AV_NOPTS_VALUE;
}
if( i_used < 0 )
/* Get the pts of the decoded frame if any, otherwise keep the
* interpolated one */
- if( frame->pts > 0 )
+ if( frame->pts != AV_NOPTS_VALUE )
{
p_sys->i_output_pts = frame->pts;
}
id->p_encoder->fmt_out.p_extra = NULL;
id->p_encoder->p_module =
- module_Need( id->p_encoder, "encoder", NULL );
+ module_Need( id->p_encoder, "encoder", NULL, 0 );
if( !id->p_encoder->p_module )
{
vlc_object_destroy( id->p_encoder );
p_out->i_dts = p_block->i_dts;
p_out->i_pts = p_block->i_pts;
p_out->i_length = p_block->i_length;
+ p_out->i_flags =
+ (p_block->i_flags << SOUT_BUFFER_FLAGS_BLOCK_SHIFT)
+ & SOUT_BUFFER_FLAGS_BLOCK_MASK;
sout_BufferChain( out, p_out );
p_block = p_block->p_next;
p_out->i_dts = p_block->i_dts;
p_out->i_pts = p_block->i_pts;
p_out->i_length = p_block->i_length;
+ p_out->i_flags =
+ (p_block->i_flags << SOUT_BUFFER_FLAGS_BLOCK_SHIFT)
+ & SOUT_BUFFER_FLAGS_BLOCK_MASK;
sout_BufferChain( &p_sys->p_buffers, p_out );
p_block = p_block->p_next;
sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_context->opaque;
/* Set PTS */
- p_frame->pts = p_sys->i_input_pts;
+ p_frame->pts = p_sys->i_input_pts ? p_sys->i_input_pts : AV_NOPTS_VALUE;
return avcodec_default_get_buffer( p_context, p_frame );
}