avcodec/dxvenc, hap(dec|enc): Move TextureDSPContext to stack
Only used during init. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -110,7 +110,6 @@ static void ht_delete(HTEntry *ht, const AVCRC *hash_ctx,
|
|||||||
typedef struct DXVEncContext {
|
typedef struct DXVEncContext {
|
||||||
AVClass *class;
|
AVClass *class;
|
||||||
|
|
||||||
TextureDSPContext texdsp;
|
|
||||||
PutByteContext pbc;
|
PutByteContext pbc;
|
||||||
|
|
||||||
uint8_t *tex_data; // Compressed texture
|
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)
|
static av_cold int dxv_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
DXVEncContext *ctx = avctx->priv_data;
|
DXVEncContext *ctx = avctx->priv_data;
|
||||||
|
TextureDSPContext texdsp;
|
||||||
int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
|
int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -275,12 +275,12 @@ static av_cold int dxv_init(AVCodecContext *avctx)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ff_texturedspenc_init(&ctx->texdsp);
|
ff_texturedspenc_init(&texdsp);
|
||||||
|
|
||||||
switch (ctx->tex_fmt) {
|
switch (ctx->tex_fmt) {
|
||||||
case DXV_FMT_DXT1:
|
case DXV_FMT_DXT1:
|
||||||
ctx->compress_tex = dxv_compress_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;
|
ctx->enc.tex_ratio = 8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@@ -61,7 +61,6 @@ typedef struct HapChunk {
|
|||||||
typedef struct HapContext {
|
typedef struct HapContext {
|
||||||
AVClass *class;
|
AVClass *class;
|
||||||
|
|
||||||
TextureDSPContext dxtc;
|
|
||||||
GetByteContext gbc;
|
GetByteContext gbc;
|
||||||
|
|
||||||
enum HapTextureFormat opt_tex_fmt; /* Texture type (encoder only) */
|
enum HapTextureFormat opt_tex_fmt; /* Texture type (encoder only) */
|
||||||
|
@@ -337,6 +337,7 @@ static int hap_decode(AVCodecContext *avctx, AVFrame *frame,
|
|||||||
static av_cold int hap_init(AVCodecContext *avctx)
|
static av_cold int hap_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
HapContext *ctx = avctx->priv_data;
|
HapContext *ctx = avctx->priv_data;
|
||||||
|
TextureDSPContext dxtc;
|
||||||
const char *texture_name;
|
const char *texture_name;
|
||||||
int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
|
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_width = FFALIGN(avctx->width, TEXTURE_BLOCK_W);
|
||||||
avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H);
|
avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H);
|
||||||
|
|
||||||
ff_texturedsp_init(&ctx->dxtc);
|
ff_texturedsp_init(&dxtc);
|
||||||
|
|
||||||
ctx->texture_count = 1;
|
ctx->texture_count = 1;
|
||||||
ctx->dec[0].raw_ratio = 16;
|
ctx->dec[0].raw_ratio = 16;
|
||||||
@@ -361,25 +362,25 @@ static av_cold int hap_init(AVCodecContext *avctx)
|
|||||||
case MKTAG('H','a','p','1'):
|
case MKTAG('H','a','p','1'):
|
||||||
texture_name = "DXT1";
|
texture_name = "DXT1";
|
||||||
ctx->dec[0].tex_ratio = 8;
|
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;
|
avctx->pix_fmt = AV_PIX_FMT_RGB0;
|
||||||
break;
|
break;
|
||||||
case MKTAG('H','a','p','5'):
|
case MKTAG('H','a','p','5'):
|
||||||
texture_name = "DXT5";
|
texture_name = "DXT5";
|
||||||
ctx->dec[0].tex_ratio = 16;
|
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;
|
avctx->pix_fmt = AV_PIX_FMT_RGBA;
|
||||||
break;
|
break;
|
||||||
case MKTAG('H','a','p','Y'):
|
case MKTAG('H','a','p','Y'):
|
||||||
texture_name = "DXT5-YCoCg-scaled";
|
texture_name = "DXT5-YCoCg-scaled";
|
||||||
ctx->dec[0].tex_ratio = 16;
|
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;
|
avctx->pix_fmt = AV_PIX_FMT_RGB0;
|
||||||
break;
|
break;
|
||||||
case MKTAG('H','a','p','A'):
|
case MKTAG('H','a','p','A'):
|
||||||
texture_name = "RGTC1";
|
texture_name = "RGTC1";
|
||||||
ctx->dec[0].tex_ratio = 8;
|
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;
|
ctx->dec[0].raw_ratio = 4;
|
||||||
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
|
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
|
||||||
break;
|
break;
|
||||||
@@ -387,8 +388,8 @@ static av_cold int hap_init(AVCodecContext *avctx)
|
|||||||
texture_name = "DXT5-YCoCg-scaled / RGTC1";
|
texture_name = "DXT5-YCoCg-scaled / RGTC1";
|
||||||
ctx->dec[0].tex_ratio = 16;
|
ctx->dec[0].tex_ratio = 16;
|
||||||
ctx->dec[1].tex_ratio = 8;
|
ctx->dec[1].tex_ratio = 8;
|
||||||
ctx->dec[0].tex_funct = ctx->dxtc.dxt5ys_block;
|
ctx->dec[0].tex_funct = dxtc.dxt5ys_block;
|
||||||
ctx->dec[1].tex_funct = ctx->dxtc.rgtc1u_alpha_block;
|
ctx->dec[1].tex_funct = dxtc.rgtc1u_alpha_block;
|
||||||
ctx->dec[1].raw_ratio = 16;
|
ctx->dec[1].raw_ratio = 16;
|
||||||
ctx->dec[1].slice_count = ctx->dec[0].slice_count;
|
ctx->dec[1].slice_count = ctx->dec[0].slice_count;
|
||||||
avctx->pix_fmt = AV_PIX_FMT_RGBA;
|
avctx->pix_fmt = AV_PIX_FMT_RGBA;
|
||||||
|
@@ -232,6 +232,7 @@ static int hap_encode(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
static av_cold int hap_init(AVCodecContext *avctx)
|
static av_cold int hap_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
HapContext *ctx = avctx->priv_data;
|
HapContext *ctx = avctx->priv_data;
|
||||||
|
TextureDSPContext dxtc;
|
||||||
int corrected_chunk_count;
|
int corrected_chunk_count;
|
||||||
int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
|
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;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ff_texturedspenc_init(&ctx->dxtc);
|
ff_texturedspenc_init(&dxtc);
|
||||||
|
|
||||||
switch (ctx->opt_tex_fmt) {
|
switch (ctx->opt_tex_fmt) {
|
||||||
case HAP_FMT_RGBDXT1:
|
case HAP_FMT_RGBDXT1:
|
||||||
ctx->enc.tex_ratio = 8;
|
ctx->enc.tex_ratio = 8;
|
||||||
avctx->codec_tag = MKTAG('H', 'a', 'p', '1');
|
avctx->codec_tag = MKTAG('H', 'a', 'p', '1');
|
||||||
avctx->bits_per_coded_sample = 24;
|
avctx->bits_per_coded_sample = 24;
|
||||||
ctx->enc.tex_funct = ctx->dxtc.dxt1_block;
|
ctx->enc.tex_funct = dxtc.dxt1_block;
|
||||||
break;
|
break;
|
||||||
case HAP_FMT_RGBADXT5:
|
case HAP_FMT_RGBADXT5:
|
||||||
ctx->enc.tex_ratio = 16;
|
ctx->enc.tex_ratio = 16;
|
||||||
avctx->codec_tag = MKTAG('H', 'a', 'p', '5');
|
avctx->codec_tag = MKTAG('H', 'a', 'p', '5');
|
||||||
avctx->bits_per_coded_sample = 32;
|
avctx->bits_per_coded_sample = 32;
|
||||||
ctx->enc.tex_funct = ctx->dxtc.dxt5_block;
|
ctx->enc.tex_funct = dxtc.dxt5_block;
|
||||||
break;
|
break;
|
||||||
case HAP_FMT_YCOCGDXT5:
|
case HAP_FMT_YCOCGDXT5:
|
||||||
ctx->enc.tex_ratio = 16;
|
ctx->enc.tex_ratio = 16;
|
||||||
avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y');
|
avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y');
|
||||||
avctx->bits_per_coded_sample = 24;
|
avctx->bits_per_coded_sample = 24;
|
||||||
ctx->enc.tex_funct = ctx->dxtc.dxt5ys_block;
|
ctx->enc.tex_funct = dxtc.dxt5ys_block;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt);
|
av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt);
|
||||||
|
Reference in New Issue
Block a user