Skip to content

Commit 456df01

Browse files
Ubi SB: Renamed some vars, doc
1 parent e806213 commit 456df01

File tree

1 file changed

+44
-43
lines changed

1 file changed

+44
-43
lines changed

src/meta/ubi_sb.c

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ typedef struct {
2929
off_t audio_stream_size;
3030
off_t audio_stream_offset;
3131
off_t audio_stream_type;
32-
off_t audio_subblock_flag;
33-
off_t audio_subblock2_flag;
32+
off_t audio_software_flag;
33+
off_t audio_hwmodule_flag;
3434
off_t audio_streamed_flag;
3535
off_t audio_cd_streamed_flag;
3636
off_t audio_loop_flag;
@@ -49,8 +49,8 @@ typedef struct {
4949
int audio_streamed_and;
5050
int audio_cd_streamed_and;
5151
int audio_loop_and;
52-
int audio_subblock_and;
53-
int audio_subblock2_and;
52+
int audio_software_and;
53+
int audio_hwmodule_and;
5454
int audio_loc_and;
5555
int audio_stereo_and;
5656
int audio_ram_streamed_and;
@@ -1848,21 +1848,22 @@ static int parse_type_audio(ubi_sb_header* sb, off_t offset, STREAMFILE* sf) {
18481848
sb->is_external = (int)!(read_32bit(offset + sb->cfg.audio_internal_flag, sf));
18491849
}
18501850

1851-
if (sb->cfg.audio_subblock_flag && sb->cfg.audio_subblock_and) {
1852-
/* flag probably means "software decoded" */
1853-
int subblock_flag = read_32bit(offset + sb->cfg.audio_subblock_flag, sf) & sb->cfg.audio_subblock_and;
1854-
sb->subblock_id = (!subblock_flag) ? 0 : 1;
1851+
if (sb->cfg.audio_software_flag && sb->cfg.audio_software_and) {
1852+
/* software decoded and hardware decoded sounds are stored in separate subblocks */
1853+
int software_flag = read_32bit(offset + sb->cfg.audio_software_flag, sf) & sb->cfg.audio_software_and;
1854+
sb->subblock_id = (!software_flag) ? 0 : 1;
18551855

18561856
if (sb->platform == UBI_PS2) {
1857-
int subblock2_flag = read_32bit(offset + sb->cfg.audio_subblock2_flag, sf) & sb->cfg.audio_subblock2_and;
1858-
sb->subblock_id = (!subblock_flag) ? ((!subblock2_flag) ? 0 : 3) : 1;
1857+
/* flag appears to mean "load into IOP memory instead of SPU" */
1858+
int hwmodule_flag = read_32bit(offset + sb->cfg.audio_hwmodule_flag, sf) & sb->cfg.audio_hwmodule_and;
1859+
sb->subblock_id = (!software_flag) ? ((!hwmodule_flag) ? 0 : 3) : 1;
18591860
}
18601861

18611862
/* PC can have subblock 2 based on two fields near the end but it wasn't seen so far */
18621863

18631864
/* stream_type field is not used if the flag is not set (it even contains garbage in some versions)
18641865
* except for PS3 which has two hardware codecs (PSX and AT3) */
1865-
if (!subblock_flag && sb->platform != UBI_PS3)
1866+
if (!software_flag && sb->platform != UBI_PS3)
18661867
sb->stream_type = 0x00;
18671868
} else {
18681869
sb->subblock_id = (sb->stream_type == 0x01) ? 0 : 1;
@@ -2636,22 +2637,22 @@ static void config_sb_entry(ubi_sb_header* sb, size_t section1_size_entry, size_
26362637
sb->cfg.section2_entry_size = section2_size_entry;
26372638
sb->cfg.section3_entry_size = 0x08;
26382639
}
2639-
static void config_sb_audio_fs(ubi_sb_header* sb, off_t streamed_flag, off_t subblock_flag, off_t loop_flag) {
2640+
static void config_sb_audio_fs(ubi_sb_header* sb, off_t streamed_flag, off_t software_flag, off_t loop_flag) {
26402641
/* audio header with standard flags */
26412642
sb->cfg.audio_streamed_flag = streamed_flag;
2642-
sb->cfg.audio_subblock_flag = subblock_flag;
2643+
sb->cfg.audio_software_flag = software_flag;
26432644
sb->cfg.audio_loop_flag = loop_flag;
26442645
sb->cfg.audio_streamed_and = 1;
2645-
sb->cfg.audio_subblock_and = 1;
2646+
sb->cfg.audio_software_and = 1;
26462647
sb->cfg.audio_loop_and = 1;
26472648
}
2648-
static void config_sb_audio_fb(ubi_sb_header* sb, off_t flag_bits, int streamed_and, int subblock_and, int loop_and) {
2649+
static void config_sb_audio_fb(ubi_sb_header* sb, off_t flag_bits, int streamed_and, int software_and, int loop_and) {
26492650
/* audio header with bit flags */
26502651
sb->cfg.audio_streamed_flag = flag_bits;
2651-
sb->cfg.audio_subblock_flag = flag_bits;
2652+
sb->cfg.audio_software_flag = flag_bits;
26522653
sb->cfg.audio_loop_flag = flag_bits;
26532654
sb->cfg.audio_streamed_and = streamed_and;
2654-
sb->cfg.audio_subblock_and = subblock_and;
2655+
sb->cfg.audio_software_and = software_and;
26552656
sb->cfg.audio_loop_and = loop_and;
26562657
}
26572658
static void config_sb_audio_hs(ubi_sb_header* sb, off_t channels, off_t sample_rate, off_t num_samples, off_t num_samples2, off_t stream_name, off_t stream_type) {
@@ -2672,40 +2673,40 @@ static void config_sb_audio_he(ubi_sb_header* sb, off_t channels, off_t sample_r
26722673
sb->cfg.audio_extra_name = extra_name;
26732674
sb->cfg.audio_stream_type = stream_type;
26742675
}
2675-
static void config_sb_audio_fb_ps2(ubi_sb_header* sb, off_t flag_bits, int streamed_and, int subblock_and, int loop_and, int subblock2_and) {
2676+
static void config_sb_audio_fb_ps2(ubi_sb_header* sb, off_t flag_bits, int streamed_and, int software_and, int loop_and, int hwmodule_and) {
26762677
/* audio header with bit flags */
26772678
sb->cfg.audio_streamed_flag = flag_bits;
2678-
sb->cfg.audio_subblock_flag = flag_bits;
2679+
sb->cfg.audio_software_flag = flag_bits;
26792680
sb->cfg.audio_loop_flag = flag_bits;
2680-
sb->cfg.audio_subblock2_flag = flag_bits;
2681+
sb->cfg.audio_hwmodule_flag = flag_bits;
26812682
sb->cfg.audio_streamed_and = streamed_and;
2682-
sb->cfg.audio_subblock_and = subblock_and;
2683+
sb->cfg.audio_software_and = software_and;
26832684
sb->cfg.audio_loop_and = loop_and;
2684-
sb->cfg.audio_subblock2_and = subblock2_and;
2685+
sb->cfg.audio_hwmodule_and = hwmodule_and;
26852686
}
26862687
static void config_sb_audio_ps2_bnm(ubi_sb_header *sb, off_t flag_bits, int streamed_and, int cd_streamed_and, int loop_and, off_t channels, off_t sample_rate) {
26872688
/* bit flags, channels and sample rate */
2688-
sb->cfg.audio_streamed_flag = flag_bits;
2689-
sb->cfg.audio_cd_streamed_flag = flag_bits;
2690-
sb->cfg.audio_loop_flag = flag_bits;
2691-
sb->cfg.audio_streamed_and = streamed_and;
2692-
sb->cfg.audio_cd_streamed_and = cd_streamed_and;
2693-
sb->cfg.audio_loop_and = loop_and;
2694-
sb->cfg.audio_channels = channels;
2695-
sb->cfg.audio_sample_rate = sample_rate;
2689+
sb->cfg.audio_streamed_flag = flag_bits;
2690+
sb->cfg.audio_cd_streamed_flag = flag_bits;
2691+
sb->cfg.audio_loop_flag = flag_bits;
2692+
sb->cfg.audio_streamed_and = streamed_and;
2693+
sb->cfg.audio_cd_streamed_and = cd_streamed_and;
2694+
sb->cfg.audio_loop_and = loop_and;
2695+
sb->cfg.audio_channels = channels;
2696+
sb->cfg.audio_sample_rate = sample_rate;
26962697
}
26972698
static void config_sb_audio_ps2_old(ubi_sb_header *sb, off_t flag_bits, int streamed_and, int loop_and, int loc_and, int stereo_and, off_t pitch, off_t sample_rate) {
26982699
/* bit flags, sample rate only */
2699-
sb->cfg.audio_streamed_flag = flag_bits;
2700-
sb->cfg.audio_loop_flag = flag_bits;
2701-
sb->cfg.audio_loc_flag = flag_bits;
2702-
sb->cfg.audio_stereo_flag = flag_bits;
2703-
sb->cfg.audio_streamed_and = streamed_and;
2704-
sb->cfg.audio_loop_and = loop_and;
2705-
sb->cfg.audio_loc_and = loc_and;
2706-
sb->cfg.audio_stereo_and = stereo_and;
2707-
sb->cfg.audio_pitch = pitch;
2708-
sb->cfg.audio_sample_rate = sample_rate;
2700+
sb->cfg.audio_streamed_flag = flag_bits;
2701+
sb->cfg.audio_loop_flag = flag_bits;
2702+
sb->cfg.audio_loc_flag = flag_bits;
2703+
sb->cfg.audio_stereo_flag = flag_bits;
2704+
sb->cfg.audio_streamed_and = streamed_and;
2705+
sb->cfg.audio_loop_and = loop_and;
2706+
sb->cfg.audio_loc_and = loc_and;
2707+
sb->cfg.audio_stereo_and = stereo_and;
2708+
sb->cfg.audio_pitch = pitch;
2709+
sb->cfg.audio_sample_rate = sample_rate;
27092710
}
27102711
static void config_sb_sequence(ubi_sb_header* sb, off_t sequence_count, off_t entry_size) {
27112712
/* sequence header and chain table */
@@ -3857,7 +3858,7 @@ static int config_sb_version(ubi_sb_header* sb, STREAMFILE* sf) {
38573858
(sb->version == 0x00190005 && sb->platform == UBI_PSP)) {
38583859
config_sb_entry(sb, 0x48, 0x58);
38593860

3860-
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 4)); /* assumed subblock_flag */
3861+
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 4)); /* assumed software_flag */
38613862
config_sb_audio_he(sb, 0x28, 0x2c, 0x34, 0x3c, 0x44, 0x48);
38623863

38633864
config_sb_sequence(sb, 0x2c, 0x10);
@@ -3871,7 +3872,7 @@ static int config_sb_version(ubi_sb_header* sb, STREAMFILE* sf) {
38713872
if (sb->version == 0x00190002 && sb->platform == UBI_PS2) {
38723873
config_sb_entry(sb, 0x48, 0x5c);
38733874

3874-
config_sb_audio_fb_ps2(sb, 0x20, (1 << 2), (1 << 3), (1 << 4), (1 << 5)); /* assumed subblock_flag */
3875+
config_sb_audio_fb_ps2(sb, 0x20, (1 << 2), (1 << 3), (1 << 4), (1 << 5)); /* assumed software_flag */
38753876
config_sb_audio_he(sb, 0x28, 0x2c, 0x34, 0x3c, 0x44, 0x48);
38763877

38773878
config_sb_sequence(sb, 0x2c, 0x10);
@@ -3994,7 +3995,7 @@ static int config_sb_version(ubi_sb_header* sb, STREAMFILE* sf) {
39943995
if (sb->version == 0x001D0000 && sb->platform == UBI_PSP) {
39953996
config_sb_entry(sb, 0x40, 0x60);
39963997

3997-
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 5)); /* assumed subblock_flag */
3998+
config_sb_audio_fb(sb, 0x20, (1 << 2), (1 << 3), (1 << 5)); /* assumed software_flag */
39983999
config_sb_audio_he(sb, 0x28, 0x30, 0x38, 0x40, 0x48, 0x4c);
39994000
return 1;
40004001
}

0 commit comments

Comments
 (0)