History

frwu: Employ more meaningful return values.

Paul B Mahol committed 14 years ago

Commit 5ff88021 parent f54ae2f1 file · +11 −9Browse files

Unified · Split

libavcodec/frwu.c+11−9
@@ -28,7 +28,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 27 unmodified lines
28{28{
29 if (avctx->width & 1) {29 if (avctx->width & 1) {
30 av_log(avctx, AV_LOG_ERROR, "FRWU needs even width\n");30 av_log(avctx, AV_LOG_ERROR, "FRWU needs even width\n");
31 return -1;31 return AVERROR(EINVAL);
32 }32 }
33 avctx->pix_fmt = PIX_FMT_UYVY422;33 avctx->pix_fmt = PIX_FMT_UYVY422;
34 34
@@ -42,7 +42,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 7 unmodified lines
42static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,42static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
43 AVPacket *avpkt)43 AVPacket *avpkt)
44{44{
45 int field;45 int field, ret;
46 AVFrame *pic = avctx->coded_frame;46 AVFrame *pic = avctx->coded_frame;
47 const uint8_t *buf = avpkt->data;47 const uint8_t *buf = avpkt->data;
48 const uint8_t *buf_end = buf + avpkt->size;48 const uint8_t *buf_end = buf + avpkt->size;
@@ -52,16 +52,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 3 unmodified lines
52 52
53 if (avpkt->size < avctx->width * 2 * avctx->height + 4 + 2*8) {53 if (avpkt->size < avctx->width * 2 * avctx->height + 4 + 2*8) {
54 av_log(avctx, AV_LOG_ERROR, "Packet is too small.\n");54 av_log(avctx, AV_LOG_ERROR, "Packet is too small.\n");
55 return -1;55 return AVERROR_INVALIDDATA;
56 }56 }
57 if (bytestream_get_le32(&buf) != AV_RL32("FRW1")) {57 if (bytestream_get_le32(&buf) != AV_RL32("FRW1")) {
58 av_log(avctx, AV_LOG_ERROR, "incorrect marker\n");58 av_log(avctx, AV_LOG_ERROR, "incorrect marker\n");
59 return -1;59 return AVERROR_INVALIDDATA;
60 }60 }
61 61
62 pic->reference = 0;62 pic->reference = 0;
63 if (avctx->get_buffer(avctx, pic) < 0)63 if ((ret = avctx->get_buffer(avctx, pic)) < 0) {
64 return -1;64 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
65 return ret;
66 }
65 67
66 pic->pict_type = AV_PICTURE_TYPE_I;68 pic->pict_type = AV_PICTURE_TYPE_I;
67 pic->key_frame = 1;69 pic->key_frame = 1;
@@ -74,16 +76,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 6 unmodified lines
74 int field_size, min_field_size = avctx->width * 2 * field_h;76 int field_size, min_field_size = avctx->width * 2 * field_h;
75 uint8_t *dst = pic->data[0];77 uint8_t *dst = pic->data[0];
76 if (buf_end - buf < 8)78 if (buf_end - buf < 8)
77 return -1;79 return AVERROR_INVALIDDATA;
78 buf += 4; // flags? 0x80 == bottom field maybe?80 buf += 4; // flags? 0x80 == bottom field maybe?
79 field_size = bytestream_get_le32(&buf);81 field_size = bytestream_get_le32(&buf);
80 if (field_size < min_field_size) {82 if (field_size < min_field_size) {
81 av_log(avctx, AV_LOG_ERROR, "Field size %i is too small (required %i)\n", field_size, min_field_size);83 av_log(avctx, AV_LOG_ERROR, "Field size %i is too small (required %i)\n", field_size, min_field_size);
82 return -1;84 return AVERROR_INVALIDDATA;
83 }85 }
84 if (buf_end - buf < field_size) {86 if (buf_end - buf < field_size) {
85 av_log(avctx, AV_LOG_ERROR, "Packet is too small, need %i, have %i\n", field_size, (int)(buf_end - buf));87 av_log(avctx, AV_LOG_ERROR, "Packet is too small, need %i, have %i\n", field_size, (int)(buf_end - buf));
86 return -1;88 return AVERROR_INVALIDDATA;
87 }89 }
88 if (field)90 if (field)
89 dst += pic->linesize[0];91 dst += pic->linesize[0];

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