From patchwork Thu Feb 16 09:21:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martijn Otto X-Patchwork-Id: 40418 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp352102pzk; Thu, 16 Feb 2023 01:21:26 -0800 (PST) X-Google-Smtp-Source: AK7set/sIMOPc5Mtfibi1jGuwSMIeia4cYmlxffih6j62EQPjjqUEZdhluIx6oI+nahlmU6ykoHb X-Received: by 2002:aa7:db49:0:b0:4ac:bd73:3b0e with SMTP id n9-20020aa7db49000000b004acbd733b0emr5250015edt.32.1676539285581; Thu, 16 Feb 2023 01:21:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676539285; cv=none; d=google.com; s=arc-20160816; b=Lj5H0z9gVq07WlpNPIwyPl0RxrALmtz+izG1yBmx4Prh/PwjZV/7Kp6FT/ldctSsQm S8iRFsqpF6pF3ZcF5k+Tzs1MFyjSH7IQ1p7UAcQzQUhVktjo6cSk8ED7MMbj4bmO4hnS uM2mGVXvn5KkVw5eO6bsWfkjjFnRvob2YezK2GYRLdAEi1UKvlWz8yXeHZZX3xjNfdY2 RLASbgiYWeEvbqIBxYeXzmOmIKdgqj3gaSxqvdjgdHqEp3neKDpGqzwqFjRptA80oQkA QIj7o4TEYJxH/R/MmAqmtIxUR8H94pex+NxvkWO/PtyQqpW2AJMm6Rsuwu7OODINK7ED xzrw== 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=WrO8/6qJzgjrMXAPBaGxG5NXx8vOAJPNANg/PN0cz58=; b=MKIyQDBNfiLzNgjn+o+IdjrirCUQab6goHUTrYxDuBBvT2E0wuS7u/CG8Jn9ht89BE BOx42OHz5GbhoaWCofZYxr0q01jMhYiYBSQHpOHpVDs75j4EeG0u1kQt4jJI5sSdlP9h FdRIHwmsyndmYIvui2xkX0xjobmb5FTo05Tnm5pR1I7FEuhjaghGKVOjRefXMAple7bt 5wJ/29gjUgF6Zqdh9wlQC6SPjK+OSVKORepiB+ZRazFuZ/FIvXOIfQxxx04k7RLfd95f PtCH7YZT1WjGeQ2rfv5CybL+QAOJxagOFTOEqNdga5KKh5AGbF81MKEzQeODwu6ZNunD pY5w== 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=yQtMZMl8; 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 w20-20020aa7da54000000b004acc9d378b2si1641444eds.390.2023.02.16.01.21.24; Thu, 16 Feb 2023 01:21:25 -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=yQtMZMl8; 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 D6A8168BEBE; Thu, 16 Feb 2023 11:21:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 661CD68B807 for ; Thu, 16 Feb 2023 11:21:14 +0200 (EET) Received: by mail-ej1-f49.google.com with SMTP id jg8so3600709ejc.6 for ; Thu, 16 Feb 2023 01:21:14 -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=99aZXzOITtKzrQRvAxXMzhgokorJvG8H042vjmOhKW4=; b=yQtMZMl8P64W+i0DBnMydmZdo0QL3ckQMcxtEYc3Srj3lDHIpjec23LEU/1tkQDnzt kzgvew2JIsH3oQIQr88Env6jl2pq4PNBUua5yMSEflTLa4UmtJnZV+LH5qnseq+yywXB JgH2EKUwiXJgodfEmpbfjJLy+uQtzPs2jQnnp57oTtRHtlVJ+KbmMGJyFEk+8VknOXea Is6vI/8VAdp8KlfnvTcb7eLiRQFgeDmLCe30WwntDL/OR7h692AtI7gJsMLSsaFm0QqY OFOkXILCkG7VpAORKceVMzYB2HsaCkSMCYNmCBEZqpnjo0oy+rL5Hh/55yZOcB2L3/Ls orMg== 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=99aZXzOITtKzrQRvAxXMzhgokorJvG8H042vjmOhKW4=; b=fEV9O9GGd/P43nD/1uytp36At/I+ClH4GulVP+cN2a6o59dLWpSDsZ8dPV4xMky/qE H20C9nnt85wQoBbI+nHeQhYfV1jO6YanUY0rv7QOfHXg5c3PuoiUoMARWKg9QbDKcIuk juAUlHL3p5vNNv2Tz1TKvFQ6n7JebrORrg5LCfaKGFsbSGX8hdghFuhb5fInyfZ6zX5Z mQESahDAIoYY5hcwiC1QIwCh+YubDG2/0Ly7G+H+wlazClTgzdzjeQKbOM7TcdajByiw T2lOujMihnszONpUZBqVfSrSiHbx2MGcN4P3GBv+0J18tvfFYT50r+O+7XI/PSRLPePl HBNw== X-Gm-Message-State: AO0yUKUcVLQzTxWtjHxzrbcp+fxeVYuHF5GO4Q9OwLP8fMb4L+l1Njfw PNvkXL4Di7uakf8W9O7QmM/6uRc8ZQLnj6H0CCY= X-Received: by 2002:a17:906:f9c5:b0:8ae:11ca:81de with SMTP id lj5-20020a170906f9c500b008ae11ca81demr4401108ejb.34.1676539273599; Thu, 16 Feb 2023 01:21:13 -0800 (PST) Received: from xps15.fritz.box ([2a10:3781:2681:1:95ef:f691:80df:51f0]) by smtp.gmail.com with ESMTPSA id fy5-20020a170906b7c500b008b112db78f9sm553973ejb.51.2023.02.16.01.21.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 01:21:13 -0800 (PST) Message-ID: <14a0e524de1278bd32e479500ceb770119b7ba36.camel@resolume.com> From: Martijn Otto To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Feb 2023 10:21:12 +0100 User-Agent: Evolution 3.38.3-1+deb11u1 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: JPwqJ6gUQpSM 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