aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxpress
diff options
context:
space:
mode:
authorJohn "Lameguy" Wilbert Villamor <lameguy64@gmail.com>2022-10-19 17:57:06 +0800
committerGitHub <noreply@github.com>2022-10-19 17:57:06 +0800
commite08a3d9366f8ca14a76b3dd569dac1fb9f569748 (patch)
tree33654513b0b184c27f8035dbc405640fcbeb44ab /libpsn00b/psxpress
parentc4a2533d21dfd05cde841ea48c67b05e0e6a853f (diff)
parent9b2ffc6078a850b7d354855cca7622090b41f30c (diff)
downloadpsn00bsdk-e08a3d9366f8ca14a76b3dd569dac1fb9f569748.tar.gz
Merge pull request #59 from spicyjpeg/psxmdec
IRQ handler fix, .STR playback example, multiple library builds (v0.21)
Diffstat (limited to 'libpsn00b/psxpress')
-rw-r--r--libpsn00b/psxpress/mdec.c17
-rw-r--r--libpsn00b/psxpress/vlc.s10
-rw-r--r--libpsn00b/psxpress/vlc2.c5
3 files changed, 22 insertions, 10 deletions
diff --git a/libpsn00b/psxpress/mdec.c b/libpsn00b/psxpress/mdec.c
index 9c82d6b..d43436f 100644
--- a/libpsn00b/psxpress/mdec.c
+++ b/libpsn00b/psxpress/mdec.c
@@ -4,13 +4,13 @@
*/
#include <stdint.h>
-#include <stdio.h>
+#include <psxetc.h>
#include <psxapi.h>
#include <psxpress.h>
#include <hwregs_c.h>
#define DMA_CHUNK_LENGTH 32
-#define MDEC_SYNC_TIMEOUT 0x1000000
+#define MDEC_SYNC_TIMEOUT 0x100000
/* Default IDCT matrix and quantization tables */
@@ -127,7 +127,7 @@ void DecDCTin(const uint32_t *data, int mode) {
// the stream.
void DecDCTinRaw(const uint32_t *data, size_t length) {
if ((length >= DMA_CHUNK_LENGTH) && (length % DMA_CHUNK_LENGTH)) {
- printf("psxmdec: transfer data length (%d) is not a multiple of %d, rounding\n", length, DMA_CHUNK_LENGTH);
+ _sdk_log("psxpress: transfer data length (%d) is not a multiple of %d, rounding\n", length, DMA_CHUNK_LENGTH);
length += DMA_CHUNK_LENGTH - 1;
}
@@ -149,13 +149,19 @@ int DecDCTinSync(int mode) {
return 0;
}
- printf("psxpress: DecDCTinSync() timeout\n");
+ _sdk_log("psxpress: DecDCTinSync() timeout\n");
+ _sdk_dump_log();
return -1;
}
void DecDCTout(uint32_t *data, size_t length) {
DecDCToutSync(0);
+ if ((length >= DMA_CHUNK_LENGTH) && (length % DMA_CHUNK_LENGTH)) {
+ _sdk_log("psxpress: transfer data length (%d) is not a multiple of %d, rounding\n", length, DMA_CHUNK_LENGTH);
+ length += DMA_CHUNK_LENGTH - 1;
+ }
+
DMA_MADR(1) = (uint32_t) data;
if (length < DMA_CHUNK_LENGTH)
DMA_BCR(1) = 0x00010000 | length;
@@ -174,6 +180,7 @@ int DecDCToutSync(int mode) {
return 0;
}
- printf("psxpress: DecDCToutSync() timeout\n");
+ _sdk_log("psxpress: DecDCToutSync() timeout\n");
+ _sdk_dump_log();
return -1;
}
diff --git a/libpsn00b/psxpress/vlc.s b/libpsn00b/psxpress/vlc.s
index fe51642..885a3f7 100644
--- a/libpsn00b/psxpress/vlc.s
+++ b/libpsn00b/psxpress/vlc.s
@@ -131,10 +131,12 @@ _vlc_skip_context_load:
#nop
.Lprocess_dc_v2_coefficient: # if (!coeff_index && !is_v3)
- # The DC coefficient in version 2 frames is not compressed.
- srl $v0, $t0, 22 # *output = (window >> (32 - 10)) | quant_scale
- or $v0, $t3
- addiu $t7, 1 # coeff_index++
+ # The DC coefficient in version 2 frames is not compressed. Value 0x1ff is
+ # used to signal the end of the bitstream.
+ srl $v0, $t0, 22 # prefix = (window >> (32 - 10))
+ li $v1, 0x01ff
+ beq $v0, $v1, .Lstop_processing # if (prefix == 0x1ff) break
+ or $v0, $t3 # *output = prefix | quant_scale
sll $t0, 10 # window <<= 10
addiu $t5, -10 # bit_offset -= 10
b .Lwrite_value
diff --git a/libpsn00b/psxpress/vlc2.c b/libpsn00b/psxpress/vlc2.c
index 73b54b2..9eb99bf 100644
--- a/libpsn00b/psxpress/vlc2.c
+++ b/libpsn00b/psxpress/vlc2.c
@@ -141,7 +141,10 @@ int __attribute__((optimize(3))) DecDCTvlcContinue2(
// TODO: version 3 is currently not supported.
return -1;
} else {
- value = _get_bits_unsigned(10);
+ value = _get_bits_unsigned(10);
+ if (value == 0x1ff)
+ break;
+
*output = value | quant_scale;
_advance_window(10);
}