#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
/*****************************************************************************
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
#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" );
{ 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 },
{ 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 },
/* */
- //AVPaletteControl palette;
-#warning FIXME
+#if LIBAVCODEC_VERSION_MAJOR < 54
+ AVPaletteControl palette;
+#else
+# warning FIXME
+#endif
/* */
bool b_flush;
}
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 );
/* */
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" );
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;
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 );
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[] = {
int i_fd;
int i_cmd, i_old_cmd;
+#if LIBAVCODEC_VERSION_MAJOR >= 54
AVDictionary *options;
+#endif
};
struct sout_stream_id_t
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);
p_sys->options = NULL;
}
free(psz_opts);
+#endif
return VLC_SUCCESS;
}
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 );
}
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);
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)
{
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)
{