Commit 999ccd2d authored by Luca Barbato's avatar Luca Barbato

tiff: cleanup the error paths

Return the proper error values and optionally report them.
parent 016c5b06
...@@ -156,10 +156,9 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride, ...@@ -156,10 +156,9 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride,
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
if (s->fax_opts & 2) { if (s->fax_opts & 2) {
av_log(s->avctx, AV_LOG_ERROR, avpriv_request_sample(s->avctx, "Uncompressed fax mode");
"Uncompressed fax mode is not supported (yet)\n");
av_free(src2); av_free(src2);
return AVERROR_INVALIDDATA; return AVERROR_PATCHWELCOME;
} }
if (!s->fill_order) { if (!s->fill_order) {
memcpy(src2, src, size); memcpy(src2, src, size);
...@@ -437,8 +436,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, ...@@ -437,8 +436,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
#endif #endif
case TIFF_JPEG: case TIFF_JPEG:
case TIFF_NEWJPEG: case TIFF_NEWJPEG:
av_log(s->avctx, AV_LOG_ERROR, avpriv_report_missing_feature(s->avctx, "JPEG compression");
"JPEG compression is not supported\n");
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
default: default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
...@@ -535,7 +533,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, ...@@ -535,7 +533,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
break; break;
case TIFF_PLANAR: case TIFF_PLANAR:
if (value == 2) { if (value == 2) {
av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n"); avpriv_report_missing_feature(s->avctx, "Planar format");
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
break; break;
...@@ -548,8 +546,12 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, ...@@ -548,8 +546,12 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
s->fax_opts = value; s->fax_opts = value;
break; break;
default: default:
av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n", if (s->avctx->err_recognition & AV_EF_EXPLODE) {
tag, tag); av_log(s->avctx, AV_LOG_ERROR,
"Unknown or unsupported tag %d/0X%0X\n",
tag, tag);
return AVERROR_INVALIDDATA;
}
} }
return 0; return 0;
} }
...@@ -640,9 +642,12 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -640,9 +642,12 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n"); av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (tiff_unpack_strip(s, dst, stride, orig_buf + soff, ssize, if ((ret = tiff_unpack_strip(s, dst, stride, orig_buf + soff, ssize,
FFMIN(s->rps, s->height - i)) < 0) FFMIN(s->rps, s->height - i))) < 0) {
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
break; break;
}
dst += s->rps * stride; dst += s->rps * stride;
} }
if (s->predictor == 2) { if (s->predictor == 2) {
......
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