MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / jpeg_decode_PS

Function jpeg_decode_PS

Source/Core/JpegTask.cpp:130–194  ·  view source on GitHub ↗

* JPEG decoding ucode found in Ocarina of Time, Pokemon Stadium 1 and * Pokemon Stadium 2. **************************************************************************/

Source from the content-addressed store, hash-verified

128 * Pokemon Stadium 2.
129 **************************************************************************/
130void jpeg_decode_PS(OSTask *task)
131{
132 s16 *macroblock {};
133 s16 qtables[3][SUBBLOCK_SIZE];
134 u32 mb {};
135
136 #ifdef DAEDALUS_DEBUG_CONSOLE
137 if (task->t.flags & 0x1)
138 {
139 DBGConsole_Msg(0, "jpeg_decode_PS: task yielding not implemented");
140 return;
141 }
142 #endif
143 u32 address {rdram_read_u32((u32)task->t.data_ptr)};
144 const u32 macroblock_count {rdram_read_u32((u32)task->t.data_ptr + 4)};
145 const u32 mode {rdram_read_u32((u32)task->t.data_ptr + 8)};
146 const u32 qtableY_ptr {rdram_read_u32((u32)task->t.data_ptr + 12)};
147 const u32 qtableU_ptr {rdram_read_u32((u32)task->t.data_ptr + 16)};
148 const u32 qtableV_ptr {rdram_read_u32((u32)task->t.data_ptr + 20)};
149
150 #ifdef DAEDALUS_DEBUG_CONSOLE
151 if (mode != 0 && mode != 2)
152 {
153 DBGConsole_Msg(0, "jpeg_decode_PS: invalid mode %d", mode);
154 return;
155 }
156 #endif
157
158 rdram_read_many_u16((u16*)qtables[0], qtableY_ptr, SUBBLOCK_SIZE);
159 rdram_read_many_u16((u16*)qtables[1], qtableU_ptr, SUBBLOCK_SIZE);
160 rdram_read_many_u16((u16*)qtables[2], qtableV_ptr, SUBBLOCK_SIZE);
161
162 void (*EmitTilesMode)(const tile_line_emitter_t, const s16 *, u32);
163
164 if (mode == 0)
165 {
166 EmitTilesMode = EmitTilesMode0;
167 }
168 else
169 {
170 EmitTilesMode = EmitTilesMode2;
171 }
172
173 const u32 subblock_count {mode + 4};
174 const u32 macroblock_size {2*subblock_count*SUBBLOCK_SIZE};
175
176 macroblock = (s16 *)malloc(sizeof(*macroblock) * macroblock_size);
177 #ifdef DAEDALUS_DEBUG_CONSOLE
178 if (!macroblock)
179 {
180 DBGConsole_Msg(0, "jpeg_decode_PS: could not allocate macroblock");
181 return;
182 }
183 #endif
184
185 for (mb = 0; mb < macroblock_count; ++mb)
186 {
187 rdram_read_many_u16((u16*)macroblock, address, macroblock_size >> 1);

Callers 1

RSP_HLE_JpegFunction · 0.85

Calls 3

rdram_read_u32Function · 0.85
rdram_read_many_u16Function · 0.85
DecodeMacroblock2Function · 0.85

Tested by

no test coverage detected