[FFmpeg-devel] [PATCH 27/57] avcodec/me_cmp: Zero MECmpContext in ff_me_cmp_init()
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Jun 12 16:48:23 EEST 2024
Not every function will be set, so zero the context
to initialize everything.
This also allows to remove an initialization in dvenc.c.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/dvenc.c | 1 -
libavcodec/me_cmp.c | 2 ++
libavcodec/tests/motion.c | 2 --
tests/checkasm/motion.c | 3 ---
4 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index f2221d0b94..c42ab8931e 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -98,7 +98,6 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
MECmpContext mecc;
me_cmp_func ildct_cmp[6];
- memset(&mecc,0, sizeof(mecc));
ff_me_cmp_init(&mecc, avctx);
ret = ff_set_cmp(&mecc, ildct_cmp, avctx->ildct_cmp, 0);
if (ret < 0)
diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index dfc351d7ae..27da787c71 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -995,6 +995,8 @@ WRAPPER8_16_SQ(bit8x8_c, bit16_c)
av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
{
+ memset(c, 0, sizeof(*c));
+
c->sum_abs_dctelem = sum_abs_dctelem_c;
/* TODO [0] 16 [1] 8 */
diff --git a/libavcodec/tests/motion.c b/libavcodec/tests/motion.c
index caa8ecb8be..c37fc551c3 100644
--- a/libavcodec/tests/motion.c
+++ b/libavcodec/tests/motion.c
@@ -131,12 +131,10 @@ int main(int argc, char **argv)
ctx = avcodec_alloc_context3(NULL);
ctx->flags |= AV_CODEC_FLAG_BITEXACT;
av_force_cpu_flags(0);
- memset(&cctx, 0, sizeof(cctx));
ff_me_cmp_init(&cctx, ctx);
for (c = 0; c < flags_size; c++) {
int x;
av_force_cpu_flags(flags[c]);
- memset(&mmxctx, 0, sizeof(mmxctx));
ff_me_cmp_init(&mmxctx, ctx);
for (x = 0; x < 2; x++) {
diff --git a/tests/checkasm/motion.c b/tests/checkasm/motion.c
index bfd1a3c17b..7e322da0d5 100644
--- a/tests/checkasm/motion.c
+++ b/tests/checkasm/motion.c
@@ -116,9 +116,6 @@ static void check_motion(void)
AVCodecContext av_ctx = { .codec_id = AV_CODEC_ID_NONE, .flags = AV_CODEC_FLAG_BITEXACT };
MECmpContext me_ctx;
- memset(&me_ctx, 0, sizeof(me_ctx));
-
-
ff_me_cmp_init(&me_ctx, &av_ctx);
for (int i = 0; i < FF_ARRAY_ELEMS(me_ctx.pix_abs); i++) {
--
2.40.1
More information about the ffmpeg-devel
mailing list