summaryrefslogtreecommitdiff
path: root/libavcodec/dxtory.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-02-06 14:49:23 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-02-09 17:22:35 +0100
commit02220b88fc38ef9dd4f2d519f5d3e4151258b60c (patch)
tree5ab09d5c019a822c0a839c6076bccff670986867 /libavcodec/dxtory.c
parentf025b8e110b36c1cdb4fb56c4cd57aeca1767b5b (diff)
avcodec/thread: Don't use ThreadFrame when unnecessary
The majority of frame-threaded decoders (mainly the intra-only) need exactly one part of ThreadFrame: The AVFrame. They don't need the owners nor the progress, yet they had to use it because ff_thread_(get|release)_buffer() requires it. This commit changes this and makes these functions work with ordinary AVFrames; the decoders that need the extra fields for progress use ff_thread_(get|release)_ext_buffer() which work exactly as ff_thread_(get|release)_buffer() used to do. This also avoids some unnecessary allocations of progress AVBuffers, namely for H.264 and HEVC film grain frames: These frames are not used for synchronization and therefore don't need a ThreadFrame. Also move the ThreadFrame structure as well as ff_thread_ref_frame() to threadframe.h, the header for frame-threaded decoders with inter-frame dependencies. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/dxtory.c')
-rw-r--r--libavcodec/dxtory.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c
index 36c30c1dbc..76e9d605b8 100644
--- a/libavcodec/dxtory.c
+++ b/libavcodec/dxtory.c
@@ -92,7 +92,6 @@ static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size,
int id, int bpp, uint32_t vflipped)
{
- ThreadFrame frame = { .f = pic };
int h;
uint8_t *dst;
int ret;
@@ -103,7 +102,7 @@ static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic,
}
avctx->pix_fmt = id;
- if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
+ if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
return ret;
do_vflip(avctx, pic, vflipped);
@@ -124,7 +123,6 @@ static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size,
uint32_t vflipped)
{
- ThreadFrame frame = { .f = pic };
int h, w;
uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V;
int height, width, hmargin, vmargin;
@@ -137,7 +135,7 @@ static int dxtory_decode_v1_410(AVCodecContext *avctx, AVFrame *pic,
}
avctx->pix_fmt = AV_PIX_FMT_YUV410P;
- if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
+ if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
return ret;
do_vflip(avctx, pic, vflipped);
@@ -220,7 +218,6 @@ static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size,
uint32_t vflipped)
{
- ThreadFrame frame = { .f = pic };
int h, w;
uint8_t *Y1, *Y2, *U, *V;
int height, width, hmargin, vmargin;
@@ -233,7 +230,7 @@ static int dxtory_decode_v1_420(AVCodecContext *avctx, AVFrame *pic,
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
- if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
+ if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
return ret;
do_vflip(avctx, pic, vflipped);
@@ -293,7 +290,6 @@ static int dxtory_decode_v1_444(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size,
uint32_t vflipped)
{
- ThreadFrame frame = { .f = pic };
int h, w;
uint8_t *Y, *U, *V;
int ret;
@@ -304,7 +300,7 @@ static int dxtory_decode_v1_444(AVCodecContext *avctx, AVFrame *pic,
}
avctx->pix_fmt = AV_PIX_FMT_YUV444P;
- if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
+ if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
return ret;
do_vflip(avctx, pic, vflipped);
@@ -429,7 +425,6 @@ static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic,
enum AVPixelFormat fmt,
uint32_t vflipped)
{
- ThreadFrame frame = { .f = pic };
GetByteContext gb, gb_check;
GetBitContext gb2;
int nslices, slice, line = 0;
@@ -456,7 +451,7 @@ static int dxtory_decode_v2(AVCodecContext *avctx, AVFrame *pic,
return AVERROR_INVALIDDATA;
avctx->pix_fmt = fmt;
- if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
+ if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
return ret;
do_vflip(avctx, pic, vflipped);