changeset 11338:444401d150d6 libavcodec

Simplify implicit_weight table init.
author michael
date Wed, 03 Mar 2010 10:57:38 +0000
parents 15dd07e86519
children a82cdda1f507
files h264.c
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/h264.c	Wed Mar 03 09:51:56 2010 +0000
+++ b/h264.c	Wed Mar 03 10:57:38 2010 +0000
@@ -1435,16 +1435,14 @@
         for(ref1=0; ref1 < h->ref_count[1]; ref1++){
             int poc1 = h->ref_list[1][ref1].poc;
             int td = av_clip(poc1 - poc0, -128, 127);
+            h->implicit_weight[ref0][ref1] = 32;
             if(td){
                 int tb = av_clip(cur_poc - poc0, -128, 127);
                 int tx = (16384 + (FFABS(td) >> 1)) / td;
-                int dist_scale_factor = av_clip((tb*tx + 32) >> 6, -1024, 1023) >> 2;
-                if(dist_scale_factor < -64 || dist_scale_factor > 128)
-                    h->implicit_weight[ref0][ref1] = 32;
-                else
+                int dist_scale_factor = (tb*tx + 32) >> 8;
+                if(dist_scale_factor >= -64 && dist_scale_factor <= 128)
                     h->implicit_weight[ref0][ref1] = 64 - dist_scale_factor;
-            }else
-                h->implicit_weight[ref0][ref1] = 32;
+            }
         }
     }
 }