From patchwork Mon Nov 7 15:11:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martijn Otto X-Patchwork-Id: 39223 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2201843pzb; Mon, 7 Nov 2022 07:12:09 -0800 (PST) X-Google-Smtp-Source: AMsMyM5hplY+zl3g3Sfwe1ObbJBZy6X1SMk9Sb5OsblyNXZaaTuLmh3BmG60aqBjPUlx79zrS9H/ X-Received: by 2002:a05:6402:3c2:b0:464:61f5:6d86 with SMTP id t2-20020a05640203c200b0046461f56d86mr19693319edw.382.1667833928728; Mon, 07 Nov 2022 07:12:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667833928; cv=none; d=google.com; s=arc-20160816; b=ZWHOsHSr8RFkVdRu5SA2ul40GJ188z6ff3fQ+FDMpu4axOMmjuCeC6QTxeM/Wt5FiT yvvmJY6LuMGi2fVesuKbEWvRdHLrcqq/nMXoxfHrm42jGrTdBBW5v0DCHlj9sCLaXZWQ zqncJDPIhCPVpZvUnKwyptJadke4T122I7jQfqTxrxoWrOrrtPJsrDWKVP+C6MtIjBgI 8HfDGCazyEH78QEpsuwObTekBpmSsG0JuRCAj78bXEop52ANUDdQPZ4l31LFqdpK3FSI lrGAlXDwieRauWplndEvJ6ck6EKALHlfp+/ouAtlqo5vv6a1sO2XPMvswBCVp92Q3Wyc qr5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:date:to:from:message-id:dkim-signature :delivered-to; bh=ILC2CmiQJ7Tb2I8+QrYlA7Gnag96XL0g71qII40TW+0=; b=a3HzlZTxFdq/bKawEFIgo0m/W6Q8bHRIOfrEnMg+4MIiZxaMCM/5phLiZsQQf2qdZV sQqCJPMYUzAzPMwOSf4xYkEQWGbFDwkcHfyQO91uJ8NjdRX8ypkt6S73D1sF0auwdUny gRe/3fPWncgfgK+ldjbU2fx2UHa5oBKiiffakbYNyLS7Q7nZr4PchvHzxTEL9eHjXM3y 0s4uBXNB4caPBL2kfp+CKwVvnqjxXgxwANFC27zVaJHiu+nqW5pcPe7t9K4gVE18lLhB wgpWn1dhRST3jy8/xIzw8lVbjbN8/c8pe19/OoNShGH45cnG4WE/kwKQGrBxHPcvjU6q YJJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@resolume-com.20210112.gappssmtp.com header.s=20210112 header.b="D9S18H2/"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k20-20020aa7d8d4000000b00463817b0ba1si8122061eds.163.2022.11.07.07.12.07; Mon, 07 Nov 2022 07:12:08 -0800 (PST) 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=@resolume-com.20210112.gappssmtp.com header.s=20210112 header.b="D9S18H2/"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7889C68BA26; Mon, 7 Nov 2022 17:12:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C548468B4E4 for ; Mon, 7 Nov 2022 17:11:57 +0200 (EET) Received: by mail-ej1-f50.google.com with SMTP id bj12so30854731ejb.13 for ; Mon, 07 Nov 2022 07:11:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resolume-com.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:date:to:from:subject:message-id:from:to:cc :subject:date:message-id:reply-to; bh=qZpPx7dFkv9hE/R9J790NQlTRY1EWNj3eKi/QowJlAs=; b=D9S18H2/1e3Z+fDPEwqDHcdmvLGOvOWR0pybAr9fjuTSHSzCyMGGTzJue3+UV8OfOx JOkwCtnwxRrH5a15q3ZgIrFJGOoNhesTuzhzDycCMmYZnScLBsvIIZc3uMSZcNpVAAoI RKzNz441/2/V4lyCYm9g5bjZY2+31fRc8BjPgOnjF8MmSulH+6akcB5J6MroPyRmLXiF 8HY495n9W9kcVexjXaoyv2pCu8hdauh4x/PSjZdnblwzgSEgYJXYvV9c402o1CCPI1I4 oF8+jFefwA3gzn7gdZO07BnlneByRxOhFzV8HplOqiFV0u4OAEa8Td6w4c5igZCHp2GA 8uNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:date:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qZpPx7dFkv9hE/R9J790NQlTRY1EWNj3eKi/QowJlAs=; b=5A3MCRkkgxTqnZM+JptkemSLc3l4lGEIfX0tEmrzB7/lplIaSzrb7K11iw8jHeO62i aSsREiuEInU+NM6YPZqUHIh+t7zidhraEy02c4wBQS9OVxbpHTmRxGbbOh5qFg5jVSd/ 9+l4fNqakrIzJqrl9h9CyG2469uiIzbW2t6X0k77qTXai5BbsVYlkIIRwmKQ4f1IjDzJ LuAyr9yPoysOE8tXjQGJzODwB0kzBspuFg7Cc+FIGzTDTrl8Xl815E9RzQFlYCBt84k4 lNK0aIfXktEYmp6IJVlxbd/ySBufczt7FZZ5tVMiIpa4SJutQu8i7uakDph9cugesRus 1f3Q== X-Gm-Message-State: ACrzQf1f1rPoVT9aWLz5cHIDEiAA/YuxatuJl2m9BYFAhnp8vq9tHvk0 lpFe1Un/mZL/KUJv+X4lPq/8c/ljfwo4OIR2 X-Received: by 2002:a17:907:6d8a:b0:7ad:d3a1:cbf6 with SMTP id sb10-20020a1709076d8a00b007add3a1cbf6mr37781744ejc.533.1667833917146; Mon, 07 Nov 2022 07:11:57 -0800 (PST) Received: from xps15.fritz.box ([2a10:3781:2681:1:30e6:8cde:8068:60b2]) by smtp.gmail.com with ESMTPSA id q15-20020a17090676cf00b007ad94422cf6sm3478913ejn.198.2022.11.07.07.11.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 07:11:56 -0800 (PST) Message-ID: <2301e206486a2a0c513542ba2358d3cd3fdc1574.camel@resolume.com> From: Martijn Otto To: ffmpeg-devel@ffmpeg.org Date: Mon, 07 Nov 2022 16:11:55 +0100 User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Subject: [FFmpeg-devel] Patch: avformat_index_get_entry and avformat_index_get_entry_from_timestamp const correctness 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: nnD2L0nzvcAs With this patch it's now possible to call avformat_index_get_entry and avformat_index_get_entry_from_timestamp with a const-qualified AVStream. From cbf7880c230ccff35b8b6d1fab192a07c6083307 Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Mon, 7 Nov 2022 16:06:30 +0100 Subject: [PATCH] avformat_index_get_entry and *_from_timestamp const correctness These functions don't need a mutable pointer to the stream, as they don't modify anything, and only return const-qualified pointers themselves. Signed-off-by: Martijn Otto --- libavformat/avformat.h | 4 ++-- libavformat/internal.h | 2 +- libavformat/seek.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 1d97d56ac5..aa216ca11e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2676,7 +2676,7 @@ int avformat_index_get_entries_count(const AVStream *st); * until any function that takes the stream or the parent AVFormatContext * as input argument is called. */ -const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx); +const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx); /** * Get the AVIndexEntry corresponding to the given timestamp. @@ -2693,7 +2693,7 @@ const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx); * until any function that takes the stream or the parent AVFormatContext * as input argument is called. */ -const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st, +const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st, int64_t wanted_timestamp, int flags); /** diff --git a/libavformat/internal.h b/libavformat/internal.h index ce837fefc7..5931b1cf14 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -417,7 +417,7 @@ static av_always_inline FFStream *ffstream(AVStream *st) static av_always_inline const FFStream *cffstream(const AVStream *st) { - return (FFStream*)st; + return (const FFStream*)st; } #ifdef __GNUC__ diff --git a/libavformat/seek.c b/libavformat/seek.c index a236e285c0..2db7ba0bd3 100644 --- a/libavformat/seek.c +++ b/libavformat/seek.c @@ -249,20 +249,20 @@ int avformat_index_get_entries_count(const AVStream *st) return cffstream(st)->nb_index_entries; } -const AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx) +const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx) { - const FFStream *const sti = ffstream(st); + const FFStream *const sti = cffstream(st); if (idx < 0 || idx >= sti->nb_index_entries) return NULL; return &sti->index_entries[idx]; } -const AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st, +const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st, int64_t wanted_timestamp, int flags) { - const FFStream *const sti = ffstream(st); + const FFStream *const sti = cffstream(st); int idx = ff_index_search_timestamp(sti->index_entries, sti->nb_index_entries, wanted_timestamp, flags); -- 2.34.1