Commit 5e99f4d4 authored by Laurent Aimar's avatar Laurent Aimar

* ffmpeg: remove some #ifdef (you need at least libavcodec build >= 4655)

and use ffmpeg postprocessing instead of vlc builtins. (It's a lot faster).
parent 4f947313
......@@ -2,7 +2,7 @@
* audio.c: audio decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: audio.c,v 1.14 2003/02/07 01:22:55 fenrir Exp $
* $Id: audio.c,v 1.15 2003/04/17 10:58:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -105,9 +105,7 @@ int E_( InitThread_Audio )( adec_thread_t *p_adec )
/* ***** Fill p_context with init values ***** */
p_adec->p_context->sample_rate = p_wf->nSamplesPerSec;
p_adec->p_context->channels = p_wf->nChannels;
#if LIBAVCODEC_BUILD >= 4618
p_adec->p_context->block_align = p_wf->nBlockAlign;
#endif
p_adec->p_context->bit_rate = p_wf->nAvgBytesPerSec * 8;
if( ( p_adec->p_context->extradata_size = p_wf->cbSize ) > 0 )
......
......@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.29 2003/04/16 00:12:36 fenrir Exp $
* $Id: ffmpeg.c,v 1.30 2003/04/17 10:58:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -40,9 +40,19 @@
#include "avcodec.h" /* ffmpeg */
#include "postprocessing/postprocessing.h"
#if LIBAVCODEC_BUILD < 4655
# error You must have a libavcodec >= 4655 (get CVS)
#endif
#include "ffmpeg.h"
#ifdef LIBAVCODEC_PP
# include "libpostproc/postprocess.h"
#else
# include "postprocessing/postprocessing.h"
#endif
#include "video.h" // video ffmpeg specific
#include "audio.h" // audio ffmpeg specific
......@@ -77,8 +87,7 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** );
#define POSTPROCESSING_Q_LONGTEXT \
"Quality of post processing\n"\
"Valid range is 0 to 6\n" \
"(Overridden by others setting)"
"Valid range is 0 to 6"
#define POSTPROCESSING_AQ_LONGTEXT \
"Post processing quality is selected upon time left " \
......@@ -95,26 +104,63 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** );
"32 ac vlc" \
"64 Qpel chroma"
/* FIXME (cut/past from ffmpeg */
#define LIBAVCODEC_PP_LONGHELP \
"<filterName>[:<option>[:<option>...]][[,|/][-]<filterName>[:<option>...]]...\n" \
"long form example:\n" \
"vdeblock:autoq/hdeblock:autoq/linblenddeint default,-vdeblock\n" \
"short form example:\n" \
"vb:a/hb:a/lb de,-vb\n" \
"more examples:\n" \
"tn:64:128:256\n" \
"Filters Options\n" \
"short long name short long option Description\n" \
"* * a autoq cpu power dependant enabler\n" \
" c chrom chrominance filtring enabled\n" \
" y nochrom chrominance filtring disabled\n" \
"hb hdeblock (2 Threshold) horizontal deblocking filter\n" \
" 1. difference factor: default=64, higher -> more deblocking\n" \
" 2. flatness threshold: default=40, lower -> more deblocking\n" \
" the h & v deblocking filters share these\n" \
" so u cant set different thresholds for h / v\n" \
"vb vdeblock (2 Threshold) vertical deblocking filter\n" \
"h1 x1hdeblock Experimental h deblock filter 1\n" \
"v1 x1vdeblock Experimental v deblock filter 1\n" \
"dr dering Deringing filter\n" \
"al autolevels automatic brightness / contrast\n" \
" f fullyrange stretch luminance to (0..255)\n" \
"lb linblenddeint linear blend deinterlacer\n" \
"li linipoldeint linear interpolating deinterlace\n" \
"ci cubicipoldeint cubic interpolating deinterlacer\n" \
"md mediandeint median deinterlacer\n" \
"fd ffmpegdeint ffmpeg deinterlacer\n" \
"de default hb:a,vb:a,dr:a,al\n" \
"fa fast h1:a,v1:a,dr:a,al\n" \
"tn tmpnoise (3 Thresholds) Temporal Noise Reducer\n" \
" 1. <= 2. <= 3. larger -> stronger filtering\n" \
"fq forceQuant <quantizer> Force quantizer\n"
vlc_module_begin();
add_category_hint( N_("ffmpeg"), NULL, VLC_FALSE );
#if LIBAVCODEC_BUILD >= 4615
add_bool( "ffmpeg-dr", 0, NULL,
"direct rendering",
"direct rendering", VLC_TRUE );
#endif
#if LIBAVCODEC_BUILD >= 4611
add_integer ( "ffmpeg-error-resilience", -1, NULL,
"error resilience", ERROR_RESILIENCE_LONGTEXT, VLC_TRUE );
add_integer ( "ffmpeg-workaround-bugs", 1, NULL,
"workaround bugs", WORKAROUND_BUGS_LONGTEXT, VLC_FALSE );
#endif
add_bool( "ffmpeg-hurry-up", 0, NULL, "hurry up", HURRY_UP_LONGTEXT, VLC_FALSE );
add_category_hint( N_("Post processing"), NULL, VLC_FALSE );
add_module( "ffmpeg-pp", "postprocessing",NULL, NULL,
N_( "ffmpeg postprocessing module" ), NULL, VLC_FALSE );
add_integer( "ffmpeg-pp-q", 0, NULL,
"post processing quality", POSTPROCESSING_Q_LONGTEXT, VLC_FALSE );
#ifdef LIBAVCODEC_PP
add_string( "ffmpeg-pp-name", "default", NULL,
"ffmpeg postproc filter chains", LIBAVCODEC_PP_LONGHELP, VLC_TRUE );
#else
add_module( "ffmpeg-pp", "postprocessing",NULL, NULL,
N_( "ffmpeg postprocessing module" ), NULL, VLC_FALSE );
add_bool( "ffmpeg-pp-auto", 0, NULL,
"auto-level Post processing quality", POSTPROCESSING_AQ_LONGTEXT, VLC_FALSE );
add_bool( "ffmpeg-db-yv", 0, NULL,
......@@ -135,7 +181,7 @@ vlc_module_begin();
add_bool( "ffmpeg-dr-c", 0, NULL,
"force chrominance deringing",
"force chrominance deringing (override other settings)", VLC_TRUE );
#endif
set_description( _("ffmpeg audio/video decoder((MS)MPEG4,SVQ1,H263,WMV,WMA)") );
set_capability( "decoder", 70 );
set_callbacks( OpenDecoder, NULL );
......@@ -275,12 +321,7 @@ static int InitThread( generic_thread_t *p_decoder )
}
/* *** Get a p_context *** */
#if LIBAVCODEC_BUILD >= 4624
p_decoder->p_context = avcodec_alloc_context();
#else
p_decoder->p_context = malloc( sizeof( AVCodecContext ) );
memset( p_decoder->p_context, 0, sizeof( AVCodecContext ) );
#endif
switch( p_decoder->i_cat )
{
......@@ -399,7 +440,6 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
psz_name = "MPEG-1/2 Video";
break;
#endif
#if LIBAVCODEC_BUILD >= 4608
case FOURCC_DIV1:
case FOURCC_div1:
case FOURCC_MPG4:
......@@ -417,7 +457,6 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
i_codec = CODEC_ID_MSMPEG4V2;
psz_name = "MS MPEG-4 v2";
break;
#endif
case FOURCC_MPG3:
case FOURCC_mpg3:
......@@ -437,21 +476,15 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
case FOURCC_3IVD:
case FOURCC_3ivd:
i_cat = VIDEO_ES;
#if LIBAVCODEC_BUILD >= 4608
i_codec = CODEC_ID_MSMPEG4V3;
#else
i_codec = CODEC_ID_MSMPEG4;
#endif
psz_name = "MS MPEG-4 v3";
break;
#if LIBAVCODEC_BUILD >= 4615
case FOURCC_SVQ1:
i_cat = VIDEO_ES;
i_codec = CODEC_ID_SVQ1;
psz_name = "SVQ-1 (Sorenson Video v1)";
break;
#endif
case FOURCC_DIVX:
case FOURCC_divx:
......@@ -512,13 +545,11 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
i_codec = CODEC_ID_MJPEG;
psz_name = "Motion JPEG";
break;
#if LIBAVCODEC_BUILD >= 4640
case FOURCC_mjpb:
i_cat = VIDEO_ES;
i_codec = CODEC_ID_MJPEGB;
psz_name = "Motion JPEG B";
break;
#endif
case FOURCC_dvsl:
case FOURCC_dvsd:
case FOURCC_DVSD:
......@@ -530,7 +561,6 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
psz_name = "DV video";
break;
#if LIBAVCODEC_BUILD >= 4655
case FOURCC_MAC3:
i_cat = AUDIO_ES;
i_codec = CODEC_ID_MACE3;
......@@ -546,9 +576,7 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
i_codec = CODEC_ID_DVAUDIO;
psz_name = "DV audio";
break;
#endif
#if LIBAVCODEC_BUILD >= 4632
case FOURCC_WMA1:
case FOURCC_wma1:
i_cat = AUDIO_ES;
......@@ -561,7 +589,6 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
i_codec = CODEC_ID_WMAV2;
psz_name ="Windows Media Audio 2";
break;
#endif
#if LIBAVCODEC_BUILD >= 4663
case FOURCC_IV31:
......
......@@ -2,7 +2,7 @@
* ffmpeg_vdec.h: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: ffmpeg.h,v 1.16 2003/04/16 00:12:36 fenrir Exp $
* $Id: ffmpeg.h,v 1.17 2003/04/17 10:58:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -47,6 +47,12 @@ typedef struct generic_thread_s
} generic_thread_t;
#if LIBAVCODEC_BUILD >= 4663
# define LIBAVCODEC_PP
#else
# undef LIBAVCODEC_PP
#endif
#define GetWLE( p ) \
( *(u8*)(p) + ( *((u8*)(p)+1) << 8 ) )
......
......@@ -2,7 +2,7 @@
* video.c: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: video.c,v 1.19 2003/03/24 13:50:55 hartman Exp $
* $Id: video.c,v 1.20 2003/04/17 10:58:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
......@@ -40,28 +40,30 @@
#endif
#include "avcodec.h" /* ffmpeg */
#include "ffmpeg.h"
#include "postprocessing/postprocessing.h"
#ifdef LIBAVCODEC_PP
# include "libpostproc/postprocess.h"
#else
# include "postprocessing/postprocessing.h"
#endif
#include "ffmpeg.h"
#include "video.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
#if LIBAVCODEC_BUILD >= 4641
static void ffmpeg_CopyPicture( picture_t *, AVFrame *, vdec_thread_t * );
#else
static void ffmpeg_CopyPicture( picture_t *, AVPicture *, vdec_thread_t * );
#endif
#ifndef LIBAVCODEC_PP
static void ffmpeg_PostProcPicture( vdec_thread_t *, picture_t * );
#if LIBAVCODEC_BUILD >= 4641
static int ffmpeg_GetFrameBuf( struct AVCodecContext *, AVFrame *);
static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame *);
#endif
/* direct rendering */
static int ffmpeg_GetFrameBuf ( struct AVCodecContext *, AVFrame *);
static void ffmpeg_ReleaseFrameBuf ( struct AVCodecContext *, AVFrame *);
/*****************************************************************************
* Local Functions
*****************************************************************************/
......@@ -81,10 +83,8 @@ static inline uint32_t ffmpeg_PixFmtToChroma( int i_ff_chroma )
return( VLC_FOURCC('I','4','2','2') );
case PIX_FMT_YUV444P:
return( VLC_FOURCC('I','4','4','4') );
#if LIBAVCODEC_BUILD >= 4615
case PIX_FMT_YUV410P:
case PIX_FMT_YUV411P:
#endif
case PIX_FMT_BGR24:
default:
return( 0 );
......@@ -111,34 +111,55 @@ static vout_thread_t *ffmpeg_CreateVout( vdec_thread_t *p_vdec,
/* we make conversion if possible*/
i_chroma = VLC_FOURCC('I','4','2','0');
}
#if LIBAVCODEC_BUILD >= 4640
i_aspect = VOUT_ASPECT_FACTOR * p_context->aspect_ratio;
if( i_aspect == 0 )
{
i_aspect = VOUT_ASPECT_FACTOR * i_width / i_height;
}
#else
switch( p_context->aspect_ratio_info )
/* Spawn a video output if there is none. First we look for our children,
* then we look for any other vout that might be available. */
p_vout = vout_Request( p_vdec->p_fifo, NULL,
i_width, i_height, i_chroma, i_aspect );
#ifdef LIBAVCODEC_PP
if( p_vdec->pp_mode && !p_vdec->pp_context )
{
int32_t i_cpu = p_vdec->p_fifo->p_libvlc->i_cpu;
int i_flags = 0;
if( i_cpu & CPU_CAPABILITY_MMX )
{
i_flags |= PP_CPU_CAPS_MMX;
}
if( i_cpu & CPU_CAPABILITY_MMXEXT )
{
i_flags |= PP_CPU_CAPS_MMX2;
}
if( i_cpu & CPU_CAPABILITY_3DNOW )
{
i_flags |= PP_CPU_CAPS_3DNOW;
}
switch( p_context->pix_fmt )
{
case( FF_ASPECT_4_3_625 ):
case( FF_ASPECT_4_3_525 ):
i_aspect = VOUT_ASPECT_FACTOR * 4 / 3;
case PIX_FMT_YUV444P:
i_flags |= PP_FORMAT_444;
break;
case( FF_ASPECT_16_9_625 ):
case( FF_ASPECT_16_9_525 ):
i_aspect = VOUT_ASPECT_FACTOR * 16 / 9 ;
case PIX_FMT_YUV422P:
i_flags |= PP_FORMAT_422;
break;
case PIX_FMT_YUV411P:
i_flags |= PP_FORMAT_411;
break;
case( FF_ASPECT_SQUARE ):
default:
i_aspect = VOUT_ASPECT_FACTOR * i_width / i_height;
i_flags |= PP_FORMAT_420;
break;
}
#endif
/* Spawn a video output if there is none. First we look for our children,
* then we look for any other vout that might be available. */
p_vout = vout_Request( p_vdec->p_fifo, NULL,
i_width, i_height, i_chroma, i_aspect );
p_vdec->pp_context = pp_get_context( i_width, i_height, i_flags );
}
#endif
return p_vout;
}
......@@ -166,20 +187,13 @@ static vout_thread_t *ffmpeg_CreateVout( vdec_thread_t *p_vdec,
int E_( InitThread_Video )( vdec_thread_t *p_vdec )
{
int i_tmp;
#if LIBAVCODEC_BUILD >= 4645
p_vdec->p_ff_pic = avcodec_alloc_frame();
#elif LIBAVCODEC_BUILD >= 4641
p_vdec->p_ff_pic = avcodec_alloc_picture();
#else
p_vdec->p_ff_pic = &p_vdec->ff_pic;
#endif
if( ( p_vdec->p_format = (BITMAPINFOHEADER *)p_vdec->p_fifo->p_bitmapinfoheader) != NULL )
{
/* ***** Fill p_context with init values ***** */
p_vdec->p_context->width = p_vdec->p_format->biWidth;
p_vdec->p_context->height = p_vdec->p_format->biHeight;
}
else
{
......@@ -189,34 +203,21 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
/* ***** Get configuration of ffmpeg plugin ***** */
#if LIBAVCODEC_BUILD >= 4611
i_tmp = config_GetInt( p_vdec->p_fifo, "ffmpeg-workaround-bugs" );
p_vdec->p_context->workaround_bugs = __MAX( __MIN( i_tmp, 99 ), 0 );
i_tmp = config_GetInt( p_vdec->p_fifo, "ffmpeg-error-resilience" );
p_vdec->p_context->error_resilience = __MAX( __MIN( i_tmp, 99 ), -1 );
#endif
#if LIBAVCODEC_BUILD >= 4614
if( config_GetInt( p_vdec->p_fifo, "grayscale" ) )
{
p_vdec->p_context->flags|= CODEC_FLAG_GRAY;
}
#endif
p_vdec->b_hurry_up = config_GetInt(p_vdec->p_fifo, "ffmpeg-hurry-up");
p_vdec->b_direct_rendering = 0;
#if 0
/* check if codec support truncated frames */
// if( p_vdec->p_codec->capabilities & CODEC_FLAG_TRUNCATED )
if( p_vdec->i_codec_id == CODEC_ID_MPEG1VIDEO)
{
msg_Dbg( p_vdec->p_fifo, "CODEC_FLAG_TRUNCATED supported" );
p_vdec->p_context->flags |= CODEC_FLAG_TRUNCATED;
}
#endif
/* CODEC_FLAG_TRUNCATED */
/* FIXME search real LIBAVCODEC_BUILD */
......@@ -231,7 +232,7 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
{
msg_Err( p_vdec->p_fifo, "cannot open codec (%s)",
p_vdec->psz_namecodec );
return( -1 );
return( VLC_EGENERIC );
}
else
{
......@@ -239,7 +240,6 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
p_vdec->psz_namecodec );
}
#if LIBAVCODEC_BUILD >= 4641
if( config_GetInt( p_vdec->p_fifo, "ffmpeg-dr" ) &&
p_vdec->p_codec->capabilities & CODEC_CAP_DR1 &&
ffmpeg_PixFmtToChroma( p_vdec->p_context->pix_fmt ) )
......@@ -255,52 +255,72 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
p_vdec->p_context->opaque = p_vdec;
}
#endif
/* ***** init this codec with special data ***** */
if( p_vdec->p_format &&
p_vdec->p_format->biSize > sizeof(BITMAPINFOHEADER) )
{
int b_gotpicture;
int i_size = p_vdec->p_format->biSize - sizeof(BITMAPINFOHEADER);
switch( p_vdec->i_codec_id )
if( p_vdec->i_codec_id == CODEC_ID_MPEG4 )
{
case( CODEC_ID_MPEG4 ):
#if 1
avcodec_decode_video( p_vdec->p_context, p_vdec->p_ff_pic,
&b_gotpicture,
(void *)&p_vdec->p_format[1],
p_vdec->p_format->biSize
- sizeof(BITMAPINFOHEADER) );
#endif
break;
default:
if( p_vdec->p_fifo->i_fourcc == FOURCC_MP4S ||
p_vdec->p_fifo->i_fourcc == FOURCC_mp4s ||
p_vdec->p_fifo->i_fourcc == FOURCC_M4S2 ||
p_vdec->p_fifo->i_fourcc == FOURCC_m4s2 ||
p_vdec->p_fifo->i_fourcc == FOURCC_WMV2 ||
p_vdec->p_fifo->i_fourcc == FOURCC_MSS1 ||
p_vdec->p_fifo->i_fourcc == FOURCC_MJPG ||
p_vdec->p_fifo->i_fourcc == FOURCC_mjpg ||
p_vdec->p_fifo->i_fourcc == FOURCC_mjpa ||
p_vdec->p_fifo->i_fourcc == FOURCC_mjpb )
{
p_vdec->p_context->extradata_size =
p_vdec->p_format->biSize - sizeof(BITMAPINFOHEADER);
p_vdec->p_context->extradata =
malloc( p_vdec->p_context->extradata_size );
i_size );
}
else
{
p_vdec->p_context->extradata_size = i_size;
p_vdec->p_context->extradata = malloc( i_size );
memcpy( p_vdec->p_context->extradata,
&p_vdec->p_format[1],
p_vdec->p_context->extradata_size );
i_size );
}
}
break;
/* ***** Load post processing ***** */
#ifdef LIBAVCODEC_PP
p_vdec->pp_context = NULL;
p_vdec->pp_mode = NULL;
/* for now we cannot do postproc and dr */
if( config_GetInt( p_vdec->p_fifo, "ffmpeg-pp-q" ) > 0 && !p_vdec->b_direct_rendering )
{
int i_quality = config_GetInt( p_vdec->p_fifo, "ffmpeg-pp-q" );
char *psz_name = config_GetPsz( p_vdec->p_fifo, "ffmpeg-pp-name" );
if( !psz_name )
{
psz_name = strdup( "default" );
}
else if( *psz_name == '\0' )
{
free( psz_name );
psz_name = strdup( "default" );
}
/* ***** Load post processing ***** */
p_vdec->pp_mode = pp_get_mode_by_name_and_quality( psz_name, i_quality );
if( !p_vdec->pp_mode )
{
msg_Err( p_vdec->p_fifo, "failed geting mode for postproc" );
}
else
{
msg_Info( p_vdec->p_fifo, "postproc activated" );
}
free( psz_name );
}
else
{
msg_Dbg( p_vdec->p_fifo, "no postproc" );
}
#else
/* get overridding settings */
p_vdec->i_pp_mode = 0;
if( config_GetInt( p_vdec->p_fifo, "ffmpeg-db-yv" ) )
......@@ -323,20 +343,15 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
/* check if the codec support postproc. */
switch( p_vdec->i_codec_id )
{
#if LIBAVCODEC_BUILD > 4608
case( CODEC_ID_MSMPEG4V1 ):
case( CODEC_ID_MSMPEG4V2 ):
case( CODEC_ID_MSMPEG4V3 ):
#else
case( CODEC_ID_MSMPEG4 ):
#endif
case( CODEC_ID_MPEG4 ):
case( CODEC_ID_H263 ):
// case( CODEC_ID_H263P ): I don't use it up to now
case( CODEC_ID_H263I ):
/* Ok we can make postprocessing :)) */
/* first try to get a postprocess module */
#if LIBAVCODEC_BUILD >= 4633
p_vdec->p_pp = vlc_object_create( p_vdec->p_fifo,
sizeof( postprocessing_t ) );
p_vdec->p_pp->psz_object_name = "postprocessing";
......@@ -360,11 +375,6 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
config_GetInt( p_vdec->p_fifo, "ffmpeg-pp-auto" )
);
}
#else
p_vdec->i_pp_mode = 0;
msg_Warn( p_vdec->p_fifo,
"post-processing not supported, upgrade ffmpeg" );
#endif
break;
default:
p_vdec->i_pp_mode = 0;
......@@ -372,11 +382,10 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
"Post processing unsupported for this codec" );
break;
}
}
// memset( &p_vdec->statistic, 0, sizeof( statistic_t ) );
#endif
return( 0 );
return( VLC_SUCCESS );
}
/*****************************************************************************
......@@ -395,6 +404,7 @@ void E_( DecodeThread_Video )( vdec_thread_t *p_vdec )
picture_t *p_pic; /* videolan picture */
mtime_t i_pts;
/* TODO implement it in a better way */
/* A good idea could be to decode all I pictures and see for the other */
if( ( p_vdec->b_hurry_up )&& ( p_vdec->i_frame_late > 4 ) )
......@@ -511,10 +521,6 @@ usenextdata:
}
else if( i_used < i_frame_size )
{
#if 0
msg_Dbg( p_vdec->p_fifo,
"didn't use all memory(%d < %d)", i_used, i_frame_size );
#endif
memmove( p_vdec->p_buffer,
p_vdec->p_buffer + i_used,
p_vdec->i_buffer_size - i_used );
......@@ -535,8 +541,7 @@ usenextdata:
i_frame_size -= i_used;
/* Update frame late count*/
/* I don't make statistic on decoding time */
if( p_vdec->pts <= mdate())
if( p_vdec->pts <= mdate() )
{
p_vdec->i_frame_late++;
}
......@@ -573,21 +578,29 @@ usenextdata:
/* fill p_picture_t from AVVideoFrame and do chroma conversion
* if needed */
ffmpeg_CopyPicture( p_pic, p_vdec->p_ff_pic, p_vdec );
#ifndef LIBAVCODEC_PP
/* Do post-processing if requested (with old code)*/
/* XXX: no dr */
if( ( p_vdec->i_pp_mode )&&
( ( p_vdec->p_vout->render.i_chroma ==
VLC_FOURCC( 'I','4','2','0' ) )||
( p_vdec->p_vout->render.i_chroma ==
VLC_FOURCC( 'Y','V','1','2' ) ) ) )
{
p_vdec->p_pp->pf_postprocess( p_pic,
p_vdec->p_ff_pic->qscale_table,
p_vdec->p_ff_pic->qstride,
p_vdec->i_pp_mode );
}
#endif
}
else
{
#if LIBAVCODEC_BUILD >= 4641
p_pic = (picture_t *)p_vdec->p_ff_pic->opaque;
#else
p_pic = NULL; /* f**ck gcc warning */
#endif
}
/* Do post-processing if requested */
/* XXX: with dr it is not a good thing if the picture will be used as
reference... */
ffmpeg_PostProcPicture( p_vdec, p_pic );
/* fix date calculation */
if( p_vdec->pts > 0 )
{
......@@ -635,6 +648,16 @@ usenextdata:
void E_( EndThread_Video )( vdec_thread_t *p_vdec )
{
#ifdef LIBAVCODEC_PP
if( p_vdec->pp_mode )
{
pp_free_mode( p_vdec->pp_mode );
if( p_vdec->pp_context )
{
pp_free_context( p_vdec->pp_context );
}
}
#else
if( p_vdec->p_pp )
{
/* release postprocessing module */
......@@ -642,13 +665,12 @@ void E_( EndThread_Video )( vdec_thread_t *p_vdec )
vlc_object_destroy( p_vdec->p_pp );
p_vdec->p_pp = NULL;
}
#endif
#if LIBAVCODEC_BUILD >= 4641
if( p_vdec->p_ff_pic )
{
free( p_vdec->p_ff_pic );
}
#endif
/* We are about to die. Reattach video output to p_vlc. */
vout_Request( p_vdec->p_fifo, p_vdec->p_vout, 0, 0, 0, 0 );
......@@ -658,15 +680,9 @@ void E_( EndThread_Video )( vdec_thread_t *p_vdec )
* ffmpeg_CopyPicture: copy a picture from ffmpeg internal buffers to a
* picture_t structure (when not in direct rendering mode).
*****************************************************************************/
#if LIBAVCODEC_BUILD >= 4641
static void ffmpeg_CopyPicture( picture_t *p_pic,
AVFrame *p_ff_pic,
vdec_thread_t *p_vdec )
#else
static void ffmpeg_CopyPicture( picture_t *p_pic,
AVPicture *p_ff_pic,
vdec_thread_t *p_vdec )
#endif
{
int i_plane;
int i_size;
......@@ -679,6 +695,30 @@ static void ffmpeg_CopyPicture( picture_t *p_pic,
if( ffmpeg_PixFmtToChroma( p_vdec->p_context->pix_fmt ) )
{
#ifdef LIBAVCODEC_PP
if( p_vdec->pp_mode && p_vdec->pp_context )
{
uint8_t *src[3], *dst[3];
int i_src_stride[3], i_dst_stride[3];
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{
src[i_plane] = p_ff_pic->data[i_plane];
dst[i_plane] = p_pic->p[i_plane].p_pixels;
i_src_stride[i_plane] = p_ff_pic->linesize[i_plane];
i_dst_stride[i_plane] = p_pic->p[i_plane].i_pitch;
}
pp_postprocess( src, i_src_stride,
dst, i_dst_stride,
p_vdec->p_context->width, p_vdec->p_context->height,
p_ff_pic->qscale_table, p_ff_pic->qstride,
p_vdec->pp_mode, p_vdec->pp_context,
p_ff_pic->pict_type );
}
else
{
#endif
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{
p_src = p_ff_pic->data[i_plane];
......@@ -694,6 +734,9 @@ static void ffmpeg_CopyPicture( picture_t *p_pic,
p_dst += i_dst_stride;
}
}
#ifdef LIBAVCODEC_PP
}
#endif
}
else
{
......@@ -703,7 +746,6 @@ static void ffmpeg_CopyPicture( picture_t *p_pic,
AVPicture dest_pic;
int i;
#if LIBAVCODEC_BUILD >= 4615
case( PIX_FMT_YUV410P ):
case( PIX_FMT_YUV411P ):
for( i = 0; i < p_pic->i_planes; i++ )
......@@ -717,7 +759,6 @@ static void ffmpeg_CopyPicture( picture_t *p_pic,
p_vdec->p_context->width,
p_vdec->p_context->height );
break;
#endif
default:
msg_Err( p_vdec->p_fifo, "don't know how to convert chroma %i",
p_vdec->p_context->pix_fmt );
......@@ -727,38 +768,10 @@ static void ffmpeg_CopyPicture( picture_t *p_pic,
}
}
/*****************************************************************************
* ffmpeg_PostProcPicture: Postprocessing is done here.
*****************************************************************************/
static void ffmpeg_PostProcPicture( vdec_thread_t *p_vdec, picture_t *p_pic )
{
if( ( p_vdec->i_pp_mode )&&
( ( p_vdec->p_vout->render.i_chroma ==
VLC_FOURCC( 'I','4','2','0' ) )||
( p_vdec->p_vout->render.i_chroma ==
VLC_FOURCC( 'Y','V','1','2' ) ) ) )
{
#if LIBAVCODEC_BUILD >= 4641
/* Make postproc */
p_vdec->p_pp->pf_postprocess( p_pic,
p_vdec->p_ff_pic->qscale_table,
p_vdec->p_ff_pic->qstride,
p_vdec->i_pp_mode );
#elif LIBAVCODEC_BUILD >= 4633
p_vdec->p_pp->pf_postprocess( p_pic,
p_vdec->p_context->display_qscale_table,
p_vdec->p_context->qstride,
p_vdec->i_pp_mode );
#endif
}
}
#if LIBAVCODEC_BUILD >= 4641
/*****************************************************************************
* ffmpeg_GetFrameBuf: callback used by ffmpeg to get a frame buffer.
* (used for direct rendering)
*****************************************************************************/
static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
AVFrame *p_ff_pic )
{
......@@ -787,9 +800,7 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
p_vdec->p_context->draw_horiz_band= NULL;
p_ff_pic->opaque = (void*)p_pic;
#if LIBAVCODEC_BUILD >= 4645
p_ff_pic->type = FF_BUFFER_TYPE_USER;
#endif
p_ff_pic->data[0] = p_pic->p[0].p_pixels;
p_ff_pic->data[1] = p_pic->p[1].p_pixels;
p_ff_pic->data[2] = p_pic->p[2].p_pixels;
......@@ -827,4 +838,3 @@ static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context,
vout_UnlinkPicture( p_vdec->p_vout, p_pic );
}
#endif
......@@ -2,7 +2,7 @@
* video.h: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: video.h,v 1.6 2002/12/10 10:22:04 fenrir Exp $
* $Id: video.h,v 1.7 2003/04/17 10:58:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -20,25 +20,24 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#if LIBAVCODEC_BUILD >= 4641 && LIBAVCODEC_BUILD < 4645
# define AVFrame AVVideoFrame
#endif
typedef struct vdec_thread_s
{
DECODER_THREAD_COMMON
#if LIBAVCODEC_BUILD >= 4641
AVFrame *p_ff_pic;
#else
AVPicture ff_pic, *p_ff_pic;
#endif
BITMAPINFOHEADER *p_format;
vout_thread_t *p_vout;
/* for post processing */
u32 i_pp_mode; /* valid only with I420 and YV12 */
#ifdef LIBAVCODEC_PP
pp_context_t *pp_context;
pp_mode_t *pp_mode;
#else
uint32_t i_pp_mode; /* valid only with I420 and YV12 */
postprocessing_t *p_pp;
#endif
/* for frame skipping algo */
int b_hurry_up;
......
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