[x264-devel] commit: Cosmetics in VBV handling (Gabriel Bouvigne )

git version control git at videolan.org
Wed Jun 11 02:42:41 CEST 2008


x264 | branch: master | Gabriel Bouvigne <gabriel.bouvigne at joost.com> | Tue Jun 10 18:40:52 2008 -0600| [3464b0e7b5c6df009c1959f73966b9666f4949d0]

Cosmetics in VBV handling

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

 common/frame.c        |   38 --------------------------------------
 common/frame.h        |    3 ---
 common/osdep.h        |    2 +-
 encoder/ratecontrol.c |   18 ++++++++++++------
 4 files changed, 13 insertions(+), 48 deletions(-)

diff --git a/common/frame.c b/common/frame.c
index a1a36b5..9956527 100644
--- a/common/frame.c
+++ b/common/frame.c
@@ -825,8 +825,6 @@ void x264_deblock_init( int cpu, x264_deblock_function_t *pf )
 
 
 /* threading */
-
-#ifdef HAVE_PTHREAD
 void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed )
 {
     x264_pthread_mutex_lock( &frame->mutex );
@@ -843,42 +841,6 @@ void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed )
     x264_pthread_mutex_unlock( &frame->mutex );
 }
 
-void x264_frame_size_estimated_set( x264_t *h, int bits )
-{
-    x264_pthread_mutex_lock( &h->fenc->mutex );
-    x264_ratecontrol_set_estimated_size(h, bits);
-    x264_pthread_mutex_unlock( &h->fenc->mutex );
-}
-
-int x264_frame_size_estimated_get( x264_t const *h)
-{
-    int size;
-    x264_pthread_mutex_lock( &h->fenc->mutex );
-    size = x264_ratecontrol_get_estimated_size(h);
-    x264_pthread_mutex_unlock( &h->fenc->mutex );
-    return size;
-}
-
-#else
-void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed )
-{}
-void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed )
-{}
-
-void x264_frame_size_estimated_set( x264_t *h, int bits )
-{
-    x264_ratecontrol_set_estimated_size(h, bits);
-}
-
-int x264_frame_size_estimated_get( x264_t const *h)
-{
-    int size;
-    size = x264_ratecontrol_set_estimated_size(h);
-    return size;
-}
-#endif
-
-
 /* list operators */
 
 void x264_frame_push( x264_frame_t **list, x264_frame_t *frame )
diff --git a/common/frame.h b/common/frame.h
index 25a373e..1cd7b64 100644
--- a/common/frame.h
+++ b/common/frame.h
@@ -121,9 +121,6 @@ void          x264_deblock_init( int cpu, x264_deblock_function_t *pf );
 void          x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed );
 void          x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed );
 
-void          x264_frame_size_estimated_set( x264_t *h, int bits );
-int           x264_frame_size_estimated_get( x264_t const *h);
-
 void          x264_frame_push( x264_frame_t **list, x264_frame_t *frame );
 x264_frame_t *x264_frame_pop( x264_frame_t **list );
 void          x264_frame_unshift( x264_frame_t **list, x264_frame_t *frame );
diff --git a/common/osdep.h b/common/osdep.h
index c3c8149..939fe78 100644
--- a/common/osdep.h
+++ b/common/osdep.h
@@ -127,7 +127,7 @@
 #define x264_pthread_cond_init(c,f)
 #define x264_pthread_cond_destroy(c)
 #define x264_pthread_cond_broadcast(c)
-#define x264_pthread_cond_wait(c,m)  usleep(100)
+#define x264_pthread_cond_wait(c,m)
 #endif
 
 /* FIXME: long isn't always the native register size (e.g. win64). */
diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index e15fe16..37cd994 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -729,12 +729,18 @@ void x264_ratecontrol_delete( x264_t *h )
 
 void x264_ratecontrol_set_estimated_size( x264_t *h, int bits )
 {
+    x264_pthread_mutex_lock( &h->fenc->mutex );
     h->rc->frame_size_estimated = bits;
+    x264_pthread_mutex_unlock( &h->fenc->mutex );
 }
 
 int x264_ratecontrol_get_estimated_size( x264_t const *h)
 {
-    return h->rc->frame_size_estimated;
+    int size;
+    x264_pthread_mutex_lock( &h->fenc->mutex );
+    size = h->rc->frame_size_estimated;
+    x264_pthread_mutex_unlock( &h->fenc->mutex );
+    return size;
 }
 
 static void accum_p_qp_update( x264_t *h, float qp )
@@ -919,7 +925,7 @@ void x264_ratecontrol_mb( x264_t *h, int bits )
             rc->qpm = X264_MIN(X264_MAX( rc->qp, avg_qp), 51); //avg_qp could go higher than 51 due to pb_offset
             i_estimated = row_bits_so_far(h, y); //FIXME: compute full estimated size
             if (i_estimated > h->rc->frame_size_planned)
-                x264_frame_size_estimated_set(h, i_estimated);
+                x264_ratecontrol_set_estimated_size(h, i_estimated);
         }
     }
     else
@@ -975,7 +981,7 @@ void x264_ratecontrol_mb( x264_t *h, int bits )
                 rc->qpm --;
                 b1 = predict_row_size_sum( h, y, rc->qpm );
             }
-            x264_frame_size_estimated_set(h, b1);
+            x264_ratecontrol_set_estimated_size(h, b1);
         }
     }
     /* loses the fractional part of the frame-wise qp */
@@ -1327,7 +1333,7 @@ static void update_vbv_plan( x264_t *h )
             double bits = t->rc->frame_size_planned;
             if( !t->b_thread_active )
                 continue;
-            bits  = X264_MAX(bits, x264_frame_size_estimated_get(t));
+            bits  = X264_MAX(bits, x264_ratecontrol_get_estimated_size(t));
             rcc->buffer_fill += rcc->buffer_rate - bits;
             rcc->buffer_fill = x264_clip3( rcc->buffer_fill, 0, rcc->buffer_size );
         }
@@ -1464,7 +1470,7 @@ static float rate_estimate_qscale( x264_t *h )
             q += rcc->pb_offset;
 
         rcc->frame_size_planned = predict_size( rcc->pred_b_from_p, q, h->fref1[h->i_ref1-1]->i_satd );
-        x264_frame_size_estimated_set(h, rcc->frame_size_planned);
+        x264_ratecontrol_set_estimated_size(h, rcc->frame_size_planned);
         rcc->last_satd = 0;
         return qp2qscale(q);
     }
@@ -1594,7 +1600,7 @@ static float rate_estimate_qscale( x264_t *h )
             rcc->frame_size_planned = qscale2bits(&rce, q);
         else
             rcc->frame_size_planned = predict_size( &rcc->pred[h->sh.i_type], q, rcc->last_satd );
-        x264_frame_size_estimated_set(h, rcc->frame_size_planned);
+        x264_ratecontrol_set_estimated_size(h, rcc->frame_size_planned);
         return q;
     }
 }



More information about the x264-devel mailing list