mirror of
https://github.com/WonderfulToolchain/psxavenc.git
synced 2025-12-17 19:40:26 +00:00
Minor fixes for interleaved .vag loop points
This commit is contained in:
11
README.md
11
README.md
@@ -80,17 +80,16 @@ Notes:
|
|||||||
[.vag header](https://psx-spx.consoledev.net/cdromfileformats/#cdrom-file-audio-single-samples-vag-sony)
|
[.vag header](https://psx-spx.consoledev.net/cdromfileformats/#cdrom-file-audio-single-samples-vag-sony)
|
||||||
at the beginning of the file. The header is always 48 bytes long for `vag`
|
at the beginning of the file. The header is always 48 bytes long for `vag`
|
||||||
files, while in the case of `vagi` files it is padded to the size specified
|
files, while in the case of `vagi` files it is padded to the size specified
|
||||||
using the `-a` option (2048 bytes by default).
|
using the `-a` option (2048 bytes by default). The `vagi` format extends the
|
||||||
|
standard .vag header by adding the following fields:
|
||||||
- The `vagi` format extends the standard .vag header by changing the signature
|
|
||||||
to `VAGi` and adding the following fields:
|
|
||||||
- the file's interleave size at offset `0x08-0x0B` (little endian);
|
- the file's interleave size at offset `0x08-0x0B` (little endian);
|
||||||
- the loop start offset in bytes-per-channel, if any, at offset `0x14-0x17`
|
- the loop start offset in bytes-per-channel, if any, at offset `0x14-0x17`
|
||||||
(little endian);
|
(little endian);
|
||||||
- the file's channel count at offset `0x1E`.
|
- the file's channel count at offset `0x1E`.
|
||||||
|
|
||||||
- The `spu`, `vag`, `spui` and `vagi` formats support setting a loop start
|
- The `spu` and `vag` formats support encoding a loop point as part of the ADPCM
|
||||||
point. If the input file is either a .wav file with sampler metadata (`smpl`
|
data, while `vagi` supports storing one in the header for use by the stream
|
||||||
|
driver. If the input file is either a .wav file with sampler metadata (`smpl`
|
||||||
chunk) or in a format FFmpeg supports parsing cue/chapter markers from, the
|
chunk) or in a format FFmpeg supports parsing cue/chapter markers from, the
|
||||||
first marker will be used as the loop point by default. The `-l` and `-n`
|
first marker will be used as the loop point by default. The `-l` and `-n`
|
||||||
options can be used to manually set a loop point or ignore the one present in
|
options can be used to manually set a loop point or ignore the one present in
|
||||||
|
|||||||
@@ -307,6 +307,8 @@ void encode_file_spui(const args_t *args, decoder_t *decoder, FILE *output) {
|
|||||||
|
|
||||||
if (args->format == FORMAT_VAGI)
|
if (args->format == FORMAT_VAGI)
|
||||||
fseek(output, header_size, SEEK_SET);
|
fseek(output, header_size, SEEK_SET);
|
||||||
|
else if (args->audio_loop_point >= 0 && !(args->flags & FLAG_QUIET))
|
||||||
|
fprintf(stderr, "Warning: ignoring loop point as there is no header to store it in\n");
|
||||||
|
|
||||||
int audio_state_size = sizeof(psx_audio_encoder_channel_state_t) * args->audio_channels;
|
int audio_state_size = sizeof(psx_audio_encoder_channel_state_t) * args->audio_channels;
|
||||||
psx_audio_encoder_channel_state_t *audio_state = malloc(audio_state_size);
|
psx_audio_encoder_channel_state_t *audio_state = malloc(audio_state_size);
|
||||||
@@ -342,12 +344,15 @@ void encode_file_spui(const args_t *args, decoder_t *decoder, FILE *output) {
|
|||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
uint8_t *last_block = chunk_ptr + length - PSX_AUDIO_SPU_BLOCK_SIZE;
|
uint8_t *last_block = chunk_ptr + length - PSX_AUDIO_SPU_BLOCK_SIZE;
|
||||||
|
|
||||||
if (args->flags & FLAG_SPU_ENABLE_LOOP) {
|
if (
|
||||||
|
(args->flags & FLAG_SPU_ENABLE_LOOP) ||
|
||||||
|
(decoder->end_of_input && args->audio_loop_point >= 0)
|
||||||
|
) {
|
||||||
last_block[1] = PSX_AUDIO_SPU_LOOP_REPEAT;
|
last_block[1] = PSX_AUDIO_SPU_LOOP_REPEAT;
|
||||||
} else if (decoder->end_of_input) {
|
} else if (decoder->end_of_input) {
|
||||||
// HACK: the trailing block should in theory be appended to
|
// HACK: the trailing block should in theory be appended to
|
||||||
// the existing data, but it's easier to just zerofill and
|
// the existing data, but it's easier to just zerofill and
|
||||||
// repurpose the last encoded block
|
// repurpose the last encoded block.
|
||||||
memset(last_block, 0, PSX_AUDIO_SPU_BLOCK_SIZE);
|
memset(last_block, 0, PSX_AUDIO_SPU_BLOCK_SIZE);
|
||||||
last_block[1] = PSX_AUDIO_SPU_LOOP_TRAP;
|
last_block[1] = PSX_AUDIO_SPU_LOOP_TRAP;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user