Utilities

Utilities — Various helper and utility functions.

Functions

#define MIRAGE_CAST_DATA()
#define MIRAGE_CAST_PTR()
guint8 mirage_helper_ascii2isrc ()
gint mirage_helper_bcd2hex ()
guint16 mirage_helper_calculate_crc16 ()
guint32 mirage_helper_calculate_crc32_fast ()
guint32 mirage_helper_calculate_crc32_standard ()
MirageSectorType mirage_helper_determine_sector_type ()
const gchar * mirage_helper_encoding_from_bom ()
gchar * mirage_helper_find_data_file ()
const gchar * mirage_helper_get_suffix ()
gboolean mirage_helper_has_suffix ()
gint mirage_helper_hex2bcd ()
guint16 * mirage_helper_init_crc16_lut ()
guint32 * mirage_helper_init_crc32_lut ()
guint8 * mirage_helper_init_ecma_130b_scrambler_lut ()
gchar mirage_helper_isrc2ascii ()
void mirage_helper_lba2msf ()
gchar * mirage_helper_lba2msf_str ()
gint mirage_helper_msf2lba ()
gint mirage_helper_msf2lba_str ()
void mirage_helper_sector_edc_ecc_compute_ecc_block ()
void mirage_helper_sector_edc_ecc_compute_edc_block ()
gint mirage_helper_strcasecmp ()
gint mirage_helper_strncasecmp ()
gchar * mirage_helper_format_string ()
gchar * mirage_helper_format_stringd ()
gchar * mirage_helper_format_stringv ()
void mirage_helper_subchannel_deinterleave ()
void mirage_helper_subchannel_interleave ()
guint16 mirage_helper_subchannel_q_calculate_crc ()
void mirage_helper_subchannel_q_decode_isrc ()
void mirage_helper_subchannel_q_decode_mcn ()
void mirage_helper_subchannel_q_encode_isrc ()
void mirage_helper_subchannel_q_encode_mcn ()
gboolean mirage_helper_validate_isrc ()

Types and Values

enum MirageSubChannel
extern guint16 * crc16_1021_lut
extern guint32 * crc32_d8018001_lut
extern guint8 * ecma_130_scrambler_lut

Includes

#include <mirage-utils.h>

Description

These functions cover various functionality. They are exported because, while primarily designed to be used within libMirage, they could also prove useful to other applications.

Functions

MIRAGE_CAST_DATA()

#define MIRAGE_CAST_DATA(buf,off,type) (*((type *)(buf+off)))

A macro for easy retrieval of data from (unsigned integer) buffer. Mostly to be used in binary image parsers, for example, to retrieve guint32 or guint16 value from buffer.

Parameters

buf

buffer to get data from

 

off

offset in buffer at which to get data

 

type

data type (i.e. 'guint64')

 

MIRAGE_CAST_PTR()

#define MIRAGE_CAST_PTR(buf,off,type) ((type)(buf+off))

A macro for easy placing of pointers within (unsigned integer) buffer. Mostly to be used in binary image parsers, for example, to retrieve a string or a structure from buffer.

Parameters

buf

buffer to place pointer in

 

off

offset in buffer at which to place pointer

 

type

pointer type (i.e. 'gchar *')

 

mirage_helper_ascii2isrc ()

guint8
mirage_helper_ascii2isrc (gchar c);

Converts ASCII character c into ISRC character.

Parameters

c

ASCII character.

[in]

Returns

ISRC character


mirage_helper_bcd2hex ()

gint
mirage_helper_bcd2hex (gint bcd);

Converts bcd-encoded integer into hex-encoded integer.

Parameters

bcd

bcd-encoded integer.

[in]

Returns

hex-encoded integer


mirage_helper_calculate_crc16 ()

guint16
mirage_helper_calculate_crc16 (const guint8 *data,
                               guint length,
                               const guint16 *crctab,
                               gboolean reflected,
                               gboolean invert);

Calculates the CRC-16 checksum of the data stored in data .

Parameters

data

buffer containing data.

[in][array length=length]

length

length of data.

[in]

crctab

pointer to CRC polynomial table.

[in][array fixed-size=256]

reflected

whether to use the reflected algorithm.

[in]

invert

whether the result should be inverted.

[in]

Returns

CRC-16 checksum of data


mirage_helper_calculate_crc32_fast ()

guint32
mirage_helper_calculate_crc32_fast (const guint8 *data,
                                    guint length,
                                    const guint32 *crctab,
                                    gboolean reflected,
                                    gboolean invert);

Calculates the CRC-32 checksum of the data stored in data . This is fast slice-by-8 implementation that processes 8 bytes at a time, and requires crctab to be allocating using mirage_helper_init_crc32_lut() with slice parameter set to 8.

Parameters

data

buffer containing data.

[in][array length=length]

length

length of data.

[in]

crctab

pointer to CRC polynomial table.

[in][array fixed-size=2048]

reflected

whether to use the reflected algorithm.

[in]

invert

whether the initial value and result should be inverted.

[in]

Returns

CRC-32 checksum of data


mirage_helper_calculate_crc32_standard ()

guint32
mirage_helper_calculate_crc32_standard
                               (const guint8 *data,
                                guint length,
                                const guint32 *crctab,
                                gboolean reflected,
                                gboolean invert);

Calculates the CRC-32 checksum of the data stored in data . This is standard inplementation that processes 1 byte at a time, and requires crctab to be allocated using mirage_helper_init_crc32_lut() with slice parameter set to 1.

Parameters

data

buffer containing data.

[in][array length=length]

length

length of data.

[in]

crctab

pointer to CRC polynomial table.

[in][array fixed-size=256]

reflected

whether to use the reflected algorithm.

[in]

invert

whether the initial value and result should be inverted.

[in]

Returns

CRC-32 checksum of data


mirage_helper_determine_sector_type ()