Skip to content
Snippets Groups Projects
Commit 94db2f10 authored by Steve Lhomme's avatar Steve Lhomme
Browse files

contrib: dvdread: do not use btn_it and its parent as packed structures

The 4x 12 bits packing is making the bitfield packing messy and incompatible
with (non)MS packing in dvdnav. In the end the structures are not read as
packed structures so we don't need to keep them packed.

Upstream patch proposed at videolan/libdvdread!42
parent 2a02bdf3
No related branches found
No related tags found
Loading
Pipeline #257187 passed with stage
in 1 hour, 1 minute, and 9 seconds
From 76a4ad6d6bd2ceea14328004048bb07fbc8e65c5 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 22 Aug 2022 09:21:05 +0200
Subject: [PATCH 1/2] nav_types: make btin_t not packed
The use of bitfields of 10 bits makes the use of `unsigned char` impossible.
That means the compiler might use more bits than expected for the 4*12 bits.
This is the case with MS-compatible compilers. We cannot guarantee that the
btin_t will use the same 10 octets as used in the binary blob.
In the end btin_t is not read as a packed structure but bit by bit in
navRead_PCI().
---
src/dvdread/nav_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dvdread/nav_types.h b/src/dvdread/nav_types.h
index f6a500f..e9d0efd 100644
--- a/src/dvdread/nav_types.h
+++ b/src/dvdread/nav_types.h
@@ -133,7 +133,7 @@ typedef struct {
unsigned int zero6 : 2; /**< reserved */
unsigned int right : 6; /**< button index when pressing right */
vm_cmd_t cmd;
-} ATTRIBUTE_PACKED btni_t;
+} btni_t;
/**
* Highlight Information
--
2.27.0.windows.1
From a5702da22dc74a272251e647f9f87434a81d09c4 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 22 Aug 2022 09:22:49 +0200
Subject: [PATCH 2/2] nav_types: make hli_t and pci_t not packed
They depends on the packing of btni_t. Since btni_t is no longer packed, they
cannot be packed anymore.
This is not a problem as they are read bit by bit in navRead_PCI().
---
src/dvdread/nav_types.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/dvdread/nav_types.h b/src/dvdread/nav_types.h
index e9d0efd..6139e5e 100644
--- a/src/dvdread/nav_types.h
+++ b/src/dvdread/nav_types.h
@@ -142,7 +142,7 @@ typedef struct {
hl_gi_t hl_gi;
btn_colit_t btn_colit;
btni_t btnit[36];
-} ATTRIBUTE_PACKED hli_t;
+} hli_t;
/**
* PCI packet
@@ -152,7 +152,7 @@ typedef struct {
nsml_agli_t nsml_agli;
hli_t hli;
uint8_t zero1[189];
-} ATTRIBUTE_PACKED pci_t;
+} pci_t;
--
2.27.0.windows.1
......@@ -21,6 +21,8 @@ $(TARBALLS)/libdvdread-$(LIBDVDREAD_VERSION).tar.bz2:
dvdread: libdvdread-$(LIBDVDREAD_VERSION).tar.bz2 .sum-dvdread
$(UNPACK)
$(APPLY) $(SRC)/dvdread/0001-ifo_types-avoid-forcing-a-higher-length-in-bitfield-.patch
$(APPLY) $(SRC)/dvdread/0001-nav_types-make-btin_t-not-packed.patch
$(APPLY) $(SRC)/dvdread/0002-nav_types-make-hli_t-and-pci_t-not-packed.patch
$(call pkg_static,"misc/dvdread.pc.in")
$(MOVE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment