[vlc-commits] [Git][videolan/vlc][master] contrib: dvdread: do not use btn_it and its parent as packed structures

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Aug 30 13:33:22 UTC 2022



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
94db2f10 by Steve Lhomme at 2022-08-30T12:38:39+00:00
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 https://code.videolan.org/videolan/libdvdread/-/merge_requests/42

- - - - -


3 changed files:

- + contrib/src/dvdread/0001-nav_types-make-btin_t-not-packed.patch
- + contrib/src/dvdread/0002-nav_types-make-hli_t-and-pci_t-not-packed.patch
- contrib/src/dvdread/rules.mak


Changes:

=====================================
contrib/src/dvdread/0001-nav_types-make-btin_t-not-packed.patch
=====================================
@@ -0,0 +1,32 @@
+From 76a4ad6d6bd2ceea14328004048bb07fbc8e65c5 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at 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
+


=====================================
contrib/src/dvdread/0002-nav_types-make-hli_t-and-pci_t-not-packed.patch
=====================================
@@ -0,0 +1,38 @@
+From a5702da22dc74a272251e647f9f87434a81d09c4 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at 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
+


=====================================
contrib/src/dvdread/rules.mak
=====================================
@@ -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)
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/94db2f105f36c107115b8019ec4c91afc8ccdd18

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/94db2f105f36c107115b8019ec4c91afc8ccdd18
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list