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 BCCB84ADB0 for ; Wed, 22 Oct 2025 13:05:49 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'wnO0oE1/nW+xFvXNhD77/rxlX/r/SgtX+iyFt62iP3U=', expected b'tf8CS5ehRaPapUWY2PeSON9aRHhmUDd46D16zaSORRo=')) header.d=niedermayer.cc header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1761138337; h=date : to : message-id : references : mime-version : in-reply-to : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : from; bh=SL01ZmCWgLbuLSFhhudigviMGF2OkV67xCRIGKA0obI=; b=cjgnR0Sewf4cWqkPzu6Yms9xsOmn6fmS8AcEuIl0D4cC2VqsqDyI2SbF5C/Dgg/mk/2e6 cwcZvJ/LSQiRCnHLOOzxtrCa4mrp9kSL69s/+LmIN3Sy/O+sVsJQotwUjsNBDv4VoATUXRc 6lZs3tz8yi6kSSHFZGu6aKWgo8kSNPtnsojYVXooy/Do1rsAe9WrQaJ17k8g99jHaAzrsl4 r16R7GqnKf0W5NOq9mAkc9mgP4gf3yZgxDtze8W2PwHb34qz5n+ftdtCsTbwRrFLQiEe6Bb URu08QpMk1NkIKAZUMU0jhDWxoOvKk7VMzfb9f7hy7uxi7xzY3Y8HuQc7RBQ== Received: from [172.19.0.2] (unknown [172.19.0.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id B1F2668F590; Wed, 22 Oct 2025 16:05:37 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1761138335; b=NuARmOK8YmtqzpHLDOS7ZhC+oXfP3hm5Vv2nqTZJnXzIdJoox+zVpVdrn8Fu+vEQYueuJ +2MY5wX8gLhv1uqjSWE13X/SEIu8hqkEZXtFoTJDHcLcNMThRFeKR+uRiqXrGPDeQQtp8Iy vxSYnHvu8HhBB4FiMsQxGMrYZnsdW6LLpKRNbpcSdhGVfBOjLk7fantmubpz8jZx/UOpGpr IA0IDXeyvfHPVgDTQ64iKA4obLAY0mSNjmcPIxp1gCtLa9APeHpDttUmmqMsJp36iA6dJbR /alVT7VTLBVB8SfWnThsB+51hp7cJlj+FGZOpMJlORaObVKyjvUUYS6IvfUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1761138335; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=wnO0oE1/nW+xFvXNhD77/rxlX/r/SgtX+iyFt62iP3U=; b=RK1k2XVbMuhuItlxRT0CPLGo0b6OhLLuEmf+auDmmcfJb+UaqjoTsFb0Oi02RGY4ksW0r zmh984+bdsmckO6gQ0GMJlCDG46DJ+uTxWfyCUta0GMwHZvXK+EObUokJiYHg4voRdSlllx FZnjAgIm3zOtGS6MDHjvFyucuGpSJ7GQINulEE/XDICDTsS1xYCY5jt/deSdu5iLEF4i6XS Be3d2z7g1JNnfF4bkq881nCS2n9AV7eSblmFdODI7rDniNUPA9ozbxlX+GawA8djkX3Q6uQ iFiokKbQXNyi/on7KO8RDGD4DbEpXVSqRjPl+nIoqwFbR6FIRG3VGfoHmhMw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=niedermayer.cc; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=niedermayer.cc; arc=none (Message is not ARC signed); dmarc=none 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 6334C68F57A for ; Wed, 22 Oct 2025 16:05:22 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id A5FA81F47E for ; Wed, 22 Oct 2025 13:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1761138321; 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=tf8CS5ehRaPapUWY2PeSON9aRHhmUDd46D16zaSORRo=; b=HrA9BlZSNMLjXGCXaqi3yRb3FeRqAF4eyXm27SqWyubDepaZMy9Wtos2KoBiUU0eOZoslO 0DL9hNnBtjNcf3WtIDKXdBRegppbjWkw2ZNOhT0Vh3y5DUIUM/EJ3s6pFXbDzeAMKCs8ER h1CDVrkGC8KkEhDC6QdwK5MoPxnBkq3qAydDa/AuCGsd/1mmH9kmwaHo02q15Nl28ECks3 NsEafUWX8i06VAN5EZU4cgjd6w79fqZZtNwb2T5zAK5/ASz2pDjGQMt6vjQ2AhtnsnWJ5f JJJxyhIs84arpEMSzAwcIRMuUGR8Dg99f/231tXVvGPq46iL/h8Q4hL7r2UueQ== Date: Wed, 22 Oct 2025 15:05:20 +0200 To: FFmpeg development discussions and patches Message-ID: References: <23234a7ec4715e7df0c9c4e5b2ad9556a98d6823.camel@haerdin.se> MIME-Version: 1.0 In-Reply-To: <23234a7ec4715e7df0c9c4e5b2ad9556a98d6823.camel@haerdin.se> X-GND-Sasl: michael@niedermayer.cc Message-ID-Hash: XEZDLXLCNXPOH4RVSHNLF334ZMZNH4YX X-Message-ID-Hash: XEZDLXLCNXPOH4RVSHNLF334ZMZNH4YX X-MailFrom: SRS0=1JUI=47=niedermayer.cc=michael@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] Re: [RFC] C++ List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michael Niedermayer via ffmpeg-devel Cc: Michael Niedermayer Content-Type: multipart/mixed; boundary="===============3091857685931525489==" Archived-At: List-Archive: List-Post: --===============3091857685931525489== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gruTCklnkf6oatYF" Content-Disposition: inline --gruTCklnkf6oatYF Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 20, 2025 at 07:50:33PM +0200, Tomas H=E4rdin via ffmpeg-devel w= rote: > Hi >=20 > I'm writing this email to get a feel for how everyone feels about > making more use of C++ in the codebase. I am only proposing using C++ > *internally*, and only where it makes sense. I am not suggesting a > "move" to C++, merely using features already present in the compilers > we target: gcc, clang and cl. The impedance mismatch should therefore > be small, and any missing compiler features should be caught by FATE. >=20 > Currently C++ use is quite limited in this project, but I see no reason > why this should be the case. doc/faq.texi makes mention of Linux' > reasons for avoiding C++, but FFmpeg is not Linux. For us ABI stability > and performance are the biggest issues. Stability can be ensured by > sticking with C for the API and disabling exceptions (or marking > relevant functions as noexcept). Performance may benefit in some cases. > This would have to be tested. Again, the most performance critical > parts can be kept as C (and asm). >=20 > My main motivation is to be able to use STL, which would simplify > string handling and memory management, and give us access to its data > structures. Manual memory management has its place, especially in lavc. > In lavf less so. RAII would do wonders in de-gotofying error handling. > Features like std::filesystem, std::chrono, std::thread etc abstract > away many OS particularities. Thorough STL-ification would render parts > of lavu obsolete. avstring.*, bprintf.* and tree.* come to mind. This > would have security benefits. Another reason is stronger typing, which > tends to reveal bugs. >=20 > I've targeted mxfdec.c as a proof-of-concept. See attached patch, which > compiles and passes fate-mxf. It is partly inspired by our decklink > binding. Particularly notable is the ability to resolve MXF structs > into MXFMetadataSetType at compile time, as well as resolving strong > references in a more type safe manner. This revealed an issue in > mxf_parse_structural_metadata() where MXFStructuralComponent* was > blindly cast to MXFTimecodeComponent*, which could cause code further > down to interpret the latter as the former, which is a not so obvious > bug that wouldn't be caught without this stronger typing. >=20 > I've not made use of STL in the attached patch because that requires > linking with libstdc++, which I couldn't be arsed to do. One practical > example where STL would come in handy is for my work on segmented > indexes. Specifically std::map and std::lower_bound. Various tables in > mxfdec.c could also be targets for turning into std::map or even > std::unordered_map. A quick experiment with callgrind suggests > mxf_read_header() might be speed up slightly with such a change. >=20 > Details like which version of C++ to use could be agreed on later if > people feel this is a good idea. Personally I favor using the most > recent version that our compiler suite supports. Lately I've been using > C++20 with icx (Intel's compiler) which has been quite pleasant. One difference that favors lower level languages is that with high level languages one looses sight of the cost of operations Teh closer you are to the implementation of a data structure, like if you are on the team of people who developed or maintains it. The more likely you are also aware of its cost or one of the reviewer would spot you doing a O(n^2) operation as if its O(1) thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Some people wanted to paint the bikeshed green, some blue and some pink. People argued and fought, when they finally agreed, only rust was left. --gruTCklnkf6oatYF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaPjWjAAKCRBhHseHBAsP q9CFAJ9Pp5ElEUVTkGfGDf4hLmsxkQ6j/QCgmB9QvZkJLbu1f8t8S+nOFFDAAGk= =5ba9 -----END PGP SIGNATURE----- --gruTCklnkf6oatYF-- --===============3091857685931525489== 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 To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org --===============3091857685931525489==--