diff mbox series

[FFmpeg-devel,5/9] checkasm/motion: Don't allocate AVCodecContext

Message ID AS8P250MB07443D1A99F33815791F613C8FFCA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 0228e27dedc66c98e5b25dee0f95e664a185bbf1
Headers show
Series [FFmpeg-devel,1/9] avfilter/bwdif: Add proper BWDIFDSPContext | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 25, 2023, 6:04 p.m. UTC
Instead use one on the stack to avoid pulling in all
of libavcodec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
ff_me_cmp_init() reads only codec_id (checks whether it is Snow)
as well as the bitexact flag. The first check has been added in
cfe675269bf44c49590e9076b5d2cd2503804f98 due to alignment;
I don't know whether this is still an issue, as the ticket referred
to in this commit does not refer to track (or at least the current
incarnation of it), but to something else.

 tests/checkasm/motion.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/tests/checkasm/motion.c b/tests/checkasm/motion.c
index 87b20d1c10..71a0ee3fc0 100644
--- a/tests/checkasm/motion.c
+++ b/tests/checkasm/motion.c
@@ -118,16 +118,14 @@  static void test_motion(const char *name, me_cmp_func test_func)
 static void check_motion(void)
 {
     char buf[64];
-    AVCodecContext *av_ctx;
+    /* Setup AVCodecContext in a way that does not pull in all of libavcodec */
+    AVCodecContext av_ctx = { .codec_id = AV_CODEC_ID_NONE, .flags = AV_CODEC_FLAG_BITEXACT };
     MECmpContext me_ctx;
 
     memset(&me_ctx, 0, sizeof(me_ctx));
 
-    /* allocate AVCodecContext */
-    av_ctx = avcodec_alloc_context3(NULL);
-    av_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
 
-    ff_me_cmp_init(&me_ctx, av_ctx);
+    ff_me_cmp_init(&me_ctx, &av_ctx);
 
     for (int i = 0; i < FF_ARRAY_ELEMS(me_ctx.pix_abs); i++) {
         for (int j = 0; j < FF_ARRAY_ELEMS(me_ctx.pix_abs[0]); j++) {
@@ -143,8 +141,6 @@  static void check_motion(void)
     }
     ME_CMP_1D_ARRAYS(XX)
 #undef XX
-
-    avcodec_free_context(&av_ctx);
 }
 
 void checkasm_check_motion(void)