Commit 3a223f41 authored by Sam Hocevar's avatar Sam Hocevar

* modules/codec/ffmpeg: bring the ffmpeg module up to date with trunk.

parent aa29fca0
......@@ -8,6 +8,7 @@ SOURCES_ffmpeg = \
encoder.c \
postprocess.c \
demux.c \
mux.c \
$(NULL)
SOURCES_ffmpegaltivec = \
......@@ -20,5 +21,6 @@ SOURCES_ffmpegaltivec = \
encoder.c \
postprocess.c \
demux.c \
mux.c \
$(NULL)
......@@ -74,7 +74,7 @@ static int Demux ( demux_t *p_demux );
static int Control( demux_t *p_demux, int i_query, va_list args );
static int IORead( void *opaque, uint8_t *buf, int buf_size );
static int IOSeek( void *opaque, offset_t offset, int whence );
static offset_t IOSeek( void *opaque, offset_t offset, int whence );
/*****************************************************************************
* Open
......@@ -338,7 +338,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
*pf = (double)stream_Tell( p_demux->s ) / (double)i64;
}
if( p_sys->ic->duration != AV_NOPTS_VALUE && p_sys->i_pcr > 0 )
if( (p_sys->ic->duration != AV_NOPTS_VALUE) && (p_sys->i_pcr > 0) )
{
*pf = (double)p_sys->i_pcr / (double)p_sys->ic->duration;
}
......@@ -442,7 +442,7 @@ static int IORead( void *opaque, uint8_t *buf, int buf_size )
return i_ret ? i_ret : -1;
}
static int IOSeek( void *opaque, offset_t offset, int whence )
static offset_t IOSeek( void *opaque, offset_t offset, int whence )
{
URLContext *p_url = opaque;
demux_t *p_demux = p_url->priv_data;
......
......@@ -43,7 +43,7 @@
#endif
#if LIBAVCODEC_BUILD < 4704
# define AV_NOPTS_VALUE 0
# define AV_NOPTS_VALUE (int64_t)0
#endif
#if LIBAVCODEC_BUILD < 4684
# define FF_QP2LAMBDA 118
......@@ -51,7 +51,6 @@
#include "ffmpeg.h"
#define AVCODEC_MAX_VIDEO_FRAME_SIZE (3*1024*1024)
#define HURRY_UP_GUARD1 (450000)
#define HURRY_UP_GUARD2 (300000)
#define HURRY_UP_GUARD3 (100000)
......@@ -429,7 +428,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
VOUT_ASPECT_FACTOR;
#endif
p_sys->p_buffer_out = malloc( AVCODEC_MAX_VIDEO_FRAME_SIZE );
p_sys->p_buffer_out = malloc( p_context->height * p_context->width * 3 );
p_enc->fmt_in.i_codec = VLC_FOURCC('I','4','2','0');
p_context->pix_fmt = E_(GetFfmpegChroma)( p_enc->fmt_in.i_codec );
......@@ -867,8 +866,8 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
#endif
/* End work-around */
i_out = avcodec_encode_video( p_sys->p_context, p_sys->p_buffer_out,
AVCODEC_MAX_VIDEO_FRAME_SIZE, &frame );
i_out = avcodec_encode_video( p_sys->p_context, (uint8_t*)p_sys->p_buffer_out,
p_sys->p_context->height * p_sys->p_context->width * 3, &frame );
if( i_out > 0 )
{
......@@ -958,7 +957,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
encoder_sys_t *p_sys = p_enc->p_sys;
block_t *p_block, *p_chain = NULL;
char *p_buffer = p_aout_buf->p_buffer;
uint8_t *p_buffer = p_aout_buf->p_buffer;
int i_samples = p_aout_buf->i_nb_samples;
int i_samples_delay = p_sys->i_samples_delay;
......@@ -991,7 +990,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
p_samples = (int16_t *)p_buffer;
}
i_out = avcodec_encode_audio( p_sys->p_context, p_sys->p_buffer_out,
i_out = avcodec_encode_audio( p_sys->p_context, (uint8_t *)p_sys->p_buffer_out,
2 * AVCODEC_MAX_AUDIO_FRAME_SIZE,
p_samples );
......
......@@ -191,6 +191,12 @@ vlc_module_begin();
set_capability( "demux2", 2 );
set_callbacks( E_(OpenDemux), E_(CloseDemux) );
/* mux submodule */
add_submodule();
set_description( _("FFmpeg muxer" ) );
set_capability( "sout mux", 2 );
set_callbacks( E_(OpenMux), E_(CloseMux) );
/* video filter submodule */
add_submodule();
set_capability( "video filter2", 50 );
......@@ -222,8 +228,8 @@ static int OpenDecoder( vlc_object_t *p_this )
int i_cat, i_codec_id, i_result;
char *psz_namecodec;
AVCodecContext *p_context;
AVCodec *p_codec;
AVCodecContext *p_context = NULL;
AVCodec *p_codec = NULL;
/* *** determine codec type *** */
if( !E_(GetFfmpegCodec)( p_dec->fmt_in.i_codec, &i_cat, &i_codec_id,
......@@ -244,7 +250,8 @@ static int OpenDecoder( vlc_object_t *p_this )
E_(InitLibavcodec)(p_this);
/* *** ask ffmpeg for a decoder *** */
if( !( p_codec = avcodec_find_decoder( i_codec_id ) ) )
p_codec = avcodec_find_decoder( i_codec_id );
if( !p_codec )
{
msg_Dbg( p_dec, "codec not found (%s)", psz_namecodec );
return VLC_EGENERIC;
......@@ -252,6 +259,8 @@ static int OpenDecoder( vlc_object_t *p_this )
/* *** get a p_context *** */
p_context = avcodec_alloc_context();
if( !p_context )
return VLC_ENOMEM;
p_context->debug = config_GetInt( p_dec, "ffmpeg-debug" );
p_context->opaque = (void *)p_this;
......@@ -325,7 +334,7 @@ static void CloseDecoder( vlc_object_t *p_this )
{
if( p_sys->p_context->extradata )
free( p_sys->p_context->extradata );
p_sys->p_context->extradata = NULL;
vlc_mutex_lock( lockval.p_address );
avcodec_close( p_sys->p_context );
vlc_mutex_unlock( lockval.p_address );
......@@ -376,6 +385,9 @@ static void LibavcodecCallback( void *p_opaque, int i_level,
i_vlc_level = VLC_MSG_DBG;
break;
case AV_LOG_DEBUG:
/* Print debug messages if they were requested */
if( p_avctx->debug ) vfprintf( stderr, psz_format, va );
return;
default:
return;
}
......@@ -721,7 +733,7 @@ static struct
VIDEO_ES, "Windows Media Video 1" },
{ VLC_FOURCC('W','M','V','2'), CODEC_ID_WMV2,
VIDEO_ES, "Windows Media Video 2" },
#if 0
#if LIBAVCODEC_BUILD >= ((51<<16)+(10<<8)+1)
{ VLC_FOURCC('W','M','V','3'), CODEC_ID_WMV3,
VIDEO_ES, "Windows Media Video 3" },
{ VLC_FOURCC('W','V','C','1'), CODEC_ID_VC1,
......@@ -780,11 +792,28 @@ static struct
VIDEO_ES, "Creative YUV Video" },
/* On2 VP3 Video Codecs */
{ VLC_FOURCC('V','P','3',' '), CODEC_ID_VP3,
VIDEO_ES, "On2's VP3 Video" },
{ VLC_FOURCC('V','P','3','0'), CODEC_ID_VP3,
VIDEO_ES, "On2's VP3 Video" },
{ VLC_FOURCC('V','P','3','1'), CODEC_ID_VP3,
VIDEO_ES, "On2's VP3 Video" },
{ VLC_FOURCC('v','p','3','1'), CODEC_ID_VP3,
VIDEO_ES, "On2's VP3 Video" },
#if LIBAVCODEC_BUILD >= ((51<<16)+(14<<8)+0)
{ VLC_FOURCC('V','P','5',' '), CODEC_ID_VP5,
VIDEO_ES, "On2's VP5 Video" },
{ VLC_FOURCC('V','P','5','0'), CODEC_ID_VP5,
VIDEO_ES, "On2's VP5 Video" },
{ VLC_FOURCC('V','P','6','2'), CODEC_ID_VP6,
VIDEO_ES, "On2's VP6.2 Video" },
{ VLC_FOURCC('v','p','6','2'), CODEC_ID_VP6,
VIDEO_ES, "On2's VP6.2 Video" },
{ VLC_FOURCC('V','P','6','F'), CODEC_ID_VP6F,
VIDEO_ES, "On2's VP6.2 Video (Flash)" },
#endif
#if LIBAVCODEC_BUILD >= 4685
/* Xiph.org theora */
{ VLC_FOURCC('t','h','e','o'), CODEC_ID_THEORA,
......@@ -904,6 +933,12 @@ static struct
VIDEO_ES, "Indeo Video v2" },
#endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(13<<8)+0)
{ VLC_FOURCC('V','M','n','c'), CODEC_ID_VMNC,
VIDEO_ES, "VMware Video" },
#endif
/*
* Image codecs
*/
......
......@@ -68,6 +68,10 @@ void E_(CloseAudioEncoder)( vlc_object_t * );
int E_(OpenDemux) ( vlc_object_t * );
void E_(CloseDemux)( vlc_object_t * );
/* Mux module */
int E_(OpenMux) ( vlc_object_t * );
void E_(CloseMux)( vlc_object_t * );
/* Video filter module */
int E_(OpenFilter)( vlc_object_t * );
int E_(OpenCropPadd)( vlc_object_t * );
......
This diff is collapsed.
......@@ -517,7 +517,7 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic,
&b_gotpicture,
p_sys->p_buffer, p_sys->i_buffer );
(uint8_t*)p_sys->p_buffer, p_sys->i_buffer );
if( b_null_size && p_sys->p_context->width > 0 &&
p_sys->p_context->height > 0 )
{
......@@ -526,7 +526,7 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
p_sys->p_context->hurry_up = 0;
i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic,
&b_gotpicture,
p_sys->p_buffer, p_sys->i_buffer );
(uint8_t*)p_sys->p_buffer, p_sys->i_buffer );
}
if( i_used < 0 )
......@@ -725,7 +725,7 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
/* Now remove all atoms before the SMI one */
if( p_sys->p_context->extradata_size > 0x5a &&
strncmp( &p[0x56], "SMI ", 4 ) )
strncmp( (char*)&p[0x56], "SMI ", 4 ) )
{
uint8_t *psz = &p[0x52];
......@@ -737,7 +737,7 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
/* FIXME handle 1 as long size */
break;
}
if( !strncmp( &psz[4], "SMI ", 4 ) )
if( !strncmp( (char*)&psz[4], "SMI ", 4 ) )
{
memmove( &p[0x52], psz,
&p[p_sys->p_context->extradata_size] - psz );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment