Skip to content

Fix weighting for B-frames

Anton Mitrofanov requested to merge BugMaster/x264:fix_bipred_weight into master

According to clause 8.4.3 of the H.264 specification:

  1. The variables w0C and w1C are derived as follows:
  • If DiffPicOrderCnt( pic1, pic0 ) is equal to 0 or one or both of pic1 and pic0 is marked as "used for long-term reference" or ( DistScaleFactor >> 2 ) < -64 or ( DistScaleFactor >> 2 ) > 128, w0C and w1C are derived as:

          w0C = 32                                (8-280)
          w1C = 32                                (8-281)

But we for the case of DiffPicOrderCnt( pic1, pic0 ) is equal to 0 used DistScaleFactor equal to 256 and next formulas:

  • Otherwise, the variables tb, td, tx, and DistScaleFactor are derived from the values of currPicOrField, pic0, and pic1 using Equations 8-201, 8-202, 8-197, and 8-198, respectively, and the weights w0C and w1C are derived as

          w0C = 64 - (DistScaleFactor >> 2)       (8-282)
          w1C = DistScaleFactor >> 2              (8-283)

As a result, we got the values w0C = 0 and w1C = 64 instead of 32 for both.

This bug never occurs with the current reference management logic.

Bug report by Lingjiang Fang.

Merge request reports

Loading