From patchwork Sat Oct 7 00:40:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 44193 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4e24:b0:15d:8365:d4b8 with SMTP id gk36csp161231pzb; Fri, 6 Oct 2023 17:40:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbPodmtkTlijT+JEyIHG8+oGvv8frbLxUg7WK66bMmY24fcBvtYMHSu0eDzAe+U9rqHYKx X-Received: by 2002:a17:907:868f:b0:9ad:e62c:4517 with SMTP id qa15-20020a170907868f00b009ade62c4517mr5619850ejc.34.1696639200022; Fri, 06 Oct 2023 17:40:00 -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 e10-20020a170906248a00b00991f1e4b044si2075445ejb.336.2023.10.06.17.39.59; Fri, 06 Oct 2023 17:40:00 -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=KFJi4oMF; 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 0F44B68CBD9; Sat, 7 Oct 2023 03:39:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2106.outbound.protection.outlook.com [40.92.89.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A66A768CBC0 for ; Sat, 7 Oct 2023 03:39:40 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aLzHFEuFA/LxkHppsEMm5UJ4b1k3sknz/etsIOgMk/mN3pCEQIGb1cUh2H5imphEM9Ir/IG76mZqy588La1L23YT3pCDzqQWxITEZ8xEiKDbR1bKnGrgh+zkp28080icWqiYrKthoLBb5Yd7IqrftoJtDmwKfpFyaHd6c8Rak6FRO4x0VjwDn2Oc2ZxnuNJvWbY2vzrlcKz1uFDwIy47SOUOOtiElsQiBsPOaiDxUaijSung4jnNbMy+/AxBOSFZ20dbtbn1isXBdiWq/cVALQzElhqyzlEhuW6dYU07Jyjl+Hwg4VT2jLh9J6JIaHRpkE4/SuWs9EY14UxvjBJJrw== 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=QH6YRw9MfsETYbO/icpEvtcAQYuwxmO0LteqPM3/9KI=; b=bdudSJQPkGDHvyjwOb1rs6ztYCwf42OcwkuMM2bt5UM+1itGaXpRMbLUgQihUSxjBqJNvDhMtadtd9RfBYTLVGcyjomT9l+8mbMXBOnUu2FCt3U0SJaJqCdSQ6joxSet6IDrueXDLagGXbCCu9fXyarRzcC9Ve1hQawByL3zqF/oWy8wm+jTs4ADWUShhVu00sQUQUm7eWvpDuOlYkWCJW131bQF88AmdFjMTr7NtiyzBGBiO2/tZ8UcHWjSxw4IaCqWPkIEBM+d59k1SYREkepLj/Pnud3SSoc0MqCI2ouYZb0XKRFmCnC+qUaOW3dFB/D339ZoOepJDIUVBDJhxQ== 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=QH6YRw9MfsETYbO/icpEvtcAQYuwxmO0LteqPM3/9KI=; b=KFJi4oMFl9uMevk7QSJgMaQEWYlZu9qPN02UHRyHVk+LRN0G1tStkYSfSKrFR6vPlJtTuf/2dE20bbj6TdkYkuzWt14eAGqMH+nQWicAe1cuhvoyy2xAoZDsyy963/9JNDMQmICPsx/OB/TeYorWbmABi/x4X+ogXPQywSiCZ281+QrJ079NxpSEj7r0NRxsmb3iz5MPBCCqYEMQBlrGrdW/tx7ojs5FvXasCJQQlphplwtPEejrcZn9nUUKOEPwbKUWapfoQMPTjHiRDAQf5lOuAdoKnFXwugUGmGuYJp7BcW0CHqE+rV3S349S3icPgMgfRYogCyt4309FUi2PtA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0050.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:14d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.37; Sat, 7 Oct 2023 00:39:30 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa%3]) with mapi id 15.20.6792.026; Sat, 7 Oct 2023 00:39:30 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 7 Oct 2023 02:40:29 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [WpMG1ic+VbmXDyW18nDADx3P55vlRU6d] X-ClientProxiedBy: ZR0P278CA0154.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::9) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20231007004031.2024778-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0050:EE_ X-MS-Office365-Filtering-Correlation-Id: 74091c88-31b2-48aa-3cec-08dbc6cdde19 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3teeEW8HsXV62+en0LCCnHJg2Hg5Kg8ErCO99IpEIcvN+s1sZmExh34l2jkVvdUpUyHfD1xWbZA1MJWszj4m+YjSmUYV5u2LtWXFynN/0aFco7A0trnji2WsOGnf8TpWoF2Mivmv6irdZDWvZ77U3UIbh8boogTrUq/N0HkEBmySCw+ww1SMBwGi2e1EnkE2QYMQf93ULeL+TEx7f2UphdiTAJBSy+FlwvKujOXTzFpoTQQRXPRPAALLP1a8Z6Bk8hh2824SvF3BF4eolKN/rJ/0Bxkxe8XKx/5a2+dEWxHVoHnAES0OL127mXnzYqG4Ne+rqveGDJjWlWWtpn8Epo6EW+wckCcHauutqzXf6SAjfvII8HA7lLgsl4ZrGnK7ItCm8cXBpKV9ISyjPxGsnnA2ftlUjfl/XCXYsnTyFf0tYnlOCE1ezHtbo0suAgGj9hevlHzwX0jAYFv+OpR7K3rJ++bbyRU+8QeqCcWHs/CU948VuH7DfYBuP1XPKykvp2bRWcuv3Z2czeTZegyQ9KdfaFe44eOa7Gz2gSEsr6qzRtbrNZRfrDLE20A1s6NjKU5T0i0+AY133bJH4AL/Ml1WuyuYAec3XEphwOrrRbNV3PLF8NdEXxWpi9O/QJ6L X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dndLdQPr/ZFQDK088FmN3qbSoG8ZupxWzqN62OgxB5kcQrUyC29nULDisXgHjjkswrIQitB3LPzb6rvKvTMhQntrgxmYF3ca6vU9Zb91jAz0l+MI6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d9BPdV2VJH1QxErw7JsSVPA1X89SCt05Q0a0kRlHAZiBnH3mEy8V2JizQqQWKBrCzJlKx3HoHMX0VheY5IwDz6w6w46WtA X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74091c88-31b2-48aa-3cec-08dbc6cdde19 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2023 00:39:30.2502 (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: PR3P250MB0050 Subject: [FFmpeg-devel] [PATCH 5/7] fftools/ffmpeg_demux: Don't use fake object with av_opt_eval 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: kb0hkOARmJ32 The av_opt_eval family of functions emits errors messages on error and can therefore not be used with fake objects when the AVClass has a custom item_name callback. The AVClass for AVCodecContext has such a custom callback (it searches whether an AVCodec is set to use its name). In practice it means that whatever is directly after the "cc" pointer to the AVClass for AVCodec in the stack frame of ist_add() will be treated as a pointer to an AVCodec with unpredictable consequences. Fix this by using an actual AVCodecContext instead of a fake object. Signed-off-by: Andreas Rheinhardt --- fftools/ffmpeg_demux.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index c71edf01a5..41fcb678c6 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1042,9 +1042,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) char *codec_tag = NULL; char *next; char *discard_str = NULL; - const AVClass *cc = avcodec_get_class(); - const AVOption *discard_opt = av_opt_find(&cc, "skip_frame", NULL, - 0, AV_OPT_SEARCH_FAKE_OBJ); int ret; ds = demux_stream_alloc(d, st); @@ -1176,18 +1173,20 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) (o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA)) ist->user_set_discard = AVDISCARD_ALL; + ist->dec_ctx = avcodec_alloc_context3(ist->dec); + if (!ist->dec_ctx) + return AVERROR(ENOMEM); + if (discard_str) { - ret = av_opt_eval_int(&cc, discard_opt, discard_str, &ist->user_set_discard); + const AVOption *discard_opt = av_opt_find(ist->dec_ctx, "skip_frame", + NULL, 0, 0); + ret = av_opt_eval_int(ist->dec_ctx, discard_opt, discard_str, &ist->user_set_discard); if (ret < 0) { av_log(ist, AV_LOG_ERROR, "Error parsing discard %s.\n", discard_str); return ret; } } - ist->dec_ctx = avcodec_alloc_context3(ist->dec); - if (!ist->dec_ctx) - return AVERROR(ENOMEM); - ret = avcodec_parameters_to_context(ist->dec_ctx, par); if (ret < 0) { av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n");