1
From 45b3f7c71ec213a2f4177e866586660fcbc68ecd Mon Sep 17 00:00:00 2001
2
From: Jeff Downs <heydowns@somuchpressure.net>
3
Date: Wed, 6 Jul 2011 11:54:36 -0400
4
Subject: [PATCH 35/70] h264: correct implicit weight table computation for long ref pics
6
Correct computation of implicit weight tables when referencing pictures
7
that are marked for long reference.
9
Signed-off-by: Diego Biurrun <diego@biurrun.de>
10
(cherry picked from commit 87cf70eb237e7586cc7399627dafa1b980ec0b7d)
12
Signed-off-by: Anton Khirnov <anton@khirnov.net>
14
libavcodec/h264.c | 20 +++++++++++---------
15
1 files changed, 11 insertions(+), 9 deletions(-)
17
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
18
index 99be210..1c60de7 100644
19
--- a/libavcodec/h264.c
20
+++ b/libavcodec/h264.c
21
@@ -2198,15 +2198,17 @@ static void implicit_weight_table(H264Context *h, int field){
22
for(ref0=ref_start; ref0 < ref_count0; ref0++){
23
int poc0 = h->ref_list[0][ref0].poc;
24
for(ref1=ref_start; ref1 < ref_count1; ref1++){
25
- int poc1 = h->ref_list[1][ref1].poc;
26
- int td = av_clip(poc1 - poc0, -128, 127);
29
- int tb = av_clip(cur_poc - poc0, -128, 127);
30
- int tx = (16384 + (FFABS(td) >> 1)) / td;
31
- int dist_scale_factor = (tb*tx + 32) >> 8;
32
- if(dist_scale_factor >= -64 && dist_scale_factor <= 128)
33
- w = 64 - dist_scale_factor;
35
+ if (!h->ref_list[0][ref0].long_ref && !h->ref_list[1][ref1].long_ref) {
36
+ int poc1 = h->ref_list[1][ref1].poc;
37
+ int td = av_clip(poc1 - poc0, -128, 127);
39
+ int tb = av_clip(cur_poc - poc0, -128, 127);
40
+ int tx = (16384 + (FFABS(td) >> 1)) / td;
41
+ int dist_scale_factor = (tb*tx + 32) >> 8;
42
+ if(dist_scale_factor >= -64 && dist_scale_factor <= 128)
43
+ w = 64 - dist_scale_factor;
47
h->implicit_weight[ref0][ref1][0]=