Commit 8c7506a0 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Don't use deprecated functions if libswscaler is present.

  - Note that these are not all replaced atm, so some functionality might be lacking
* Make the minimum version of libavcodec version 5000 (september 2005).
  - Removed all the checks for previous API versions.
parent 147753f6
...@@ -58,7 +58,7 @@ struct decoder_sys_t ...@@ -58,7 +58,7 @@ struct decoder_sys_t
/* Common part between video and audio decoder */ /* Common part between video and audio decoder */
int i_cat; int i_cat;
int i_codec_id; int i_codec_id;
char *psz_namecodec; const char *psz_namecodec;
AVCodecContext *p_context; AVCodecContext *p_context;
AVCodec *p_codec; AVCodec *p_codec;
...@@ -84,7 +84,7 @@ struct decoder_sys_t ...@@ -84,7 +84,7 @@ struct decoder_sys_t
* The ffmpeg codec will be opened, some memory allocated. * The ffmpeg codec will be opened, some memory allocated.
*****************************************************************************/ *****************************************************************************/
int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context, int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
AVCodec *p_codec, int i_codec_id, char *psz_namecodec ) AVCodec *p_codec, int i_codec_id, const char *psz_namecodec )
{ {
decoder_sys_t *p_sys; decoder_sys_t *p_sys;
vlc_value_t lockval; vlc_value_t lockval;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "ffmpeg.h" #include "ffmpeg.h"
#if !defined(HAVE_FFMPEG_SWSCALE_H) && !defined(HAVE_LIBSWSCALE_TREE)
void E_(InitLibavcodec) ( vlc_object_t *p_object ); void E_(InitLibavcodec) ( vlc_object_t *p_object );
static void ChromaConversion( vout_thread_t *, picture_t *, picture_t * ); static void ChromaConversion( vout_thread_t *, picture_t *, picture_t * );
...@@ -188,3 +189,4 @@ void E_(CloseChroma)( vlc_object_t *p_this ) ...@@ -188,3 +189,4 @@ void E_(CloseChroma)( vlc_object_t *p_this )
} }
free( p_vout->chroma.p_sys ); free( p_vout->chroma.p_sys );
} }
#endif /* !defined(HAVE_FFMPEG_SWSCALE_H) && !defined(HAVE_LIBSWSCALE_TREE) */
\ No newline at end of file
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
//#define AVFORMAT_DEBUG 1 //#define AVFORMAT_DEBUG 1
/* Version checking */ /* Version checking */
#if (LIBAVFORMAT_BUILD >= 4629) && (defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE)) #if defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE)
/***************************************************************************** /*****************************************************************************
* demux_sys_t: demux descriptor * demux_sys_t: demux descriptor
...@@ -486,7 +486,7 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence ) ...@@ -486,7 +486,7 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence )
return stream_Tell( p_demux->s ); return stream_Tell( p_demux->s );
} }
#else /* LIBAVFORMAT_BUILD >= 4611 */ #else /* HAVE_FFMPEG_AVFORMAT_H */
int E_(OpenDemux)( vlc_object_t *p_this ) int E_(OpenDemux)( vlc_object_t *p_this )
{ {
...@@ -497,4 +497,4 @@ void E_(CloseDemux)( vlc_object_t *p_this ) ...@@ -497,4 +497,4 @@ void E_(CloseDemux)( vlc_object_t *p_this )
{ {
} }
#endif /* LIBAVFORMAT_BUILD >= 4629 */ #endif /* HAVE_FFMPEG_AVFORMAT_H */
...@@ -43,13 +43,6 @@ ...@@ -43,13 +43,6 @@
# include <avcodec.h> # include <avcodec.h>
#endif #endif
#if LIBAVCODEC_BUILD < 4704
# define AV_NOPTS_VALUE (int64_t)0
#endif
#if LIBAVCODEC_BUILD < 4684
# define FF_QP2LAMBDA 118
#endif
#include "ffmpeg.h" #include "ffmpeg.h"
#define HURRY_UP_GUARD1 (450000) #define HURRY_UP_GUARD1 (450000)
...@@ -76,7 +69,6 @@ static int FfmpegExecute( AVCodecContext *s, ...@@ -76,7 +69,6 @@ static int FfmpegExecute( AVCodecContext *s,
/***************************************************************************** /*****************************************************************************
* thread_context_t : for multithreaded encoding * thread_context_t : for multithreaded encoding
*****************************************************************************/ *****************************************************************************/
#if LIBAVCODEC_BUILD >= 4702
struct thread_context_t struct thread_context_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
...@@ -90,7 +82,6 @@ struct thread_context_t ...@@ -90,7 +82,6 @@ struct thread_context_t
vlc_cond_t cond; vlc_cond_t cond;
vlc_bool_t b_work, b_done; vlc_bool_t b_work, b_done;
}; };
#endif
/***************************************************************************** /*****************************************************************************
* encoder_sys_t : ffmpeg encoder descriptor * encoder_sys_t : ffmpeg encoder descriptor
...@@ -202,7 +193,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -202,7 +193,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
AVCodecContext *p_context; AVCodecContext *p_context;
AVCodec *p_codec; AVCodec *p_codec;
int i_codec_id, i_cat; int i_codec_id, i_cat;
char *psz_namecodec; const char *psz_namecodec;
vlc_value_t val; vlc_value_t val;
vlc_value_t lockval; vlc_value_t lockval;
...@@ -393,13 +384,8 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -393,13 +384,8 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
&& (p_context->width > 720 || p_context->height > 576) ) && (p_context->width > 720 || p_context->height > 576) )
p_context->level = 4; /* High level */ p_context->level = 4; /* High level */
#if LIBAVCODEC_BUILD >= 4754
p_context->time_base.num = p_enc->fmt_in.video.i_frame_rate_base; p_context->time_base.num = p_enc->fmt_in.video.i_frame_rate_base;
p_context->time_base.den = p_enc->fmt_in.video.i_frame_rate; p_context->time_base.den = p_enc->fmt_in.video.i_frame_rate;
#else
p_context->frame_rate = p_enc->fmt_in.video.i_frame_rate;
p_context->frame_rate_base= p_enc->fmt_in.video.i_frame_rate_base;
#endif
/* Defaults from ffmpeg.c */ /* Defaults from ffmpeg.c */
p_context->qblur = 0.5; p_context->qblur = 0.5;
...@@ -412,9 +398,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -412,9 +398,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context->lumi_masking = p_sys->f_lumi_masking; p_context->lumi_masking = p_sys->f_lumi_masking;
p_context->dark_masking = p_sys->f_dark_masking; p_context->dark_masking = p_sys->f_dark_masking;
p_context->p_masking = p_sys->f_p_masking; p_context->p_masking = p_sys->f_p_masking;
#if LIBAVCODEC_BUILD >= 4741
p_context->border_masking = p_sys->f_border_masking; p_context->border_masking = p_sys->f_border_masking;
#endif
p_context->luma_elim_threshold = p_sys->i_luma_elim; p_context->luma_elim_threshold = p_sys->i_luma_elim;
p_context->chroma_elim_threshold = p_sys->i_chroma_elim; p_context->chroma_elim_threshold = p_sys->i_chroma_elim;
...@@ -426,7 +410,6 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -426,7 +410,6 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
if( !p_context->max_b_frames ) if( !p_context->max_b_frames )
p_context->flags |= CODEC_FLAG_LOW_DELAY; p_context->flags |= CODEC_FLAG_LOW_DELAY;
#if LIBAVCODEC_BUILD >= 4687
av_reduce( &i_aspect_num, &i_aspect_den, av_reduce( &i_aspect_num, &i_aspect_den,
p_enc->fmt_in.video.i_aspect, p_enc->fmt_in.video.i_aspect,
VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ ); VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
...@@ -434,16 +417,11 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -434,16 +417,11 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
&p_context->sample_aspect_ratio.den, &p_context->sample_aspect_ratio.den,
i_aspect_num * (int64_t)p_context->height, i_aspect_num * (int64_t)p_context->height,
i_aspect_den * (int64_t)p_context->width, 1 << 30 ); i_aspect_den * (int64_t)p_context->width, 1 << 30 );
#else
p_context->aspect_ratio = ((float)p_enc->fmt_in.video.i_aspect) /
VOUT_ASPECT_FACTOR;
#endif
p_sys->p_buffer_out = malloc( p_context->height * p_context->width * 3 ); 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_enc->fmt_in.i_codec = VLC_FOURCC('I','4','2','0');
p_context->pix_fmt = E_(GetFfmpegChroma)( p_enc->fmt_in.i_codec ); p_context->pix_fmt = E_(GetFfmpegChroma)( p_enc->fmt_in.i_codec );
#if LIBAVCODEC_BUILD >= 4714
if( p_codec->pix_fmts ) if( p_codec->pix_fmts )
{ {
const enum PixelFormat *p = p_codec->pix_fmts; const enum PixelFormat *p = p_codec->pix_fmts;
...@@ -454,9 +432,6 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -454,9 +432,6 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
if( *p == -1 ) p_context->pix_fmt = p_codec->pix_fmts[0]; if( *p == -1 ) p_context->pix_fmt = p_codec->pix_fmts[0];
p_enc->fmt_in.i_codec = E_(GetVlcChroma)( p_context->pix_fmt ); p_enc->fmt_in.i_codec = E_(GetVlcChroma)( p_context->pix_fmt );
} }
#else
p_enc->fmt_in.i_codec = E_(GetVlcChroma)( p_context->pix_fmt );
#endif
if ( p_sys->b_strict_rc ) if ( p_sys->b_strict_rc )
{ {
...@@ -471,9 +446,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -471,9 +446,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
if ( p_sys->f_i_quant_factor != 0.0 ) if ( p_sys->f_i_quant_factor != 0.0 )
p_context->i_quant_factor = p_sys->f_i_quant_factor; p_context->i_quant_factor = p_sys->f_i_quant_factor;
#if LIBAVCODEC_BUILD >= 4690
p_context->noise_reduction = p_sys->i_noise_reduction; p_context->noise_reduction = p_sys->i_noise_reduction;
#endif
if ( p_sys->b_mpeg4_matrix ) if ( p_sys->b_mpeg4_matrix )
{ {
...@@ -499,11 +472,9 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -499,11 +472,9 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
else else
{ {
p_context->flags |= CODEC_FLAG_INTERLACED_DCT; p_context->flags |= CODEC_FLAG_INTERLACED_DCT;
#if LIBAVCODEC_BUILD >= 4698
if ( p_sys->b_interlace_me ) if ( p_sys->b_interlace_me )
p_context->flags |= CODEC_FLAG_INTERLACED_ME; p_context->flags |= CODEC_FLAG_INTERLACED_ME;
} }
#endif
} }
if ( p_sys->b_trellis ) if ( p_sys->b_trellis )
...@@ -512,10 +483,8 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -512,10 +483,8 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
if ( p_sys->i_qmin > 0 && p_sys->i_qmin == p_sys->i_qmax ) if ( p_sys->i_qmin > 0 && p_sys->i_qmin == p_sys->i_qmax )
p_context->flags |= CODEC_FLAG_QSCALE; p_context->flags |= CODEC_FLAG_QSCALE;
#if LIBAVCODEC_BUILD >= 4702
if ( p_enc->i_threads >= 1 ) if ( p_enc->i_threads >= 1 )
p_context->thread_count = p_enc->i_threads; p_context->thread_count = p_enc->i_threads;
#endif
if( p_sys->i_vtolerance > 0 ) if( p_sys->i_vtolerance > 0 )
p_context->bit_rate_tolerance = p_sys->i_vtolerance; p_context->bit_rate_tolerance = p_sys->i_vtolerance;
...@@ -531,9 +500,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -531,9 +500,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
if( p_sys->i_quality ) if( p_sys->i_quality )
{ {
p_context->flags |= CODEC_FLAG_QSCALE; p_context->flags |= CODEC_FLAG_QSCALE;
#if LIBAVCODEC_BUILD >= 4668
p_context->global_quality = p_sys->i_quality; p_context->global_quality = p_sys->i_quality;
#endif
} }
} }
else if( p_enc->fmt_in.i_cat == AUDIO_ES ) else if( p_enc->fmt_in.i_cat == AUDIO_ES )
...@@ -661,7 +628,6 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -661,7 +628,6 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
/**************************************************************************** /****************************************************************************
* Ffmpeg threading system * Ffmpeg threading system
****************************************************************************/ ****************************************************************************/
#if LIBAVCODEC_BUILD >= 4702
static int FfmpegThread( struct thread_context_t *p_context ) static int FfmpegThread( struct thread_context_t *p_context )
{ {
while ( !p_context->b_die && !p_context->b_error ) while ( !p_context->b_die && !p_context->b_error )
...@@ -730,7 +696,6 @@ static int FfmpegExecute( AVCodecContext *s, ...@@ -730,7 +696,6 @@ static int FfmpegExecute( AVCodecContext *s,
return 0; return 0;
} }
#endif
/**************************************************************************** /****************************************************************************
* EncodeVideo: the whole thing * EncodeVideo: the whole thing
...@@ -741,7 +706,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -741,7 +706,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
AVFrame frame; AVFrame frame;
int i_out, i_plane; int i_out, i_plane;
#if LIBAVCODEC_BUILD >= 4702
if ( !p_sys->b_inited && p_enc->i_threads >= 1 ) if ( !p_sys->b_inited && p_enc->i_threads >= 1 )
{ {
struct thread_context_t ** pp_contexts; struct thread_context_t ** pp_contexts;
...@@ -771,7 +735,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -771,7 +735,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
p_sys->p_context->execute = FfmpegExecute; p_sys->p_context->execute = FfmpegExecute;
} }
#endif
memset( &frame, 0, sizeof( AVFrame ) ); memset( &frame, 0, sizeof( AVFrame ) );
for( i_plane = 0; i_plane < p_pict->i_planes; i_plane++ ) for( i_plane = 0; i_plane < p_pict->i_planes; i_plane++ )
...@@ -784,20 +747,13 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -784,20 +747,13 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
frame.pict_type = 0; frame.pict_type = 0;
frame.repeat_pict = p_pict->i_nb_fields - 2; frame.repeat_pict = p_pict->i_nb_fields - 2;
#if LIBAVCODEC_BUILD >= 4685
frame.interlaced_frame = !p_pict->b_progressive; frame.interlaced_frame = !p_pict->b_progressive;
frame.top_field_first = !!p_pict->b_top_field_first; frame.top_field_first = !!p_pict->b_top_field_first;
#endif
#if LIBAVCODEC_BUILD < 4702
/* Set the pts of the frame being encoded (segfaults with mpeg4!)*/ /* Set the pts of the frame being encoded (segfaults with mpeg4!)*/
if( p_enc->fmt_out.i_codec == VLC_FOURCC( 'm', 'p', 'g', 'v' ) || if( p_enc->fmt_out.i_codec == VLC_FOURCC( 'm', 'p', 'g', 'v' ) ||
p_enc->fmt_out.i_codec == VLC_FOURCC( 'm', 'p', '1', 'v' ) || p_enc->fmt_out.i_codec == VLC_FOURCC( 'm', 'p', '1', 'v' ) ||
p_enc->fmt_out.i_codec == VLC_FOURCC( 'm', 'p', '2', 'v' ) ) p_enc->fmt_out.i_codec == VLC_FOURCC( 'm', 'p', '2', 'v' ) )
#else
if( 1 )
#endif
{ {
frame.pts = p_pict->date ? p_pict->date : (signed int) AV_NOPTS_VALUE; frame.pts = p_pict->date ? p_pict->date : (signed int) AV_NOPTS_VALUE;
...@@ -818,20 +774,17 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -818,20 +774,17 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
if ( current_date + HURRY_UP_GUARD2 > frame.pts ) if ( current_date + HURRY_UP_GUARD2 > frame.pts )
{ {
p_sys->p_context->flags &= ~CODEC_FLAG_TRELLIS_QUANT; p_sys->p_context->flags &= ~CODEC_FLAG_TRELLIS_QUANT;
#if LIBAVCODEC_BUILD >= 4690
p_sys->p_context->noise_reduction = p_sys->i_noise_reduction p_sys->p_context->noise_reduction = p_sys->i_noise_reduction
+ (HURRY_UP_GUARD2 + current_date - frame.pts) / 500; + (HURRY_UP_GUARD2 + current_date - frame.pts) / 500;
#endif
msg_Dbg( p_enc, "hurry up mode 2" ); msg_Dbg( p_enc, "hurry up mode 2" );
} }
else else
{ {
if ( p_sys->b_trellis ) if ( p_sys->b_trellis )
p_sys->p_context->flags |= CODEC_FLAG_TRELLIS_QUANT; p_sys->p_context->flags |= CODEC_FLAG_TRELLIS_QUANT;
#if LIBAVCODEC_BUILD >= 4690
p_sys->p_context->noise_reduction = p_sys->p_context->noise_reduction =
p_sys->i_noise_reduction; p_sys->i_noise_reduction;
#endif
} }
} }
...@@ -871,14 +824,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -871,14 +824,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
frame.quality = p_sys->i_quality; frame.quality = p_sys->i_quality;
/* Ugly work-around for stupid libavcodec behaviour */ /* Ugly work-around for stupid libavcodec behaviour */
#if LIBAVCODEC_BUILD >= 4722
p_sys->i_framenum++; p_sys->i_framenum++;
p_sys->pi_delay_pts[p_sys->i_framenum % MAX_FRAME_DELAY] = frame.pts; p_sys->pi_delay_pts[p_sys->i_framenum % MAX_FRAME_DELAY] = frame.pts;
frame.pts = p_sys->i_framenum * AV_TIME_BASE * frame.pts = p_sys->i_framenum * AV_TIME_BASE *
p_enc->fmt_in.video.i_frame_rate_base; p_enc->fmt_in.video.i_frame_rate_base;
frame.pts += p_enc->fmt_in.video.i_frame_rate - 1; frame.pts += p_enc->fmt_in.video.i_frame_rate - 1;
frame.pts /= p_enc->fmt_in.video.i_frame_rate; frame.pts /= p_enc->fmt_in.video.i_frame_rate;
#endif
/* End work-around */ /* End work-around */
i_out = avcodec_encode_video( p_sys->p_context, (uint8_t*)p_sys->p_buffer_out, i_out = avcodec_encode_video( p_sys->p_context, (uint8_t*)p_sys->p_buffer_out,
...@@ -907,7 +858,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -907,7 +858,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
p_block->i_pts = p_sys->p_context->coded_frame->pts; p_block->i_pts = p_sys->p_context->coded_frame->pts;
/* Ugly work-around for stupid libavcodec behaviour */ /* Ugly work-around for stupid libavcodec behaviour */
#if LIBAVCODEC_BUILD >= 4722
{ {
int64_t i_framenum = p_block->i_pts * int64_t i_framenum = p_block->i_pts *
p_enc->fmt_in.video.i_frame_rate / p_enc->fmt_in.video.i_frame_rate /
...@@ -915,7 +865,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -915,7 +865,6 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
p_block->i_pts = p_sys->pi_delay_pts[i_framenum % MAX_FRAME_DELAY]; p_block->i_pts = p_sys->pi_delay_pts[i_framenum % MAX_FRAME_DELAY];
} }
#endif
/* End work-around */ /* End work-around */
if( p_sys->p_context->coded_frame->pict_type != FF_I_TYPE && if( p_sys->p_context->coded_frame->pict_type != FF_I_TYPE &&
...@@ -1056,7 +1005,6 @@ void E_(CloseEncoder)( vlc_object_t *p_this ) ...@@ -1056,7 +1005,6 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
var_Get( p_enc->p_libvlc_global, "avcodec", &lockval ); var_Get( p_enc->p_libvlc_global, "avcodec", &lockval );
#if LIBAVCODEC_BUILD >= 4702
if ( p_sys->b_inited && p_enc->i_threads >= 1 ) if ( p_sys->b_inited && p_enc->i_threads >= 1 )
{ {
int i; int i;
...@@ -1074,7 +1022,6 @@ void E_(CloseEncoder)( vlc_object_t *p_this ) ...@@ -1074,7 +1022,6 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
free( pp_contexts ); free( pp_contexts );
} }
#endif
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
avcodec_close( p_sys->p_context ); avcodec_close( p_sys->p_context );
......
...@@ -36,18 +36,16 @@ ...@@ -36,18 +36,16 @@
# include <avcodec.h> # include <avcodec.h>
#endif #endif
#if LIBAVCODEC_BUILD < 4680 #if LIBAVCODEC_BUILD < 5000
# error You must have a libavcodec >= 4680 (get CVS) # error You must have a libavcodec >= 5000 (get CVS)
#endif #endif
#include "ffmpeg.h" #include "ffmpeg.h"
#ifdef LIBAVCODEC_PP #ifdef HAVE_POSTPROC_POSTPROCESS_H
# ifdef HAVE_POSTPROC_POSTPROCESS_H
# include <postproc/postprocess.h> # include <postproc/postprocess.h>
# else #else
# include <libpostproc/postprocess.h> # include <libpostproc/postprocess.h>
# endif
#endif #endif
/***************************************************************************** /*****************************************************************************
...@@ -71,14 +69,14 @@ static int OpenDecoder( vlc_object_t * ); ...@@ -71,14 +69,14 @@ static int OpenDecoder( vlc_object_t * );
static void CloseDecoder( vlc_object_t * ); static void CloseDecoder( vlc_object_t * );
static int nloopf_list[] = { 0, 1, 2, 3, 4 }; static int nloopf_list[] = { 0, 1, 2, 3, 4 };
static char *nloopf_list_text[] = static const char *nloopf_list_text[] =
{ N_("None"), N_("Non-ref"), N_("Bidir"), N_("Non-key"), N_("All") }; { N_("None"), N_("Non-ref"), N_("Bidir"), N_("Non-key"), N_("All") };
static char *enc_hq_list[] = { "rd", "bits", "simple" }; static const char *enc_hq_list[] = { "rd", "bits", "simple" };
static char *enc_hq_list_text[] = { N_("rd"), N_("bits"), N_("simple") }; static const char *enc_hq_list_text[] = { N_("rd"), N_("bits"), N_("simple") };
static int pi_mode_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 }; static int pi_mode_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
static char *ppsz_mode_descriptions[] = static const char *ppsz_mode_descriptions[] =
{ N_("Fast bilinear"), N_("Bilinear"), N_("Bicubic (good quality)"), { N_("Fast bilinear"), N_("Bilinear"), N_("Bicubic (good quality)"),
N_("Experimental"), N_("Nearest neighbour (bad quality)"), N_("Experimental"), N_("Nearest neighbour (bad quality)"),
N_("Area"), N_("Luma bicubic / chroma bilinear"), N_("Gauss"), N_("Area"), N_("Luma bicubic / chroma bilinear"), N_("Gauss"),
...@@ -120,20 +118,12 @@ vlc_module_begin(); ...@@ -120,20 +118,12 @@ vlc_module_begin();
SKIPLOOPF_LONGTEXT, VLC_TRUE ); SKIPLOOPF_LONGTEXT, VLC_TRUE );
change_integer_list( nloopf_list, nloopf_list_text, 0 ); change_integer_list( nloopf_list, nloopf_list_text, 0 );
#ifdef LIBAVCODEC_PP
add_integer( "ffmpeg-pp-q", 0, NULL, PP_Q_TEXT, PP_Q_LONGTEXT, VLC_FALSE ); add_integer( "ffmpeg-pp-q", 0, NULL, PP_Q_TEXT, PP_Q_LONGTEXT, VLC_FALSE );
add_string( "ffmpeg-pp-name", "default", NULL, LIBAVCODEC_PP_TEXT, add_string( "ffmpeg-pp-name", "default", NULL, LIBAVCODEC_PP_TEXT,
LIBAVCODEC_PP_LONGTEXT, VLC_TRUE ); LIBAVCODEC_PP_LONGTEXT, VLC_TRUE );
#endif
add_integer( "ffmpeg-debug", 0, NULL, DEBUG_TEXT, DEBUG_LONGTEXT, add_integer( "ffmpeg-debug", 0, NULL, DEBUG_TEXT, DEBUG_LONGTEXT,
VLC_TRUE ); VLC_TRUE );
/* chroma conversion submodule */
add_submodule();
set_capability( "chroma", 50 );
set_callbacks( E_(OpenChroma), E_(CloseChroma) );
set_description( _("FFmpeg chroma conversion") );
/* encoder submodule */ /* encoder submodule */
add_submodule(); add_submodule();
set_section( N_("Encoding") , NULL ); set_section( N_("Encoding") , NULL );
...@@ -205,6 +195,26 @@ vlc_module_begin(); ...@@ -205,6 +195,26 @@ vlc_module_begin();
set_capability( "sout mux", 2 ); set_capability( "sout mux", 2 );
set_callbacks( E_(OpenMux), E_(CloseMux) ); set_callbacks( E_(OpenMux), E_(CloseMux) );
#if defined(HAVE_FFMPEG_SWSCALE_H) || defined(HAVE_LIBSWSCALE_TREE)
/* video filter submodule */
add_submodule();
set_description( _("Video scaling filter") );
set_capability( "video filter2", 1000 );
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VFILTER );
set_callbacks( E_(OpenScaler), E_(CloseScaler) );
add_integer( "swscale-mode", 0, NULL, SCALEMODE_TEXT, SCALEMODE_LONGTEXT, VLC_TRUE );
change_integer_list( pi_mode_values, ppsz_mode_descriptions, 0 );
var_Create( p_module->p_libvlc_global, "avcodec", VLC_VAR_MUTEX );
#else
/* chroma conversion submodule */
add_submodule();
set_capability( "chroma", 50 );
set_callbacks( E_(OpenChroma), E_(CloseChroma) );
set_description( _("FFmpeg chroma conversion") );
/* video filter submodule */ /* video filter submodule */
add_submodule(); add_submodule();
set_capability( "video filter2", 50 ); set_capability( "video filter2", 50 );
...@@ -223,18 +233,8 @@ vlc_module_begin(); ...@@ -223,18 +233,8 @@ vlc_module_begin();
set_callbacks( E_(OpenDeinterlace), E_(CloseDeinterlace) ); set_callbacks( E_(OpenDeinterlace), E_(CloseDeinterlace) );
set_description( _("FFmpeg deinterlace video filter") ); set_description( _("FFmpeg deinterlace video filter") );
add_shortcut( "ffmpeg-deinterlace" ); add_shortcut( "ffmpeg-deinterlace" );
#endif
/* video filter submodule */
add_submodule();
set_description( _("Video scaling filter") );
set_capability( "video filter2", 1000 );
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VFILTER );
set_callbacks( E_(OpenScaler), E_(CloseScaler) );
add_integer( "swscale-mode", 0, NULL, SCALEMODE_TEXT, SCALEMODE_LONGTEXT, VLC_TRUE );
change_integer_list( pi_mode_values, ppsz_mode_descriptions, 0 );
var_Create( p_module->p_libvlc_global, "avcodec", VLC_VAR_MUTEX );
vlc_module_end(); vlc_module_end();
/***************************************************************************** /*****************************************************************************
...@@ -244,7 +244,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -244,7 +244,7 @@ static int OpenDecoder( vlc_object_t *p_this )
{ {
decoder_t *p_dec = (decoder_t*) p_this; decoder_t *p_dec = (decoder_t*) p_this;
int i_cat, i_codec_id, i_result; int i_cat, i_codec_id, i_result;
char *psz_namecodec; const char *psz_namecodec;
AVCodecContext *p_context = NULL; AVCodecContext *p_context = NULL;
AVCodec *p_codec = NULL; AVCodec *p_codec = NULL;
...@@ -437,7 +437,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object ) ...@@ -437,7 +437,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object )
b_ffmpeginit = 1; b_ffmpeginit = 1;
msg_Dbg( p_object, "libavcodec initialized (interface %d )", msg_Dbg( p_object, "libavcodec initialized (interface %d )",
LIBAVCODEC_BUILD ); LIBAVCODEC_VERSION_INT );
} }
else else
{ {
...@@ -518,7 +518,7 @@ static struct ...@@ -518,7 +518,7 @@ static struct
vlc_fourcc_t i_fourcc; vlc_fourcc_t i_fourcc;
int i_codec; int i_codec;
int i_cat; int i_cat;
char *psz_name; const char *psz_name;
} codecs_table[] = } codecs_table[] =
{ {
...@@ -693,15 +693,11 @@ static struct ...@@ -693,15 +693,11 @@ static struct
{ VLC_FOURCC('F','L','V','1'), CODEC_ID_FLV1, { VLC_FOURCC('F','L','V','1'), CODEC_ID_FLV1,
VIDEO_ES, "Flash Video" }, VIDEO_ES, "Flash Video" },
#if LIBAVCODEC_BUILD > 4716
{ VLC_FOURCC('H','2','6','1'), CODEC_ID_H261, { VLC_FOURCC('H','2','6','1'), CODEC_ID_H261,
VIDEO_ES, "H.261" }, VIDEO_ES, "H.261" },
#endif
#if LIBAVCODEC_BUILD > 4680
{ VLC_FOURCC('F','L','I','C'), CODEC_ID_FLIC, { VLC_FOURCC('F','L','I','C'), CODEC_ID_FLIC,
VIDEO_ES, "Flic Video" }, VIDEO_ES, "Flic Video" },
#endif
/* MJPEG */ /* MJPEG */
{ VLC_FOURCC( 'M', 'J', 'P', 'G' ), CODEC_ID_MJPEG, { VLC_FOURCC( 'M', 'J', 'P', 'G' ), CODEC_ID_MJPEG,
...@@ -718,14 +714,10 @@ static struct ...@@ -718,14 +714,10 @@ static struct
VIDEO_ES, "Motion JPEG Video" }, VIDEO_ES, "Motion JPEG Video" },
{ VLC_FOURCC( 'J', 'P', 'G', 'L' ), CODEC_ID_MJPEG, { VLC_FOURCC( 'J', 'P', 'G', 'L' ), CODEC_ID_MJPEG,
VIDEO_ES, "Motion JPEG Video" }, VIDEO_ES, "Motion JPEG Video" },
{ VLC_FOURCC( 'm', 'j', 'p', 'b' ), CODEC_ID_MJPEGB, /* for mov file */ { VLC_FOURCC( 'm', 'j', 'p', 'b' ), CODEC_ID_MJPEGB, /* for mov file */
VIDEO_ES, "Motion JPEG B Video" }, VIDEO_ES, "Motion JPEG B Video" },
#if LIBAVCODEC_BUILD > 4680
{ VLC_FOURCC( 'S', 'P', '5', 'X' ), CODEC_ID_SP5X, { VLC_FOURCC( 'S', 'P', '5', 'X' ), CODEC_ID_SP5X,
VIDEO_ES, "Sunplus Motion JPEG Video" }, VIDEO_ES, "Sunplus Motion JPEG Video" },
#endif
/* DV */ /* DV */
{ VLC_FOURCC('d','v','s','l'), CODEC_ID_DVVIDEO, { VLC_FOURCC('d','v','s','l'), CODEC_ID_DVVIDEO,
...@@ -752,7 +744,7 @@ static struct ...@@ -752,7 +744,7 @@ static struct
VIDEO_ES, "Windows Media Video 1" }, VIDEO_ES, "Windows Media Video 1" },
{ VLC_FOURCC('W','M','V','2'), CODEC_ID_WMV2, { VLC_FOURCC('W','M','V','2'), CODEC_ID_WMV2,
VIDEO_ES, "Windows Media Video 2" }, VIDEO_ES, "Windows Media Video 2" },
#if LIBAVCODEC_BUILD >= ((51<<16)+(10<<8)+1) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(10<<8)+1)
{ VLC_FOURCC('W','M','V','3'), CODEC_ID_WMV3, { VLC_FOURCC('W','M','V','3'), CODEC_ID_WMV3,
VIDEO_ES, "Windows Media Video 3" }, VIDEO_ES, "Windows Media Video 3" },
{ VLC_FOURCC('W','V','C','1'), CODEC_ID_VC1, { VLC_FOURCC('W','V','C','1'), CODEC_ID_VC1,
...@@ -765,7 +757,6 @@ static struct ...@@ -765,7 +757,6 @@ static struct
VIDEO_ES, "Windows Media Video Advanced Profile" }, VIDEO_ES, "Windows Media Video Advanced Profile" },
#endif #endif
#if LIBAVCODEC_BUILD >= 4683
/* Microsoft Video 1 */ /* Microsoft Video 1 */
{ VLC_FOURCC('M','S','V','C'), CODEC_ID_MSVIDEO1, { VLC_FOURCC('M','S','V','C'), CODEC_ID_MSVIDEO1,
VIDEO_ES, "Microsoft Video 1" }, VIDEO_ES, "Microsoft Video 1" },
...@@ -785,7 +776,6 @@ static struct ...@@ -785,7 +776,6 @@ static struct
VIDEO_ES, "Microsoft RLE Video" }, VIDEO_ES, "Microsoft RLE Video" },
{ VLC_FOURCC(0x1,0x0,0x0,0x0), CODEC_ID_MSRLE, { VLC_FOURCC(0x1,0x0,0x0,0x0), CODEC_ID_MSRLE,
VIDEO_ES, "Microsoft RLE Video" }, VIDEO_ES, "Microsoft RLE Video" },
#endif
/* Indeo Video Codecs (Quality of this decoder on ppc is not good) */ /* Indeo Video Codecs (Quality of this decoder on ppc is not good) */
{ VLC_FOURCC('I','V','3','1'), CODEC_ID_INDEO3, { VLC_FOURCC('I','V','3','1'), CODEC_ID_INDEO3,
...@@ -797,10 +787,8 @@ static struct ...@@ -797,10 +787,8 @@ static struct
{ VLC_FOURCC('i','v','3','2'), CODEC_ID_INDEO3, { VLC_FOURCC('i','v','3','2'), CODEC_ID_INDEO3,
VIDEO_ES, "Indeo Video v3" }, VIDEO_ES, "Indeo Video v3" },
#if LIBAVCODEC_BUILD >= 4721
{ VLC_FOURCC('t','s','c','c'), CODEC_ID_TSCC, { VLC_FOURCC('t','s','c','c'), CODEC_ID_TSCC,
VIDEO_ES, "TechSmith Camtasia Screen Capture Video" }, VIDEO_ES, "TechSmith Camtasia Screen Capture Video" },
#endif
/* Huff YUV */ /* Huff YUV */
{ VLC_FOURCC('H','F','Y','U'), CODEC_ID_HUFFYUV, { VLC_FOURCC('H','F','Y','U'), CODEC_ID_HUFFYUV,
...@@ -820,7 +808,7 @@ static struct ...@@ -820,7 +808,7 @@ static struct
{ VLC_FOURCC('v','p','3','1'), CODEC_ID_VP3, { VLC_FOURCC('v','p','3','1'), CODEC_ID_VP3,
VIDEO_ES, "On2's VP3 Video" }, VIDEO_ES, "On2's VP3 Video" },
#if LIBAVCODEC_BUILD >= ((51<<16)+(14<<8)+0) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(14<<8)+0)
{ VLC_FOURCC('V','P','5',' '), CODEC_ID_VP5, { VLC_FOURCC('V','P','5',' '), CODEC_ID_VP5,
VIDEO_ES, "On2's VP5 Video" }, VIDEO_ES, "On2's VP5 Video" },
{ VLC_FOURCC('V','P','5','0'), CODEC_ID_VP5, { VLC_FOURCC('V','P','5','0'), CODEC_ID_VP5,
...@@ -833,11 +821,9 @@ static struct ...@@ -833,11 +821,9 @@ static struct
VIDEO_ES, "On2's VP6.2 Video (Flash)" }, VIDEO_ES, "On2's VP6.2 Video (Flash)" },
#endif #endif
#if LIBAVCODEC_BUILD >= 4685
/* Xiph.org theora */ /* Xiph.org theora */
{ VLC_FOURCC('t','h','e','o'), CODEC_ID_THEORA, { VLC_FOURCC('t','h','e','o'), CODEC_ID_THEORA,
VIDEO_ES, "Xiph.org's Theora Video" }, VIDEO_ES, "Xiph.org's Theora Video" },
#endif
#if ( !defined( WORDS_BIGENDIAN ) ) #if ( !defined( WORDS_BIGENDIAN ) )
/* Asus Video (Another thing that doesn't work on PPC) */ /* Asus Video (Another thing that doesn't work on PPC) */
...@@ -864,12 +850,11 @@ static struct ...@@ -864,12 +850,11 @@ static struct
VIDEO_ES, "Real Video 10" }, VIDEO_ES, "Real Video 10" },
{ VLC_FOURCC('R','V','1','3'), CODEC_ID_RV10, { VLC_FOURCC('R','V','1','3'), CODEC_ID_RV10,
VIDEO_ES, "Real Video 13" }, VIDEO_ES, "Real Video 13" },
#if LIBAVCODEC_BUILD >= ((51<<16)+(15<<8)+1) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(15<<8)+1)
{ VLC_FOURCC('R','V','2','0'), CODEC_ID_RV20, { VLC_FOURCC('R','V','2','0'), CODEC_ID_RV20,
VIDEO_ES, "Real Video 20" }, VIDEO_ES, "Real Video 20" },
#endif #endif
#if LIBAVCODEC_BUILD >= 4684
/* Apple Video */ /* Apple Video */
{ VLC_FOURCC('r','p','z','a'), CODEC_ID_RPZA, { VLC_FOURCC('r','p','z','a'), CODEC_ID_RPZA,
VIDEO_ES, "Apple Video" }, VIDEO_ES, "Apple Video" },
...@@ -884,17 +869,14 @@ static struct ...@@ -884,17 +869,14 @@ static struct
/* Id Quake II CIN */ /* Id Quake II CIN */
{ VLC_FOURCC('I','D','C','I'), CODEC_ID_IDCIN, { VLC_FOURCC('I','D','C','I'), CODEC_ID_IDCIN,
VIDEO_ES, "Id Quake II CIN Video" }, VIDEO_ES, "Id Quake II CIN Video" },
#endif
/* 4X Technologies */ /* 4X Technologies */
{ VLC_FOURCC('4','x','m','v'), CODEC_ID_4XM, { VLC_FOURCC('4','x','m','v'), CODEC_ID_4XM,
VIDEO_ES, "4X Technologies Video" }, VIDEO_ES, "4X Technologies Video" },
#if LIBAVCODEC_BUILD >= 4694
/* Duck TrueMotion */ /* Duck TrueMotion */
{ VLC_FOURCC('D','U','C','K'), CODEC_ID_TRUEMOTION1, { VLC_FOURCC('D','U','C','K'), CODEC_ID_TRUEMOTION1,
VIDEO_ES, "Duck TrueMotion v1 Video" }, VIDEO_ES, "Duck TrueMotion v1 Video" },
#endif
/* Interplay MVE */ /* Interplay MVE */
{ VLC_FOURCC('i','m','v','e'), CODEC_ID_INTERPLAY_VIDEO, { VLC_FOURCC('i','m','v','e'), CODEC_ID_INTERPLAY_VIDEO,
...@@ -908,19 +890,14 @@ static struct ...@@ -908,19 +890,14 @@ static struct
{ VLC_FOURCC('M','D','E','C'), CODEC_ID_MDEC, { VLC_FOURCC('M','D','E','C'), CODEC_ID_MDEC,
VIDEO_ES, "PSX MDEC Video" }, VIDEO_ES, "PSX MDEC Video" },
#if LIBAVCODEC_BUILD >= 4699
/* Sierra VMD */ /* Sierra VMD */
{ VLC_FOURCC('v','m','d','v'), CODEC_ID_VMDVIDEO, { VLC_FOURCC('v','m','d','v'), CODEC_ID_VMDVIDEO,
VIDEO_ES, "Sierra VMD Video" }, VIDEO_ES, "Sierra VMD Video" },
#endif
#if LIBAVCODEC_BUILD >= 4719
/* FFMPEG's SNOW wavelet codec */ /* FFMPEG's SNOW wavelet codec */
{ VLC_FOURCC('S','N','O','W'), CODEC_ID_SNOW, { VLC_FOURCC('S','N','O','W'), CODEC_ID_SNOW,
VIDEO_ES, "FFMpeg SNOW wavelet Video" }, VIDEO_ES, "FFMpeg SNOW wavelet Video" },
#endif
#if LIBAVCODEC_BUILD >= 4752
{ VLC_FOURCC('r','l','e',' '), CODEC_ID_QTRLE, { VLC_FOURCC('r','l','e',' '), CODEC_ID_QTRLE,
VIDEO_ES, "Apple QuickTime RLE Video" }, VIDEO_ES, "Apple QuickTime RLE Video" },
...@@ -948,15 +925,13 @@ static struct ...@@ -948,15 +925,13 @@ static struct
{ VLC_FOURCC('A','A','S','C'), CODEC_ID_AASC, { VLC_FOURCC('A','A','S','C'), CODEC_ID_AASC,
VIDEO_ES, "Autodesc RLE Video" }, VIDEO_ES, "Autodesc RLE Video" },
#endif
#if LIBAVCODEC_BUILD >= 4753
{ VLC_FOURCC('I','V','2','0'), CODEC_ID_INDEO2, { VLC_FOURCC('I','V','2','0'), CODEC_ID_INDEO2,
VIDEO_ES, "Indeo Video v2" }, VIDEO_ES, "Indeo Video v2" },
{ VLC_FOURCC('R','T','2','1'), CODEC_ID_INDEO2, { VLC_FOURCC('R','T','2','1'), CODEC_ID_INDEO2,
VIDEO_ES, "Indeo Video v2" }, VIDEO_ES, "Indeo Video v2" },
#endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(13<<8)+0) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(13<<8)+0)
{ VLC_FOURCC('V','M','n','c'), CODEC_ID_VMNC, { VLC_FOURCC('V','M','n','c'), CODEC_ID_VMNC,
VIDEO_ES, "VMware Video" }, VIDEO_ES, "VMware Video" },
#endif #endif
...@@ -965,8 +940,6 @@ static struct ...@@ -965,8 +940,6 @@ static struct
/* /*
* Image codecs * Image codecs
*/ */
#if LIBAVCODEC_BUILD >= 4731
{ VLC_FOURCC('p','n','g',' '), CODEC_ID_PNG, { VLC_FOURCC('p','n','g',' '), CODEC_ID_PNG,
VIDEO_ES, "PNG Image" }, VIDEO_ES, "PNG Image" },
{ VLC_FOURCC('p','p','m',' '), CODEC_ID_PPM, { VLC_FOURCC('p','p','m',' '), CODEC_ID_PPM,
...@@ -977,14 +950,13 @@ static struct ...@@ -977,14 +950,13 @@ static struct
VIDEO_ES, "PGM YUV Image" }, VIDEO_ES, "PGM YUV Image" },
{ VLC_FOURCC('p','a','m',' '), CODEC_ID_PAM, { VLC_FOURCC('p','a','m',' '), CODEC_ID_PAM,
VIDEO_ES, "PAM Image" }, VIDEO_ES, "PAM Image" },
#endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(0<<8)+0) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(0<<8)+0)
{ VLC_FOURCC('b','m','p',' '), CODEC_ID_BMP, { VLC_FOURCC('b','m','p',' '), CODEC_ID_BMP,
VIDEO_ES, "BMP Image" }, VIDEO_ES, "BMP Image" },
#endif #endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(21<<8)+0) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(21<<8)+0)
{ VLC_FOURCC('g','i','f',' '), CODEC_ID_GIF, { VLC_FOURCC('g','i','f',' '), CODEC_ID_GIF,
VIDEO_ES, "GIF Image" }, VIDEO_ES, "GIF Image" },
#endif #endif
...@@ -1037,11 +1009,9 @@ static struct ...@@ -1037,11 +1009,9 @@ static struct
{ VLC_FOURCC('a','5','2','b'), CODEC_ID_AC3, /* VLC specific hack */ { VLC_FOURCC('a','5','2','b'), CODEC_ID_AC3, /* VLC specific hack */
AUDIO_ES, "A52 Audio (aka AC3)" }, AUDIO_ES, "A52 Audio (aka AC3)" },
#if LIBAVCODEC_BUILD >= 4719
/* DTS Audio */ /* DTS Audio */
{ VLC_FOURCC('d','t','s',' '), CODEC_ID_DTS, { VLC_FOURCC('d','t','s',' '), CODEC_ID_DTS,
AUDIO_ES, "DTS Audio" }, AUDIO_ES, "DTS Audio" },
#endif
/* AAC audio */ /* AAC audio */
{ VLC_FOURCC('m','p','4','a'), CODEC_ID_AAC, { VLC_FOURCC('m','p','4','a'), CODEC_ID_AAC,
...@@ -1059,7 +1029,6 @@ static struct ...@@ -1059,7 +1029,6 @@ static struct
{ VLC_FOURCC('R','o','Q','a'), CODEC_ID_ROQ_DPCM, { VLC_FOURCC('R','o','Q','a'), CODEC_ID_ROQ_DPCM,
AUDIO_ES, "Id RoQ DPCM Audio" }, AUDIO_ES, "Id RoQ DPCM Audio" },
#if LIBAVCODEC_BUILD >= 4685
/* Sony Playstation XA ADPCM */ /* Sony Playstation XA ADPCM */
{ VLC_FOURCC('x','a',' ',' '), CODEC_ID_ADPCM_XA, { VLC_FOURCC('x','a',' ',' '), CODEC_ID_ADPCM_XA,
AUDIO_ES, "PSX XA ADPCM Audio" }, AUDIO_ES, "PSX XA ADPCM Audio" },
...@@ -1067,65 +1036,54 @@ static struct ...@@ -1067,65 +1036,54 @@ static struct
/* ADX ADPCM */ /* ADX ADPCM */
{ VLC_FOURCC('a','d','x',' '), CODEC_ID_ADPCM_ADX, { VLC_FOURCC('a','d','x',' '), CODEC_ID_ADPCM_ADX,
AUDIO_ES, "ADX ADPCM Audio" }, AUDIO_ES, "ADX ADPCM Audio" },
#endif
#if LIBAVCODEC_BUILD >= 4699
/* Sierra VMD */ /* Sierra VMD */
{ VLC_FOURCC('v','m','d','a'), CODEC_ID_VMDAUDIO, { VLC_FOURCC('v','m','d','a'), CODEC_ID_VMDAUDIO,
AUDIO_ES, "Sierra VMD Audio" }, AUDIO_ES, "Sierra VMD Audio" },
#endif
#if LIBAVCODEC_BUILD >= 4706
/* G.726 ADPCM */ /* G.726 ADPCM */
{ VLC_FOURCC('g','7','2','6'), CODEC_ID_ADPCM_G726, { VLC_FOURCC('g','7','2','6'), CODEC_ID_ADPCM_G726,
AUDIO_ES, "G.726 ADPCM Audio" }, AUDIO_ES, "G.726 ADPCM Audio" },
#endif
#if LIBAVCODEC_BUILD >= 4683
/* AMR */ /* AMR */
{ VLC_FOURCC('s','a','m','r'), CODEC_ID_AMR_NB, { VLC_FOURCC('s','a','m','r'), CODEC_ID_AMR_NB,
AUDIO_ES, "AMR narrow band" }, AUDIO_ES, "AMR narrow band" },
{ VLC_FOURCC('s','a','w','b'), CODEC_ID_AMR_WB, { VLC_FOURCC('s','a','w','b'), CODEC_ID_AMR_WB,
AUDIO_ES, "AMR wide band" }, AUDIO_ES, "AMR wide band" },
#endif
#if LIBAVCODEC_BUILD >= 4703
/* FLAC */ /* FLAC */
{ VLC_FOURCC('f','l','a','c'), CODEC_ID_FLAC, { VLC_FOURCC('f','l','a','c'), CODEC_ID_FLAC,
AUDIO_ES, "FLAC (Free Lossless Audio Codec)" }, AUDIO_ES, "FLAC (Free Lossless Audio Codec)" },
#endif
#if LIBAVCODEC_BUILD >= 4745
/* ALAC */ /* ALAC */
{ VLC_FOURCC('a','l','a','c'), CODEC_ID_ALAC, { VLC_FOURCC('a','l','a','c'), CODEC_ID_ALAC,
AUDIO_ES, "Apple Lossless Audio Codec" }, AUDIO_ES, "Apple Lossless Audio Codec" },
#endif
#if LIBAVCODEC_BUILD >= ((50<<16)+(0<<8)+1) #if LIBAVCODEC_VERSION_INT >= ((50<<16)+(0<<8)+1)
/* QDM2 */ /* QDM2 */
{ VLC_FOURCC('Q','D','M','2'), CODEC_ID_QDM2, { VLC_FOURCC('Q','D','M','2'), CODEC_ID_QDM2,
AUDIO_ES, "QDM2 Audio" }, AUDIO_ES, "QDM2 Audio" },
#endif #endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(0<<8)+0) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(0<<8)+0)
/* COOK */ /* COOK */
{ VLC_FOURCC('c','o','o','k'), CODEC_ID_COOK, { VLC_FOURCC('c','o','o','k'), CODEC_ID_COOK,
AUDIO_ES, "Cook Audio" }, AUDIO_ES, "Cook Audio" },
#endif #endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(4<<8)+0) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(4<<8)+0)
/* TTA: The Lossless True Audio */ /* TTA: The Lossless True Audio */
{ VLC_FOURCC('T','T','A','1'), CODEC_ID_TTA, { VLC_FOURCC('T','T','A','1'), CODEC_ID_TTA,
AUDIO_ES, "The Lossless True Audio" }, AUDIO_ES, "The Lossless True Audio" },
#endif #endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(8<<8)+0) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(8<<8)+0)
/* Shorten */ /* Shorten */
{ VLC_FOURCC('s','h','n',' '), CODEC_ID_SHORTEN, { VLC_FOURCC('s','h','n',' '), CODEC_ID_SHORTEN,
AUDIO_ES, "Shorten Lossless Audio" }, AUDIO_ES, "Shorten Lossless Audio" },
#endif #endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(16<<8)+0) #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(16<<8)+0)
{ VLC_FOURCC('w','v','p','k'), CODEC_ID_WAVPACK, { VLC_FOURCC('w','v','p','k'), CODEC_ID_WAVPACK,
AUDIO_ES, "WavPack" }, AUDIO_ES, "WavPack" },
#endif #endif
...@@ -1168,7 +1126,7 @@ static struct ...@@ -1168,7 +1126,7 @@ static struct
}; };
int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
int *pi_ffmpeg_codec, char **ppsz_name ) int *pi_ffmpeg_codec, const char **ppsz_name )
{ {
int i; int i;
...@@ -1178,7 +1136,7 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -1178,7 +1136,7 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
{ {
if( pi_cat ) *pi_cat = codecs_table[i].i_cat; if( pi_cat ) *pi_cat = codecs_table[i].i_cat;
if( pi_ffmpeg_codec ) *pi_ffmpeg_codec = codecs_table[i].i_codec; if( pi_ffmpeg_codec ) *pi_ffmpeg_codec = codecs_table[i].i_codec;
if( ppsz_name ) *ppsz_name = codecs_table[i].psz_name; if( ppsz_name ) *ppsz_name = (char *)codecs_table[i].psz_name;
return VLC_TRUE; return VLC_TRUE;
} }
...@@ -1187,7 +1145,7 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat, ...@@ -1187,7 +1145,7 @@ int E_(GetFfmpegCodec)( vlc_fourcc_t i_fourcc, int *pi_cat,
} }
int E_(GetVlcFourcc)( int i_ffmpeg_codec, int *pi_cat, int E_(GetVlcFourcc)( int i_ffmpeg_codec, int *pi_cat,
vlc_fourcc_t *pi_fourcc, char **ppsz_name ) vlc_fourcc_t *pi_fourcc, const char **ppsz_name )
{ {
int i; int i;
......
...@@ -23,32 +23,26 @@ ...@@ -23,32 +23,26 @@
#include "codecs.h" /* BITMAPINFOHEADER */ #include "codecs.h" /* BITMAPINFOHEADER */
#if LIBAVCODEC_BUILD >= 4663
# define LIBAVCODEC_PP
#else
# undef LIBAVCODEC_PP
#endif
struct picture_t; struct picture_t;
struct AVFrame; struct AVFrame;
struct AVCodecContext; struct AVCodecContext;
struct AVCodec; struct AVCodec;
void E_(InitLibavcodec)( vlc_object_t * ); void E_(InitLibavcodec)( vlc_object_t * );
int E_(GetFfmpegCodec) ( vlc_fourcc_t, int *, int *, char ** ); int E_(GetFfmpegCodec) ( vlc_fourcc_t, int *, int *, const char ** );
int E_(GetVlcFourcc) ( int, int *, vlc_fourcc_t *, char ** ); int E_(GetVlcFourcc) ( int, int *, vlc_fourcc_t *, const char ** );
int E_(GetFfmpegChroma)( vlc_fourcc_t ); int E_(GetFfmpegChroma)( vlc_fourcc_t );
vlc_fourcc_t E_(GetVlcChroma)( int ); vlc_fourcc_t E_(GetVlcChroma)( int );
/* Video decoder module */ /* Video decoder module */
int E_( InitVideoDec )( decoder_t *, AVCodecContext *, AVCodec *, int E_( InitVideoDec )( decoder_t *, AVCodecContext *, AVCodec *,
int, char * ); int, const char * );
void E_( EndVideoDec ) ( decoder_t * ); void E_( EndVideoDec ) ( decoder_t * );
picture_t *E_( DecodeVideo ) ( decoder_t *, block_t ** ); picture_t *E_( DecodeVideo ) ( decoder_t *, block_t ** );
/* Audio decoder module */ /* Audio decoder module */
int E_( InitAudioDec )( decoder_t *, AVCodecContext *, AVCodec *, int E_( InitAudioDec )( decoder_t *, AVCodecContext *, AVCodec *,
int, char * ); int, const char * );
void E_( EndAudioDec ) ( decoder_t * ); void E_( EndAudioDec ) ( decoder_t * );
aout_buffer_t *E_( DecodeAudio ) ( decoder_t *, block_t ** ); aout_buffer_t *E_( DecodeAudio ) ( decoder_t *, block_t ** );
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
//#define AVFORMAT_DEBUG 1 //#define AVFORMAT_DEBUG 1
/* Version checking */ /* Version checking */
#if (LIBAVFORMAT_BUILD >= 4687) && (defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE)) #if defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE)
/***************************************************************************** /*****************************************************************************
* mux_sys_t: mux descriptor * mux_sys_t: mux descriptor
...@@ -443,7 +443,7 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence ) ...@@ -443,7 +443,7 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence )
return 0; return 0;
} }
#else /* LIBAVFORMAT_BUILD >= 4687 */ #else /* HAVE_FFMPEG_AVFORMAT_H */
int E_(OpenMux)( vlc_object_t *p_this ) int E_(OpenMux)( vlc_object_t *p_this )
{ {
...@@ -454,4 +454,4 @@ void E_(CloseMux)( vlc_object_t *p_this ) ...@@ -454,4 +454,4 @@ void E_(CloseMux)( vlc_object_t *p_this )
{ {
} }
#endif /* LIBAVFORMAT_BUILD >= 4687 */ #endif /* HAVE_FFMPEG_AVFORMAT_H */
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include "ffmpeg.h" #include "ffmpeg.h"
#ifdef LIBAVCODEC_PP
#ifdef HAVE_POSTPROC_POSTPROCESS_H #ifdef HAVE_POSTPROC_POSTPROCESS_H
# include <postproc/postprocess.h> # include <postproc/postprocess.h>
#else #else
...@@ -265,5 +263,3 @@ static int PPQCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -265,5 +263,3 @@ static int PPQCallback( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
#endif /* LIBAVCODEC_PP */
...@@ -67,7 +67,7 @@ void *( *swscale_fast_memcpy )( void *, const void *, size_t ); ...@@ -67,7 +67,7 @@ void *( *swscale_fast_memcpy )( void *, const void *, size_t );
static picture_t *Filter( filter_t *, picture_t * ); static picture_t *Filter( filter_t *, picture_t * );
static int CheckInit( filter_t * ); static int CheckInit( filter_t * );
static char *ppsz_mode_descriptions[] = static const char *ppsz_mode_descriptions[] =
{ N_("Fast bilinear"), N_("Bilinear"), N_("Bicubic (good quality)"), { N_("Fast bilinear"), N_("Bilinear"), N_("Bicubic (good quality)"),
N_("Experimental"), N_("Nearest neighbour (bad quality)"), N_("Experimental"), N_("Nearest neighbour (bad quality)"),
N_("Area"), N_("Luma bicubic / chroma bilinear"), N_("Gauss"), N_("Area"), N_("Luma bicubic / chroma bilinear"), N_("Gauss"),
......
...@@ -46,7 +46,7 @@ struct decoder_sys_t ...@@ -46,7 +46,7 @@ struct decoder_sys_t
/* Common part between video and audio decoder */ /* Common part between video and audio decoder */
int i_cat; int i_cat;
int i_codec_id; int i_codec_id;
char *psz_namecodec; const char *psz_namecodec;
AVCodecContext *p_context; AVCodecContext *p_context;
AVCodec *p_codec; AVCodec *p_codec;
...@@ -170,16 +170,12 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec, ...@@ -170,16 +170,12 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
} }
else else
{ {
#if LIBAVCODEC_BUILD >= 4687
p_dec->fmt_out.video.i_aspect = p_dec->fmt_out.video.i_aspect =
VOUT_ASPECT_FACTOR * ( av_q2d(p_context->sample_aspect_ratio) * VOUT_ASPECT_FACTOR * ( av_q2d(p_context->sample_aspect_ratio) *
p_context->width / p_context->height ); p_context->width / p_context->height );
p_dec->fmt_out.video.i_sar_num = p_context->sample_aspect_ratio.num; p_dec->fmt_out.video.i_sar_num = p_context->sample_aspect_ratio.num;
p_dec->fmt_out.video.i_sar_den = p_context->sample_aspect_ratio.den; p_dec->fmt_out.video.i_sar_den = p_context->sample_aspect_ratio.den;
#else
p_dec->fmt_out.video.i_aspect =
VOUT_ASPECT_FACTOR * p_context->aspect_ratio;
#endif
if( p_dec->fmt_out.video.i_aspect == 0 ) if( p_dec->fmt_out.video.i_aspect == 0 )
{ {
p_dec->fmt_out.video.i_aspect = p_dec->fmt_out.video.i_aspect =
...@@ -195,31 +191,20 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec, ...@@ -195,31 +191,20 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
p_dec->fmt_out.video.i_frame_rate_base = p_dec->fmt_out.video.i_frame_rate_base =
p_dec->fmt_out.video.i_frame_rate_base; p_dec->fmt_out.video.i_frame_rate_base;
} }
else else if( p_context->time_base.num > 0 && p_context->time_base.den > 0 )
#if LIBAVCODEC_BUILD >= 4754
if( p_context->time_base.num > 0 && p_context->time_base.den > 0 )
{ {
p_dec->fmt_out.video.i_frame_rate = p_context->time_base.den; p_dec->fmt_out.video.i_frame_rate = p_context->time_base.den;
p_dec->fmt_out.video.i_frame_rate_base = p_context->time_base.num; p_dec->fmt_out.video.i_frame_rate_base = p_context->time_base.num;
} }
#else
if( p_context->frame_rate > 0 && p_context->frame_rate_base > 0 )
{
p_dec->fmt_out.video.i_frame_rate = p_context->frame_rate;
p_dec->fmt_out.video.i_frame_rate_base = p_context->frame_rate_base;
}
#endif
p_pic = p_dec->pf_vout_buffer_new( p_dec ); p_pic = p_dec->pf_vout_buffer_new( p_dec );
#ifdef LIBAVCODEC_PP
if( p_sys->p_pp && p_sys->b_pp && !p_sys->b_pp_init ) if( p_sys->p_pp && p_sys->b_pp && !p_sys->b_pp_init )
{ {
E_(InitPostproc)( p_dec, p_sys->p_pp, p_context->width, E_(InitPostproc)( p_dec, p_sys->p_pp, p_context->width,
p_context->height, p_context->pix_fmt ); p_context->height, p_context->pix_fmt );
p_sys->b_pp_init = VLC_TRUE; p_sys->b_pp_init = VLC_TRUE;
} }
#endif
return p_pic; return p_pic;
} }
...@@ -231,7 +216,7 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec, ...@@ -231,7 +216,7 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
* opened (done after the first decoded frame). * opened (done after the first decoded frame).
*****************************************************************************/ *****************************************************************************/
int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
AVCodec *p_codec, int i_codec_id, char *psz_namecodec ) AVCodec *p_codec, int i_codec_id, const char *psz_namecodec )
{ {
decoder_sys_t *p_sys; decoder_sys_t *p_sys;
vlc_value_t lockval; vlc_value_t lockval;
...@@ -271,25 +256,19 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -271,25 +256,19 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
var_Create( p_dec, "ffmpeg-vismv", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_dec, "ffmpeg-vismv", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_dec, "ffmpeg-vismv", &val ); var_Get( p_dec, "ffmpeg-vismv", &val );
#if LIBAVCODEC_BUILD >= 4698
if( val.i_int ) p_sys->p_context->debug_mv = val.i_int; if( val.i_int ) p_sys->p_context->debug_mv = val.i_int;
#endif
var_Create( p_dec, "ffmpeg-lowres", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_dec, "ffmpeg-lowres", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_dec, "ffmpeg-lowres", &val ); var_Get( p_dec, "ffmpeg-lowres", &val );
#if LIBAVCODEC_BUILD >= 4723
if( val.i_int > 0 && val.i_int <= 2 ) p_sys->p_context->lowres = val.i_int; if( val.i_int > 0 && val.i_int <= 2 ) p_sys->p_context->lowres = val.i_int;
#endif
var_Create( p_dec, "ffmpeg-skiploopfilter", var_Create( p_dec, "ffmpeg-skiploopfilter",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_dec, "ffmpeg-skiploopfilter", &val ); var_Get( p_dec, "ffmpeg-skiploopfilter", &val );
#if LIBAVCODEC_BUILD >= 4758
if( val.i_int > 0 ) p_sys->p_context->skip_loop_filter = AVDISCARD_NONREF; if( val.i_int > 0 ) p_sys->p_context->skip_loop_filter = AVDISCARD_NONREF;
if( val.i_int > 1 ) p_sys->p_context->skip_loop_filter = AVDISCARD_BIDIR; if( val.i_int > 1 ) p_sys->p_context->skip_loop_filter = AVDISCARD_BIDIR;
if( val.i_int > 2 ) p_sys->p_context->skip_loop_filter = AVDISCARD_NONKEY; if( val.i_int > 2 ) p_sys->p_context->skip_loop_filter = AVDISCARD_NONKEY;
if( val.i_int > 3 ) p_sys->p_context->skip_loop_filter = AVDISCARD_ALL; if( val.i_int > 3 ) p_sys->p_context->skip_loop_filter = AVDISCARD_ALL;
#endif
/* ***** ffmpeg frame skipping ***** */ /* ***** ffmpeg frame skipping ***** */
var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
...@@ -305,22 +284,16 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -305,22 +284,16 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
p_sys->p_context->pix_fmt != PIX_FMT_YUV422P && p_sys->p_context->pix_fmt != PIX_FMT_YUV422P &&
/* H264 uses too many reference frames */ /* H264 uses too many reference frames */
p_sys->i_codec_id != CODEC_ID_H264 && p_sys->i_codec_id != CODEC_ID_H264 &&
#if LIBAVCODEC_BUILD >= 4698
!p_sys->p_context->debug_mv ) !p_sys->p_context->debug_mv )
#else
1 )
#endif
{ {
/* Some codecs set pix_fmt only after the 1st frame has been decoded, /* Some codecs set pix_fmt only after the 1st frame has been decoded,
* so we need to do another check in ffmpeg_GetFrameBuf() */ * so we need to do another check in ffmpeg_GetFrameBuf() */
p_sys->b_direct_rendering = 1; p_sys->b_direct_rendering = 1;
} }
#ifdef LIBAVCODEC_PP
p_sys->p_pp = NULL; p_sys->p_pp = NULL;
p_sys->b_pp = p_sys->b_pp_async = p_sys->b_pp_init = VLC_FALSE; p_sys->b_pp = p_sys->b_pp_async = p_sys->b_pp_init = VLC_FALSE;
p_sys->p_pp = E_(OpenPostproc)( p_dec, &p_sys->b_pp_async ); p_sys->p_pp = E_(OpenPostproc)( p_dec, &p_sys->b_pp_async );
#endif
/* ffmpeg doesn't properly release old pictures when frames are skipped */ /* ffmpeg doesn't properly release old pictures when frames are skipped */
//if( p_sys->b_hurry_up ) p_sys->b_direct_rendering = 0; //if( p_sys->b_hurry_up ) p_sys->b_direct_rendering = 0;
...@@ -354,13 +327,11 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -354,13 +327,11 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt ); p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt );
/* Setup palette */ /* Setup palette */
#if LIBAVCODEC_BUILD >= 4688
if( p_dec->fmt_in.video.p_palette ) if( p_dec->fmt_in.video.p_palette )
p_sys->p_context->palctrl = p_sys->p_context->palctrl =
(AVPaletteControl *)p_dec->fmt_in.video.p_palette; (AVPaletteControl *)p_dec->fmt_in.video.p_palette;
else else
p_sys->p_context->palctrl = &palette_control; p_sys->p_context->palctrl = &palette_control;
#endif
/* ***** Open the codec ***** */ /* ***** Open the codec ***** */
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
...@@ -602,7 +573,6 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -602,7 +573,6 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
if( !p_dec->fmt_in.video.i_aspect ) if( !p_dec->fmt_in.video.i_aspect )
{ {
/* Fetch again the aspect ratio in case it changed */ /* Fetch again the aspect ratio in case it changed */
#if LIBAVCODEC_BUILD >= 4687
p_dec->fmt_out.video.i_aspect = p_dec->fmt_out.video.i_aspect =
VOUT_ASPECT_FACTOR VOUT_ASPECT_FACTOR
* ( av_q2d(p_sys->p_context->sample_aspect_ratio) * ( av_q2d(p_sys->p_context->sample_aspect_ratio)
...@@ -611,10 +581,7 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -611,10 +581,7 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
= p_sys->p_context->sample_aspect_ratio.num; = p_sys->p_context->sample_aspect_ratio.num;
p_dec->fmt_out.video.i_sar_den p_dec->fmt_out.video.i_sar_den
= p_sys->p_context->sample_aspect_ratio.den; = p_sys->p_context->sample_aspect_ratio.den;
#else
p_dec->fmt_out.video.i_aspect =
VOUT_ASPECT_FACTOR * p_sys->p_context->aspect_ratio;
#endif
if( p_dec->fmt_out.video.i_aspect == 0 ) if( p_dec->fmt_out.video.i_aspect == 0 )
{ {
p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR
...@@ -628,7 +595,6 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -628,7 +595,6 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
p_pic->date = p_sys->i_pts; p_pic->date = p_sys->i_pts;
/* interpolate the next PTS */ /* interpolate the next PTS */
#if LIBAVCODEC_BUILD >= 4754
if( p_dec->fmt_in.video.i_frame_rate > 0 && if( p_dec->fmt_in.video.i_frame_rate > 0 &&
p_dec->fmt_in.video.i_frame_rate_base > 0 ) p_dec->fmt_in.video.i_frame_rate_base > 0 )
{ {
...@@ -646,16 +612,6 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -646,16 +612,6 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
p_block->i_rate / INPUT_RATE_DEFAULT / p_block->i_rate / INPUT_RATE_DEFAULT /
(2 * p_sys->p_context->time_base.den); (2 * p_sys->p_context->time_base.den);
} }
#else
if( p_sys->p_context->frame_rate > 0 )
{
p_sys->i_pts += I64C(1000000) *
(2 + p_sys->p_ff_pic->repeat_pict) *
p_sys->p_context->frame_rate_base *
p_block->i_rate / INPUT_RATE_DEFAULT /
(2 * p_sys->p_context->frame_rate);
}
#endif
if( p_sys->b_first_frame ) if( p_sys->b_first_frame )
{ {
...@@ -665,10 +621,8 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -665,10 +621,8 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
} }
p_pic->i_nb_fields = 2 + p_sys->p_ff_pic->repeat_pict; p_pic->i_nb_fields = 2 + p_sys->p_ff_pic->repeat_pict;
#if LIBAVCODEC_BUILD >= 4685
p_pic->b_progressive = !p_sys->p_ff_pic->interlaced_frame; p_pic->b_progressive = !p_sys->p_ff_pic->interlaced_frame;
p_pic->b_top_field_first = p_sys->p_ff_pic->top_field_first; p_pic->b_top_field_first = p_sys->p_ff_pic->top_field_first;
#endif
return p_pic; return p_pic;
} }
...@@ -693,11 +647,7 @@ void E_(EndVideoDec)( decoder_t *p_dec ) ...@@ -693,11 +647,7 @@ void E_(EndVideoDec)( decoder_t *p_dec )
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
if( p_sys->p_ff_pic ) av_free( p_sys->p_ff_pic ); if( p_sys->p_ff_pic ) av_free( p_sys->p_ff_pic );
#ifdef LIBAVCODEC_PP
E_(ClosePostproc)( p_dec, p_sys->p_pp ); E_(ClosePostproc)( p_dec, p_sys->p_pp );
#endif
free( p_sys->p_buffer_orig ); free( p_sys->p_buffer_orig );
} }
...@@ -792,11 +742,10 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec, ...@@ -792,11 +742,10 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
uint8_t *p_dst, *p_src; uint8_t *p_dst, *p_src;
int i_src_stride, i_dst_stride; int i_src_stride, i_dst_stride;
#ifdef LIBAVCODEC_PP
if( p_sys->p_pp && p_sys->b_pp ) if( p_sys->p_pp && p_sys->b_pp )
E_(PostprocPict)( p_dec, p_sys->p_pp, p_pic, p_ff_pic ); E_(PostprocPict)( p_dec, p_sys->p_pp, p_pic, p_ff_pic );
else else
#endif {
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ ) for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{ {
p_src = p_ff_pic->data[i_plane]; p_src = p_ff_pic->data[i_plane];
...@@ -814,6 +763,7 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec, ...@@ -814,6 +763,7 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
} }
} }
} }
}
else else
{ {
AVPicture dest_pic; AVPicture dest_pic;
...@@ -831,11 +781,13 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec, ...@@ -831,11 +781,13 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
dest_pic.data[i] = p_pic->p[i].p_pixels; dest_pic.data[i] = p_pic->p[i].p_pixels;
dest_pic.linesize[i] = p_pic->p[i].i_pitch; dest_pic.linesize[i] = p_pic->p[i].i_pitch;
} }
#if !defined(HAVE_FFMPEG_SWSCALE_H) && !defined(HAVE_LIBSWSCALE_TREE)
img_convert( &dest_pic, PIX_FMT_YUV420P, img_convert( &dest_pic, PIX_FMT_YUV420P,
(AVPicture *)p_ff_pic, (AVPicture *)p_ff_pic,
p_sys->p_context->pix_fmt, p_sys->p_context->pix_fmt,
p_sys->p_context->width, p_sys->p_context->width,
p_sys->p_context->height ); p_sys->p_context->height );
#endif
break; break;
default: default:
msg_Err( p_dec, "don't know how to convert chroma %i", msg_Err( p_dec, "don't know how to convert chroma %i",
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include "ffmpeg.h" #include "ffmpeg.h"
#if !defined(HAVE_FFMPEG_SWSCALE_H) && !defined(HAVE_LIBSWSCALE_TREE)
void E_(InitLibavcodec) ( vlc_object_t *p_object ); void E_(InitLibavcodec) ( vlc_object_t *p_object );
static int CheckInit( filter_t *p_filter ); static int CheckInit( filter_t *p_filter );
static picture_t *Process( filter_t *p_filter, picture_t *p_pic ); static picture_t *Process( filter_t *p_filter, picture_t *p_pic );
...@@ -287,7 +289,6 @@ static int CheckInit( filter_t *p_filter ) ...@@ -287,7 +289,6 @@ static int CheckInit( filter_t *p_filter )
- p_filter->fmt_out.video.i_x_offset; - p_filter->fmt_out.video.i_x_offset;
} }
#if LIBAVCODEC_BUILD >= 4708
p_sys->p_rsc = img_resample_full_init( p_sys->p_rsc = img_resample_full_init(
p_filter->fmt_out.video.i_width, p_filter->fmt_out.video.i_width,
p_filter->fmt_out.video.i_height, p_filter->fmt_out.video.i_height,
...@@ -297,15 +298,7 @@ static int CheckInit( filter_t *p_filter ) ...@@ -297,15 +298,7 @@ static int CheckInit( filter_t *p_filter )
i_cropleft,i_cropright, i_cropleft,i_cropright,
i_paddtop,i_paddbottom, i_paddtop,i_paddbottom,
i_paddleft,i_paddright ); i_paddleft,i_paddright );
#else
p_sys->p_rsc = img_resample_full_init(
p_filter->fmt_out.video.i_width - i_paddleft - i_paddright,
p_filter->fmt_out.video.i_height - i_paddtop - i_paddbottom,
p_filter->fmt_in.video.i_width,
p_filter->fmt_in.video.i_height,
i_croptop,i_cropbottom,
i_cropleft,i_cropright );
#endif
msg_Dbg( p_filter, "input: %ix%i -> %ix%i", msg_Dbg( p_filter, "input: %ix%i -> %ix%i",
p_filter->fmt_out.video.i_width, p_filter->fmt_out.video.i_width,
p_filter->fmt_out.video.i_height, p_filter->fmt_out.video.i_height,
...@@ -383,10 +376,7 @@ static void fill_pad_region( AVPicture* img, int height, int width, ...@@ -383,10 +376,7 @@ static void fill_pad_region( AVPicture* img, int height, int width,
} }
} }
#if LIBAVCODEC_BUILD < 4708
/* Workaround, because old libavcodec doesnt know how to padd */ /* Workaround, because old libavcodec doesnt know how to padd */
static void img_resample_padd( ImgReSampleContext *s, AVPicture *output, static void img_resample_padd( ImgReSampleContext *s, AVPicture *output,
const AVPicture *input, int padtop, int padleft ) const AVPicture *input, int padtop, int padleft )
{ {
...@@ -398,8 +388,6 @@ static void img_resample_padd( ImgReSampleContext *s, AVPicture *output, ...@@ -398,8 +388,6 @@ static void img_resample_padd( ImgReSampleContext *s, AVPicture *output,
nopadd_pic.data[2] += ( nopadd_pic.linesize[2] * padtop + padleft ) >> 1; nopadd_pic.data[2] += ( nopadd_pic.linesize[2] * padtop + padleft ) >> 1;
img_resample( s, &nopadd_pic, input ); img_resample( s, &nopadd_pic, input );
} }
#endif
/***************************************************************************** /*****************************************************************************
...@@ -465,20 +453,7 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic ) ...@@ -465,20 +453,7 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic )
{ {
if( p_sys->b_convert ) p_dst = &p_sys->tmp_pic; if( p_sys->b_convert ) p_dst = &p_sys->tmp_pic;
#if LIBAVCODEC_BUILD >= 4708
img_resample( p_sys->p_rsc, p_dst, p_src ); img_resample( p_sys->p_rsc, p_dst, p_src );
#else
if ( p_sys->b_enable_croppadd )
{
img_resample_padd( p_sys->p_rsc, p_dst, p_src,
p_filter->fmt_out.video.i_y_offset,
p_filter->fmt_out.video.i_x_offset );
}
else
{
img_resample( p_sys->p_rsc, p_dst, p_src );
}
#endif
if (p_sys->b_enable_croppadd) if (p_sys->b_enable_croppadd)
{ {
...@@ -526,20 +501,7 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic ) ...@@ -526,20 +501,7 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic )
{ {
p_dst = &dest_pic; p_dst = &dest_pic;
#if LIBAVCODEC_BUILD >= 4708
img_resample( p_sys->p_rsc, p_dst, p_src );
#else
if ( p_sys->b_enable_croppadd )
{
img_resample_padd( p_sys->p_rsc, p_dst, p_src,
p_filter->fmt_out.video.i_y_offset,
p_filter->fmt_out.video.i_x_offset );
}
else
{
img_resample( p_sys->p_rsc, p_dst, p_src ); img_resample( p_sys->p_rsc, p_dst, p_src );
}
#endif
if (p_sys->b_enable_croppadd) if (p_sys->b_enable_croppadd)
{ {
...@@ -690,3 +652,5 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) ...@@ -690,3 +652,5 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic )
p_pic->pf_release( p_pic ); p_pic->pf_release( p_pic );
return p_pic_dst; return p_pic_dst;
} }
#endif /* ( (defined(HAVE_FFMPEG_SWSCALE_H) || defined(HAVE_LIBSWSCALE_TREE)) */
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