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.
pull/115/head
Anton Khirnov 10 years ago
parent e44b58924f
commit 80a11de7dc
  1. 6
      libavformat/nutenc.c
  2. 4
      tests/ref/lavf/nut
  3. 54
      tests/ref/seek/lavf-nut

@ -170,6 +170,7 @@ static void build_frame_code(AVFormatContext *s)
int start2 = start + (end - start) * stream_id / s->nb_streams; int start2 = start + (end - start) * stream_id / s->nb_streams;
int end2 = start + (end - start) * (stream_id + 1) / s->nb_streams; int end2 = start + (end - start) * (stream_id + 1) / s->nb_streams;
AVCodecContext *codec = s->streams[stream_id]->codec; 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 is_audio = codec->codec_type == AVMEDIA_TYPE_AUDIO;
int intra_only = /*codec->intra_only || */ is_audio; int intra_only = /*codec->intra_only || */ is_audio;
int pred_count; int pred_count;
@ -212,7 +213,7 @@ static void build_frame_code(AVFormatContext *s)
start2++; start2++;
} }
if (codec->has_b_frames) { if (desc && desc->props & AV_CODEC_PROP_REORDER) {
pred_count = 5; pred_count = 5;
pred_table[0] = -2; pred_table[0] = -2;
pred_table[1] = -1; pred_table[1] = -1;
@ -417,6 +418,7 @@ static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc,
{ {
NUTContext *nut = avctx->priv_data; NUTContext *nut = avctx->priv_data;
AVCodecContext *codec = st->codec; 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); unsigned codec_tag = av_codec_get_tag(ff_nut_codec_tags, codec->codec_id);
ff_put_v(bc, i); 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].time_base - nut->time_base);
ff_put_v(bc, nut->stream[i].msb_pts_shift); ff_put_v(bc, nut->stream[i].msb_pts_shift);
ff_put_v(bc, nut->stream[i].max_pts_distance); 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 */ avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
ff_put_v(bc, codec->extradata_size); ff_put_v(bc, codec->extradata_size);

@ -1,3 +1,3 @@
8c9d5193a672ad0dee90f0712acc3a31 *./tests/data/lavf/lavf.nut d685d5af89cfddb2660f03b1dee3f9a2 *./tests/data/lavf/lavf.nut
319680 ./tests/data/lavf/lavf.nut 319711 ./tests/data/lavf/lavf.nut
./tests/data/lavf/lavf.nut CRC=0x4c963cda ./tests/data/lavf/lavf.nut CRC=0x4c963cda

@ -1,53 +1,53 @@
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st:-1 flags:0 ts:-1.000000 ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st:-1 flags:1 ts: 1.894167 ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 0 flags:0 ts: 0.800000 ret: 0 st: 0 flags:0 ts: 0.800000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 0 flags:1 ts:-0.320000 ret: 0 st: 0 flags:1 ts:-0.320000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st: 1 flags:0 ts: 2.586122 ret: 0 st: 1 flags:0 ts: 2.586122
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 1 flags:1 ts: 1.462857 ret: 0 st: 1 flags:1 ts: 1.462857
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st:-1 flags:0 ts: 0.365002 ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st:-1 flags:1 ts:-0.740831 ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st: 0 flags:0 ts: 2.160000 ret: 0 st: 0 flags:0 ts: 2.160000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 0 flags:1 ts: 1.040000 ret: 0 st: 0 flags:1 ts: 1.040000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 1 flags:0 ts:-0.052245 ret: 0 st: 1 flags:0 ts:-0.052245
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st: 1 flags:1 ts: 2.847347 ret: 0 st: 1 flags:1 ts: 2.847347
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st:-1 flags:0 ts: 1.730004 ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st:-1 flags:1 ts: 0.624171 ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 0 flags:0 ts:-0.480000 ret: 0 st: 0 flags:0 ts:-0.480000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st: 0 flags:1 ts: 2.400000 ret: 0 st: 0 flags:1 ts: 2.400000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 1 flags:0 ts: 1.306122 ret: 0 st: 1 flags:0 ts: 1.306122
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 1 flags:1 ts: 0.208980 ret: 0 st: 1 flags:1 ts: 0.208980
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st:-1 flags:0 ts:-0.904994 ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st:-1 flags:1 ts: 1.989173 ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 0 flags:0 ts: 0.880000 ret: 0 st: 0 flags:0 ts: 0.880000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 0 flags:1 ts:-0.240000 ret: 0 st: 0 flags:1 ts:-0.240000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837
ret: 0 st: 1 flags:0 ts: 2.664490 ret: 0 st: 1 flags:0 ts: 2.664490
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st: 1 flags:1 ts: 1.567347 ret: 0 st: 1 flags:1 ts: 1.567347
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st:-1 flags:0 ts: 0.460008 ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146353 size: 27925
ret: 0 st:-1 flags:1 ts:-0.645825 ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 295 size: 27837

Loading…
Cancel
Save