aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-08-12 20:28:37 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-08-12 20:28:37 +0200
commit497d66126242a94c32c146434e543ee2833e6349 (patch)
treeaf57a50fe5a4cb179cf491833407cfd3bd4cef0f
parent8044ab94e485d2c40ff8d87a7907f31ed2ebc997 (diff)
parentb5d7b80a7e43779ca2962ba56442579c2a7e927d (diff)
downloadffmpeg-497d66126242a94c32c146434e543ee2833e6349.tar.gz
Merge commit 'b5d7b80a7e43779ca2962ba56442579c2a7e927d' into release/0.10
* commit 'b5d7b80a7e43779ca2962ba56442579c2a7e927d': ffv1dec: check that global parameters do not change in version 0/1 Conflicts: libavcodec/ffv1.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/ffv1.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index e2301e6ce3..fd3e4f70b5 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -1551,20 +1551,48 @@ static int read_header(FFV1Context *f){
memset(state, 128, sizeof(state));
if(f->version < 2){
- f->version= get_symbol(c, state, 0);
- f->ac= f->avctx->coder_type= get_symbol(c, state, 0);
- if(f->ac>1){
- for(i=1; i<256; i++){
- f->state_transition[i]= get_symbol(c, state, 1) + c->one_state[i];
- }
+ int chroma_h_shift, chroma_v_shift, colorspace, bits_per_raw_sample;
+ int transparency;
+ unsigned v = get_symbol(c, state, 0);
+ if (v > 1) {
+ av_log(f->avctx, AV_LOG_ERROR,
+ "invalid version %d in version 1 header\n", v);
+ return AVERROR_INVALIDDATA;
}
- f->colorspace= get_symbol(c, state, 0); //YUV cs type
- if(f->version>0)
- f->avctx->bits_per_raw_sample= get_symbol(c, state, 0);
+ f->version = v;
+
+ f->ac = f->avctx->coder_type = get_symbol(c, state, 0);
+
+ if (f->ac > 1) {
+ for (i = 1; i < 256; i++)
+ f->state_transition[i] =
+ get_symbol(c, state, 1) + c->one_state[i];
+ }
+
+ colorspace = get_symbol(c, state, 0); //YUV cs type
+ bits_per_raw_sample = f->version > 0 ? get_symbol(c, state, 0) : f->avctx->bits_per_raw_sample;
get_rac(c, state); //no chroma = false
- f->chroma_h_shift= get_symbol(c, state, 0);
- f->chroma_v_shift= get_symbol(c, state, 0);
- f->transparency= get_rac(c, state);
+ chroma_h_shift = get_symbol(c, state, 0);
+ chroma_v_shift = get_symbol(c, state, 0);
+ transparency = get_rac(c, state);
+
+ if (f->plane_count) {
+ if (colorspace != f->colorspace ||
+ bits_per_raw_sample != f->avctx->bits_per_raw_sample ||
+ chroma_h_shift != f->chroma_h_shift ||
+ chroma_v_shift != f->chroma_v_shift ||
+ transparency != f->transparency) {
+ av_log(f->avctx, AV_LOG_ERROR, "Invalid change of global parameters\n");
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
+ f->colorspace = colorspace;
+ f->avctx->bits_per_raw_sample = bits_per_raw_sample;
+ f->chroma_h_shift = chroma_h_shift;
+ f->chroma_v_shift = chroma_v_shift;
+ f->transparency = transparency;
+
f->plane_count= 2 + f->transparency;
}