Mercurial > libavcodec.hg
comparison snow.c @ 5666:b5c137f3f53a libavcodec
allow changing of the spatial_decomposition_count and quantization tables
per frame (this is untested as the encoder does not use it yet)
author | michael |
---|---|
date | Sun, 09 Sep 2007 15:06:46 +0000 |
parents | 834f359e7257 |
children | 9242e125395f |
comparison
equal
deleted
inserted
replaced
5665:834f359e7257 | 5666:b5c137f3f53a |
---|---|
3514 } | 3514 } |
3515 } | 3515 } |
3516 } | 3516 } |
3517 } | 3517 } |
3518 | 3518 |
3519 static void encode_qlogs(SnowContext *s){ | |
3520 int plane_index, level, orientation; | |
3521 | |
3522 for(plane_index=0; plane_index<2; plane_index++){ | |
3523 for(level=0; level<s->spatial_decomposition_count; level++){ | |
3524 for(orientation=level ? 1:0; orientation<4; orientation++){ | |
3525 if(orientation==2) continue; | |
3526 put_symbol(&s->c, s->header_state, s->plane[plane_index].band[level][orientation].qlog, 1); | |
3527 } | |
3528 } | |
3529 } | |
3530 } | |
3531 | |
3519 static void encode_header(SnowContext *s){ | 3532 static void encode_header(SnowContext *s){ |
3520 int plane_index, level, orientation, i; | 3533 int plane_index, i; |
3521 uint8_t kstate[32]; | 3534 uint8_t kstate[32]; |
3522 | 3535 |
3523 memset(kstate, MID_STATE, sizeof(kstate)); | 3536 memset(kstate, MID_STATE, sizeof(kstate)); |
3524 | 3537 |
3525 put_rac(&s->c, kstate, s->keyframe); | 3538 put_rac(&s->c, kstate, s->keyframe); |
3548 put_symbol(&s->c, s->header_state, s->chroma_v_shift, 0); | 3561 put_symbol(&s->c, s->header_state, s->chroma_v_shift, 0); |
3549 put_rac(&s->c, s->header_state, s->spatial_scalability); | 3562 put_rac(&s->c, s->header_state, s->spatial_scalability); |
3550 // put_rac(&s->c, s->header_state, s->rate_scalability); | 3563 // put_rac(&s->c, s->header_state, s->rate_scalability); |
3551 put_symbol(&s->c, s->header_state, s->max_ref_frames-1, 0); | 3564 put_symbol(&s->c, s->header_state, s->max_ref_frames-1, 0); |
3552 | 3565 |
3553 for(plane_index=0; plane_index<2; plane_index++){ | 3566 encode_qlogs(s); |
3554 for(level=0; level<s->spatial_decomposition_count; level++){ | |
3555 for(orientation=level ? 1:0; orientation<4; orientation++){ | |
3556 if(orientation==2) continue; | |
3557 put_symbol(&s->c, s->header_state, s->plane[plane_index].band[level][orientation].qlog, 1); | |
3558 } | |
3559 } | |
3560 } | |
3561 } | 3567 } |
3562 | 3568 |
3563 if(!s->keyframe){ | 3569 if(!s->keyframe){ |
3564 int update_mc=0; | 3570 int update_mc=0; |
3565 for(plane_index=0; plane_index<2; plane_index++){ | 3571 for(plane_index=0; plane_index<2; plane_index++){ |
3581 p->last_diag_mc= p->diag_mc; | 3587 p->last_diag_mc= p->diag_mc; |
3582 p->last_htaps= p->htaps; | 3588 p->last_htaps= p->htaps; |
3583 memcpy(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); | 3589 memcpy(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); |
3584 } | 3590 } |
3585 } | 3591 } |
3592 put_rac(&s->c, s->header_state, 0); | |
3593 if(0){ | |
3594 put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); | |
3595 encode_qlogs(s); | |
3596 } | |
3586 } | 3597 } |
3587 | 3598 |
3588 put_symbol(&s->c, s->header_state, s->spatial_decomposition_type - s->last_spatial_decomposition_type, 1); | 3599 put_symbol(&s->c, s->header_state, s->spatial_decomposition_type - s->last_spatial_decomposition_type, 1); |
3589 put_symbol(&s->c, s->header_state, s->qlog - s->last_qlog , 1); | 3600 put_symbol(&s->c, s->header_state, s->qlog - s->last_qlog , 1); |
3590 put_symbol(&s->c, s->header_state, s->mv_scale - s->last_mv_scale, 1); | 3601 put_symbol(&s->c, s->header_state, s->mv_scale - s->last_mv_scale, 1); |
3596 s->last_qbias = s->qbias; | 3607 s->last_qbias = s->qbias; |
3597 s->last_mv_scale = s->mv_scale; | 3608 s->last_mv_scale = s->mv_scale; |
3598 s->last_block_max_depth = s->block_max_depth; | 3609 s->last_block_max_depth = s->block_max_depth; |
3599 } | 3610 } |
3600 | 3611 |
3612 static void decode_qlogs(SnowContext *s){ | |
3613 int plane_index, level, orientation; | |
3614 | |
3615 for(plane_index=0; plane_index<3; plane_index++){ | |
3616 for(level=0; level<s->spatial_decomposition_count; level++){ | |
3617 for(orientation=level ? 1:0; orientation<4; orientation++){ | |
3618 int q; | |
3619 if (plane_index==2) q= s->plane[1].band[level][orientation].qlog; | |
3620 else if(orientation==2) q= s->plane[plane_index].band[level][1].qlog; | |
3621 else q= get_symbol(&s->c, s->header_state, 1); | |
3622 s->plane[plane_index].band[level][orientation].qlog= q; | |
3623 } | |
3624 } | |
3625 } | |
3626 } | |
3627 | |
3601 static int decode_header(SnowContext *s){ | 3628 static int decode_header(SnowContext *s){ |
3602 int plane_index, level, orientation; | 3629 int plane_index; |
3603 uint8_t kstate[32]; | 3630 uint8_t kstate[32]; |
3604 | 3631 |
3605 memset(kstate, MID_STATE, sizeof(kstate)); | 3632 memset(kstate, MID_STATE, sizeof(kstate)); |
3606 | 3633 |
3607 s->keyframe= get_rac(&s->c, kstate); | 3634 s->keyframe= get_rac(&s->c, kstate); |
3628 s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); | 3655 s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); |
3629 s->spatial_scalability= get_rac(&s->c, s->header_state); | 3656 s->spatial_scalability= get_rac(&s->c, s->header_state); |
3630 // s->rate_scalability= get_rac(&s->c, s->header_state); | 3657 // s->rate_scalability= get_rac(&s->c, s->header_state); |
3631 s->max_ref_frames= get_symbol(&s->c, s->header_state, 0)+1; | 3658 s->max_ref_frames= get_symbol(&s->c, s->header_state, 0)+1; |
3632 | 3659 |
3633 for(plane_index=0; plane_index<3; plane_index++){ | 3660 decode_qlogs(s); |
3634 for(level=0; level<s->spatial_decomposition_count; level++){ | |
3635 for(orientation=level ? 1:0; orientation<4; orientation++){ | |
3636 int q; | |
3637 if (plane_index==2) q= s->plane[1].band[level][orientation].qlog; | |
3638 else if(orientation==2) q= s->plane[plane_index].band[level][1].qlog; | |
3639 else q= get_symbol(&s->c, s->header_state, 1); | |
3640 s->plane[plane_index].band[level][orientation].qlog= q; | |
3641 } | |
3642 } | |
3643 } | |
3644 } | 3661 } |
3645 | 3662 |
3646 if(!s->keyframe){ | 3663 if(!s->keyframe){ |
3647 if(s->always_reset || get_rac(&s->c, s->header_state)){ | 3664 if(s->always_reset || get_rac(&s->c, s->header_state)){ |
3648 for(plane_index=0; plane_index<2; plane_index++){ | 3665 for(plane_index=0; plane_index<2; plane_index++){ |
3660 p->hcoeff[0]= 32-sum; | 3677 p->hcoeff[0]= 32-sum; |
3661 } | 3678 } |
3662 s->plane[2].diag_mc= s->plane[1].diag_mc; | 3679 s->plane[2].diag_mc= s->plane[1].diag_mc; |
3663 s->plane[2].htaps = s->plane[1].htaps; | 3680 s->plane[2].htaps = s->plane[1].htaps; |
3664 memcpy(s->plane[2].hcoeff, s->plane[1].hcoeff, sizeof(s->plane[1].hcoeff)); | 3681 memcpy(s->plane[2].hcoeff, s->plane[1].hcoeff, sizeof(s->plane[1].hcoeff)); |
3682 } | |
3683 if(get_rac(&s->c, s->header_state)){ | |
3684 s->spatial_decomposition_count= get_symbol(&s->c, s->header_state, 0); | |
3685 decode_qlogs(s); | |
3665 } | 3686 } |
3666 } | 3687 } |
3667 | 3688 |
3668 s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1); | 3689 s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1); |
3669 if(s->spatial_decomposition_type > 1){ | 3690 if(s->spatial_decomposition_type > 1){ |