Commit 60217b5b authored by Michael Niedermayer's avatar Michael Niedermayer

ffv1: Remove slice count field with 1.3 and just count slices.

This field was problematic because in case of damaged slices it can be
lost
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 3ed6917a
...@@ -660,9 +660,8 @@ static void write_header(FFV1Context *f){ ...@@ -660,9 +660,8 @@ static void write_header(FFV1Context *f){
put_rac(c, state, f->transparency); put_rac(c, state, f->transparency);
write_quant_tables(c, f->quant_table); write_quant_tables(c, f->quant_table);
}else{ }else if(f->version < 3){
put_symbol(c, state, f->slice_count, 0); put_symbol(c, state, f->slice_count, 0);
if(f->version < 3){
for(i=0; i<f->slice_count; i++){ for(i=0; i<f->slice_count; i++){
FFV1Context *fs= f->slice_context[i]; FFV1Context *fs= f->slice_context[i];
put_symbol(c, state, (fs->slice_x +1)*f->num_h_slices / f->width , 0); put_symbol(c, state, (fs->slice_x +1)*f->num_h_slices / f->width , 0);
...@@ -674,7 +673,6 @@ static void write_header(FFV1Context *f){ ...@@ -674,7 +673,6 @@ static void write_header(FFV1Context *f){
av_assert0(f->plane[j].quant_table_index == f->avctx->context_model); av_assert0(f->plane[j].quant_table_index == f->avctx->context_model);
} }
} }
}
} }
} }
#endif /* CONFIG_FFV1_ENCODER */ #endif /* CONFIG_FFV1_ENCODER */
...@@ -1862,10 +1860,21 @@ static int read_header(FFV1Context *f){ ...@@ -1862,10 +1860,21 @@ static int read_header(FFV1Context *f){
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n"); av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
return -1; return -1;
} }
}else{ }else if(f->version < 3){
f->slice_count= get_symbol(c, state, 0); f->slice_count= get_symbol(c, state, 0);
if(f->slice_count > (unsigned)MAX_SLICES) }else{
return -1; const uint8_t *p= c->bytestream_end;
for(f->slice_count = 0; f->slice_count < MAX_SLICES && 3 < p - c->bytestream_start; f->slice_count++){
int trailer = 3 + 5*!!f->ec;
int size = AV_RB24(p-trailer);
if(size + trailer > p - c->bytestream_start)
break;
p -= size + trailer;
}
}
if(f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0){
av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid\n", f->slice_count);
return -1;
} }
for(j=0; j<f->slice_count; j++){ for(j=0; j<f->slice_count; j++){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment