mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/texturedsp: Factor common code out
Namely calling avctx->execute2(avctx,...). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
4f58372c10
commit
341d0419e1
@ -636,7 +636,7 @@ 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];
|
||||
avctx->execute2(avctx, ff_texturedsp_decompress_thread, &ctx->dec, NULL, ctx->dec.slice_count);
|
||||
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];
|
||||
int x, y, i;
|
||||
|
@ -236,7 +236,7 @@ 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];
|
||||
avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count);
|
||||
ff_texturedsp_exec_compress_threads(avctx, &ctx->enc);
|
||||
} else {
|
||||
/* unimplemented: YCoCg formats */
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
@ -323,7 +323,7 @@ static int hap_decode(AVCodecContext *avctx, AVFrame *frame,
|
||||
|
||||
ctx->dec[t].frame_data.out = frame->data[0];
|
||||
ctx->dec[t].stride = frame->linesize[0];
|
||||
avctx->execute2(avctx, ff_texturedsp_decompress_thread, &ctx->dec[t], NULL, ctx->dec[t].slice_count);
|
||||
ff_texturedsp_exec_decompress_threads(avctx, &ctx->dec[t]);
|
||||
}
|
||||
|
||||
/* Frame is ready to be output */
|
||||
|
@ -63,7 +63,7 @@ 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];
|
||||
avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count);
|
||||
ff_texturedsp_exec_compress_threads(avctx, &ctx->enc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -653,6 +653,6 @@ av_cold void ff_texturedsp_init(TextureDSPContext *c)
|
||||
c->dxn3dc_block = dxn3dc_block;
|
||||
}
|
||||
|
||||
#define TEXTUREDSP_FUNC_NAME ff_texturedsp_decompress_thread
|
||||
#define TEXTUREDSP_FUNC_NAME ff_texturedsp_exec_decompress_threads
|
||||
#define TEXTUREDSP_TEX_FUNC(a, b, c) tex_funct(a, b, c)
|
||||
#include "texturedsp_template.c"
|
||||
|
@ -39,8 +39,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
#define TEXTURE_BLOCK_W 4
|
||||
#define TEXTURE_BLOCK_H 4
|
||||
|
||||
@ -89,7 +87,10 @@ typedef struct TextureDSPThreadContext {
|
||||
void ff_texturedsp_init(TextureDSPContext *c);
|
||||
void ff_texturedspenc_init(TextureDSPEncContext *c);
|
||||
|
||||
int ff_texturedsp_decompress_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb);
|
||||
int ff_texturedsp_compress_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb);
|
||||
struct AVCodecContext;
|
||||
int ff_texturedsp_exec_decompress_threads(struct AVCodecContext *avctx,
|
||||
TextureDSPThreadContext *ctx);
|
||||
int ff_texturedsp_exec_compress_threads(struct AVCodecContext *avctx,
|
||||
TextureDSPThreadContext *ctx);
|
||||
|
||||
#endif /* AVCODEC_TEXTUREDSP_H */
|
||||
|
@ -20,10 +20,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, void *arg,
|
||||
#include "avcodec.h"
|
||||
|
||||
static int exec_func(AVCodecContext *avctx, void *arg,
|
||||
int slice, int thread_nb)
|
||||
{
|
||||
TextureDSPThreadContext *ctx = 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;
|
||||
@ -55,3 +57,8 @@ int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, void *arg,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, TextureDSPThreadContext *ctx)
|
||||
{
|
||||
return avctx->execute2(avctx, exec_func, ctx, NULL, ctx->slice_count);
|
||||
}
|
||||
|
@ -654,6 +654,6 @@ av_cold void ff_texturedspenc_init(TextureDSPEncContext *c)
|
||||
c->dxt5ys_block = dxt5ys_block;
|
||||
}
|
||||
|
||||
#define TEXTUREDSP_FUNC_NAME ff_texturedsp_compress_thread
|
||||
#define TEXTUREDSP_FUNC_NAME ff_texturedsp_exec_compress_threads
|
||||
#define TEXTUREDSP_TEX_FUNC(a, b, c) tex_funct(c, b, a)
|
||||
#include "texturedsp_template.c"
|
||||
|
@ -162,7 +162,7 @@ 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];
|
||||
avctx->execute2(avctx, ff_texturedsp_decompress_thread, &ctx->dec, NULL, ctx->dec.slice_count);
|
||||
ff_texturedsp_exec_decompress_threads(avctx, &ctx->dec);
|
||||
}
|
||||
|
||||
*got_frame = 1;
|
||||
|
@ -114,7 +114,7 @@ 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;
|
||||
avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count);
|
||||
ff_texturedsp_exec_compress_threads(avctx, &ctx->enc);
|
||||
} else {
|
||||
const uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1);
|
||||
av_image_copy_plane(pkt->data + VBN_HEADER_SIZE, linesize, flipped, -frame->linesize[0], linesize, frame->height);
|
||||
|
Loading…
Reference in New Issue
Block a user