mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-17 04:06:25 +00:00
fix number of samples reported with gapless decoding
Some checks are pending
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Some checks are pending
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
This commit is contained in:
parent
af2df7d889
commit
18a4bd2014
|
@ -65,7 +65,6 @@ void AjmAt9Decoder::GetCodecInfo(void* out_info) {
|
|||
}
|
||||
|
||||
void AjmAt9Decoder::Decode(const AjmJobInput* input, AjmJobOutput* output) {
|
||||
LOG_TRACE(Lib_Ajm, "Decoding with instance {} in size = {}", index, input->buffer.size());
|
||||
Atrac9CodecInfo codec_info;
|
||||
Atrac9GetCodecInfo(handle, &codec_info);
|
||||
|
||||
|
@ -125,16 +124,18 @@ void AjmAt9Decoder::Decode(const AjmJobInput* input, AjmJobOutput* output) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
written =
|
||||
write_output({pcm_buffer.data(), std::min(pcm_buffer.size(), samples_remain)});
|
||||
total_decoded_samples += codec_info.frameSamples;
|
||||
const auto pcm_size = std::min(pcm_buffer.size(), samples_remain);
|
||||
const auto nsamples = pcm_size / codec_info.channels;
|
||||
written = write_output({pcm_buffer.data(), pcm_size});
|
||||
total_decoded_samples += nsamples;
|
||||
if (gapless.total_samples != 0) {
|
||||
gapless_decoded_samples += codec_info.frameSamples;
|
||||
gapless_decoded_samples += nsamples;
|
||||
}
|
||||
}
|
||||
|
||||
num_frames += 1;
|
||||
if ((num_frames % codec_info.framesInSuperframe) == 0) {
|
||||
num_frames = 0;
|
||||
if (superframe_bytes_remain) {
|
||||
if (output->p_stream) {
|
||||
output->p_stream->input_consumed += superframe_bytes_remain;
|
||||
|
@ -156,10 +157,9 @@ void AjmAt9Decoder::Decode(const AjmJobInput* input, AjmJobOutput* output) {
|
|||
}
|
||||
}
|
||||
|
||||
if (gapless.total_samples != 0 && gapless_decoded_samples >= gapless.total_samples) {
|
||||
if (flags.gapless_loop) {
|
||||
ResetCodec();
|
||||
}
|
||||
if (flags.gapless_loop && gapless.total_samples != 0 &&
|
||||
gapless_decoded_samples >= gapless.total_samples) {
|
||||
ResetCodec();
|
||||
}
|
||||
|
||||
if (output->p_stream) {
|
||||
|
|
|
@ -25,11 +25,8 @@ struct AjmSidebandDecAt9CodecInfo {
|
|||
};
|
||||
|
||||
struct AjmAt9Decoder final : AjmInstance {
|
||||
void* handle;
|
||||
bool decoder_initialized = false;
|
||||
std::fstream file;
|
||||
int length;
|
||||
u8 config_data[ORBIS_AT9_CONFIG_DATA_SIZE];
|
||||
void* handle{};
|
||||
u8 config_data[ORBIS_AT9_CONFIG_DATA_SIZE]{};
|
||||
u32 superframe_bytes_remain{};
|
||||
u32 num_frames{};
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ void AjmMp3Decoder::Reset() {
|
|||
int ret = avcodec_open2(c, codec, nullptr);
|
||||
ASSERT_MSG(ret >= 0, "Could not open codec");
|
||||
total_decoded_samples = 0;
|
||||
gapless_decoded_samples = 0;
|
||||
}
|
||||
|
||||
void AjmMp3Decoder::Decode(const AjmJobInput* input, AjmJobOutput* output) {
|
||||
|
@ -138,13 +139,12 @@ void AjmMp3Decoder::Decode(const AjmJobInput* input, AjmJobOutput* output) {
|
|||
if (frame->format != AV_SAMPLE_FMT_S16) {
|
||||
frame = ConvertAudioFrame(frame);
|
||||
}
|
||||
const auto frame_samples = frame->ch_layout.nb_channels * frame->nb_samples;
|
||||
const auto size = frame_samples * sizeof(u16);
|
||||
const auto size = frame->ch_layout.nb_channels * frame->nb_samples * sizeof(u16);
|
||||
if (gapless.skipped_samples < gapless.skip_samples) {
|
||||
gapless.skipped_samples += frame_samples;
|
||||
gapless.skipped_samples += frame->nb_samples;
|
||||
if (gapless.skipped_samples > gapless.skip_samples) {
|
||||
const u32 nsamples = gapless.skipped_samples - gapless.skip_samples;
|
||||
const auto start = frame_samples - nsamples;
|
||||
const auto start = frame->nb_samples - nsamples;
|
||||
write_output({reinterpret_cast<s16*>(frame->data[0]), nsamples});
|
||||
gapless.skipped_samples = gapless.skip_samples;
|
||||
total_decoded_samples += nsamples;
|
||||
|
@ -154,9 +154,9 @@ void AjmMp3Decoder::Decode(const AjmJobInput* input, AjmJobOutput* output) {
|
|||
}
|
||||
} else {
|
||||
write_output({reinterpret_cast<s16*>(frame->data[0]), size >> 1});
|
||||
total_decoded_samples += frame_samples;
|
||||
total_decoded_samples += frame->nb_samples;
|
||||
if (gapless.total_samples != 0) {
|
||||
gapless_decoded_samples += frame_samples;
|
||||
gapless_decoded_samples += frame->nb_samples;
|
||||
}
|
||||
}
|
||||
av_frame_free(&frame);
|
||||
|
|
Loading…
Reference in a new issue