History

avcodec/pgxdec: Avoid always-false checks

We have already checked that there is data to be read.

Andreas Rheinhardt committed 4 years ago

Commit be6cd7d1 parent a7e8b0f1 file · +10 −10Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/pgxdec.c+10−10
@@ -32,9 +32,9 @@ static int pgx_get_number(AVCodecContext *avctx, GetByteContext *g, int *number) · 31 unmodified lines
3232 *number = 0;
3333 while (1) {
3434 uint64_t temp;
35− if (!bytestream2_get_bytes_left(g))
35+ if (bytestream2_get_bytes_left(g) <= 0)
3636 return AVERROR_INVALIDDATA;
37− digit = bytestream2_get_byte(g);
37+ digit = bytestream2_get_byteu(g);
3838 if (digit == ' ' || digit == 0xA || digit == 0xD)
3939 break;
4040 else if (digit < '0' || digit > '9')
@@ -59,22 +59,22 @@ static int pgx_decode_header(AVCodecContext *avctx, GetByteContext *g, · 18 unmodified lines
5959 if (bytestream2_get_bytes_left(g) < 12)
6060 return AVERROR_INVALIDDATA;
6161
62− bytestream2_skip(g, 6);
62+ bytestream2_skipu(g, 6);
6363
6464 // Is the component signed?
65− byte = bytestream2_peek_byte(g);
65+ byte = bytestream2_peek_byteu(g);
6666 if (byte == '+') {
6767 *sign = 0;
68− bytestream2_skip(g, 1);
68+ bytestream2_skipu(g, 1);
6969 } else if (byte == '-') {
7070 *sign = 1;
71− bytestream2_skip(g, 1);
71+ bytestream2_skipu(g, 1);
7272 } else if (byte == 0)
7373 goto error;
7474
75− byte = bytestream2_peek_byte(g);
75+ byte = bytestream2_peek_byteu(g);
7676 if (byte == ' ')
77− bytestream2_skip(g, 1);
77+ bytestream2_skipu(g, 1);
7878 else if (byte == 0)
7979 goto error;
8080
@@ -104,9 +104,9 @@ error: · 23 unmodified lines
104104 for (j = 0; j < width; j++) { \
105105 unsigned val; \
106106 if (sign) \
107− val = (PIXEL)bytestream2_get_ ##suffix(g) + (1 << (depth - 1)); \
107+ val = (PIXEL)bytestream2_get_ ##suffix##u(g) + (1 << (depth - 1)); \
108108 else \
109− val = bytestream2_get_ ##suffix(g); \
109+ val = bytestream2_get_ ##suffix##u(g); \
110110 val <<= (D - depth); \
111111 *(line + j) = val; \
112112 } \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t