Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 5bc5bfe

Browse files
committed
Merge commit '0e020921726ee812e633959d9ad6315ff58b902b'
2 parents c293783 + 0e02092 commit 5bc5bfe

17 files changed

Lines changed: 153 additions & 131 deletions

Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -Im4
22

33
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src/dvdread $(CSS_CFLAGS)
44

5-
dist_doc_DATA = AUTHORS ChangeLog COPYING NEWS README TODO
5+
dist_doc_DATA = AUTHORS ChangeLog COPYING NEWS README.md TODO
66

77
MAINTAINERCLEANFILES = ChangeLog
88

@@ -12,7 +12,7 @@ ChangeLog: $(wildcard $(srcdir)/.git/logs/HEAD)
1212
-rm -f $(@)-tmp
1313
test -e $(@) || touch $(@)
1414

15-
EXTRA_DIST = msvc/ doc/footer.html doc/header.html
15+
EXTRA_DIST = msvc doc/footer.html doc/header.html
1616

1717
lib_LTLIBRARIES = libdvdread.la
1818

NEWS

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
libdvdread (6.1.3)
2+
* Improvements for OpenBSD
3+
* Fix crashes on some DVD (0 PCGI SRP)
4+
* Misc source fixes and cleanups, including fixes for recent toolchains
5+
16
libdvdread (6.1.2)
27
* Fix Win32 Unicode paths opening
38
* Fix warnings and build improvements
@@ -84,7 +89,7 @@ libdvdread (4.2.0)
8489
* fixed segfault when reading certain DVDs, for example "Thor"
8590

