- for (i = 0; i < ctx->chunk_count; i++) {
- if (ctx->chunk_results[i] < 0)
- return ctx->chunk_results[i];
+ if (avctx->codec->update_thread_context)
+ ff_thread_finish_setup(avctx);
+
+ /* Unpack the DXT texture */
+ if (hap_can_use_tex_in_place(ctx)) {
+ /* Only DXTC texture compression in a contiguous block */
+ ctx->tex_data = ctx->gbc.buffer;
+ tex_size = FFMIN(ctx->texture_section_size, bytestream2_get_bytes_left(&ctx->gbc));
+ } else {
+ /* Perform the second-stage decompression */
+ ret = av_reallocp(&ctx->tex_buf, ctx->tex_size);
+ if (ret < 0)
+ return ret;
+
+ avctx->execute2(avctx, decompress_chunks_thread, NULL,
+ ctx->chunk_results, ctx->chunk_count);
+
+ for (i = 0; i < ctx->chunk_count; i++) {
+ if (ctx->chunk_results[i] < 0)
+ return ctx->chunk_results[i];
+ }
+
+ ctx->tex_data = ctx->tex_buf;
+ tex_size = ctx->tex_size;