diff -Nru libmirage-3.1.0/CMakeLists.txt libmirage-3.2.0/CMakeLists.txt --- libmirage-3.1.0/CMakeLists.txt 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/CMakeLists.txt 2018-07-07 19:55:02.000000000 +0000 @@ -5,7 +5,7 @@ # Release versioning: set (MIRAGE_VERSION_MAJOR 3) -set (MIRAGE_VERSION_MINOR 1) +set (MIRAGE_VERSION_MINOR 2) set (MIRAGE_VERSION_MICRO 0) set (MIRAGE_VERSION_LONG ${MIRAGE_VERSION_MAJOR}.${MIRAGE_VERSION_MINOR}.${MIRAGE_VERSION_MICRO}) set (MIRAGE_VERSION_SHORT ${MIRAGE_VERSION_MAJOR}.${MIRAGE_VERSION_MINOR}) @@ -99,6 +99,7 @@ if (CMAKE_COMPILER_IS_GNUCC) add_definitions (-Wall -Wextra -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align) add_definitions (-Wno-sign-compare) + add_definitions (-Wno-cast-function-type) endif () # Definitions needed for localization @@ -123,7 +124,6 @@ mirage/contextual.h mirage/debug.h mirage/disc.h - mirage/disc-structures.h mirage/error.h mirage/file-stream.h mirage/filter-stream.h @@ -211,7 +211,7 @@ SOURCE_DIR ${PROJECT_SOURCE_DIR}/mirage ${PROJECT_BINARY_DIR}/mirage SOURCES ${libmirage_HEADERS} ${libmirage_SOURCES} DOCS_DIR ${PROJECT_SOURCE_DIR}/reference - IGNORE_HFILES "compat-input-stream.h disc-structures.h" + IGNORE_HFILES "compat-input-stream.h" CFLAGS ${GLIB_CFLAGS} -I${PROJECT_SOURCE_DIR}/mirage LDFLAGS ${GLIB_LDFLAGS} -L${PROJECT_BINARY_DIR} -Wl,-rpath,${PROJECT_BINARY_DIR} -l${GTKDOC_LIB} diff -Nru libmirage-3.1.0/debian/changelog libmirage-3.2.0/debian/changelog --- libmirage-3.1.0/debian/changelog 2017-06-10 21:48:25.000000000 +0000 +++ libmirage-3.2.0/debian/changelog 2018-07-08 12:02:03.000000000 +0000 @@ -1,3 +1,7 @@ +libmirage (3.2.0-1ubuntu1~precise1~ppa1) precise; urgency=low + * Updated to 3.2.0 + -- Rok Mandeljc Sat, 7 Jul 2018 12:00:00 +0100 + libmirage (3.1.0-1ubuntu1~precise1~ppa1) precise; urgency=low * Updated to 3.1.0. -- Rok Mandeljc Sat, 06 Jun 2017 12:00:00 +0100 diff -Nru libmirage-3.1.0/debian/control libmirage-3.2.0/debian/control --- libmirage-3.1.0/debian/control 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/debian/control 2018-07-08 12:02:03.000000000 +0000 @@ -27,11 +27,11 @@ file, which is based on GObjects. -Package: gir1.2-mirage-3.1 +Package: gir1.2-mirage-3.2 Section: introspection Architecture: any -Conflicts: gir1.2-mirage-3.0 -Replaces: gir1.2-mirage-3.0 +Conflicts: gir1.2-mirage-3.0, gir1.2-mirage-3.1 +Replaces: gir1.2-mirage-3.0, gir1.2-mirage-3.1 Depends: libmirage11 (= ${binary:Version}), ${gir:Depends}, ${misc:Depends} Description: CD-ROM image access library (typelib files) This package provides typelib files. diff -Nru libmirage-3.1.0/debian/gir1.2-mirage-3.1.install libmirage-3.2.0/debian/gir1.2-mirage-3.1.install --- libmirage-3.1.0/debian/gir1.2-mirage-3.1.install 2017-06-10 21:48:47.000000000 +0000 +++ libmirage-3.2.0/debian/gir1.2-mirage-3.1.install 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -usr/lib/girepository-1.0/* - diff -Nru libmirage-3.1.0/debian/gir1.2-mirage-3.2.install libmirage-3.2.0/debian/gir1.2-mirage-3.2.install --- libmirage-3.1.0/debian/gir1.2-mirage-3.2.install 1970-01-01 00:00:00.000000000 +0000 +++ libmirage-3.2.0/debian/gir1.2-mirage-3.2.install 2018-07-08 12:02:03.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/girepository-1.0/* diff -Nru libmirage-3.1.0/debian/libmirage11.install libmirage-3.2.0/debian/libmirage11.install --- libmirage-3.1.0/debian/libmirage11.install 2017-06-10 21:49:15.000000000 +0000 +++ libmirage-3.2.0/debian/libmirage11.install 2018-07-08 12:02:03.000000000 +0000 @@ -1,4 +1,4 @@ usr/lib/lib*.so.* -usr/lib/libmirage-3.1/*.so +usr/lib/libmirage-3.2/*.so usr/share/mime/packages/*.xml usr/share/locale/*/LC_MESSAGES/libmirage.mo diff -Nru libmirage-3.1.0/debian/rules libmirage-3.2.0/debian/rules --- libmirage-3.1.0/debian/rules 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/debian/rules 2018-07-08 12:02:03.000000000 +0000 @@ -12,10 +12,10 @@ dh_strip --dbg-package="libmirage11-dbg" override_dh_makeshlibs: - dh_makeshlibs --exclude="libmirage-3.1" + dh_makeshlibs --exclude="libmirage-3.2" override_dh_shlibdeps: - dh_shlibdeps --exclude="libmirage-3.1" + dh_shlibdeps --exclude="libmirage-3.2" %: dh $@ --with gir diff -Nru libmirage-3.1.0/images/image-iso/parser.c libmirage-3.2.0/images/image-iso/parser.c --- libmirage-3.1.0/images/image-iso/parser.c 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/images/image-iso/parser.c 2018-07-07 19:55:02.000000000 +0000 @@ -34,6 +34,10 @@ MirageStream *stream; }; +/* Nintendo ISO image patterns */ +static const guint8 pattern_nintendo_gamecube_iso[4] = { 0xC2, 0x33, 0x9F, 0x3D }; +static const guint8 pattern_nintendo_wii_iso[4] = { 0x5D, 0x1C, 0x9E, 0xA3 }; + /**********************************************************************\ * Private structure * @@ -49,10 +53,42 @@ /**********************************************************************\ * File identification * \**********************************************************************/ +static gboolean mirage_parser_iso_read_data_from_offset (MirageParserIso *self, MirageStream *stream, goffset offset, guint8 *buf, gint buflen, GError **error) +{ + /* Seek to offset */ + if (!mirage_stream_seek(stream, offset, G_SEEK_SET, NULL)) { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: failed to seek to %" G_GOFFSET_MODIFIER "Xh to read %d bytes of data!\n", __debug__, offset, buflen); + + gchar tmp[100] = ""; /* Work-around for lack of direct G_GOFFSET_MODIFIER support in xgettext() */ + g_snprintf(tmp, sizeof(tmp)/sizeof(tmp[0]), "%" G_GINT64_MODIFIER "Xh", offset); + g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_IMAGE_FILE_ERROR, Q_("Failed to seek to %s to read %d bytes of data!"), tmp, buflen); + + return FALSE; + } + + /* Read */ + if (mirage_stream_read(stream, buf, buflen, NULL) != buflen) { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: failed to read %d bytes of data!\n", __debug__, buflen); + g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_IMAGE_FILE_ERROR, Q_("Failed to read %d bytes of data!"), buflen); + return FALSE; + } + + return TRUE; +} + static gboolean mirage_parser_iso_determine_sector_size (MirageParserIso *self, struct IsoFileInfo *file_info, GError **error) { - const gint valid_sector_sizes[] = { 2048, 2332, 2336, 2352 }; - const gint data_offset[] = { 0, 0, 0, 16 }; + const struct { + gint sector_size; + gint data_offset; + } valid_sector_sizes[] = { + { 2048, 0 }, /* 2048-byte Mode 1 / Mode 2 Form 1 sector; offset: 0 */ + { 2332, 8 }, /* 2332-byte Mode 2 Form 1 sector; offset: 8 (sub-header) */ + { 2336, 8 }, /* 2336-byte Mode 2 Form 1 sector: offset: 8 (sub-header) */ + { 2352, 16 }, /* 2352-byte Mode 1 sector; offset: 16 (sync+header) */ + { 2352, 24 }, /* 2352-byte Mode 2 Form 1 sector; offset: 24 (synch+header+sub-header */ + }; + const gint valid_subchannel_sizes[] = { 0, 16, 96 }; MirageStream *stream = file_info->stream; @@ -75,11 +111,19 @@ return FALSE; } - /* Check all possible combinations of sector data and subchannel sizes */ + /* Mark track mode and subchannel format for auto-detection via + mirage_parser_iso_determine_track_type() and + mirage_parser_iso_determine_subchannel_type(). This is a general + case that may get overriden by some of the checks below */ + file_info->track_mode = -1; + file_info->subchannel_format = -1; + + /* Assuming a data track with ISO9660 or UDF filesystem, check all + possible combinations of sector data and subchannel sizes */ for (gint i = 0; i < G_N_ELEMENTS(valid_subchannel_sizes); i++) { for (gint j = 0; j < G_N_ELEMENTS(valid_sector_sizes); j++) { - gint full_sector_size = valid_sector_sizes[j] + valid_subchannel_sizes[i]; - MIRAGE_DEBUG(self, MIRAGE_DEBUG_IMAGE_ID, "%s: checking %d-byte sector size with %d-byte subchannel...\n", __debug__, valid_sector_sizes[j], valid_subchannel_sizes[i]); + gint full_sector_size = valid_sector_sizes[j].sector_size + valid_subchannel_sizes[i]; + MIRAGE_DEBUG(self, MIRAGE_DEBUG_IMAGE_ID, "%s: checking %d-byte sector size with %d-byte subchannel and data offset %d...\n", __debug__, valid_sector_sizes[j].sector_size, valid_subchannel_sizes[i], valid_sector_sizes[j].data_offset); /* Check if file size is a multiple of full sector size */ if (file_length % full_sector_size != 0) { @@ -91,27 +135,15 @@ /* Check for CD001 or BEA01 at sector 16 */ guint8 buf[8]; - goffset offset = 16*full_sector_size + data_offset[j]; - - if (!mirage_stream_seek(stream, offset, G_SEEK_SET, NULL)) { - MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: failed to seek to %" G_GOFFSET_MODIFIER "Xh to read 8-byte pattern!\n", __debug__, offset); - - gchar tmp[100] = ""; /* Work-around for lack of direct G_GOFFSET_MODIFIER support in xgettext() */ - g_snprintf(tmp, sizeof(tmp)/sizeof(tmp[0]), "%" G_GINT64_MODIFIER "Xh", offset); - g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_IMAGE_FILE_ERROR, Q_("Failed to seek to %s to read 8-byte pattern!"), tmp); + goffset offset = 16*full_sector_size + valid_sector_sizes[j].data_offset; - return FALSE; - } - - if (mirage_stream_read(stream, buf, 8, NULL) != 8) { - MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: failed to read 8-byte pattern!\n", __debug__); - g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_IMAGE_FILE_ERROR, Q_("Failed to read 8-byte pattern!")); + if (!mirage_parser_iso_read_data_from_offset(self, stream, offset, buf, 8, error)) { return FALSE; } if (!memcmp(buf, mirage_pattern_cd001, sizeof(mirage_pattern_cd001)) || !memcmp(buf, mirage_pattern_bea01, sizeof(mirage_pattern_bea01))) { - file_info->main_data_size = valid_sector_sizes[j]; + file_info->main_data_size = valid_sector_sizes[j].sector_size; file_info->subchannel_data_size = valid_subchannel_sizes[i]; file_info->main_data_format = MIRAGE_MAIN_DATA_FORMAT_DATA; @@ -123,6 +155,46 @@ } } + /* Check for Nintendo GameCube or Wii disc dump. These have 2048-byte + sector data, and contain a 4-byte signature at offset 0x1C or 0x18, + respectively. */ + if (file_length % 2048 == 0) { + gboolean is_nintendo = FALSE; + + MIRAGE_DEBUG(self, MIRAGE_DEBUG_IMAGE_ID, "%s: file size is multiple of 2048; checking for Nintendo GameCube or Wii signature...\n", __debug__); + + /* Nintendo GameCube ISO */ + if (!is_nintendo) { + guint8 buf[4]; + if (mirage_parser_iso_read_data_from_offset(self, stream, 0x1C, buf, 4, NULL) + && !memcmp(buf, pattern_nintendo_gamecube_iso, sizeof(pattern_nintendo_gamecube_iso))) { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_IMAGE_ID, "%s: GameCube ISO signature found!\n", __debug__); + is_nintendo = TRUE; + } + } + + /* Nintendo Wii ISO */ + if (!is_nintendo) { + guint8 buf[4]; + if (mirage_parser_iso_read_data_from_offset(self, stream, 0x18, buf, 4, NULL) + && !memcmp(buf, pattern_nintendo_wii_iso, sizeof(pattern_nintendo_wii_iso))) { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_IMAGE_ID, "%s: Wii ISO signature found!\n", __debug__); + is_nintendo = TRUE; + } + } + + if (is_nintendo) { + file_info->main_data_size = 2048; + file_info->subchannel_data_size = 0; + file_info->main_data_format = MIRAGE_MAIN_DATA_FORMAT_DATA; + + file_info->track_mode = MIRAGE_SECTOR_MODE1; /* Mode 1 track */ + file_info->subchannel_format = 0; /* No sub-channel */ + + return TRUE; + } + } + /* Now that we have ruled out any possible combination for a data track, if the stream length is multiple of 2352, we assume that we are dealing with audio track data */ @@ -163,19 +235,7 @@ MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: 2352-byte main sector data; determining track type at address 16 (offset %" G_GOFFSET_MODIFIER "Xh)...\n", __debug__, offset); - if (!mirage_stream_seek(stream, offset, G_SEEK_SET, NULL)) { - MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: failed to seek to offset %" G_GOFFSET_MODIFIER "Xh to read 16-byte pattern!\n", __debug__, offset); - - gchar tmp[100] = ""; /* Work-around for lack of direct G_GOFFSET_MODIFIER support in xgettext() */ - g_snprintf(tmp, sizeof(tmp)/sizeof(tmp[0]), "%" G_GINT64_MODIFIER "Xh", offset); - g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_IMAGE_FILE_ERROR, Q_("Failed to seek to offset %s to read 16-byte pattern!"), tmp); - - return FALSE; - } - - if (mirage_stream_read(stream, buf, 16, NULL) != 16) { - MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: failed to read 16-byte pattern!\n", __debug__); - g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_IMAGE_FILE_ERROR, Q_("Failed to read 16-byte pattern!")); + if (!mirage_parser_iso_read_data_from_offset(self, stream, offset, buf, 16, error)) { return FALSE; } @@ -214,19 +274,7 @@ MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: 96-byte internal PW subchannel data found!\n", __debug__); MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: determining whether it is linear or interleaved from subchannel data of sector 16 (offset %" G_GOFFSET_MODIFIER "Xh)...\n", __debug__, offset); - if (!mirage_stream_seek(stream, offset, G_SEEK_SET, NULL)) { - MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: failed to seek to offset %" G_GOFFSET_MODIFIER "Xh to read subchannel data!\n", __debug__, offset); - - gchar tmp[100] = ""; /* Work-around for lack of direct G_GOFFSET_MODIFIER support in xgettext() */ - g_snprintf(tmp, sizeof(tmp)/sizeof(tmp[0]), "%" G_GINT64_MODIFIER "Xh", offset); - g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_IMAGE_FILE_ERROR, Q_("Failed to seek to offset %s to read subchannel data!"), tmp); - - return FALSE; - } - - if (mirage_stream_read(stream, buf, sizeof(buf), NULL) != sizeof(buf)) { - MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: failed to read subchannel data!\n", __debug__); - g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_IMAGE_FILE_ERROR, Q_("Failed to read subchannel data!")); + if (!mirage_parser_iso_read_data_from_offset(self, stream, offset, buf, 96, error)) { return FALSE; } @@ -432,8 +480,10 @@ mirage_parser_generate_info(MIRAGE_PARSER(self), "PARSER-ISO", Q_("ISO Image Parser"), - 2, + 4, Q_("ISO images (*.iso, *.bin, *.img)"), "application/x-cd-image", + Q_("GameCube ISO images (*.iso"), "application/x-gamecube-iso-image", + Q_("Wii ISO images (*.iso)"), "application/x-wii-iso-image", Q_("WAV audio files (*.wav)"), "audio/x-wav" ); } diff -Nru libmirage-3.1.0/images/image-iso/writer.c libmirage-3.2.0/images/image-iso/writer.c --- libmirage-3.1.0/images/image-iso/writer.c 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/images/image-iso/writer.c 2018-07-07 19:55:02.000000000 +0000 @@ -268,6 +268,7 @@ /* I/O stream */ stream = mirage_contextual_create_output_stream(MIRAGE_CONTEXTUAL(self), filename, filter_chain, error); + g_free(filename); if (!stream) { g_object_unref(fragment); return NULL; @@ -361,12 +362,24 @@ return G_OBJECT_CLASS(mirage_writer_iso_parent_class)->dispose(gobject); } +static void mirage_writer_iso_finalize (GObject *gobject) +{ + MirageWriterIso *self = MIRAGE_WRITER_ISO(gobject); + + /* Free the image basename */ + g_free(self->priv->image_file_basename); + + /* Chain up to the parent class */ + return G_OBJECT_CLASS(mirage_writer_iso_parent_class)->finalize(gobject); +} + static void mirage_writer_iso_class_init (MirageWriterIsoClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); MirageWriterClass *writer_class = MIRAGE_WRITER_CLASS(klass); gobject_class->dispose = mirage_writer_iso_dispose; + gobject_class->finalize = mirage_writer_iso_finalize; writer_class->open_image = mirage_writer_iso_open_image; writer_class->create_fragment = mirage_writer_iso_create_fragment; diff -Nru libmirage-3.1.0/images/image-mds/parser.c libmirage-3.2.0/images/image-mds/parser.c --- libmirage-3.1.0/images/image-mds/parser.c 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/images/image-mds/parser.c 2018-07-07 19:55:02.000000000 +0000 @@ -297,49 +297,46 @@ data consists of 8200 bytes, containing afore-mentioned sequence for each layer. */ if (self->priv->header->disc_structures_offset) { - MirageDiscStructureCopyright *copy_info; - MirageDiscStructureManufacturingData *manu_info; - MirageDiscStructurePhysicalInfo *phys_info; - MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: reading disc structures\n", __debug__); cur_ptr = self->priv->mds_data + self->priv->header->disc_structures_offset; - /* DVD copyright information */ - copy_info = MIRAGE_CAST_PTR(cur_ptr, 0, MirageDiscStructureCopyright *); - cur_ptr += sizeof(MirageDiscStructureCopyright); - - /* DVD manufacture information */ - manu_info = MIRAGE_CAST_PTR(cur_ptr, 0, MirageDiscStructureManufacturingData *); - cur_ptr += sizeof(MirageDiscStructureManufacturingData); - - /* Physical information */ - phys_info = MIRAGE_CAST_PTR(cur_ptr, 0, MirageDiscStructurePhysicalInfo *); - cur_ptr += sizeof(MirageDiscStructurePhysicalInfo); - - mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0000, (guint8 *)phys_info, sizeof(MirageDiscStructureCopyright)); - mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0001, (guint8 *)copy_info, sizeof(MirageDiscStructureManufacturingData)); - mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0004, (guint8 *)manu_info, sizeof(MirageDiscStructurePhysicalInfo)); + /* 0x0001: DVD copyright information */ + mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0001, cur_ptr, 4); + cur_ptr += 4; + + /* 0x0004: DVD manufacturing information */ + mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0004, cur_ptr, 2048); + cur_ptr += 2048; + + /* 0x0000: Physical information */ + int num_layers = (cur_ptr[2] & 0x60) >> 4; /* Bits 5 and 6 of byte 2 comprise num_layers field */ + if (num_layers == 0x01) { + num_layers = 2; /* field value 01b specifies 2 layers */ + } else { + num_layers = 1; /* field value 00b specifies 1 layer */ + } + + MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: number of layers: %d\n", __debug__, num_layers); + + mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0000, cur_ptr, 2048); + cur_ptr += 2048; /* Second round if it's dual-layer... */ - if (phys_info->num_layers == 0x01) { + if (num_layers == 2) { MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: dual-layer disc; reading disc structures for second layer\n", __debug__); - /* DVD copyright information */ - copy_info = MIRAGE_CAST_PTR(cur_ptr, 0, MirageDiscStructureCopyright *); - cur_ptr += sizeof(MirageDiscStructureCopyright); - - /* DVD manufacture information */ - manu_info = MIRAGE_CAST_PTR(cur_ptr, 0, MirageDiscStructureManufacturingData *); - cur_ptr += sizeof(MirageDiscStructureManufacturingData); - - /* Physical information */ - phys_info = MIRAGE_CAST_PTR(cur_ptr, 0, MirageDiscStructurePhysicalInfo *); - cur_ptr += sizeof(MirageDiscStructurePhysicalInfo); - - mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0000, (guint8 *)phys_info, sizeof(MirageDiscStructureCopyright)); - mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0001, (guint8 *)copy_info, sizeof(MirageDiscStructureManufacturingData)); - mirage_disc_set_disc_structure(self->priv->disc, 0, 0x0004, (guint8 *)manu_info, sizeof(MirageDiscStructurePhysicalInfo)); + /* 0x0001: DVD copyright information */ + mirage_disc_set_disc_structure(self->priv->disc, 1, 0x0001, cur_ptr, 4); + cur_ptr += 4; + + /* 0x0004: DVD manufacturing information */ + mirage_disc_set_disc_structure(self->priv->disc, 1, 0x0004, cur_ptr, 2048); + cur_ptr += 2048; + + /* 0x0000: Physical information */ + mirage_disc_set_disc_structure(self->priv->disc, 1, 0x0000, cur_ptr, 2048); + cur_ptr += 2048; } } } diff -Nru libmirage-3.1.0/images/image-toc/writer.c libmirage-3.2.0/images/image-toc/writer.c --- libmirage-3.1.0/images/image-toc/writer.c 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/images/image-toc/writer.c 2018-07-07 19:55:02.000000000 +0000 @@ -335,6 +335,7 @@ /* TOC does not list first track's pregap. Unless it is greater than standard 150? But the first fragment (j == 0) always model the standard pregap */ + g_free(length_msf); g_object_unref(fragment); continue; } @@ -346,6 +347,7 @@ } } + g_free(length_msf); g_object_unref(fragment); } @@ -559,6 +561,7 @@ /* I/O stream */ stream = mirage_contextual_create_output_stream(MIRAGE_CONTEXTUAL(self), filename, filter_chain, error); + g_free(filename); if (!stream) { g_object_unref(fragment); return NULL; @@ -643,12 +646,24 @@ return G_OBJECT_CLASS(mirage_writer_toc_parent_class)->dispose(gobject); } +static void mirage_writer_toc_finalize (GObject *gobject) +{ + MirageWriterToc *self = MIRAGE_WRITER_TOC(gobject); + + /* Free the image basename */ + g_free(self->priv->image_file_basename); + + /* Chain up to the parent class */ + return G_OBJECT_CLASS(mirage_writer_toc_parent_class)->finalize(gobject); +} + static void mirage_writer_toc_class_init (MirageWriterTocClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); MirageWriterClass *writer_class = MIRAGE_WRITER_CLASS(klass); gobject_class->dispose = mirage_writer_toc_dispose; + gobject_class->finalize = mirage_writer_toc_finalize; writer_class->open_image = mirage_writer_toc_open_image; writer_class->create_fragment = mirage_writer_toc_create_fragment; diff -Nru libmirage-3.1.0/mirage/disc.c libmirage-3.2.0/mirage/disc.c --- libmirage-3.1.0/mirage/disc.c 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/mirage/disc.c 2018-07-07 19:55:02.000000000 +0000 @@ -162,71 +162,6 @@ MIRAGE_DEBUG(self, MIRAGE_DEBUG_DISC, "%s: end\n", __debug__); } - -static void mirage_disc_generate_disc_structure (MirageDisc *self, gint layer, gint type) -{ - MIRAGE_DEBUG(self, MIRAGE_DEBUG_DISC, "%s: start (layer: %d, type: 0x%X)\n", __debug__, layer, type); - - switch (type) { - case 0x0000: { - MirageDiscStructurePhysicalInfo *phys_info = g_new0(MirageDiscStructurePhysicalInfo, 1); - - gint disc_length = mirage_disc_layout_get_length(self); - - phys_info->book_type = 0x00; /* DVD-ROM */ - phys_info->part_ver = 0x05; /* Let's say we comply with v.5 of DVD-ROM book */ - phys_info->disc_size = 0x00; /* 120mm disc */ - phys_info->max_rate = 0x0F; /* Not specified */ - phys_info->num_layers = 0x00; /* 0x00: 1 layer */ - phys_info->track_path = 0; /* Parallell track path */ - phys_info->layer_type = 1; /* Layer contains embossed data */ - phys_info->linear_density = 0; /* 0.267 um/bit */ - phys_info->track_density = 0; /* 0.74 um/track */ - /* The following three fields are 24-bit... */ - phys_info->data_start = GUINT32_FROM_BE(0x30000) >> 8; /* DVD-ROM */ - phys_info->data_end = GUINT32_FROM_BE(0x30000+disc_length) >> 8; /* FIXME: It seems lead-in (out?) length should be subtracted here (241-244 sectors...) */ - phys_info->layer0_end = GUINT32_FROM_BE(0x00) >>8; /* We don't contain multiple layers, but we don't use OTP, so we might get away with this */ - phys_info->bca = 0; - - /* Store the structure */ - mirage_disc_set_disc_structure(self, layer, type, (const guint8 *)phys_info, sizeof(MirageDiscStructurePhysicalInfo)); - break; - } - case 0x0001: { - MirageDiscStructureCopyright *copy_info = g_new0(MirageDiscStructureCopyright, 1); - - GVariant *dvd_report_css_value; - gboolean dvd_report_css = FALSE; - - dvd_report_css_value = mirage_contextual_get_option(MIRAGE_CONTEXTUAL(self), "dvd-report-css"); - if (dvd_report_css_value) { - dvd_report_css = g_variant_get_boolean(dvd_report_css_value); - g_variant_unref(dvd_report_css_value); - } - - if (dvd_report_css) { - copy_info->copy_protection = 0x01; /* CSS/CPPM */ - copy_info->region_info = 0x00; /* Playable in all regions */ - } else { - copy_info->copy_protection = 0x00;/* None */ - copy_info->region_info = 0x00; /* N/A */ - } - - /* Store the structure */ - mirage_disc_set_disc_structure(self, layer, type, (const guint8 *)copy_info, sizeof(MirageDiscStructureCopyright)); - break; - } - case 0x0004: { - MirageDiscStructureManufacturingData *manu_info = g_new0(MirageDiscStructureManufacturingData, 1); - - /* Store the structure */ - mirage_disc_set_disc_structure(self, layer, type, (const guint8 *)manu_info, sizeof(MirageDiscStructureManufacturingData)); - break; - } - } -} - - static gint sort_sessions_by_number (MirageSession *session1, MirageSession *session2) { gint number1 = mirage_session_layout_get_session_number(session1); @@ -1391,16 +1326,8 @@ array = g_hash_table_lookup(self->priv->disc_structures, GINT_TO_POINTER(key)); if (!array) { - /* Structure needs to be fabricated (if appropriate) */ - mirage_disc_generate_disc_structure(self, layer, type); - - /* Try getting it again */ - array = g_hash_table_lookup(self->priv->disc_structures, GINT_TO_POINTER(key)); - - if (!array) { - g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_DISC_ERROR, Q_("Disc structure data not provided and could not be fabricated!")); - return FALSE; - } + g_set_error(error, MIRAGE_ERROR, MIRAGE_ERROR_DISC_ERROR, Q_("Disc structure data not provided!")); + return FALSE; } if (data) { diff -Nru libmirage-3.1.0/mirage/disc-structures.h libmirage-3.2.0/mirage/disc-structures.h --- libmirage-3.1.0/mirage/disc-structures.h 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/mirage/disc-structures.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -/* - * libMirage: disc structures - * Copyright (C) 2006-2014 Rok Mandeljc - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __MIRAGE_DISC_STRUCTURES_H__ -#define __MIRAGE_DISC_STRUCTURES_H__ - - -G_BEGIN_DECLS - -/* Note: although at the moment these have the same layout as structures defined - in MMC-3, they are libMirage's internal representation of disc structures and - could thus change any time */ - -typedef struct -{ - #if G_BYTE_ORDER == G_BIG_ENDIAN - guint8 book_type : 4; - guint8 part_ver : 4; - #else - guint8 part_ver : 4; - guint8 book_type : 4; - #endif - - #if G_BYTE_ORDER == G_BIG_ENDIAN - guint8 disc_size : 4; - guint8 max_rate : 4; - #else - guint8 max_rate : 4; - guint8 disc_size : 4; - #endif - - #if G_BYTE_ORDER == G_BIG_ENDIAN - guint8 __dummy1__ : 1; - guint8 num_layers : 2; - guint8 track_path : 1; - guint8 layer_type : 4; - #else - guint8 layer_type : 4; - guint8 track_path : 1; - guint8 num_layers : 2; - guint8 __dummy1__ : 1; - #endif - - #if G_BYTE_ORDER == G_BIG_ENDIAN - guint8 linear_density : 4; - guint8 track_density : 4; - #else - guint8 track_density : 4; - guint8 linear_density : 4; - #endif - - #if G_BYTE_ORDER == G_BIG_ENDIAN - guint32 __dummy2__ : 8; - guint32 data_start : 24; - #else - guint32 data_start : 24; - guint32 __dummy2__ : 8; - #endif - - #if G_BYTE_ORDER == G_BIG_ENDIAN - guint32 __dummy3__ : 8; - guint32 data_end : 24; - #else - guint32 data_end : 24; - guint32 __dummy3__ : 8; - #endif - - #if G_BYTE_ORDER == G_BIG_ENDIAN - guint32 __dummy4__ : 8; - guint32 layer0_end : 24; - #else - guint32 layer0_end : 24; - guint32 __dummy4__ : 8; - #endif - - #if G_BYTE_ORDER == G_BIG_ENDIAN - guint8 bca : 1; - guint8 __dummy5__ : 7; - #else - guint8 __dummy5__ : 7; - guint8 bca : 1; - #endif - - guint8 media_specific[2031]; -} MirageDiscStructurePhysicalInfo; - -typedef struct -{ - guint8 copy_protection; - guint8 region_info; - guint8 __dummy1__; - guint8 __dummy2__; -} MirageDiscStructureCopyright; - -typedef struct -{ - guint8 disc_manufacturing_data[2048]; -} MirageDiscStructureManufacturingData; - -G_END_DECLS - -#endif /* __MIRAGE_DISC_STRUCTURES_H__ */ diff -Nru libmirage-3.1.0/mirage/mirage.h libmirage-3.2.0/mirage/mirage.h --- libmirage-3.1.0/mirage/mirage.h 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/mirage/mirage.h 2018-07-07 19:55:02.000000000 +0000 @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff -Nru libmirage-3.1.0/mirage/parser.c libmirage-3.2.0/mirage/parser.c --- libmirage-3.1.0/mirage/parser.c 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/mirage/parser.c 2018-07-07 19:55:02.000000000 +0000 @@ -190,10 +190,22 @@ if (length <= 90*60*75) { MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: disc layout size implies CD-ROM image\n", __debug__); return MIRAGE_MEDIUM_CD; - } else { - MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: disc layout size implies DVD-ROM image\n", __debug__); + } else if (length <= 2295104) { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: disc layout size implies single-layer DVD-ROM image\n", __debug__); + return MIRAGE_MEDIUM_DVD; + } else if (length <= 4173824) { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: disc layout size implies dual-layer DVD-ROM image\n", __debug__); return MIRAGE_MEDIUM_DVD; - }; + } else if (length <= 12219392) { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: disc layout size implies single-layer BD-ROM image\n", __debug__); + return MIRAGE_MEDIUM_BD; + } else if (length <= 24438784) { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_PARSER, "%s: disc layout size implies dual-layer BD-ROM image\n", __debug__); + return MIRAGE_MEDIUM_BD; + } else { + MIRAGE_DEBUG(self, MIRAGE_DEBUG_WARNING, "%s: disc layout size (%d) exceeds all known media types - assuming BD-ROM!\n", __debug__, length); + return MIRAGE_MEDIUM_BD; + } } /** diff -Nru libmirage-3.1.0/README libmirage-3.2.0/README --- libmirage-3.1.0/README 2017-06-10 21:29:17.000000000 +0000 +++ libmirage-3.2.0/README 2018-07-07 19:55:02.000000000 +0000 @@ -1,5 +1,5 @@ libMirage -3.1.0 +3.2.0 ~~~~~ @@ -87,6 +87,8 @@ 3. Requirements: ~~~~~~~~~~~~~~~~ + + - CMake >= 2.8.5 - GLib >= 2.28 - libsndfile >= 1.0.0 - libsamplerate >= 0.1.0