comparison snow.c @ 9367:b32ece43b8a2 libavcodec

Factorize check of read symbols.
author michael
date Thu, 09 Apr 2009 18:21:51 +0000
parents 48eb9ec4e318
children 86decbea7c1c
comparison
equal deleted inserted replaced
9366:48eb9ec4e318 9367:b32ece43b8a2
3551 } 3551 }
3552 } 3552 }
3553 } 3553 }
3554 } 3554 }
3555 3555
3556 #define GET_S(dst, check) \
3557 tmp= get_symbol(&s->c, s->header_state, 0);\
3558 if(!(check)){\
3559 av_log(s->avctx, AV_LOG_ERROR, "Error " #dst " is %d\n", tmp);\
3560 return -1;\
3561 }\
3562 dst= tmp;
3563
3556 static int decode_header(SnowContext *s){ 3564 static int decode_header(SnowContext *s){
3557 int plane_index, tmp; 3565 int plane_index, tmp;
3558 uint8_t kstate[32]; 3566 uint8_t kstate[32];
3559 3567
3560 memset(kstate, MID_STATE, sizeof(kstate)); 3568 memset(kstate, MID_STATE, sizeof(kstate));
3568 s->mv_scale= 3576 s->mv_scale=
3569 s->block_max_depth= 0; 3577 s->block_max_depth= 0;
3570 } 3578 }
3571 if(s->keyframe){ 3579 if(s->keyframe){
3572 s->version= get_symbol(&s->c, s->header_state, 0); 3580 s->version= get_symbol(&s->c, s->header_state, 0);
3573 if(s->version>0){ 3581 GET_S(s->version, tmp <= 0U)
3574 av_log(s->avctx, AV_LOG_ERROR, "version %d not supported", s->version);
3575 return -1;
3576 }
3577 s->always_reset= get_rac(&s->c, s->header_state); 3582 s->always_reset= get_rac(&s->c, s->header_state);
3578 s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0); 3583 s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0);
3579 s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0); 3584 s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0);
3580 s->spatial_decomposition_count= get_symbol(&s->c, s->header_state, 0); 3585 s->spatial_decomposition_count= get_symbol(&s->c, s->header_state, 0);
3581 s->colorspace_type= get_symbol(&s->c, s->header_state, 0); 3586 s->colorspace_type= get_symbol(&s->c, s->header_state, 0);
3582 s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0); 3587 s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0);
3583 s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); 3588 s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0);
3584 s->spatial_scalability= get_rac(&s->c, s->header_state); 3589 s->spatial_scalability= get_rac(&s->c, s->header_state);
3585 // s->rate_scalability= get_rac(&s->c, s->header_state); 3590 // s->rate_scalability= get_rac(&s->c, s->header_state);
3586 tmp= get_symbol(&s->c, s->header_state, 0)+1; 3591 GET_S(s->max_ref_frames, tmp < (unsigned)MAX_REF_FRAMES)
3587 if(tmp < 1 || tmp > MAX_REF_FRAMES){ 3592 s->max_ref_frames++;
3588 av_log(s->avctx, AV_LOG_ERROR, "reference frame count is %d\n", tmp);
3589 return -1;
3590 }
3591 s->max_ref_frames= tmp;
3592 3593
3593 decode_qlogs(s); 3594 decode_qlogs(s);
3594 } 3595 }
3595 3596
3596 if(!s->keyframe){ 3597 if(!s->keyframe){