From patchwork Sat May 11 20:51:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48781 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1706:b0:1af:cdee:28c5 with SMTP id nv6csp299985pzb; Sat, 11 May 2024 14:00:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGWytCDrN7LI9RXnVhmQzBytPQmhoON+/Kh0IQ9M/RgN9s5J/+5j2EDQdHYCnUtYjn4FWRMJbpXUDMQOw9k6+C29s15eIlMG89yQ== X-Google-Smtp-Source: AGHT+IEeC96GcflHPhRPbpPeFNV6rJLN4ibEQl4Rb3jH6iZg/f5d64mxmIL2jxYpariLeWK8+cug X-Received: by 2002:a17:906:31d7:b0:a59:c7d9:9d39 with SMTP id a640c23a62f3a-a5a2d54c0b5mr411449666b.10.1715461231988; Sat, 11 May 2024 14:00:31 -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 a640c23a62f3a-a5a1797cac5si322198766b.244.2024.05.11.14.00.31; Sat, 11 May 2024 14:00:31 -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=XLqzxJrX; 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 1EE2B68D813; Sat, 11 May 2024 23:55:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2069.outbound.protection.outlook.com [40.92.90.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7473268D80F for ; Sat, 11 May 2024 23:55:40 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UIQ8P/h9toHIQmUUgPjYyyCu0HOUFLE6VHpWzxDI68mNKPrkgtbE06fzdr5Yyk49c8oKKk0aEDOLE1i0+6+Eg3R0sKJye5gQutrDYBPM5DHtbGOJ11dgW8GMnVF05wJPot7ryu91Q4XUKFFVEb0K7lCBU56AFGHvxHJYqFjW0hEiIwe03WO76EQPs1B12TX7vVmxsSUytVgfGgiuxaLe2TDHCyR1J061eoIpx9yW+ILOxK4q9RBvymbLFH+srGVu5szGQ6J1Ocnqm+vHapKW6L91dv4FvShjjnT8C0R6nh4Kl/ACXG8uzruLuGRo/cA6gk/b8agba6QjzxSZ94iUPg== 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=CyBRe1lLXxNwgC6EpQT71HRSQqqIs8RCmM5tZT1Ir2I=; b=IM1JpRJQUeZz9oznLS95SDuJBBrhU5SFAkFBo1QjH1mLg5g0Swq8ACUifdbbr8Kelvzuk58f0kG6wfA9IcfaxMQKLcBKaytYQMRvoLaqwPO+v0S2joQzoL50pIDyaMoSzDs94fT39tT7U9xGJi/HuaUeYlBQHfDU9l60EyaSCOFtTJeJtRjbu7a8KkzWyR6v8WxwNJp+g30GmK/ppaxgX+pSVvWP5lF3VmXVlQtx0/b8ylN9HMDuWFf2iwEQxgAu2cLdlLFpnrAVaI44UyBFJB4FPD/9dCfQy7CU7lOOvCluVnVoXDrHAFIg3fjF92kl4nnsFc5yCzPiOtl7n+ejcA== 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=CyBRe1lLXxNwgC6EpQT71HRSQqqIs8RCmM5tZT1Ir2I=; b=XLqzxJrXgwIY/wMuK1qvsfjOtuStQ+2h5p3H09eKbmMZRK83BZWehod5p0scDTwkkBX7AFLT6l9USt79ZRtpsk6bBxgRfqEYTkMF5402x7OsIpDmgEbVUvJWpun2JZpxFzxwljrN6yug1zWP06hexM+rpjxy3pC9Wjevj0TCE4KvDe+MawkjeDZPR78fPAZ5f3xDj+3hFWj/tWYd2kH1VXhnRNX/G0/9JT4tVf2niPTojZTYrvcQXHipp0FeFUKRlFhDdrjUTUBmOstXVbsPhyKyaK6T9zATtw7cVPZYULw48Cv3K/E9TLwEoALBnVZV1tkGd5EtoR2QK1W/ontYZg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0070.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:37d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Sat, 11 May 2024 20:55:39 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::d6a1:e3af:a5f1:b614]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::d6a1:e3af:a5f1:b614%7]) with mapi id 15.20.7544.052; Sat, 11 May 2024 20:55:38 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 11 May 2024 22:51:24 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [c/tmF2MV2oGLeIrveNS84gsUgX/9pss2GTNATC2gCwk=] X-ClientProxiedBy: ZR0P278CA0172.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:45::6) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240511205135.2411886-59-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0070:EE_ X-MS-Office365-Filtering-Correlation-Id: 219f414a-f416-4d4c-2ef4-08dc71fcb676 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3412199016|440099019|1710799017; X-Microsoft-Antispam-Message-Info: UilKI4t+8K6X7+F2ICUer0nU0ubgmO1ReuxWHLFgs1Pbbgx9oaBHVuavVtgul/TZy4WIFCH5ZVd4ZsLQiuJb6E6NHjAR88mnIdDeSG0GZRG5IFHJ9NyCZ8xiLGILdw09fviqyObAJU5C5T0+lUeRizxID7bX6FHTOWHdEz07rqwxMoXrGNUrEK8LN/YHsVGYnFiI8tivdq06poX2M4eM+FDEEW6HxH15544ZLHpjWm/zPws2zQ32FVT8bhefzWvJlW4E8Ndu0JKT8w4vhO8JGkeVvLK8Ko5nFj0BR1W02B1RX9ieYkpy/E5WodJVggIHJQmFnzHJU6tQ6W8MeV9I6xqhjuEZjzotSQDTgsGVoJN+ZANmS8pm7JB/tYZmPoT7nyv3tdu93CP6D8+ITaA0qCRJuJtiHqz55TRH2cznp2DfU/0CxTpYgA1JTYjavFR1RvOxT98pKBEA6cGs1m71zh760gpXN3kBARZNh6jYP9cNCSpjRGXNuXoq5Ca3Se6LTUjN6jyCP8PeaOycI3scARLwHYVNWVuL4B4b3323imwrPXZQeHnATSGwe6UEXkYJF33q4lYZiccKyf4Y/0Vdh8OZ4nzbneby/624YRTmOuw= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: siAitXjdAEEHYBjsIrT2AXNI+NCnfvt5SW6anR7eCZqEx7JE1S69dInTYY/9S5tzQZqIwnTrSYxx4CT7M83O26TEZtq3ZMrBzV2srI/riikNIK9q6oDt+gQUtY6GxWS04kGauV02fWAUqxECIbTj1/nGiTN6NwvtOxabbc5TfYV9/3lZzIHfGFwFwECSsg8qW4ALNEiIc6Suo52C2NcoqXGAa93adFay0bJFIkMPRC/msXHRfYwA3gRfgnw+dkSStz782z/LDLkP1RlLQo/LIC7RH19WDtH8NccA+FsEe+FZIHU4KJ5Z9fqyu3MKHWLGRRMLZa/JPcnr5+15AU2Sag3sP/YNbPhpFokx2bna5t3P9JGikBtsrlOsvYI1BkWDqFp1hipsAJuY2iX0288oqnGa2KjSGaUYPTklciVilkW7o3M/4/zILrrY6L+h3xpFu/lBnaSBVkXHDTkfilaURsMR0M7IY+9VdpZACIDyXMH16Y1K5oY2T4fzklS8IVn77JVWRWZqa3eFdeL8p8Hx7U7G/EV3MYNUUFX+BhQBWXr5sQxbmNT07OEzp7prN2/m+bUPye2shnAnI+9UYjXUeoX/m15i/w/+WWqHCJHdNnPSpCAofNFDo0Td3oeXS7/eimHgXo9YEI80H9L4diTWhMajTOqEIDzlNFePQSnkmAPiWNArCP9gm2HmJJH1YHvzFP+R6sO5ptvOpLgD2v0c+m3OrMdA2DZtU2DNYZPsIAG5r/MojtPoOf1KFUCqd6d0/srPAnE7GtMAo2pKtRxBt7Vcowuhlk4eCltn7873koNoqgmTPHHrK7dCObsLAgIMAQPWmKQxnSQnEge60s/MnAewOI9brNPEiJClcjaDQBqr+mOnG2ocoPoUbympF0UdtDdLV1J84iOuk82htkAvqBGRqW6XJXsz+nBdTyTFff0UaQAYgoHbYw8uz+PWH1VSZw4MuDeo7/ZMYzWKwLHO4otjTw2/lj0lXpyMQe1nEZkjlkAEAcKYywAJBqXH+nbsKCtsphrnHqFwZfx8WQOEhe2eUy/AkOnEl5aVC87KASv6B+5XnP2Cx94+kR0Gn7Lpn62w972u3L7w9Wd5mn8TooxRV1rX4fBdpL8gcErGC+4EbNGpO/PL/TUEA4GTdULkPIyqWlxCNabDWXKtj11dHkLYAfLCZp9CyA6KpkNPAoatWO9+yUBGHSkRvNqD3uqdQcoSr7cGN92INq3bDeS4yMTxmCW0aJhtktnnu5beng53CvXrKKaYm+PDrWgHbzRLBAhuujzQJv+yTLT9AU0X4Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 219f414a-f416-4d4c-2ef4-08dc71fcb676 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2024 20:55:38.8835 (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: AS8P250MB0070 Subject: [FFmpeg-devel] [PATCH v2 60/71] 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: R+fG8s691V/B Only set the ScratchpadContext and let the users that need it (i.e. encoders) set the MotionEstContext stuff themselves. Also add an explicit pointer to ScratchpadContext to point to the allocated buffer so that none of the other scratchpad pointers is singled out as being used for the allocations. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegpicture.c | 18 +++++++----------- libavcodec/mpegpicture.h | 8 ++++---- libavcodec/mpegvideo.c | 10 +++------- libavcodec/mpegvideo_dec.c | 5 ++--- libavcodec/mpegvideo_enc.c | 7 +++++-- libavcodec/svq1enc.c | 6 +++--- 6 files changed, 24 insertions(+), 30 deletions(-) diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index 43d35934c8..cde060aa1f 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" @@ -136,8 +135,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); @@ -158,7 +157,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->scratchpad_buf); // edge emu needs blocksize + filter length - 1 // (= 17x17 for halfpel / 21x21 for H.264) @@ -167,16 +166,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->scratchpad_buf, 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->scratchpad_buf + 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 ddb3ac5a2b..86504fe8ca 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 @@ -35,6 +34,7 @@ typedef struct ScratchpadContext { uint8_t *edge_emu_buffer; ///< temporary buffer for if MVs point to out-of-frame data uint8_t *obmc_scratchpad; union { + uint8_t *scratchpad_buf; ///< the other *_scratchpad point into this buffer uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision }; @@ -121,7 +121,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 +133,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 36947c6e31..89d19a743a 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.scratchpad_buf); + 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 85ed52d9ad..aac1fad535 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.scratchpad_buf; s->picture_number = s->cur_pic.ptr->display_picture_number; } @@ -3616,9 +3617,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 = s->thread_context[i]; + ret = ff_update_duplicate_context(slice, s); if (ret < 0) return ret; + slice->me.temp = slice->me.scratchpad = slice->sc.scratchpad_buf; } /* Estimate motion for every MB */ 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]);