Commit 4308323d authored by Konstantin Pavlov's avatar Konstantin Pavlov Committed by Jean-Baptiste Kempf

Update av* code to use new APIs after Libav Big Bump.

Tested on current libav and ffmpeg @ 25846 svn revision playback only.

No need to bump current lavc/lavf requirements (52.25.0 and 52.45.0), as
all the "new" functions used arrived earlier than abovementioned
versions were published.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 2f918cf7
...@@ -150,8 +150,8 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -150,8 +150,8 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
return VLC_ENOMEM; return VLC_ENOMEM;
} }
p_codec->type = CODEC_TYPE_AUDIO; p_codec->type = AVMEDIA_TYPE_AUDIO;
p_context->codec_type = CODEC_TYPE_AUDIO; p_context->codec_type = AVMEDIA_TYPE_AUDIO;
p_context->codec_id = i_codec_id; p_context->codec_id = i_codec_id;
p_sys->p_context = p_context; p_sys->p_context = p_context;
p_sys->p_codec = p_codec; p_sys->p_codec = p_codec;
...@@ -258,6 +258,7 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block ) ...@@ -258,6 +258,7 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
int i_used, i_output; int i_used, i_output;
aout_buffer_t *p_buffer; aout_buffer_t *p_buffer;
block_t *p_block; block_t *p_block;
AVPacket pkt;
if( !pp_block || !*pp_block ) return NULL; if( !pp_block || !*pp_block ) return NULL;
...@@ -329,9 +330,12 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block ) ...@@ -329,9 +330,12 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
p_sys->p_output = av_realloc( p_sys->p_output, i_output ); p_sys->p_output = av_realloc( p_sys->p_output, i_output );
} }
i_used = avcodec_decode_audio2( p_sys->p_context, av_init_packet( &pkt );
pkt.data = p_block->p_buffer;
pkt.size = p_block->i_buffer;
i_used = avcodec_decode_audio3( p_sys->p_context,
(int16_t*)p_sys->p_output, &i_output, (int16_t*)p_sys->p_output, &i_output,
p_block->p_buffer, p_block->i_buffer ); &pkt );
if( i_used < 0 || i_output < 0 ) if( i_used < 0 || i_output < 0 )
{ {
......
...@@ -263,39 +263,39 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -263,39 +263,39 @@ static int OpenDecoder( vlc_object_t *p_this )
p_context->dsp_mask = 0; p_context->dsp_mask = 0;
if( !(i_cpu & CPU_CAPABILITY_MMX) ) if( !(i_cpu & CPU_CAPABILITY_MMX) )
{ {
p_context->dsp_mask |= FF_MM_MMX; p_context->dsp_mask |= AV_CPU_FLAG_MMX;
} }
if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
{ {
p_context->dsp_mask |= FF_MM_MMXEXT; p_context->dsp_mask |= AV_CPU_FLAG_MMX2;
} }
if( !(i_cpu & CPU_CAPABILITY_3DNOW) ) if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
{ {
p_context->dsp_mask |= FF_MM_3DNOW; p_context->dsp_mask |= AV_CPU_FLAG_3DNOW;
} }
if( !(i_cpu & CPU_CAPABILITY_SSE) ) if( !(i_cpu & CPU_CAPABILITY_SSE) )
{ {
p_context->dsp_mask |= FF_MM_SSE; p_context->dsp_mask |= AV_CPU_FLAG_SSE;
} }
if( !(i_cpu & CPU_CAPABILITY_SSE2) ) if( !(i_cpu & CPU_CAPABILITY_SSE2) )
{ {
p_context->dsp_mask |= FF_MM_SSE2; p_context->dsp_mask |= AV_CPU_FLAG_SSE2;
} }
#ifdef FF_MM_SSE3 #ifdef AV_CPU_FLAG_SSE3
if( !(i_cpu & CPU_CAPABILITY_SSE3) ) if( !(i_cpu & CPU_CAPABILITY_SSE3) )
p_context->dsp_mask |= FF_MM_SSE3; p_context->dsp_mask |= AV_CPU_FLAG_SSE3;
#endif #endif
#ifdef FF_MM_SSSE3 #ifdef AV_CPU_FLAG_SSSE3
if( !(i_cpu & CPU_CAPABILITY_SSSE3) ) if( !(i_cpu & CPU_CAPABILITY_SSSE3) )
p_context->dsp_mask |= FF_MM_SSSE3; p_context->dsp_mask |= AV_CPU_FLAG_SSSE3;
#endif #endif
#ifdef FF_MM_SSE4 #ifdef AV_CPU_FLAG_SSE4
if( !(i_cpu & CPU_CAPABILITY_SSE4_1) ) if( !(i_cpu & CPU_CAPABILITY_SSE4_1) )
p_context->dsp_mask |= FF_MM_SSE4; p_context->dsp_mask |= AV_CPU_FLAG_SSE4;
#endif #endif
#ifdef FF_MM_SSE42 #ifdef AV_CPU_FLAG_SSE42
if( !(i_cpu & CPU_CAPABILITY_SSE4_2) ) if( !(i_cpu & CPU_CAPABILITY_SSE4_2) )
p_context->dsp_mask |= FF_MM_SSE42; p_context->dsp_mask |= AV_CPU_FLAG_SSE42;
#endif #endif
p_dec->b_need_packetized = true; p_dec->b_need_packetized = true;
......
...@@ -276,3 +276,36 @@ int ffmpeg_OpenCodec( decoder_t *p_dec ); ...@@ -276,3 +276,36 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
* system) */ * system) */
//#define HAVE_AVCODEC_VAAPI 1 //#define HAVE_AVCODEC_VAAPI 1
//#define HAVE_AVCODEC_DXVA2 1 //#define HAVE_AVCODEC_DXVA2 1
/* Ugly ifdefinitions to provide backwards compatibility with older ffmpeg/libav
* versions */
#ifndef AV_CPU_FLAG_FORCE
# define AV_CPU_FLAG_FORCE FF_MM_FORCE
# define AV_CPU_FLAG_MMX FF_MM_MMX
# define AV_CPU_FLAG_3DNOW FF_MM_3DNOW
# define AV_CPU_FLAG_MMX2 FF_MM_MMX2
# define AV_CPU_FLAG_SSE FF_MM_SSE
# define AV_CPU_FLAG_SSE2 FF_MM_SSE2
# define AV_CPU_FLAG_SSE2SLOW FF_MM_SSE2SLOW
# define AV_CPU_FLAG_3DNOWEXT FF_MM_3DNOWEXT
# define AV_CPU_FLAG_SSE3 FF_MM_SSE3
# define AV_CPU_FLAG_SSE3SLOW FF_MM_SSE3SLOW
# define AV_CPU_FLAG_SSSE3 FF_MM_SSSE3
# define AV_CPU_FLAG_SSE4 FF_MM_SSE4
# define AV_CPU_FLAG_SSE42 FF_MM_SSE42
# define AV_CPU_FLAG_IWMMXT FF_MM_IWMMXT
# define AV_CPU_FLAG_ALTIVEC FF_MM_ALTIVEC
#endif
#if LIBAVCODEC_VERSION_MAJOR < 53
# define AVMediaType CodecType
# define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
# define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
# define AVMEDIA_TYPE_SUBTITLE CODEC_TYPE_SUBTITLE
# define AVMEDIA_TYPE_DATA CODEC_TYPE_DATA
# define AVMEDIA_TYPE_ATTACHMENT CODEC_TYPE_ATTACHMENT
#endif
#ifndef AV_PKT_FLAG_KEY
# define AV_PKT_FLAG_KEY PKT_FLAG_KEY
#endif
...@@ -287,20 +287,20 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -287,20 +287,20 @@ int OpenEncoder( vlc_object_t *p_this )
p_context->dsp_mask = 0; p_context->dsp_mask = 0;
if( !(i_cpu & CPU_CAPABILITY_MMX) ) if( !(i_cpu & CPU_CAPABILITY_MMX) )
{ {
p_context->dsp_mask |= FF_MM_MMX; p_context->dsp_mask |= AV_CPU_FLAG_MMX;
} }
if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
{ {
p_context->dsp_mask |= FF_MM_MMXEXT; p_context->dsp_mask |= AV_CPU_FLAG_MMX2;
} }
if( !(i_cpu & CPU_CAPABILITY_3DNOW) ) if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
{ {
p_context->dsp_mask |= FF_MM_3DNOW; p_context->dsp_mask |= AV_CPU_FLAG_3DNOW;
} }
if( !(i_cpu & CPU_CAPABILITY_SSE) ) if( !(i_cpu & CPU_CAPABILITY_SSE) )
{ {
p_context->dsp_mask |= FF_MM_SSE; p_context->dsp_mask |= AV_CPU_FLAG_SSE;
p_context->dsp_mask |= FF_MM_SSE2; p_context->dsp_mask |= AV_CPU_FLAG_SSE2;
} }
config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg ); config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );
...@@ -395,7 +395,7 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -395,7 +395,7 @@ int OpenEncoder( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_context->codec_type = CODEC_TYPE_VIDEO; p_context->codec_type = AVMEDIA_TYPE_VIDEO;
p_context->width = p_enc->fmt_in.video.i_width; p_context->width = p_enc->fmt_in.video.i_width;
p_context->height = p_enc->fmt_in.video.i_height; p_context->height = p_enc->fmt_in.video.i_height;
...@@ -511,11 +511,6 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -511,11 +511,6 @@ int OpenEncoder( vlc_object_t *p_this )
i_codec_id == CODEC_ID_SVQ3 ) i_codec_id == CODEC_ID_SVQ3 )
p_enc->i_threads = 1; p_enc->i_threads = 1;
if ( p_enc->i_threads >= 1 )
avcodec_thread_init( p_context, p_enc->i_threads );
else
avcodec_thread_init( p_context, vlc_GetCPUCount() );
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;
...@@ -530,12 +525,12 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -530,12 +525,12 @@ int OpenEncoder( vlc_object_t *p_this )
if( p_sys->i_qmin > 0 ) if( p_sys->i_qmin > 0 )
{ {
p_context->mb_qmin = p_context->qmin = p_sys->i_qmin; p_context->qmin = p_sys->i_qmin;
p_context->mb_lmin = p_context->lmin = p_sys->i_qmin * FF_QP2LAMBDA; p_context->mb_lmin = p_context->lmin = p_sys->i_qmin * FF_QP2LAMBDA;
} }
if( p_sys->i_qmax > 0 ) if( p_sys->i_qmax > 0 )
{ {
p_context->mb_qmax = p_context->qmax = p_sys->i_qmax; p_context->qmax = p_sys->i_qmax;
p_context->mb_lmax = p_context->lmax = p_sys->i_qmax * FF_QP2LAMBDA; p_context->mb_lmax = p_context->lmax = p_sys->i_qmax * FF_QP2LAMBDA;
} }
p_context->max_qdiff = 3; p_context->max_qdiff = 3;
...@@ -565,7 +560,7 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -565,7 +560,7 @@ int OpenEncoder( vlc_object_t *p_this )
if( i_codec_id == CODEC_ID_MP3 && p_enc->fmt_in.audio.i_channels > 2 ) if( i_codec_id == CODEC_ID_MP3 && p_enc->fmt_in.audio.i_channels > 2 )
p_enc->fmt_in.audio.i_channels = 2; p_enc->fmt_in.audio.i_channels = 2;
p_context->codec_type = CODEC_TYPE_AUDIO; p_context->codec_type = AVMEDIA_TYPE_AUDIO;
p_context->sample_fmt = p_codec->sample_fmts ? p_context->sample_fmt = p_codec->sample_fmts ?
p_codec->sample_fmts[0] : p_codec->sample_fmts[0] :
SAMPLE_FMT_S16; SAMPLE_FMT_S16;
...@@ -607,20 +602,20 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -607,20 +602,20 @@ int OpenEncoder( vlc_object_t *p_this )
/* Check that we don't overrun users qmin/qmax values */ /* Check that we don't overrun users qmin/qmax values */
if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) ) if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) )
{ {
p_context->mb_qmin = p_context->qmin = 10; p_context->qmin = 10;
p_context->mb_lmin = p_context->lmin = 10 * FF_QP2LAMBDA; p_context->mb_lmin = p_context->lmin = 10 * FF_QP2LAMBDA;
} }
if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmax" ) ) if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmax" ) )
{ {
p_context->mb_qmax = p_context->qmax = 42; p_context->qmax = 42;
p_context->mb_lmax = p_context->lmax = 42 * FF_QP2LAMBDA; p_context->mb_lmax = p_context->lmax = 42 * FF_QP2LAMBDA;
} }
} else { } else {
if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) ) if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) )
{ {
p_context->mb_qmin = p_context->qmin = 1; p_context->qmin = 1;
p_context->mb_lmin = p_context->lmin = FF_QP2LAMBDA; p_context->mb_lmin = p_context->lmin = FF_QP2LAMBDA;
} }
} }
...@@ -649,6 +644,11 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -649,6 +644,11 @@ int OpenEncoder( vlc_object_t *p_this )
p_context->extradata = NULL; p_context->extradata = NULL;
p_context->flags |= CODEC_FLAG_GLOBAL_HEADER; p_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
if( p_enc->i_threads >= 1)
p_context->thread_count = p_enc->i_threads;
else
p_context->thread_count = vlc_GetCPUCount();
int ret; int ret;
vlc_avcodec_lock(); vlc_avcodec_lock();
ret = avcodec_open( p_context, p_codec ); ret = avcodec_open( p_context, p_codec );
......
...@@ -76,8 +76,8 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context, ...@@ -76,8 +76,8 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
if (!sys) if (!sys)
return VLC_ENOMEM; return VLC_ENOMEM;
codec->type = CODEC_TYPE_SUBTITLE; codec->type = AVMEDIA_TYPE_SUBTITLE;
context->codec_type = CODEC_TYPE_SUBTITLE; context->codec_type = AVMEDIA_TYPE_SUBTITLE;
context->codec_id = codec_id; context->codec_id = codec_id;
sys->p_context = context; sys->p_context = context;
sys->p_codec = codec; sys->p_codec = codec;
......
...@@ -207,8 +207,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -207,8 +207,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
if( ( p_dec->p_sys = p_sys = calloc( 1, sizeof(decoder_sys_t) ) ) == NULL ) if( ( p_dec->p_sys = p_sys = calloc( 1, sizeof(decoder_sys_t) ) ) == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
p_codec->type = CODEC_TYPE_VIDEO; p_codec->type = AVMEDIA_TYPE_VIDEO;
p_context->codec_type = CODEC_TYPE_VIDEO; p_context->codec_type = AVMEDIA_TYPE_VIDEO;
p_context->codec_id = i_codec_id; p_context->codec_id = i_codec_id;
p_sys->p_context = p_context; p_sys->p_context = p_context;
p_sys->p_codec = p_codec; p_sys->p_codec = p_codec;
...@@ -552,6 +552,7 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) ...@@ -552,6 +552,7 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
{ {
int i_used, b_gotpicture; int i_used, b_gotpicture;
picture_t *p_pic; picture_t *p_pic;
AVPacket pkt;
/* Set the PTS/DTS in the context reordered_opaque field */ /* Set the PTS/DTS in the context reordered_opaque field */
if( p_block->i_pts > VLC_TS_INVALID ) if( p_block->i_pts > VLC_TS_INVALID )
...@@ -568,9 +569,11 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) ...@@ -568,9 +569,11 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
post_mt( p_sys ); post_mt( p_sys );
i_used = avcodec_decode_video( p_context, p_sys->p_ff_pic, av_init_packet( &pkt );
&b_gotpicture, pkt.data = p_block->p_buffer;
p_block->i_buffer <= 0 && p_sys->b_flush ? NULL : p_block->p_buffer, p_block->i_buffer ); pkt.size = p_block->i_buffer;
i_used = avcodec_decode_video2( p_context, p_sys->p_ff_pic,
&b_gotpicture, &pkt );
if( b_null_size && !p_sys->b_flush && if( b_null_size && !p_sys->b_flush &&
p_context->width > 0 && p_context->height > 0 ) p_context->width > 0 && p_context->height > 0 )
...@@ -579,9 +582,8 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) ...@@ -579,9 +582,8 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
b_null_size = false; b_null_size = false;
if( p_sys->b_hurry_up ) if( p_sys->b_hurry_up )
p_context->skip_frame = p_sys->i_skip_frame; p_context->skip_frame = p_sys->i_skip_frame;
i_used = avcodec_decode_video( p_context, p_sys->p_ff_pic, i_used = avcodec_decode_video2( p_context, p_sys->p_ff_pic,
&b_gotpicture, p_block->p_buffer, &b_gotpicture, &pkt );
p_block->i_buffer );
} }
wait_mt( p_sys ); wait_mt( p_sys );
......
...@@ -260,7 +260,7 @@ int OpenDemux( vlc_object_t *p_this ) ...@@ -260,7 +260,7 @@ int OpenDemux( vlc_object_t *p_this )
switch( cc->codec_type ) switch( cc->codec_type )
{ {
case CODEC_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
es_format_Init( &fmt, AUDIO_ES, fcc ); es_format_Init( &fmt, AUDIO_ES, fcc );
fmt.i_bitrate = cc->bit_rate; fmt.i_bitrate = cc->bit_rate;
fmt.audio.i_channels = cc->channels; fmt.audio.i_channels = cc->channels;
...@@ -270,7 +270,7 @@ int OpenDemux( vlc_object_t *p_this ) ...@@ -270,7 +270,7 @@ int OpenDemux( vlc_object_t *p_this )
psz_type = "audio"; psz_type = "audio";
break; break;
case CODEC_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
es_format_Init( &fmt, VIDEO_ES, fcc ); es_format_Init( &fmt, VIDEO_ES, fcc );
/* Special case for raw video data */ /* Special case for raw video data */
...@@ -301,7 +301,7 @@ int OpenDemux( vlc_object_t *p_this ) ...@@ -301,7 +301,7 @@ int OpenDemux( vlc_object_t *p_this )
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 );
break; break;
case CODEC_TYPE_SUBTITLE: case AVMEDIA_TYPE_SUBTITLE:
es_format_Init( &fmt, SPU_ES, fcc ); es_format_Init( &fmt, SPU_ES, fcc );
if( strncmp( p_sys->ic->iformat->name, "matroska", 8 ) == 0 && if( strncmp( p_sys->ic->iformat->name, "matroska", 8 ) == 0 &&
cc->codec_id == CODEC_ID_DVD_SUBTITLE && cc->codec_id == CODEC_ID_DVD_SUBTITLE &&
...@@ -351,33 +351,44 @@ int OpenDemux( vlc_object_t *p_this ) ...@@ -351,33 +351,44 @@ int OpenDemux( vlc_object_t *p_this )
default: default:
es_format_Init( &fmt, UNKNOWN_ES, 0 ); es_format_Init( &fmt, UNKNOWN_ES, 0 );
#ifdef HAVE_FFMPEG_CODEC_ATTACHMENT #ifdef HAVE_FFMPEG_CODEC_ATTACHMENT
if( cc->codec_type == CODEC_TYPE_ATTACHMENT ) if( cc->codec_type == AVMEDIA_TYPE_ATTACHMENT )
{ {
input_attachment_t *p_attachment; input_attachment_t *p_attachment;
psz_type = "attachment"; psz_type = "attachment";
if( cc->codec_id == CODEC_ID_TTF ) if( cc->codec_id == CODEC_ID_TTF )
{ {
p_attachment = vlc_input_attachment_New( s->filename, "application/x-truetype-font", NULL, AVMetadataTag *filename = av_metadata_get( s->metadata, "filename", NULL, 0 );
cc->extradata, (int)cc->extradata_size ); if( filename && filename->value )
TAB_APPEND( p_sys->i_attachments, p_sys->attachments, p_attachment ); {
p_attachment = vlc_input_attachment_New(
filename->value, "application/x-truetype-font",
NULL, cc->extradata, (int)cc->extradata_size );
TAB_APPEND( p_sys->i_attachments, p_sys->attachments,
p_attachment );
}
} }
else msg_Warn( p_demux, "unsupported attachment type in ffmpeg demux" ); else msg_Warn( p_demux, "unsupported attachment type in ffmpeg demux" );
} }
break; break;
#endif #endif
if( cc->codec_type == CODEC_TYPE_DATA ) if( cc->codec_type == AVMEDIA_TYPE_DATA )
psz_type = "data"; psz_type = "data";
msg_Warn( p_demux, "unsupported track type in ffmpeg demux" ); msg_Warn( p_demux, "unsupported track type in ffmpeg demux" );
break; break;
} }
fmt.psz_language = strdup( s->language );
AVMetadataTag *language = av_metadata_get( s->metadata, "language", NULL, 0 );
if ( language && language->value )
fmt.psz_language = strdup( language->value );
if( s->disposition & AV_DISPOSITION_DEFAULT ) if( s->disposition & AV_DISPOSITION_DEFAULT )
fmt.i_priority = 1000; fmt.i_priority = 1000;
#ifdef HAVE_FFMPEG_CODEC_ATTACHMENT #ifdef HAVE_FFMPEG_CODEC_ATTACHMENT
if( cc->codec_type != CODEC_TYPE_ATTACHMENT ) if( cc->codec_type != AVMEDIA_TYPE_ATTACHMENT )
#endif #endif
{ {
const bool b_ogg = !strcmp( p_sys->fmt->name, "ogg" ); const bool b_ogg = !strcmp( p_sys->fmt->name, "ogg" );
...@@ -466,9 +477,10 @@ int OpenDemux( vlc_object_t *p_this ) ...@@ -466,9 +477,10 @@ int OpenDemux( vlc_object_t *p_this )
{ {
seekpoint_t *s = vlc_seekpoint_New(); seekpoint_t *s = vlc_seekpoint_New();
if( p_sys->ic->chapters[i]->title ) AVMetadataTag *title = av_metadata_get( p_sys->ic->metadata, "title", NULL, 0);
if( title && title->value )
{ {
s->psz_name = strdup( p_sys->ic->chapters[i]->title ); s->psz_name = strdup( title->value );
EnsureUTF8( s->psz_name ); EnsureUTF8( s->psz_name );
msg_Dbg( p_demux, " - chapter %d: %s", i, s->psz_name ); msg_Dbg( p_demux, " - chapter %d: %s", i, s->psz_name );
} }
...@@ -551,7 +563,7 @@ static int Demux( demux_t *p_demux ) ...@@ -551,7 +563,7 @@ static int Demux( demux_t *p_demux )
memcpy( p_frame->p_buffer, pkt.data, pkt.size ); memcpy( p_frame->p_buffer, pkt.data, pkt.size );
} }
if( pkt.flags & PKT_FLAG_KEY ) if( pkt.flags & AV_PKT_FLAG_KEY )
p_frame->i_flags |= BLOCK_FLAG_TYPE_I; p_frame->i_flags |= BLOCK_FLAG_TYPE_I;
i_start_time = ( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE ) ? i_start_time = ( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE ) ?
...@@ -571,7 +583,7 @@ static int Demux( demux_t *p_demux ) ...@@ -571,7 +583,7 @@ static int Demux( demux_t *p_demux )
p_stream->time_base.den; p_stream->time_base.den;
if( pkt.dts != AV_NOPTS_VALUE && pkt.dts == pkt.pts && if( pkt.dts != AV_NOPTS_VALUE && pkt.dts == pkt.pts &&
p_stream->codec->codec_type == CODEC_TYPE_VIDEO ) p_stream->codec->codec_type == AVMEDIA_TYPE_VIDEO )
{ {
/* Add here notoriously bugged file formats/samples regarding PTS */ /* Add here notoriously bugged file formats/samples regarding PTS */
if( !strcmp( p_sys->fmt->name, "flv" ) ) if( !strcmp( p_sys->fmt->name, "flv" ) )
...@@ -752,16 +764,22 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -752,16 +764,22 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
{ {
vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* ); vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );
if( p_sys->ic->title[0] ) AVMetadataTag *title = av_metadata_get( p_sys->ic->metadata, "language", NULL, 0 );
vlc_meta_SetTitle( p_meta, p_sys->ic->title ); AVMetadataTag *author = av_metadata_get( p_sys->ic->metadata, "author", NULL, 0 );
if( p_sys->ic->author[0] ) AVMetadataTag *copyright = av_metadata_get( p_sys->ic->metadata, "copyright", NULL, 0 );
vlc_meta_SetArtist( p_meta, p_sys->ic->author ); AVMetadataTag *comment = av_metadata_get( p_sys->ic->metadata, "comment", NULL, 0 );
if( p_sys->ic->copyright[0] ) AVMetadataTag *genre = av_metadata_get( p_sys->ic->metadata, "genre", NULL, 0 );
vlc_meta_SetCopyright( p_meta, p_sys->ic->copyright );
if( p_sys->ic->comment[0] ) if( title && title->value )
vlc_meta_SetDescription( p_meta, p_sys->ic->comment ); vlc_meta_SetTitle( p_meta, title->value );
if( p_sys->ic->genre[0] ) if( author && author->value )
vlc_meta_SetGenre( p_meta, p_sys->ic->genre ); vlc_meta_SetArtist( p_meta, author->value );
if( copyright && copyright->value )
vlc_meta_SetCopyright( p_meta, copyright->value );
if( comment && comment->value )
vlc_meta_SetDescription( p_meta, comment->value );
if( genre && genre->value )
vlc_meta_SetGenre( p_meta, genre->value );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -96,12 +96,12 @@ int OpenMux( vlc_object_t *p_this ) ...@@ -96,12 +96,12 @@ int OpenMux( vlc_object_t *p_this )
psz_mux = var_GetNonEmptyString( p_mux, "ffmpeg-mux" ); psz_mux = var_GetNonEmptyString( p_mux, "ffmpeg-mux" );
if( psz_mux ) if( psz_mux )
{ {
file_oformat = guess_format( psz_mux, NULL, NULL ); file_oformat = av_guess_format( psz_mux, NULL, NULL );
} }
else else
{ {
file_oformat = file_oformat =
guess_format(NULL, p_mux->p_access->psz_path, NULL); av_guess_format(NULL, p_mux->p_access->psz_path, NULL);
} }
if (!file_oformat) if (!file_oformat)
{ {
...@@ -116,7 +116,7 @@ int OpenMux( vlc_object_t *p_this ) ...@@ -116,7 +116,7 @@ int OpenMux( vlc_object_t *p_this )
p_mux->pf_mux = Mux; p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) ); p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
p_sys->oc = av_alloc_format_context(); p_sys->oc = avformat_alloc_context();
p_sys->oc->oformat = file_oformat; p_sys->oc->oformat = file_oformat;
/* Create I/O wrapper */ /* Create I/O wrapper */
...@@ -225,7 +225,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -225,7 +225,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
switch( p_input->p_fmt->i_cat ) switch( p_input->p_fmt->i_cat )
{ {
case AUDIO_ES: case AUDIO_ES:
codec->codec_type = CODEC_TYPE_AUDIO; codec->codec_type = AVMEDIA_TYPE_AUDIO;
codec->channels = p_input->p_fmt->audio.i_channels; codec->channels = p_input->p_fmt->audio.i_channels;
codec->sample_rate = p_input->p_fmt->audio.i_rate; codec->sample_rate = p_input->p_fmt->audio.i_rate;
codec->time_base = (AVRational){1, codec->sample_rate}; codec->time_base = (AVRational){1, codec->sample_rate};
...@@ -240,7 +240,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -240,7 +240,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
p_input->p_fmt->video.i_frame_rate = 25; p_input->p_fmt->video.i_frame_rate = 25;
p_input->p_fmt->video.i_frame_rate_base = 1; p_input->p_fmt->video.i_frame_rate_base = 1;
} }
codec->codec_type = CODEC_TYPE_VIDEO; codec->codec_type = AVMEDIA_TYPE_VIDEO;
codec->width = p_input->p_fmt->video.i_width; codec->width = p_input->p_fmt->video.i_width;
codec->height = p_input->p_fmt->video.i_height; codec->height = p_input->p_fmt->video.i_height;
av_reduce( &codec->sample_aspect_ratio.num, av_reduce( &codec->sample_aspect_ratio.num,
...@@ -311,7 +311,7 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -311,7 +311,7 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
pkt.size = p_data->i_buffer; pkt.size = p_data->i_buffer;
pkt.stream_index = i_stream; pkt.stream_index = i_stream;
if( p_data->i_flags & BLOCK_FLAG_TYPE_I ) pkt.flags |= PKT_FLAG_KEY; if( p_data->i_flags & BLOCK_FLAG_TYPE_I ) pkt.flags |= AV_PKT_FLAG_KEY;
/* avformat expects pts/dts which start from 0 */ /* avformat expects pts/dts which start from 0 */
p_data->i_dts -= p_mux->p_sys->i_initial_dts; p_data->i_dts -= p_mux->p_sys->i_initial_dts;
......
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