| 1586 | } |
| 1587 | |
| 1588 | static void encode_header(SnowContext *s){ |
| 1589 | int plane_index, i; |
| 1590 | uint8_t kstate[32]; |
| 1591 | |
| 1592 | memset(kstate, MID_STATE, sizeof(kstate)); |
| 1593 | |
| 1594 | put_rac(&s->c, kstate, s->keyframe); |
| 1595 | if(s->keyframe || s->always_reset){ |
| 1596 | ff_snow_reset_contexts(s); |
| 1597 | s->last_spatial_decomposition_type= |
| 1598 | s->last_qlog= |
| 1599 | s->last_qbias= |
| 1600 | s->last_mv_scale= |
| 1601 | s->last_block_max_depth= 0; |
| 1602 | for(plane_index=0; plane_index<2; plane_index++){ |
| 1603 | Plane *p= &s->plane[plane_index]; |
| 1604 | p->last_htaps=0; |
| 1605 | p->last_diag_mc=0; |
| 1606 | memset(p->last_hcoeff, 0, sizeof(p->last_hcoeff)); |
| 1607 | } |
| 1608 | } |
| 1609 | if(s->keyframe){ |
| 1610 | put_symbol(&s->c, s->header_state, s->version, 0); |
| 1611 | put_rac(&s->c, s->header_state, s->always_reset); |
| 1612 | put_symbol(&s->c, s->header_state, s->temporal_decomposition_type, 0); |
| 1613 | put_symbol(&s->c, s->header_state, s->temporal_decomposition_count, 0); |
| 1614 | put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); |
| 1615 | put_symbol(&s->c, s->header_state, s->colorspace_type, 0); |
| 1616 | if (s->nb_planes > 2) { |
| 1617 | put_symbol(&s->c, s->header_state, s->chroma_h_shift, 0); |
| 1618 | put_symbol(&s->c, s->header_state, s->chroma_v_shift, 0); |
| 1619 | } |
| 1620 | put_rac(&s->c, s->header_state, s->spatial_scalability); |
| 1621 | // put_rac(&s->c, s->header_state, s->rate_scalability); |
| 1622 | put_symbol(&s->c, s->header_state, s->max_ref_frames-1, 0); |
| 1623 | |
| 1624 | encode_qlogs(s); |
| 1625 | } |
| 1626 | |
| 1627 | if(!s->keyframe){ |
| 1628 | int update_mc=0; |
| 1629 | for(plane_index=0; plane_index<FFMIN(s->nb_planes, 2); plane_index++){ |
| 1630 | Plane *p= &s->plane[plane_index]; |
| 1631 | update_mc |= p->last_htaps != p->htaps; |
| 1632 | update_mc |= p->last_diag_mc != p->diag_mc; |
| 1633 | update_mc |= !!memcmp(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); |
| 1634 | } |
| 1635 | put_rac(&s->c, s->header_state, update_mc); |
| 1636 | if(update_mc){ |
| 1637 | for(plane_index=0; plane_index<FFMIN(s->nb_planes, 2); plane_index++){ |
| 1638 | Plane *p= &s->plane[plane_index]; |
| 1639 | put_rac(&s->c, s->header_state, p->diag_mc); |
| 1640 | put_symbol(&s->c, s->header_state, p->htaps/2-1, 0); |
| 1641 | for(i= p->htaps/2; i; i--) |
| 1642 | put_symbol(&s->c, s->header_state, FFABS(p->hcoeff[i]), 0); |
| 1643 | } |
| 1644 | } |
| 1645 | if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){ |
no test coverage detected