aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rtpdec_jpeg.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-09-11 12:07:56 +0300
committerMartin Storsjö <martin@martin.st>2012-09-12 12:07:57 +0300
commit932d8300d38587ebc223e3bacc3c33ed68bf3cf6 (patch)
tree8fe0f06c7fe5942703ea2f8a03961da47eea2ca0 /libavformat/rtpdec_jpeg.c
parent7ef4323405fae8f62732111b747d585ef9c786c7 (diff)
downloadffmpeg-932d8300d38587ebc223e3bacc3c33ed68bf3cf6.tar.gz
rtpdec_jpeg: Merge two if statements
This makes the code more readable and robust. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtpdec_jpeg.c')
-rw-r--r--libavformat/rtpdec_jpeg.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c
index 19ecbf47fa..0513b09b3d 100644
--- a/libavformat/rtpdec_jpeg.c
+++ b/libavformat/rtpdec_jpeg.c
@@ -252,44 +252,43 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
}
/* Parse the quantization table header. */
- if (q > 127 && off == 0) {
- uint8_t precision;
-
- if (len < 4) {
- av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
- return AVERROR_INVALIDDATA;
- }
+ if (off == 0) {
+ /* Start of JPEG data packet. */
+ uint8_t new_qtables[128];
+ uint8_t hdr[1024];
- /* The first byte is reserved for future use. */
- precision = AV_RB8(buf + 1); /* size of coefficients */
- qtable_len = AV_RB16(buf + 2); /* length in bytes */
- buf += 4;
- len -= 4;
+ if (q > 127) {
+ uint8_t precision;
+ if (len < 4) {
+ av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
+ return AVERROR_INVALIDDATA;
+ }
- if (precision)
- av_log(ctx, AV_LOG_WARNING, "Only 8-bit precision is supported.\n");
+ /* The first byte is reserved for future use. */
+ 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) {
- av_log(ctx, AV_LOG_ERROR,
- "Invalid RTP/JPEG packet. Quantization tables not found.\n");
- return AVERROR_INVALIDDATA;
- }
+ if (precision)
+ av_log(ctx, AV_LOG_WARNING, "Only 8-bit precision is supported.\n");
- if (qtable_len > 0) {
- if (len < qtable_len) {
- av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
+ if (q == 255 && qtable_len == 0) {
+ av_log(ctx, AV_LOG_ERROR,
+ "Invalid RTP/JPEG packet. Quantization tables not found.\n");
return AVERROR_INVALIDDATA;
}
- qtables = buf;
- buf += qtable_len;
- len -= qtable_len;
- }
- }
- if (off == 0) {
- /* Start of JPEG data packet. */
- uint8_t new_qtables[128];
- uint8_t hdr[1024];
+ if (qtable_len > 0) {
+ if (len < qtable_len) {
+ av_log(ctx, AV_LOG_ERROR, "Too short RTP/JPEG packet.\n");
+ return AVERROR_INVALIDDATA;
+ }
+ qtables = buf;
+ buf += qtable_len;
+ len -= qtable_len;
+ }
+ }
/* Skip the current frame in case of the end packet
* has been lost somewhere. */