Просмотр исходного кода

avcodec/me_cmp: Zero MECmpContext in ff_me_cmp_init()

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@outlook.com>
Andreas Rheinhardt 10 месяцев назад
Родитель
Сommit
8b4f7c0663
4 измененных файлов с 2 добавлено и 6 удалено
  1. 0 1
      libavcodec/dvenc.c
  2. 2 0
      libavcodec/me_cmp.c
  3. 0 2
      libavcodec/tests/motion.c
  4. 0 3
      tests/checkasm/motion.c

+ 0 - 1
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)

+ 2 - 0
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 */

+ 0 - 2
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++) {

+ 0 - 3
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++) {