]> git.sesse.net Git - ffmpeg/blobdiff - doc/developer.texi
vf_delogo: switch to an AVOptions-based system.
[ffmpeg] / doc / developer.texi
index fed28cdbcd4357ce0c5120f6a12aa86591f59700..3d574e4428fa903fc0933911414a1c596d2ebd58 100644 (file)
@@ -27,7 +27,7 @@ audio or video streams.
 
 Shared libraries should be used whenever is possible in order to reduce
 the effort distributors have to pour to support programs and to ensure
-only the public api is used.
+only the public API is used.
 
 You can use Libav in your commercial program, but you must abide to the
 license, LGPL or GPL depending on the specific features used, please refer
@@ -178,30 +178,40 @@ GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
 @end itemize
 
 @subsection Naming conventions
-All names are using underscores (_), not CamelCase. For example,
-@samp{avfilter_get_video_buffer} is a valid function name and
-@samp{AVFilterGetVideo} is not. The only exception from this are structure
-names; they should always be in the CamelCase
+All names should be composed with underscores (_), not CamelCase. For example,
+@samp{avfilter_get_video_buffer} is an acceptable function name and
+@samp{AVFilterGetVideo} is not. The only exception are structure
+names; they should always be CamelCase.
 
-There are following conventions for naming variables and functions:
+There are the following conventions for naming variables and functions:
 @itemize @bullet
 @item
 For local variables no prefix is required.
 @item
-For variables and functions declared as @code{static} no prefixes are required.
+For file-scope variables and functions declared as @code{static}, no prefix
+is required.
 @item
-For variables and functions used internally by the library, @code{ff_} prefix
-should be used.
-For example, @samp{ff_w64_demuxer}.
+For variables and functions visible outside of file scope, but only used
+internally by a library, an @code{ff_} prefix should be used,
+e.g. @samp{ff_w64_demuxer}.
 @item
-For variables and functions used internally across multiple libraries, use
-@code{avpriv_}. For example, @samp{avpriv_aac_parse_header}.
+For variables and functions visible outside of file scope, used internally
+across multiple libraries, use @code{avpriv_} as prefix, for example,
+@samp{avpriv_aac_parse_header}.
 @item
-For exported names, each library has its own prefixes. Just check the existing
-code and name accordingly.
+For externally visible symbols, each library has its own prefix. Check
+the existing code and choose names accordingly.
 @end itemize
 
