mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-08-27 04:37:41 +00:00
Fix several bugs in h264bitstream
This commit is contained in:
+9
-5
@@ -138,15 +138,19 @@ static inline uint32_t bs_read_u8(bs_t* b)
|
||||
|
||||
static inline uint32_t bs_read_ue(bs_t* b)
|
||||
{
|
||||
int32_t r = 0;
|
||||
uint32_t r = 0;
|
||||
int i = 0;
|
||||
|
||||
while( (bs_read_u1(b) == 0) && (i < 32) && (!bs_eof(b)) )
|
||||
while (!bs_eof(b) && (i < 32) && (bs_read_u1(b) == 0))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
if (i >= 32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
r = bs_read_u(b, i);
|
||||
r += (1 << i) - 1;
|
||||
r += (1U << i) - 1U;
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -260,11 +264,11 @@ static inline void bs_write_se(bs_t* b, int32_t v)
|
||||
{
|
||||
if (v <= 0)
|
||||
{
|
||||
bs_write_ue(b, -v*2);
|
||||
bs_write_ue(b, (-(uint32_t)v) * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
bs_write_ue(b, v*2 - 1);
|
||||
bs_write_ue(b, ((uint32_t)v) * 2 - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user