Be consistent with error messages and code formatting.
Unified · Split
| @@ -23,7 +23,7 @@ · 22 unmodified lines | |||
| 23 | typedef struct { | 23 | typedef struct { |
| 24 | AVFrame previous_frame; | 24 | AVFrame previous_frame; |
| 25 | z_stream zstream; | 25 | z_stream zstream; |
| 26 | int size; | 26 | int size; |
| 27 | } ZeroCodecContext; | 27 | } ZeroCodecContext; |
| 28 | 28 | ||
| 29 | static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, | 29 | static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, |
| @@ -33,7 +33,8 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, · 3 unmodified lines | |||
| 33 | AVFrame *pic = avctx->coded_frame; | 33 | AVFrame *pic = avctx->coded_frame; |
| 34 | AVFrame *prev_pic = &zc->previous_frame; | 34 | AVFrame *prev_pic = &zc->previous_frame; |
| 35 | z_stream *zstream = &zc->zstream; | 35 | z_stream *zstream = &zc->zstream; |
| 36 | uint8_t *prev = prev_pic->data[0], *dst; | 36 | uint8_t *prev = prev_pic->data[0]; |
| 37 | uint8_t *dst; | ||
| 37 | int i, j, zret; | 38 | int i, j, zret; |
| 38 | 39 | ||
| 39 | pic->reference = 3; | 40 | pic->reference = 3; |
| @@ -43,7 +44,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, · 3 unmodified lines | |||
| 43 | pic->pict_type = AV_PICTURE_TYPE_I; | 44 | pic->pict_type = AV_PICTURE_TYPE_I; |
| 44 | } else { | 45 | } else { |
| 45 | if (!prev) { | 46 | if (!prev) { |
| 46 | av_log(avctx, AV_LOG_ERROR, "Missing reference frame!\n"); | 47 | av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n"); |
| 47 | return AVERROR_INVALIDDATA; | 48 | return AVERROR_INVALIDDATA; |
| 48 | } | 49 | } |
| 49 | pic->key_frame = 0; | 50 | pic->key_frame = 0; |
| @@ -56,16 +57,15 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, · 6 unmodified lines | |||
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | zret = inflateReset(zstream); | 59 | zret = inflateReset(zstream); |
| 59 | |||
| 60 | if (zret != Z_OK) { | 60 | if (zret != Z_OK) { |
| 61 | av_log(avctx, AV_LOG_ERROR, "Could not reset inflate: %d\n", zret); | 61 | av_log(avctx, AV_LOG_ERROR, "Could not reset inflate: %d.\n", zret); |
| 62 | return AVERROR(EINVAL); | 62 | return AVERROR_INVALIDDATA; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | zstream->next_in = avpkt->data; | 65 | zstream->next_in = avpkt->data; |
| 66 | zstream->avail_in = avpkt->size; | 66 | zstream->avail_in = avpkt->size; |
| 67 | 67 | ||
| 68 | dst = pic->data[0]; | 68 | dst = pic->data[0]; |
| 69 | 69 | ||
| 70 | /** | 70 | /** |
| 71 | * ZeroCodec has very simple interframe compression. If a value | 71 | * ZeroCodec has very simple interframe compression. If a value |
| @@ -75,11 +75,12 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, · 3 unmodified lines | |||
| 75 | for (i = 0; i < avctx->height; i++) { | 75 | for (i = 0; i < avctx->height; i++) { |
| 76 | zstream->next_out = dst; | 76 | zstream->next_out = dst; |
| 77 | zstream->avail_out = avctx->width << 1; | 77 | zstream->avail_out = avctx->width << 1; |
| 78 | |||
| 78 | zret = inflate(zstream, Z_SYNC_FLUSH); | 79 | zret = inflate(zstream, Z_SYNC_FLUSH); |
| 79 | if (zret != Z_OK && zret != Z_STREAM_END) { | 80 | if (zret != Z_OK && zret != Z_STREAM_END) { |
| 80 | av_log(avctx, AV_LOG_ERROR, | 81 | av_log(avctx, AV_LOG_ERROR, |
| 81 | "Inflate failed with return code: %d\n", zret); | 82 | "Inflate failed with return code: %d.\n", zret); |
| 82 | return AVERROR(EINVAL); | 83 | return AVERROR_INVALIDDATA; |
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | if (!(avpkt->flags & AV_PKT_FLAG_KEY)) | 86 | if (!(avpkt->flags & AV_PKT_FLAG_KEY)) |
| @@ -137,14 +138,12 @@ static av_cold int zerocodec_decode_init(AVCodecContext *avctx) · 51 unmodified lines | |||
| 137 | zstream->opaque = Z_NULL; | 138 | zstream->opaque = Z_NULL; |
| 138 | 139 | ||
| 139 | zret = inflateInit(zstream); | 140 | zret = inflateInit(zstream); |
| 140 | |||
| 141 | if (zret != Z_OK) { | 141 | if (zret != Z_OK) { |
| 142 | av_log(avctx, AV_LOG_ERROR, "Could not initialize inflate: %d\n", zret); | 142 | av_log(avctx, AV_LOG_ERROR, "Could not initialize inflate: %d.\n", zret); |
| 143 | return AVERROR(ENOMEM); | 143 | return AVERROR(ENOMEM); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | avctx->coded_frame = avcodec_alloc_frame(); | 146 | avctx->coded_frame = avcodec_alloc_frame(); |
| 147 | |||
| 148 | if (!avctx->coded_frame) { | 147 | if (!avctx->coded_frame) { |
| 149 | av_log(avctx, AV_LOG_ERROR, "Could not allocate frame buffer.\n"); | 148 | av_log(avctx, AV_LOG_ERROR, "Could not allocate frame buffer.\n"); |
| 150 | zerocodec_decode_close(avctx); | 149 | zerocodec_decode_close(avctx); |