Commit f6d0b13a authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Partial revert of "avcodec: remove support for old versions"

This partially reverts and adapts commit cde81e52.
This is mostly related to Palette and Options
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent b7786ff2
......@@ -42,8 +42,10 @@
#include "chroma.h"
#include "avcommon.h"
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 54, 25, 0 )
# error You must update libavcodec to a version >= 54.25.0
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 )
# error You must update libavcodec to a version >= 53.34.0
#elif LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 54, 25, 0 )
# warning You should update libavcodec to a version >= 54.25.0
#endif
/*****************************************************************************
......
......@@ -68,7 +68,12 @@ static inline void vlc_init_avformat(void)
static inline void vlc_init_avcodec(void)
{
vlc_avcodec_lock();
#if LIBAVCODEC_VERSION_MAJOR < 54
avcodec_init();
#endif
avcodec_register_all();
vlc_avcodec_unlock();
}
#endif
......
......@@ -389,11 +389,13 @@ int OpenEncoder( vlc_object_t *p_this )
#endif
else if( !strncmp( psz_val, "ltp", 3 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_LTP;
#if LIBAVCODEC_VERSION_CHECK( 54, 19, 0, 35, 100 )
/* These require libavcodec with libfdk-aac */
else if( !strncmp( psz_val, "hev2", 4 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_HE_V2;
else if( !strncmp( psz_val, "hev1", 4 ) )
p_sys->i_aac_profile = FF_PROFILE_AAC_HE;
#endif
else
{
msg_Warn( p_enc, "unknown AAC profile requested, setting it to low" );
......
......@@ -192,19 +192,31 @@ static const struct
{ VLC_CODEC_VBLE, AV_CODEC_ID_VBLE, VIDEO_ES },
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 1, 0 )
{ VLC_CODEC_CDXL, AV_CODEC_ID_CDXL, VIDEO_ES },
#endif
{ VLC_CODEC_UTVIDEO, AV_CODEC_ID_UTVIDEO, VIDEO_ES },
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 42, 0 )
{ VLC_CODEC_DXTORY, AV_CODEC_ID_DXTORY, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 16, 0, 27, 100 )
{ VLC_CODEC_MSS1, AV_CODEC_ID_MSS1, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 17, 0, 32, 100 )
{ VLC_CODEC_MSA1, AV_CODEC_ID_MSA1, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 18, 0, 34, 100 )
{ VLC_CODEC_TSC2, AV_CODEC_ID_TSCC2, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 20, 0, 37, 100 )
{ VLC_CODEC_MTS2, AV_CODEC_ID_MTS2, VIDEO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 27, 0, 55, 100 )
{ VLC_CODEC_MSS2, AV_CODEC_ID_MSS2, VIDEO_ES },
......@@ -379,11 +391,17 @@ static const struct
{ VLC_CODEC_TRUEHD, AV_CODEC_ID_TRUEHD, AUDIO_ES },
{ VLC_CODEC_MLP, AV_CODEC_ID_MLP, AUDIO_ES },
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 5, 0 )
{ VLC_CODEC_WMAL, AV_CODEC_ID_WMALOSSLESS, AUDIO_ES },
#endif
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 12, 0 )
{ VLC_CODEC_RALF, AV_CODEC_ID_RALF, AUDIO_ES },
#endif
#if LIBAVCODEC_VERSION_CHECK( 54, 14, 0, 26, 100 )
{ VLC_CODEC_INDEO_AUDIO, AV_CODEC_ID_IAC, AUDIO_ES },
#endif
/* PCM */
{ VLC_CODEC_S8, AV_CODEC_ID_PCM_S8, AUDIO_ES },
......
......@@ -75,8 +75,11 @@ struct decoder_sys_t
/* */
//AVPaletteControl palette;
#warning FIXME
#if LIBAVCODEC_VERSION_MAJOR < 54
AVPaletteControl palette;
#else
# warning FIXME
#endif
/* */
bool b_flush;
......@@ -376,8 +379,39 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
}
p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma;
#if LIBAVCODEC_VERSION_MAJOR < 54
/* Setup palette */
# warning FIXME: 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
#endif
/* ***** init this codec with special data ***** */
ffmpeg_InitCodec( p_dec );
......@@ -912,6 +946,10 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
/* */
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 ) )
{
msg_Err( p_dec, "VaGrabSurface failed" );
......@@ -1000,6 +1038,10 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
p_ff_pic->linesize[2] = p_pic->p[2].i_pitch;
p_ff_pic->linesize[3] = 0;
#if LIBAVCODEC_VERSION_MAJOR < 54
p_ff_pic->age = 256*256*256*64;
#endif
post_mt( p_sys );
return 0;
......
......@@ -325,7 +325,15 @@ int OpenDemux( vlc_object_t *p_this )
fmt.video.i_width = cc->width;
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
#endif
psz_type = "video";
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 );
......
......@@ -131,8 +131,10 @@ vlc_module_begin ()
QSCALE_TEXT, QSCALE_LONGTEXT, true )
add_bool( SOUT_CFG_PREFIX "mute-audio", true,
AUDIO_TEXT, AUDIO_LONGTEXT, true )
#if LIBAVCODEC_VERSION_MAJOR >= 54
add_string( SOUT_CFG_PREFIX "options", NULL,
AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true )
#endif
vlc_module_end ()
static const char *const ppsz_sout_options[] = {
......@@ -156,7 +158,9 @@ struct sout_stream_sys_t
int i_fd;
int i_cmd, i_old_cmd;
#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionary *options;
#endif
};
struct sout_stream_id_t
......@@ -293,6 +297,7 @@ static int Open( vlc_object_t *p_this )
p_stream->pf_send = Send;
p_stream->p_sys = p_sys;
#if LIBAVCODEC_VERSION_MAJOR >= 54
char *psz_opts = var_InheritString( p_stream, SOUT_CFG_PREFIX "options" );
if (psz_opts && *psz_opts) {
p_sys->options = vlc_av_get_options(psz_opts);
......@@ -300,6 +305,7 @@ static int Open( vlc_object_t *p_this )
p_sys->options = NULL;
}
free(psz_opts);
#endif
return VLC_SUCCESS;
}
......@@ -312,7 +318,10 @@ static void Close( vlc_object_t * p_this )
sout_stream_t *p_stream = (sout_stream_t *)p_this;
sout_stream_sys_t *p_sys = p_stream->p_sys;
#if LIBAVCODEC_VERSION_MAJOR >= 54
av_dict_free( &p_sys->options );
#endif
free( p_sys );
}
......@@ -371,6 +380,7 @@ 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;
int ret;
#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionary *options = NULL;
if (p_sys->options)
av_dict_copy(&options, p_sys->options, 0);
......@@ -382,6 +392,11 @@ 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 );
}
av_dict_free(&options);
#else
vlc_avcodec_lock();
ret = avcodec_open( id->ff_enc_c, id->ff_enc );
vlc_avcodec_unlock();
#endif
if (ret)
{
......@@ -768,17 +783,21 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
vlc_avcodec_lock();
int ret;
#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionary *options = NULL;
if (p_sys->options)
av_dict_copy(&options, p_sys->options, 0);
#endif
ret = avcodec_open2( id->ff_enc_c, id->ff_enc, options ? &options : NULL );
vlc_avcodec_unlock();
#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX))) {
msg_Err( p_stream, "Unknown option \"%s\"", t->key );
}
av_dict_free(&options);
#endif
if (ret)
{
......
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