From patchwork Wed Mar 15 14:07:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40679 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp3453053pzb; Wed, 15 Mar 2023 07:08:11 -0700 (PDT) X-Google-Smtp-Source: AK7set9tzCHGedHtw1lFYE6zOXxcGU8zGGU28aswfFIG7yt/e3oWvo9TYEWNo6r+nQYXftPjGBRi X-Received: by 2002:a50:ee8e:0:b0:4af:7bdc:188e with SMTP id f14-20020a50ee8e000000b004af7bdc188emr2764441edr.16.1678889291140; Wed, 15 Mar 2023 07:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678889291; cv=none; d=google.com; s=arc-20160816; b=juDK/rnCBtv81BzresTp0MlM3SSbeZ0dJsp/BltSICbQAoKYJLr1ij2eoo194zwTBF 8k/mStklLtmoN1AHEuiTmlU8jRmOjPyqt+2CwVKeS0lHUxZCf/xsR6wwu67ltuAMqCim 1C9T9NHQBDf6JbmziEggaJmcQrfCHfC5l6Z4dLOdpWKgn45yfZTgVJH0jt5GhUz/1JFx j3Sfd35tB0Xyi0FiJ5i1WVyd73Wg2YOapKCbcFMR5UoN8fy4yXxKKZhtba3EiDOkVWtb 1JpxmYPWCIRPXLGEggf7UpqDKo5SR8Me5wNPjGqwgrQN5D43uvQ+MDA+OV/1xFS5XNlb msrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=qpdlJBbKhF1enQRpQRHCdySeRH1ptXHdiy7dQ1At/HM=; b=0iMBw+J58koRI1+A2eQjtCtTX+c+HJ7ONDzRc5uwteeE6yHWZzNZ2Z0qmi3hHQbmj8 fAUsdFwT/nLChbNi7slpiHYnAkNt0nung7kfR+r/rQa5tMxW4h9x9IdSoUVwwmSPwFSF xVVF4r3FlKX1zq5cHY7ig7vm8N72qPbqCUlYHbtP26B+4209t+8ShQvjpY8y2zgqNBBA KmnsQVMBtb5H4JZoysE/W/HcwhzHhJzNBLdZTHLrWmakZljAfeC5XHyIUrW7HHgouUay 3gorQ1ZRymhYCxRN8eJgVST0ss9o9gAplPforIoVxzgdpk9DKNayRNH3xIMFXJ2d0ocj LEtg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c6-20020aa7c746000000b004fe95a9e4f6si3523050eds.493.2023.03.15.07.08.10; Wed, 15 Mar 2023 07:08:11 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3608568BD50; Wed, 15 Mar 2023 16:08:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BA41F68B796 for ; Wed, 15 Mar 2023 16:08:00 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 205C02404F5 for ; Wed, 15 Mar 2023 15:08:00 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id dOP0Zbof3tUl for ; Wed, 15 Mar 2023 15:07:59 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 4ACD3240178 for ; Wed, 15 Mar 2023 15:07:59 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BEC5B3A00B6 for ; Wed, 15 Mar 2023 15:07:52 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Mar 2023 15:07:44 +0100 Message-Id: <20230315140746.14692-1-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] doc/developer.texi: document the use of other languages than C 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: E3PWOkXWK7Cy --- doc/developer.texi | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 1275fa4f84..db5afafa4b 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -56,9 +56,9 @@ and should try to fix issues their commit causes. @anchor{Coding Rules} @chapter Coding Rules -@section C language features +@section Language -FFmpeg is programmed in the ISO C99 language, extended with: +FFmpeg is mainly programmed in the ISO C99 language, extended with: @itemize @bullet @item Atomic operations from C11 @file{stdatomic.h}. They are emulated on @@ -83,6 +83,40 @@ complex numbers; mixed statements and declarations. @end itemize +@subsection SIMD/DSP +@anchor{SIMD/DSP} + +As modern compilers are unable to generate efficient SIMD or other +performance-critical DSP code from plain C, handwritten assembly is used. +Usually such code is isolated in a separate function. Then the standard approach +is writing multiple versions of this function – a plain C one that works +everywhere and may also be useful for debugging, and potentially multiple +architecture-specific optimized implementations. Initialization code then +chooses the best available version at runtime and loads it into a function +pointer; the function in question is then always called through this pointer. + +The specific syntax used for writing assembly is: +@itemize @bullet +@item +NASM on x86; + +@item +GAS on ARM. +@end itemize + +@subsection Other languages + +Other languages than C may be used in special cases: +@itemize @bullet +@item +Compiler intrinsics or inline assembly when the code in question cannot be +written in the standard way described in the @ref{SIMD/DSP} section. This +typically applies to code that needs to be inlined. + +@item +Objective-C where required for interacting with macOS-specific interfaces. +@end itemize + @section Code formatting conventions There are the following guidelines regarding the indentation in files: