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 );
......
This diff is collapsed.
...@@ -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,25 +742,25 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec, ...@@ -792,25 +742,25 @@ 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++ )
{ {
p_src = p_ff_pic->data[i_plane]; for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
p_dst = p_pic->p[i_plane].p_pixels;
i_src_stride = p_ff_pic->linesize[i_plane];
i_dst_stride = p_pic->p[i_plane].i_pitch;
i_size = __MIN( i_src_stride, i_dst_stride );
for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines;
i_line++ )
{ {
p_dec->p_libvlc->pf_memcpy( p_dst, p_src, i_size ); p_src = p_ff_pic->data[i_plane];
p_src += i_src_stride; p_dst = p_pic->p[i_plane].p_pixels;
p_dst += i_dst_stride; i_src_stride = p_ff_pic->linesize[i_plane];
i_dst_stride = p_pic->p[i_plane].i_pitch;
i_size = __MIN( i_src_stride, i_dst_stride );
for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines;
i_line++ )
{
p_dec->p_libvlc->pf_memcpy( p_dst, p_src, i_size );
p_src += i_src_stride;
p_dst += i_dst_stride;
}
} }
} }
} }
...@@ -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 ); 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)
{ {
...@@ -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