summaryrefslogtreecommitdiff
path: root/libavformat/nutenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-11-15 09:46:05 +0100
committerAnton Khirnov <anton@khirnov.net>2015-01-27 09:15:07 +0100
commit80a11de7dca315505bf203ce9c8c016e71724fd2 (patch)
tree343d5d5268ed0613ea391ae742f36786af74e818 /libavformat/nutenc.c
parente44b58924fe7b180bf8b0c277c15d1a58210a0e9 (diff)
nutenc: do not use has_b_frames
It is unreliable, especially when the stream codec context is not the encoding context. Use the codec descriptor properties instead.
Diffstat (limited to 'libavformat/nutenc.c')
-rw-r--r--libavformat/nutenc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 08907ef489..3b43954dbd 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -170,6 +170,7 @@ static void build_frame_code(AVFormatContext *s)
int start2 = start + (end - start) * stream_id / s->nb_streams;
int end2 = start + (end - start) * (stream_id + 1) / s->nb_streams;
AVCodecContext *codec = s->streams[stream_id]->codec;
+ const AVCodecDescriptor *desc = avcodec_descriptor_get(codec->codec_id);
int is_audio = codec->codec_type == AVMEDIA_TYPE_AUDIO;
int intra_only = /*codec->intra_only || */ is_audio;
int pred_count;
@@ -212,7 +213,7 @@ static void build_frame_code(AVFormatContext *s)
start2++;
}
- if (codec->has_b_frames) {
+ if (desc && desc->props & AV_CODEC_PROP_REORDER) {
pred_count = 5;
pred_table[0] = -2;
pred_table[1] = -1;
@@ -417,6 +418,7 @@ static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc,
{
NUTContext *nut = avctx->priv_data;
AVCodecContext *codec = st->codec;
+ const AVCodecDescriptor *desc = avcodec_descriptor_get(codec->codec_id);
unsigned codec_tag = av_codec_get_tag(ff_nut_codec_tags, codec->codec_id);
ff_put_v(bc, i);
@@ -449,7 +451,7 @@ static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc,
ff_put_v(bc, nut->stream[i].time_base - nut->time_base);
ff_put_v(bc, nut->stream[i].msb_pts_shift);
ff_put_v(bc, nut->stream[i].max_pts_distance);
- ff_put_v(bc, codec->has_b_frames);
+ ff_put_v(bc, (desc && desc->props & AV_CODEC_PROP_REORDER) ? 16 : 0);
avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
ff_put_v(bc, codec->extradata_size);