summaryrefslogtreecommitdiff
path: root/libavcodec/tiff.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-06-08 11:31:31 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-06-08 11:32:34 +0200
commit1fec361f353cf140a67b28c2d73c3822a89a76d6 (patch)
tree973bccb6cd7feab4fe92d22856fbdb522e214e8e /libavcodec/tiff.c
parenta804632b155d7e4841ee568cadb05d4f7e5d4af9 (diff)
parent016c5b066de08a93a5f6b5beb0ef377356b35cde (diff)
Merge commit '016c5b066de08a93a5f6b5beb0ef377356b35cde'
* commit '016c5b066de08a93a5f6b5beb0ef377356b35cde': tiff: refactor fax support in a separate function Conflicts: libavcodec/tiff.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tiff.c')
-rw-r--r--libavcodec/tiff.c76
1 files changed, 39 insertions, 37 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index e9b17615c9..89e2b401ff 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -470,6 +470,44 @@ static int tiff_unpack_zlib(TiffContext *s, uint8_t *dst, int stride,
}
#endif
+
+static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride,
+ const uint8_t *src, int size, int width, int lines)
+{
+ int i, ret = 0;
+ int line;
+ uint8_t *src2 = av_malloc((unsigned)size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!src2) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Error allocating temporary buffer\n");
+ return AVERROR(ENOMEM);
+ }
+ if (s->fax_opts & 2) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Uncompressed fax mode is not supported (yet)\n");
+ av_free(src2);
+ return AVERROR_INVALIDDATA;
+ }
+ if (!s->fill_order) {
+ memcpy(src2, src, size);
+ } else {
+ for (i = 0; i < size; i++)
+ src2[i] = ff_reverse[src[i]];
+ }
+ memset(src2 + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride,
+ s->compr, s->fax_opts);
+ if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
+ for (line = 0; line < lines; line++) {
+ horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);
+ dst += stride;
+ }
+ av_free(src2);
+ return ret;
+}
+
static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
const uint8_t *src, int size, int lines)
{
@@ -510,43 +548,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
if (s->compr == TIFF_CCITT_RLE ||
s->compr == TIFF_G3 ||
s->compr == TIFF_G4) {
- int i, ret = 0;
- uint8_t *src2 = av_malloc((unsigned)size +
- FF_INPUT_BUFFER_PADDING_SIZE);
-
- if (!src2) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Error allocating temporary buffer\n");
- return AVERROR(ENOMEM);
- }
- if (s->fax_opts & 2) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Uncompressed fax mode is not supported (yet)\n");
- av_free(src2);
- return AVERROR_INVALIDDATA;
- }
- if (!s->fill_order) {
- memcpy(src2, src, size);
- } else {
- for (i = 0; i < size; i++)
- src2[i] = ff_reverse[src[i]];
- }
- memset(src2 + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- switch (s->compr) {
- case TIFF_CCITT_RLE:
- case TIFF_G3:
- case TIFF_G4:
- ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride,
- s->compr, s->fax_opts);
- break;
- }
- if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8)
- for (line = 0; line < lines; line++) {
- horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);
- dst += stride;
- }
- av_free(src2);
- return ret;
+ return tiff_unpack_fax(s, dst, stride, src, size, width, lines);
}
for (line = 0; line < lines; line++) {
if (src - ssrc > size) {