[vlc-commits] avformat/mux: use AVCodecparameters (refs #18697)
Rémi Denis-Courmont
git at videolan.org
Sat Nov 4 09:38:07 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 4 10:31:57 2017 +0200| [9b5ad83a391f57c677d0247ebcebf098189100e6] | committer: Rémi Denis-Courmont
avformat/mux: use AVCodecparameters (refs #18697)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9b5ad83a391f57c677d0247ebcebf098189100e6
---
modules/demux/avformat/mux.c | 55 +++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 26 deletions(-)
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 3cc8ba97ad..f0affe0c2a 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -187,8 +187,6 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
const es_format_t *fmt = p_input->p_fmt;
- AVCodecContext *codec;
- AVStream *stream;
unsigned i_codec_id;
msg_Dbg( p_mux, "adding input" );
@@ -230,13 +228,18 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
*((int *)p_input->p_sys) = p_sys->oc->nb_streams;
/* */
- stream = avformat_new_stream( p_sys->oc, NULL);
+ AVStream *stream = avformat_new_stream( p_sys->oc, NULL);
if( !stream )
{
free( p_input->p_sys );
return VLC_EGENERIC;
}
- codec = stream->codec;
+
+#if (LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 5, 0))
+ AVCodecParameters *codecpar = stream->codecpar;
+#else
+ AVCodecContext *codecpar = stream->codec;
+#endif
unsigned int i_bitrate = fmt->i_bitrate;
unsigned int i_frame_rate = fmt->video.i_frame_rate;
@@ -244,10 +247,10 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
switch( fmt->i_cat )
{
case AUDIO_ES:
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->channels = fmt->audio.i_channels;
- codec->sample_rate = fmt->audio.i_rate;
- stream->time_base = (AVRational){1, codec->sample_rate};
+ codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ codecpar->channels = fmt->audio.i_channels;
+ codecpar->sample_rate = fmt->audio.i_rate;
+ stream->time_base = (AVRational){1, codecpar->sample_rate};
if (fmt->i_bitrate == 0) {
msg_Warn( p_mux, "Missing audio bitrate, assuming 64k" );
i_bitrate = 64000;
@@ -265,17 +268,17 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
fmt->video.i_frame_rate_base,
(double)fmt->video.i_frame_rate/(double)fmt->video.i_frame_rate_base );
- codec->codec_type = AVMEDIA_TYPE_VIDEO;
- codec->width = fmt->video.i_visible_width;
- codec->height = fmt->video.i_visible_height;
- av_reduce( &codec->sample_aspect_ratio.num,
- &codec->sample_aspect_ratio.den,
+ codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ codecpar->width = fmt->video.i_visible_width;
+ codecpar->height = fmt->video.i_visible_height;
+ av_reduce( &codecpar->sample_aspect_ratio.num,
+ &codecpar->sample_aspect_ratio.den,
fmt->video.i_sar_num,
fmt->video.i_sar_den, 1 << 30 /* something big */ );
msg_Dbg(p_mux, "Muxing aspect ratio will be %d/%d",
fmt->video.i_sar_num, fmt->video.i_sar_den);
- stream->sample_aspect_ratio.den = codec->sample_aspect_ratio.den;
- stream->sample_aspect_ratio.num = codec->sample_aspect_ratio.num;
+ stream->sample_aspect_ratio.den = codecpar->sample_aspect_ratio.den;
+ stream->sample_aspect_ratio.num = codecpar->sample_aspect_ratio.num;
stream->time_base.den = i_frame_rate;
stream->time_base.num = i_frame_rate_base;
if (fmt->i_bitrate == 0) {
@@ -289,28 +292,28 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
vlc_assert_unreachable();
}
- codec->bit_rate = i_bitrate;
- codec->codec_tag = av_codec_get_tag( p_sys->oc->oformat->codec_tag, i_codec_id );
- if( !codec->codec_tag && i_codec_id == AV_CODEC_ID_MP2 )
+ codecpar->bit_rate = i_bitrate;
+ codecpar->codec_tag = av_codec_get_tag( p_sys->oc->oformat->codec_tag, i_codec_id );
+ if( !codecpar->codec_tag && i_codec_id == AV_CODEC_ID_MP2 )
{
i_codec_id = AV_CODEC_ID_MP3;
- codec->codec_tag = av_codec_get_tag( p_sys->oc->oformat->codec_tag, i_codec_id );
+ codecpar->codec_tag = av_codec_get_tag( p_sys->oc->oformat->codec_tag, i_codec_id );
}
- codec->codec_id = i_codec_id;
+ codecpar->codec_id = i_codec_id;
if( fmt->i_extra )
{
if( fmt->i_codec == VLC_CODEC_OPUS )
{
- codec->extradata_size = opus_size[0];
- codec->extradata = av_malloc( opus_size[0] );
- memcpy( codec->extradata, opus_packet[0], opus_size[0] );
+ codecpar->extradata_size = opus_size[0];
+ codecpar->extradata = av_malloc( opus_size[0] );
+ memcpy( codecpar->extradata, opus_packet[0], opus_size[0] );
}
else
{
- codec->extradata_size = fmt->i_extra;
- codec->extradata = av_malloc( fmt->i_extra );
- memcpy( codec->extradata, fmt->p_extra, fmt->i_extra );
+ codecpar->extradata_size = fmt->i_extra;
+ codecpar->extradata = av_malloc( fmt->i_extra );
+ memcpy( codecpar->extradata, fmt->p_extra, fmt->i_extra );
}
}
More information about the vlc-commits
mailing list