Commit 932d8300 authored by Martin Storsjö's avatar Martin Storsjö

rtpdec_jpeg: Merge two if statements

This makes the code more readable and robust.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent 7ef43234
...@@ -252,44 +252,43 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg, ...@@ -252,44 +252,43 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
} }
/* Parse the quantization table header. */ /* Parse the quantization table header. */
if (q > 127 && off == 0) { if (off == 0) {
uint8_t precision; /* Start of JPEG data packet. */
uint8_t new_qtables[128];
if (len < 4) { uint8_t hdr[1024];
av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
return AVERROR_INVALIDDATA;
}
/* The first byte is reserved for future use. */ if (q > 127) {
precision = AV_RB8(buf + 1); /* size of coefficients */ uint8_t precision;
qtable_len = AV_RB16(buf + 2); /* length in bytes */ if (len < 4) {
buf += 4; av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
len -= 4; return AVERROR_INVALIDDATA;
}
if (precision) /* The first byte is reserved for future use. */
av_log(ctx, AV_LOG_WARNING, "Only 8-bit precision is supported.\n"); precision = AV_RB8(buf + 1); /* size of coefficients */
qtable_len = AV_RB16(buf + 2); /* length in bytes */
buf += 4;
len -= 4;
if (q == 255 && qtable_len == 0) { if (precision)
av_log(ctx, AV_LOG_ERROR, av_log(ctx, AV_LOG_WARNING, "Only 8-bit precision is supported.\n");
"Invalid RTP/JPEG packet. Quantization tables not found.\n");
return AVERROR_INVALIDDATA;
}
if (qtable_len > 0) { if (q == 255 && qtable_len == 0) {
if (len < qtable_len) { av_log(ctx, AV_LOG_ERROR,
av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n"); "Invalid RTP/JPEG packet. Quantization tables not found.\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
qtables = buf;
buf += qtable_len;
len -= qtable_len;
}
}
if (off == 0) { if (qtable_len > 0) {
/* Start of JPEG data packet. */ if (len < qtable_len) {
uint8_t new_qtables[128]; av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
uint8_t hdr[1024]; return AVERROR_INVALIDDATA;
}
qtables = buf;
buf += qtable_len;
len -= qtable_len;
}
}
/* Skip the current frame in case of the end packet /* Skip the current frame in case of the end packet
* has been lost somewhere. */ * has been lost somewhere. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment