[FFmpeg-devel] [PATCH] tiff: frame multithreading support
Paul B Mahol
onemda at gmail.com
Fri Aug 9 16:06:42 CEST 2013
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
libavcodec/tiff.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index f4ad773..f3e0b43 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -41,6 +41,7 @@
#include "mathops.h"
#include "tiff.h"
#include "tiff_data.h"
+#include "thread.h"
typedef struct TiffContext {
AVCodecContext *avctx;
@@ -622,7 +623,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
return 0;
}
-static int init_image(TiffContext *s, AVFrame *frame)
+static int init_image(TiffContext *s, ThreadFrame *frame)
{
int i, ret;
uint32_t *pal;
@@ -679,14 +680,14 @@ static int init_image(TiffContext *s, AVFrame *frame)
return ret;
avcodec_set_dimensions(s->avctx, s->width, s->height);
}
- if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0)
+ if ((ret = ff_thread_get_buffer(s->avctx, frame, 0)) < 0)
return ret;
if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
if (s->palette_is_set) {
- memcpy(frame->data[1], s->palette, sizeof(s->palette));
+ memcpy(frame->f->data[1], s->palette, sizeof(s->palette));
} else {
/* make default grayscale pal */
- pal = (uint32_t *) frame->data[1];
+ pal = (uint32_t *) frame->f->data[1];
for (i = 0; i < 1<<s->bpp; i++)
pal[i] = 0xFFU << 24 | i * 255 / ((1<<s->bpp) - 1) * 0x010101;
}
@@ -1073,6 +1074,7 @@ static int decode_frame(AVCodecContext *avctx,
{
TiffContext *const s = avctx->priv_data;
AVFrame *const p = data;
+ ThreadFrame frame = { .f = data };
unsigned off;
int id, le, ret, plane, planes;
int i, j, entries, stride;
@@ -1149,7 +1151,7 @@ static int decode_frame(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
/* now we have the data and may start decoding */
- if ((ret = init_image(s, p)) < 0)
+ if ((ret = init_image(s, &frame)) < 0)
return ret;
if (s->strips == 1 && !s->stripsize) {
@@ -1288,5 +1290,5 @@ AVCodec ff_tiff_decoder = {
.init = tiff_init,
.close = tiff_end,
.decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
};
--
1.7.11.2
More information about the ffmpeg-devel
mailing list