History

ffv1dec: check that global parameters do not change in version 0/1

Such changes are neither allowed nor supported

Michael Niedermayer committed 13 years ago

Commit da7d8391 parent 3187fa11 file · +25 −7Browse files

Unified · Split

libavcodec/ffv1dec.c+25−7
@@ -550,6 +550,7 @@ static int read_header(FFV1Context *f) · 549 unmodified lines
550550 memset(state, 128, sizeof(state));
551551
552552 if (f->version < 2) {
553+ int chroma_planes, chroma_h_shift, chroma_v_shift, transparency, colorspace, bits_per_raw_sample;
553554 unsigned v = get_symbol(c, state, 0);
554555 if (v > 1) {
555556 av_log(f->avctx, AV_LOG_ERROR,
@@ -566,15 +567,32 @@ static int read_header(FFV1Context *f) · 10 unmodified lines
566567 get_symbol(c, state, 1) + c->one_state[i];
567568 }
568569
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+ }
570588
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;
573595
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);
578596 f->plane_count = 2 + f->transparency;
579597 }
580598

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t