* [FFmpeg-devel] [PATCH] avcodec/apv_decode: build the lut table only once
@ 2025-05-04 1:46 James Almer
0 siblings, 0 replies; only message in thread
From: James Almer @ 2025-05-04 1:46 UTC (permalink / raw)
To: ffmpeg-devel
No reason to build the exact same table once per decoding thread.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/apv_decode.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/libavcodec/apv_decode.c b/libavcodec/apv_decode.c
index b1e1db7d64..b1c59fc873 100644
--- a/libavcodec/apv_decode.c
+++ b/libavcodec/apv_decode.c
@@ -19,6 +19,7 @@
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/thread.h"
#include "apv.h"
#include "apv_decode.h"
@@ -39,8 +40,6 @@ typedef struct APVDecodeContext {
CodedBitstreamFragment au;
APVDerivedTileInfo tile_info;
- APVVLCLUT decode_lut;
-
AVFrame *output_frame;
uint8_t warned_additional_frames;
@@ -55,6 +54,8 @@ static const enum AVPixelFormat apv_format_table[5][5] = {
{ AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUVA444P16 },
};
+static APVVLCLUT decode_lut;
+
static int apv_decode_check_format(AVCodecContext *avctx,
const APVRawFrameHeader *header)
{
@@ -101,11 +102,20 @@ static const CodedBitstreamUnitType apv_decompose_unit_types[] = {
APV_PBU_METADATA,
};
+static AVOnce apv_entropy_once = AV_ONCE_INIT;
+
+static av_cold void apv_entropy_build_decode_lut(void)
+{
+ ff_apv_entropy_build_decode_lut(&decode_lut);
+}
+
static av_cold int apv_decode_init(AVCodecContext *avctx)
{
APVDecodeContext *apv = avctx->priv_data;
int err;
+ ff_thread_once(&apv_entropy_once, apv_entropy_build_decode_lut);
+
err = ff_cbs_init(&apv->cbc, AV_CODEC_ID_APV, avctx);
if (err < 0)
return err;
@@ -117,8 +127,6 @@ static av_cold int apv_decode_init(AVCodecContext *avctx)
// Extradata could be set here, but is ignored by the decoder.
- ff_apv_entropy_build_decode_lut(&apv->decode_lut);
-
ff_apv_dsp_init(&apv->dsp);
return 0;
@@ -201,7 +209,7 @@ static int apv_decode_tile_component(AVCodecContext *avctx, void *data,
APVEntropyState entropy_state = {
.log_ctx = avctx,
- .decode_lut = &apv->decode_lut,
+ .decode_lut = &decode_lut,
.prev_dc = 0,
.prev_dc_diff = 20,
.prev_1st_ac_level = 0,
--
2.49.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-05-04 1:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-04 1:46 [FFmpeg-devel] [PATCH] avcodec/apv_decode: build the lut table only once James Almer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git