Commit 6ed38b1f authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Diego Biurrun

tiff: Return more meaningful error codes

Signed-off-by: 's avatarDiego Biurrun <diego@biurrun.de>
parent 23944d29
...@@ -153,7 +153,8 @@ static int add_entry1(TiffEncoderContext *s, ...@@ -153,7 +153,8 @@ static int add_entry1(TiffEncoderContext *s,
* @param dst Output buffer * @param dst Output buffer
* @param n Size of input buffer * @param n Size of input buffer
* @param compr Compression method * @param compr Compression method
* @return Number of output bytes. If an output error is encountered, -1 returned * @return Number of output bytes. If an output error is encountered, a negative
* value corresponding to an AVERROR error code is returned.
*/ */
static int encode_strip(TiffEncoderContext *s, const int8_t *src, static int encode_strip(TiffEncoderContext *s, const int8_t *src,
uint8_t *dst, int n, int compr) uint8_t *dst, int n, int compr)
...@@ -166,14 +167,14 @@ static int encode_strip(TiffEncoderContext *s, const int8_t *src, ...@@ -166,14 +167,14 @@ static int encode_strip(TiffEncoderContext *s, const int8_t *src,
unsigned long zlen = s->buf_size - (*s->buf - s->buf_start); unsigned long zlen = s->buf_size - (*s->buf - s->buf_start);
if (compress(dst, &zlen, src, n) != Z_OK) { if (compress(dst, &zlen, src, n) != Z_OK) {
av_log(s->avctx, AV_LOG_ERROR, "Compressing failed\n"); av_log(s->avctx, AV_LOG_ERROR, "Compressing failed\n");
return -1; return AVERROR_UNKNOWN;
} }
return zlen; return zlen;
} }
#endif #endif
case TIFF_RAW: case TIFF_RAW:
if (check_size(s, n)) if (check_size(s, n))
return -1; return AVERROR(EINVAL);
memcpy(dst, src, n); memcpy(dst, src, n);
return n; return n;
case TIFF_PACKBITS: case TIFF_PACKBITS:
...@@ -182,7 +183,7 @@ static int encode_strip(TiffEncoderContext *s, const int8_t *src, ...@@ -182,7 +183,7 @@ static int encode_strip(TiffEncoderContext *s, const int8_t *src,
case TIFF_LZW: case TIFF_LZW:
return ff_lzw_encode(s->lzws, src, n); return ff_lzw_encode(s->lzws, src, n);
default: default:
return -1; return AVERROR(EINVAL);
} }
} }
...@@ -291,7 +292,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, ...@@ -291,7 +292,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
default: default:
av_log(s->avctx, AV_LOG_ERROR, av_log(s->avctx, AV_LOG_ERROR,
"This colors format is not supported\n"); "This colors format is not supported\n");
return -1; return AVERROR(EINVAL);
} }
if (s->compr == TIFF_DEFLATE || if (s->compr == TIFF_DEFLATE ||
......
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