Skip to content

Commit b05cd1e

Browse files
committed
ffv1dec: Check bits_per_raw_sample and colorspace for equality in ver 0/1 headers
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
1 parent 0550734 commit b05cd1e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: libavcodec/ffv1dec.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ static int read_header(FFV1Context *f)
580580
memset(state, 128, sizeof(state));
581581

582582
if (f->version < 2) {
583-
int chroma_planes, chroma_h_shift, chroma_v_shift, transparency;
583+
int chroma_planes, chroma_h_shift, chroma_v_shift, transparency, colorspace, bits_per_raw_sample;
584584
unsigned v= get_symbol(c, state, 0);
585585
if (v >= 2) {
586586
av_log(f->avctx, AV_LOG_ERROR, "invalid version %d in ver01 header\n", v);
@@ -593,18 +593,17 @@ static int read_header(FFV1Context *f)
593593
f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i];
594594
}
595595

596-
f->colorspace = get_symbol(c, state, 0); //YUV cs type
597-
598-
if (f->version > 0)
599-
f->avctx->bits_per_raw_sample = get_symbol(c, state, 0);
600-
596+
colorspace = get_symbol(c, state, 0); //YUV cs type
597+
bits_per_raw_sample = f->version > 0 ? get_symbol(c, state, 0) : f->avctx->bits_per_raw_sample;
601598
chroma_planes = get_rac(c, state);
602599
chroma_h_shift = get_symbol(c, state, 0);
603600
chroma_v_shift = get_symbol(c, state, 0);
604601
transparency = get_rac(c, state);
605602

606603
if (f->plane_count) {
607-
if ( chroma_planes != f->chroma_planes
604+
if ( colorspace != f->colorspace
605+
|| bits_per_raw_sample != f->avctx->bits_per_raw_sample
606+
|| chroma_planes != f->chroma_planes
608607
|| chroma_h_shift!= f->chroma_h_shift
609608
|| chroma_v_shift!= f->chroma_v_shift
610609
|| transparency != f->transparency) {
@@ -613,6 +612,8 @@ static int read_header(FFV1Context *f)
613612
}
614613
}
615614

615+
f->colorspace = colorspace;
616+
f->avctx->bits_per_raw_sample = bits_per_raw_sample;
616617
f->chroma_planes = chroma_planes;
617618
f->chroma_h_shift = chroma_h_shift;
618619
f->chroma_v_shift = chroma_v_shift;

0 commit comments

Comments
 (0)