From patchwork Sun Mar 17 22:28:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 47146 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp700349pzb; Sun, 17 Mar 2024 15:31:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUVvNSTbrf+fZRIYgcCNhdSmYaXOnpOd2QwOnhjS+8E1kD12/+1j0BdwOUCQCl+HJQUnsjGpo3vyAPp7hLvenIxAQJsdb7YOhGK9g== X-Google-Smtp-Source: AGHT+IFzLxt9CcxAETAGTB0pHAsILPciZUCcIXZcdfc3aPAMx/cBJCSUnflWo4YazRlOloUwEvYd X-Received: by 2002:a05:6402:36f:b0:565:983d:7bbb with SMTP id s15-20020a056402036f00b00565983d7bbbmr5832536edw.14.1710714689769; Sun, 17 Mar 2024 15:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710714689; cv=none; d=google.com; s=arc-20160816; b=Wdtbi3Rea/HaquVvkvqXBaE/9bxlWQdfjS2YVd1mpXg3bjtOSaSH5GPk8vDyTMFvsb VtOYNFgDsvXZ5YtNa/KhR69V2BJepXfLUPg43PUqVAmpwo9Y5hFzJvLv3MKa9E5X2uM8 6OMMvDki9dRBhTQsdNjhheTR8GjL8MUU2c74g9gqfafZhe7L8bPBLhZHvtzF4ZYM+cBQ 7dD3u2HW+bHqwYFxEBH3yuR51dRYqHenWDq2laUEvJZIRht35MhR/ry1QxREV+0b4jQA PBNWftX/rI5dGqmQTKhR2Z79al8rG/jd1eGAHqG/+pU8pxn5c10KsMzCQxxK4QiH2lob 7uuQ== 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=9U5eMHymiaArnzB/I5wT7Sz1TjGYNMK1AbYW0iiByJs=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=BHdFnxgHKUvHq5JG7RdJYVYPtgAG4hw+oNFTpC9XVG248tMIpC/SzFuhpAUePKS7ad rQe/9vO1vipb62nTJri+RsgiwQQW3WfLp182ZyUme/Y7VhhFlv+JSncVqdwKZSnp1VOk C9Em1c5YIKhlL2Nw2F0Xk8YVjuHu5fx/+U4fLa7s9elOXDMFALPjN9pqPA7JfuXYpiiW hyoovrt4RJtvD5iFKkzLXVTGd2y2bIedJ84psHY6asF/QYBrhNgILiK3s1d603lQOkv5 3hlbuys2+FVb7Fzz2m++1KpUOVPrNXYdpW97vK/3cSdm5gsa8e2c9rDpDRFX46+x6zKF KO6w==; 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=nsBuqlqB; 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 b14-20020a0564021f0e00b00568f3cca3b8si626809edb.648.2024.03.17.15.31.29; Sun, 17 Mar 2024 15:31:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=nsBuqlqB; 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 9510568D20A; Mon, 18 Mar 2024 00:31:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B4D2268D1A6 for ; Mon, 18 Mar 2024 00:31:08 +0200 (EET) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-41412fe2609so31055e9.1 for ; Sun, 17 Mar 2024 15:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710714668; x=1711319468; 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=feZ6gpg0EDinKRjrxdqS51T6+YVT8WtqBVi2y06yVYs=; b=nsBuqlqBUGQp6Kn/ZEHkOlJGfeyAAltfb9HowB1FDo6KIG4mCQrLDgR6kutUtdUNqp JatWz3gMIHVm1sSGe/Y0TVV7c9w3vu/QN6ODKWSn3Y15YW+4ot5YD5xjZ9c+SG1UT+LW R5UHvI7xCeGvSBIW5ep+cjZnsUByP19N95G7CYkc7nG1Au5u85H9PkU7n2juX7yC4Tsm 1GY9nnQvIQhsXCVHk+9v5RKCZ1KED3W8S+0usr43Iv5RfivhyI/Mby6GDVxCyRwt6P7G HjkVuAKMTyRtvfkr4czEy6RrI7HjYfp8eBHxXrt1/J5GMqqFXNBq21tg7U7w1A9Osjqq aJ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710714668; x=1711319468; 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=feZ6gpg0EDinKRjrxdqS51T6+YVT8WtqBVi2y06yVYs=; b=IowTIEJFqXq1I06l+xS1QYFWpnizi0hef14nNidAWlTO2pH5ECv4vr9HbrFvZVHLg9 iW+2T1tsC+GaOpIWeAN+51upF7NgF5N4yG/fdiXNgET951VGQW2u42SUIeKYPOQlVV77 QotAiEuXnEdd8tMi2fgGeKoYUTsnZ5tIfeBD+STX6bw1P8AJwoiTe2MRDrUotn/FAaH+ NlZQ0QhazscId98UqESZ9TmQ8OKJ6iI4UrzxQEXSUdcSVh/zuM5jfIliG4mrd+kvFf9e XmJ5mEdLZ8GBDKuIOQoACt5DleHoDMMi4sIryIR79UN36JS2FbFyMnbGg80cvT0y4C5m CbLg== X-Gm-Message-State: AOJu0Yz5Sq3UK0sTii01Vjxz8KC3jDJ8meXShDMkhebVuTFrBSMbNfrs LiD2GCOaaajU7I3x4M2KaFRr/nazp0q+8Sm1SrnuocwPKDUItNCDJGGoSAvj X-Received: by 2002:a05:600c:45c6:b0:414:8e5:91f5 with SMTP id s6-20020a05600c45c600b0041408e591f5mr3322996wmo.30.1710714667704; Sun, 17 Mar 2024 15:31:07 -0700 (PDT) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b00413f3b16a26sm12183682wmq.35.2024.03.17.15.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 15:31:07 -0700 (PDT) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 23:28:32 +0100 Message-ID: <20240317223102.49414-2-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317223102.49414-1-matthieu.bouron@gmail.com> References: <20240227145536.281991-1-matthieu.bouron@gmail.com> <20240317223102.49414-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 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: UxB1NYiW2qaS This will allow users to pass the Android ApplicationContext which is mandatory to retrieve the ContentResolver responsible to resolve/open Android content-uri. --- doc/APIchanges | 3 +++ libavcodec/jni.c | 42 ++++++++++++++++++++++++++++++++++++++++++ libavcodec/jni.h | 17 +++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index a44c8e4f10..ae1868047e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-03-xx - xxxxxxxxxx - lavc 61.2.100 - jni.h + Add av_jni_set_android_app_ctx() and av_jni_get_android_app_ctx(). + 2024-03-xx - xxxxxxxxxx - lavu 59.2.100 - channel_layout.h Add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL. diff --git a/libavcodec/jni.c b/libavcodec/jni.c index ae6490de9d..cfe95bd1ec 100644 --- a/libavcodec/jni.c +++ b/libavcodec/jni.c @@ -77,3 +77,45 @@ void *av_jni_get_java_vm(void *log_ctx) } #endif + +#if defined(__ANDROID__) + +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) +{ +#if CONFIG_JNI + JNIEnv *env = ff_jni_get_env(log_ctx); + 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; +#else + return AVERROR(ENOSYS); +#endif +} + +void *av_jni_get_android_app_ctx(void) +{ +#if CONFIG_JNI + void *ctx; + + pthread_mutex_lock(&lock); + ctx = android_app_ctx; + pthread_mutex_unlock(&lock); + + return ctx; +#else + return NULL; +#endif +} + +#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 Sun Mar 17 22:28:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 47147 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp700398pzb; Sun, 17 Mar 2024 15:31:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTdGkJZDeOU6sK21bcW6DT1MB+3rcX8ulLiIaioAHyPflaXevEQjJ7sp5oMNKC05U/HeIt1tbnwbZq7zLGC1Z8NH+L1qvxINr4Ng== X-Google-Smtp-Source: AGHT+IECLLZoJxvdzHKfI14hm4LWosgR6frh/eJQr99qYZc1NzTPI72vHz/xX7zH9D2MSMCoN0fY X-Received: by 2002:a05:651c:486:b0:2d4:764f:87d9 with SMTP id s6-20020a05651c048600b002d4764f87d9mr5978725ljc.32.1710714698618; Sun, 17 Mar 2024 15:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710714698; cv=none; d=google.com; s=arc-20160816; b=ZxPGT1RAoF9ibQMC34kL1+LYwRUCfPbrMI9q4xl/85XIxrw+5+Ecw3jJ98SbSmaP14 dYlaeqULZY/GfcZdidIQyziNoAkMw704hjDNIO6gzWncV9wN9hqbBqgK+7ZSc5nzTvRh jooGcwIqa+hluFeO07IlGup7UjUjhrXR4ORT2ccqMktZnWPvD7cyrfM5bihFGdLy+BXR wSSJ/mgo3pW8bJA8QnfQfyhSB3KHwV+P7gNIZQGcXPsK6bu6Ls3uCGB3rmgzkk2DqMM1 dGUR+GBcPDC2Lri3t3THgjFU4PsHUbg7WgluSHresaJyJ8PBI/ydsogwjznP6YxYbV/S F+Wg== 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=2mm+xQCIguuHCHRHOGxf8AaWJw3q4oeSFHftiohN5NE=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=Cn15iUfl5vI6BkiUnsMMFCR/MZcElz4VTdpPVMvMl1TY5I+wpKPlXRURLXHliz37eb nQIryVk+kpN1Dpty4QjCgBePE+B71Oh+aVLEPtXNNftO3g1NIeV0VCPRuxF0zIk/Y0W7 cnLCkQpYpB67lYCZ+WOT5BrsYXHJ2dKVw+g+gLKu236BhlV9XrN7mlh+6MMQwYqhYfUy 9F/oScxQwCKui7me1m941Ij8uo6bAEPMSaTZ2pVjDP/kOiv4rZlurZZsYWiOo+mHfsQh xuhFpkEtPumKVSoG+mKuerpCAsYmz8uNVbbBPswieOlOQHq+1dvATMFkkATPYHJmYVFc kUaA==; 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=c7vKcS2o; 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 z8-20020a2e3508000000b002d4716c9adasi2180230ljz.366.2024.03.17.15.31.38; Sun, 17 Mar 2024 15:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=c7vKcS2o; 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 AE47768D210; Mon, 18 Mar 2024 00:31:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE48A68D1A6 for ; Mon, 18 Mar 2024 00:31:08 +0200 (EET) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-41411421113so1101125e9.1 for ; Sun, 17 Mar 2024 15:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710714668; x=1711319468; 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=gZf6z6BHrUpnvV3QsnUsc/zl83hGRjMwleCAjtI45ZU=; b=c7vKcS2oc6pCuHaOaXzj5eBeXdVTnslHu1M5UDRKiGF8oKur3Q3ICH8jM+v1RBPVge nhUNjx6AfwrAj5051jlJ70KCbrI6yqGq0GMxgPILIF2wIlqMSNafHFsM5b4Nnkfxjdl3 WwMIxMen/2+O3wnIz+SRQjwwhFizcm/8PCcAUoAJJu7oreYvOU46KTqUgFqINOq0Cejr Ooy/CV9SCugWH9VfaloYuNVSP4W9eYyYDtrXPyi22Re1ta5VDBK2KBXc6lf133DvQ7n6 Dk3uEE1vR/k6WCX4pbWOeDVob8nigeBxIeRTq6AYPh0qtjVJq+M5/rX41tcbOw0m381g 5Q+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710714668; x=1711319468; 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=gZf6z6BHrUpnvV3QsnUsc/zl83hGRjMwleCAjtI45ZU=; b=D7pJk+KNtZLAd+BqNFkiQ5EhUy/rEnXcWoe09byG6GXnNDBbMsa1z8hrqmBwVUfdOF 1icvViJbyZlk25x6lWIp9vPCU7bUv4RVC9NxwVUf/gv7NU48XmjboSJc6DeoPxRmdmyv pFyN5HeV24H9Fwpv+Ve/vJHXMpok6AhCbYAC9KgrAW4YuiSLKv8dn7HA00Sy2WhLenqg 9Qx6Wvc188jByeEbb63b3TnIF11b3J4GIE/TSRyRxk00VFlHt5gfMy/8RUtsZbFkuszN 9JUfL7ej01qYppsB3Jn8tfygrOVfndqfLPtfmq2riLwOwc+pgYz2DjKXxI/nZuAyDXYM hV9A== X-Gm-Message-State: AOJu0YywOFfzjCnDzNSs8VzKQwbcPx0z2F97XpGVNG++PQvgUhSqP37g ZV6tIxbXXPbC9kQ5kMyUDhTmrWB7nVBpm/qf8/GZ6ZCRv3hidJ3GIi3T1/aJ X-Received: by 2002:a05:600c:4f46:b0:414:b14:5654 with SMTP id m6-20020a05600c4f4600b004140b145654mr2211348wmq.21.1710714668153; Sun, 17 Mar 2024 15:31:08 -0700 (PDT) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b00413f3b16a26sm12183682wmq.35.2024.03.17.15.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 15:31:07 -0700 (PDT) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 23:28:33 +0100 Message-ID: <20240317223102.49414-3-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317223102.49414-1-matthieu.bouron@gmail.com> References: <20240227145536.281991-1-matthieu.bouron@gmail.com> <20240317223102.49414-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 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: jXMhci0oq9di Handles Android content-uri starting with content://. --- configure | 2 + libavcodec/jni.c | 1 + libavformat/Makefile | 1 + libavformat/file.c | 160 ++++++++++++++++++++++++++++++++++++++++ libavformat/protocols.c | 1 + 5 files changed, 165 insertions(+) diff --git a/configure b/configure index 2b4c4ec9a2..9ef432fddf 100755 --- a/configure +++ b/configure @@ -3656,6 +3656,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/libavcodec/jni.c b/libavcodec/jni.c index cfe95bd1ec..1193c608c3 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) diff --git a/libavformat/Makefile b/libavformat/Makefile index 94a949f555..44aa485029 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -658,6 +658,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..dd5819c06f 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,142 @@ const URLProtocol ff_fd_protocol = { }; #endif /* CONFIG_FD_PROTOCOL */ + +#if CONFIG_ANDROID_CONTENT_PROTOCOL + +typedef 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; +} JFields; + +#define OFFSET(x) offsetof(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; + struct stat st; + const char *mode_str = "r"; + + JNIEnv *env; + 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 (fstat(fd, &st) < 0) { + close(fd); + return AVERROR(errno); + } + + c->fd = fd; + h->is_streamed = !(S_ISREG(st.st_mode) || S_ISBLK(st.st_mode)); + +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 Sun Mar 17 22:28:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 47148 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp700428pzb; Sun, 17 Mar 2024 15:31:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLHaOzsjSXszW12tCjlbLqWYORZsUME3nDRYEozixOx7w0nNNu/Iy2ydDhJvSQxiayPqK59prDGsBYVHEP9s+GHkmY5kCYHH499Q== X-Google-Smtp-Source: AGHT+IGXMUZBpdtz0d3NTbMHnwWMMuA9eNlxasA4UlU1BWRT6zVgWBClRO/gbODE7nRYkSwZJCtF X-Received: by 2002:a05:6402:1f03:b0:568:b4c8:9af with SMTP id b3-20020a0564021f0300b00568b4c809afmr5153966edb.17.1710714706352; Sun, 17 Mar 2024 15:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710714706; cv=none; d=google.com; s=arc-20160816; b=kuRGIUPcpbq+WPVTlN2ahZDejKTIYw5fq+ZIEJuYpqsXDzFztH7oW0tSqecsYuDPIM lm+S8Rz6oBb+A+zUx7w2iiJXodkrQT03+yLjZfS1RJ7rDpTfAooPORZceMVEbR54Flic lMxdR3bXet7Ncs7h25oMnAmfgs0H3UplXn7BiDvPm8YMv+uLn9HfjOwcRaVazFUzW7P9 GOv2JGVvHMDmi7RRSAYqONJA9xptexPPmTY48o22qrZPNT5Y3D2aDydX3nbjfwZyM4QM fMI8aqCP4gt4RHyQXr3ozKorlVqCifa0Wdg4HqWOHqpncKsDQ1ehb13Tfx8AdTaxRMLa 2QAQ== 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=Xh0Dr27yn06ZK2XlFDAap85AVnHMJcu+bxCCH1jif14=; fh=bsOL+ub9JEnfNazRgCdgjxJAChubFVskZxBzYcxeDLU=; b=HeXkFhC1eCtKyznKg1iFs7y1ID+Xyhh7yFaosw1lK6Zyhe3wiFp/yNVEfjPhm9U5Q9 pdaQdTbNx7BL8LzGVSWY3z0WIZIs5cUDiwjtePSxw+R9WDik5imh6GJXCNrxouv3aux/ +J13RerN2IqAduYdwzgeoAy4Yobb5F1hLEKWz/UW7uzEcKoa1w+Ru9YCjZps92BHYy2A dSpJOk0/+DwodtQ2v0s47ZKrq9DKFOjsfVh8KSK6i+iZfgE6tTNFhNEDeiWVChVX1ayW jdJITt6gKlxkOB6ZKY90OxFaCNnLy/cFXe3BoQjSk0hiNDNiDxM0r1Hc5X/hVFUuR8IO Z8Fw==; 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=Fhb5ppC1; 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 el4-20020a056402360400b00568915686bdsi3807645edb.491.2024.03.17.15.31.46; Sun, 17 Mar 2024 15:31:46 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Fhb5ppC1; 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 C4B2468D206; Mon, 18 Mar 2024 00:31:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 79E7F68D1A6 for ; Mon, 18 Mar 2024 00:31:09 +0200 (EET) Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-512e39226efso3160223e87.0 for ; Sun, 17 Mar 2024 15:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710714669; x=1711319469; 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=iWCJmFh2RkzyDimSfcoMRDKy/ibxxAu0pD09y0hgV+U=; b=Fhb5ppC1a2TSDPT/aHJEboSEktkimB4s7YooqKbMgSbb3FG1th3YqpkUTAHYLvc99x dziLXVWgkoAVvK7qba0vFk2Kh+2jC2dCrq56jexnIaJtAKyVBeDSDKes3TbqddcKtaJi xcufUJ9sIHMN3NL0kGzr/iggIIfL5bsxo1Ba9eeaeDj/PWgZ3gIA3NeqmB+L802gj19A CL2ThNUPM4+eAR6ZSCq4WQhbLTcpciUpvUSc/KkyTgfZB7j6pNl8ExNPCV0SJVU0qXn1 D1Sj00vLLX0s9fTZ5SWq6RZQ9PQ9XjJwiNHQ11ChXsuIq85EPsnVUuQRCMgRdozgx2lH oxwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710714669; x=1711319469; 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=iWCJmFh2RkzyDimSfcoMRDKy/ibxxAu0pD09y0hgV+U=; b=CL/m3cqz87NgHEEOSnnkBb/qShRwN4eWo7VCdUTfKxNuFgvT+/4xZ2NEWtSVia7o3G u++65g6ll4WUaReS8f++VWflcvsbQr0foA3t3skqrVz9tr00WTQZPZqqEGLDZpLhbIkA m6+2ndx/NWs2DIb6Amz5HldkmVnD3lW2PE7rc0/T933GiPtGA3d3b6hto/BtDyqVQtA4 pUIpO2I1xlbJXZEDlwvKLy8KfONbSSVFOIJtT6ZIcQPdEGq+KQjMQdcEqBlfFwN7clo5 EnS/KYZkKoslELXmBLW4JSHVmV9YXAeHYyct9mYIDpR7Sz5xwZZwZrbaeEl+gLBzTpiP b0Zg== X-Gm-Message-State: AOJu0YzLMDphUIZazoANYTgtSW67sfSjDHeKVa8//rF+MmZzjSp4PTOf pkzseybu6iMdVyfVOI8/TfLTE1EssJB9074Qi0NxpI3Oeiq5z1QvipoqDh5V X-Received: by 2002:a19:2d1c:0:b0:513:b134:ed1a with SMTP id k28-20020a192d1c000000b00513b134ed1amr6469400lfj.2.1710714668554; Sun, 17 Mar 2024 15:31:08 -0700 (PDT) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b00413f3b16a26sm12183682wmq.35.2024.03.17.15.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 15:31:08 -0700 (PDT) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 23:28:34 +0100 Message-ID: <20240317223102.49414-4-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317223102.49414-1-matthieu.bouron@gmail.com> References: <20240227145536.281991-1-matthieu.bouron@gmail.com> <20240317223102.49414-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 3/6] avcodec/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: vAqnIAeXdrTG --- libavcodec/ffjni.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/ffjni.h b/libavcodec/ffjni.h index 6027bac0ab..d1e86f8329 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 Sun Mar 17 22:28:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 47149 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp700469pzb; Sun, 17 Mar 2024 15:31:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8EIaxX21JJc/TvS4lbL3wPuaPtcuTYcI3qEwG1gvksLN3ZoSH5YIdJdN+i0zRe6nwrlJvV5thZ0vjXDK8YanRsiPJbZ5MkfKYhA== X-Google-Smtp-Source: AGHT+IE0O5hikYGZoYQOUktr8r8FBHZlDk/dBGuxUtzmpcYdBGEBKbZ8FiO5I4VT+6+ryZzi0t6w X-Received: by 2002:a19:5e12:0:b0:513:c16d:f192 with SMTP id s18-20020a195e12000000b00513c16df192mr6201249lfb.13.1710714715840; Sun, 17 Mar 2024 15:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710714715; cv=none; d=google.com; s=arc-20160816; b=aSsvS40RMdP/l0bwGgxbKo0nuUXkVF8eXEmmcFEzPi0ZfQVvj/r9BDMsSLws9QjthV kRknirDEUG6MuvRAg0QIuXP8iKHqhrkfA1UtH38N6bVgMH97AHcSa8UnnKfkIg/y6Mw8 O+e6XMTP+15Nai7MdX/FWLyzaj2ttZ/h8KmyA6NGzGP2MC0n75Bg7wi0ZoMKqCQisjHO qAIA/ejtt0atLQ24zdYK9zBkNuJeDz02RiBO2OGvas3Qj3cT3jH7st/SiC52L1GMIRbh av2XuVRIW3disXnmW8FQiHHwwjwSuBU1tMOBaox0kODrWsDYbquDZpgEah5kt5mk87j/ uqXg== 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=lzLdX34LZrn7+MDbvlAnBuVp8Sqp1ng9+BblLYa/4CZ10vrqyqXk7dUjFno7UgQvLm CWlAocRmVXjnsrc/Ri0gJ6rPC7+griDmaOeV0aDQ535Z2AeOeRQ3n2ba4L/08CaMw10g +gIKF4XBkpqUfFrEHkR0I1b6d3I4wdJtxi2B0gxq2G5JkZbNjgsR49K0LJuvHdUZl39a 2nm3uYXain17g3QY+PZ9QWACse3nNuCJrgoy6aaegwtoO4iTD+/B4hKq0ft3z3iIZoAq DmgY1eYPdZqqGF7x7pS6XcD0KdZkxE//AJ5LJi7hP+rOY/QL8JdGtJ+MDCp3hV0d+oFf okog==; 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=dCQ4KOBa; 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 y4-20020a056512044400b00513d89c9afdsi1782302lfk.220.2024.03.17.15.31.55; Sun, 17 Mar 2024 15:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=dCQ4KOBa; 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 E3B9D68D212; Mon, 18 Mar 2024 00:31:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A3C1268D1EB for ; Mon, 18 Mar 2024 00:31:09 +0200 (EET) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-41412fe2609so31245e9.1 for ; Sun, 17 Mar 2024 15:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710714669; x=1711319469; 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=dCQ4KOBarFPk/Fuyd0fINQk6/9KFSbI1yebmAKHY7r9QZEGuDY1Ctmhld7Ocmz7iV1 gizv3ZORQ1ILDYDLeJ9iV3goSa5kg+TOjpS8wlrcPkF8napGxIeZLP9owhsZHOWRZXCX 6GOVyoSfFji4KxA9nibubV821TU7w5HLpIdVU3UueMtn8hv8muMuZ0DiuQeCBO+EGY7Q FqGhnajD/f9CyasdVEb7pCQhu+mPlFzYMI+o8+BQI0tw6iIfjkxoKYdS1eP3A+je8G0W 88GsSucFGC2gJcteybfXotxVM+KRpM0qhqKa93X297yj6GC/LGKkjwkv1AnlJ5to/fBv 1b8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710714669; x=1711319469; 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=pILW1oCjebu70WWUecBim2Q6BcA5yXsD5Y/+YyJqKj2hQe4GE7Phnxx5xXWe/HdfpI NTpi0gOrTwslDUpoOt7a05hdKtQJMqrG2nYFybQcMoIpdfn3Wjfdytr0NpfDXQyovl12 G34hixAKDTIfYcERxJeH6EuFBiL2tLkMvOGMF6KtgXAO+6X26G43j5oi9uVItmYddh1B IHOZPIKcgsPDFS0tGMPmkzXmTS1PI3OJpdCkhQ03YcUZmVzCIRQf3ou4CwBjrQtUAV6S TsJ6pEOrqzj83exB+ruVBoIgpVqxRqCz5thaG1bCHS5DBf1swy2oFgxh1jVIMVOIKU1P QsfQ== X-Gm-Message-State: AOJu0YwLZq37WRA2o5IDkYcT/BRD+STPaLg3+8Dahw8dsIwgnIhi1/e8 /ZyM3MW8XxgVMuHvdXj8AGwWaMU68u3kB6JAd5rKFGX0S3wVIZ0ICU3LSeHB X-Received: by 2002:a05:600c:198a:b0:414:85f:1dcb with SMTP id t10-20020a05600c198a00b00414085f1dcbmr3069609wmq.1.1710714668952; Sun, 17 Mar 2024 15:31:08 -0700 (PDT) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b00413f3b16a26sm12183682wmq.35.2024.03.17.15.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 15:31:08 -0700 (PDT) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 23:28:35 +0100 Message-ID: <20240317223102.49414-5-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317223102.49414-1-matthieu.bouron@gmail.com> References: <20240227145536.281991-1-matthieu.bouron@gmail.com> <20240317223102.49414-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 4/6] avcodec/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: RsNOw2v88Pi+ 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 Sun Mar 17 22:28:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 47150 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp700516pzb; Sun, 17 Mar 2024 15:32:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/CkphNAF3vSLNTQ+JFrFGH/2LvREeVfL1X22FdlT7M88K9pZh9GwW4UozFPp+18gAQth7pm6knMsITg5mhIsWUVRBBW0+KlgvEg== X-Google-Smtp-Source: AGHT+IHr0hXOH2rbb57XPvdQULKf3N/LDOdyK9i290UA1n+7KHJxItLDwKTvnQD/WV+x9sZJizFc X-Received: by 2002:a05:6402:e0b:b0:567:ef00:bdbe with SMTP id h11-20020a0564020e0b00b00567ef00bdbemr9251263edh.33.1710714724286; Sun, 17 Mar 2024 15:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710714724; cv=none; d=google.com; s=arc-20160816; b=hMNVs8V1pYWcDH6B5Ssbw44Cb85yigs9pMz5Tp9/3OJ+NtmWGQlm7ySqF3rYv9tsFk ezIgZqaR7Gg3WJR8QohvJBzyA3Pi0c/zOfq4Ai9uNb8fwraZ2w3yLGW7y2D5YtOyrS5Y Ax6OxdP75RM/UcizkNRDcshupm7cil2tRxfJH5upiBR0JISSQG9tfiv7ymwDDmD7zKhy XGrQvr1+GAmKnwz+HVpadFCvOpO+mrzjLM9tuQiu+5VcaB/3viveYd0C7lwcCAesYeVO MGBfX0uQDKmolrpZX3lmKKnWTCUBtmpPeK2v7kEcuqh2HKA5UGoQm1X1Pg33DQ6lFvto sZVQ== 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=JLjbDHggfkXlDDnaYwd3GW/v/pgigc6iy16QmAFm8RcDNd2X7r5W6sj99QhQc50HzJ t/7roBi4ibAWxvDWPXWXkcfuiHRsCX0XYwP1arHnTvqmqQTeAbae/nkA1fea6r7k6a3d EPMqr4PrN8IRpWCoezwLDJXO1SV2YjZHAdrgDgxbNa1p1YGJGC+V+xPPwUqjC0GhEYUh xhizwLeK/uNITDBO5YMJDK2eRzPeEsxmrCJAOk9kjHHPwZWgcqKQ67vinLq4U6jmCs5e j+FlzP3WShhpQpLY32veuCWyT5AORzLvGWCRMxqFOX9WEiYPY4KOrb/agtgXMdYO+WDI GYRw==; 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=Kg9M1OTG; 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 fj6-20020a0564022b8600b00564d2bf234dsi3873755edb.253.2024.03.17.15.32.03; Sun, 17 Mar 2024 15:32:04 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Kg9M1OTG; 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 0336D68D221; Mon, 18 Mar 2024 00:31:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 49EBC68D1CD for ; Mon, 18 Mar 2024 00:31:10 +0200 (EET) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4141129bf14so1160755e9.3 for ; Sun, 17 Mar 2024 15:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710714669; x=1711319469; 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=Kg9M1OTGkDbBaFpYMWSZSY+YDX1isB/8ZcENWTcBZ7qCck1Ex6M6hLcpc4gmC2JL9C Tz7n097obufYrliSDERGYJpN9dLJU9rpkjjs9WeBkknr3IWhn+t6KuxD7yaY/SSBNlLa djShqvyapbq0nWdsXR1300MIyWDaiAoIrBkwuq6gTiAgSbOPoeVNwi0lQ2+9cxlbdJyZ K6sXCpLQMy/xySscraJuOt3AAimqIToDLrf9ncwK8u3NGa713MmsncYPJlUA8Riv/Au9 rfLCKr4DRhvrpqn6eMO0sCqb5BfMFtVDviJjqGCfp707gCMkih3fnb3c8JV5JLg1iuhh 5hkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710714669; x=1711319469; 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=kIdVXky3r3GIopxPcSGq4Orq9GRDZEk3gVlmTxHVB+Hj/86gsVrcKDFOY2mcElsVlb oit2Q2/vJMg62/d7jor3YHEoCH8HHGEsytAwfd5thQRoOJRkdwuXZ+EQpFxzMX83hNl1 XbTxGbr50l9HowHEy+E+CNDpmYCD3z4sth52UBkNlp6wCkiiF2SoSF0nmRgegRcMSZOj 430+wZZJ+GISAzw6yA1yx9QhaEi0GOCDR9MKLNEiiaeER32bslF9sbuEPoY+X5Tph/QP Um3xm3Mm+AEm+ik20/2mVZ5mt6TK8piaPRFzuEwZDjzwVzuKSaCI0GQ+jfL98dAxRW5J 4DGQ== X-Gm-Message-State: AOJu0YyofX27v99j6XNOVdUTW4mEUlZTGacU0WYKLmz5MhhtO39CZMVB hzpwj+/McLM4X211xs13jg3pJX2b5INsLKeM0SZM7spJcylMJUaPI1xIWZJG X-Received: by 2002:a05:600c:314e:b0:414:630:2691 with SMTP id h14-20020a05600c314e00b0041406302691mr3714599wmo.6.1710714669377; Sun, 17 Mar 2024 15:31:09 -0700 (PDT) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b00413f3b16a26sm12183682wmq.35.2024.03.17.15.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 15:31:09 -0700 (PDT) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 23:28:36 +0100 Message-ID: <20240317223102.49414-6-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317223102.49414-1-matthieu.bouron@gmail.com> References: <20240227145536.281991-1-matthieu.bouron@gmail.com> <20240317223102.49414-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 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: YXhQHOqK1a4j 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 Sun Mar 17 22:28: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: 47151 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp700558pzb; Sun, 17 Mar 2024 15:32:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVaDGh+ILZWW4pSTF2fielHneTeynOdiEpzTllUuMtrfW+E9omqTORniALYj+kLkJidk2JUyTqahX7YUlDz2rzTDZ1X+JrTTJi1lQ== X-Google-Smtp-Source: AGHT+IE3V5vsd4j3VbUUCV1NkutygXbdnOdHbGDWZAoqrVJaI5Gh0Mmo9DNzaDpGY5mYhDxCRsRQ X-Received: by 2002:a17:907:7797:b0:a46:485a:3163 with SMTP id ky23-20020a170907779700b00a46485a3163mr6649128ejc.6.1710714733884; Sun, 17 Mar 2024 15:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710714733; cv=none; d=google.com; s=arc-20160816; b=YuS4Ja/aN0MpfbHYvGVxSk2DVLZ0ql9tNq8x859AAGsEy+jOGv+CRUL5F3PKejASME YVSR3vlXxGlkAn9gMeTNK73TyEg7JTZGQFWLeV3E2h518OMYmQ7rIqdNAG12sSsFwVfZ 8EVA2DnB5TuCiHJjQGPL4EZcLOP86DTIfDOU9naHYrRJqXoTb89opJG8ZJW5tN0szsFz +XZ1QZIUWyPYr9bJ5Je2WA6yYwwyNNi5oeAr2jH0hXpBBzE927BTnKdVnoIwBTvjgu1Q sKZUbTlt7omw7EjNAN96Gh79RAL59Z+tz7BHpegTH71iTE8OpI1pFXqihyZllYT4aW1G 8r6A== 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=dtKqgfJNs1qpajPX/7jOubl/hVHxwoTpP08RvyT5c8UyFoeAjQDB7dWPFiCrYW48z5 mfi6gG+36QimWRSTGw7bKvi3Il18Y3znDCPIRfir0K0vhP00uvvcblNvV9cC3+R3XFJw /uewv2DasFi7hS7eDeUv9X3cxHbHkqjHN/R1Ws18zPAslVypcWrJYh27RCk0zhiYGvY1 PRHaj0JvscR8E9KcFGu0QhClaBbOWo9hO30b3q2aBCha63qFqzCYqQyMeRApMPEgXB4R NXgR8Q0UO1g1YnMmBfSFl7jvppJZEwGOhxfCGu3HvxNS+aFUMfez0mZicKhUjzKMo2cy Sp7Q==; 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=LvBKUlNm; 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 h7-20020a17090619c700b00a4535a7db44si3815370ejd.51.2024.03.17.15.32.13; Sun, 17 Mar 2024 15:32:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=LvBKUlNm; 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 172AC68D226; Mon, 18 Mar 2024 00:31:22 +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 8296B68D1CD for ; Mon, 18 Mar 2024 00:31:10 +0200 (EET) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-33ec8f13c62so2728435f8f.0 for ; Sun, 17 Mar 2024 15:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710714670; x=1711319470; 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=LvBKUlNm9Bbaja0bOu+h3XZjgIGWixZ1sQOgPddekNjAm8HKR5DbRjz53QWH3TbgKW G+A/2yvRkAxdJliVayaTGOGFmWbiID8QSHMjh5JyhR6b6khklPyHniALcSl/xvllykEq ISbCMoOkWcn4d9g29hQSnPpb0P28+XAms3tL99VA+FMnnj4dZMwpQiMQRDKn6tSMpd1K dvzg0kp8SmfuMYn360Y3KSRr0sWJj4EGcX0ty0sGPHRyaWZCGxPa0/nQmM93TW9Ug9ej jz9zkipIbz2IMTK230dPuOhzAwjrp3ZnPAxQRghLdEjjGP8Q1imA2kMis6FE3WwkCG46 AVIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710714670; x=1711319470; 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=ak/81PkG7lIgp8r4cqHnGyovE4oqPk57pUGqgRuVCbzWkRGyfVI6QeMgsOhSS77VR6 Q48kKxVjyn8Owpo118zlEDXmR02InHF4e5d0LwHlRGKvlmfX/f2ScOFNom3wbrCcIKI1 o1Tl/Rj7o4q7lxE3EUbYhtWjwUwZNNNYik8f9pa4hzkqvI6xFO4cWwmbnbjL7O4MouKh Y9YdQTF6PjqhGgSkeA1ymw1sJ7CyhvS3avwppSbUbKhi3QtHe7x/fXBQescz+06+RQXR wd27s/solrGwUa8ghhXOSyxXxvtDM35fZQzPJRbZ7pyErySKxVXY6Z3extwjsv+K3L+4 iWow== X-Gm-Message-State: AOJu0Yx5kmOS9KYysXOFTxtCJtEF9tQ2mh7TF/VMlilsH0Uii/qEM7ZS 5sR2JAC+kP52PdLXlGF1CLgy7OmWNA5Rsp9gHIa4fPjufMFFFHQca+tD0Zzo X-Received: by 2002:a05:6000:1c6:b0:33d:f60e:5c6c with SMTP id t6-20020a05600001c600b0033df60e5c6cmr6446116wrx.53.1710714669763; Sun, 17 Mar 2024 15:31:09 -0700 (PDT) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b00413f3b16a26sm12183682wmq.35.2024.03.17.15.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 15:31:09 -0700 (PDT) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 23:28:37 +0100 Message-ID: <20240317223102.49414-7-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317223102.49414-1-matthieu.bouron@gmail.com> References: <20240227145536.281991-1-matthieu.bouron@gmail.com> <20240317223102.49414-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 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: OOJq83pdSOnC 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; }