Skip to content

Commit a90ff81

Browse files
committed
avcodec/ffv1enc: Factor set_micro_version() out of ff_ffv1_write_extradata()
and call it from ff_ffv1_encode_init() setting micro version from code writing the extradata is messy, this should be cleaner Signed-off-by: Michael Niedermayer <[email protected]>
1 parent e0aedeb commit a90ff81

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

libavcodec/ffv1enc.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,22 @@ static void write_header(FFV1Context *f)
392392
}
393393
}
394394

395+
static void set_micro_version(FFV1Context *f)
396+
{
397+
f->combined_version = f->version << 16;
398+
if (f->version > 2) {
399+
if (f->version == 3) {
400+
f->micro_version = 4;
401+
} else if (f->version == 4) {
402+
f->micro_version = 5;
403+
} else
404+
av_assert0(0);
405+
406+
f->combined_version += f->micro_version;
407+
} else
408+
av_assert0(f->micro_version == 0);
409+
}
410+
395411
av_cold int ff_ffv1_write_extradata(AVCodecContext *avctx)
396412
{
397413
FFV1Context *f = avctx->priv_data;
@@ -414,15 +430,8 @@ av_cold int ff_ffv1_write_extradata(AVCodecContext *avctx)
414430
ff_build_rac_states(&c, 0.05 * (1LL << 32), 256 - 8);
415431

416432
put_symbol(&c, state, f->version, 0);
417-
f->combined_version = f->version << 16;
418-
if (f->version > 2) {
419-
if (f->version == 3) {
420-
f->micro_version = 4;
421-
} else if (f->version == 4)
422-
f->micro_version = 5;
423-
f->combined_version += f->micro_version;
433+
if (f->version > 2)
424434
put_symbol(&c, state, f->micro_version, 0);
425-
}
426435

427436
put_symbol(&c, state, f->ac, 0);
428437
if (f->ac == AC_RANGE_CUSTOM_TAB)
@@ -742,6 +751,8 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx)
742751
s->num_v_slices = 1;
743752
}
744753

754+
set_micro_version(s);
755+
745756
return 0;
746757
}
747758

0 commit comments

Comments
 (0)