Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 4/7] avcodec/dxvenc, hap(dec|enc): Move TextureDSPContext to stack
Date: Wed, 24 Jan 2024 20:52:36 +0100
Message-ID: <AS8P250MB0744C784499A8746E4B628378F7B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB0744B4D31626D49493AE03358F7B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

Only used during init.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dxvenc.c |  6 +++---
 libavcodec/hap.h    |  1 -
 libavcodec/hapdec.c | 15 ++++++++-------
 libavcodec/hapenc.c |  9 +++++----
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/libavcodec/dxvenc.c b/libavcodec/dxvenc.c
index 94e522d72b..796f70da02 100644
--- a/libavcodec/dxvenc.c
+++ b/libavcodec/dxvenc.c
@@ -110,7 +110,6 @@ static void ht_delete(HTEntry *ht, const AVCRC *hash_ctx,
 typedef struct DXVEncContext {
     AVClass *class;
 
-    TextureDSPContext texdsp;
     PutByteContext pbc;
 
     uint8_t *tex_data;   // Compressed texture
@@ -267,6 +266,7 @@ static int dxv_encode(AVCodecContext *avctx, AVPacket *pkt,
 static av_cold int dxv_init(AVCodecContext *avctx)
 {
     DXVEncContext *ctx = avctx->priv_data;
+    TextureDSPContext texdsp;
     int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
 
     if (ret < 0) {
@@ -275,12 +275,12 @@ static av_cold int dxv_init(AVCodecContext *avctx)
         return ret;
     }
 
-    ff_texturedspenc_init(&ctx->texdsp);
+    ff_texturedspenc_init(&texdsp);
 
     switch (ctx->tex_fmt) {
     case DXV_FMT_DXT1:
         ctx->compress_tex = dxv_compress_dxt1;
-        ctx->enc.tex_funct = ctx->texdsp.dxt1_block;
+        ctx->enc.tex_funct = texdsp.dxt1_block;
         ctx->enc.tex_ratio = 8;
         break;
     default:
diff --git a/libavcodec/hap.h b/libavcodec/hap.h
index fb5a4c4123..a888b58fd7 100644
--- a/libavcodec/hap.h
+++ b/libavcodec/hap.h
@@ -61,7 +61,6 @@ typedef struct HapChunk {
 typedef struct HapContext {
     AVClass *class;
 
-    TextureDSPContext dxtc;
     GetByteContext gbc;
 
     enum HapTextureFormat opt_tex_fmt; /* Texture type (encoder only) */
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index fee3c04d84..64e0494370 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -337,6 +337,7 @@ static int hap_decode(AVCodecContext *avctx, AVFrame *frame,
 static av_cold int hap_init(AVCodecContext *avctx)
 {
     HapContext *ctx = avctx->priv_data;
+    TextureDSPContext dxtc;
     const char *texture_name;
     int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
 
@@ -350,7 +351,7 @@ static av_cold int hap_init(AVCodecContext *avctx)
     avctx->coded_width  = FFALIGN(avctx->width,  TEXTURE_BLOCK_W);
     avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H);
 
-    ff_texturedsp_init(&ctx->dxtc);
+    ff_texturedsp_init(&dxtc);
 
     ctx->texture_count  = 1;
     ctx->dec[0].raw_ratio = 16;
@@ -361,25 +362,25 @@ static av_cold int hap_init(AVCodecContext *avctx)
     case MKTAG('H','a','p','1'):
         texture_name = "DXT1";
         ctx->dec[0].tex_ratio = 8;
-        ctx->dec[0].tex_funct = ctx->dxtc.dxt1_block;
+        ctx->dec[0].tex_funct = dxtc.dxt1_block;
         avctx->pix_fmt = AV_PIX_FMT_RGB0;
         break;
     case MKTAG('H','a','p','5'):
         texture_name = "DXT5";
         ctx->dec[0].tex_ratio = 16;
-        ctx->dec[0].tex_funct = ctx->dxtc.dxt5_block;
+        ctx->dec[0].tex_funct = dxtc.dxt5_block;
         avctx->pix_fmt = AV_PIX_FMT_RGBA;
         break;
     case MKTAG('H','a','p','Y'):
         texture_name = "DXT5-YCoCg-scaled";
         ctx->dec[0].tex_ratio = 16;
-        ctx->dec[0].tex_funct = ctx->dxtc.dxt5ys_block;
+        ctx->dec[0].tex_funct = dxtc.dxt5ys_block;
         avctx->pix_fmt = AV_PIX_FMT_RGB0;
         break;
     case MKTAG('H','a','p','A'):
         texture_name = "RGTC1";
         ctx->dec[0].tex_ratio = 8;
-        ctx->dec[0].tex_funct = ctx->dxtc.rgtc1u_gray_block;
+        ctx->dec[0].tex_funct = dxtc.rgtc1u_gray_block;
         ctx->dec[0].raw_ratio = 4;
         avctx->pix_fmt = AV_PIX_FMT_GRAY8;
         break;
@@ -387,8 +388,8 @@ static av_cold int hap_init(AVCodecContext *avctx)
         texture_name  = "DXT5-YCoCg-scaled / RGTC1";
         ctx->dec[0].tex_ratio = 16;
         ctx->dec[1].tex_ratio = 8;
-        ctx->dec[0].tex_funct = ctx->dxtc.dxt5ys_block;
-        ctx->dec[1].tex_funct = ctx->dxtc.rgtc1u_alpha_block;
+        ctx->dec[0].tex_funct = dxtc.dxt5ys_block;
+        ctx->dec[1].tex_funct = dxtc.rgtc1u_alpha_block;
         ctx->dec[1].raw_ratio = 16;
         ctx->dec[1].slice_count = ctx->dec[0].slice_count;
         avctx->pix_fmt = AV_PIX_FMT_RGBA;
diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c
index 7de7358e3d..2c8bc8e16a 100644
--- a/libavcodec/hapenc.c
+++ b/libavcodec/hapenc.c
@@ -232,6 +232,7 @@ static int hap_encode(AVCodecContext *avctx, AVPacket *pkt,
 static av_cold int hap_init(AVCodecContext *avctx)
 {
     HapContext *ctx = avctx->priv_data;
+    TextureDSPContext dxtc;
     int corrected_chunk_count;
     int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
 
@@ -247,26 +248,26 @@ static av_cold int hap_init(AVCodecContext *avctx)
         return AVERROR_INVALIDDATA;
     }
 
-    ff_texturedspenc_init(&ctx->dxtc);
+    ff_texturedspenc_init(&dxtc);
 
     switch (ctx->opt_tex_fmt) {
     case HAP_FMT_RGBDXT1:
         ctx->enc.tex_ratio = 8;
         avctx->codec_tag = MKTAG('H', 'a', 'p', '1');
         avctx->bits_per_coded_sample = 24;
-        ctx->enc.tex_funct = ctx->dxtc.dxt1_block;
+        ctx->enc.tex_funct = dxtc.dxt1_block;
         break;
     case HAP_FMT_RGBADXT5:
         ctx->enc.tex_ratio = 16;
         avctx->codec_tag = MKTAG('H', 'a', 'p', '5');
         avctx->bits_per_coded_sample = 32;
-        ctx->enc.tex_funct = ctx->dxtc.dxt5_block;
+        ctx->enc.tex_funct = dxtc.dxt5_block;
         break;
     case HAP_FMT_YCOCGDXT5:
         ctx->enc.tex_ratio = 16;
         avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y');
         avctx->bits_per_coded_sample = 24;
-        ctx->enc.tex_funct = ctx->dxtc.dxt5ys_block;
+        ctx->enc.tex_funct = dxtc.dxt5ys_block;
         break;
     default:
         av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt);
-- 
2.34.1

_______________________________________________
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".

  parent reply	other threads:[~2024-01-24 20:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 19:50 [FFmpeg-devel] [PATCH 1/7] avcodec/dxvenc: Don't cast const away Andreas Rheinhardt
2024-01-24 19:52 ` [FFmpeg-devel] [PATCH 2/7] avcodec/dxvenc: Fix data races with slice threading Andreas Rheinhardt
2024-01-24 19:52 ` [FFmpeg-devel] [PATCH 3/7] avcodec/texturedspenc: Remove unused rgtc1_u_alpha encoding func Andreas Rheinhardt
2024-01-24 19:52 ` Andreas Rheinhardt [this message]
2024-01-24 19:52 ` [FFmpeg-devel] [PATCH 5/7] avcodec/texturedsp: Add separate TextureDSPEncContext Andreas Rheinhardt
2024-01-24 19:52 ` [FFmpeg-devel] [PATCH 6/7] avcodec/hap: Avoid unnecessary opt.h inclusion Andreas Rheinhardt
2024-01-25 19:27   ` Vittorio Giovara
2024-01-26  6:41     ` Andreas Rheinhardt
2024-01-24 19:52 ` [FFmpeg-devel] [PATCH 7/7] avcodec/texturedsp: Factor common code out Andreas Rheinhardt
2024-01-24 20:49 ` [FFmpeg-devel] [PATCH 1/7] avcodec/dxvenc: Don't cast const away Connor Worley
2024-01-25  3:04   ` Andreas Rheinhardt
2024-01-26 19:00 ` Andreas Rheinhardt
2024-01-26 19:15   ` Connor Worley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB0744C784499A8746E4B628378F7B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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