Mercurial > libavcodec.hg
comparison mpegvideo.c @ 2990:0300c2647bc3 libavcodec
support downscaling frames for dynamic b frame decission
author | michael |
---|---|
date | Sun, 25 Dec 2005 18:34:02 +0000 |
parents | 538eed481f62 |
children | 188f4ef688f2 |
comparison
equal
deleted
inserted
replaced
2989:c6e656e76eed | 2990:0300c2647bc3 |
---|---|
2143 | 2143 |
2144 static int estimate_best_b_count(MpegEncContext *s){ | 2144 static int estimate_best_b_count(MpegEncContext *s){ |
2145 AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id); | 2145 AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id); |
2146 AVCodecContext *c= avcodec_alloc_context(); | 2146 AVCodecContext *c= avcodec_alloc_context(); |
2147 AVFrame input[FF_MAX_B_FRAMES+2]; | 2147 AVFrame input[FF_MAX_B_FRAMES+2]; |
2148 const int scale= 0; | 2148 const int scale= s->avctx->brd_scale; |
2149 int i, j, out_size; | 2149 int i, j, out_size; |
2150 int outbuf_size= (s->width * s->height) >> (2*scale); //FIXME | 2150 int outbuf_size= s->width * s->height; //FIXME |
2151 uint8_t *outbuf= av_malloc(outbuf_size); | 2151 uint8_t *outbuf= av_malloc(outbuf_size); |
2152 ImgReSampleContext *resample; | 2152 ImgReSampleContext *resample; |
2153 int64_t best_rd= INT64_MAX; | 2153 int64_t best_rd= INT64_MAX; |
2154 int best_b_count= -1; | 2154 int best_b_count= -1; |
2155 const int lambda2= s->lambda2; | 2155 const int lambda2= s->lambda2; |
2196 c->error[0]= c->error[1]= c->error[2]= 0; | 2196 c->error[0]= c->error[1]= c->error[2]= 0; |
2197 | 2197 |
2198 input[0].pict_type= I_TYPE; | 2198 input[0].pict_type= I_TYPE; |
2199 input[0].quality= 2 * FF_QP2LAMBDA; | 2199 input[0].quality= 2 * FF_QP2LAMBDA; |
2200 out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[0]); | 2200 out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[0]); |
2201 rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT; | |
2201 | 2202 |
2202 for(i=0; i<s->max_b_frames+1; i++){ | 2203 for(i=0; i<s->max_b_frames+1; i++){ |
2203 int is_p= i % (j+1) == j || i==s->max_b_frames; | 2204 int is_p= i % (j+1) == j || i==s->max_b_frames; |
2204 | 2205 |
2205 input[i+1].pict_type= is_p ? P_TYPE : B_TYPE; | 2206 input[i+1].pict_type= is_p ? P_TYPE : B_TYPE; |