Mercurial > libavcodec.hg
comparison mpegvideo.c @ 2997:188f4ef688f2 libavcodec
second try of improved lambda/qp guessing for motion estimation RD in first pass
author | michael |
---|---|
date | Thu, 29 Dec 2005 15:46:23 +0000 |
parents | 0300c2647bc3 |
children | 037518fde4bd |
comparison
equal
deleted
inserted
replaced
2996:bf34de4233a0 | 2997:188f4ef688f2 |
---|---|
1592 draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); | 1592 draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); |
1593 } | 1593 } |
1594 emms_c(); | 1594 emms_c(); |
1595 | 1595 |
1596 s->last_pict_type = s->pict_type; | 1596 s->last_pict_type = s->pict_type; |
1597 s->last_lambda_for[s->pict_type]= s->current_picture_ptr->quality; | |
1597 if(s->pict_type!=B_TYPE){ | 1598 if(s->pict_type!=B_TYPE){ |
1598 s->last_non_b_pict_type= s->pict_type; | 1599 s->last_non_b_pict_type= s->pict_type; |
1599 } | 1600 } |
1600 #if 0 | 1601 #if 0 |
1601 /* copy back current_picture variables */ | 1602 /* copy back current_picture variables */ |
2202 | 2203 |
2203 for(i=0; i<s->max_b_frames+1; i++){ | 2204 for(i=0; i<s->max_b_frames+1; i++){ |
2204 int is_p= i % (j+1) == j || i==s->max_b_frames; | 2205 int is_p= i % (j+1) == j || i==s->max_b_frames; |
2205 | 2206 |
2206 input[i+1].pict_type= is_p ? P_TYPE : B_TYPE; | 2207 input[i+1].pict_type= is_p ? P_TYPE : B_TYPE; |
2207 input[i+1].quality= s->rc_context.last_qscale_for[input[i+1].pict_type]; | 2208 input[i+1].quality= s->last_lambda_for[input[i+1].pict_type]; |
2208 out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[i+1]); | 2209 out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[i+1]); |
2209 rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; | 2210 rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; |
2210 } | 2211 } |
2211 | 2212 |
2212 /* get the delayed frames */ | 2213 /* get the delayed frames */ |
5396 | 5397 |
5397 if(s->flags & CODEC_FLAG_PASS2){ | 5398 if(s->flags & CODEC_FLAG_PASS2){ |
5398 estimate_qp(s, 1); | 5399 estimate_qp(s, 1); |
5399 ff_get_2pass_fcode(s); | 5400 ff_get_2pass_fcode(s); |
5400 }else if(!(s->flags & CODEC_FLAG_QSCALE)){ | 5401 }else if(!(s->flags & CODEC_FLAG_QSCALE)){ |
5401 RateControlContext *rcc= &s->rc_context; | |
5402 | |
5403 if(s->pict_type==B_TYPE) | 5402 if(s->pict_type==B_TYPE) |
5404 s->lambda= rcc->last_qscale_for[s->pict_type]; | 5403 s->lambda= s->last_lambda_for[s->pict_type]; |
5405 else | 5404 else |
5406 s->lambda= rcc->last_qscale_for[rcc->last_non_b_pict_type]; | 5405 s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; |
5407 update_qscale(s); | 5406 update_qscale(s); |
5408 } | 5407 } |
5409 | 5408 |
5410 s->mb_intra=0; //for the rate distortion & bit compare functions | 5409 s->mb_intra=0; //for the rate distortion & bit compare functions |
5411 for(i=1; i<s->avctx->thread_count; i++){ | 5410 for(i=1; i<s->avctx->thread_count; i++){ |