From patchwork Tue Feb 27 14:50:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 46571 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51b:b0:19e:cdac:8cce with SMTP id gm27csp2043653pzb; Tue, 27 Feb 2024 06:56:15 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUCDOfA0L5ePbRGvexQ+OfNQWRWkFQO98yKLfq41Pb4Ljz9rRyWjLfn21HukmuD6LVyZdTOZnoShfV6X9xTx1QSWo4FtOFi/Uhx/Q== X-Google-Smtp-Source: AGHT+IHkfMOBy9maU9BMC+meq3/kscKv4q0kVZ0h5HFR3DaFEb9WsmPbOHWQiZoWeOzS7k6ucmo8 X-Received: by 2002:a17:906:2b88:b0:a3f:2e6f:800e with SMTP id m8-20020a1709062b8800b00a3f2e6f800emr6670764ejg.24.1709045775602; Tue, 27 Feb 2024 06:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709045775; cv=none; d=google.com; s=arc-20160816; b=tvqEol/Em7cv3gGew48xZhBZyP4aNKIxW6WiPRIU1a99N8cn1aVkX0AmgcKLJ5sMQr PlgQQZEgXLEyX1PZQC0vne1MwR0cJDcN7S772e5AtZqV286vy82mTUIb7ECMYibIIo1d tAOGTkhtJxsGAG6HTRDpx7DOEBOPcpnRvZ9u6j/VpDlRxEhnPEbF9eovcCj5/39OeP0I /Dz9WmCKcZUdHTg1sas6rQN5Gl1He/s8ZgcHU4cVqvEhAIyLifxwsFwjp6b8gvpHT6wa UjDA5r+QDfLS59EsMskHxPNdCg5AgiC8Oh9cWol+Q2Q62ZP6E6Y0k3D2V5T1nmZq12f5 pIsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=DgbpW5QLheupjw17wDUFJn3fDUhyOtZzabKBZ3c3YKI=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=Ktuks2bhpK3S/zFyax+OrEZ+jHQMnB7RTfcpdJG+dgwfd7Tio6TscXeTAdiavGgF9h X5XHIqgamiXKQFjc4l5UOmgK/2LGh4mvFH8QZyEvlP4oixRZjqUO9YGuOw7p+HTSHCuP hNCYqB1pwbtlRmp3eaQ3g0Im+OIk2HHTj7vmjyrz3xVMT3SUvchUAz69fj25USDGQ8qm 9RvyzDVD1EthAOBscz/WpfgBKRHNsPhb6IL6zW7UXeRoufL8tXp+Fv1yCH1Ey22+5mon 75AQf30yA7Vu0WVHaXVH3AbG1Bl9EB7JY31KkarKRO1edTDcVRqwzMKYxcFCSSb5IRui bDMQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=lVJruL45; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id oq2-20020a170906cc8200b00a438d35b117si757266ejb.521.2024.02.27.06.56.15; Tue, 27 Feb 2024 06:56:15 -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=@gmail.com header.s=20230601 header.b=lVJruL45; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 33BEF68CC1D; Tue, 27 Feb 2024 16:56:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E075E68CBD7 for ; Tue, 27 Feb 2024 16:55:58 +0200 (EET) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5101cd91017so6418327e87.2 for ; Tue, 27 Feb 2024 06:55:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709045758; x=1709650558; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RwW1CJQtfQILe+wiKC0hERGdn0Ju6cDDGRNPYfPybJo=; b=lVJruL453zS71iq+GdOZgpEXbVO6qKcI8pYRhqvtShf4ehpzl3ZfWmSC+9mm2SxncE ozGjOUiwpzyO1lMstWgWwCHWCQUtEOgct99bQhqakURe/x1YJ0sz7A9b7qkcrF8SRdNi JbpvWU4Tti6S+fO+8pzS8YLTY2QbOrd4C2QBEG4WVxku0FeFVLYWZVXJWv+e3162JO1O BBOXKc77wS5yVqSrj3VYXVoBhxbGuuRDpXNpkHhVM5DMS/I/IREvajY5PIJL4PvMQ0+O 3KaP0j5pdIeIcMniDk5csgMDlzup1ikyU9uC6h+vtLZzftbvtmodj/6j/wNVV9PGILy7 sQQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045758; x=1709650558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RwW1CJQtfQILe+wiKC0hERGdn0Ju6cDDGRNPYfPybJo=; b=FYi4qQnp4clpDdtIqPvGWewYArYtgOe1jhY8C3yarycx9wPDwypjpcVG9J4ZX9Vysd 2k4vdgIZnKrhd583GWH8PHf3YGyvSeD0YU7IL1vBpsARv29B0wifxyhuUF+cagxLWe9I Cs5WMXo5wado5FbQ4XmxDoiH8WmIjKydkqQJgoMsLeZxVyOr8hexguAexbrgddD39jNr TL5r5HCAuicDuzDfwhlnEr4UoybJtSNLnWhyqD+p1rRipmmHVS7RLPNMtULNdEAXs2DY DUQe5mRE5ERq11N2mKEWbu10cNU6qx+w87zsRU9wbLTEismuDaSApEI5rFlqb2bbGvIe m8tA== X-Gm-Message-State: AOJu0YzFVTHCvwH6AkzkUHE76f1lTOSWXW9tUEnS5Qudt0HBbu9fOGB3 RFtq48swbVE+YP01nzVLPrANQJQZmTLOP6UPd2BG1AxcmVMCkvjg9ITtedSV X-Received: by 2002:a05:6512:48da:b0:511:88cc:4f00 with SMTP id er26-20020a05651248da00b0051188cc4f00mr5759203lfb.56.1709045757666; Tue, 27 Feb 2024 06:55:57 -0800 (PST) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id o9-20020a5d4a89000000b0033df1dc39f0sm1859627wrq.4.2024.02.27.06.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:55:57 -0800 (PST) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Feb 2024 15:50:37 +0100 Message-ID: <20240227145536.281991-2-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227145536.281991-1-matthieu.bouron@gmail.com> References: <20240213230418.457056-1-matthieu.bouron@gmail.com> <20240227145536.281991-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/6] avcodec: add av_jni_{get, set}_android_app_ctx helper 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: Matthieu Bouron Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: beCOvu4bkhIF This will allow users to pass the Android ApplicationContext which is mandatory to retrieve the ContentResolver responsible to resolve/open Android content-uri. --- libavcodec/jni.c | 40 ++++++++++++++++++++++++++++++++++++++++ libavcodec/jni.h | 17 +++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/libavcodec/jni.c b/libavcodec/jni.c index ae6490de9d..7d04d0a268 100644 --- a/libavcodec/jni.c +++ b/libavcodec/jni.c @@ -64,6 +64,36 @@ void *av_jni_get_java_vm(void *log_ctx) return vm; } +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) +{ + JNIEnv *env = avpriv_jni_get_env(c); + if (!env) + return AVERROR(EINVAL); + + jobjectRefType type = (*env)->GetObjectRefType(env, app_ctx); + if (type != JNIGlobalRefType) { + av_log(log_ctx, AV_LOG_ERROR, "Application context must be passed as a global reference"); + return AVERROR(EINVAL); + } + + pthread_mutex_lock(&lock); + android_app_ctx = app_ctx; + pthread_mutex_unlock(&lock); + + return 0; +} + +void *av_jni_get_android_app_ctx(void) +{ + void *ctx; + + pthread_mutex_lock(&lock); + ctx = android_app_ctx; + pthread_mutex_unlock(&lock); + + return ctx; +} + #else int av_jni_set_java_vm(void *vm, void *log_ctx) @@ -76,4 +106,14 @@ void *av_jni_get_java_vm(void *log_ctx) return NULL; } +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) +{ + return AVERROR(ENOSYS); +} + +void *av_jni_get_android_app_ctx(void) +{ + return NULL; +} + #endif diff --git a/libavcodec/jni.h b/libavcodec/jni.h index dd99e92611..da8025f830 100644 --- a/libavcodec/jni.h +++ b/libavcodec/jni.h @@ -43,4 +43,21 @@ int av_jni_set_java_vm(void *vm, void *log_ctx); */ void *av_jni_get_java_vm(void *log_ctx); +/* + * Set the Android application context which will be used to retrieve the Android + * content resolver to resolve content uris. + * + * @param app_ctx global JNI reference to the Android application context + * @return 0 on success, < 0 otherwise + */ +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx); + +/* + * Get the Android application context that has been set with + * av_jni_set_android_app_ctx. + * + * @return a pointer the the Android application context + */ +void *av_jni_get_android_app_ctx(void); + #endif /* AVCODEC_JNI_H */ From patchwork Tue Feb 27 14:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 46572 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51b:b0:19e:cdac:8cce with SMTP id gm27csp2043725pzb; Tue, 27 Feb 2024 06:56:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU2BKnwxj74DnVjP9W5ePPBy0W8/tppCpLCd3x/+i5bmaS1L8i0vYhepOhgqqFSrEbSOIMzc7ggKAcUEAEB7pBNpzBV6N6mDwseDQ== X-Google-Smtp-Source: AGHT+IF4skb3BHofKaDnvZMM+hqCD7NwImkwTaPumvETfHWna0QtL0FfUr6olsJGQ8sW6x8mC45Q X-Received: by 2002:a05:6512:a91:b0:512:ed78:a840 with SMTP id m17-20020a0565120a9100b00512ed78a840mr8231894lfu.61.1709045784090; Tue, 27 Feb 2024 06:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709045784; cv=none; d=google.com; s=arc-20160816; b=rqPTGfbR1C5DSxb+wZstBD7UdbvfgWeKd+ScsrwQpuzFzcv/sYvuhzR/f94h8z2R2r HCS2nmP44ygGGZVrPRG6GKF6YNQ3NQ9xNxUZG3L3Nlt4/49jUvhdoPyF7xaVf7Fq/zUA Ybj5ZVOO/TWj8PeKYvCzAjNerBWqKb5EZGKfZuyjQ1a4L9VHn338ESyvENPwxZYSy67m W7EQz8pjVmtmW7KsZjn9V7GyNQGXUMQpwZ/CE1F6GG2jZNr3fUA90pWDEHvGL/tBqufY 4PL5aSd5Xp/xV5RvQeFXe2xfrhmfdFXSID4cOMdUHG25hZOsDhcpTw0oNj8fh6Kn6uu6 hOTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=82tnwUxoFdtxr8NQU9bkwGaGc0XTehjr3uTieiu9YLU=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=U0UZOYEtmNtMDqP5FzWn0PHwrakTtNsBP/IIWsC6a1HCTiAyiu03HWDPrBp2STkH6H 2m99byU80mWS9it+FUqB2tn4UO3uyGNkKkq4tvhHPyddNG3VIY7lYYaVTJBGHrc7wNmh Q1E9E6dYdnXOm2ccUV8BS4GC6tqVH61FMInkhp58pXBrBdH0Jk3t31MOn0Fe28uSDyMb zemy8kR66HxJg7sYOpr6TyBAQBKe/JA92Q8BZXmaFvolfiDw2VFR0Oa/NEer+FRp7qvh Uc9DZPtLWZ2ddi1PweHnh6Q0sGvv/1m7lDf8j1oyW/CJ1p/goD0PsdZ7ICUjJqxrdjN4 XbTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="jNv/Uosh"; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e20-20020aa7d7d4000000b0056484c0505asi760913eds.201.2024.02.27.06.56.23; Tue, 27 Feb 2024 06:56:24 -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=@gmail.com header.s=20230601 header.b="jNv/Uosh"; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 526F768CC49; Tue, 27 Feb 2024 16:56:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0C97968CBDB for ; Tue, 27 Feb 2024 16:55:59 +0200 (EET) Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4129e8bc6c8so24708315e9.2 for ; Tue, 27 Feb 2024 06:55:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709045758; x=1709650558; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a0bDzAb3nSRlCdgcE+1SAVS6H5SSolRMeK6W0cxSe1A=; b=jNv/UoshCQ7gqYAbqluRFaPJjcdN/DaFKsbYy/xLISlc3gXuCI9YmJK/IHdt2td4/2 rpDiF5Pjp5nTZXsDOXl8t+O/mxSzY4TZKB3SNu9yVctaAtbrlepgZIyzzXzRzJuHFpx9 OyXyygexJyp7iC8p+KnPbVJ8lbATcofCgVjHUdl+fN5rsXdrWrbnzkkvV87VWtMcfYqW jf4TlXzRf/6b+xjYEC7/MhM8s5r81i+LO8JQx3b6m2IlShAbLJS2lfZIAT7FTF5mEnu9 7U63BEV9jn6UKzVsQn5WIIjKCZyiradeS+AJUWFj3Nt2I7C5SDULmJhNQkAzSeFSzxx5 w2+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045758; x=1709650558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a0bDzAb3nSRlCdgcE+1SAVS6H5SSolRMeK6W0cxSe1A=; b=sxzpk+JuOOmQ9Jmrl0nJjeZnHAiajT6vvUhy2GjIXZzl5271oi2zEDWlodJkT9LQB8 /dGAKX/7E5R03Cy4/N90JDq+K94GfvPP9EjcJuBLXf1oXAHlLtKNwjq1w31s1It2aac7 mHWi2NZFPX9abyj5Kh9gtFsqNkmkIpwzH74ElFsVrc11oQM7HYjFMcLjICMZmKJcVgVL L8utZmLxwwEMELML0ofA2J8H0G68YmmB+W4TNJUYIl9oNh6+pwtW8VfrjTxQIdF4U7R5 iDOVa+/wt2OFKNDyQexo250EKRRavBWFeYN8FHfqRfMBWl0Djaviz+Z7akIBt/jFsTup ZInA== X-Gm-Message-State: AOJu0YwkxdOwAbFX/1GjqkEmRFK6Khlngsku4U9zVBQqHXneV11r5Nso AowKoY7gETJPoK33h2qR5VMePhucMtMpqrFbbBF9l//UMpz2jFsi/+Isi7tU X-Received: by 2002:a05:600c:524f:b0:412:9eff:4a9a with SMTP id fc15-20020a05600c524f00b004129eff4a9amr6620123wmb.9.1709045758316; Tue, 27 Feb 2024 06:55:58 -0800 (PST) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id o9-20020a5d4a89000000b0033df1dc39f0sm1859627wrq.4.2024.02.27.06.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:55:57 -0800 (PST) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Feb 2024 15:50:38 +0100 Message-ID: <20240227145536.281991-3-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227145536.281991-1-matthieu.bouron@gmail.com> References: <20240213230418.457056-1-matthieu.bouron@gmail.com> <20240227145536.281991-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/6] avformat: add Android content resolver protocol support 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: Matthieu Bouron Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: SFwAXi3nysnP Handles Android content-uri starting with content://. --- configure | 2 + doc/APIchanges | 3 + libavcodec/jni.c | 3 +- libavformat/Makefile | 1 + libavformat/file.c | 157 ++++++++++++++++++++++++++++++++++++++++ libavformat/protocols.c | 1 + 6 files changed, 166 insertions(+), 1 deletion(-) diff --git a/configure b/configure index bb5e630bad..790a1df7c8 100755 --- a/configure +++ b/configure @@ -3655,6 +3655,8 @@ xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes" xv_outdev_deps="xlib_xv xlib_x11 xlib_xext" # protocols +android_content_protocol_deps="jni" +android_content_protocol_select="file_protocol" async_protocol_deps="threads" bluray_protocol_deps="libbluray" ffrtmpcrypt_protocol_conflict="librtmp_protocol" diff --git a/doc/APIchanges b/doc/APIchanges index 10f6667e9e..258e953ca6 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2024-02-xx - xxxxxxxxxx - lavc 60.41.100 - jni.h + Add av_jni_set_android_app_ctx() and av_jni_get_android_app_ctx(). + 2024-02-26 - xxxxxxxxxx - lavf 60.22.101 - avformat.h AV_DISPOSITION_DEPENDENT may now also be used for video streams intended to be merged with other video streams for presentation. diff --git a/libavcodec/jni.c b/libavcodec/jni.c index 7d04d0a268..5a75d97f19 100644 --- a/libavcodec/jni.c +++ b/libavcodec/jni.c @@ -35,6 +35,7 @@ #include "ffjni.h" static void *java_vm; +static void *android_app_ctx; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; int av_jni_set_java_vm(void *vm, void *log_ctx) @@ -66,7 +67,7 @@ void *av_jni_get_java_vm(void *log_ctx) int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) { - JNIEnv *env = avpriv_jni_get_env(c); + JNIEnv *env = ff_jni_get_env(log_ctx); if (!env) return AVERROR(EINVAL); diff --git a/libavformat/Makefile b/libavformat/Makefile index 4a380668bd..08fe98a535 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -657,6 +657,7 @@ OBJS-$(CONFIG_LIBOPENMPT_DEMUXER) += libopenmpt.o OBJS-$(CONFIG_VAPOURSYNTH_DEMUXER) += vapoursynth.o # protocols I/O +OBJS-$(CONFIG_ANDROID_CONTENT_PROTOCOL) += file.o OBJS-$(CONFIG_ASYNC_PROTOCOL) += async.o OBJS-$(CONFIG_APPLEHTTP_PROTOCOL) += hlsproto.o OBJS-$(CONFIG_BLURAY_PROTOCOL) += bluray.o diff --git a/libavformat/file.c b/libavformat/file.c index 64df7ff6fb..1b2b69f090 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -40,6 +40,12 @@ #include #include "os_support.h" #include "url.h" +#if CONFIG_ANDROID_CONTENT_PROTOCOL +#include +#include "libavcodec/jni.h" +#include "libavcodec/ffjni.c" +#endif + /* Some systems may not have S_ISFIFO */ #ifndef S_ISFIFO @@ -101,6 +107,21 @@ typedef struct FileContext { int64_t initial_pos; } FileContext; + +#if CONFIG_ANDROID_CONTENT_PROTOCOL +static const AVOption android_content_options[] = { + { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, + { NULL } +}; + +static const AVClass android_content_class = { + .class_name = "android_content", + .item_name = av_default_item_name, + .option = android_content_options, + .version = LIBAVUTIL_VERSION_INT, +}; +#endif + static const AVOption file_options[] = { { "truncate", "truncate existing files on write", offsetof(FileContext, trunc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM }, { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, @@ -524,3 +545,139 @@ const URLProtocol ff_fd_protocol = { }; #endif /* CONFIG_FD_PROTOCOL */ + +#if CONFIG_ANDROID_CONTENT_PROTOCOL + +struct JFields { + jclass uri_class; + jmethodID parse_id; + + jclass context_class; + jmethodID get_content_resolver_id; + + jclass content_resolver_class; + jmethodID open_file_descriptor_id; + + jclass parcel_file_descriptor_class; + jmethodID detach_fd_id; +}; + +#define OFFSET(x) offsetof(struct JFields, x) +static const struct FFJniField jfields_mapping[] = { + { "android/net/Uri", NULL, NULL, FF_JNI_CLASS, OFFSET(uri_class), 1 }, + { "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;", FF_JNI_STATIC_METHOD, OFFSET(parse_id), 1 }, + + { "android/content/Context", NULL, NULL, FF_JNI_CLASS, OFFSET(context_class), 1 }, + { "android/content/Context", "getContentResolver", "()Landroid/content/ContentResolver;", FF_JNI_METHOD, OFFSET(get_content_resolver_id), 1 }, + + { "android/content/ContentResolver", NULL, NULL, FF_JNI_CLASS, OFFSET(content_resolver_class), 1 }, + { "android/content/ContentResolver", "openFileDescriptor", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;", FF_JNI_METHOD, OFFSET(open_file_descriptor_id), 1 }, + + { "android/os/ParcelFileDescriptor", NULL, NULL, FF_JNI_CLASS, OFFSET(parcel_file_descriptor_class), 1 }, + { "android/os/ParcelFileDescriptor", "detachFd", "()I", FF_JNI_METHOD, OFFSET(detach_fd_id), 1 }, + + { NULL } +}; +#undef OFFSET + +static int android_content_open(URLContext *h, const char *filename, int flags) +{ + FileContext *c = h->priv_data; + int fd, ret; + const char *mode_str = "r"; + + JNIEnv *env; + struct JFields jfields = { 0 }; + jobject application_context = NULL; + jobject url = NULL; + jobject mode = NULL; + jobject uri = NULL; + jobject content_resolver = NULL; + jobject parcel_file_descriptor = NULL; + + env = ff_jni_get_env(c); + if (!env) { + return AVERROR(EINVAL); + } + + ret = ff_jni_init_jfields(env, &jfields, jfields_mapping, 0, c); + if (ret < 0) { + av_log(c, AV_LOG_ERROR, "failed to initialize jni fields\n"); + return ret; + } + + application_context = av_jni_get_android_app_ctx(); + if (!application_context) { + av_log(c, AV_LOG_ERROR, "application context is not set\n"); + ret = AVERROR_EXTERNAL; + goto done; + } + + url = ff_jni_utf_chars_to_jstring(env, filename, c); + if (!url) { + ret = AVERROR_EXTERNAL; + goto done; + } + + if (flags & AVIO_FLAG_WRITE && flags & AVIO_FLAG_READ) + mode_str = "rw"; + else if (flags & AVIO_FLAG_WRITE) + mode_str = "w"; + + mode = ff_jni_utf_chars_to_jstring(env, mode_str, c); + if (!mode) { + ret = AVERROR_EXTERNAL; + goto done; + } + + uri = (*env)->CallStaticObjectMethod(env, jfields.uri_class, jfields.parse_id, url); + ret = ff_jni_exception_check(env, 1, c); + if (ret < 0) + goto done; + + content_resolver = (*env)->CallObjectMethod(env, application_context, jfields.get_content_resolver_id); + ret = ff_jni_exception_check(env, 1, c); + if (ret < 0) + goto done; + + parcel_file_descriptor = (*env)->CallObjectMethod(env, content_resolver, jfields.open_file_descriptor_id, uri, mode); + ret = ff_jni_exception_check(env, 1, c); + if (ret < 0) + goto done; + + fd = (*env)->CallIntMethod(env, parcel_file_descriptor, jfields.detach_fd_id); + ret = ff_jni_exception_check(env, 1, c); + if (ret < 0) + goto done; + +#if HAVE_SETMODE + setmode(fd, O_BINARY); +#endif + c->fd = fd; + h->is_streamed = 0; + +done: + (*env)->DeleteLocalRef(env, url); + (*env)->DeleteLocalRef(env, mode); + (*env)->DeleteLocalRef(env, uri); + (*env)->DeleteLocalRef(env, content_resolver); + (*env)->DeleteLocalRef(env, parcel_file_descriptor); + ff_jni_reset_jfields(env, &jfields, jfields_mapping, 0, c); + + return ret; +} + +URLProtocol ff_android_content_protocol = { + .name = "content", + .url_open = android_content_open, + .url_read = file_read, + .url_write = file_write, + .url_seek = file_seek, + .url_close = file_close, + .url_get_file_handle = file_get_handle, + .url_check = NULL, + .priv_data_size = sizeof(FileContext), + .priv_data_class = &android_content_class, +}; + +#endif /* CONFIG_ANDROID_CONTENT_PROTOCOL */ diff --git a/libavformat/protocols.c b/libavformat/protocols.c index 360018b17c..93a6d67261 100644 --- a/libavformat/protocols.c +++ b/libavformat/protocols.c @@ -24,6 +24,7 @@ #include "url.h" +extern const URLProtocol ff_android_content_protocol; extern const URLProtocol ff_async_protocol; extern const URLProtocol ff_bluray_protocol; extern const URLProtocol ff_cache_protocol; From patchwork Tue Feb 27 14:50:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 46573 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51b:b0:19e:cdac:8cce with SMTP id gm27csp2043799pzb; Tue, 27 Feb 2024 06:56:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXEkILN+91HChWGFtO4R9BFfj0W4Mz4CBmi7CyrnhxNnKdtb+ccE98n8a16FAbauIUhozXdnnO/g9lO2uvniTUM/1RTcJD9PYfY3A== X-Google-Smtp-Source: AGHT+IEgoGkpdhyLiHKcSdX9o/KcXSrubqVSQNHrFxxMVgg/Yw3jS+xPdeng7gCzfav/c9mqIrEC X-Received: by 2002:a17:906:35cd:b0:a43:3f37:4d87 with SMTP id p13-20020a17090635cd00b00a433f374d87mr4709941ejb.46.1709045792455; Tue, 27 Feb 2024 06:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709045792; cv=none; d=google.com; s=arc-20160816; b=L6ak1jv3yJwF70trGNTQeSblHqJ+LkMdT1c5f+XFIVPPRgkvJ9V6vUT33NxPBlL7XY VAsIhCTnrO7+vJcUM8JT767Jz8MzSTzEFAlWMRx2oghHg+/tFen4tgKtJvUIuCj00JyH 2yfpJt7A+BaF5BtNa8gpqnP0GStA5LmPtrsFj/NXfVOPdg7K8IGWtpw+276Cebj12zw0 oOMqjUG7blS6XbDfG010kAJsYAHzCzjD1LuU2pikcNlh4qGupSUCfSxz1Xew3RwqoVpU eeme4noDgdDVB5wVu0QuGiIwAcczn9gflt6Ezkjkb5o/Co8tOoAQ7iJ+E3zBaf6l+C9l lJTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=DHj5B7q8YPWR/g3/czU6yqOIj7QUNaGZHBV8r3HvKHE=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=GxMLxieUofSBzcRoOKRiEKoXYHPHCSoCyrvKSAxIPfbwWGt2gJMsPtK/oTtgZnMIto Rie1lDMTbzmiE7RT8wTRFCFK21VwpUb8iZane5Kv5O3ZVmElP29pnYFe/rTnSpm3H2ys QkqUhzSMENqWjOM6EyBFGMwJGuwyh0sCMUpmGfqG5GKpcN/Ke+6asE6baeG37/zNJPCK IJiWSiAP6jOs2svp7q3bjMWx6g9tko4EFXmiAtSEmiu9rRliUJhZTIahr782nFAl34Cy sq6V6EH4mqzXiVzhhxpWHqndfnbujzxXPRy4muLD2b54P0RSv2Q+Yq0rsdqOg6Vm2ZI5 sINw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=h7h1yPp2; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hb24-20020a170906b89800b00a43106a5124si776273ejb.840.2024.02.27.06.56.31; Tue, 27 Feb 2024 06:56:32 -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=@gmail.com header.s=20230601 header.b=h7h1yPp2; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 420C368CC83; Tue, 27 Feb 2024 16:56:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9D34C68CBDB for ; Tue, 27 Feb 2024 16:55:59 +0200 (EET) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d28387db09so32926091fa.0 for ; Tue, 27 Feb 2024 06:55:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709045759; x=1709650559; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2cN9JRGAeHwmXk4IM+0UtodKygGRscPdkBUl4Td4LAQ=; b=h7h1yPp2R0n3bsG8SbR7kGfJ6x1A4JqW6x14U8tHYyJDA/H4HePdTG59wxs4ktooXu b0Aog4YApyTw1GiyE50xQMRKrzn0Yo1a3q0ksWUQ5/hClxErT69zeTpJojZ9wajorMA7 hLFDdxO0jtQEkCo2WFWRk8XS56mCsFYsxcdcfh7+iOAen9jOXSDSyAwjARChDoIbC1A+ OMlws+lu0uLPfr6LAXaJakzEN21uceZJyWeZVHnRrGc+p+QMT9zjy6U/RAPJZiynzQMA uCgWd8LhGOZrjeXniMUN6wZr7Oqyu4nGjBp1jwlo34T+L2PAJImFev0/tE57PTIKlHJ3 FLLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045759; x=1709650559; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2cN9JRGAeHwmXk4IM+0UtodKygGRscPdkBUl4Td4LAQ=; b=N31jM2kI0R67yg6xP4vR06QxHkZNoKVXhBQ0ZIZSl+oT1HUoK+OJBo7YOHpHLUOOTH fLoXVL7zZ6/s4VHVl9LiBA0ExKbivu6/DqSriIv2S0g/K7DFLsSnhLlgmgXdjBhq4b82 pwIPxv/0qXHHWE3+fgTtSxYGQLx5BGF1sDpGt0y9DvV1q0SDT7XbNaGhY7sKCY0T41YD Rg6QKIr27HyQpA62Q4cC3zC0aZzxxsqF6LOsu8XwDYtBiZAVa/igQSTsneHYAmwDafbj 4VNZ/ZfO8WOIvrvGdp2jGr2gzGHqQiTMIDxrH+dzHDoARYmyAf4iRlueniMijear5Ms4 I/xQ== X-Gm-Message-State: AOJu0YzoVkjpfvcuU2GUu2aGzbTu9UTVkMKGCT4V92V1/DoWNfr9bi4Q sWqpTLHhtM3uNXGBkP+66mQlfJPCftdeIBWP44TyQvkF5G0Y2VHcAyI3yink X-Received: by 2002:a2e:9d8b:0:b0:2d2:9573:dc52 with SMTP id c11-20020a2e9d8b000000b002d29573dc52mr1637644ljj.2.1709045758718; Tue, 27 Feb 2024 06:55:58 -0800 (PST) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id o9-20020a5d4a89000000b0033df1dc39f0sm1859627wrq.4.2024.02.27.06.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:55:58 -0800 (PST) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Feb 2024 15:50:39 +0100 Message-ID: <20240227145536.281991-4-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227145536.281991-1-matthieu.bouron@gmail.com> References: <20240213230418.457056-1-matthieu.bouron@gmail.com> <20240227145536.281991-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/6] avutil/jni: use size_t to store structure offsets 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: Matthieu Bouron Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bUSUxFfZHu0u --- libavcodec/ffjni.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/ffjni.h b/libavcodec/ffjni.h index 6027bac0ab..d5894609ed 100644 --- a/libavcodec/ffjni.h +++ b/libavcodec/ffjni.h @@ -24,6 +24,7 @@ #define AVCODEC_FFJNI_H #include +#include /* * Attach permanently a JNI environment to the current thread and retrieve it. @@ -105,7 +106,7 @@ struct FFJniField { const char *method; const char *signature; enum FFJniFieldType type; - int offset; + size_t offset; int mandatory; }; From patchwork Tue Feb 27 14:50:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 46574 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51b:b0:19e:cdac:8cce with SMTP id gm27csp2043866pzb; Tue, 27 Feb 2024 06:56:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXNM4ehGdwvKqjKw9L0E/jD7vDfMhDIGoboYUnKByAci8AllEo8+BcOS+kPMBHqQnLWnx6vHqmUYIzdPOxl54ZsNg/EzwbCgIsTUw== X-Google-Smtp-Source: AGHT+IEkcREb1mPecdszbwzmQeH7thFDcLttQDKhoTCxiQIeVEsEqdYqwryh/11GaG7pj3FEuTzZ X-Received: by 2002:ac2:4288:0:b0:512:fdb3:7a9e with SMTP id m8-20020ac24288000000b00512fdb37a9emr3339445lfh.31.1709045800428; Tue, 27 Feb 2024 06:56:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709045800; cv=none; d=google.com; s=arc-20160816; b=juk1uwiEdihvGvouq3sqqGwM3kzjeAf1cY8iE2sxaZo2tsjRvEEYIcvqxambrcEXDR 2S/w9QeYWWSRtQ5pc0iphUircNveQo1kfDyUXWI3HbjouKBYUSYrNuFXO0WMYATREMsX op/urNxQnuv4eQ4SiK7NieWxP7tnsZDHLRzOAGJCVYZDUckpRlhi+084eikq1SEUUsr9 ILJXTlUY7docEHiTCfohh7sS93Zb0W37xUE612zVJKSQSJUlF2J45Zppa41WxvNTA6a4 d3+xefRfhoPs0d7ZG1dfNrRVDC2QfXhml2YcmYQA1Ss0KkJDU4eKubutZBU39hAjwuQw MUbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=2dGDrc6vG7DwqggBfFEip2R13BaqMcwLkSoSrpPl1ns=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=a5+bbRfkk1ZlaMnGPvMNf6jXd2V+yrSaK72oBRlNT9O2rqF0gqZjwPKwjgoqbsmzDS EQBL/tSSaq6mb54ZvywFatLKyivaMkQL/Dr2hsNCpaWI99MEKdavQpHnu8wUMNgJMsZT rGTgcf67JB8uJs+jY/ywRuyFFFtaxK73fWcpFY2vCPu3YHifQnkYSMbGTLmyTZURDzTI ClXndFpNDLYTGvdGavK/oVSTmMfjZIu4doXo75sXMcBOEmtU/ludxZoXodRHEP/+pYeZ 7TJb91bjMm1W6b/moj7fIxIoXzFLl+b0BxZNWWj/59U5LwZ09fBAe+XerN/eKdQh7O0p ig+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=dpqCOYm7; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v16-20020a056402185000b005664810cae5si330244edy.39.2024.02.27.06.56.40; Tue, 27 Feb 2024 06:56:40 -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=@gmail.com header.s=20230601 header.b=dpqCOYm7; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F67368CC91; Tue, 27 Feb 2024 16:56:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED1C968CAA9 for ; Tue, 27 Feb 2024 16:55:59 +0200 (EET) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-33d568fbf62so2478446f8f.3 for ; Tue, 27 Feb 2024 06:55:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709045759; x=1709650559; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lPYRLaemd/5JXt7wVTMSEuFYjpCq9JVN5Mxm5L8PxrM=; b=dpqCOYm7Q/0DNfZDqn+D6e14/00C5OetNaav6gPJe1xh38nT/U3HghRsCq3sVK2f0N cjYImLwMEhY5OMPmG9dOqe0iLO/g0fFPTB5LuediEiCPB34EsN7gWylSmv/Ajps+NExc VpmkvxA94Xjl4ZU0A7VG08tBkaxu0em0zYO/rvhXRVAqdkvy9syeKk3PSXuY7L1L6hZW s0pKDPSCWgfELjBzAVDdkBhiaQenHBBPuU88fuSIaPUTJc6ihTtbZ5EhSaUAkHXyRvzK OzVpC1+w/uptH98z4iGif7Mrd18iMhlX1IgYgqaqeQJyM/FgE1Uz9Zst1i8mKbX6/CrR TIlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045759; x=1709650559; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lPYRLaemd/5JXt7wVTMSEuFYjpCq9JVN5Mxm5L8PxrM=; b=SeO2S0BJSaJJC6yjQ9LZJpDSvRTiWsYRFE/9I/bg6uir0TEIDBxdDPPWkYh32A+BR7 zH5QJ/x7GOOfIN7Ekua+VQPFmmkD418/hZyzavRjwhhk8Fyj4m7t0owr9MA2e/5vYUpx JyXbr1rlbP0JrqzS9sw20885NM/qG71QLP2RqyKOv+aZNgH0b5aWjT4Tim6/q4FdLB1z sQYRiFFZ3ITsGARkxKJsvd6pV351YCQ+9RgssP/LxLWbawyckFoBz4nWUhjjEZRBf/Ls AbCZoAlTqcPgXE6V7w5zg8jQXQSdh7t8ETKsZEVqndNunU3urfDO2ByU8P8zEMqrnZXr +fyA== X-Gm-Message-State: AOJu0YwanTyhx/1BdqUevH6PcX21Q/hwuXEt6te0xVnig5cLrkmMfe9f LC/OzsZJR2Cs/BCj7WZomeiYWC98xfrhS4qwXQUeh+PBgJ/6A7CldhB1TORW X-Received: by 2002:adf:e689:0:b0:33d:afbc:6c85 with SMTP id r9-20020adfe689000000b0033dafbc6c85mr8125779wrm.8.1709045759191; Tue, 27 Feb 2024 06:55:59 -0800 (PST) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id o9-20020a5d4a89000000b0033df1dc39f0sm1859627wrq.4.2024.02.27.06.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:55:58 -0800 (PST) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Feb 2024 15:50:40 +0100 Message-ID: <20240227145536.281991-5-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227145536.281991-1-matthieu.bouron@gmail.com> References: <20240213230418.457056-1-matthieu.bouron@gmail.com> <20240227145536.281991-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/6] avutil/jni: remove unnecessary NULL checks before calling DeleteLocalRef() 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: Matthieu Bouron Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: djuIwvp8siBT Delete{Global,Local}Ref() already handle NULL. --- libavcodec/ffjni.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libavcodec/ffjni.c b/libavcodec/ffjni.c index e3cf24d3e2..69d9a9faa3 100644 --- a/libavcodec/ffjni.c +++ b/libavcodec/ffjni.c @@ -236,17 +236,9 @@ done: av_free(name); av_free(message); - if (class_class) { - (*env)->DeleteLocalRef(env, class_class); - } - - if (exception_class) { - (*env)->DeleteLocalRef(env, exception_class); - } - - if (string) { - (*env)->DeleteLocalRef(env, string); - } + (*env)->DeleteLocalRef(env, class_class); + (*env)->DeleteLocalRef(env, exception_class); + (*env)->DeleteLocalRef(env, string); return ret; } From patchwork Tue Feb 27 14:50:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 46575 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51b:b0:19e:cdac:8cce with SMTP id gm27csp2043937pzb; Tue, 27 Feb 2024 06:56:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXwjqyhJMKtRp1eQDbR30r9I2yK5EhF/XtG5AtmZ7Q3mwpHErSOK+Ngr2UAAaCQL8N9SVZUwfSPjtTqByPoPWMJKb2qljWCbot3bA== X-Google-Smtp-Source: AGHT+IFkP2QKWuj6SiMQjofzJEQsSoE0tc+Zx3KZrSTPu5i9LNyP/FbCiseAriNTZZM8F9jHtBfo X-Received: by 2002:aa7:da0d:0:b0:566:4624:b120 with SMTP id r13-20020aa7da0d000000b005664624b120mr967708eds.26.1709045809646; Tue, 27 Feb 2024 06:56:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709045809; cv=none; d=google.com; s=arc-20160816; b=OsZKuKD2pfxfDfQh4NzOVXZT0sRcJ4AOSZmhdi05l0PX5eypnJf+OD/dOeHo9H5x5s 4G1JdQKxzj1qqhw5LTnbPEhOiqZyhY3aLKIO6+xpPlK7NgzqWtS22i0//gbrQIl0Th2G xa08Faw+j5CfNVHMhtiYQd9iG0wMUf7J3zZJ7VyRaAsTeVBM0zXPc1wFCVXpbtMealQ4 OcLYKXbLelLR6hXaRvlMt/+qE++77Wg/4LHI56xSKyCf47D0aWo5J9eGUaBL3opkDxzi LuMuXKUx4M/iqmWzPXFJZvpjBDNem8fmcxzkkkMhbRdkule0Sgw5OQR01oKNNrCoKyEj LmZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=KHcJoGwluyVhSqPCO/pnCjjL0M8cDD58XTfLVrudi6k=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=Ahqa9XELZIOWOK0dM2I7LAEP44R3KAZscybreJ5QRt1TZlZec9YZ3AfXco+sVGRN4u 2x56r2DLvc04T57RZwRPk68nLsc8CY6ETOpbKhYFrnQ+o8Kp5Dg/+ykPB20d75KEQLtx s40mfkNl05CqM1DlI3p0V5FziRmYx5c+uGh7wT/iBMsd6bdRQu2CaR7D7q4Qip9RUWdf qUj8pxPoP2lGq32VnU2qIjvqJe79FerMZl4HIks92HX2+NV7AxplSs9Dc4x8nJHycymj Jmj6sCsz55y/G7F9ksLbuNW36O2E+u4dlsrzTWv+K6Pm6IheuQgAKUWn3lhSMc9k1Kps fwiw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Y0spj4TK; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u24-20020a50a418000000b00566131a26e6si756655edb.345.2024.02.27.06.56.49; Tue, 27 Feb 2024 06:56:49 -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=@gmail.com header.s=20230601 header.b=Y0spj4TK; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6552B68CCB3; Tue, 27 Feb 2024 16:56:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A9E2168CBDB for ; Tue, 27 Feb 2024 16:56:00 +0200 (EET) Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2d2509c66daso63056421fa.3 for ; Tue, 27 Feb 2024 06:56:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709045760; x=1709650560; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z5QRaiE4LQS4bhGU8W20zvI2KtXvhLn43GZsqULLobI=; b=Y0spj4TKYiyymqlHPFXeXfdHx2G/gqhDW7SBgVJS987lfw2BwQCL9BkwuSQa0kwRD0 n+1CMJ7+v38FjPbBr/wGjkZS3D+m0Np05rUuZ5RYgABlpRIfGLh2u1G+hXHiHmO6F81w Hasl5P0mndEHknIr+W9X3Z9kd89uQWaV2hGsFliMoOt+mzPWaXzAWH7RqlzvccjSVxz0 oEWuBCzbjFtkMCSA4awO1P9DxE/geM2dve9J3naMhNuiM8z89Zt0GILR2NJOk/LMl+w5 aKur4Cbj7jvVi078U8RPVKb2HN7woqqEgBPc1PFYWvC1igMawCFY27HpKxW15Y5pA+cg 8zfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045760; x=1709650560; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z5QRaiE4LQS4bhGU8W20zvI2KtXvhLn43GZsqULLobI=; b=J9CHOQ2h3lauo6pqa7EEA5VcyVcSDGi5y/I3XhIvISI581B4TI+H2of1k53V5I7pJJ AHE8tZekMWh7J5NfVov99vuBt0aPGhQDGLHUnwpGloqRmIpYljdFlvWTnLTo7X0kLv8D orSoXol3Lj/Uw4BgewAa7M4wS2d/JOBHKRCxx9gzuj/ZZjpT+k+ZDpRGtphYKsD1ko2/ xBYViOr87Gkc970OnOlNZ3/DFtDqJypg0RuWFZzwlTp2VG+NXFhIPtWXw9763KITP043 kNXaTLrOzKEDDfziCqFN5bVxhI/eh2l5uClARm5j+rXS5sP4O0enTH+inBhTHLo2IRvL Pycw== X-Gm-Message-State: AOJu0YyE0tT4Ythcq47h0asF5+ZxDzHtLbFBTbubsLVcVmh0gEUzeN0I hrdkGVgkU+1vkajgNh/EdtZLRq2g1p2Im+bl4qzPmqJ8AowzVksh5nS9sALs X-Received: by 2002:a2e:7818:0:b0:2d2:937d:f5fa with SMTP id t24-20020a2e7818000000b002d2937df5famr1987977ljc.12.1709045759663; Tue, 27 Feb 2024 06:55:59 -0800 (PST) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id o9-20020a5d4a89000000b0033df1dc39f0sm1859627wrq.4.2024.02.27.06.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:55:59 -0800 (PST) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Feb 2024 15:50:41 +0100 Message-ID: <20240227145536.281991-6-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227145536.281991-1-matthieu.bouron@gmail.com> References: <20240213230418.457056-1-matthieu.bouron@gmail.com> <20240227145536.281991-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 5/6] avcodec/mediacodec_wrapper: use an OFFSET() macro where relevant 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: Matthieu Bouron Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: A0Ap036Odnu+ Reduces a bit the horizontal spacing. --- libavcodec/mediacodec_wrapper.c | 138 +++++++++++++++++--------------- 1 file changed, 72 insertions(+), 66 deletions(-) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index 0880ddd3ef..78cd28f53d 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -60,31 +60,33 @@ struct JNIAMediaCodecListFields { jfieldID level_id; }; +#define OFFSET(x) offsetof(struct JNIAMediaCodecListFields, x) static const struct FFJniField jni_amediacodeclist_mapping[] = { - { "android/media/MediaCodecList", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, mediacodec_list_class), 1 }, - { "android/media/MediaCodecList", "", "(I)V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, init_id), 0 }, - { "android/media/MediaCodecList", "findDecoderForFormat", "(Landroid/media/MediaFormat;)Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, find_decoder_for_format_id), 0 }, + { "android/media/MediaCodecList", NULL, NULL, FF_JNI_CLASS, OFFSET(mediacodec_list_class), 1 }, + { "android/media/MediaCodecList", "", "(I)V", FF_JNI_METHOD, OFFSET(init_id), 0 }, + { "android/media/MediaCodecList", "findDecoderForFormat", "(Landroid/media/MediaFormat;)Ljava/lang/String;", FF_JNI_METHOD, OFFSET(find_decoder_for_format_id), 0 }, - { "android/media/MediaCodecList", "getCodecCount", "()I", FF_JNI_STATIC_METHOD, offsetof(struct JNIAMediaCodecListFields, get_codec_count_id), 1 }, - { "android/media/MediaCodecList", "getCodecInfoAt", "(I)Landroid/media/MediaCodecInfo;", FF_JNI_STATIC_METHOD, offsetof(struct JNIAMediaCodecListFields, get_codec_info_at_id), 1 }, + { "android/media/MediaCodecList", "getCodecCount", "()I", FF_JNI_STATIC_METHOD, OFFSET(get_codec_count_id), 1 }, + { "android/media/MediaCodecList", "getCodecInfoAt", "(I)Landroid/media/MediaCodecInfo;", FF_JNI_STATIC_METHOD, OFFSET(get_codec_info_at_id), 1 }, - { "android/media/MediaCodecInfo", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, mediacodec_info_class), 1 }, - { "android/media/MediaCodecInfo", "getName", "()Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_name_id), 1 }, - { "android/media/MediaCodecInfo", "getCapabilitiesForType", "(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_codec_capabilities_id), 1 }, - { "android/media/MediaCodecInfo", "getSupportedTypes", "()[Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_supported_types_id), 1 }, - { "android/media/MediaCodecInfo", "isEncoder", "()Z", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_encoder_id), 1 }, - { "android/media/MediaCodecInfo", "isSoftwareOnly", "()Z", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_software_only_id), 0 }, + { "android/media/MediaCodecInfo", NULL, NULL, FF_JNI_CLASS, OFFSET(mediacodec_info_class), 1 }, + { "android/media/MediaCodecInfo", "getName", "()Ljava/lang/String;", FF_JNI_METHOD, OFFSET(get_name_id), 1 }, + { "android/media/MediaCodecInfo", "getCapabilitiesForType", "(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;", FF_JNI_METHOD, OFFSET(get_codec_capabilities_id), 1 }, + { "android/media/MediaCodecInfo", "getSupportedTypes", "()[Ljava/lang/String;", FF_JNI_METHOD, OFFSET(get_supported_types_id), 1 }, + { "android/media/MediaCodecInfo", "isEncoder", "()Z", FF_JNI_METHOD, OFFSET(is_encoder_id), 1 }, + { "android/media/MediaCodecInfo", "isSoftwareOnly", "()Z", FF_JNI_METHOD, OFFSET(is_software_only_id), 0 }, - { "android/media/MediaCodecInfo$CodecCapabilities", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, codec_capabilities_class), 1 }, - { "android/media/MediaCodecInfo$CodecCapabilities", "colorFormats", "[I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, color_formats_id), 1 }, - { "android/media/MediaCodecInfo$CodecCapabilities", "profileLevels", "[Landroid/media/MediaCodecInfo$CodecProfileLevel;", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, profile_levels_id), 1 }, + { "android/media/MediaCodecInfo$CodecCapabilities", NULL, NULL, FF_JNI_CLASS, OFFSET(codec_capabilities_class), 1 }, + { "android/media/MediaCodecInfo$CodecCapabilities", "colorFormats", "[I", FF_JNI_FIELD, OFFSET(color_formats_id), 1 }, + { "android/media/MediaCodecInfo$CodecCapabilities", "profileLevels", "[Landroid/media/MediaCodecInfo$CodecProfileLevel;", FF_JNI_FIELD, OFFSET(profile_levels_id), 1 }, - { "android/media/MediaCodecInfo$CodecProfileLevel", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, codec_profile_level_class), 1 }, - { "android/media/MediaCodecInfo$CodecProfileLevel", "profile", "I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, profile_id), 1 }, - { "android/media/MediaCodecInfo$CodecProfileLevel", "level", "I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, level_id), 1 }, + { "android/media/MediaCodecInfo$CodecProfileLevel", NULL, NULL, FF_JNI_CLASS, OFFSET(codec_profile_level_class), 1 }, + { "android/media/MediaCodecInfo$CodecProfileLevel", "profile", "I", FF_JNI_FIELD, OFFSET(profile_id), 1 }, + { "android/media/MediaCodecInfo$CodecProfileLevel", "level", "I", FF_JNI_FIELD, OFFSET(level_id), 1 }, { NULL } }; +#undef OFFSET struct JNIAMediaFormatFields { @@ -110,29 +112,31 @@ struct JNIAMediaFormatFields { }; +#define OFFSET(x) offsetof(struct JNIAMediaFormatFields, x) static const struct FFJniField jni_amediaformat_mapping[] = { - { "android/media/MediaFormat", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaFormatFields, mediaformat_class), 1 }, + { "android/media/MediaFormat", NULL, NULL, FF_JNI_CLASS, OFFSET(mediaformat_class), 1 }, - { "android/media/MediaFormat", "", "()V", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, init_id), 1 }, + { "android/media/MediaFormat", "", "()V", FF_JNI_METHOD, OFFSET(init_id), 1 }, - { "android/media/MediaFormat", "containsKey", "(Ljava/lang/String;)Z", FF_JNI_METHOD,offsetof(struct JNIAMediaFormatFields, contains_key_id), 1 }, + { "android/media/MediaFormat", "containsKey", "(Ljava/lang/String;)Z", FF_JNI_METHOD, OFFSET(contains_key_id), 1 }, - { "android/media/MediaFormat", "getInteger", "(Ljava/lang/String;)I", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, get_integer_id), 1 }, - { "android/media/MediaFormat", "getLong", "(Ljava/lang/String;)J", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, get_long_id), 1 }, - { "android/media/MediaFormat", "getFloat", "(Ljava/lang/String;)F", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, get_float_id), 1 }, - { "android/media/MediaFormat", "getByteBuffer", "(Ljava/lang/String;)Ljava/nio/ByteBuffer;", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, get_bytebuffer_id), 1 }, - { "android/media/MediaFormat", "getString", "(Ljava/lang/String;)Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, get_string_id), 1 }, + { "android/media/MediaFormat", "getInteger", "(Ljava/lang/String;)I", FF_JNI_METHOD, OFFSET(get_integer_id), 1 }, + { "android/media/MediaFormat", "getLong", "(Ljava/lang/String;)J", FF_JNI_METHOD, OFFSET(get_long_id), 1 }, + { "android/media/MediaFormat", "getFloat", "(Ljava/lang/String;)F", FF_JNI_METHOD, OFFSET(get_float_id), 1 }, + { "android/media/MediaFormat", "getByteBuffer", "(Ljava/lang/String;)Ljava/nio/ByteBuffer;", FF_JNI_METHOD, OFFSET(get_bytebuffer_id), 1 }, + { "android/media/MediaFormat", "getString", "(Ljava/lang/String;)Ljava/lang/String;", FF_JNI_METHOD, OFFSET(get_string_id), 1 }, - { "android/media/MediaFormat", "setInteger", "(Ljava/lang/String;I)V", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, set_integer_id), 1 }, - { "android/media/MediaFormat", "setLong", "(Ljava/lang/String;J)V", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, set_long_id), 1 }, - { "android/media/MediaFormat", "setFloat", "(Ljava/lang/String;F)V", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, set_float_id), 1 }, - { "android/media/MediaFormat", "setByteBuffer", "(Ljava/lang/String;Ljava/nio/ByteBuffer;)V", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, set_bytebuffer_id), 1 }, - { "android/media/MediaFormat", "setString", "(Ljava/lang/String;Ljava/lang/String;)V", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, set_string_id), 1 }, + { "android/media/MediaFormat", "setInteger", "(Ljava/lang/String;I)V", FF_JNI_METHOD, OFFSET(set_integer_id), 1 }, + { "android/media/MediaFormat", "setLong", "(Ljava/lang/String;J)V", FF_JNI_METHOD, OFFSET(set_long_id), 1 }, + { "android/media/MediaFormat", "setFloat", "(Ljava/lang/String;F)V", FF_JNI_METHOD, OFFSET(set_float_id), 1 }, + { "android/media/MediaFormat", "setByteBuffer", "(Ljava/lang/String;Ljava/nio/ByteBuffer;)V", FF_JNI_METHOD, OFFSET(set_bytebuffer_id), 1 }, + { "android/media/MediaFormat", "setString", "(Ljava/lang/String;Ljava/lang/String;)V", FF_JNI_METHOD, OFFSET(set_string_id), 1 }, - { "android/media/MediaFormat", "toString", "()Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaFormatFields, to_string_id), 1 }, + { "android/media/MediaFormat", "toString", "()Ljava/lang/String;", FF_JNI_METHOD, OFFSET(to_string_id), 1 }, { NULL } }; +#undef OFFSET static const AVClass amediaformat_class = { .class_name = "amediaformat", @@ -202,57 +206,59 @@ struct JNIAMediaCodecFields { }; +#define OFFSET(x) offsetof(struct JNIAMediaCodecFields, x) static const struct FFJniField jni_amediacodec_mapping[] = { - { "android/media/MediaCodec", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecFields, mediacodec_class), 1 }, + { "android/media/MediaCodec", NULL, NULL, FF_JNI_CLASS, OFFSET(mediacodec_class), 1 }, - { "android/media/MediaCodec", "INFO_TRY_AGAIN_LATER", "I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecFields, info_try_again_later_id), 1 }, - { "android/media/MediaCodec", "INFO_OUTPUT_BUFFERS_CHANGED", "I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecFields, info_output_buffers_changed_id), 1 }, - { "android/media/MediaCodec", "INFO_OUTPUT_FORMAT_CHANGED", "I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecFields, info_output_format_changed_id), 1 }, + { "android/media/MediaCodec", "INFO_TRY_AGAIN_LATER", "I", FF_JNI_STATIC_FIELD, OFFSET(info_try_again_later_id), 1 }, + { "android/media/MediaCodec", "INFO_OUTPUT_BUFFERS_CHANGED", "I", FF_JNI_STATIC_FIELD, OFFSET(info_output_buffers_changed_id), 1 }, + { "android/media/MediaCodec", "INFO_OUTPUT_FORMAT_CHANGED", "I", FF_JNI_STATIC_FIELD, OFFSET(info_output_format_changed_id), 1 }, - { "android/media/MediaCodec", "BUFFER_FLAG_CODEC_CONFIG", "I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecFields, buffer_flag_codec_config_id), 1 }, - { "android/media/MediaCodec", "BUFFER_FLAG_END_OF_STREAM", "I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecFields, buffer_flag_end_of_stream_id), 1 }, - { "android/media/MediaCodec", "BUFFER_FLAG_KEY_FRAME", "I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecFields, buffer_flag_key_frame_id), 0 }, + { "android/media/MediaCodec", "BUFFER_FLAG_CODEC_CONFIG", "I", FF_JNI_STATIC_FIELD, OFFSET(buffer_flag_codec_config_id), 1 }, + { "android/media/MediaCodec", "BUFFER_FLAG_END_OF_STREAM", "I", FF_JNI_STATIC_FIELD, OFFSET(buffer_flag_end_of_stream_id), 1 }, + { "android/media/MediaCodec", "BUFFER_FLAG_KEY_FRAME", "I", FF_JNI_STATIC_FIELD, OFFSET(buffer_flag_key_frame_id), 0 }, - { "android/media/MediaCodec", "CONFIGURE_FLAG_ENCODE", "I", FF_JNI_STATIC_FIELD, offsetof(struct JNIAMediaCodecFields, configure_flag_encode_id), 1 }, + { "android/media/MediaCodec", "CONFIGURE_FLAG_ENCODE", "I", FF_JNI_STATIC_FIELD, OFFSET(configure_flag_encode_id), 1 }, - { "android/media/MediaCodec", "createByCodecName", "(Ljava/lang/String;)Landroid/media/MediaCodec;", FF_JNI_STATIC_METHOD, offsetof(struct JNIAMediaCodecFields, create_by_codec_name_id), 1 }, - { "android/media/MediaCodec", "createDecoderByType", "(Ljava/lang/String;)Landroid/media/MediaCodec;", FF_JNI_STATIC_METHOD, offsetof(struct JNIAMediaCodecFields, create_decoder_by_type_id), 1 }, - { "android/media/MediaCodec", "createEncoderByType", "(Ljava/lang/String;)Landroid/media/MediaCodec;", FF_JNI_STATIC_METHOD, offsetof(struct JNIAMediaCodecFields, create_encoder_by_type_id), 1 }, + { "android/media/MediaCodec", "createByCodecName", "(Ljava/lang/String;)Landroid/media/MediaCodec;", FF_JNI_STATIC_METHOD, OFFSET(create_by_codec_name_id), 1 }, + { "android/media/MediaCodec", "createDecoderByType", "(Ljava/lang/String;)Landroid/media/MediaCodec;", FF_JNI_STATIC_METHOD, OFFSET(create_decoder_by_type_id), 1 }, + { "android/media/MediaCodec", "createEncoderByType", "(Ljava/lang/String;)Landroid/media/MediaCodec;", FF_JNI_STATIC_METHOD, OFFSET(create_encoder_by_type_id), 1 }, - { "android/media/MediaCodec", "getName", "()Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, get_name_id), 1 }, + { "android/media/MediaCodec", "getName", "()Ljava/lang/String;", FF_JNI_METHOD, OFFSET(get_name_id), 1 }, - { "android/media/MediaCodec", "configure", "(Landroid/media/MediaFormat;Landroid/view/Surface;Landroid/media/MediaCrypto;I)V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, configure_id), 1 }, - { "android/media/MediaCodec", "start", "()V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, start_id), 1 }, - { "android/media/MediaCodec", "flush", "()V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, flush_id), 1 }, - { "android/media/MediaCodec", "stop", "()V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, stop_id), 1 }, - { "android/media/MediaCodec", "release", "()V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, release_id), 1 }, + { "android/media/MediaCodec", "configure", "(Landroid/media/MediaFormat;Landroid/view/Surface;Landroid/media/MediaCrypto;I)V", FF_JNI_METHOD, OFFSET(configure_id), 1 }, + { "android/media/MediaCodec", "start", "()V", FF_JNI_METHOD, OFFSET(start_id), 1 }, + { "android/media/MediaCodec", "flush", "()V", FF_JNI_METHOD, OFFSET(flush_id), 1 }, + { "android/media/MediaCodec", "stop", "()V", FF_JNI_METHOD, OFFSET(stop_id), 1 }, + { "android/media/MediaCodec", "release", "()V", FF_JNI_METHOD, OFFSET(release_id), 1 }, - { "android/media/MediaCodec", "getOutputFormat", "()Landroid/media/MediaFormat;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, get_output_format_id), 1 }, + { "android/media/MediaCodec", "getOutputFormat", "()Landroid/media/MediaFormat;", FF_JNI_METHOD, OFFSET(get_output_format_id), 1 }, - { "android/media/MediaCodec", "dequeueInputBuffer", "(J)I", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, dequeue_input_buffer_id), 1 }, - { "android/media/MediaCodec", "queueInputBuffer", "(IIIJI)V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, queue_input_buffer_id), 1 }, - { "android/media/MediaCodec", "getInputBuffer", "(I)Ljava/nio/ByteBuffer;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, get_input_buffer_id), 0 }, - { "android/media/MediaCodec", "getInputBuffers", "()[Ljava/nio/ByteBuffer;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, get_input_buffers_id), 1 }, + { "android/media/MediaCodec", "dequeueInputBuffer", "(J)I", FF_JNI_METHOD, OFFSET(dequeue_input_buffer_id), 1 }, + { "android/media/MediaCodec", "queueInputBuffer", "(IIIJI)V", FF_JNI_METHOD, OFFSET(queue_input_buffer_id), 1 }, + { "android/media/MediaCodec", "getInputBuffer", "(I)Ljava/nio/ByteBuffer;", FF_JNI_METHOD, OFFSET(get_input_buffer_id), 0 }, + { "android/media/MediaCodec", "getInputBuffers", "()[Ljava/nio/ByteBuffer;", FF_JNI_METHOD, OFFSET(get_input_buffers_id), 1 }, - { "android/media/MediaCodec", "dequeueOutputBuffer", "(Landroid/media/MediaCodec$BufferInfo;J)I", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, dequeue_output_buffer_id), 1 }, - { "android/media/MediaCodec", "getOutputBuffer", "(I)Ljava/nio/ByteBuffer;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, get_output_buffer_id), 0 }, - { "android/media/MediaCodec", "getOutputBuffers", "()[Ljava/nio/ByteBuffer;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, get_output_buffers_id), 1 }, - { "android/media/MediaCodec", "releaseOutputBuffer", "(IZ)V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, release_output_buffer_id), 1 }, - { "android/media/MediaCodec", "releaseOutputBuffer", "(IJ)V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, release_output_buffer_at_time_id), 0 }, + { "android/media/MediaCodec", "dequeueOutputBuffer", "(Landroid/media/MediaCodec$BufferInfo;J)I", FF_JNI_METHOD, OFFSET(dequeue_output_buffer_id), 1 }, + { "android/media/MediaCodec", "getOutputBuffer", "(I)Ljava/nio/ByteBuffer;", FF_JNI_METHOD, OFFSET(get_output_buffer_id), 0 }, + { "android/media/MediaCodec", "getOutputBuffers", "()[Ljava/nio/ByteBuffer;", FF_JNI_METHOD, OFFSET(get_output_buffers_id), 1 }, + { "android/media/MediaCodec", "releaseOutputBuffer", "(IZ)V", FF_JNI_METHOD, OFFSET(release_output_buffer_id), 1 }, + { "android/media/MediaCodec", "releaseOutputBuffer", "(IJ)V", FF_JNI_METHOD, OFFSET(release_output_buffer_at_time_id), 0 }, - { "android/media/MediaCodec", "setInputSurface", "(Landroid/view/Surface;)V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, set_input_surface_id), 0 }, - { "android/media/MediaCodec", "signalEndOfInputStream", "()V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, signal_end_of_input_stream_id), 0 }, + { "android/media/MediaCodec", "setInputSurface", "(Landroid/view/Surface;)V", FF_JNI_METHOD, OFFSET(set_input_surface_id), 0 }, + { "android/media/MediaCodec", "signalEndOfInputStream", "()V", FF_JNI_METHOD, OFFSET(signal_end_of_input_stream_id), 0 }, - { "android/media/MediaCodec$BufferInfo", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecFields, mediainfo_class), 1 }, + { "android/media/MediaCodec$BufferInfo", NULL, NULL, FF_JNI_CLASS, OFFSET(mediainfo_class), 1 }, - { "android/media/MediaCodec.BufferInfo", "", "()V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecFields, init_id), 1 }, - { "android/media/MediaCodec.BufferInfo", "flags", "I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecFields, flags_id), 1 }, - { "android/media/MediaCodec.BufferInfo", "offset", "I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecFields, offset_id), 1 }, - { "android/media/MediaCodec.BufferInfo", "presentationTimeUs", "J", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecFields, presentation_time_us_id), 1 }, - { "android/media/MediaCodec.BufferInfo", "size", "I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecFields, size_id), 1 }, + { "android/media/MediaCodec.BufferInfo", "", "()V", FF_JNI_METHOD, OFFSET(init_id), 1 }, + { "android/media/MediaCodec.BufferInfo", "flags", "I", FF_JNI_FIELD, OFFSET(flags_id), 1 }, + { "android/media/MediaCodec.BufferInfo", "offset", "I", FF_JNI_FIELD, OFFSET(offset_id), 1 }, + { "android/media/MediaCodec.BufferInfo", "presentationTimeUs", "J", FF_JNI_FIELD, OFFSET(presentation_time_us_id), 1 }, + { "android/media/MediaCodec.BufferInfo", "size", "I", FF_JNI_FIELD, OFFSET(size_id), 1 }, { NULL } }; +#undef OFFSET static const AVClass amediacodec_class = { .class_name = "amediacodec", From patchwork Tue Feb 27 14:50:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 46576 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51b:b0:19e:cdac:8cce with SMTP id gm27csp2044005pzb; Tue, 27 Feb 2024 06:56:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCViUlK229SWXdQbGX9cYoi9FjKOsf5/8TkazDbLyOgDJy2LFsgSgqr1QRu8KbHhFnz/zWBy+RpkgD1z6hciDFlhns2AXhHKJ+9EEg== X-Google-Smtp-Source: AGHT+IHhua721b6VcIjyt+Df2N0M2aIxPCAuM9uU059FYXuxg84gFT148LVgXWsMNV+A0Mep60K+ X-Received: by 2002:a05:6512:3985:b0:512:f892:4985 with SMTP id j5-20020a056512398500b00512f8924985mr5313433lfu.0.1709045818143; Tue, 27 Feb 2024 06:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709045818; cv=none; d=google.com; s=arc-20160816; b=hl+qD5k8Xb7iK1AU1hBJmcS7r+6Q2sxi4eC4vh/+uy1JvvH4T77tcX7UViQjY9tBjk aC1OCf1HeQDAOIhDqHqfwqG1XGAZmb4bzSNf9NQZ2PVRxs3ixcDH976PVO3ZW8xIzi92 SI/uXkZ84vLnemjBQlvO7Dpp6vr/c0kIvrGwyTOkzBXf5/eNK9G18STtYoy9wnXfojSt Lnd3BF5SGyl28DLR8fMVdYRYSqcVpT1+coVZElrClQr/G9FT0FFjSTOxRmOiGyEuF0W2 EDUWqSx7JU/VgxlYGuqb0Lnh/VCmZk3mwR2AYQmDEdWmRj+iVJa/NKDzJwPutvxzN9LH IQCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=pIxgB99eOwL5+uuew2H7uifaqdYTQg81cHpN8nQny8o=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=tPwvmJLoAknTPM9QPbB2yKk8WHWsXInQra47H/X0AOOOC9qeU5Y+1olEmSzXqUAt+X 9n8PVXSx4StYb9ONrkmz9pk3M6yQUffL4e39Uvr2wu9ddfmpR6tlIenYHYqSkc2Tk2kT 3Zb7ktuyVUfxuINtKAJrmYOXtLclbX4M+VIO1CC0WlzoW0w+losvRzLCSonJls3HcqrK ZMjjRdO4hcVv1i4S7+o4QsS2673aOttiMMZLkKaIaJGUO7U9L273hyvq+1rkePV2n3Yo sJcffZBxwhSN9yi+3ECtolYc6pqte/ifAbradWukRbPlTMOv7IOS4GOe/2iXGptZD9ql QyDA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=YcfAb6DJ; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z13-20020a170906714d00b00a3fbd91ee0asi767129ejj.53.2024.02.27.06.56.57; Tue, 27 Feb 2024 06:56:58 -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=@gmail.com header.s=20230601 header.b=YcfAb6DJ; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8404568CCDC; Tue, 27 Feb 2024 16:56:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2BD5168CC1C for ; Tue, 27 Feb 2024 16:56:01 +0200 (EET) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d22b8c6e0dso47692601fa.2 for ; Tue, 27 Feb 2024 06:56:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709045760; x=1709650560; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DDzOVF3maP9Po5HKxlvTyuOnMaRpz7ktNvC2kYuDWn8=; b=YcfAb6DJh7oPL48WAOhXyuyN3QDb/L4bjdBfzdnmYnvhz0+YQUZCqGLGH6qHfQybIw APBWBo/mNZWV//JFpk7oSUCGfT1OvQVv7WzL9rxWAU1PNozqrK7c34nhMlvBLEJVQ/th 3ZICrfwSGvr7D3L3It5LyRKPB80ayjqFw1xakepkuQOaxqcd0no1+FqqvAoBEZ1sstzB MAPrZySjZRmeokeODP6myeifFkFhhkoiYbGy0p7eRIF5cAs1EmUIqrkh3eScEAHzfLbR xo5BdiBsXRMYKttEbssz4Y+PXzkjh5S5ZPT2j+Ssu9Yb/CbahF50Iq97GIFINyL7Tuno ev2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045760; x=1709650560; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DDzOVF3maP9Po5HKxlvTyuOnMaRpz7ktNvC2kYuDWn8=; b=LpSaOg3/AS5QTH/kQ7MIrI7mpwLa5o8BMdNBdS1RrM5UJDzGur4OJ/zV/7F2b/gD6F 3bIutwy7w+ofKwkYGBzAeu70ui477TaFdBfizzKlZWb5Sgzq91y4pvPEOpWSjCqHG68o EzmEjWD0uBMP1MuE+SfRDaa8zfCfgat+1/O2XJ2BaV+3rIYDxttMXeG5EZBIHbo5Oc4l XimISVO3LyO6RrE/9xBVhJLRgcaU0c8t9RC99mER6H4v+TKSg3RS/fdx5lCcVjdPwnaJ W2agBx5bn0NwLXQb7t7Pz2Pz8mMk66Ewo8TKvNfl5k1T9Z+Oa42J2xKkrRhz02TYH7FO J1zg== X-Gm-Message-State: AOJu0YxWxFkBznCGWFZ2knLQJ/62UbtdWAR3nS/lWlEBlSg+Cs5XVwaq ZCnDx/HYW4DrBx3cRGuOpDkNFyT4fT+4+y6l3KoDqSPFs1Vu/Gb62hYj3awW X-Received: by 2002:a05:651c:106a:b0:2d2:a59f:494e with SMTP id y10-20020a05651c106a00b002d2a59f494emr693004ljm.36.1709045760105; Tue, 27 Feb 2024 06:56:00 -0800 (PST) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id o9-20020a5d4a89000000b0033df1dc39f0sm1859627wrq.4.2024.02.27.06.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:55:59 -0800 (PST) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Feb 2024 15:50:42 +0100 Message-ID: <20240227145536.281991-7-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227145536.281991-1-matthieu.bouron@gmail.com> References: <20240213230418.457056-1-matthieu.bouron@gmail.com> <20240227145536.281991-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 6/6] avcodec/mediacodec_wrapper: remove unnecessary NULL checks before calling Delete{Global, Local}Ref() 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: Matthieu Bouron Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: F5Sqp779ActS Delete{Global,Local}Ref already handle NULL. --- libavcodec/mediacodec_wrapper.c | 189 ++++++++------------------------ 1 file changed, 47 insertions(+), 142 deletions(-) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index 78cd28f53d..306359071e 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -549,10 +549,8 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e goto done; } - if (codec_name) { - (*env)->DeleteLocalRef(env, codec_name); - codec_name = NULL; - } + (*env)->DeleteLocalRef(env, codec_name); + codec_name = NULL; /* Skip software decoders */ if ( @@ -616,10 +614,8 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e found_codec = profile == supported_profile; - if (profile_level) { - (*env)->DeleteLocalRef(env, profile_level); - profile_level = NULL; - } + (*env)->DeleteLocalRef(env, profile_level); + profile_level = NULL; if (found_codec) { break; @@ -627,20 +623,14 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e } done_with_type: - if (profile_levels) { - (*env)->DeleteLocalRef(env, profile_levels); - profile_levels = NULL; - } + (*env)->DeleteLocalRef(env, profile_levels); + profile_levels = NULL; - if (capabilities) { - (*env)->DeleteLocalRef(env, capabilities); - capabilities = NULL; - } + (*env)->DeleteLocalRef(env, capabilities); + capabilities = NULL; - if (type) { - (*env)->DeleteLocalRef(env, type); - type = NULL; - } + (*env)->DeleteLocalRef(env, type); + type = NULL; av_freep(&supported_type); @@ -650,15 +640,11 @@ done_with_type: } done_with_info: - if (info) { - (*env)->DeleteLocalRef(env, info); - info = NULL; - } + (*env)->DeleteLocalRef(env, info); + info = NULL; - if (types) { - (*env)->DeleteLocalRef(env, types); - types = NULL; - } + (*env)->DeleteLocalRef(env, types); + types = NULL; if (found_codec) { break; @@ -668,33 +654,13 @@ done_with_info: } done: - if (codec_name) { - (*env)->DeleteLocalRef(env, codec_name); - } - - if (info) { - (*env)->DeleteLocalRef(env, info); - } - - if (type) { - (*env)->DeleteLocalRef(env, type); - } - - if (types) { - (*env)->DeleteLocalRef(env, types); - } - - if (capabilities) { - (*env)->DeleteLocalRef(env, capabilities); - } - - if (profile_level) { - (*env)->DeleteLocalRef(env, profile_level); - } - - if (profile_levels) { - (*env)->DeleteLocalRef(env, profile_levels); - } + (*env)->DeleteLocalRef(env, codec_name); + (*env)->DeleteLocalRef(env, info); + (*env)->DeleteLocalRef(env, type); + (*env)->DeleteLocalRef(env, types); + (*env)->DeleteLocalRef(env, capabilities); + (*env)->DeleteLocalRef(env, profile_level); + (*env)->DeleteLocalRef(env, profile_levels); av_freep(&supported_type); @@ -741,9 +707,7 @@ static FFAMediaFormat *mediaformat_jni_new(void) } fail: - if (object) { - (*env)->DeleteLocalRef(env, object); - } + (*env)->DeleteLocalRef(env, object); if (!format->object) { ff_jni_reset_jfields(env, &format->jfields, jni_amediaformat_mapping, 1, format); @@ -828,9 +792,7 @@ static char* mediaformat_jni_toString(FFAMediaFormat* ctx) ret = ff_jni_jstring_to_utf_chars(env, description, format); fail: - if (description) { - (*env)->DeleteLocalRef(env, description); - } + (*env)->DeleteLocalRef(env, description); return ret; } @@ -867,9 +829,7 @@ static int mediaformat_jni_getInt32(FFAMediaFormat* ctx, const char *name, int32 ret = 1; fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } + (*env)->DeleteLocalRef(env, key); return ret; } @@ -906,9 +866,7 @@ static int mediaformat_jni_getInt64(FFAMediaFormat* ctx, const char *name, int64 ret = 1; fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } + (*env)->DeleteLocalRef(env, key); return ret; } @@ -945,9 +903,7 @@ static int mediaformat_jni_getFloat(FFAMediaFormat* ctx, const char *name, float ret = 1; fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } + (*env)->DeleteLocalRef(env, key); return ret; } @@ -999,13 +955,8 @@ static int mediaformat_jni_getBuffer(FFAMediaFormat* ctx, const char *name, void ret = 1; fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } - - if (result) { - (*env)->DeleteLocalRef(env, result); - } + (*env)->DeleteLocalRef(env, key); + (*env)->DeleteLocalRef(env, result); return ret; } @@ -1049,13 +1000,8 @@ static int mediaformat_jni_getString(FFAMediaFormat* ctx, const char *name, cons ret = 1; fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } - - if (result) { - (*env)->DeleteLocalRef(env, result); - } + (*env)->DeleteLocalRef(env, key); + (*env)->DeleteLocalRef(env, result); return ret; } @@ -1081,9 +1027,7 @@ static void mediaformat_jni_setInt32(FFAMediaFormat* ctx, const char* name, int3 } fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } + (*env)->DeleteLocalRef(env, key); } static void mediaformat_jni_setInt64(FFAMediaFormat* ctx, const char* name, int64_t value) @@ -1107,9 +1051,7 @@ static void mediaformat_jni_setInt64(FFAMediaFormat* ctx, const char* name, int6 } fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } + (*env)->DeleteLocalRef(env, key); } static void mediaformat_jni_setFloat(FFAMediaFormat* ctx, const char* name, float value) @@ -1133,9 +1075,7 @@ static void mediaformat_jni_setFloat(FFAMediaFormat* ctx, const char* name, floa } fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } + (*env)->DeleteLocalRef(env, key); } static void mediaformat_jni_setString(FFAMediaFormat* ctx, const char* name, const char* value) @@ -1165,13 +1105,8 @@ static void mediaformat_jni_setString(FFAMediaFormat* ctx, const char* name, con } fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } - - if (string) { - (*env)->DeleteLocalRef(env, string); - } + (*env)->DeleteLocalRef(env, key); + (*env)->DeleteLocalRef(env, string); } static void mediaformat_jni_setBuffer(FFAMediaFormat* ctx, const char* name, void* data, size_t size) @@ -1213,13 +1148,8 @@ static void mediaformat_jni_setBuffer(FFAMediaFormat* ctx, const char* name, voi } fail: - if (key) { - (*env)->DeleteLocalRef(env, key); - } - - if (buffer) { - (*env)->DeleteLocalRef(env, buffer); - } + (*env)->DeleteLocalRef(env, key); + (*env)->DeleteLocalRef(env, buffer); } static int codec_init_static_fields(FFAMediaCodecJni *codec) @@ -1352,26 +1282,13 @@ static inline FFAMediaCodec *codec_create(int method, const char *arg) ret = 0; fail: - if (jarg) { - (*env)->DeleteLocalRef(env, jarg); - } - - if (object) { - (*env)->DeleteLocalRef(env, object); - } - - if (buffer_info) { - (*env)->DeleteLocalRef(env, buffer_info); - } + (*env)->DeleteLocalRef(env, jarg); + (*env)->DeleteLocalRef(env, object); + (*env)->DeleteLocalRef(env, buffer_info); if (ret < 0) { - if (codec->object) { - (*env)->DeleteGlobalRef(env, codec->object); - } - - if (codec->buffer_info) { - (*env)->DeleteGlobalRef(env, codec->buffer_info); - } + (*env)->DeleteGlobalRef(env, codec->object); + (*env)->DeleteGlobalRef(env, codec->buffer_info); ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec); av_freep(&codec); @@ -1692,13 +1609,8 @@ static uint8_t* mediacodec_jni_getInputBuffer(FFAMediaCodec* ctx, size_t idx, si ret = (*env)->GetDirectBufferAddress(env, buffer); *out_size = (*env)->GetDirectBufferCapacity(env, buffer); fail: - if (buffer) { - (*env)->DeleteLocalRef(env, buffer); - } - - if (input_buffers) { - (*env)->DeleteLocalRef(env, input_buffers); - } + (*env)->DeleteLocalRef(env, buffer); + (*env)->DeleteLocalRef(env, input_buffers); return ret; } @@ -1740,13 +1652,8 @@ static uint8_t* mediacodec_jni_getOutputBuffer(FFAMediaCodec* ctx, size_t idx, s ret = (*env)->GetDirectBufferAddress(env, buffer); *out_size = (*env)->GetDirectBufferCapacity(env, buffer); fail: - if (buffer) { - (*env)->DeleteLocalRef(env, buffer); - } - - if (output_buffers) { - (*env)->DeleteLocalRef(env, output_buffers); - } + (*env)->DeleteLocalRef(env, buffer); + (*env)->DeleteLocalRef(env, output_buffers); return ret; } @@ -1768,9 +1675,7 @@ static FFAMediaFormat* mediacodec_jni_getOutputFormat(FFAMediaCodec* ctx) ret = mediaformat_jni_newFromObject(mediaformat); fail: - if (mediaformat) { - (*env)->DeleteLocalRef(env, mediaformat); - } + (*env)->DeleteLocalRef(env, mediaformat); return ret; }