[APU] Misc Changes:

- Unified APU error messages
- Removed magic number from SetOffset call
- Commented out that annoying assertion from XmaContext::GetNextFrame
- Removed checks for current_input_packet_count and replaced with bool check

Not sure how to call it correctly. I know that calls with packet count == 1 is specific one
and probably handled differently. Is it streaming or how should it be called?
This commit is contained in:
Gliniak 2022-12-11 12:22:23 +01:00
parent 2c6bbf9a4a
commit 82ccdd3db5
1 changed files with 16 additions and 12 deletions

View File

@ -357,7 +357,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
XELOGAPU( XELOGAPU(
"Processing context {} (offset {}, buffer {}, ptr {:p}, output buffer " "Processing context {} (offset {}, buffer {}, ptr {:p}, output buffer "
"{}, output buffer count {})", "{:08X}, output buffer count {})",
id(), data->input_buffer_read_offset, data->current_buffer, id(), data->input_buffer_read_offset, data->current_buffer,
current_input_buffer, data->output_buffer_ptr, current_input_buffer, data->output_buffer_ptr,
data->output_buffer_block_count); data->output_buffer_block_count);
@ -366,7 +366,8 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
return; return;
} }
if (!data->output_buffer_block_count) { if (!data->output_buffer_block_count) {
XELOGE("Received 0 for output_buffer_block_count!"); XELOGE("XmaContext {}: Error - Received 0 for output_buffer_block_count!",
id());
return; return;
} }
size_t input_buffer_0_size = size_t input_buffer_0_size =
@ -378,6 +379,8 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
size_t current_input_size = size_t current_input_size =
data->current_buffer ? input_buffer_1_size : input_buffer_0_size; data->current_buffer ? input_buffer_1_size : input_buffer_0_size;
size_t current_input_packet_count = current_input_size / kBytesPerPacket; size_t current_input_packet_count = current_input_size / kBytesPerPacket;
bool is_streaming = data->input_buffer_0_packet_count == 1 &&
data->input_buffer_1_packet_count == 1;
// Output buffers are in raw PCM samples, 256 bytes per block. // Output buffers are in raw PCM samples, 256 bytes per block.
// Output buffer is a ring buffer. We need to write from the write offset // Output buffer is a ring buffer. We need to write from the write offset
@ -458,7 +461,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
reuse_input_buffer = TrySetupNextLoop(data, true); reuse_input_buffer = TrySetupNextLoop(data, true);
} }
if (!reuse_input_buffer) { if (!reuse_input_buffer) {
if (current_input_packet_count == 1) { if (is_streaming) {
SwapInputBuffer(data); SwapInputBuffer(data);
} else { } else {
is_stream_done_ = true; is_stream_done_ = true;
@ -483,7 +486,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
stream = stream =
BitStream(current_input_buffer, (packet_idx + 1) * kBitsPerPacket); BitStream(current_input_buffer, (packet_idx + 1) * kBitsPerPacket);
stream.SetOffset(packet_idx * kBitsPerPacket + 32); stream.SetOffset(packet_idx * kBitsPerPacket + kBitsPerHeader);
if (split_frame_len_ > xma::kMaxFrameLength) { if (split_frame_len_ > xma::kMaxFrameLength) {
// TODO write CopyPeekMethod // TODO write CopyPeekMethod
@ -505,7 +508,8 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
if (split_frame_len_partial_ > split_frame_len_) { if (split_frame_len_partial_ > split_frame_len_) {
XELOGAPU( XELOGAPU(
"XmaContext {}: Invalid split frame lengths {}! frame_length: {} " "XmaContext {}: Error - Invalid split frame lengths {}! "
"frame_length: {} "
"partial_length: {}", "partial_length: {}",
id(), split_frame_len_, split_frame_len_partial_); id(), split_frame_len_, split_frame_len_partial_);
split_frame_len_ = 0; split_frame_len_ = 0;
@ -548,7 +552,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
if (!ValidFrameOffset(current_input_buffer, current_input_size, if (!ValidFrameOffset(current_input_buffer, current_input_size,
data->input_buffer_read_offset)) { data->input_buffer_read_offset)) {
XELOGAPU("XmaContext {}: Invalid read offset {}!", id(), XELOGAPU("XmaContext {}: Error - Invalid read offset {}!", id(),
data->input_buffer_read_offset); data->input_buffer_read_offset);
SwapInputBuffer(data); SwapInputBuffer(data);
return; return;
@ -610,7 +614,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
reuse_input_buffer = TrySetupNextLoop(data, true); reuse_input_buffer = TrySetupNextLoop(data, true);
} }
if (!reuse_input_buffer) { if (!reuse_input_buffer) {
if (current_input_packet_count == 1) { if (is_streaming) {
SwapInputBuffer(data); SwapInputBuffer(data);
} else { } else {
is_stream_done_ = true; is_stream_done_ = true;
@ -642,7 +646,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
auto ret = avcodec_send_packet(av_context_, av_packet_); auto ret = avcodec_send_packet(av_context_, av_packet_);
if (ret < 0) { if (ret < 0) {
XELOGE("XmaContext {}: Error sending packet for decoding", id()); XELOGE("XmaContext {}: Error - Sending packet for decoding failed", id());
// TODO bail out // TODO bail out
assert_always(); assert_always();
} }
@ -654,7 +658,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
else else
*/ */
if (ret < 0) { if (ret < 0) {
XELOGE("XmaContext {}: Error during decoding", id()); XELOGE("XmaContext {}: Error - Decoding failed", id());
data->parser_error_status = 4; // TODO(Gliniak): Find all parsing errors data->parser_error_status = 4; // TODO(Gliniak): Find all parsing errors
// and create enumerator from them // and create enumerator from them
assert_always(); assert_always();
@ -707,7 +711,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
reuse_input_buffer = TrySetupNextLoop(data, true); reuse_input_buffer = TrySetupNextLoop(data, true);
} }
if (!reuse_input_buffer) { if (!reuse_input_buffer) {
if (current_input_packet_count == 1) { if (is_streaming) {
SwapInputBuffer(data); SwapInputBuffer(data);
} else { } else {
is_stream_done_ = true; is_stream_done_ = true;
@ -732,7 +736,7 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
reuse_input_buffer = TrySetupNextLoop(data, true); reuse_input_buffer = TrySetupNextLoop(data, true);
} }
if (!reuse_input_buffer) { if (!reuse_input_buffer) {
if (current_input_packet_count == 1) { if (is_streaming) {
SwapInputBuffer(data); SwapInputBuffer(data);
} else { } else {
is_stream_done_ = true; is_stream_done_ = true;
@ -776,7 +780,7 @@ size_t XmaContext::GetNextFrame(uint8_t* block, size_t size,
uint64_t len = stream.Read(15); uint64_t len = stream.Read(15);
if ((len - 15) > stream.BitsRemaining()) { if ((len - 15) > stream.BitsRemaining()) {
assert_always("TODO"); // assert_always("TODO");
// *bit_offset = next_packet; // *bit_offset = next_packet;
// return false; // return false;
// return next_packet; // return next_packet;