Commit cde81e52 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: remove support for old versions

parent ba293fd5
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
#include "chroma.h" #include "chroma.h"
#include "avcommon.h" #include "avcommon.h"
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 ) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 54, 25, 0 )
# error You must update libavcodec to a version >= 53.34.0 # error You must update libavcodec to a version >= 54.25.0
#endif #endif
/***************************************************************************** /*****************************************************************************
...@@ -300,11 +300,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -300,11 +300,7 @@ static int OpenDecoder( vlc_object_t *p_this )
} }
/* *** get a p_context *** */ /* *** get a p_context *** */
#if LIBAVCODEC_VERSION_MAJOR >= 54
p_context = avcodec_alloc_context3(p_codec); p_context = avcodec_alloc_context3(p_codec);
#else
p_context = avcodec_alloc_context();
#endif
if( !p_context ) if( !p_context )
return VLC_ENOMEM; return VLC_ENOMEM;
p_context->debug = var_InheritInteger( p_dec, "avcodec-debug" ); p_context->debug = var_InheritInteger( p_dec, "avcodec-debug" );
...@@ -429,11 +425,7 @@ int ffmpeg_OpenCodec( decoder_t *p_dec ) ...@@ -429,11 +425,7 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
} }
int ret; int ret;
vlc_avcodec_lock(); vlc_avcodec_lock();
#if LIBAVCODEC_VERSION_MAJOR >= 54
ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, NULL /* options */ ); ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, NULL /* options */ );
#else
ret = avcodec_open( p_sys->p_context, p_sys->p_codec );
#endif
vlc_avcodec_unlock(); vlc_avcodec_unlock();
if( ret < 0 ) if( ret < 0 )
return VLC_EGENERIC; return VLC_EGENERIC;
......
...@@ -283,79 +283,3 @@ int ffmpeg_OpenCodec( decoder_t *p_dec ); ...@@ -283,79 +283,3 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
#define LIBAVCODEC_VERSION_CHECK( a, b, c, d, e ) \ #define LIBAVCODEC_VERSION_CHECK( a, b, c, d, e ) \
(LIBAVCODEC_VERSION_MICRO < 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, b, c ) ) || \ (LIBAVCODEC_VERSION_MICRO < 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, b, c ) ) || \
(LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) ) (LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) )
#if LIBAVCODEC_VERSION_MAJOR < 54
# define AV_PICTURE_TYPE_B FF_B_TYPE
# define AV_PICTURE_TYPE_I FF_I_TYPE
# define AV_PICTURE_TYPE_P FF_P_TYPE
# define AV_SAMPLE_FMT_NONE SAMPLE_FMT_NONE
# define AV_SAMPLE_FMT_U8 SAMPLE_FMT_U8
# define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16
# define AV_SAMPLE_FMT_S32 SAMPLE_FMT_S32
# define AV_SAMPLE_FMT_FLT SAMPLE_FMT_FLT
# define AV_SAMPLE_FMT_DBL SAMPLE_FMT_DBL
#ifndef AV_CH_FRONT_LEFT
# define AV_CH_FRONT_LEFT CH_FRONT_LEFT
#endif
#ifndef AV_CH_FRONT_RIGHT
# define AV_CH_FRONT_RIGHT CH_FRONT_RIGHT
#endif
#ifndef AV_CH_FRONT_CENTER
# define AV_CH_FRONT_CENTER CH_FRONT_CENTER
#endif
#ifndef AV_CH_LOW_FREQUENCY
# define AV_CH_LOW_FREQUENCY CH_LOW_FREQUENCY
#endif
#ifndef AV_CH_BACK_LEFT
# define AV_CH_BACK_LEFT CH_BACK_LEFT
#endif
#ifndef AV_CH_BACK_RIGHT
# define AV_CH_BACK_RIGHT CH_BACK_RIGHT
#endif
#ifndef AV_CH_FRONT_LEFT_OF_CENTER
# define AV_CH_FRONT_LEFT_OF_CENTER CH_FRONT_LEFT_OF_CENTER
#endif
#ifndef AV_CH_FRONT_RIGHT_OF_CENTER
# define AV_CH_FRONT_RIGHT_OF_CENTER CH_FRONT_RIGHT_OF_CENTER
#endif
#ifndef AV_CH_BACK_CENTER
# define AV_CH_BACK_CENTER CH_BACK_CENTER
#endif
#ifndef AV_CH_SIDE_LEFT
# define AV_CH_SIDE_LEFT CH_SIDE_LEFT
#endif
#ifndef AV_CH_SIDE_RIGHT
# define AV_CH_SIDE_RIGHT CH_SIDE_RIGHT
#endif
#ifndef AV_CH_TOP_CENTER
# define AV_CH_TOP_CENTER CH_TOP_CENTER
#endif
#ifndef AV_CH_TOP_FRONT_LEFT
# define AV_CH_TOP_FRONT_LEFT CH_TOP_FRONT_LEFT
#endif
#ifndef AV_CH_TOP_FRONT_CENTER
# define AV_CH_TOP_FRONT_CENTER CH_TOP_FRONT_CENTER
#endif
#ifndef AV_CH_TOP_FRONT_RIGHT
# define AV_CH_TOP_FRONT_RIGHT CH_TOP_FRONT_RIGHT
#endif
#ifndef AV_CH_TOP_BACK_LEFT
# define AV_CH_TOP_BACK_LEFT CH_TOP_BACK_LEFT
#endif
#ifndef AV_CH_TOP_BACK_CENTER
# define AV_CH_TOP_BACK_CENTER CH_TOP_BACK_CENTER
#endif
#ifndef AV_CH_TOP_BACK_RIGHT
# define AV_CH_TOP_BACK_RIGHT CH_TOP_BACK_RIGHT
#endif
#ifndef AV_CH_STEREO_LEFT
# define AV_CH_STEREO_LEFT CH_STEREO_LEFT
#endif
#ifndef AV_CH_STEREO_RIGHT
# define AV_CH_STEREO_RIGHT CH_STEREO_RIGHT
#endif
#endif /* LIBAVCODEC_VERSION_MAJOR < 54 */
...@@ -63,12 +63,7 @@ static inline void vlc_init_avformat(void) ...@@ -63,12 +63,7 @@ static inline void vlc_init_avformat(void)
static inline void vlc_init_avcodec(void) static inline void vlc_init_avcodec(void)
{ {
vlc_avcodec_lock(); vlc_avcodec_lock();
#if LIBAVCODEC_VERSION_MAJOR < 54
avcodec_init();
#endif
avcodec_register_all(); avcodec_register_all();
vlc_avcodec_unlock(); vlc_avcodec_unlock();
} }
#endif #endif
......
...@@ -300,11 +300,7 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -300,11 +300,7 @@ int OpenEncoder( vlc_object_t *p_this )
p_sys->p_buffer = NULL; p_sys->p_buffer = NULL;
p_sys->i_buffer_out = 0; p_sys->i_buffer_out = 0;
#if LIBAVCODEC_VERSION_MAJOR < 54
p_context = avcodec_alloc_context();
#else
p_context = avcodec_alloc_context3(p_codec); p_context = avcodec_alloc_context3(p_codec);
#endif
p_sys->p_context = p_context; p_sys->p_context = p_context;
p_sys->p_context->codec_id = p_sys->p_codec->id; p_sys->p_context->codec_id = p_sys->p_codec->id;
p_context->debug = var_InheritInteger( p_enc, "avcodec-debug" ); p_context->debug = var_InheritInteger( p_enc, "avcodec-debug" );
...@@ -387,13 +383,11 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -387,13 +383,11 @@ int OpenEncoder( vlc_object_t *p_this )
#endif #endif
else if( !strncmp( psz_val, "ltp", 3 ) ) else if( !strncmp( psz_val, "ltp", 3 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_LTP; p_sys->i_aac_profile = FF_PROFILE_AAC_LTP;
#if LIBAVCODEC_VERSION_CHECK( 54, 19, 0, 35, 100 )
/* These require libavcodec with libfdk-aac */ /* These require libavcodec with libfdk-aac */
else if( !strncmp( psz_val, "hev2", 4 ) ) else if( !strncmp( psz_val, "hev2", 4 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_HE_V2; p_sys->i_aac_profile = FF_PROFILE_AAC_HE_V2;
else if( !strncmp( psz_val, "hev1", 4 ) ) else if( !strncmp( psz_val, "hev1", 4 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_HE; p_sys->i_aac_profile = FF_PROFILE_AAC_HE;
#endif
else else
{ {
msg_Warn( p_enc, "unknown AAC profile requested, setting it to low" ); msg_Warn( p_enc, "unknown AAC profile requested, setting it to low" );
...@@ -697,11 +691,7 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -697,11 +691,7 @@ int OpenEncoder( vlc_object_t *p_this )
int ret; int ret;
vlc_avcodec_lock(); vlc_avcodec_lock();
#if LIBAVCODEC_VERSION_MAJOR < 54
ret = avcodec_open( p_context, p_codec );
#else
ret = avcodec_open2( p_context, p_codec, NULL /* options */ ); ret = avcodec_open2( p_context, p_codec, NULL /* options */ );
#endif
vlc_avcodec_unlock(); vlc_avcodec_unlock();
if( ret ) if( ret )
{ {
...@@ -755,11 +745,7 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -755,11 +745,7 @@ int OpenEncoder( vlc_object_t *p_this )
p_context->codec = NULL; p_context->codec = NULL;
vlc_avcodec_lock(); vlc_avcodec_lock();
#if LIBAVCODEC_VERSION_MAJOR < 54
ret = avcodec_open( p_context, p_codec );
#else
ret = avcodec_open2( p_context, p_codec, NULL /* options */ ); ret = avcodec_open2( p_context, p_codec, NULL /* options */ );
#endif
vlc_avcodec_unlock(); vlc_avcodec_unlock();
if( ret ) if( ret )
{ {
......
...@@ -192,31 +192,19 @@ static const struct ...@@ -192,31 +192,19 @@ static const struct
{ VLC_CODEC_VBLE, CODEC_ID_VBLE, VIDEO_ES }, { VLC_CODEC_VBLE, CODEC_ID_VBLE, VIDEO_ES },
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 1, 0 )
{ VLC_CODEC_CDXL, CODEC_ID_CDXL, VIDEO_ES }, { VLC_CODEC_CDXL, CODEC_ID_CDXL, VIDEO_ES },
#endif
{ VLC_CODEC_UTVIDEO, CODEC_ID_UTVIDEO, VIDEO_ES }, { VLC_CODEC_UTVIDEO, CODEC_ID_UTVIDEO, VIDEO_ES },
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 42, 0 )
{ VLC_CODEC_DXTORY, CODEC_ID_DXTORY, VIDEO_ES }, { VLC_CODEC_DXTORY, CODEC_ID_DXTORY, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 16, 0, 27, 100 )
{ VLC_CODEC_MSS1, CODEC_ID_MSS1, VIDEO_ES }, { VLC_CODEC_MSS1, CODEC_ID_MSS1, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 17, 0, 32, 100 )
{ VLC_CODEC_MSA1, CODEC_ID_MSA1, VIDEO_ES }, { VLC_CODEC_MSA1, CODEC_ID_MSA1, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 18, 0, 34, 100 )
{ VLC_CODEC_TSC2, CODEC_ID_TSCC2, VIDEO_ES }, { VLC_CODEC_TSC2, CODEC_ID_TSCC2, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 20, 0, 37, 100 )
{ VLC_CODEC_MTS2, CODEC_ID_MTS2, VIDEO_ES }, { VLC_CODEC_MTS2, CODEC_ID_MTS2, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 27, 0, 55, 100 ) #if LIBAVCODEC_VERSION_CHECK( 54, 27, 0, 55, 100 )
{ VLC_CODEC_MSS2, AV_CODEC_ID_MSS2, VIDEO_ES }, { VLC_CODEC_MSS2, AV_CODEC_ID_MSS2, VIDEO_ES },
...@@ -391,17 +379,11 @@ static const struct ...@@ -391,17 +379,11 @@ static const struct
{ VLC_CODEC_TRUEHD, CODEC_ID_TRUEHD, AUDIO_ES }, { VLC_CODEC_TRUEHD, CODEC_ID_TRUEHD, AUDIO_ES },
{ VLC_CODEC_MLP, CODEC_ID_MLP, AUDIO_ES }, { VLC_CODEC_MLP, CODEC_ID_MLP, AUDIO_ES },
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 5, 0 )
{ VLC_CODEC_WMAL, CODEC_ID_WMALOSSLESS, AUDIO_ES }, { VLC_CODEC_WMAL, CODEC_ID_WMALOSSLESS, AUDIO_ES },
#endif
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 12, 0 )
{ VLC_CODEC_RALF, CODEC_ID_RALF, AUDIO_ES }, { VLC_CODEC_RALF, CODEC_ID_RALF, AUDIO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 14, 0, 26, 100 )
{ VLC_CODEC_INDEO_AUDIO, CODEC_ID_IAC, AUDIO_ES }, { VLC_CODEC_INDEO_AUDIO, CODEC_ID_IAC, AUDIO_ES },
#endif
/* PCM */ /* PCM */
{ VLC_CODEC_S8, CODEC_ID_PCM_S8, AUDIO_ES }, { VLC_CODEC_S8, CODEC_ID_PCM_S8, AUDIO_ES },
......
...@@ -83,11 +83,7 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context, ...@@ -83,11 +83,7 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
/* */ /* */
int ret; int ret;
vlc_avcodec_lock(); vlc_avcodec_lock();
#if LIBAVCODEC_VERSION_MAJOR < 54
ret = avcodec_open(context, codec);
#else
ret = avcodec_open2(context, codec, NULL /* options */); ret = avcodec_open2(context, codec, NULL /* options */);
#endif
vlc_avcodec_unlock(); vlc_avcodec_unlock();
if (ret < 0) { if (ret < 0) {
msg_Err(dec, "cannot open codec (%s)", namecodec); msg_Err(dec, "cannot open codec (%s)", namecodec);
......
...@@ -75,11 +75,8 @@ struct decoder_sys_t ...@@ -75,11 +75,8 @@ struct decoder_sys_t
/* */ /* */
#if LIBAVCODEC_VERSION_MAJOR < 54 //AVPaletteControl palette;
AVPaletteControl palette; #warning FIXME
#else
# warning FIXME
#endif
/* */ /* */
bool b_flush; bool b_flush;
...@@ -212,11 +209,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -212,11 +209,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
/* ***** Get configuration of ffmpeg plugin ***** */ /* ***** Get configuration of ffmpeg plugin ***** */
p_sys->p_context->workaround_bugs = p_sys->p_context->workaround_bugs =
var_InheritInteger( p_dec, "avcodec-workaround-bugs" ); var_InheritInteger( p_dec, "avcodec-workaround-bugs" );
#if LIBAVCODEC_VERSION_MAJOR < 54
p_sys->p_context->error_recognition =
#else
p_sys->p_context->err_recognition = p_sys->p_context->err_recognition =
#endif
var_InheritInteger( p_dec, "avcodec-error-resilience" ); var_InheritInteger( p_dec, "avcodec-error-resilience" );
if( var_CreateGetBool( p_dec, "grayscale" ) ) if( var_CreateGetBool( p_dec, "grayscale" ) )
...@@ -383,39 +376,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -383,39 +376,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
} }
p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma; p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma;
#if LIBAVCODEC_VERSION_MAJOR < 54
/* Setup palette */ /* Setup palette */
memset( &p_sys->palette, 0, sizeof(p_sys->palette) );
if( p_dec->fmt_in.video.p_palette )
{
p_sys->palette.palette_changed = 1;
for( int i = 0; i < __MIN( AVPALETTE_COUNT, p_dec->fmt_in.video.p_palette->i_entries ); i++ )
{
union {
uint32_t u;
uint8_t a[4];
} c;
c.a[0] = p_dec->fmt_in.video.p_palette->palette[i][0];
c.a[1] = p_dec->fmt_in.video.p_palette->palette[i][1];
c.a[2] = p_dec->fmt_in.video.p_palette->palette[i][2];
c.a[3] = p_dec->fmt_in.video.p_palette->palette[i][3];
p_sys->palette.palette[i] = c.u;
}
p_sys->p_context->palctrl = &p_sys->palette;
p_dec->fmt_out.video.p_palette = malloc( sizeof(video_palette_t) );
if( p_dec->fmt_out.video.p_palette )
*p_dec->fmt_out.video.p_palette = *p_dec->fmt_in.video.p_palette;
}
else if( p_sys->i_codec_id != CODEC_ID_MSVIDEO1 && p_sys->i_codec_id != CODEC_ID_CINEPAK )
{
p_sys->p_context->palctrl = &p_sys->palette;
}
#else
# warning FIXME # warning FIXME
#endif
/* ***** init this codec with special data ***** */ /* ***** init this codec with special data ***** */
ffmpeg_InitCodec( p_dec ); ffmpeg_InitCodec( p_dec );
...@@ -968,10 +930,6 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context, ...@@ -968,10 +930,6 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
/* */ /* */
p_ff_pic->type = FF_BUFFER_TYPE_USER; p_ff_pic->type = FF_BUFFER_TYPE_USER;
#if LIBAVCODEC_VERSION_MAJOR < 54
p_ff_pic->age = 256*256*256*64;
#endif
if( vlc_va_Get( p_sys->p_va, p_ff_pic ) ) if( vlc_va_Get( p_sys->p_va, p_ff_pic ) )
{ {
msg_Err( p_dec, "VaGrabSurface failed" ); msg_Err( p_dec, "VaGrabSurface failed" );
...@@ -1060,10 +1018,6 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context, ...@@ -1060,10 +1018,6 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
p_ff_pic->linesize[2] = p_pic->p[2].i_pitch; p_ff_pic->linesize[2] = p_pic->p[2].i_pitch;
p_ff_pic->linesize[3] = 0; p_ff_pic->linesize[3] = 0;
#if LIBAVCODEC_VERSION_MAJOR < 54
p_ff_pic->age = 256*256*256*64;
#endif
post_mt( p_sys ); post_mt( p_sys );
return 0; return 0;
......
...@@ -325,15 +325,7 @@ int OpenDemux( vlc_object_t *p_this ) ...@@ -325,15 +325,7 @@ int OpenDemux( vlc_object_t *p_this )
fmt.video.i_width = cc->width; fmt.video.i_width = cc->width;
fmt.video.i_height = cc->height; fmt.video.i_height = cc->height;
#if LIBAVCODEC_VERSION_MAJOR < 54
if( cc->palctrl )
{
fmt.video.p_palette = malloc( sizeof(video_palette_t) );
*fmt.video.p_palette = *(video_palette_t *)cc->palctrl;
}
#else
# warning FIXME: implement palette transmission # warning FIXME: implement palette transmission
#endif
psz_type = "video"; psz_type = "video";
fmt.video.i_frame_rate = cc->time_base.den; fmt.video.i_frame_rate = cc->time_base.den;
fmt.video.i_frame_rate_base = cc->time_base.num * __MAX( cc->ticks_per_frame, 1 ); fmt.video.i_frame_rate_base = cc->time_base.num * __MAX( cc->ticks_per_frame, 1 );
......
...@@ -131,10 +131,8 @@ vlc_module_begin () ...@@ -131,10 +131,8 @@ vlc_module_begin ()
QSCALE_TEXT, QSCALE_LONGTEXT, true ) QSCALE_TEXT, QSCALE_LONGTEXT, true )
add_bool( SOUT_CFG_PREFIX "mute-audio", true, add_bool( SOUT_CFG_PREFIX "mute-audio", true,
AUDIO_TEXT, AUDIO_LONGTEXT, true ) AUDIO_TEXT, AUDIO_LONGTEXT, true )
#if LIBAVCODEC_VERSION_MAJOR >= 54
add_string( SOUT_CFG_PREFIX "options", NULL, add_string( SOUT_CFG_PREFIX "options", NULL,
AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true ) AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true )
#endif
vlc_module_end () vlc_module_end ()
static const char *const ppsz_sout_options[] = { static const char *const ppsz_sout_options[] = {
...@@ -158,9 +156,7 @@ struct sout_stream_sys_t ...@@ -158,9 +156,7 @@ struct sout_stream_sys_t
int i_fd; int i_fd;
int i_cmd, i_old_cmd; int i_cmd, i_old_cmd;
#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionary *options; AVDictionary *options;
#endif
}; };
struct sout_stream_id_t struct sout_stream_id_t
...@@ -297,7 +293,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -297,7 +293,6 @@ static int Open( vlc_object_t *p_this )
p_stream->pf_send = Send; p_stream->pf_send = Send;
p_stream->p_sys = p_sys; p_stream->p_sys = p_sys;
#if LIBAVCODEC_VERSION_MAJOR >= 54
char *psz_opts = var_InheritString( p_stream, SOUT_CFG_PREFIX "options" ); char *psz_opts = var_InheritString( p_stream, SOUT_CFG_PREFIX "options" );
if (psz_opts && *psz_opts) { if (psz_opts && *psz_opts) {
p_sys->options = vlc_av_get_options(psz_opts); p_sys->options = vlc_av_get_options(psz_opts);
...@@ -305,7 +300,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -305,7 +300,6 @@ static int Open( vlc_object_t *p_this )
p_sys->options = NULL; p_sys->options = NULL;
} }
free(psz_opts); free(psz_opts);
#endif
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -318,10 +312,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -318,10 +312,7 @@ static void Close( vlc_object_t * p_this )
sout_stream_t *p_stream = (sout_stream_t *)p_this; sout_stream_t *p_stream = (sout_stream_t *)p_this;
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
#if LIBAVCODEC_VERSION_MAJOR >= 54
av_dict_free( &p_sys->options ); av_dict_free( &p_sys->options );
#endif
free( p_sys ); free( p_sys );
} }
...@@ -371,11 +362,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -371,11 +362,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
return NULL; return NULL;
} }
#if LIBAVCODEC_VERSION_MAJOR < 54
id->ff_enc_c = avcodec_alloc_context();
#else
id->ff_enc_c = avcodec_alloc_context3( id->ff_enc ); id->ff_enc_c = avcodec_alloc_context3( id->ff_enc );
#endif
id->ff_enc_c->dsp_mask = GetVlcDspMask(); id->ff_enc_c->dsp_mask = GetVlcDspMask();
id->ff_enc_c->sample_rate = p_fmt->audio.i_rate; id->ff_enc_c->sample_rate = p_fmt->audio.i_rate;
id->ff_enc_c->time_base.num = 1; id->ff_enc_c->time_base.num = 1;
...@@ -384,7 +371,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -384,7 +371,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->ff_enc_c->bit_rate = p_fmt->i_bitrate; id->ff_enc_c->bit_rate = p_fmt->i_bitrate;
int ret; int ret;
#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionary *options = NULL; AVDictionary *options = NULL;
if (p_sys->options) if (p_sys->options)
av_dict_copy(&options, p_sys->options, 0); av_dict_copy(&options, p_sys->options, 0);
...@@ -396,11 +382,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -396,11 +382,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
msg_Err( p_stream, "Unknown option \"%s\"", t->key ); msg_Err( p_stream, "Unknown option \"%s\"", t->key );
} }
av_dict_free(&options); av_dict_free(&options);
#else
vlc_avcodec_lock();
ret = avcodec_open( id->ff_enc_c, id->ff_enc );
vlc_avcodec_unlock();
#endif
if (ret) if (ret)
{ {
...@@ -760,11 +741,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -760,11 +741,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
return 0; return 0;
} }
#if LIBAVCODEC_VERSION_MAJOR < 54
id->ff_enc_c = avcodec_alloc_context();
#else
id->ff_enc_c = avcodec_alloc_context3( id->ff_enc ); id->ff_enc_c = avcodec_alloc_context3( id->ff_enc );
#endif
id->ff_enc_c->dsp_mask = GetVlcDspMask(); id->ff_enc_c->dsp_mask = GetVlcDspMask();
id->ff_enc_c->width = p_sys->p_pictures[p_sys->i_cmd-1].format.i_width; id->ff_enc_c->width = p_sys->p_pictures[p_sys->i_cmd-1].format.i_width;
id->ff_enc_c->height = p_sys->p_pictures[p_sys->i_cmd-1].format.i_height; id->ff_enc_c->height = p_sys->p_pictures[p_sys->i_cmd-1].format.i_height;
...@@ -791,22 +768,18 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -791,22 +768,18 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
vlc_avcodec_lock(); vlc_avcodec_lock();
int ret; int ret;
#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionary *options = NULL; AVDictionary *options = NULL;
if (p_sys->options) if (p_sys->options)
av_dict_copy(&options, p_sys->options, 0); av_dict_copy(&options, p_sys->options, 0);
ret = avcodec_open2( id->ff_enc_c, id->ff_enc, options ? &options : NULL ); ret = avcodec_open2( id->ff_enc_c, id->ff_enc, options ? &options : NULL );
#else
ret = avcodec_open( id->ff_enc_c, id->ff_enc );
#endif
vlc_avcodec_unlock(); vlc_avcodec_unlock();
#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionaryEntry *t = NULL; AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX))) { while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX))) {
msg_Err( p_stream, "Unknown option \"%s\"", t->key ); msg_Err( p_stream, "Unknown option \"%s\"", t->key );
} }
av_dict_free(&options); av_dict_free(&options);
#endif
if (ret) if (ret)
{ {
msg_Err( p_stream, "cannot open encoder" ); msg_Err( p_stream, "cannot open encoder" );
......
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