[libdvdnav-devel] [Git][videolan/libdvdread][master] 7 commits: dvd_input: return the last block of a file that ends mid-block, padded with zeros
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Wed Dec 2 11:50:56 UTC 2026
Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread
Commits:
7c2a91a1 by Saifelden Mohamed Ismail at 2026-12-02T12:46:02+01:00
dvd_input: return the last block of a file that ends mid-block, padded with zeros
- - - - -
c847306e by Saifelden Mohamed Ismail at 2026-12-02T12:46:02+01:00
dvd_reader: read unencrypted files from a directory tree without libdvdcss
- - - - -
4f64587d by Saifelden Mohamed Ismail at 2026-12-02T12:46:02+01:00
ifo_types: read the DVD-VR CPRM info from byte 267
- - - - -
6723aae6 by Saifelden Mohamed Ismail at 2026-12-02T12:46:02+01:00
ifo_read: keep only the 10 size bits of a DVD-VR VOBU entry
- - - - -
d3b1538e by Saifelden Mohamed Ismail at 2026-12-02T12:46:02+01:00
ifo_types: name the DVD-VR still picture and playlist table addresses
- - - - -
ea98ba1a by Saifelden Mohamed Ismail at 2026-12-02T12:46:02+01:00
dvd_input, ifo_types: correct the comments made wrong by the partial block and VOBU size fixes
- - - - -
c10c95b6 by Saifelden Mohamed Ismail at 2026-12-02T12:46:02+01:00
dvd_input: do not apply CSS decryption to DVD-VR and DVD-Audio streams
- - - - -
5 changed files:
- src/dvd_input.c
- src/dvd_input.h
- src/dvd_reader.c
- src/dvdread/ifo_types.h
- src/ifo_read.c
Changes:
=====================================
src/dvd_input.c
=====================================
@@ -138,6 +138,10 @@ static dvd_input_t dvd_input_New(void *priv, dvd_logger_cb *logcb)
return dev;
}
+static int file_seek(dvd_input_t dev, int blocks);
+static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags);
+static int file_close(dvd_input_t dev);
+
/**
* initialize and open a DVD (device or file or stream_cb)
*/
@@ -183,6 +187,8 @@ static dvd_input_t css_open(void *priv, dvd_logger_cb *logcb,
*/
static int css_seek(dvd_input_t dev, int blocks)
{
+ if(!dev->dvdcss)
+ return file_seek(dev, blocks);
/* DVDINPUT_NOFLAGS should match the DVDCSS_NOFLAGS value. */
return DVDcss_seek(dev->dvdcss, blocks, DVDINPUT_NOFLAGS);
}
@@ -205,12 +211,15 @@ static int css_title(dvd_input_t dev, int block)
*/
static int css_read(dvd_input_t dev, void *buffer, int blocks, int flags)
{
+ if(!dev->dvdcss)
+ return file_read(dev, buffer, blocks, flags);
#ifdef HAVE_DVDCSS_DVDCPXM_H
if ((dev->stream_type == DVD_A || dev->stream_type == DVD_VR) &&
dev->cpxm_ready)
return DVDcpxm_read(dev->dvdcss, buffer, blocks, flags);
- else
#endif
+ if (dev->stream_type == DVD_A || dev->stream_type == DVD_VR)
+ flags &= ~DVDINPUT_READ_DECRYPT;
return DVDcss_read(dev->dvdcss, buffer, blocks, flags);
}
@@ -221,6 +230,9 @@ static int css_close(dvd_input_t dev)
{
int ret;
+ if(!dev->dvdcss)
+ return file_close(dev);
+
ret = DVDcss_close(dev->dvdcss);
free(dev);
@@ -376,8 +388,14 @@ static int file_read(dvd_input_t dev, void *buffer, int blocks,
}
if(ret == 0) {
- /* Nothing more to read. Return all of the whole blocks, if any.
- * Adjust the file position back to the previous block boundary. */
+ /* Nothing more to read. Return all of the whole blocks, if any,
+ * and a last partial block padded with zeros.
+ * Adjust the file position to the end of the returned blocks. */
+ if(bytes % DVD_VIDEO_LB_LEN) {
+ memset(((char*)buffer) + bytes, 0,
+ DVD_VIDEO_LB_LEN - bytes % DVD_VIDEO_LB_LEN);
+ blocks_read++;
+ }
ret = file_seek(dev, dev->ipos + blocks_read);
if(ret < 0)
return ret;
@@ -412,6 +430,12 @@ static int file_close(dvd_input_t dev)
return ret;
}
+dvd_input_t dvdinput_open_file(void *priv, dvd_logger_cb *logcb,
+ const char *target, dvd_reader_filesystem_h *fs)
+{
+ return file_open(priv, logcb, target, NULL, fs);
+}
+
/**
* Setup read functions with either libdvdcss or minimal DVD access.
*/
=====================================
src/dvd_input.h
=====================================
@@ -31,6 +31,8 @@
#define DVDINPUT_READ_DECRYPT (1 << 0)
extern void dvdinput_set_stream(dvd_input_t, dvd_type_t);
+dvd_input_t dvdinput_open_file(void *, dvd_logger_cb *, const char *,
+ dvd_reader_filesystem_h *);
/**
* Setup function accessed by dvd_reader.c. Returns 1 if there is CSS support.
* Otherwise it fallsback to the internal dvdread implementation (without css support)
=====================================
src/dvd_reader.c
=====================================
@@ -1041,7 +1041,7 @@ static dvd_file_t *DVDOpenFilePath( dvd_reader_t *ctx, const char *filename )
return NULL;
}
- dev = ctx->dvdinput_open( ctx->priv, &ctx->logcb, full_path, NULL, ctx->fs );
+ dev = dvdinput_open_file( ctx->priv, &ctx->logcb, full_path, ctx->fs );
if( !dev ) {
Log0(ctx, "DVDOpenFilePath:dvdinput_open %s failed", full_path );
return NULL;
=====================================
src/dvdread/ifo_types.h
=====================================
@@ -1222,13 +1222,14 @@ typedef struct {
uint8_t zero_226[30];
/* 256 */
uint32_t org_pgci_sa; /* original program chain start address */
- uint32_t org_pgci_ea; /* end address for the org_pgci */
- uint8_t unknown_264[7];
+ uint32_t s_avfit_sa; /* still picture information table start address */
+ uint8_t unknown_264[3];
cprm_info_t cprm_info;
+ uint8_t unknown_276[4];
uint8_t zero_280[24];
/* 304 */
uint32_t ud_pgcit_sa; /* user defined program chain information table */
- uint32_t info_308_sa; /* ? start address */
+ uint32_t playlist_sa; /* user made playlists start address */
uint32_t info_312_sa;
uint32_t info_316_sa; /* ? start address */
uint8_t zero_320[32];
@@ -1269,7 +1270,7 @@ typedef struct {
typedef struct {
uint8_t data1;
- /* only 14 bits are used for size,
+ /* only 10 bits are used for size,
* but use full 16 for easy access. */
uint16_t vobu_size;
} ATTRIBUTE_PACKED vobu_info_t;
=====================================
src/ifo_read.c
=====================================
@@ -1497,8 +1497,8 @@ static int ifoRead_RTAV_VMGI(ifo_handle_t *ifofile) {
B2N_32(ifofile->rtav_vmgi->vmgi_ea);
B2N_32(ifofile->rtav_vmgi->org_pgci_sa);
B2N_32(ifofile->rtav_vmgi->ud_pgcit_sa);
- B2N_32(ifofile->rtav_vmgi->org_pgci_ea);
- B2N_32(ifofile->rtav_vmgi->info_308_sa);
+ B2N_32(ifofile->rtav_vmgi->s_avfit_sa);
+ B2N_32(ifofile->rtav_vmgi->playlist_sa);
B2N_32(ifofile->rtav_vmgi->info_312_sa);
B2N_32(ifofile->rtav_vmgi->info_316_sa);
B2N_32(ifofile->rtav_vmgi->txtdt_mg_sa);
@@ -1700,8 +1700,10 @@ int ifoRead_PGC_GI(ifo_handle_t *ifofile) {
free(pgc_gi->pgi[i].map.vobu_infos);
goto fail3;
}
- for(int j = 0; j<pgc_gi->pgi[i].map.nr_of_vobu_info; j++)
+ for(int j = 0; j<pgc_gi->pgi[i].map.nr_of_vobu_info; j++) {
B2N_16(pgc_gi->pgi[i].map.vobu_infos[j].vobu_size);
+ pgc_gi->pgi[i].map.vobu_infos[j].vobu_size &= 0x3ff;
+ }
} else {
pgc_gi->pgi[i].map.vobu_infos = NULL;
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/159e42811b1016a1d30be8304bc0617f244ce16a...c10c95b69f1e677015ef0ef63d2f526ebaa075e8
--
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/159e42811b1016a1d30be8304bc0617f244ce16a...c10c95b69f1e677015ef0ef63d2f526ebaa075e8
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 libdvdnav-devel
mailing list