diff mpegvideo_enc.c @ 10636:703cfed31320 libavcodec

Move ff_init_qscale_tab() from h263.c to mpegvideo, the function is not h263 specific.
author michael
date Thu, 03 Dec 2009 21:36:58 +0000
parents 8cf141fae2f3
children afd44c3040f5
line wrap: on
line diff
--- a/mpegvideo_enc.c	Thu Dec 03 19:19:57 2009 +0000
+++ b/mpegvideo_enc.c	Thu Dec 03 21:36:58 2009 +0000
@@ -146,6 +146,20 @@
         put_bits(pb, 1, 0);
 }
 
+/**
+ * init s->current_picture.qscale_table from s->lambda_table
+ */
+void ff_init_qscale_tab(MpegEncContext *s){
+    int8_t * const qscale_table= s->current_picture.qscale_table;
+    int i;
+
+    for(i=0; i<s->mb_num; i++){
+        unsigned int lam= s->lambda_table[ s->mb_index2xy[i] ];
+        int qp= (lam*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7);
+        qscale_table[ s->mb_index2xy[i] ]= av_clip(qp, s->avctx->qmin, s->avctx->qmax);
+    }
+}
+
 static void copy_picture_attributes(MpegEncContext *s, AVFrame *dst, AVFrame *src){
     int i;