8691
libdvdread (4.1.3)
87-
* an embarassing amount of fixes regarding potential memory and resource leaks
92+
* an embarrassing amount of fixes regarding potential memory and resource leaks
8893
(patches contributed by Erik Hovland)
8994
* added dvdread-config (dvdnav-config's younger brother)
9095
* added pkgconfig support
@@ -105,7 +110,7 @@ libdvdnav (4.1.1)
105110
dvdnav_{title,part}_play() works again
106111
* removed wrong SPU stream change event filter
107112
(fixes unwanted subtitles in the trailer of "Girl, interrupted", RC2)
108-
* fixed error "Expected NAV packet but none found." occuring sometimes
113+
* fixed error "Expected NAV packet but none found." occurring sometimes
109114
on resume from menu
110115

111116
libdvdnav (0.1.10)
@@ -139,7 +144,7 @@ libdvdnav (0.1.6) unstable; urgency=low
139144
* method to try-run VM operations, now used for safer chapter skipping and menu jumps
140145
* fixed detection of current PTT to not assume a 1:1 mapping between PTTs and PGs
141146
* releasing stills when jumping to menu fixes some state inconsistencies
142-
* do not assume PGs to be physically layed out in sequence on the disc
147+
* do not assume PGs to be physically laid out in sequence on the disc
143148
* optional PGC based seeking
144149
* new event on cell changes for timing info
145150

README

Lines changed: 0 additions & 57 deletions
This file was deleted.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Goals and features
2+
3+
**libdvdread** is a library for simpler navigation (DVDs without menus)
4+
5+
## Where does it come from?
6+
7+
This library is based on a lot of code and expertise from the **Ogle project**.
8+
**Ogle** was the first DVD player who implemented **free DVD navigation**. The
9+
**libdvdread** developers wish to express their gratitude to the Ogle people
10+
for all the valuable research work they have done.
11+
12+
Initially, the dvdnav code was part of a plugin to the xine media player
13+
called xine-dvdnav. Later on, the DVD VM specific code was split
14+
from xine-dvdnav and went into the first version of libdvdnav.
15+
16+
Then, it was forked, and forked again on MPlayer repositories.
17+
libdvdnav and libdvdread were merged, and then split again.
18+
19+
## Where is it now?
20+
21+
Libdvdread is hosted [here](https://code.videolan.org/videolan/libdvdread)
22+
23+
You can find more information [here](https://www.videolan.org/developers/libdvdnav.html)
24+
25+
Please report bugs to the developers mailinglist at
26+
[dvdnav mailing list](https://mailman.videolan.org/listinfo/libdvdnav-devel)
27+
28+
## License
29+
30+
**Libdvdread** is completely licensed under GPL. You may use it at wish within the
31+
bounds of this license. See the file [COPYING](https://code.videolan.org/videolan/libdvdread/-/blob/master/COPYING) for a copy of the GPL.
32+
33+
## Using libdvdread
34+
35+
A detailed description of DVD structures is available [here](http://www.mpucoder.com/dvd/)
36+
37+
All documentation is also accessible [here](http://dvdnav.mplayerhq.hu/#docs)
38+
39+
## CoC
40+
41+
The [VideoLAN Code of Conduct](https://wiki.videolan.org/Code_of_Conduct/) applies to this project.

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl library version number
22
m4_define([dvdread_major], 6)
33
m4_define([dvdread_minor], 1)
4-
m4_define([dvdread_micro], 2)
4+
m4_define([dvdread_micro], 3)
55
m4_define([dvdread_version],[dvdread_major.dvdread_minor.dvdread_micro])
66

77
AC_INIT(libdvdread, dvdread_version)
@@ -98,7 +98,7 @@ CC_CHECK_CFLAGS_APPEND([-Wall -Wsign-compare -Wextra])
9898

9999

100100
AC_ARG_ENABLE([apidoc],
101-
AS_HELP_STRING([--disable-apidoc], [Disable building (with Doxygen) and intalling API documentation @<:@default=auto@:@>]))
101+
AS_HELP_STRING([--disable-apidoc], [Disable building (with Doxygen) and installing API documentation @<:@default=auto@:@>]))
102102

103103
AC_PATH_PROG([DOXYGEN], [doxygen])
104104

src/bitreader.c

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
#include <stdlib.h>
2424
#include <string.h>
2525
#include <inttypes.h>
26+
#include <assert.h>
2627

2728
#include "dvdread/bitreader.h"
2829

29-
int dvdread_getbits_init(getbits_state_t *state, uint8_t *start) {
30+
int dvdread_getbits_init(getbits_state_t *state, const uint8_t *start) {
3031
if ((state == NULL) || (start == NULL)) return 0;
3132
state->start = start;
3233
state->bit_position = 0;
3334
state->byte_position = 0;
34-
state->byte = start[0];
3535
return 1;
3636
}
3737

@@ -47,37 +47,32 @@ uint32_t dvdread_getbits(getbits_state_t *state, uint32_t number_of_bits) {
4747

4848
if ((state->bit_position) > 0) { /* Last getbits left us in the middle of a byte. */
4949
if (number_of_bits > (8-state->bit_position)) { /* this getbits will span 2 or more bytes. */
50-
byte = state->byte;
50+
byte = state->start[state->byte_position] << state->bit_position;
5151
byte = byte >> (state->bit_position);
5252
result = byte;
5353
number_of_bits -= (8-state->bit_position);
5454
state->bit_position = 0;
5555
state->byte_position++;
56-
state->byte = state->start[state->byte_position];
5756
} else {
58-
byte=state->byte;
59-
state->byte = state->byte << number_of_bits;
57+
byte = state->start[state->byte_position] << state->bit_position;
6058
byte = byte >> (8 - number_of_bits);
6159
result = byte;
6260
state->bit_position += number_of_bits; /* Here it is impossible for bit_position > 8 */
6361
if (state->bit_position == 8) {
6462
state->bit_position = 0;
6563
state->byte_position++;
66-
state->byte = state->start[state->byte_position];
6764
}
6865
number_of_bits = 0;
6966
}
7067
}
7168
if ((state->bit_position) == 0) {
7269
while (number_of_bits > 7) {
73-
result = (result << 8) + state->byte;
70+
result = (result << 8) + state->start[state->byte_position];
7471
state->byte_position++;
75-
state->byte = state->start[state->byte_position];
7672
number_of_bits -= 8;
7773
}
7874
if (number_of_bits > 0) { /* number_of_bits < 8 */
79-
byte = state->byte;
80-
state->byte = state->byte << number_of_bits;
75+
byte = state->start[state->byte_position] << state->bit_position;
8176
state->bit_position += number_of_bits; /* Here it is impossible for bit_position > 7 */
8277
byte = byte >> (8 - number_of_bits);
8378
result = (result << number_of_bits) + byte;
@@ -115,3 +110,54 @@ uint32_t dvdread_get32bits(getbits_state_t *state) {
115110
}
116111

117112
#endif
113+
114+
#ifdef BITREADER_TESTS
115+
116+
int main()
117+
{
118+
uint8_t buff[2] = {
119+
0x6E, 0xC2
120+
// 0b 01101110 11000010
121+
};
122+
getbits_state_t state;
123+
dvdread_getbits_init(&state, buff);
124+
125+
uint32_t bits = dvdread_getbits(&state, 3);
126+
assert(bits == 3);
127+
128+
bits = dvdread_getbits(&state, 3);
129+
assert(bits == 3);
130+
131+
bits = dvdread_getbits(&state, 4);
132+
assert(bits == 11);
133+
134+
bits = dvdread_getbits(&state, 6);
135+
assert(bits == 2);
136+
137+
dvdread_getbits_init(&state, buff);
138+
bits = dvdread_getbits(&state, 10);
139+
assert(bits == 443);
140+
141+
bits = dvdread_getbits(&state, 6);
142+
assert(bits == 2);
143+
144+
dvdread_getbits_init(&state, buff);
145+
bits = dvdread_getbits(&state, 16);
146+
assert(bits == 28354);
147+
148+
buff[0] = buff[1] = 0xFF;
149+
dvdread_getbits_init(&state, buff);
150+
bits = dvdread_getbits(&state, 16);
151+
assert(bits == 0xFFFF);
152+
153+
uint8_t large[5] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
154+
dvdread_getbits_init(&state, large);
155+
bits = dvdread_getbits(&state, 8);
156+
assert(bits == 0xFF);
157+
bits = dvdread_getbits(&state, 32);
158+
assert(bits == 0xFFFFFFFF);
159+
160+
return 0;
161+
}
162+
163+
#endif

src/dvd_input.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,15 @@ int dvdinput_setup(void *priv, dvd_logger_cb *logcb)
350350
#define CSS_LIB "libdvdcss-2.dll"
351351
#elif defined(__OS2__)
352352
#define CSS_LIB "dvdcss2.dll"
353+
#elif defined(__OpenBSD__)
354+
#define CSS_LIB "libdvdcss.so"
353355
#else
354356
#define CSS_LIB "libdvdcss.so.2"
355357
#endif
356358
dvdcss_library = dlopen(CSS_LIB, RTLD_LAZY);
357359

358360
if(dvdcss_library != NULL) {
359-
#if defined(__OpenBSD__) && !defined(__ELF__) || defined(__OS2__)
361+
#ifdef __OS2__
360362
#define U_S "_"
361363
#else
362364
#define U_S

src/dvd_reader.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
#include <stdio.h> /* fprintf */
3030
#include <errno.h> /* errno, EIN* */
3131
#include <string.h> /* memcpy, strlen */
32-
#ifdef HAVE_UNISTD_H
33-
#include <unistd.h> /* chdir, getcwd */
34-
#endif
32+
#include <unistd.h> /* pclose */
3533
#include <limits.h> /* PATH_MAX */
3634
#include <dirent.h> /* opendir, readdir */
3735
#include <ctype.h> /* isalpha */
@@ -290,7 +288,7 @@ static int initAllCSSKeys( dvd_reader_t *ctx )
290288
for( title = 0; title < 100; title++ ) {
291289
gettimeofday( &t_s, NULL );
292290
if( title == 0 ) {
293-
sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
291+
strcpy( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
294292
} else {
295293
sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 0 );
296294
}
@@ -553,33 +551,18 @@ static dvd_reader_t *DVDOpenCommon( void *priv,
553551
if( !(path_copy = strdup( path ) ) )
554552
goto DVDOpen_error;
555553

556-
#ifndef _WIN32 /* don't have fchdir, and getcwd( NULL, ... ) is strange */
554+
#ifndef _WIN32 /* win32 doesn't have realpath */
557555
/* Also WIN32 does not have symlinks, so we don't need this bit of code. */
558556

559557
/* Resolve any symlinks and get the absolute dir name. */
560558
{
561-
if( ( cdir = open( ".", O_RDONLY ) ) >= 0 ) {
562-
int retval;
563-
if( chdir( path_copy ) == -1 ) {
564-
goto DVDOpen_error;
565-
}
566-
new_path = malloc(PATH_MAX+1);
567-
if(!new_path) {
568-
goto DVDOpen_error;
569-
}
570-
if( getcwd( new_path, PATH_MAX ) == NULL ) {
571-
goto DVDOpen_error;
572-
}
573-
retval = fchdir( cdir );
574-
close( cdir );
575-
cdir = -1;
576-
if( retval == -1 ) {
559+
new_path = realpath( path_copy, NULL );
560+
if( new_path == NULL ) {
577561
goto DVDOpen_error;
578562
}
579563
free(path_copy);
580564
path_copy = new_path;
581565
new_path = NULL;
582-
}
583566
}
584567
#endif
585568

0 commit comments

Comments
 (0)