-@subsection Miscellanous conventions
+Furthermore, name space reserved for the system should not be invaded.
+Identifiers ending in @code{_t} are reserved by
+@url{http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html#tag_02_02_02, POSIX}.
+Also avoid names starting with @code{__} or @code{_} followed by an uppercase
+letter as they are reserved by the C standard. Names starting with @code{_}
+are reserved at the file level and may not be used for externally visible
+symbols. If in doubt, just avoid names starting with @code{_} altogether.
+
+@subsection Miscellaneous conventions
 @itemize @bullet
 @item
 fprintf and printf are forbidden in libavformat and libavcodec,
@@ -215,14 +225,14 @@ should also be avoided if they don't make the code easier to understand.
 In order to configure Vim to follow Libav formatting conventions, paste
 the following snippet into your @file{.vimrc}:
 @example
-" indentation rules for libav: 4 spaces, no tabs
+" Indentation rules for Libav: 4 spaces, no tabs.
 set expandtab
 set shiftwidth=4
 set softtabstop=4
 set cindent
 set cinoptions=(0
-" allow tabs in Makefiles
-autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=8
+" Allow tabs in Makefiles.
+autocmd FileType make,automake set noexpandtab shiftwidth=8 softtabstop=8
 " Trailing whitespace and tabs are forbidden, so highlight them.
 highlight ForbiddenWhitespace ctermbg=red guibg=red
 match ForbiddenWhitespace /\s\+$\|\t/
@@ -235,8 +245,8 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
 (c-add-style "libav"
              '("k&r"
                (c-basic-offset . 4)
-               (indent-tabs-mode nil)
-               (show-trailing-whitespace t)
+               (indent-tabs-mode nil)
+               (show-trailing-whitespace t)
                (c-offsets-alist
                 (statement-cont . (c-lineup-assignments +)))
                )
@@ -248,8 +258,13 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
 
 @enumerate
 @item
-   Contributions should be licensed under the LGPL 2.1, including an
-   "or any later version" clause, or the MIT license.  GPL 2 including
+   Contributions should be licensed under the
+   @uref{http://www.gnu.org/licenses/lgpl-2.1.html, LGPL 2.1},
+   including an "or any later version" clause, or, if you prefer
+   a gift-style license, the
+   @uref{http://www.isc.org/software/license/, ISC} or
+   @uref{http://mit-license.org/, MIT} license.
+   @uref{http://www.gnu.org/licenses/gpl-2.0.html, GPL 2} including
    an "or any later version" clause is also acceptable, but LGPL is
    preferred.
 @item
@@ -265,10 +280,15 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
    in the commit.
 @item
    The commit message should have a short first line in the form of
-   @samp{topic: short description} as header, separated by a newline
-   from the body consting in few lines explaining the reason of the patch.
-   Referring to the issue on the bug tracker does not exempt to report an
-   excerpt of the bug.
+   a @samp{topic: short description} as a header, separated by a newline
+   from the body consisting of an explanation of why the change is necessary.
+   If the commit fixes a known bug on the bug tracker, the commit message
+   should include its bug ID. Referring to the issue on the bug tracker does
+   not exempt you from writing an excerpt of the bug in the commit message.
+   If the patch is a bug fix which should be backported to stable releases,
+   i.e. a non-API/ABI-breaking bug fix, add @code{CC: libav-stable@@libav.org}
+   to the bottom of your commit message, and make sure to CC your patch to
+   this address, too. Some git setups will do this automatically.
 @item
    Work in progress patches should be sent to the mailing list with the [WIP]
    or the [RFC] tag.
@@ -315,7 +335,7 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
 @item
     Never write to unallocated memory, never write over the end of arrays,
     always check values read from some untrusted source before using them
-    as array index or other risky things. Always use valgrind to doublecheck.
+    as array index or other risky things. Always use valgrind to double-check.
 @item
     Remember to check if you need to bump versions for the specific libav
     parts (libavutil, libavcodec, libavformat) you are changing. You need
@@ -341,8 +361,6 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
 
 We think our rules are not too hard. If you have comments, contact us.
 
-Note, some rules were borrowed from the MPlayer project.
-
 @section Submitting patches
 
 First, read the @ref{Coding Rules} above if you did not yet, in particular
@@ -362,12 +380,6 @@ The tool is located in the tools directory.
 Run the @ref{Regression Tests} before submitting a patch in order to verify
 it does not cause unexpected problems.
 
-Patches should be posted as base64 encoded attachments (or any other
-encoding which ensures that the patch will not be trashed during
-transmission) to the
-@uref{https://lists.libav.org/mailman/listinfo/libav-devel, libav-devel}
-mailing list.
-
 It also helps quite a bit if you tell us what the patch does (for example
 'replaces lrint by lrintf'), and why (for example '*BSD isn't C99 compliant
 and has no lrint()'). This kind of explanation should be the body of the
@@ -376,8 +388,12 @@ commit message.
 Also please if you send several patches, send each patch as a separate mail,
 do not attach several unrelated patches to the same mail.
 
-Use @code{git send-email} when possible since it will properly send patches
-without requiring extra care.
+Patches should be posted to the
+@uref{https://lists.libav.org/mailman/listinfo/libav-devel, libav-devel}
+mailing list. Use @code{git send-email} when possible since it will properly
+send patches without requiring extra care. If you cannot, then send patches
+as base64-encoded attachments, so your patch is not trashed during
+transmission.
 
 Your patch will be reviewed on the mailing list. You will likely be asked
 to make some changes and are expected to send in an improved version that
@@ -403,9 +419,11 @@ send a reminder by email. Your patch should eventually be dealt with.
 @item
     Did you register it in @file{allcodecs.c} or @file{allformats.c}?
 @item
-    Did you add the CodecID to @file{avcodec.h}?
+    Did you add the AVCodecID to @file{avcodec.h}?
+    When adding new codec IDs, also add an entry to the codec descriptor
+    list in @file{libavcodec/codec_desc.c}.
 @item
-    If it has a fourcc, did you add it to @file{libavformat/riff.c},
+    If it has a FourCC, did you add it to @file{libavformat/riff.c},
     even if it is only a decoder?
 @item
     Did you add a rule to compile the appropriate files in the Makefile?
@@ -432,9 +450,7 @@ send a reminder by email. Your patch should eventually be dealt with.
 
 @enumerate
 @item
-    Does @code{make fate} pass with the patch applied?
-@item
-    Does @code{make checkheaders} pass with the patch applied?
+    Does @code{make check} pass with the patch applied?
 @item
     Is the patch against latest Libav git master branch?
 @item
@@ -453,8 +469,10 @@ send a reminder by email. Your patch should eventually be dealt with.
     other security issues?
 @item
     Did you test your decoder or demuxer against damaged data? If no, see
-    tools/trasher and the noise bitstream filter. Your decoder or demuxer
-    should not crash or end in a (near) infinite loop when fed damaged data.
+    tools/trasher, the noise bitstream filter, and
+    @uref{http://caca.zoy.org/wiki/zzuf, zzuf}. Your decoder or demuxer
+    should not crash, end in a (near) infinite loop, or allocate ridiculous
+    amounts of memory when fed damaged data.
 @item
     Does the patch not mix functional and cosmetic changes?
 @item
@@ -490,6 +508,10 @@ send a reminder by email. Your patch should eventually be dealt with.
 @item
     Lines with similar content should be aligned vertically when doing so
     improves readability.
+@item
+    Make sure you check the return values of function and return appropriate
+    error codes. Especially memory allocation functions like @code{malloc()}
+    are notoriously left unchecked, which is a serious problem.
 @end enumerate
 
 @section Patch review process
@@ -528,4 +550,131 @@ why the expected result changed.
 
 Please refer to @url{fate.html}.
 
+@subsection Visualizing Test Coverage
+
+The Libav build system allows visualizing the test coverage in an easy
+manner with the coverage tools @code{gcov}/@code{lcov}.  This involves
+the following steps:
+
+@enumerate
+@item
+    Configure to compile with instrumentation enabled:
+    @code{configure --toolchain=gcov}.
+@item
+    Run your test case, either manually or via FATE. This can be either
+    the full FATE regression suite, or any arbitrary invocation of any
+    front-end tool provided by Libav, in any combination.
+@item
+    Run @code{make lcov} to generate coverage data in HTML format.
+@item
+    View @code{lcov/index.html} in your preferred HTML viewer.
+@end enumerate
+
+You can use the command @code{make lcov-reset} to reset the coverage
+measurements. You will need to rerun @code{make lcov} after running a
+new test.
+
+@anchor{Release process}
+@section Release process
+
+Libav maintains a set of @strong{release branches}, which are the
+recommended deliverable for system integrators and distributors (such as
+Linux distributions, etc.). At irregular times, a @strong{release
+manager} prepares, tests and publishes tarballs on the
+@url{http://libav.org} website.
+
+There are two kinds of releases:
+
+@enumerate
+@item
+    @strong{Major releases} always include the latest and greatest
+    features and functionality.
+@item
+    @strong{Point releases} are cut from @strong{release} branches,
+    which are named @code{release/X}, with @code{X} being the release
+    version number.
+@end enumerate
+
+Note that we promise to our users that shared libraries from any Libav
+release never break programs that have been @strong{compiled} against
+previous versions of @strong{the same release series} in any case!
+
+However, from time to time, we do make API changes that require adaptations
+in applications. Such changes are only allowed in (new) major releases and
+require further steps such as bumping library version numbers and/or
+adjustments to the symbol versioning file. Please discuss such changes
+on the @strong{libav-devel} mailing list in time to allow forward planning.
+
+@anchor{Criteria for Point Releases}
+@subsection Criteria for Point Releases
+
+Changes that match the following criteria are valid candidates for
+inclusion into a point release:
+
+@enumerate
+@item
+    Fixes a security issue, preferably identified by a @strong{CVE
+    number} issued by @url{http://cve.mitre.org/}.
+@item
+    Fixes a documented bug in @url{http://bugzilla.libav.org}.
+@item
+    Improves the included documentation.
+@item
+    Retains both source code and binary compatibility with previous
+    point releases of the same release branch.
+@end enumerate
+
+The order for checking the rules is (1 OR 2 OR 3) AND 4.
+
+All Libav developers are welcome to nominate commits that they push to
+@code{master} by mailing the @strong{libav-stable} mailing list. The
+easiest way to do so is to include @code{CC: libav-stable@@libav.org} in
+the commit message.
+
+
+@subsection Release Checklist
+
+The release process involves the following steps:
+
+@enumerate
+@item
+    Ensure that the @file{RELEASE} file contains the version number for
+    the upcoming release.
+@item
+    File a release tracking bug in @url{http://bugzilla.libav.org}. Make
+    sure that the bug has an alias named @code{ReleaseX.Y} for the
+    @code{X.Y} release.
+@item
+    Announce the intent to do a release to the mailing list.
+@item
+    Reassign unresolved blocking bugs from previous release
+    tracking bugs to the new bug.
+@item
+    Review patch nominations that reach the @strong{libav-stable}
+    mailing list, and push patches that fulfill the stable release
+    criteria to the release branch.
+@item
+    Ensure that the FATE regression suite still passes in the release
+    branch on at least @strong{i386} and @strong{amd64}
+    (cf. @ref{Regression Tests}).
+@item
+    Prepare the release tarballs in @code{xz} and @code{gz} formats, and
+    supplementing files that contain @code{md5} and @code{sha1}
+    checksums.
+@item
+    Publish the tarballs at @url{http://libav.org/releases}. Create and
+    push an annotated tag in the form @code{vX}, with @code{X}
+    containing the version number.
+@item
+    Build the tarballs with the Windows binaries, and publish them at
+    @url{http://win32.libav.org/releases}.
+@item
+    Propose and send a patch to the @strong{libav-devel} mailing list
+    with a news entry for the website.
+@item
+    Publish the news entry.
+@item
+    Send announcement to the mailing list.
+@end enumerate
+
 @bye