From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v2 3/3] lavc/dxv: remove ctx fields that can be derived from texdsp ctxs
Date: Sun, 11 Feb 2024 10:04:27 +0100
Message-ID: <AS8P250MB07443D01CD0BEE1CD2A1CB758F492@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240210225847.53228-3-connorbworley@gmail.com>
Connor Worley:
> Signed-off-by: Connor Worley <connorbworley@gmail.com>
> ---
> libavcodec/dxv.c | 53 ++++++++----------------------------------------
> 1 file changed, 9 insertions(+), 44 deletions(-)
>
> diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
> index cd78de3e0d..82c493f1de 100644
> --- a/libavcodec/dxv.c
> +++ b/libavcodec/dxv.c
> @@ -39,20 +39,12 @@ typedef struct DXVContext {
>
> uint8_t *tex_data; // Compressed texture
> uint8_t *ctex_data; // Compressed chroma texture
> - int tex_rat; // Compression ratio
> - int tex_step; // Distance between blocks
> - int ctex_step; // Distance between blocks
> +
> int64_t tex_size; // Texture size
> int64_t ctex_size; // Chroma texture size
>
> uint8_t *op_data[4]; // Opcodes
> int64_t op_size[4]; // Opcodes size
> -
> - int texture_block_w;
> - int texture_block_h;
> -
> - int ctexture_block_w;
> - int ctexture_block_h;
> } DXVContext;
>
> /* This scheme addresses already decoded elements depending on 2-bit status:
> @@ -865,9 +857,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> cavctx.coded_height = avctx->coded_height / 2;
> cavctx.coded_width = avctx->coded_width / 2;
>
> - ctx->texture_block_h = 4;
> - ctx->texture_block_w = 4;
> -
> avctx->pix_fmt = AV_PIX_FMT_RGBA;
> avctx->colorspace = AVCOL_SPC_RGB;
>
> @@ -878,8 +867,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> texdsp_ctx.tex_funct = ctx->texdsp.dxt1_block;
> texdsp_ctx.tex_ratio = 8;
> texdsp_ctx.raw_ratio = 16;
> - ctx->tex_rat = 8;
> - ctx->tex_step = 8;
> msgcomp = "DXTR1";
> msgtext = "DXT1";
> break;
> @@ -889,8 +876,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> texdsp_ctx.tex_funct = ctx->texdsp.dxt4_block;
> texdsp_ctx.tex_ratio = 16;
> texdsp_ctx.raw_ratio = 16;
> - ctx->tex_rat = 4;
> - ctx->tex_step = 16;
> msgcomp = "DXTR5";
> msgtext = "DXT5";
> break;
> @@ -902,16 +887,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> ctexdsp_ctx.tex_funct = ctx->texdsp.rgtc1u_gray_block;
> ctexdsp_ctx.tex_ratio = 16;
> ctexdsp_ctx.raw_ratio = 4;
> - ctx->tex_rat = 8;
> - ctx->tex_step = 32;
> - ctx->ctex_step = 16;
> msgcomp = "YOCOCG6";
> msgtext = "YCG6";
> - ctx->ctex_size = avctx->coded_width * avctx->coded_height / 4;
> - ctx->texture_block_h = 4;
> - ctx->texture_block_w = 16;
> - ctx->ctexture_block_h = 4;
> - ctx->ctexture_block_w = 4;
> avctx->pix_fmt = AV_PIX_FMT_YUV420P;
> avctx->colorspace = AVCOL_SPC_YCOCG;
> break;
> @@ -923,16 +900,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> ctexdsp_ctx.tex_funct = ctx->texdsp.rgtc1u_gray_block;
> ctexdsp_ctx.tex_ratio = 16;
> ctexdsp_ctx.raw_ratio = 4;
> - ctx->tex_rat = 4;
> - ctx->tex_step = 64;
> - ctx->ctex_step = 16;
> msgcomp = "YAOCOCG10";
> msgtext = "YG10";
> - ctx->ctex_size = avctx->coded_width * avctx->coded_height / 4;
> - ctx->texture_block_h = 4;
> - ctx->texture_block_w = 16;
> - ctx->ctexture_block_h = 4;
> - ctx->ctexture_block_w = 4;
> avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
> avctx->colorspace = AVCOL_SPC_YCOCG;
> break;
> @@ -957,7 +926,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> texdsp_ctx.tex_funct = ctx->texdsp.dxt5_block;
> texdsp_ctx.tex_ratio = 16;
> texdsp_ctx.raw_ratio = 16;
> - ctx->tex_step = 16;
> } else if (old_type & 0x20 || version_major == 1) {
> tag = DXV_FMT_DXT1;
> msgtext = "DXT1";
> @@ -965,12 +933,10 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> texdsp_ctx.tex_funct = ctx->texdsp.dxt1_block;
> texdsp_ctx.tex_ratio = 8;
> texdsp_ctx.raw_ratio = 16;
> - ctx->tex_step = 8;
> } else {
> av_log(avctx, AV_LOG_ERROR, "Unsupported header (0x%08"PRIX32")\n.", tag);
> return AVERROR_INVALIDDATA;
> }
> - ctx->tex_rat = 1;
> break;
> }
>
> @@ -986,7 +952,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> /* Encoder copies texture data when compression is not advantageous. */
> if (bytestream2_get_byte(gbc)) {
> msgcomp = "RAW";
> - ctx->tex_rat = 1;
> decompress_tex = dxv_decompress_raw;
> }
>
> @@ -1004,14 +969,20 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> return AVERROR_INVALIDDATA;
> }
>
> - ctx->tex_size = avctx->coded_width * avctx->coded_height * 4 / ctx->tex_rat;
> + ctx->tex_size = avctx->coded_width / (texdsp_ctx.raw_ratio / (avctx->pix_fmt == AV_PIX_FMT_RGBA ? 4 : 1)) *
> + avctx->coded_height / TEXTURE_BLOCK_H *
> + texdsp_ctx.tex_ratio;
> ret = av_reallocp(&ctx->tex_data, ctx->tex_size + AV_INPUT_BUFFER_PADDING_SIZE);
> if (ret < 0)
> return ret;
>
> - if (ctx->ctex_size) {
> + if (avctx->pix_fmt != AV_PIX_FMT_RGBA) {
> int i;
>
> + ctx->ctex_size = cavctx.coded_width / ctexdsp_ctx.raw_ratio *
> + cavctx.coded_height / TEXTURE_BLOCK_H *
> + ctexdsp_ctx.tex_ratio;
> +
> ctx->op_size[0] = avctx->coded_width * avctx->coded_height / 16;
> ctx->op_size[1] = avctx->coded_width * avctx->coded_height / 32;
> ctx->op_size[2] = avctx->coded_width * avctx->coded_height / 32;
> @@ -1031,12 +1002,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
> ret = decompress_tex(avctx);
> if (ret < 0)
> return ret;
> - {
> - int w_block = avctx->coded_width / ctx->texture_block_w;
> - int h_block = avctx->coded_height / ctx->texture_block_h;
> - if (w_block * h_block * ctx->tex_step > ctx->tex_size * 8LL)
> - return AVERROR_INVALIDDATA;
> - }
You removed this check without replacement. It presumably fixed a bug.
Did you test whether you reopened said bug?
(I think I already asked this in an earlier iteration of this patchset.)
- Andreas
_______________________________________________
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".
next prev parent reply other threads:[~2024-02-11 9:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-10 22:58 [FFmpeg-devel] [PATCH v2 1/3] lavc/dxv: move tag definitions to common header Connor Worley
2024-02-10 22:58 ` [FFmpeg-devel] [PATCH v2 2/3] lavc/dvx: use texdsp funcs for texture block decompression Connor Worley
2024-02-10 22:58 ` [FFmpeg-devel] [PATCH v2 3/3] lavc/dxv: remove ctx fields that can be derived from texdsp ctxs Connor Worley
2024-02-10 23:42 ` Lynne
2024-02-11 9:04 ` Andreas Rheinhardt [this message]
2024-02-11 12:36 ` Connor Worley
2024-02-11 12:41 ` Connor Worley
2024-02-11 17:40 ` James Almer
2024-02-11 23:02 ` Connor Worley
2024-02-12 0:29 ` 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=AS8P250MB07443D01CD0BEE1CD2A1CB758F492@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