libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libcdio-devel] Re: here's a patch that changes nothing...


From: Robert William Fuller
Subject: [Libcdio-devel] Re: here's a patch that changes nothing...
Date: Sat, 08 Mar 2008 23:06:41 -0500
User-agent: Thunderbird 2.0.0.6 (X11/20071013)

Robert William Fuller wrote:
Robert William Fuller wrote:
Robert William Fuller wrote:
Robert William Fuller wrote:
Robert William Fuller wrote:
This is preliminary work for adding support for audio track pregaps in NRG images. It does not change existing behavior, but it does add necessary fields to the daox and daoi structures. Let me know what you think. I'm assuming I should hold on to these until after the freeze?

Scratch that. I just realized I can delete code from nrg.c! Another patch will follow.

Sheesh, why make common structures if you don't delete code? Ok, so here's the revised version:

Aw crap. I'll never get this right. Here's the same patch with the "Only in" removed:

Looks like I missed that extra +1 for CDIO_MCN_SIZE too.... O well, when I submit something larger? The funny thing is that CDIO_MCN_SIZE is 13, so the macro already includes the NULL terminator, but there's lots of code that allocates CDIO_MCN_SIZE+1 then does [CDIO_MCN_SIZE]='\0';

Alright, what the hey. I've already flooded the list, and it seems to need some action anyway. Next time I promise to wait longer before sending a patch and not modify it and re-send it and modify it and re-send it and modify it....

diff -upr libcdio-0.80-clean/lib/driver/image/nrg.c 
libcdio-0.80/lib/driver/image/nrg.c
--- libcdio-0.80-clean/lib/driver/image/nrg.c   2008-03-03 07:04:34.000000000 
-0500
+++ libcdio-0.80/lib/driver/image/nrg.c 2008-03-08 23:04:48.000000000 -0500
@@ -371,24 +371,23 @@ parse_nrg (_img_private_t *p_env, const 
       case DAOX_ID: /* "DAOX" */ 
       case DAOI_ID: /* "DAOI" */
        {
+          _dao_common_t *_dao_common = (void *) chunk->data;
          track_format_t track_format;
          int disc_mode;
 
          /* We include an extra 0 byte so these can be used as C strings.*/
-         p_env->psz_mcn    = calloc(1, CDIO_MCN_SIZE+1);
+         p_env->psz_mcn    = calloc(1, CDIO_MCN_SIZE);
+
+          disc_mode = _dao_common->u.unknown[2];
+          memcpy(p_env->psz_mcn, &(_dao_common->psz_mcn), CDIO_MCN_SIZE-1);
+         p_env->psz_mcn[CDIO_MCN_SIZE] = '\0';
 
          if (DAOX_ID == opcode) {
-           _daox_array_t *_entries = (void *) chunk->data;
-           disc_mode    = _entries->_unknown[1];
-           p_env->dtyp  = _entries->_unknown[19];
-           memcpy(p_env->psz_mcn, &(_entries->psz_mcn), CDIO_MCN_SIZE);
-           p_env->psz_mcn[CDIO_MCN_SIZE] = '\0';
+           _daox_t *_entries = (void *) chunk->data;
+           p_env->dtyp = _entries->track_info[0].common.u.unknown[0];
          } else {
-           _daoi_array_t *_entries = (void *) chunk->data;
-           disc_mode    = _entries->_unknown[1];
-           p_env->dtyp  = _entries->_unknown[19];
-           memcpy(p_env->psz_mcn, &(_entries->psz_mcn), CDIO_MCN_SIZE);
-           p_env->psz_mcn[CDIO_MCN_SIZE] = '\0';
+           _daoi_t *_entries = (void *) chunk->data;
+           p_env->dtyp = _entries->track_info[0].common.u.unknown[0];
          }
 
          p_env->is_dao = true;
diff -upr libcdio-0.80-clean/lib/driver/image/nrg.h 
libcdio-0.80/lib/driver/image/nrg.h
--- libcdio-0.80-clean/lib/driver/image/nrg.h   2006-01-14 04:45:44.000000000 
-0500
+++ libcdio-0.80/lib/driver/image/nrg.h 2008-03-08 22:33:29.000000000 -0500
@@ -71,19 +71,54 @@ typedef struct {
   uint32_t lsn        GNUC_PACKED; 
 } _cuex_array_t;
 
+/* New DAO[XI] Information from http://en.wikipedia.org/wiki/NRG_(file_format)
+*/
+
 typedef struct {
-  uint32_t _unknown1  GNUC_PACKED;
-  char      psz_mcn[CDIO_MCN_SIZE];             
-  uint8_t  _unknown[64-CDIO_MCN_SIZE-sizeof(uint32_t)];
+  uint8_t    zero[10];
+  uint32_t   sector_size         GNUC_PACKED;
+  union {
+    uint32_t mode                GNUC_PACKED;
+    uint8_t  unknown[4];
+  } u;
+} _dao_array_common_t;
+
+typedef struct {
+  _dao_array_common_t common;
+  uint64_t   index0              GNUC_PACKED;
+  uint64_t   index1              GNUC_PACKED;
+  uint64_t   end_of_track        GNUC_PACKED;
 } _daox_array_t;
 
 typedef struct {
-  uint32_t _unknown1  GNUC_PACKED;
-  char      psz_mcn[CDIO_MCN_SIZE];
-  uint8_t  _unknown[64-CDIO_MCN_SIZE-sizeof(uint32_t)];
+  _dao_array_common_t common;
+  uint32_t   index0              GNUC_PACKED;
+  uint32_t   index1              GNUC_PACKED;
+  uint32_t   end_of_track        GNUC_PACKED;
 } _daoi_array_t;
 
 typedef struct {
+  uint32_t   chunk_size_le       GNUC_PACKED;
+  char       psz_mcn[CDIO_MCN_SIZE-1];
+  union {
+    uint32_t toc_type            GNUC_PACKED;
+    uint8_t  unknown[4];
+  } u;
+  uint8_t    first_track;
+  uint8_t    last_track;
+} _dao_common_t;
+
+typedef struct {
+  _dao_common_t common;
+  _daox_array_t track_info[EMPTY_ARRAY_SIZE];
+} _daox_t;
+
+typedef struct {
+  _dao_common_t common;
+  _daoi_array_t track_info[EMPTY_ARRAY_SIZE];
+} _daoi_t;
+
+typedef struct {
   uint32_t id                    GNUC_PACKED;
   uint32_t len                   GNUC_PACKED;
   char data[EMPTY_ARRAY_SIZE];

reply via email to

[Prev in Thread] Current Thread [Next in Thread]