From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 030D04B76A for ; Mon, 21 Jul 2025 22:26:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 44C7468CB8E; Tue, 22 Jul 2025 01:26:42 +0300 (EEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 76B4468CA4C for ; Tue, 22 Jul 2025 01:26:36 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6DDAB1F68D for ; Mon, 21 Jul 2025 22:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1753136795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FUdMP1UWU3gGD9f34Edvd/FCaFUxeTrBsTNsuRXYJvg=; b=EoiNGP7sOLuDG9xnpYjLu6H5z0nKk4h4bZtxlur7GaxYVecQGlgEwqEKRkZE+rOO7xhnuk ewC5GOMHNtWOwmbRU9d7j4sGzPpc98ZjuukhzAVUdMp0M/EG0vK2sKZ4DVFVldrDdnju0V B3CpxXNvEffymFzmUENCFrw9Z7drnV0uf4/tCg4vG0tCfmqlySAS5mEMyyDCj9p7U6JbKE wVOmW1zS459e+ysCSC/3QNJpLCaa7yUfYcCWaSEJeHp0lu0oRjikI7ZjKCNAF46FvtShJC VYk07q75Vn7OppBea7fy7CkEwzGuqP4HB2y7OJ2KNQVtJFSBvKM849FpSo758w== Date: Tue, 22 Jul 2025 00:26:34 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250721222634.GC29660@pb2> References: <20250719162653.1234750-1-bernat.arlandis@gmail.com> <157575cf-ce2d-4358-922d-1ec0e828fd2b@gmail.com> MIME-Version: 1.0 In-Reply-To: <157575cf-ce2d-4358-922d-1ec0e828fd2b@gmail.com> X-GND-State: clean X-GND-Score: -85 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejfedvjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdludehmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddtudenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepudetvdfhudeuudegudefgfehhfevvdfggfffkefhvdfgvdetffdtjeekheetfeehnecukfhppeeguddrieeirdeihedrudejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeguddrieeirdeihedrudejiedphhgvlhhopehlohgtrghlhhhoshhtpdhmrghilhhfrhhomhepmhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtpdhnsggprhgtphhtthhopedupdhrtghpthhtohepfhhfmhhpvghgqdguvghvvghlsehffhhmphgvghdrohhrgh X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH] libtheoraenc: Add encoding speed level 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 Content-Type: multipart/mixed; boundary="===============4488999940703286639==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4488999940703286639== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="0CtgcDj4H8Wc7M0B" Content-Disposition: inline --0CtgcDj4H8Wc7M0B Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Bernat On Sun, Jul 20, 2025 at 09:15:07PM +0200, Bernat Arlandis wrote: > El 19/7/25 a las 18:26, bernat.arlandis@gmail.com escribi=F3: > > From: Bernat Arlandis > >=20 > > --- > > libavcodec/libtheoraenc.c | 27 +++++++++++++++++++++++++++ > > 1 file changed, 27 insertions(+) > >=20 > > diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c > > index eb94458639..de2b913634 100644 > > --- a/libavcodec/libtheoraenc.c > > +++ b/libavcodec/libtheoraenc.c > > @@ -37,6 +37,7 @@ > > #include "libavutil/pixdesc.h" > > #include "libavutil/log.h" > > #include "libavutil/base64.h" > > +#include "libavutil/opt.h" > > #include "avcodec.h" > > #include "codec_internal.h" > > #include "encode.h" > > @@ -45,6 +46,7 @@ > > #include > > typedef struct TheoraContext { > > + AVClass *av_class; /**< class for AVOptions = */ > > th_enc_ctx *t_state; > > uint8_t *stats; > > int stats_size; > > @@ -52,8 +54,21 @@ typedef struct TheoraContext { > > int uv_hshift; > > int uv_vshift; > > int keyframe_mask; > > + int speed_level; > > } TheoraContext; > > +static const AVOption options[] =3D { > > + { "speed_level", "Sets the encoding speed level", offsetof(TheoraC= ontext, speed_level), AV_OPT_TYPE_INT, { .i64 =3D -1 }, -1, INT_MAX, AV_OPT= _FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, > > + { NULL } > > +}; > > + > > +static const AVClass theora_class =3D { > > + .class_name =3D "libtheora", > > + .item_name =3D av_default_item_name, > > + .option =3D options, > > + .version =3D LIBAVUTIL_VERSION_INT, > > +}; > > + > > /** Concatenate an ogg_packet into the extradata. */ > > static int concatenate_packet(unsigned int* offset, > > AVCodecContext* avc_context, > > @@ -244,6 +259,17 @@ static av_cold int encode_init(AVCodecContext* avc= _context) > > return AVERROR_EXTERNAL; > > } > > + // Set encoding speed level > > + if (h->speed_level !=3D -1) { > > + int max_speed_level; > > + int speed_level =3D h->speed_level; > > + th_encode_ctl(h->t_state, TH_ENCCTL_GET_SPLEVEL_MAX, &max_spee= d_level, sizeof(max_speed_level)); > > + if (speed_level > max_speed_level) { > > + speed_level =3D max_speed_level; > > + } > > + th_encode_ctl(h->t_state, TH_ENCCTL_SET_SPLEVEL, &speed_level,= sizeof(speed_level)); > > + } > > + > > // need to enable 2 pass (via TH_ENCCTL_2PASS_) before encoding h= eaders > > if (avc_context->flags & AV_CODEC_FLAG_PASS1) { > > if ((ret =3D get_stats(avc_context, 0)) < 0) > > @@ -389,6 +415,7 @@ const FFCodec ff_libtheora_encoder =3D { > > .close =3D encode_close, > > FF_CODEC_ENCODE_CB(encode_frame), > > CODEC_PIXFMTS(AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_= YUV444P), > > + .p.priv_class =3D &theora_class, > > .color_ranges =3D AVCOL_RANGE_MPEG, > > .p.wrapper_name =3D "libtheora", > > }; > >=20 > > base-commit: bedfb6eca402037f5cbb115fa767d106b8c14f1c > I've used -1 for the default library value, but there might be a better w= ay > to tell the code to use the default value without exposing this value to = the > user.=A0 I just don't know how. -1 is ok, will apply with speed_level =3D FFMIN(speed_level, max_speed_level); instead of teh if()... thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "Nothing to hide" only works if the folks in power share the values of you and everyone you know entirely and always will -- Tom Scott --0CtgcDj4H8Wc7M0B Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaH6+mgAKCRBhHseHBAsP q9ByAKCF0RBv4TdBVHLLi8czMME7M0TmFQCfSC63bWugvMYjiiCk+YhHgiO3mYA= =SBpM -----END PGP SIGNATURE----- --0CtgcDj4H8Wc7M0B-- --===============4488999940703286639== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============4488999940703286639==--