[vlc-commits] [Git][videolan/vlc][master] 5 commits: tests: bits: add const on write test buffer

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Jun 21 16:59:59 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
2e916d87 by Steve Lhomme at 2026-06-21T16:47:58+00:00
tests: bits: add const on write test buffer

- - - - -
60f5e84a by Steve Lhomme at 2026-06-21T16:47:58+00:00
tests: bits: use bs_init() or bs_init_custom()

Do not access the "internal" parts of the callback handling.

- - - - -
d4c0ef28 by Steve Lhomme at 2026-06-21T16:47:58+00:00
packetizer: hxxx: avoid casting a void*

- - - - -
bde48546 by Steve Lhomme at 2026-06-21T16:47:58+00:00
packetizer: hxxx: use more const internally

- - - - -
f3b1230f by Steve Lhomme at 2026-06-21T16:47:58+00:00
tests: bits: test EOF and errors on skip

When we skip the exact remaining amount of that we should get a EOF but no
error. If we skip one more bit we should get an error.

This cannot be tested with the custom callback that skips even bytes.

- - - - -


2 changed files:

- modules/packetizer/hxxx_ep3b.h
- test/src/misc/bits.c


Changes:

=====================================
modules/packetizer/hxxx_ep3b.h
=====================================
@@ -20,7 +20,7 @@
  *****************************************************************************/
 #include <vlc_bits.h>
 
