@@ -550,6 +550,7 @@ static int read_header(FFV1Context *f)
550
550
memset (state , 128 , sizeof (state ));
551
551
552
552
if (f -> version < 2 ) {
553
+ int chroma_planes , chroma_h_shift , chroma_v_shift , transparency , colorspace , bits_per_raw_sample ;
553
554
unsigned v = get_symbol (c , state , 0 );
554
555
if (v > 1 ) {
555
556
av_log (f -> avctx , AV_LOG_ERROR ,
@@ -566,15 +567,32 @@ static int read_header(FFV1Context *f)
566
567
get_symbol (c , state , 1 ) + c -> one_state [i ];
567
568
}
568
569
569
- f -> colorspace = get_symbol (c , state , 0 ); //YUV cs type
570
+ colorspace = get_symbol (c , state , 0 ); //YUV cs type
571
+ bits_per_raw_sample = f -> version > 0 ? get_symbol (c , state , 0 ) : f -> avctx -> bits_per_raw_sample ;
572
+ chroma_planes = get_rac (c , state );
573
+ chroma_h_shift = get_symbol (c , state , 0 );
574
+ chroma_v_shift = get_symbol (c , state , 0 );
575
+ transparency = get_rac (c , state );
576
+
577
+ if (f -> plane_count ) {
578
+ if (colorspace != f -> colorspace ||
579
+ bits_per_raw_sample != f -> avctx -> bits_per_raw_sample ||
580
+ chroma_planes != f -> chroma_planes ||
581
+ chroma_h_shift != f -> chroma_h_shift ||
582
+ chroma_v_shift != f -> chroma_v_shift ||
583
+ transparency != f -> transparency ) {
584
+ av_log (f -> avctx , AV_LOG_ERROR , "Invalid change of global parameters\n" );
585
+ return AVERROR_INVALIDDATA ;
586
+ }
587
+ }
570
588
571
- if (f -> version > 0 )
572
- f -> avctx -> bits_per_raw_sample = get_symbol (c , state , 0 );
589
+ f -> colorspace = colorspace ;
590
+ f -> avctx -> bits_per_raw_sample = bits_per_raw_sample ;
591
+ f -> chroma_planes = chroma_planes ;
592
+ f -> chroma_h_shift = chroma_h_shift ;
593
+ f -> chroma_v_shift = chroma_v_shift ;
594
+ f -> transparency = transparency ;
573
595
574
- f -> chroma_planes = get_rac (c , state );
575
- f -> chroma_h_shift = get_symbol (c , state , 0 );
576
- f -> chroma_v_shift = get_symbol (c , state , 0 );
577
- f -> transparency = get_rac (c , state );
578
596
f -> plane_count = 2 + f -> transparency ;
579
597
}
580
598
0 commit comments