diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-07-12 13:55:19 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-07-25 13:57:02 +0200 |
commit | 9a8f36cfeb9d3fae5525d3d370e15201c1cbdd15 (patch) | |
tree | 298b6e44b55babbbea51f07ef456db0df11182a7 | |
parent | 003a9759db592e471229896f6165a098c52afe2f (diff) |
cfhd: simplify dimension/format check
-rw-r--r-- | libavcodec/cfhd.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index 1e4e0a0c75..f9ab950cfb 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -686,7 +686,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, CFHDContext *s = avctx->priv_data; GetByteContext gb; ThreadFrame frame = { .f = data }; - int ret = 0, planes, plane, got_buffer = 0; + int ret = 0, planes, plane; int16_t tag; uint16_t value; @@ -704,29 +704,26 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, break; } - if (s->coded_width && s->coded_height && s->coded_format != AV_PIX_FMT_NONE) { - if (s->a_width != s->coded_width || s->a_height != s->coded_height || - s->a_format != s->coded_format) { - free_buffers(s); - if ((ret = alloc_buffers(s)) < 0) { - free_buffers(s); - return ret; - } - } + if (s->coded_width <= 0 || s->coded_height <= 0 || s->coded_format == AV_PIX_FMT_NONE) { + av_log(avctx, AV_LOG_ERROR, "Video dimensions/format missing or invalid\n"); + return AVERROR_INVALIDDATA; + } - if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) + if (s->a_width != s->coded_width || s->a_height != s->coded_height || + s->a_format != s->coded_format) { + free_buffers(s); + if ((ret = alloc_buffers(s)) < 0) { + free_buffers(s); return ret; - - s->coded_width = 0; - s->coded_height = 0; - s->coded_format = AV_PIX_FMT_NONE; - got_buffer = 1; + } } - if (!got_buffer) { - av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n"); - return AVERROR_INVALIDDATA; - } + if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) + return ret; + + s->coded_width = 0; + s->coded_height = 0; + s->coded_format = AV_PIX_FMT_NONE; while (bytestream2_get_bytes_left(&gb) > 4) { if ((ret = parse_tag(s, &gb, &tag, &value, &planes)) < 0) |