[libdvdnav-devel] [Git][videolan/libdvdread][master] 2 commits: ifo_types: avoid forcing a higher length in bitfield structures

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Aug 22 07:57:15 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread


Commits:
ea158e81 by Steve Lhomme at 2022-08-22T07:25:06+00:00
ifo_types: avoid forcing a higher length in bitfield structures

LLVM ends up using the size of an unsigned int if it's used in the bitfield.
In other places the bitfields are using unsigned char which always uses the
proper size in the packed structures.

* multichannel_ext_t would end up having a size of 27 instead of 24
* cell_playback_t would end up having a size of 26 instead of 24
* pgci_srp_t would end up having a size of 11 instead of 8
* playback_type_t would end up having a size of 4 instead of 1

- - - - -
f3c27767 by Steve Lhomme at 2022-08-22T07:25:06+00:00
nav_types: avoid forcing a higher length in bitfield structures

LLVM ends up using the size of an unsigned int if it's used in the bitfield.
In other places the bitfields are using unsigned char which always uses the
proper size in the packed structures.

/!\ btni_t fields are kept with unsigned int as unsigned char cannot hold
10 bits. btni_t is not actually read as a packed structure. So we keep the
current format for backward compatibility.

- - - - -


2 changed files:

- src/dvdread/ifo_types.h
- src/dvdread/nav_types.h


Changes:

