[FFmpeg-cvslog] avcodec/fic: Avoid copying cursor unnecessarily
Andreas Rheinhardt
git at videolan.org
Thu Jul 3 21:17:00 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Jun 23 03:40:15 2025 +0200| [5d5e922088fab4aa1329feaf9d9ad89519191f9f] | committer: Andreas Rheinhardt
avcodec/fic: Avoid copying cursor unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5d5e922088fab4aa1329feaf9d9ad89519191f9f
---
libavcodec/fic.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/libavcodec/fic.c b/libavcodec/fic.c
index ec26e3154d..a40fe1f27b 100644
--- a/libavcodec/fic.c
+++ b/libavcodec/fic.c
@@ -56,7 +56,6 @@ typedef struct FICContext {
int aligned_width, aligned_height;
int num_slices, slice_h;
- uint8_t cursor_buf[4096];
int skip_cursor;
} FICContext;
@@ -86,6 +85,7 @@ static const uint8_t fic_header[7] = { 0, 0, 1, 'F', 'I', 'C', 'V' };
#define FIC_HEADER_SIZE 27
#define CURSOR_OFFSET 59
+#define CURSOR_SIZE 4096
static av_always_inline void fic_idct(int16_t *blk, int step, int shift, int rnd)
{
@@ -214,10 +214,11 @@ static av_always_inline void fic_alpha_blend(uint8_t *dst, uint8_t *src,
dst[i] += ((src[i] - dst[i]) * alpha[i]) >> 8;
}
-static void fic_draw_cursor(AVCodecContext *avctx, int cur_x, int cur_y)
+static void fic_draw_cursor(AVCodecContext *avctx, const uint8_t cursor_buf[CURSOR_SIZE],
+ int cur_x, int cur_y)
{
FICContext *ctx = avctx->priv_data;
- uint8_t *ptr = ctx->cursor_buf;
+ const uint8_t *ptr = cursor_buf;
uint8_t *dstptr[3];
uint8_t planes[4][1024];
uint8_t chroma[3][256];
@@ -346,9 +347,8 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
skip_cursor = 1;
}
- if (!skip_cursor && avpkt->size < CURSOR_OFFSET + sizeof(ctx->cursor_buf)) {
+ if (!skip_cursor && avpkt->size < CURSOR_OFFSET + CURSOR_SIZE)
skip_cursor = 1;
- }
/* Slice height for all but the last slice. */
ctx->slice_h = 16 * (ctx->aligned_height >> 4) / nslices;
@@ -431,8 +431,7 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
/* Draw cursor. */
if (!skip_cursor) {
- memcpy(ctx->cursor_buf, src + CURSOR_OFFSET, sizeof(ctx->cursor_buf));
- fic_draw_cursor(avctx, cur_x, cur_y);
+ fic_draw_cursor(avctx, src + CURSOR_OFFSET, cur_x, cur_y);
}
skip:
More information about the ffmpeg-cvslog
mailing list