Mercurial > libavcodec.hg
comparison snow.c @ 5670:2f3431b34f0f libavcodec
make changing spatial_decomposition_count per frame work
author | michael |
---|---|
date | Sun, 09 Sep 2007 18:28:36 +0000 |
parents | 52aae8c63b30 |
children | 72c65bca55db |
comparison
equal
deleted
inserted
replaced
5669:d540c7d88344 | 5670:2f3431b34f0f |
---|---|
452 int version; | 452 int version; |
453 int spatial_decomposition_type; | 453 int spatial_decomposition_type; |
454 int last_spatial_decomposition_type; | 454 int last_spatial_decomposition_type; |
455 int temporal_decomposition_type; | 455 int temporal_decomposition_type; |
456 int spatial_decomposition_count; | 456 int spatial_decomposition_count; |
457 int last_spatial_decomposition_count; | |
457 int temporal_decomposition_count; | 458 int temporal_decomposition_count; |
458 int max_ref_frames; | 459 int max_ref_frames; |
459 int ref_frames; | 460 int ref_frames; |
460 int16_t (*ref_mvs[MAX_REF_FRAMES])[2]; | 461 int16_t (*ref_mvs[MAX_REF_FRAMES])[2]; |
461 uint32_t *ref_scores[MAX_REF_FRAMES]; | 462 uint32_t *ref_scores[MAX_REF_FRAMES]; |
3586 p->last_diag_mc= p->diag_mc; | 3587 p->last_diag_mc= p->diag_mc; |
3587 p->last_htaps= p->htaps; | 3588 p->last_htaps= p->htaps; |
3588 memcpy(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); | 3589 memcpy(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); |
3589 } | 3590 } |
3590 } | 3591 } |
3591 put_rac(&s->c, s->header_state, 0); | 3592 if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){ |
3592 if(0){ | 3593 put_rac(&s->c, s->header_state, 1); |
3593 put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); | 3594 put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); |
3594 encode_qlogs(s); | 3595 encode_qlogs(s); |
3595 } | 3596 }else |
3597 put_rac(&s->c, s->header_state, 0); | |
3596 } | 3598 } |
3597 | 3599 |
3598 put_symbol(&s->c, s->header_state, s->spatial_decomposition_type - s->last_spatial_decomposition_type, 1); | 3600 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->qlog - s->last_qlog , 1); | 3601 put_symbol(&s->c, s->header_state, s->qlog - s->last_qlog , 1); |
3600 put_symbol(&s->c, s->header_state, s->mv_scale - s->last_mv_scale, 1); | 3602 put_symbol(&s->c, s->header_state, s->mv_scale - s->last_mv_scale, 1); |
3604 s->last_spatial_decomposition_type= s->spatial_decomposition_type; | 3606 s->last_spatial_decomposition_type= s->spatial_decomposition_type; |
3605 s->last_qlog = s->qlog; | 3607 s->last_qlog = s->qlog; |
3606 s->last_qbias = s->qbias; | 3608 s->last_qbias = s->qbias; |
3607 s->last_mv_scale = s->mv_scale; | 3609 s->last_mv_scale = s->mv_scale; |
3608 s->last_block_max_depth = s->block_max_depth; | 3610 s->last_block_max_depth = s->block_max_depth; |
3611 s->last_spatial_decomposition_count= s->spatial_decomposition_count; | |
3609 } | 3612 } |
3610 | 3613 |
3611 static void decode_qlogs(SnowContext *s){ | 3614 static void decode_qlogs(SnowContext *s){ |
3612 int plane_index, level, orientation; | 3615 int plane_index, level, orientation; |
3613 | 3616 |
3935 && avctx->global_quality == 0){ | 3938 && avctx->global_quality == 0){ |
3936 av_log(avctx, AV_LOG_ERROR, "the 9/7 wavelet is incompatible with lossless mode\n"); | 3939 av_log(avctx, AV_LOG_ERROR, "the 9/7 wavelet is incompatible with lossless mode\n"); |
3937 return -1; | 3940 return -1; |
3938 } | 3941 } |
3939 | 3942 |
3940 s->spatial_decomposition_count= 5; | |
3941 s->spatial_decomposition_type= avctx->prediction_method; //FIXME add decorrelator type r transform_type | 3943 s->spatial_decomposition_type= avctx->prediction_method; //FIXME add decorrelator type r transform_type |
3942 | 3944 |
3943 s->chroma_h_shift= 1; //FIXME XXX | 3945 s->chroma_h_shift= 1; //FIXME XXX |
3944 s->chroma_v_shift= 1; | 3946 s->chroma_v_shift= 1; |
3945 | 3947 |
3954 s->plane[plane_index].hcoeff[2]= 2; | 3956 s->plane[plane_index].hcoeff[2]= 2; |
3955 s->plane[plane_index].fast_mc= 1; | 3957 s->plane[plane_index].fast_mc= 1; |
3956 } | 3958 } |
3957 | 3959 |
3958 common_init(avctx); | 3960 common_init(avctx); |
3959 common_init_after_header(avctx); | |
3960 alloc_blocks(s); | 3961 alloc_blocks(s); |
3961 | 3962 |
3962 s->version=0; | 3963 s->version=0; |
3963 | 3964 |
3964 s->m.avctx = avctx; | 3965 s->m.avctx = avctx; |
3980 if((avctx->flags&CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){ | 3981 if((avctx->flags&CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){ |
3981 if(ff_rate_control_init(&s->m) < 0) | 3982 if(ff_rate_control_init(&s->m) < 0) |
3982 return -1; | 3983 return -1; |
3983 } | 3984 } |
3984 s->pass1_rc= !(avctx->flags & (CODEC_FLAG_QSCALE|CODEC_FLAG_PASS2)); | 3985 s->pass1_rc= !(avctx->flags & (CODEC_FLAG_QSCALE|CODEC_FLAG_PASS2)); |
3985 | |
3986 for(plane_index=0; plane_index<3; plane_index++){ | |
3987 calculate_vissual_weight(s, &s->plane[plane_index]); | |
3988 } | |
3989 | |
3990 | 3986 |
3991 avctx->coded_frame= &s->current_picture; | 3987 avctx->coded_frame= &s->current_picture; |
3992 switch(avctx->pix_fmt){ | 3988 switch(avctx->pix_fmt){ |
3993 // case PIX_FMT_YUV444P: | 3989 // case PIX_FMT_YUV444P: |
3994 // case PIX_FMT_YUV422P: | 3990 // case PIX_FMT_YUV422P: |
4211 memcpy(rc_block_bak, s->block_state, sizeof(s->block_state)); | 4207 memcpy(rc_block_bak, s->block_state, sizeof(s->block_state)); |
4212 } | 4208 } |
4213 | 4209 |
4214 redo_frame: | 4210 redo_frame: |
4215 | 4211 |
4212 if(pict->pict_type == I_TYPE) | |
4213 s->spatial_decomposition_count= 5; | |
4214 else | |
4215 s->spatial_decomposition_count= 5; | |
4216 | |
4216 s->m.pict_type = pict->pict_type; | 4217 s->m.pict_type = pict->pict_type; |
4217 s->qbias= pict->pict_type == P_TYPE ? 2 : 0; | 4218 s->qbias= pict->pict_type == P_TYPE ? 2 : 0; |
4219 | |
4220 common_init_after_header(avctx); | |
4221 | |
4222 if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){ | |
4223 for(plane_index=0; plane_index<3; plane_index++){ | |
4224 calculate_vissual_weight(s, &s->plane[plane_index]); | |
4225 } | |
4226 } | |
4218 | 4227 |
4219 encode_header(s); | 4228 encode_header(s); |
4220 s->m.misc_bits = 8*(s->c.bytestream - s->c.bytestream_start); | 4229 s->m.misc_bits = 8*(s->c.bytestream - s->c.bytestream_start); |
4221 encode_blocks(s, 1); | 4230 encode_blocks(s, 1); |
4222 s->m.mv_bits = 8*(s->c.bytestream - s->c.bytestream_start) - s->m.misc_bits; | 4231 s->m.mv_bits = 8*(s->c.bytestream - s->c.bytestream_start) - s->m.misc_bits; |