[x264-devel] Mark frame_size_estimated as volatile

Anton Mitrofanov git at videolan.org
Mon Mar 11 20:24:07 CET 2019


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Mon Feb  4 22:04:56 2019 +0300| [6d8af5f0e390bbcd31a65dda04ef27d3f93821c1] | committer: Henrik Gramner

Mark frame_size_estimated as volatile

Ensures that access is atomic and that other threads sees the actual
value of the variable.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=6d8af5f0e390bbcd31a65dda04ef27d3f93821c1
---

 encoder/ratecontrol.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index c2f455fd..1860cb46 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -154,8 +154,8 @@ struct x264_ratecontrol_t
     } mbtree;
 
     /* MBRC stuff */
-    float frame_size_estimated; /* Access to this variable must be atomic: double is
-                                 * not atomic on all arches we care about */
+    volatile float frame_size_estimated; /* Access to this variable must be atomic: double is
+                                          * not atomic on all arches we care about */
     double frame_size_maximum;  /* Maximum frame size due to MinCR */
     double frame_size_planned;
     double slice_size_planned;
@@ -1714,7 +1714,7 @@ int x264_ratecontrol_mb( x264_t *h, int bits )
         /* Last-ditch attempt: if the last row of the frame underflowed the VBV,
          * try again. */
         if( rc->qpm < qp_max && can_reencode_row
-            && (h->rc->frame_size_estimated + size_of_other_slices > X264_MIN( rc->frame_size_maximum, rc->buffer_fill )) )
+            && (bits_so_far + size_of_other_slices > X264_MIN( rc->frame_size_maximum, rc->buffer_fill )) )
         {
             rc->qpm = qp_max;
             rc->qpa_rc = rc->qpa_rc_prev;



More information about the x264-devel mailing list