From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id D1B234F1A3 for ; Sun, 15 Jun 2025 16:59:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 85F7368D868; Sun, 15 Jun 2025 19:57:11 +0300 (EEST) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 1AC0068D86A for ; Sun, 15 Jun 2025 19:57:09 +0300 (EEST) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-23636167b30so32736165ad.1 for ; Sun, 15 Jun 2025 09:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750006628; x=1750611428; darn=ffmpeg.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=gxNFZRM5M9DEy0HXQirDhrEPjbPcH6z1b266crth4jw=; b=OfUT0iTS83QfMDXNdFPVihrtq87af2mKul/O+Ov5Mgk5getDuQ2XVZssOy/qL//ATi gk0OoM/gHDolGcbnFrTd0fUZKLykCvnhaVWRlL/bVlLpiozNk9z9SUfJLVJknE+wBT44 0989TyeB6E28oueEG8oUFhECNAtkRIcIuz95pGjJZTQN81DOhKxKJSaW/4mZjdV/WCFP GoVoBylDzmV3/BTl+WLazlwrZf7GhS6ipaLl7Tljb5DT12eArURYOQh0flRXwtgbfrBk G775G1C5CREqYLhnAEDgqoiG6hl0s3h1XrGEkDoreb3qgouo9dndqpQlXXcO7pLj8Pyb nI4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750006628; x=1750611428; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=gxNFZRM5M9DEy0HXQirDhrEPjbPcH6z1b266crth4jw=; b=UBVzm9g+7yoNxgKLI2Z0XRUkU1MKG2SmWkcBswmVU7CE/TRA97BsC63OIx3EHBi4ko Uvw9OpKL35NOaQwzhuiZC861+wDIVKRlJMU9rVzK89htP0F670qyjGLG70cNziPkVIap PESvLQBgVi1QJVXP8FkMlpYhJGGu3ANxceZoGo5XvjK76DqW8m5gia0EhNFXZoHFb1/Q rxi9dVYKgVmsf2yEgTY4eSEGpqB7tA111xEKVYEGql8pE0w+i0OEYeg6zHuKwnlEqhrq yVLL/FdqFYgoV8s2v9XK8xClCAX5vNB8Va4NmbiERHEaytxltyxoH0NZdTksYGJ4ZsK2 HKzA== X-Gm-Message-State: AOJu0Yw4GkdoxgOpuYt+BONfv6iNTYRyHSCwHhOxaMH8DlQwT8T2wH6y z4iVGO/byh0s9Tz54Ud3j3JCsBUopAbZil/49ktW3O7cwPl6gUt/gtskcohXng== X-Gm-Gg: ASbGncsqWA7WzKgJcXMoBB+g5fqYL5ZNqD2E2vq1Gc2FPU717DOgHhXOpTlbYN5WMWP S4ILxxcjhsPK3y7OSTHs6Ku5dXl6poyKf1vu299wa0lTCWJgHQNvut8CPPttR6ye8ra+e8GRnQa v+vpgXrOLnmdtE+FMEKZQb99aqzZYZHzMb1dbRtDdWUL+9VspPKzuVYih5ZRgZ1kjbpnx5c4+Ex r+gHbXBbz6TrxhAjDCt0IjGKxJ730s4mXxcLk/ys5tK/2ygMkIEi9j0QvTO3eQKAHl6v9Kd60kc MphUZdTJv61X3L1jeNdou/HFExfVkyj85+zYYMTiNNCtUUru8/7IZKS8lGSJJ6u7lOUH5xiAEUZ nY/ig4wVRJO1Q5r+e X-Google-Smtp-Source: AGHT+IFCzcUdIsSkxznFdOPgjcqjjx1SRnXgxQ2RrB6sBPdINJPcEPtxh0Ph8YX5CF3cnY98qDmiXg== X-Received: by 2002:a17:902:e315:b0:235:f143:9b16 with SMTP id d9443c01a7336-2366b3e388fmr77309335ad.41.1750006628130; Sun, 15 Jun 2025 09:57:08 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2365e0d0ab2sm46323935ad.246.2025.06.15.09.57.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Jun 2025 09:57:07 -0700 (PDT) From: Andreas Rheinhardt X-Google-Original-From: Andreas Rheinhardt Message-Id: <7b5acf6504a3139358d6c5fc62eb7910b0878c4f.1750006479.git.ffmpegagent@gmail.com> In-Reply-To: References: Date: Sun, 15 Jun 2025 16:54:16 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 25/47] avcodec/mpegvideo: Defer init of enc slice ctxs in ff_mpv_common_init() 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Andreas Rheinhardt This will allow to perform initializations between ff_mpv_common_init() and ff_mpv_init_duplicate_contexts() that will be automatically copied to the slice contexts. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.c | 8 +++++--- libavcodec/mpegvideo_enc.c | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index e329771b38..f6e997193d 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -431,9 +431,11 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) s->slice_context_count = nb_slices; // if (s->width && s->height) { - ret = ff_mpv_init_duplicate_contexts(s); - if (ret < 0) - goto fail; + if (!s->encoding) { + ret = ff_mpv_init_duplicate_contexts(s); + if (ret < 0) + goto fail; + } // } return 0; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index af1e77cfec..1fae5fbeb0 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1023,9 +1023,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) m->lmin = m->lmax; } - /* ff_mpv_common_init() will copy (memdup) the contents of the main slice - * to the slice contexts, so we initialize various fields of it - * before calling ff_mpv_common_init(). */ + /* ff_mpv_init_duplicate_contexts() will copy (memdup) the contents of the + * main slice to the slice contexts, so we initialize various fields of it + * before calling ff_mpv_init_duplicate_contexts(). */ s->parent = m; ff_mpv_idct_init(&s->c); init_unquantize(s, avctx); @@ -1057,6 +1057,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->c.slice_ctx_size = sizeof(*s); ret = ff_mpv_common_init(&s->c); + if (ret < 0) + return ret; + ret = ff_mpv_init_duplicate_contexts(&s->c); if (ret < 0) return ret; -- ffmpeg-codebot _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".