[libbluray-devel] [Git][videolan/libbluray][master] 2 commits: Simplify bs_seek_byte()
Petri Hintukainen (@hpi)
gitlab at videolan.org
Sun Aug 30 17:26:21 UTC 2026
Petri Hintukainen pushed to branch master at VideoLAN / libbluray
Commits:
256a6676 by Petri Hintukainen at 2026-08-30T20:07:15+03:00
Simplify bs_seek_byte()
- - - - -
1a882a57 by Petri Hintukainen at 2026-08-30T20:07:22+03:00
Use bdpriv_ prefix for mutex functions
- - - - -
3 changed files:
- src/util/bits.c
- src/util/mutex.c
- src/util/mutex.h
Changes:
=====================================
src/util/bits.c
=====================================
@@ -126,29 +126,16 @@ void bb_seek( BITBUFFER *bb, int64_t off, int whence)
}
#endif
-static int _bs_seek( BITSTREAM *bs, int64_t off, int whence)
+int bs_seek_byte( BITSTREAM *bs, int64_t off )
{
int result = 0;
- int64_t b;
- switch (whence) {
- case SEEK_CUR:
- off = bs->pos * 8 + (bs->bb.p - bs->bb.p_start) * 8 + off;
- break;
- case SEEK_END:
- off = bs->end * 8 - off;
- break;
- case SEEK_SET:
- default:
- break;
- }
if (off < 0) {
BD_DEBUG(DBG_FILE | DBG_CRIT, "bs_seek(): seek failed (negative offset)\n");
return -1;
}
- b = off >> 3;
- if (b >= bs->end)
+ if (off >= bs->end)
{
int64_t pos;
if (BF_BUF_SIZE < bs->end) {
@@ -158,12 +145,12 @@ static int _bs_seek( BITSTREAM *bs, int64_t off, int whence)
}
result = _bs_read_at(bs, pos);
bs->bb.p = bs->bb.p_end;
- } else if (b < bs->pos || b >= (bs->pos + BF_BUF_SIZE)) {
- result = _bs_read_at(bs, b);
+ } else if (off < bs->pos || off >= (bs->pos + BF_BUF_SIZE)) {
+ result = _bs_read_at(bs, off);
} else {
- b -= bs->pos;
- bs->bb.p = &bs->bb.p_start[b];
- bs->bb.i_left = 8 - (off & 0x07);
+ off -= bs->pos;
+ bs->bb.p = &bs->bb.p_start[off];
+ bs->bb.i_left = 8;
}
return result;
@@ -176,12 +163,6 @@ void bb_seek_byte( BITBUFFER *bb, int64_t off)
}
#endif
-int bs_seek_byte( BITSTREAM *s, int64_t off)
-{
- return _bs_seek(s, off << 3, SEEK_SET);
-}
-
-
uint32_t bb_read( BITBUFFER *bb, int i_count )
{
static const uint32_t i_mask[33] = {
=====================================
src/util/mutex.c
=====================================
@@ -117,7 +117,7 @@ static int _mutex_destroy(MUTEX_IMPL *p)
#endif /* HAVE_PTHREAD_H */
-int bd_mutex_lock(BD_MUTEX *p)
+int bdpriv_mutex_lock(BD_MUTEX *p)
{
if (!p->impl) {
BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_lock() failed !\n");
@@ -126,7 +126,7 @@ int bd_mutex_lock(BD_MUTEX *p)
return _mutex_lock((MUTEX_IMPL*)p->impl);
}
-int bd_mutex_unlock(BD_MUTEX *p)
+int bdpriv_mutex_unlock(BD_MUTEX *p)
{
if (!p->impl) {
BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_unlock() failed !\n");
@@ -135,7 +135,7 @@ int bd_mutex_unlock(BD_MUTEX *p)
return _mutex_unlock((MUTEX_IMPL*)p->impl);
}
-int bd_mutex_init(BD_MUTEX *p)
+int bdpriv_mutex_init(BD_MUTEX *p)
{
p->impl = calloc(1, sizeof(MUTEX_IMPL));
if (!p->impl) {
@@ -151,7 +151,7 @@ int bd_mutex_init(BD_MUTEX *p)
return 0;
}
-int bd_mutex_destroy(BD_MUTEX *p)
+int bdpriv_mutex_destroy(BD_MUTEX *p)
{
if (!p->impl) {
BD_DEBUG(DBG_BLURAY|DBG_CRIT, "bd_mutex_destroy() failed !\n");
=====================================
src/util/mutex.h
=====================================
@@ -31,10 +31,15 @@ struct bd_mutex_s {
void *impl;
};
-BD_PRIVATE int bd_mutex_init(BD_MUTEX *p);
-BD_PRIVATE int bd_mutex_destroy(BD_MUTEX *p);
+BD_PRIVATE int bdpriv_mutex_init(BD_MUTEX *p);
+BD_PRIVATE int bdpriv_mutex_destroy(BD_MUTEX *p);
-BD_PRIVATE int bd_mutex_lock(BD_MUTEX *p);
-BD_PRIVATE int bd_mutex_unlock(BD_MUTEX *p);
+BD_PRIVATE int bdpriv_mutex_lock(BD_MUTEX *p);
+BD_PRIVATE int bdpriv_mutex_unlock(BD_MUTEX *p);
+
+#define bd_mutex_init(p) bdpriv_mutex_init(p);
+#define bd_mutex_destroy(p) bdpriv_mutex_destroy(p)
+#define bd_mutex_lock(p) bdpriv_mutex_lock(p)
+#define bd_mutex_unlock(p) bdpriv_mutex_unlock(p)
#endif // LIBBLURAY_MUTEX_H_
View it on GitLab: https://code.videolan.org/videolan/libbluray/-/compare/ea3e318b89c42d2eff2ce0b9d78dc2371fbb6a67...1a882a5741ff7891a1942fbc24983c5a37b6d0e6
--
View it on GitLab: https://code.videolan.org/videolan/libbluray/-/compare/ea3e318b89c42d2eff2ce0b9d78dc2371fbb6a67...1a882a5741ff7891a1942fbc24983c5a37b6d0e6
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 libbluray-devel
mailing list