From patchwork Mon Apr 29 21:14:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48406 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1509:b0:1a9:af23:56c1 with SMTP id nq9csp2272774pzb; Mon, 29 Apr 2024 14:20:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzIH9o3sadD14c4CJGCtPR7bbBOxmR4SqRHB4+xhdqPFKp6ogtkdnT7S/xBeHF9Ed31AR8/TNT0AvEL5NAqYn+Brvff7VL8NmVJw== X-Google-Smtp-Source: AGHT+IEBo/5BhHg0foRd//S4c8fjUU/4KNLTl9cmIsP6noFL2cBgNXUk77N8R+ZtH/ZBA0p3vxOs X-Received: by 2002:a05:6402:320a:b0:572:5f24:153a with SMTP id g10-20020a056402320a00b005725f24153amr6798745eda.3.1714425616356; Mon, 29 Apr 2024 14:20:16 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a15-20020a509b4f000000b005726912d00bsi3352316edj.447.2024.04.29.14.20.15; Mon, 29 Apr 2024 14:20:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b="o/H858WQ"; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 114F268D613; Tue, 30 Apr 2024 00:17:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2106.outbound.protection.outlook.com [40.92.91.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4EB0868D605 for ; Tue, 30 Apr 2024 00:17:29 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WwjcwZWRF9iokr0R1xZTqqb/Hl2pcDt2NkMhW/sztJl7QCZFyHXDTWsrUbsmUpAV2mAW6+DDJ2oM/xPg5bEPChAz20AY+0HvFXWap1pj3v1cTWBNLL+X0o3a6yjpMaDFFv/OjV8upQGuECaUfhGX8rllT9yzTtSiHNEtCEHcmec3gfjiNic76oM00mUtfhd87ZGpilz2XHpt5bBKLsbMdD4XlFhyIzjceEPcmic5HroIgZz/cXST21V2JUlZOOEPSxMGQF5uNWjMvK/3vUmn9YnZcnJCcoK+k/eeLptJl7A2fKWfXkDsFM+6+dfhCO0oK92O0ZY5WYRNhhLg5hJQ7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t0Is5JwEYfWr1cJOxVdA4fCPd5LrteA/JLsI/WNpwBQ=; b=Il44Qjo5qPP3hF4Xpu/K1/KtAEp2k+fFO1KQmiPXDmX9ayNRW/zDbxH8m+np54296ZwmbG5LjGwpaP92Q/r5ksJLDayP6ZsLTBJ8ZCfJbdnsSl/9Zucd+tpNU25MIKSrsHLa1Rx1Tl+BPM1J1cvvzTZePABte3M9EnpZoMRmCUN4y/+3B1Y2N2emyD7cfMP0cultYQL3P14YwLY2y+iMnnxMMeDvG0GzX11etxZqZq1Oy971XyY2k2U9wk9ixIPCE/rU8E+maudvxed+e1M1eOBN2vXd8PVwnUl0VaZo1KhlDGFVRdfjgpwpeuiUa9Tyyn28suxdhfyl99Pp/SopAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t0Is5JwEYfWr1cJOxVdA4fCPd5LrteA/JLsI/WNpwBQ=; b=o/H858WQuHS+HwKPAlj9su2Aia/4DL2O1dN5omB64JZP2ufovYMVbI1IfBZlS0bIyYh/NHa9MNp7lqIzjuctsjoTNCKvvxqclOsi53+ETteYIxJh6CwQKXDCOU4NjwVo5oTRNZoB0L6v0RwGihuSC4AZ/TYf7JzOUMXTHjjWDeFVSIQJMvLnC4HoVEjyxGGFoJq1gKsrPxrO1qH4eAJTuUIprs13UZCB0AcjiS8sQMTWSQn1nhcYbDSjEx2QoGkRT67xdCW7pDMrW4hGXCZRyX7szXWXccVCWmMAOa6b/uTY0WMBe0Uh9lGIepqh66h3FgaXjGfhZP2LxsglHj2oSg== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0616.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:297::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 21:17:27 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 21:17:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Apr 2024 23:14:29 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [jSg3jxXklbhzwLgLTcticYBUBZcDgTSyXXl+YcLO8Bo=] X-ClientProxiedBy: ZR0P278CA0199.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:6a::21) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240429211438.3274834-34-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0616:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a8ec850-32de-44a1-1edf-08dc6891c5b3 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3412199016|440099019|1710799017; X-Microsoft-Antispam-Message-Info: 3jQk//Apmfmc8IAJaezcP9Q6bKA7GbeO6iYqFce6gZwKLkik3k8gD25zBuZKyJ3T36hiRstqxjiweTkWG4INcZC/pfWEHt8yob0J7hY6W5N6+VZybro8YOO2GC1ZIm99g52dridaPIeZNSwVHq8rbS0k2eOgJA/kcwXtRji3NO70Z/Ys17+yo16RHFpMSbOrL/Hj2vnCswpkuEoUCkkSbPtJA0xoS1HoVB/lrNYlp5iA+EzvHN4ulsDu2ZNamk21TKAif66JzDoaoKmwXdBpCrXW6+TJkuwIeE4P+5PfuOzc7Zp7nP8FM7+aRH9xzN/cqoRfsGqeyWojGELH47lfSm93GMtrj09NT7QFkXMA/p+baWsUx6W0Yql8JlMoV0pGD5ApiAY1Yy2aPYSAsvkFYKx3m9FZ0pmMt8+aOHb5jGSHrZ622HHtVPDq0uyxTDPoL5qohgSoq1YjBLprH7tsXq2+yUVQhXnmlwy9wBBMD9ZUz63dhVOSf3oQXVXz4YJGYnFcIaEVdJY2mDQ1j4veTPNxJ+zmPAUVQ4RdLUoN+Ukw/K4d0XKw3UemO4viBsjvFocEniMY+tZw2j09hXfIK4KaBhw45TeoaXwc1M3zRJY= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iLP23R6hgJiFY2eRFzr8Cc642YbL4gMLwf2/RPGQ5k6wkhPJlAohT/eLQ9u6ZorPV5Z5s1mwoq08nkBkAYA8s8FtWTLl1NQp98pWj8l36zjgqzfy139P20Cr4OushlBHPxBDlEuyeKJIyMVaVzYEVFPQJZ0tZvFqbz2oLSjllVxeaUc5+y3a0+WbYx+e/mdPTjZfRtFrUR3z1KqtU9rA+2/eB2JlcreZpcB0NtdZlSGpsdnE6hhxDjyPNnreVXBZfJ8DqSEXjLayhT2cA6xR4s4d8xlirNEFxjD6gd2noQwiFhJcVa0AmlKTAW4a/RSjyLbaKftY4IZNP3qpe0WhAbALLRVMdflEL4tMLW+VnfPf9m+8RKVq3AGpZr0S6g2AlsV+MQyv/SZyJx8HXhY9E4tN1fFQqvNE4qTVjCK39MEkzwGBJZ247oIgt3rkuGhIaKAe9nBD2rG/XF0P2zYWk6z0NaDHQhivnnOmJs+BNgjNyxaxAQ2UJCgak2aPVWs09mjxUlg5wqdshYhCYlYz3ixTQOesopVLEMkkt0EuroUfQv3b6r16Raa4FCgO6dbgF02EwhuAc7qZwFt3dDiU6P+U/qFsXkJSb0DjYOltV2ZxlKx5hpXiu/RGJxX6eBL+pcQdje8K1MgpjXtiwN8P2bzjj46KCbg7QA9g1SBqEpQMwUl3sbNUwmqCTsKCqzTjxEHQwN37yNOIE2Ie8z10HvT6FV9QkbAhCs8O3QO0dIZQaa/LMu03IL9Kk6J5hLnrAXmjjpSypd1xJZceS3NTvLc7liccxYWQNkqf/JSYEBRUTlji5pmQe/euYBx11bry1Z90KGqREz+/DwegCYb+3RAPfqgYoRbNKqXAFL1H6MRPT2VYCo6J2ELdfoS2DxX+RQa5OsvimpNDDZD98jKr/KVDARV4qdJnOQKO4mWMRj2gqoZWh7alKGNW4qZm53PS6i5yDP3mf2m9VWvP7b/YMjH+AdZMFB8NR4kup7QJzBVTMwdf1goirDjpHkj6+1GSNRTHpvpbY6OpZVcN/X8xIeX9Vh1IULtJsGhY5348qYZu29cAMasQ90ruHf6yzIWaM8LIJVvQxhMoMMQqsvLSuh4sTLKRN5wsjxnjjtEkG1udLNm0U75xRHhnu4uGIni1zT6ZBKAVKAKJ3kAmdN3wsfM7h3VxYK5Anwrh/QgTKHjftkR3imnG2aeRDkRYzG0JEncprWBz6m2Edd0WuFtKu3IeOGc00ughi0d4kSsr4ntFK+xqiPG3L8yj/9TrWGKluZKVEAH8EhjxxG+3GWUg+Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a8ec850-32de-44a1-1edf-08dc6891c5b3 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 21:17:27.7875 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0616 Subject: [FFmpeg-devel] [PATCH 48/57] avcodec/mpegpicture: Avoid MotionEstContext in ff_mpeg_framesize_alloc() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: p451O3XcCAAI Only set the ScratchpadContext and let the users that need it (i.e. encoders) set the MotionEstContext stuff themselves. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegpicture.c | 18 +++++++----------- libavcodec/mpegpicture.h | 7 +++---- libavcodec/mpegvideo.c | 10 +++------- libavcodec/mpegvideo_dec.c | 5 ++--- libavcodec/mpegvideo_enc.c | 7 +++++-- libavcodec/svq1enc.c | 6 +++--- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index cfb97a664d..fc4fec082d 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -25,7 +25,6 @@ #include "libavutil/imgutils.h" #include "avcodec.h" -#include "motion_est.h" #include "mpegpicture.h" #include "refstruct.h" @@ -137,8 +136,8 @@ void ff_mpv_workpic_from_pic(MPVWorkPicture *wpic, MPVPicture *pic) set_workpic_from_pic(wpic, pic); } -int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, - ScratchpadContext *sc, int linesize) +int ff_mpv_framesize_alloc(AVCodecContext *avctx, + ScratchpadContext *sc, int linesize) { # define EMU_EDGE_HEIGHT (4 * 70) int linesizeabs = FFABS(linesize); @@ -159,7 +158,7 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, return AVERROR(ENOMEM); av_freep(&sc->edge_emu_buffer); - av_freep(&me->scratchpad); + av_freep(&sc->b_scratchpad); // edge emu needs blocksize + filter length - 1 // (= 17x17 for halfpel / 21x21 for H.264) @@ -168,16 +167,14 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, // linesize * interlaced * MBsize // we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines if (!FF_ALLOCZ_TYPED_ARRAY(sc->edge_emu_buffer, alloc_size * EMU_EDGE_HEIGHT) || - !FF_ALLOCZ_TYPED_ARRAY(me->scratchpad, alloc_size * 4 * 16 * 2)) { + !FF_ALLOCZ_TYPED_ARRAY(sc->b_scratchpad, alloc_size * 4 * 16 * 2)) { sc->linesize = 0; av_freep(&sc->edge_emu_buffer); return AVERROR(ENOMEM); } sc->linesize = linesizeabs; - me->temp = me->scratchpad; - sc->b_scratchpad = me->scratchpad; - sc->obmc_scratchpad = me->scratchpad + 16; + sc->obmc_scratchpad = sc->b_scratchpad + 16; return 0; } @@ -238,14 +235,13 @@ static int alloc_picture_tables(BufferPoolContext *pools, MPVPicture *pic, } int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVWorkPicture *wpic, - MotionEstContext *me, ScratchpadContext *sc, + ScratchpadContext *sc, BufferPoolContext *pools, int mb_height) { MPVPicture *pic = wpic->ptr; int ret; - ret = ff_mpeg_framesize_alloc(avctx, me, sc, - pic->f->linesize[0]); + ret = ff_mpv_framesize_alloc(avctx, sc, pic->f->linesize[0]); if (ret < 0) goto fail; diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h index 5f619a29bf..185238d09c 100644 --- a/libavcodec/mpegpicture.h +++ b/libavcodec/mpegpicture.h @@ -25,7 +25,6 @@ #include #include "avcodec.h" -#include "motion_est.h" #include "threadprogress.h" #define MPV_MAX_PLANES 3 @@ -121,7 +120,7 @@ struct FFRefStructPool *ff_mpv_alloc_pic_pool(int init_progress); * and set the MPVWorkPicture's fields. */ int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVWorkPicture *pic, - MotionEstContext *me, ScratchpadContext *sc, + ScratchpadContext *sc, BufferPoolContext *pools, int mb_height); /** @@ -133,8 +132,8 @@ int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVWorkPicture *pic, int ff_mpv_pic_check_linesize(void *logctx, const struct AVFrame *f, ptrdiff_t *linesizep, ptrdiff_t *uvlinesizep); -int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, - ScratchpadContext *sc, int linesize); +int ff_mpv_framesize_alloc(AVCodecContext *avctx, + ScratchpadContext *sc, int linesize); void ff_mpv_unref_picture(MPVWorkPicture *pic); void ff_mpv_workpic_from_pic(MPVWorkPicture *wpic, MPVPicture *pic); diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 711bf6c17a..f4ad08f25b 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -438,9 +438,8 @@ static void free_duplicate_context(MpegEncContext *s) return; av_freep(&s->sc.edge_emu_buffer); - av_freep(&s->me.scratchpad); - s->me.temp = - s->sc.b_scratchpad = + av_freep(&s->sc.b_scratchpad); + s->me.temp = s->me.scratchpad = s->sc.obmc_scratchpad = NULL; s->sc.linesize = 0; @@ -465,8 +464,6 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src) { #define COPY(a) bak->a = src->a COPY(sc); - COPY(me.scratchpad); - COPY(me.temp); COPY(me.map); COPY(me.score_map); COPY(blocks); @@ -500,8 +497,7 @@ int ff_update_duplicate_context(MpegEncContext *dst, const MpegEncContext *src) // exchange uv FFSWAP(void *, dst->pblocks[4], dst->pblocks[5]); } - ret = ff_mpeg_framesize_alloc(dst->avctx, &dst->me, - &dst->sc, dst->linesize); + ret = ff_mpv_framesize_alloc(dst->avctx, &dst->sc, dst->linesize); if (ret < 0) { av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context " "scratch buffers.\n"); diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index b7f72ad460..9d2b7671e3 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -155,8 +155,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, } // linesize-dependent scratch buffer allocation - ret = ff_mpeg_framesize_alloc(s->avctx, &s->me, - &s->sc, s1->linesize); + ret = ff_mpv_framesize_alloc(s->avctx, &s->sc, s1->linesize); if (ret < 0) { av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate context " "scratch buffers.\n"); @@ -264,7 +263,7 @@ static int alloc_picture(MpegEncContext *s, MPVWorkPicture *dst, int reference) av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height || FFALIGN(s->mb_height, 2) == s->buffer_pools.alloc_mb_height); av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride); - ret = ff_mpv_alloc_pic_accessories(s->avctx, dst, &s->me, &s->sc, + ret = ff_mpv_alloc_pic_accessories(s->avctx, dst, &s->sc, &s->buffer_pools, s->mb_height); if (ret < 0) goto fail; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index a7e9a3d443..2bf4fc2cea 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1663,12 +1663,13 @@ static int select_input_picture(MpegEncContext *s) av_assert1(s->mb_width == s->buffer_pools.alloc_mb_width); av_assert1(s->mb_height == s->buffer_pools.alloc_mb_height); av_assert1(s->mb_stride == s->buffer_pools.alloc_mb_stride); - ret = ff_mpv_alloc_pic_accessories(s->avctx, &s->cur_pic, &s->me, + ret = ff_mpv_alloc_pic_accessories(s->avctx, &s->cur_pic, &s->sc, &s->buffer_pools, s->mb_height); if (ret < 0) { ff_mpv_unref_picture(&s->cur_pic); return ret; } + s->me.temp = s->me.scratchpad = s->sc.b_scratchpad; s->picture_number = s->cur_pic.ptr->display_picture_number; } @@ -3617,9 +3618,11 @@ static int encode_picture(MpegEncContext *s) s->mb_intra=0; //for the rate distortion & bit compare functions for(i=1; ithread_context[i], s); + MpegEncContext *const slice_context = s->thread_context[i]; + ret = ff_update_duplicate_context(slice_context, s); if (ret < 0) return ret; + slice_context->me.temp = slice_context->me.scratchpad = slice_context->sc.b_scratchpad; } if(ff_init_me(s)<0) diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 9c9be8c6b3..35413b8afd 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -543,15 +543,15 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) s->rd_total / (double)(avctx->width * avctx->height * avctx->frame_num)); - s->m.mb_type = NULL; - ff_mpv_common_end(&s->m); - av_freep(&s->m.me.scratchpad); av_freep(&s->m.me.map); av_freep(&s->mb_type); av_freep(&s->dummy); av_freep(&s->scratchbuf); + s->m.mb_type = NULL; + ff_mpv_common_end(&s->m); + for (i = 0; i < 3; i++) { av_freep(&s->motion_val8[i]); av_freep(&s->motion_val16[i]);