=====================================
src/dvdread/ifo_types.h
=====================================
@@ -132,29 +132,29 @@ typedef struct {
  * MultiChannel Extension
  */
 typedef struct {
-  unsigned int zero1      : 7;
-  unsigned int ach0_gme   : 1;
-
-  unsigned int zero2      : 7;
-  unsigned int ach1_gme   : 1;
-
-  unsigned int zero3      : 4;
-  unsigned int ach2_gv1e  : 1;
-  unsigned int ach2_gv2e  : 1;
-  unsigned int ach2_gm1e  : 1;
-  unsigned int ach2_gm2e  : 1;
-
-  unsigned int zero4      : 4;
-  unsigned int ach3_gv1e  : 1;
-  unsigned int ach3_gv2e  : 1;
-  unsigned int ach3_gmAe  : 1;
-  unsigned int ach3_se2e  : 1;
-
-  unsigned int zero5      : 4;
-  unsigned int ach4_gv1e  : 1;
-  unsigned int ach4_gv2e  : 1;
-  unsigned int ach4_gmBe  : 1;
-  unsigned int ach4_seBe  : 1;
+  unsigned char zero1      : 7;
+  unsigned char ach0_gme   : 1;
+
+  unsigned char zero2      : 7;
+  unsigned char ach1_gme   : 1;
+
+  unsigned char zero3      : 4;
+  unsigned char ach2_gv1e  : 1;
+  unsigned char ach2_gv2e  : 1;
+  unsigned char ach2_gm1e  : 1;
+  unsigned char ach2_gm2e  : 1;
+
+  unsigned char zero4      : 4;
+  unsigned char ach3_gv1e  : 1;
+  unsigned char ach3_gv2e  : 1;
+  unsigned char ach3_gmAe  : 1;
+  unsigned char ach3_se2e  : 1;
+
+  unsigned char zero5      : 4;
+  unsigned char ach4_gv1e  : 1;
+  unsigned char ach4_gv2e  : 1;
+  unsigned char ach4_gmBe  : 1;
+  unsigned char ach4_seBe  : 1;
   uint8_t zero6[19];
 } ATTRIBUTE_PACKED multichannel_ext_t;
 
@@ -207,16 +207,16 @@ typedef uint8_t pgc_program_map_t;
  * Cell Playback Information.
  */
 typedef struct {
-  unsigned int block_mode       : 2;
-  unsigned int block_type       : 2;
-  unsigned int seamless_play    : 1;
-  unsigned int interleaved      : 1;
-  unsigned int stc_discontinuity: 1;
-  unsigned int seamless_angle   : 1;
-  unsigned int zero_1           : 1;
-  unsigned int playback_mode    : 1;  /**< When set, enter StillMode after each VOBU */
-  unsigned int restricted       : 1;  /**< ?? drop out of fastforward? */
-  unsigned int cell_type        : 5;  /** for karaoke, reserved otherwise */
+  unsigned char block_mode       : 2;
+  unsigned char block_type       : 2;
+  unsigned char seamless_play    : 1;
+  unsigned char interleaved      : 1;
+  unsigned char stc_discontinuity: 1;
+  unsigned char seamless_angle   : 1;
+  unsigned char zero_1           : 1;
+  unsigned char playback_mode    : 1;  /**< When set, enter StillMode after each VOBU */
+  unsigned char restricted       : 1;  /**< ?? drop out of fastforward? */
+  unsigned char cell_type        : 5;  /** for karaoke, reserved otherwise */
   uint8_t still_time;
   uint8_t cell_cmd_nr;
   dvd_time_t playback_time;
@@ -247,35 +247,35 @@ typedef struct {
  * User Operations.
  */
 typedef struct {
-  unsigned int zero                           : 7; /* 25-31 */
-  unsigned int video_pres_mode_change         : 1; /* 24 */
-
-  unsigned int karaoke_audio_pres_mode_change : 1; /* 23 */
-  unsigned int angle_change                   : 1;
-  unsigned int subpic_stream_change           : 1;
-  unsigned int audio_stream_change            : 1;
-  unsigned int pause_on                       : 1;
-  unsigned int still_off                      : 1;
-  unsigned int button_select_or_activate      : 1;
-  unsigned int resume                         : 1; /* 16 */
-
-  unsigned int chapter_menu_call              : 1; /* 15 */
-  unsigned int angle_menu_call                : 1;
-  unsigned int audio_menu_call                : 1;
-  unsigned int subpic_menu_call               : 1;
-  unsigned int root_menu_call                 : 1;
-  unsigned int title_menu_call                : 1;
-  unsigned int backward_scan                  : 1;
-  unsigned int forward_scan                   : 1; /* 8 */
-
-  unsigned int next_pg_search                 : 1; /* 7 */
-  unsigned int prev_or_top_pg_search          : 1;
-  unsigned int time_or_chapter_search         : 1;
-  unsigned int go_up                          : 1;
-  unsigned int stop                           : 1;
-  unsigned int title_play                     : 1;
-  unsigned int chapter_search_or_play         : 1;
-  unsigned int title_or_time_play             : 1; /* 0 */
+  unsigned char zero                           : 7; /* 25-31 */
+  unsigned char video_pres_mode_change         : 1; /* 24 */
+
+  unsigned char karaoke_audio_pres_mode_change : 1; /* 23 */
+  unsigned char angle_change                   : 1;
+  unsigned char subpic_stream_change           : 1;
+  unsigned char audio_stream_change            : 1;
+  unsigned char pause_on                       : 1;
+  unsigned char still_off                      : 1;
+  unsigned char button_select_or_activate      : 1;
+  unsigned char resume                         : 1; /* 16 */
+
+  unsigned char chapter_menu_call              : 1; /* 15 */
+  unsigned char angle_menu_call                : 1;
+  unsigned char audio_menu_call                : 1;
+  unsigned char subpic_menu_call               : 1;
+  unsigned char root_menu_call                 : 1;
+  unsigned char title_menu_call                : 1;
+  unsigned char backward_scan                  : 1;
+  unsigned char forward_scan                   : 1; /* 8 */
+
+  unsigned char next_pg_search                 : 1; /* 7 */
+  unsigned char prev_or_top_pg_search          : 1;
+  unsigned char time_or_chapter_search         : 1;
+  unsigned char go_up                          : 1;
+  unsigned char stop                           : 1;
+  unsigned char title_play                     : 1;
+  unsigned char chapter_search_or_play         : 1;
+  unsigned char title_or_time_play             : 1; /* 0 */
 } ATTRIBUTE_PACKED user_ops_t;
 
 /**
@@ -312,9 +312,9 @@ typedef struct {
  */
 typedef struct {
   uint8_t  entry_id;
-  unsigned int block_mode : 2;
-  unsigned int block_type : 2;
-  unsigned int zero_1   : 4;
+  unsigned char block_mode : 2;
+  unsigned char block_type : 2;
+  unsigned char zero_1   : 4;
   uint16_t ptl_id_mask;
   uint32_t pgc_start_byte;
   pgc_t *pgc;
@@ -440,14 +440,14 @@ typedef struct {
 } ATTRIBUTE_PACKED vmgi_mat_t;
 
 typedef struct {
-  unsigned int zero_1                    : 1;
-  unsigned int multi_or_random_pgc_title : 1; /* 0: one sequential pgc title */
-  unsigned int jlc_exists_in_cell_cmd    : 1;
-  unsigned int jlc_exists_in_prepost_cmd : 1;
-  unsigned int jlc_exists_in_button_cmd  : 1;
-  unsigned int jlc_exists_in_tt_dom      : 1;
-  unsigned int chapter_search_or_play    : 1; /* UOP 1 */
-  unsigned int title_or_time_play        : 1; /* UOP 0 */
+  unsigned char zero_1                    : 1;
+  unsigned char multi_or_random_pgc_title : 1; /* 0: one sequential pgc title */
+  unsigned char jlc_exists_in_cell_cmd    : 1;
+  unsigned char jlc_exists_in_prepost_cmd : 1;
+  unsigned char jlc_exists_in_button_cmd  : 1;
+  unsigned char jlc_exists_in_tt_dom      : 1;
+  unsigned char chapter_search_or_play    : 1; /* UOP 1 */
+  unsigned char title_or_time_play        : 1; /* UOP 0 */
 } ATTRIBUTE_PACKED playback_type_t;
 
 /**


=====================================
src/dvdread/nav_types.h
=====================================
@@ -77,14 +77,14 @@ typedef struct {
   uint32_t hli_s_ptm;              /**< start ptm of hli */
   uint32_t hli_e_ptm;              /**< end ptm of hli */
   uint32_t btn_se_e_ptm;           /**< end ptm of button select */
-  unsigned int zero1 : 2;          /**< reserved */
-  unsigned int btngr_ns : 2;       /**< number of button groups 1, 2 or 3 with 36/18/12 buttons */
-  unsigned int zero2 : 1;          /**< reserved */
-  unsigned int btngr1_dsp_ty : 3;  /**< display type of subpic stream for button group 1 */
-  unsigned int zero3 : 1;          /**< reserved */
-  unsigned int btngr2_dsp_ty : 3;  /**< display type of subpic stream for button group 2 */
-  unsigned int zero4 : 1;          /**< reserved */
-  unsigned int btngr3_dsp_ty : 3;  /**< display type of subpic stream for button group 3 */
+  unsigned char zero1 : 2;          /**< reserved */
+  unsigned char btngr_ns : 2;       /**< number of button groups 1, 2 or 3 with 36/18/12 buttons */
+  unsigned char zero2 : 1;          /**< reserved */
+  unsigned char btngr1_dsp_ty : 3;  /**< display type of subpic stream for button group 1 */
+  unsigned char zero3 : 1;          /**< reserved */
+  unsigned char btngr2_dsp_ty : 3;  /**< display type of subpic stream for button group 2 */
+  unsigned char zero4 : 1;          /**< reserved */
+  unsigned char btngr3_dsp_ty : 3;  /**< display type of subpic stream for button group 3 */
   uint8_t btn_ofn;     /**< button offset number range 0-255 */
   uint8_t btn_ns;      /**< number of valid buttons  <= 36/18/12 (low 6 bits) */
   uint8_t nsl_btn_ns;  /**< number of buttons selectable by U_BTNNi (low 6 bits)   nsl_btn_ns <= btn_ns */



View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/23392df9d6ee8e3632f16ffbd9ce07fa993c30ce...f3c27767e28452731a6445fdbc183f8d456100b7

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/23392df9d6ee8e3632f16ffbd9ce07fa993c30ce...f3c27767e28452731a6445fdbc183f8d456100b7
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the libdvdnav-devel mailing list