From e24ceba0e1fb39094e29117ff1091f760b42c732 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sat, 25 Sep 2010 05:36:30 +0000 Subject: [PATCH] IPU: * Fix a potentially obscure bug in ipuCSC (color space conversion) which would have caused PCSX2 to hang on certain types of rare partial transfers. * Remove some more dead code and structure data from the mpeg library. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3833 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/IPU/IPU.cpp | 36 +++++++++--------------------------- pcsx2/IPU/IPU_Fifo.cpp | 20 -------------------- pcsx2/IPU/mpeg2lib/Mpeg.cpp | 6 ------ pcsx2/IPU/mpeg2lib/Mpeg.h | 18 ++---------------- pcsx2/SaveState.h | 2 +- 5 files changed, 12 insertions(+), 70 deletions(-) diff --git a/pcsx2/IPU/IPU.cpp b/pcsx2/IPU/IPU.cpp index 754b6e5a83..ef90f46ee7 100644 --- a/pcsx2/IPU/IPU.cpp +++ b/pcsx2/IPU/IPU.cpp @@ -51,7 +51,6 @@ u8 indx4[16*16/2]; void tIPU_cmd::clear() { memzero_sse_a(*this); - //memzero(*this); current = 0xffffffff; } @@ -365,7 +364,7 @@ static __ri void ipuIDEC(tIPU_CMD_IDEC idec) decoder.scantype = ipuRegs.ctrl.AS; decoder.intra_dc_precision = ipuRegs.ctrl.IDP; - //from IDEC value +//from IDEC value decoder.quantizer_scale = idec.QSC; decoder.frame_pred_frame_dct= !idec.DTD; decoder.sgn = idec.SGN; @@ -551,9 +550,8 @@ static bool ipuSETVQ(u32 val) } // IPU Transfers are split into 8Qwords so we need to send ALL the data -static bool __fastcall ipuCSC(u32 val) +static __ri bool ipuCSC(tIPU_CMD_CSC csc) { - tIPU_CMD_CSC csc(val); csc.log_from_YCbCr(); for (;ipu_cmd.index < (int)csc.MBC; ipu_cmd.index++) @@ -568,21 +566,13 @@ static bool __fastcall ipuCSC(u32 val) if (csc.OFM) { - while (ipu_cmd.pos[1] < 32) - { - ipu_cmd.pos[1] += ipu_fifo.out.write(((u32*) & decoder.rgb16) + 4 * ipu_cmd.pos[1], 32 - ipu_cmd.pos[1]); - - if (ipu_cmd.pos[1] <= 0) return false; - } + ipu_cmd.pos[1] += ipu_fifo.out.write(((u32*) & decoder.rgb16) + 4 * ipu_cmd.pos[1], 32 - ipu_cmd.pos[1]); + if (ipu_cmd.pos[1] < 32) return false; } else { - while (ipu_cmd.pos[1] < 64) - { - ipu_cmd.pos[1] += ipu_fifo.out.write(((u32*) & decoder.rgb32) + 4 * ipu_cmd.pos[1], 64 - ipu_cmd.pos[1]); - - if (ipu_cmd.pos[1] <= 0) return false; - } + ipu_cmd.pos[1] += ipu_fifo.out.write(((u32*) & decoder.rgb32) + 4 * ipu_cmd.pos[1], 64 - ipu_cmd.pos[1]); + if (ipu_cmd.pos[1] < 64) return false; } ipu_cmd.pos[0] = 0; @@ -592,10 +582,8 @@ static bool __fastcall ipuCSC(u32 val) return true; } -// Todo - Need to add the same stop and start code as CSC -static bool ipuPACK(u32 val) +static __ri bool ipuPACK(tIPU_CMD_CSC csc) { - tIPU_CMD_CSC csc(val); csc.log_from_RGB32(); for (;ipu_cmd.index < (int)csc.MBC; ipu_cmd.index++) @@ -613,13 +601,11 @@ static bool ipuPACK(u32 val) if (csc.OFM) { ipu_cmd.pos[1] += ipu_fifo.out.write(((u32*) & decoder.rgb16) + 4 * ipu_cmd.pos[1], 32 - ipu_cmd.pos[1]); - if (ipu_cmd.pos[1] < 32) return false; } else { ipu_cmd.pos[1] += ipu_fifo.out.write(((u32*)indx4) + 4 * ipu_cmd.pos[1], 8 - ipu_cmd.pos[1]); - if (ipu_cmd.pos[1] < 8) return false; } @@ -887,17 +873,13 @@ __fi void IPUCMD_WRITE(u32 val) break; case SCE_IPU_CSC: - ipu_cmd.pos[1] = 0; - ipu_cmd.index = 0; break; case SCE_IPU_PACK: - ipu_cmd.pos[1] = 0; - ipu_cmd.index = 0; break; jNO_DEFAULT; - } + } ipuRegs.ctrl.BUSY = 1; @@ -966,7 +948,7 @@ __noinline void IPUWorker() break; jNO_DEFAULT - } + } // success ipuRegs.ctrl.BUSY = 0; diff --git a/pcsx2/IPU/IPU_Fifo.cpp b/pcsx2/IPU/IPU_Fifo.cpp index 25b0aad6f5..5f03dc6983 100644 --- a/pcsx2/IPU/IPU_Fifo.cpp +++ b/pcsx2/IPU/IPU_Fifo.cpp @@ -127,26 +127,6 @@ int IPU_Fifo_Output::write(const u32 *value, uint size) } while(true); return origsize - size; - -#if 0 - if (ipuRegs.ctrl.OFC >= 8) IPU0dma(); - - uint transsize = min(size, 8 - (uint)ipuRegs.ctrl.OFC); - uint firsttrans = transsize; - - while (transsize > 0) - { - CopyQWC(&data[writepos], value); - writepos = (writepos + 4) & 31; - value += 4; - --transsize; - } - - ipuRegs.ctrl.OFC += firsttrans; - IPU0dma(); - - return firsttrans; -#endif } void IPU_Fifo_Output::read(void *value, uint size) diff --git a/pcsx2/IPU/mpeg2lib/Mpeg.cpp b/pcsx2/IPU/mpeg2lib/Mpeg.cpp index b00344288e..4a2c3f00d2 100644 --- a/pcsx2/IPU/mpeg2lib/Mpeg.cpp +++ b/pcsx2/IPU/mpeg2lib/Mpeg.cpp @@ -699,7 +699,6 @@ __fi bool mpeg2sliceIDEC() decoder.dc_dct_pred[1] = decoder.dc_dct_pred[2] = 128 << decoder.intra_dc_precision; - decoder.mbc = 0; ipuRegs.top = 0; ipuRegs.ctrl.ECD = 0; @@ -818,7 +817,6 @@ __fi bool mpeg2sliceIDEC() return false; } - decoder.mbc++; mbaCount = 0; } @@ -867,8 +865,6 @@ __fi bool mpeg2sliceIDEC() decoder.dc_dct_pred[0] = decoder.dc_dct_pred[1] = decoder.dc_dct_pred[2] = 128 << decoder.intra_dc_precision; - - decoder.mbc += mbaCount; } case 4: @@ -1110,7 +1106,6 @@ __fi bool mpeg2_slice() ipuRegs.ctrl.SCD = 0; coded_block_pattern = decoder.coded_block_pattern; - decoder.mbc = 1; decoder.SetOutputTo(mb16); case 3: @@ -1127,7 +1122,6 @@ __fi bool mpeg2_slice() return false; } - decoder.mbc++; mbaCount = 0; } diff --git a/pcsx2/IPU/mpeg2lib/Mpeg.h b/pcsx2/IPU/mpeg2lib/Mpeg.h index 85a7a68a4e..b4741d9574 100644 --- a/pcsx2/IPU/mpeg2lib/Mpeg.h +++ b/pcsx2/IPU/mpeg2lib/Mpeg.h @@ -151,12 +151,7 @@ struct decoder_t { uint ipu0_data; // amount of data in the output macroblock (in QWC) uint ipu0_idx; - /* bit parsing stuff */ - //u32 bitstream_buf; /* current 32 bit working set */ - //int bitstream_bits; /* used bits in working set */ - - int quantizer_scale; /* remove */ - int dmv_offset; /* remove */ + int quantizer_scale; /* now non-slice-specific information */ @@ -191,8 +186,6 @@ struct decoder_t { int dte; // Output Format int ofm; - // Macroblock count - int mbc; // Macroblock type int macroblock_modes; // DC Reset @@ -205,8 +198,6 @@ struct decoder_t { /* the zigzag scan we're supposed to be using, true for alt, false for normal */ bool scantype; - int second_field; - int mpeg1; template< typename T > @@ -225,12 +216,10 @@ struct decoder_t { void AdvanceIpuDataBy(uint amt) { - pxAssumeDev(ipu0_data>=amt, "IPU FIFO Overflow on advance!" ); + pxAssumeMsg(ipu0_data>=amt, "IPU FIFO Overflow on advance!" ); ipu0_idx += amt; ipu0_data -= amt; } - - __fi bool ReadIpuData(u128* out); }; struct mpeg2_scan_pack @@ -248,9 +237,6 @@ extern s32 SBITS(uint bits); extern void mpeg2_idct_copy(s16 * block, u8* dest, int stride); extern void mpeg2_idct_add(int last, s16 * block, s16* dest, int stride); -#define IDEC 0 -#define BDEC 1 - extern bool mpeg2sliceIDEC(); extern bool mpeg2_slice(); extern int get_macroblock_address_increment(); diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index a981837907..9aa3c0b5bd 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -24,7 +24,7 @@ // the lower 16 bit value. IF the change is breaking of all compatibility with old // states, increment the upper 16 bit value, and clear the lower 16 bits to 0. -static const u32 g_SaveVersion = 0x8b4b0000; +static const u32 g_SaveVersion = 0x8b4c0000; // this function is meant to be used in the place of GSfreeze, and provides a safe layer // between the GS saving function and the MTGS's needs. :)