From patchwork Wed Nov 6 12:33:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 52614 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2fe5:b0:4a6:1c7:11b7 with SMTP id kw5csp617812vqb; Wed, 6 Nov 2024 04:39:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXt6U6BUPa/6JnNw3R9ZOLtMTjVmqoLYYq5So3D+DwdgOwcZm/NOdzEVzeBylIqHaa9Ku/UuGI8FOUqTAJGe0R4@gmail.com X-Google-Smtp-Source: AGHT+IGg8i3Z9thZC/EF5kVLoLf9+6PtSXr4UNzvToqJG8wU9xmw5OfWDzWPUq2r56zjrM+7tdqU X-Received: by 2002:a05:6402:2682:b0:5cb:67a8:cf0a with SMTP id 4fb4d7f45d1cf-5cbbf87519cmr12873177a12.2.1730896748709; Wed, 06 Nov 2024 04:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1730896748; cv=none; d=google.com; s=arc-20240605; b=lGcDG3uPG82oJI/WzKPKDJbGyaG6lXqVshdgZSAo4SE/iJCuC/6lRTZszrGvxn7i4k jysQ7IkV7XY2uTJ6TwkRvfGJ1TVyEpj9fv7e63S9DHte1Pbyd58aUGGOomaOs/nkCqa7 Req8LpP1WEkWg1VgN3uvcxD2iXRfGfMQlm4X14wkfTR7ePEcB8dWQ9PJrxY2QKsLUsaL TLZMUBvS1I0XEfezrKAF+hVKi1G7Srw2RGMwCsSJFtqkc9pZOSaIMyzqXxHw8GDEKXSN ir8xEsHtMYeclWlO5U8gdUnsMHJNgHA4oN8cZJkYqFJGx9lQZgm8zt0ynjFPj51dq6Bh nTJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:date:to:from:message-id :dkim-signature:delivered-to; bh=/IF9Gkuz0rdrSVEjE/FeVxwBad8mGc1n6B0OVbWpkhM=; fh=HnHYuZ9XgUo86ZRXTLWWmQxhslYEI9B9taZ5X1DLFfc=; b=kUjwwiLCOn2P9agjNgRm5N5Q/a9io6iPRPfjuRwcYjbLU9DrvqAfE6ccQZbvcD/YLC kiCkCBWdjJqlR2hy1SrNyJIVmdQ+s9qw5lswIf3DpkrXsj/9pGdL9Q/ftuWvcQVL0Ojv V3P1RJxkg/wMpdcgRxSK6A8obERLKdskykouAxZVc3Iq1pt4xBkAAGjNKQjDsxLhNlIf cICrB1XtydUjpSxL7qNInpFmuLTIaFZeoAcP8j8cAOl8JdkFmv1lL2j4DVYYL6p3mKr1 OOqzSc+aE4rl/LWGrIgeRaoVZouyB3sS3VYaVC4LCBC9SG8LnUzd3fw0tO0Wyk4nHDV0 VsTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=JDiND+5w; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5cee6aff5efsi2748615a12.232.2024.11.06.04.39.08; Wed, 06 Nov 2024 04:39:08 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=JDiND+5w; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C42F968DDAE; Wed, 6 Nov 2024 14:33:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-192.mail.qq.com (out203-205-221-192.mail.qq.com [203.205.221.192]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9DDB168DDAE for ; Wed, 6 Nov 2024 14:33:14 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1730896386; bh=pkXdjljJzHlnJrwhQ2bumvNneTsAWvIeMglWF1U3UuQ=; h=From:To:Cc:Subject:Date; b=JDiND+5wWn557Bt8IcVsiYhY1kv1EoSlaj+AmbZ1GP+cZS1DQeG+dt4XttHKTYNXX Z+NtsKLZJHnXziw9dQWsefdxed27gJS8gRxt/OL41d1yKcm9NUEB8eMqw36pafkoW3 +sXG1AQxtAvt/SZ9VCr4qebrByT0na8NVED8RxFc= Received: from ZHILIZHAO-MB1.tencent.com ([59.37.125.101]) by newxmesmtplogicsvrszb21-0.qq.com (NewEsmtp) with SMTP id 8458C695; Wed, 06 Nov 2024 20:33:05 +0800 X-QQ-mid: xmsmtpt1730896385tgad1reeo Message-ID: X-QQ-XMAILINFO: OATpkVjS499upLUs5s4W2f8569iLmDx9ka4hPmZAkTSS+BL+ADxaoRm2LkdaiQ H8C6jlVl51ImJE6a1acfulA8FQBhXmLCbtz+9iG/VPUn9WdpX2eKMCrK2Pmhkg+mmD/EI71S8/RA seGXjNV8RYPWg0qaJIZIqITYneZZuSHDzUn5p9jQIC7ONEUCug+g8hxPyrSP8hke1CRVpQWkVHOG RdPw1XMzNq2E1p6gTUbodcTZYqocucKb+s6x6IZD3TyM9/URD4pc+JtW9LU4LbNWLCKkZc7UcSih Pkvm4rKWWVK6ahRj/GvG9QnkiMrjgbsWoXer6pfLVh14K1gNmeG1fiUfHt5DpsGbgI840FNZZB69 eQMloe4OalBYcV9cOrs4mAj1xBV44HAde6jXPzboo/vgKzeK0Ne4Cfsw3bw930H3kehlJTolDImU dq4RBj9PBixkeb5ZMj3S7X7fvHZ+K3NMPCPUAdLGTpB/YQ8adEB+jCrhk2nbFyfRiKYmunAFfJmf edEpsyOO6HqCy7Fud6QpHby/ciWRq1wMHJpLFwkw2CCwgHYFDtKAs19d8lxuuH8N4QbdXOnkOfj7 Y428vckasEB/gJzhns7TF3412FsreVzWR1nkDpObH8Evho7qwDmIYpYlyXJrCLsehVeN40oA1fZc JqN39d8CkuU2k8RjiruekXPOb+NCR2BRRh0D8bRp0cN5qqCLvfG4OuBOGCI+OLMY22ThlowbxZjH 21e8P0uvGBvna4r8+drKHyEyyJSqzfdCzfY9LESrfBGvT4ZorlueEtf5fLBCObjyVDyNfXaKTmUB gYkvxAnwUudpIXHYDp/Sb0TrTJGIHmRvHZiUNlCZJfh5x8p9T4XQJW0r7WnJuSNTM18c8gHHAx9T EHGsw/wj3jWVEUDrUIFCd+xOKtJ+Oo6KX7F/qlhbP44PqgWtuo6vj63vbIXJpRDC3WR0KrJtaxR2 PdZ0BvhTJbgBWq5hEk1OJ6YTN+5L4I3t7WzDEC8crtLe+DG5ZJ300jL6UHXoq1W2lpTq2P29omSD 37CtXNa0HpVcpiaPJzGApE7Qx1DhQ24+TtwQt7Mw== X-QQ-XMRINFO: OD9hHCdaPRBwq3WW+NvGbIU= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Nov 2024 20:33:04 +0800 X-OQ-MSGID: <20241106123304.17794-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/mediacodecdec: Add operating_rate option 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: srxZCImznxoi From: Zhao Zhili The codec wants to know whether the usecase is realtime playback or full-speed transcoding, or playback at a higher speed. The codec runs faster when operating_rate higher than framerate. --- libavcodec/mediacodecdec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index cc55b306bd..4937828f21 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -57,6 +57,8 @@ typedef struct MediaCodecH264DecContext { int amlogic_mpeg2_api23_workaround; int use_ndk_codec; + // Ref. MediaFormat KEY_OPERATING_RATE + int operating_rate; } MediaCodecH264DecContext; static av_cold int mediacodec_decode_close(AVCodecContext *avctx) @@ -441,6 +443,8 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx) ff_AMediaFormat_setInt32(format, "channel-count", avctx->ch_layout.nb_channels); ff_AMediaFormat_setInt32(format, "sample-rate", avctx->sample_rate); } + if (s->operating_rate > 0) + ff_AMediaFormat_setInt32(format, "operating-rate", s->operating_rate); s->ctx = av_mallocz(sizeof(*s->ctx)); if (!s->ctx) { @@ -599,6 +603,8 @@ static const AVOption ff_mediacodec_vdec_options[] = { OFFSET(delay_flush), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VD }, { "ndk_codec", "Use MediaCodec from NDK", OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VD }, + { "operating_rate", "The desired operating rate that the codec will need to operate at, zero for unspecified", + OFFSET(operating_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VD }, { NULL } }; @@ -662,6 +668,8 @@ DECLARE_MEDIACODEC_VDEC(av1, "AV1", AV_CODEC_ID_AV1, NULL) static const AVOption ff_mediacodec_adec_options[] = { { "ndk_codec", "Use MediaCodec from NDK", OFFSET(use_ndk_codec), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, AD }, + { "operating_rate", "The desired operating rate that the codec will need to operate at, zero for unspecified", + OFFSET(operating_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AD }, { NULL } };