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

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
32 *number = 0;32 *number = 0;
33 while (1) {33 while (1) {
34 uint64_t temp;34 uint64_t temp;
35 if (!bytestream2_get_bytes_left(g))35 if (bytestream2_get_bytes_left(g) <= 0)
36 return AVERROR_INVALIDDATA;36 return AVERROR_INVALIDDATA;
37 digit = bytestream2_get_byte(g);37 digit = bytestream2_get_byteu(g);
38 if (digit == ' ' || digit == 0xA || digit == 0xD)38 if (digit == ' ' || digit == 0xA || digit == 0xD)
39 break;39 break;
40 else if (digit < '0' || digit > '9')40 else if (digit < '0' || digit > '9')
@@ -59,22 +59,22 @@ static int pgx_decode_header(AVCodecContext *avctx, GetByteContext *g, · 18 unmodified lines
59 if (bytestream2_get_bytes_left(g) < 12)59 if (bytestream2_get_bytes_left(g) < 12)
60 return AVERROR_INVALIDDATA;60 return AVERROR_INVALIDDATA;
61 61
62 bytestream2_skip(g, 6);62 bytestream2_skipu(g, 6);
63 63
64 // Is the component signed?64 // Is the component signed?
65 byte = bytestream2_peek_byte(g);65 byte = bytestream2_peek_byteu(g);
66 if (byte == '+') {66 if (byte == '+') {
67 *sign = 0;67 *sign = 0;
68 bytestream2_skip(g, 1);68 bytestream2_skipu(g, 1);
69 } else if (byte == '-') {69 } else if (byte == '-') {
70 *sign = 1;70 *sign = 1;
71 bytestream2_skip(g, 1);71 bytestream2_skipu(g, 1);
72 } else if (byte == 0)72 } else if (byte == 0)
73 goto error;73 goto error;
74 74
75 byte = bytestream2_peek_byte(g);75 byte = bytestream2_peek_byteu(g);
76 if (byte == ' ')76 if (byte == ' ')
77 bytestream2_skip(g, 1);77 bytestream2_skipu(g, 1);
78 else if (byte == 0)78 else if (byte == 0)
79 goto error;79 goto error;
80 80
@@ -104,9 +104,9 @@ error: · 23 unmodified lines
104 for (j = 0; j < width; j++) { \104 for (j = 0; j < width; j++) { \
105 unsigned val; \105 unsigned val; \
106 if (sign) \106 if (sign) \
107 val = (PIXEL)bytestream2_get_ ##suffix(g) + (1 << (depth - 1)); \107 val = (PIXEL)bytestream2_get_ ##suffix##u(g) + (1 << (depth - 1)); \
108 else \108 else \
109 val = bytestream2_get_ ##suffix(g); \109 val = bytestream2_get_ ##suffix##u(g); \
110 val <<= (D - depth); \110 val <<= (D - depth); \
111 *(line + j) = val; \111 *(line + j) = val; \
112 } \112 } \

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