diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index f5c6473fe496550ba82bdce547ed16cdb595b0e3..1cb66d33a3c0b0fd9f2933dfa3a05890b5397d29 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3152,7 +3152,7 @@ static void implicit_weight_table(H264Context *h){
     for(ref0=0; ref0 < h->ref_count[0]; ref0++){
         int poc0 = h->ref_list[0][ref0].poc;
         for(ref1=0; ref1 < h->ref_count[1]; ref1++){
-            int poc1 = h->ref_list[0][ref1].poc;
+            int poc1 = h->ref_list[1][ref1].poc;
             int td = clip(poc1 - poc0, -128, 127);
             if(td){
                 int tb = clip(cur_poc - poc0, -128, 127);