-static inline uint8_t *hxxx_ep3b_to_rbsp( uint8_t *p, uint8_t *end, unsigned *pi_prev, size_t i_count )
+static inline const uint8_t *hxxx_ep3b_to_rbsp( const uint8_t *p, const uint8_t *end, unsigned *pi_prev, size_t i_count )
 {
     for( size_t i=0; i<i_count; i++ )
     {
@@ -81,7 +81,7 @@ static void hxxx_bsfw_ep3b_ctx_init( struct hxxx_bsfw_ep3b_ctx_s *ctx )
 
 static size_t hxxx_bsfw_byte_forward_ep3b( bs_t *s, size_t i_count )
 {
-    struct hxxx_bsfw_ep3b_ctx_s *ctx = (struct hxxx_bsfw_ep3b_ctx_s *) s->p_priv;
+    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
     if( s->p == NULL )
     {
         s->p = s->p_start;
@@ -92,14 +92,14 @@ static size_t hxxx_bsfw_byte_forward_ep3b( bs_t *s, size_t i_count )
     if( s->p >= s->p_end )
         return 0;
 
-    s->p = hxxx_ep3b_to_rbsp( s->p, s->p_end, &ctx->i_prev, i_count );
+    s->p = (uint8_t*) hxxx_ep3b_to_rbsp( s->p, s->p_end, &ctx->i_prev, i_count );
     ctx->i_bytepos += i_count;
     return i_count;
 }
 
 static size_t hxxx_bsfw_byte_pos_ep3b( const bs_t *s )
 {
-    struct hxxx_bsfw_ep3b_ctx_s *ctx = (struct hxxx_bsfw_ep3b_ctx_s *) s->p_priv;
+    struct hxxx_bsfw_ep3b_ctx_s *ctx = s->p_priv;
     return ctx->i_bytepos;
 }
 


=====================================
test/src/misc/bits.c
=====================================
@@ -46,9 +46,9 @@ enum dataset
 } ;
 
 #define bs_init(a,b,c) \
-    bs_init( a, b, c); \
-    if( callbacks ) { (a)->cb = *callbacks; \
-                      if( cb_priv ) { (a)->p_priv = cb_priv; priv_init( cb_priv ); }; }
+    if( callbacks ) { bs_init_custom( a, b, c, callbacks, cb_priv ); \
+                      if( cb_priv ) { priv_init( cb_priv ); }; } \
+    else { bs_init( a, b, c); }
 
 static int run_tests( const struct testset *p_testsets,
                       const char *psz_tag,
@@ -138,6 +138,19 @@ static int run_tests( const struct testset *p_testsets,
     test_assert( bs_error(&bs), false );
     test_assert( bs_eof(&bs), false );
 
+    if( !callbacks )
+    {
+        bs_init( &bs, p_testsets[TESTSET2].data, p_testsets[TESTSET2].count );
+        bs_skip( &bs, p_testsets[TESTSET2].count * 8 );
+        test_assert( bs_eof(&bs), true );
+        test_assert( bs_error(&bs), false );
+
+        bs_init( &bs, p_testsets[TESTSET2].data, p_testsets[TESTSET2].count );
+        bs_skip( &bs, p_testsets[TESTSET2].count * 8 + 1 );
+        test_assert( bs_error(&bs), true );
+        test_assert( bs_eof(&bs), true );
+    }
+
     /* */
     bs_init( &bs, p_testsets[TESTSET2].data,
                   p_testsets[TESTSET2].count );
@@ -153,7 +166,7 @@ static int run_tests( const struct testset *p_testsets,
 
     /* test writes */
     uint8_t buf[5] = { 0 };
-    uint8_t bufok[5] = { 0x7D, 0xF7, 0xDF, 0x7D, 0xF7 };
+    const uint8_t bufok[5] = { 0x7D, 0xF7, 0xDF, 0x7D, 0xF7 };
     bs_write_init( &bs, &buf, 5 );
     bs_write(&bs, 1, 1 );
     test_assert(buf[0], 0x80);
@@ -261,10 +274,8 @@ static int test_annexb( const char *psz_tag )
 
     bs_t bs;
     struct hxxx_bsfw_ep3b_ctx_s bsctx;
-    bs_init( &bs, &annexb, ARRAY_SIZE(annexb) );
     hxxx_bsfw_ep3b_ctx_init( &bsctx );
-    bs.cb = hxxx_bsfw_ep3b_callbacks;
-    bs.p_priv = &bsctx;
+    bs_init_custom( &bs, &annexb, ARRAY_SIZE(annexb), &hxxx_bsfw_ep3b_callbacks, &bsctx );
     for( size_t i=0; i<ARRAY_SIZE(unesc)*8; i++ )
     {
         test_assert(bs_aligned( &bs ), !!(i%8 == 0));
@@ -273,10 +284,8 @@ static int test_annexb( const char *psz_tag )
     }
     test_assert(bs_eof( &bs ), 1);
 
-    bs_init( &bs, &annexb, ARRAY_SIZE(annexb) );
     hxxx_bsfw_ep3b_ctx_init( &bsctx );
-    bs.cb = hxxx_bsfw_ep3b_callbacks;
-    bs.p_priv = &bsctx;
+    bs_init_custom( &bs, &annexb, ARRAY_SIZE(annexb), &hxxx_bsfw_ep3b_callbacks, &bsctx );
     for( size_t i=0; i<ARRAY_SIZE(unesc)*4; i++ )
     {
         test_assert(bs_pos( &bs ), i*2);
@@ -297,10 +306,8 @@ static int test_annexb( const char *psz_tag )
                                0x40, 0x01, 0x0C, 0x01, 0xFF, 0xFF, 0x01, 0x60,
                                0x00, 0x00,       0x00, 0x40, 0x00, 0x00,
                                0x00, 0x00,       0x00, 0x78, 0x10, 0x90, 0x24 };
-    bs_init( &bs, vpsnal, ARRAY_SIZE(vpsnal) );
     hxxx_bsfw_ep3b_ctx_init( &bsctx );
-    bs.cb = hxxx_bsfw_ep3b_callbacks;
-    bs.p_priv = &bsctx;
+    bs_init_custom( &bs, vpsnal, ARRAY_SIZE(vpsnal), &hxxx_bsfw_ep3b_callbacks, &bsctx );
     for(size_t i=0; i<ARRAY_SIZE(vpsnalunesc); i++)
         test_assert(bs_read(&bs, 8), vpsnalunesc[i]);
 
@@ -328,10 +335,8 @@ static int test_annexb( const char *psz_tag )
                                0x2C, 0x6D, 0xD1, 0xBF, 0x54, 0x3A, 0x1F, 0x16,
                                0x06, 0xFF, 0x04, 0x5B, 0xFF, 0xB4, 0x79, 0xFF,
                                0xE8, 0x14, 0x80 };
-    bs_init( &bs, seinal, ARRAY_SIZE(seinal) );
     hxxx_bsfw_ep3b_ctx_init( &bsctx );
-    bs.cb = hxxx_bsfw_ep3b_callbacks;
-    bs.p_priv = &bsctx;
+    bs_init_custom( &bs, seinal, ARRAY_SIZE(seinal), &hxxx_bsfw_ep3b_callbacks, &bsctx );
     for(size_t i=0; i<ARRAY_SIZE(seinalunesc); i++)
         test_assert(bs_read(&bs, 8), seinalunesc[i]);
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8ac2333894074012b42c58d56eb750b1f0fa01be...f3b1230fc5de0934e15922f073c2dc818f2205c6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8ac2333894074012b42c58d56eb750b1f0fa01be...f3b1230fc5de0934e15922f073c2dc818f2205c6
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list