mirror of https://github.com/PCSX2/pcsx2.git
IPU: Implement start code validation for BDEC/IDEC
According to MPEG specs when 8 "0" bits are found, we should check for 000001xxh. Recommended way is to check 24 bits (000001h), and if they won't match discard 8 bits and try again until valid code is found, or stream ends.
This commit is contained in:
parent
8d3c82de19
commit
2dd9d8338b
|
@ -920,6 +920,7 @@ finish_idec:
|
|||
case 3:
|
||||
{
|
||||
u8 bit8;
|
||||
u32 start_check;
|
||||
if (!getBits8((u8*)&bit8, 0))
|
||||
{
|
||||
ipu_cmd.pos[0] = 3;
|
||||
|
@ -929,7 +930,21 @@ finish_idec:
|
|||
if (bit8 == 0)
|
||||
{
|
||||
g_BP.Align();
|
||||
ipuRegs.ctrl.SCD = 1;
|
||||
do
|
||||
{
|
||||
if (!g_BP.FillBuffer(24))
|
||||
{
|
||||
ipu_cmd.pos[0] = 3;
|
||||
return false;
|
||||
}
|
||||
start_check = UBITS(24);
|
||||
if (start_check == 1)
|
||||
{
|
||||
ipuRegs.ctrl.SCD = 1;
|
||||
break;
|
||||
}
|
||||
DUMPBITS(8);
|
||||
} while (start_check != 1);
|
||||
}
|
||||
}
|
||||
[[fallthrough]];
|
||||
|
@ -1196,6 +1211,7 @@ __fi bool mpeg2_slice()
|
|||
case 4:
|
||||
{
|
||||
u8 bit8;
|
||||
u32 start_check;
|
||||
if (!getBits8((u8*)&bit8, 0))
|
||||
{
|
||||
ipu_cmd.pos[0] = 4;
|
||||
|
@ -1205,7 +1221,21 @@ __fi bool mpeg2_slice()
|
|||
if (bit8 == 0)
|
||||
{
|
||||
g_BP.Align();
|
||||
ipuRegs.ctrl.SCD = 1;
|
||||
do
|
||||
{
|
||||
if (!g_BP.FillBuffer(24))
|
||||
{
|
||||
ipu_cmd.pos[0] = 4;
|
||||
return false;
|
||||
}
|
||||
start_check = UBITS(24);
|
||||
if (start_check == 1)
|
||||
{
|
||||
ipuRegs.ctrl.SCD = 1;
|
||||
break;
|
||||
}
|
||||
DUMPBITS(8);
|
||||
} while (start_check != 1);
|
||||
}
|
||||
}
|
||||
[[fallthrough]];
|
||||
|
|
Loading…
Reference in New Issue