| 3524 | } |
| 3525 | |
| 3526 | static void encode_header(SnowContext *s){ |
| 3527 | int plane_index, i; |
| 3528 | uint8_t kstate[32]; |
| 3529 | |
| 3530 | memset(kstate, MID_STATE, sizeof(kstate)); |
| 3531 | |
| 3532 | put_rac(&s->c, kstate, s->keyframe); |
| 3533 | if(s->keyframe || s->always_reset){ |
| 3534 | reset_contexts(s); |
| 3535 | s->last_spatial_decomposition_type= |
| 3536 | s->last_qlog= |
| 3537 | s->last_qbias= |
| 3538 | s->last_mv_scale= |
| 3539 | s->last_block_max_depth= 0; |
| 3540 | for(plane_index=0; plane_index<2; plane_index++){ |
| 3541 | Plane *p= &s->plane[plane_index]; |
| 3542 | p->last_htaps=0; |
| 3543 | p->last_diag_mc=0; |
| 3544 | memset(p->last_hcoeff, 0, sizeof(p->last_hcoeff)); |
| 3545 | } |
| 3546 | } |
| 3547 | if(s->keyframe){ |
| 3548 | put_symbol(&s->c, s->header_state, s->version, 0); |
| 3549 | put_rac(&s->c, s->header_state, s->always_reset); |
| 3550 | put_symbol(&s->c, s->header_state, s->temporal_decomposition_type, 0); |
| 3551 | put_symbol(&s->c, s->header_state, s->temporal_decomposition_count, 0); |
| 3552 | put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); |
| 3553 | put_symbol(&s->c, s->header_state, s->colorspace_type, 0); |
| 3554 | put_symbol(&s->c, s->header_state, s->chroma_h_shift, 0); |
| 3555 | put_symbol(&s->c, s->header_state, s->chroma_v_shift, 0); |
| 3556 | put_rac(&s->c, s->header_state, s->spatial_scalability); |
| 3557 | // put_rac(&s->c, s->header_state, s->rate_scalability); |
| 3558 | put_symbol(&s->c, s->header_state, s->max_ref_frames-1, 0); |
| 3559 | |
| 3560 | encode_qlogs(s); |
| 3561 | } |
| 3562 | |
| 3563 | if(!s->keyframe){ |
| 3564 | int update_mc=0; |
| 3565 | for(plane_index=0; plane_index<2; plane_index++){ |
| 3566 | Plane *p= &s->plane[plane_index]; |
| 3567 | update_mc |= p->last_htaps != p->htaps; |
| 3568 | update_mc |= p->last_diag_mc != p->diag_mc; |
| 3569 | update_mc |= !!memcmp(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); |
| 3570 | } |
| 3571 | put_rac(&s->c, s->header_state, update_mc); |
| 3572 | if(update_mc){ |
| 3573 | for(plane_index=0; plane_index<2; plane_index++){ |
| 3574 | Plane *p= &s->plane[plane_index]; |
| 3575 | put_rac(&s->c, s->header_state, p->diag_mc); |
| 3576 | put_symbol(&s->c, s->header_state, p->htaps/2-1, 0); |
| 3577 | for(i= p->htaps/2; i; i--) |
| 3578 | put_symbol(&s->c, s->header_state, FFABS(p->hcoeff[i]), 0); |
| 3579 | } |
| 3580 | } |
| 3581 | if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){ |
| 3582 | put_rac(&s->c, s->header_state, 1); |
| 3583 | put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); |
no test coverage detected