diff --git a/libavcodec/dds.c b/libavcodec/dds.c index 67e2325a2a..89cf225f25 100644 --- a/libavcodec/dds.c +++ b/libavcodec/dds.c @@ -636,6 +636,8 @@ static int dds_decode(AVCodecContext *avctx, AVFrame *frame, ctx->dec.tex_data.in = gbc->buffer; ctx->dec.frame_data.out = frame->data[0]; ctx->dec.stride = frame->linesize[0]; + ctx->dec.width = avctx->coded_width; + ctx->dec.height = avctx->coded_height; ff_texturedsp_exec_decompress_threads(avctx, &ctx->dec); } else if (!ctx->paletted && ctx->bpp == 4 && avctx->pix_fmt == AV_PIX_FMT_PAL8) { uint8_t *dst = frame->data[0]; diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c index 82c493f1de..9130319d8f 100644 --- a/libavcodec/dxv.c +++ b/libavcodec/dxv.c @@ -843,7 +843,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, { DXVContext *ctx = avctx->priv_data; GetByteContext *gbc = &ctx->gbc; - AVCodecContext cavctx = *avctx; TextureDSPThreadContext texdsp_ctx, ctexdsp_ctx; int (*decompress_tex)(AVCodecContext *avctx); const char *msgcomp, *msgtext; @@ -854,9 +853,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, bytestream2_init(gbc, avpkt->data, avpkt->size); - cavctx.coded_height = avctx->coded_height / 2; - cavctx.coded_width = avctx->coded_width / 2; - avctx->pix_fmt = AV_PIX_FMT_RGBA; avctx->colorspace = AVCOL_SPC_RGB; @@ -943,7 +939,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, texdsp_ctx.slice_count = av_clip(avctx->thread_count, 1, avctx->coded_height / TEXTURE_BLOCK_H); ctexdsp_ctx.slice_count = av_clip(avctx->thread_count, 1, - cavctx.coded_height / TEXTURE_BLOCK_H); + avctx->coded_height / 2 / TEXTURE_BLOCK_H); + /* New header is 12 bytes long. */ if (!old_type) { version_major = bytestream2_get_byte(gbc) - 1; @@ -979,8 +976,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, 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 * + ctx->ctex_size = avctx->coded_width / 2 / ctexdsp_ctx.raw_ratio * + avctx->coded_height / 2 / TEXTURE_BLOCK_H * ctexdsp_ctx.tex_ratio; ctx->op_size[0] = avctx->coded_width * avctx->coded_height / 16; @@ -1007,6 +1004,10 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, if (ret < 0) return ret; + texdsp_ctx.width = avctx->coded_width; + texdsp_ctx.height = avctx->coded_height; + ctexdsp_ctx.width = avctx->coded_width / 2; + ctexdsp_ctx.height = avctx->coded_height / 2; switch (tag) { case DXV_FMT_YG10: /* BC5 texture with alpha in the second half of each block */ @@ -1022,13 +1023,13 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, ctexdsp_ctx.tex_data.in = ctx->ctex_data; ctexdsp_ctx.frame_data.out = frame->data[2]; ctexdsp_ctx.stride = frame->linesize[2]; - ret = ff_texturedsp_exec_decompress_threads(&cavctx, &ctexdsp_ctx); + ret = ff_texturedsp_exec_decompress_threads(avctx, &ctexdsp_ctx); if (ret < 0) return ret; ctexdsp_ctx.tex_data.in = ctx->ctex_data + ctexdsp_ctx.tex_ratio / 2; ctexdsp_ctx.frame_data.out = frame->data[1]; ctexdsp_ctx.stride = frame->linesize[1]; - ret = ff_texturedsp_exec_decompress_threads(&cavctx, &ctexdsp_ctx); + ret = ff_texturedsp_exec_decompress_threads(avctx, &ctexdsp_ctx); if (ret < 0) return ret; /* fallthrough */ diff --git a/libavcodec/dxvenc.c b/libavcodec/dxvenc.c index c7a6a02d0d..1ce2b1d014 100644 --- a/libavcodec/dxvenc.c +++ b/libavcodec/dxvenc.c @@ -233,6 +233,8 @@ static int dxv_encode(AVCodecContext *avctx, AVPacket *pkt, ctx->enc.tex_data.out = ctx->tex_data; ctx->enc.frame_data.in = frame->data[0]; ctx->enc.stride = frame->linesize[0]; + ctx->enc.width = avctx->width; + ctx->enc.height = avctx->height; ff_texturedsp_exec_compress_threads(avctx, &ctx->enc); } else { /* unimplemented: YCoCg formats */ diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c index 3a848e9f67..6066cb814c 100644 --- a/libavcodec/hapdec.c +++ b/libavcodec/hapdec.c @@ -323,6 +323,8 @@ static int hap_decode(AVCodecContext *avctx, AVFrame *frame, ctx->dec[t].frame_data.out = frame->data[0]; ctx->dec[t].stride = frame->linesize[0]; + ctx->dec[t].width = avctx->coded_width; + ctx->dec[t].height = avctx->coded_height; ff_texturedsp_exec_decompress_threads(avctx, &ctx->dec[t]); } diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c index 50798d1812..3f74098d13 100644 --- a/libavcodec/hapenc.c +++ b/libavcodec/hapenc.c @@ -63,6 +63,8 @@ static int compress_texture(AVCodecContext *avctx, uint8_t *out, int out_length, ctx->enc.tex_data.out = out; ctx->enc.frame_data.in = f->data[0]; ctx->enc.stride = f->linesize[0]; + ctx->enc.width = avctx->width; + ctx->enc.height = avctx->height; ff_texturedsp_exec_compress_threads(avctx, &ctx->enc); return 0; diff --git a/libavcodec/texturedsp.h b/libavcodec/texturedsp.h index 86c8eea02d..0bf49e8729 100644 --- a/libavcodec/texturedsp.h +++ b/libavcodec/texturedsp.h @@ -72,6 +72,7 @@ typedef struct TextureDSPThreadContext { uint8_t *out; // Output frame data } frame_data; ptrdiff_t stride; // Frame linesize + int width, height; // Frame width / height union { const uint8_t *in; // Compressed texture for decompression uint8_t *out; // Compressed texture of compression diff --git a/libavcodec/texturedsp_template.c b/libavcodec/texturedsp_template.c index 9589cc4187..b9caf494cc 100644 --- a/libavcodec/texturedsp_template.c +++ b/libavcodec/texturedsp_template.c @@ -27,8 +27,8 @@ static int exec_func(AVCodecContext *avctx, void *arg, { const TextureDSPThreadContext *ctx = arg; uint8_t *d = ctx->tex_data.out; - int w_block = avctx->coded_width / TEXTURE_BLOCK_W; - int h_block = avctx->coded_height / TEXTURE_BLOCK_H; + int w_block = ctx->width / TEXTURE_BLOCK_W; + int h_block = ctx->height / TEXTURE_BLOCK_H; int x, y; int start_slice, end_slice; int base_blocks_per_slice = h_block / ctx->slice_count; diff --git a/libavcodec/vbndec.c b/libavcodec/vbndec.c index 83ce9e994b..68b2236124 100644 --- a/libavcodec/vbndec.c +++ b/libavcodec/vbndec.c @@ -162,6 +162,8 @@ static int vbn_decode_frame(AVCodecContext *avctx, ctx->dec.raw_ratio = 16; ctx->dec.frame_data.out = frame->data[0] + frame->linesize[0] * (frame->height - 1); ctx->dec.stride = -frame->linesize[0]; + ctx->dec.width = avctx->coded_width; + ctx->dec.height = avctx->coded_height; ff_texturedsp_exec_decompress_threads(avctx, &ctx->dec); } diff --git a/libavcodec/vbnenc.c b/libavcodec/vbnenc.c index 13412b6e37..55e436b5e5 100644 --- a/libavcodec/vbnenc.c +++ b/libavcodec/vbnenc.c @@ -114,6 +114,8 @@ static int vbn_encode(AVCodecContext *avctx, AVPacket *pkt, ctx->enc.frame_data.in = (frame->height - 1) * frame->linesize[0] + frame->data[0]; ctx->enc.stride = -frame->linesize[0]; ctx->enc.tex_data.out = pkt->data + VBN_HEADER_SIZE; + ctx->enc.width = avctx->width; + ctx->enc.height = avctx->height; ff_texturedsp_exec_compress_threads(avctx, &ctx->enc); } else { const uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1);