Draft 1 of CDXA embedding
This commit is contained in:
parent
38c1c90fd5
commit
b6e4558e35
|
@ -49,7 +49,7 @@ pub const fn xa_audio_interleave_count(files: usize) -> usize {
|
|||
}
|
||||
|
||||
pub const fn sector_count_audio(audio_samples: usize) -> usize {
|
||||
multiple_of_round_up(audio_samples, sector::Audio::SAMPLE_SIZE)
|
||||
multiple_of_round_up(audio_samples, sector::Audio::DATA_SIZE)
|
||||
}
|
||||
|
||||
pub const fn sector_count_mode2_form1(data_size: usize) -> usize {
|
||||
|
|
|
@ -54,6 +54,7 @@ pub fn create_xa_audio_for_raw(mut sub_mode: SubMode, coding_info: CodingInfo, c
|
|||
|
||||
sub_mode.set_audio();
|
||||
|
||||
sector.sub_header.file_number = 1;
|
||||
sector.sub_header.channel_number = channel;
|
||||
sector.sub_header.sub_mode = sub_mode;
|
||||
sector.sub_header.coding_info = coding_info;
|
||||
|
@ -116,21 +117,23 @@ pub fn create_xa_audio_for(data: &Vec<RawData>) -> Vec<Mode2Form2> {
|
|||
|
||||
for sector_id in 0..sectors_to_parse {
|
||||
let mut channel_id = 0;
|
||||
let sub_mode = {
|
||||
let mut sub_mode = SubMode::default_form2();
|
||||
sub_mode.set_real_time();
|
||||
|
||||
if sector_id + 1 == sectors_to_parse {
|
||||
sub_mode.set_eof();
|
||||
sub_mode.set_eor();
|
||||
}
|
||||
sub_mode
|
||||
};
|
||||
|
||||
for channel in &mut channels {
|
||||
let sub_mode = {
|
||||
let mut sub_mode = SubMode::default_form2();
|
||||
|
||||
if sector_id + 1 == sectors_to_parse {
|
||||
sub_mode.set_eof();
|
||||
sub_mode.set_eor();
|
||||
}
|
||||
|
||||
else {
|
||||
sub_mode.set_real_time();
|
||||
}
|
||||
sub_mode
|
||||
};
|
||||
let (raw_data, coding_info) = {
|
||||
if channel.is_empty() {
|
||||
([0u8; Mode2Form2::DATA_SIZE], CodingInfo::default())
|
||||
([0xFFu8; Mode2Form2::DATA_SIZE], CodingInfo::default())
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -149,11 +152,19 @@ pub fn create_xa_audio_for(data: &Vec<RawData>) -> Vec<Mode2Form2> {
|
|||
(raw_data, sub_header.coding_info)
|
||||
}
|
||||
};
|
||||
|
||||
sectors[cur_sector_id] = create_xa_audio_for_raw(sub_mode, coding_info, channel_id, &raw_data);
|
||||
channel_id += 1;
|
||||
cur_sector_id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for channel in channels {
|
||||
if !channel.is_empty() {
|
||||
tool_helper::print_warning(format!("Channel not fully encoded!"));
|
||||
}
|
||||
}
|
||||
|
||||
sectors
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use cdtypes::types::helper::sector_count_mode2_form2;
|
||||
use cdtypes::types::helper::sector_count_audio;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -108,7 +108,7 @@ pub struct InterleavedXASizes {
|
|||
|
||||
impl InterleavedXASizes {
|
||||
pub fn new(content: &Vec<RawData>) -> InterleavedXASizes {
|
||||
let biggest_file_size = {
|
||||
let biggest_file_sectors = {
|
||||
let mut biggest_size = 0;
|
||||
|
||||
for channel in content {
|
||||
|
@ -116,12 +116,14 @@ impl InterleavedXASizes {
|
|||
biggest_size = channel.len();
|
||||
}
|
||||
}
|
||||
biggest_size
|
||||
|
||||
// Strip off all the unnecessary data
|
||||
sector_count_audio(biggest_size) + 1
|
||||
// ^ encoding file end for streaming
|
||||
};
|
||||
let channels = content.len();
|
||||
let biggest_file_sectors = sector_count_mode2_form2(biggest_file_size);
|
||||
let channels = content.len();
|
||||
InterleavedXASizes{
|
||||
channels, biggest_file_sectors, full_size_bytes: channels*biggest_file_sectors*Mode2Form2::DATA_SIZE
|
||||
channels, biggest_file_sectors: biggest_file_sectors, full_size_bytes: channels*biggest_file_sectors*Mode2Form2::DATA_SIZE
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue