developer.html 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Created by , GNU Texinfo 7.1.1 -->
  4. <head>
  5. <meta charset="utf-8">
  6. <title>
  7. Developer Documentation
  8. </title>
  9. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  10. <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
  11. <link rel="stylesheet" type="text/css" href="style.min.css">
  12. </head>
  13. <body>
  14. <div class="container">
  15. <h1>
  16. Developer Documentation
  17. </h1>
  18. <a name="SEC_Top"></a>
  19. <div class="element-contents" id="SEC_Contents">
  20. <h2 class="contents-heading">Table of Contents</h2>
  21. <div class="contents">
  22. <ul class="toc-numbered-mark">
  23. <li><a id="toc-Introduction" href="#Introduction">1 Introduction</a></li>
  24. <li><a id="toc-Coding-Rules-1" href="#Coding-Rules-1">2 Coding Rules</a>
  25. <ul class="toc-numbered-mark">
  26. <li><a id="toc-Language" href="#Language">2.1 Language</a>
  27. <ul class="toc-numbered-mark">
  28. <li><a id="toc-SIMD_002fDSP-1" href="#SIMD_002fDSP-1">2.1.1 SIMD/DSP</a></li>
  29. <li><a id="toc-Other-languages" href="#Other-languages">2.1.2 Other languages</a></li>
  30. </ul></li>
  31. <li><a id="toc-Code-formatting-conventions" href="#Code-formatting-conventions">2.2 Code formatting conventions</a>
  32. <ul class="toc-numbered-mark">
  33. <li><a id="toc-Examples" href="#Examples">2.2.1 Examples</a></li>
  34. <li><a id="toc-Vim-configuration" href="#Vim-configuration">2.2.2 Vim configuration</a></li>
  35. <li><a id="toc-Emacs-configuration" href="#Emacs-configuration">2.2.3 Emacs configuration</a></li>
  36. </ul></li>
  37. <li><a id="toc-Comments" href="#Comments">2.3 Comments</a></li>
  38. <li><a id="toc-Naming-conventions-1" href="#Naming-conventions-1">2.4 Naming conventions</a></li>
  39. <li><a id="toc-Miscellaneous-conventions" href="#Miscellaneous-conventions">2.5 Miscellaneous conventions</a></li>
  40. </ul></li>
  41. <li><a id="toc-Development-Policy-1" href="#Development-Policy-1">3 Development Policy</a>
  42. <ul class="toc-numbered-mark">
  43. <li><a id="toc-Code-behaviour" href="#Code-behaviour">3.1 Code behaviour</a></li>
  44. <li><a id="toc-Patches_002fCommitting" href="#Patches_002fCommitting">3.2 Patches/Committing</a></li>
  45. <li><a id="toc-Code" href="#Code">3.3 Code</a></li>
  46. <li><a id="toc-Library-public-interfaces" href="#Library-public-interfaces">3.4 Library public interfaces</a>
  47. <ul class="toc-numbered-mark">
  48. <li><a id="toc-Adding-new-interfaces" href="#Adding-new-interfaces">3.4.1 Adding new interfaces</a></li>
  49. <li><a id="toc-Removing-interfaces-1" href="#Removing-interfaces-1">3.4.2 Removing interfaces</a></li>
  50. <li><a id="toc-Major-version-bumps-1" href="#Major-version-bumps-1">3.4.3 Major version bumps</a></li>
  51. </ul></li>
  52. <li><a id="toc-Documentation_002fOther" href="#Documentation_002fOther">3.5 Documentation/Other</a></li>
  53. </ul></li>
  54. <li><a id="toc-Submitting-patches-1" href="#Submitting-patches-1">4 Submitting patches</a></li>
  55. <li><a id="toc-New-codecs-or-formats-checklist" href="#New-codecs-or-formats-checklist">5 New codecs or formats checklist</a></li>
  56. <li><a id="toc-Patch-submission-checklist" href="#Patch-submission-checklist">6 Patch submission checklist</a></li>
  57. <li><a id="toc-Patch-review-process" href="#Patch-review-process">7 Patch review process</a></li>
  58. <li><a id="toc-Regression-tests-1" href="#Regression-tests-1">8 Regression tests</a>
  59. <ul class="toc-numbered-mark">
  60. <li><a id="toc-Adding-files-to-the-fate_002dsuite-dataset" href="#Adding-files-to-the-fate_002dsuite-dataset">8.1 Adding files to the fate-suite dataset</a></li>
  61. <li><a id="toc-Visualizing-Test-Coverage" href="#Visualizing-Test-Coverage">8.2 Visualizing Test Coverage</a></li>
  62. <li><a id="toc-Using-Valgrind" href="#Using-Valgrind">8.3 Using Valgrind</a></li>
  63. </ul></li>
  64. <li><a id="toc-Maintenance-process" href="#Maintenance-process">9 Maintenance process</a>
  65. <ul class="toc-numbered-mark">
  66. <li><a id="toc-MAINTAINERS-1" href="#MAINTAINERS-1">9.1 MAINTAINERS</a></li>
  67. <li><a id="toc-Becoming-a-maintainer-1" href="#Becoming-a-maintainer-1">9.2 Becoming a maintainer</a></li>
  68. </ul></li>
  69. <li><a id="toc-Release-process-1" href="#Release-process-1">10 Release process</a>
  70. <ul class="toc-numbered-mark">
  71. <li><a id="toc-Criteria-for-Point-Releases-1" href="#Criteria-for-Point-Releases-1">10.1 Criteria for Point Releases</a></li>
  72. <li><a id="toc-Release-Checklist" href="#Release-Checklist">10.2 Release Checklist</a></li>
  73. </ul></li>
  74. </ul>
  75. </div>
  76. </div>
  77. <a name="Introduction"></a>
  78. <h2 class="chapter">1 Introduction<span class="pull-right"><a class="anchor hidden-xs" href="#Introduction" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Introduction" aria-hidden="true">TOC</a></span></h2>
  79. <p>This text is concerned with the development <em class="emph">of</em> FFmpeg itself. Information
  80. on using the FFmpeg libraries in other programs can be found elsewhere, e.g. in:
  81. </p><ul class="itemize mark-bullet">
  82. <li>the installed header files
  83. </li><li><a class="url" href="http://ffmpeg.org/doxygen/trunk/index.html">the Doxygen documentation</a>
  84. generated from the headers
  85. </li><li>the examples under <samp class="file">doc/examples</samp>
  86. </li></ul>
  87. <p>For more detailed legal information about the use of FFmpeg in
  88. external programs read the <samp class="file">LICENSE</samp> file in the source tree and
  89. consult <a class="url" href="https://ffmpeg.org/legal.html">https://ffmpeg.org/legal.html</a>.
  90. </p>
  91. <p>If you modify FFmpeg code for your own use case, you are highly encouraged to
  92. <em class="emph">submit your changes back to us</em>, using this document as a guide. There are
  93. both pragmatic and ideological reasons to do so:
  94. </p><ul class="itemize mark-bullet">
  95. <li>Maintaining external changes to keep up with upstream development is
  96. time-consuming and error-prone. With your code in the main tree, it will be
  97. maintained by FFmpeg developers.
  98. </li><li>FFmpeg developers include leading experts in the field who can find bugs or
  99. design flaws in your code.
  100. </li><li>By supporting the project you find useful you ensure it continues to be
  101. maintained and developed.
  102. </li></ul>
  103. <p>All proposed code changes should be submitted for review to
  104. <a class="url" href="mailto:ffmpeg-devel@ffmpeg.org">the development mailing list</a>, as
  105. described in more detail in the <a class="ref" href="#Submitting-patches">Submitting patches</a> chapter. The code
  106. should comply with the <a class="ref" href="#Development-Policy">Development Policy</a> and follow the <a class="ref" href="#Coding-Rules">Coding Rules</a>.
  107. The developer making the commit and the author are responsible for their changes
  108. and should try to fix issues their commit causes.
  109. </p>
  110. <a class="anchor" id="Coding-Rules"></a><a name="Coding-Rules-1"></a>
  111. <h2 class="chapter">2 Coding Rules<span class="pull-right"><a class="anchor hidden-xs" href="#Coding-Rules-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Coding-Rules-1" aria-hidden="true">TOC</a></span></h2>
  112. <a name="Language"></a>
  113. <h3 class="section">2.1 Language<span class="pull-right"><a class="anchor hidden-xs" href="#Language" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Language" aria-hidden="true">TOC</a></span></h3>
  114. <p>FFmpeg is mainly programmed in the ISO C11 language, except for the public
  115. headers which must stay C99 compatible.
  116. </p>
  117. <p>Compiler-specific extensions may be used with good reason, but must not be
  118. depended on, i.e. the code must still compile and work with compilers lacking
  119. the extension.
  120. </p>
  121. <p>The following C99 features must not be used anywhere in the codebase:
  122. </p><ul class="itemize mark-bullet">
  123. <li>variable-length arrays;
  124. </li><li>complex numbers;
  125. </li></ul>
  126. <a name="SIMD_002fDSP-1"></a>
  127. <h4 class="subsection">2.1.1 SIMD/DSP<span class="pull-right"><a class="anchor hidden-xs" href="#SIMD_002fDSP-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-SIMD_002fDSP-1" aria-hidden="true">TOC</a></span></h4>
  128. <a class="anchor" id="SIMD_002fDSP"></a>
  129. <p>As modern compilers are unable to generate efficient SIMD or other
  130. performance-critical DSP code from plain C, handwritten assembly is used.
  131. Usually such code is isolated in a separate function. Then the standard approach
  132. is writing multiple versions of this function – a plain C one that works
  133. everywhere and may also be useful for debugging, and potentially multiple
  134. architecture-specific optimized implementations. Initialization code then
  135. chooses the best available version at runtime and loads it into a function
  136. pointer; the function in question is then always called through this pointer.
  137. </p>
  138. <p>The specific syntax used for writing assembly is:
  139. </p><ul class="itemize mark-bullet">
  140. <li>NASM on x86;
  141. </li><li>GAS on ARM and RISC-V.
  142. </li></ul>
  143. <p>A unit testing framework for assembly called <code class="code">checkasm</code> lives under
  144. <samp class="file">tests/checkasm</samp>. All new assembly should come with <code class="code">checkasm</code> tests;
  145. adding tests for existing assembly that lacks them is also strongly encouraged.
  146. </p>
  147. <a name="Other-languages"></a>
  148. <h4 class="subsection">2.1.2 Other languages<span class="pull-right"><a class="anchor hidden-xs" href="#Other-languages" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Other-languages" aria-hidden="true">TOC</a></span></h4>
  149. <p>Other languages than C may be used in special cases:
  150. </p><ul class="itemize mark-bullet">
  151. <li>Compiler intrinsics or inline assembly when the code in question cannot be
  152. written in the standard way described in the <a class="ref" href="#SIMD_002fDSP">SIMD/DSP</a> section. This
  153. typically applies to code that needs to be inlined.
  154. </li><li>Objective-C where required for interacting with macOS-specific interfaces.
  155. </li></ul>
  156. <a name="Code-formatting-conventions"></a>
  157. <h3 class="section">2.2 Code formatting conventions<span class="pull-right"><a class="anchor hidden-xs" href="#Code-formatting-conventions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Code-formatting-conventions" aria-hidden="true">TOC</a></span></h3>
  158. <p>There are the following guidelines regarding the code style in files:
  159. </p>
  160. <ul class="itemize mark-bullet">
  161. <li>Indent size is 4.
  162. </li><li>The TAB character is forbidden outside of Makefiles as is any
  163. form of trailing whitespace. Commits containing either will be
  164. rejected by the git repository.
  165. </li><li>You should try to limit your code lines to 80 characters; however, do so if
  166. and only if this improves readability.
  167. </li><li>K&amp;R coding style is used.
  168. </li></ul>
  169. <p>The presentation is one inspired by &rsquo;indent -i4 -kr -nut&rsquo;.
  170. </p>
  171. <a name="Examples"></a>
  172. <h4 class="subsection">2.2.1 Examples<span class="pull-right"><a class="anchor hidden-xs" href="#Examples" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Examples" aria-hidden="true">TOC</a></span></h4>
  173. <p>Some notable examples to illustrate common code style in FFmpeg:
  174. </p>
  175. <ul class="itemize mark-bullet">
  176. <li>Space around assignments and after
  177. <code class="code">if</code>/<code class="code">do</code>/<code class="code">while</code>/<code class="code">for</code> keywords:
  178. <div class="example user-c user-good">
  179. <pre class="example-preformatted">// Good
  180. if (condition)
  181. av_foo();
  182. </pre></div>
  183. <div class="example user-c user-good">
  184. <pre class="example-preformatted">// Good
  185. for (size_t i = 0; i &lt; len; i++)
  186. av_bar(i);
  187. </pre></div>
  188. <div class="example user-c user-good">
  189. <pre class="example-preformatted">// Good
  190. size_t size = 0;
  191. </pre></div>
  192. <p>However no spaces between the parentheses and condition, unless it helps
  193. readability of complex conditions, so the following should not be done:
  194. </p>
  195. <div class="example user-c user-bad">
  196. <pre class="example-preformatted">// Bad style
  197. if ( condition )
  198. av_foo();
  199. </pre></div>
  200. </li><li>No unnecessary parentheses, unless it helps readability:
  201. <div class="example user-c user-good">
  202. <pre class="example-preformatted">// Good
  203. int fields = ilace ? 2 : 1;
  204. </pre></div>
  205. </li><li>Don&rsquo;t wrap single-line blocks in braces. Use braces only if there is an accompanying else statement. This keeps future code changes easier to keep track of.
  206. <div class="example user-c user-good">
  207. <pre class="example-preformatted">// Good
  208. if (bits_pixel == 24) {
  209. avctx-&gt;pix_fmt = AV_PIX_FMT_BGR24;
  210. } else if (bits_pixel == 8) {
  211. avctx-&gt;pix_fmt = AV_PIX_FMT_GRAY8;
  212. } else
  213. return AVERROR_INVALIDDATA;
  214. </pre></div>
  215. </li><li>Avoid assignments in conditions where it makes sense:
  216. <div class="example user-c user-good">
  217. <pre class="example-preformatted">// Good
  218. video_enc-&gt;chroma_intra_matrix = av_mallocz(sizeof(*video_enc-&gt;chroma_intra_matrix) * 64)
  219. if (!video_enc-&gt;chroma_intra_matrix)
  220. return AVERROR(ENOMEM);
  221. </pre></div>
  222. <div class="example user-c user-bad">
  223. <pre class="example-preformatted">// Bad style
  224. if (!(video_enc-&gt;chroma_intra_matrix = av_mallocz(sizeof(*video_enc-&gt;chroma_intra_matrix) * 64)))
  225. return AVERROR(ENOMEM);
  226. </pre></div>
  227. <div class="example user-c user-good">
  228. <pre class="example-preformatted">// Ok
  229. while ((entry = av_dict_iterate(options, entry)))
  230. av_log(ctx, AV_LOG_INFO, &quot;Item '%s': '%s'\n&quot;, entry-&gt;key, entry-&gt;value);
  231. </pre></div>
  232. </li><li>When declaring a pointer variable, the <code class="code">*</code> goes with the variable not the type:
  233. <div class="example user-c user-good">
  234. <pre class="example-preformatted">// Good
  235. AVStream *stream;
  236. </pre></div>
  237. <div class="example user-c user-bad">
  238. <pre class="example-preformatted">// Bad style
  239. AVStream* stream;
  240. </pre></div>
  241. </li></ul>
  242. <p>If you work on a file that does not follow these guidelines consistently,
  243. change the parts that you are editing to follow these guidelines but do
  244. not make unrelated changes in the file to make it conform to these.
  245. </p>
  246. <a name="Vim-configuration"></a>
  247. <h4 class="subsection">2.2.2 Vim configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Vim-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Vim-configuration" aria-hidden="true">TOC</a></span></h4>
  248. <p>In order to configure Vim to follow FFmpeg formatting conventions, paste
  249. the following snippet into your <samp class="file">.vimrc</samp>:
  250. </p><div class="example">
  251. <pre class="example-preformatted">&quot; indentation rules for FFmpeg: 4 spaces, no tabs
  252. set expandtab
  253. set shiftwidth=4
  254. set softtabstop=4
  255. set cindent
  256. set cinoptions=(0
  257. &quot; Allow tabs in Makefiles.
  258. autocmd FileType make,automake set noexpandtab shiftwidth=8 softtabstop=8
  259. &quot; Trailing whitespace and tabs are forbidden, so highlight them.
  260. highlight ForbiddenWhitespace ctermbg=red guibg=red
  261. match ForbiddenWhitespace /\s\+$\|\t/
  262. &quot; Do not highlight spaces at the end of line while typing on that line.
  263. autocmd InsertEnter * match ForbiddenWhitespace /\t\|\s\+\%#\@&lt;!$/
  264. </pre></div>
  265. <a name="Emacs-configuration"></a>
  266. <h4 class="subsection">2.2.3 Emacs configuration<span class="pull-right"><a class="anchor hidden-xs" href="#Emacs-configuration" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Emacs-configuration" aria-hidden="true">TOC</a></span></h4>
  267. <p>For Emacs, add these roughly equivalent lines to your <samp class="file">.emacs.d/init.el</samp>:
  268. </p><div class="example lisp">
  269. <pre class="lisp-preformatted">(c-add-style &quot;ffmpeg&quot;
  270. '(&quot;k&amp;r&quot;
  271. (c-basic-offset . 4)
  272. (indent-tabs-mode . nil)
  273. (show-trailing-whitespace . t)
  274. (c-offsets-alist
  275. (statement-cont . (c-lineup-assignments +)))
  276. )
  277. )
  278. (setq c-default-style &quot;ffmpeg&quot;)
  279. </pre></div>
  280. <a name="Comments"></a>
  281. <h3 class="section">2.3 Comments<span class="pull-right"><a class="anchor hidden-xs" href="#Comments" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Comments" aria-hidden="true">TOC</a></span></h3>
  282. <p>Use the JavaDoc/Doxygen format (see examples below) so that code documentation
  283. can be generated automatically. All nontrivial functions should have a comment
  284. above them explaining what the function does, even if it is just one sentence.
  285. All structures and their member variables should be documented, too.
  286. </p>
  287. <p>Avoid Qt-style and similar Doxygen syntax with <code class="code">!</code> in it, i.e. replace
  288. <code class="code">//!</code> with <code class="code">///</code> and similar. Also @ syntax should be employed
  289. for markup commands, i.e. use <code class="code">@param</code> and not <code class="code">\param</code>.
  290. </p>
  291. <div class="example">
  292. <pre class="example-preformatted">/**
  293. * @file
  294. * MPEG codec.
  295. * @author ...
  296. */
  297. /**
  298. * Summary sentence.
  299. * more text ...
  300. * ...
  301. */
  302. typedef struct Foobar {
  303. int var1; /**&lt; var1 description */
  304. int var2; ///&lt; var2 description
  305. /** var3 description */
  306. int var3;
  307. } Foobar;
  308. /**
  309. * Summary sentence.
  310. * more text ...
  311. * ...
  312. * @param my_parameter description of my_parameter
  313. * @return return value description
  314. */
  315. int myfunc(int my_parameter)
  316. ...
  317. </pre></div>
  318. <a class="anchor" id="Naming-conventions"></a><a name="Naming-conventions-1"></a>
  319. <h3 class="section">2.4 Naming conventions<span class="pull-right"><a class="anchor hidden-xs" href="#Naming-conventions-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Naming-conventions-1" aria-hidden="true">TOC</a></span></h3>
  320. <p>Names of functions, variables, and struct members must be lowercase, using
  321. underscores (_) to separate words. For example, &lsquo;<samp class="samp">avfilter_get_video_buffer</samp>&rsquo;
  322. is an acceptable function name and &lsquo;<samp class="samp">AVFilterGetVideo</samp>&rsquo; is not.
  323. </p>
  324. <p>Struct, union, enum, and typedeffed type names must use CamelCase. All structs
  325. and unions should be typedeffed to the same name as the struct/union tag, e.g.
  326. <code class="code">typedef struct AVFoo { ... } AVFoo;</code>. Enums are typically not
  327. typedeffed.
  328. </p>
  329. <p>Enumeration constants and macros must be UPPERCASE, except for macros
  330. masquerading as functions, which should use the function naming convention.
  331. </p>
  332. <p>All identifiers in the libraries should be namespaced as follows:
  333. </p><ul class="itemize mark-bullet">
  334. <li>No namespacing for identifiers with file and lower scope (e.g. local variables,
  335. static functions), and struct and union members,
  336. </li><li>The <code class="code">ff_</code> prefix must be used for variables and functions visible outside
  337. of file scope, but only used internally within a single library, e.g.
  338. &lsquo;<samp class="samp">ff_w64_demuxer</samp>&rsquo;. This prevents name collisions when FFmpeg is statically
  339. linked.
  340. </li><li>For variables and functions visible outside of file scope, used internally
  341. across multiple libraries, use <code class="code">avpriv_</code> as prefix, for example,
  342. &lsquo;<samp class="samp">avpriv_report_missing_feature</samp>&rsquo;.
  343. </li><li>All other internal identifiers, like private type or macro names, should be
  344. namespaced only to avoid possible internal conflicts. E.g. <code class="code">H264_NAL_SPS</code>
  345. vs. <code class="code">HEVC_NAL_SPS</code>.
  346. </li><li>Each library has its own prefix for public symbols, in addition to the
  347. commonly used <code class="code">av_</code> (<code class="code">avformat_</code> for libavformat,
  348. <code class="code">avcodec_</code> for libavcodec, <code class="code">swr_</code> for libswresample, etc).
  349. Check the existing code and choose names accordingly.
  350. </li><li>Other public identifiers (struct, union, enum, macro, type names) must use their
  351. library&rsquo;s public prefix (<code class="code">AV</code>, <code class="code">Sws</code>, or <code class="code">Swr</code>).
  352. </li></ul>
  353. <p>Furthermore, name space reserved for the system should not be invaded.
  354. Identifiers ending in <code class="code">_t</code> are reserved by
  355. <a class="url" href="http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html#tag_02_02_02">POSIX</a>.
  356. Also avoid names starting with <code class="code">__</code> or <code class="code">_</code> followed by an uppercase
  357. letter as they are reserved by the C standard. Names starting with <code class="code">_</code>
  358. are reserved at the file level and may not be used for externally visible
  359. symbols. If in doubt, just avoid names starting with <code class="code">_</code> altogether.
  360. </p>
  361. <a name="Miscellaneous-conventions"></a>
  362. <h3 class="section">2.5 Miscellaneous conventions<span class="pull-right"><a class="anchor hidden-xs" href="#Miscellaneous-conventions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Miscellaneous-conventions" aria-hidden="true">TOC</a></span></h3>
  363. <ul class="itemize mark-bullet">
  364. <li>Casts should be used only when necessary. Unneeded parentheses
  365. should also be avoided if they don&rsquo;t make the code easier to understand.
  366. </li></ul>
  367. <a class="anchor" id="Development-Policy"></a><a name="Development-Policy-1"></a>
  368. <h2 class="chapter">3 Development Policy<span class="pull-right"><a class="anchor hidden-xs" href="#Development-Policy-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Development-Policy-1" aria-hidden="true">TOC</a></span></h2>
  369. <a name="Code-behaviour"></a>
  370. <h3 class="section">3.1 Code behaviour<span class="pull-right"><a class="anchor hidden-xs" href="#Code-behaviour" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Code-behaviour" aria-hidden="true">TOC</a></span></h3>
  371. <a name="Correctness"></a>
  372. <p>The code must be valid. It must not crash, abort, access invalid pointers, leak
  373. memory, cause data races or signed integer overflow, or otherwise cause
  374. undefined behaviour. Error codes should be checked and, when applicable,
  375. forwarded to the caller.
  376. </p>
  377. <a name="Thread_002d-and-library_002dsafety"></a>
  378. <p>Our libraries may be called by multiple independent callers in the same process.
  379. These calls may happen from any number of threads and the different call sites
  380. may not be aware of each other - e.g. a user program may be calling our
  381. libraries directly, and use one or more libraries that also call our libraries.
  382. The code must behave correctly under such conditions.
  383. </p>
  384. <a name="Robustness"></a>
  385. <p>The code must treat as untrusted any bytestream received from a caller or read
  386. from a file, network, etc. It must not misbehave when arbitrary data is sent to
  387. it - typically it should print an error message and return
  388. <code class="code">AVERROR_INVALIDDATA</code> on encountering invalid input data.
  389. </p>
  390. <a name="Memory-allocation"></a>
  391. <p>The code must use the <code class="code">av_malloc()</code> family of functions from
  392. <samp class="file">libavutil/mem.h</samp> to perform all memory allocation, except in special cases
  393. (e.g. when interacting with an external library that requires a specific
  394. allocator to be used).
  395. </p>
  396. <p>All allocations should be checked and <code class="code">AVERROR(ENOMEM)</code> returned on
  397. failure. A common mistake is that error paths leak memory - make sure that does
  398. not happen.
  399. </p>
  400. <a name="stdio"></a>
  401. <p>Our libraries must not access the stdio streams stdin/stdout/stderr directly
  402. (e.g. via <code class="code">printf()</code> family of functions), as that is not library-safe. For
  403. logging, use <code class="code">av_log()</code>.
  404. </p>
  405. <a name="Patches_002fCommitting"></a>
  406. <h3 class="section">3.2 Patches/Committing<span class="pull-right"><a class="anchor hidden-xs" href="#Patches_002fCommitting" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Patches_002fCommitting" aria-hidden="true">TOC</a></span></h3>
  407. <a name="Licenses-for-patches-must-be-compatible-with-FFmpeg_002e"></a>
  408. <p>Contributions should be licensed under the
  409. <a class="uref" href="http://www.gnu.org/licenses/lgpl-2.1.html">LGPL 2.1</a>,
  410. including an &quot;or any later version&quot; clause, or, if you prefer
  411. a gift-style license, the
  412. <a class="uref" href="http://opensource.org/licenses/isc-license.txt">ISC</a> or
  413. <a class="uref" href="http://mit-license.org/">MIT</a> license.
  414. <a class="uref" href="http://www.gnu.org/licenses/gpl-2.0.html">GPL 2</a> including
  415. an &quot;or any later version&quot; clause is also acceptable, but LGPL is
  416. preferred.
  417. If you add a new file, give it a proper license header. Do not copy and
  418. paste it from a random place, use an existing file as template.
  419. </p>
  420. <a name="You-must-not-commit-code-which-breaks-FFmpeg_0021"></a>
  421. <p>This means unfinished code which is enabled and breaks compilation,
  422. or compiles but does not work/breaks the regression tests. Code which
  423. is unfinished but disabled may be permitted under-circumstances, like
  424. missing samples or an implementation with a small subset of features.
  425. Always check the mailing list for any reviewers with issues and test
  426. FATE before you push.
  427. </p>
  428. <a name="Commit-messages"></a>
  429. <p>Commit messages are highly important tools for informing other developers on
  430. what a given change does and why. Every commit must always have a properly
  431. filled out commit message with the following format:
  432. </p><div class="example">
  433. <pre class="example-preformatted">area changed: short 1 line description
  434. details describing what and why and giving references.
  435. </pre></div>
  436. <p>If the commit addresses a known bug on our bug tracker or other external issue
  437. (e.g. CVE), the commit message should include the relevant bug ID(s) or other
  438. external identifiers. Note that this should be done in addition to a proper
  439. explanation and not instead of it. Comments such as &quot;fixed!&quot; or &quot;Changed it.&quot;
  440. are not acceptable.
  441. </p>
  442. <p>When applying patches that have been discussed at length on the mailing list,
  443. reference the thread in the commit message.
  444. </p>
  445. <a name="Testing-must-be-adequate-but-not-excessive_002e"></a>
  446. <p>If it works for you, others, and passes FATE then it should be OK to commit
  447. it, provided it fits the other committing criteria. You should not worry about
  448. over-testing things. If your code has problems (portability, triggers
  449. compiler bugs, unusual environment etc) they will be reported and eventually
  450. fixed.
  451. </p>
  452. <a name="Do-not-commit-unrelated-changes-together_002e"></a>
  453. <p>They should be split them into self-contained pieces. Also do not forget
  454. that if part B depends on part A, but A does not depend on B, then A can
  455. and should be committed first and separate from B. Keeping changes well
  456. split into self-contained parts makes reviewing and understanding them on
  457. the commit log mailing list easier. This also helps in case of debugging
  458. later on.
  459. Also if you have doubts about splitting or not splitting, do not hesitate to
  460. ask/discuss it on the developer mailing list.
  461. </p>
  462. <a name="Cosmetic-changes-should-be-kept-in-separate-patches_002e"></a>
  463. <p>We refuse source indentation and other cosmetic changes if they are mixed
  464. with functional changes, such commits will be rejected and removed. Every
  465. developer has his own indentation style, you should not change it. Of course
  466. if you (re)write something, you can use your own style, even though we would
  467. prefer if the indentation throughout FFmpeg was consistent (Many projects
  468. force a given indentation style - we do not.). If you really need to make
  469. indentation changes (try to avoid this), separate them strictly from real
  470. changes.
  471. </p>
  472. <p>NOTE: If you had to put if(){ .. } over a large (&gt; 5 lines) chunk of code,
  473. then either do NOT change the indentation of the inner part within (do not
  474. move it to the right)! or do so in a separate commit
  475. </p>
  476. <a name="Credit-the-author-of-the-patch_002e"></a>
  477. <p>Make sure the author of the commit is set correctly. (see git commit &ndash;author)
  478. If you apply a patch, send an
  479. answer to ffmpeg-devel (or wherever you got the patch from) saying that
  480. you applied the patch.
  481. </p>
  482. <a name="Credit-any-researchers"></a>
  483. <p>If a commit/patch fixes an issues found by some researcher, always credit the
  484. researcher in the commit message for finding/reporting the issue.
  485. </p>
  486. <a name="Always-wait-long-enough-before-pushing-changes"></a>
  487. <p>Do NOT commit to code actively maintained by others without permission.
  488. Send a patch to ffmpeg-devel. If no one answers within a reasonable
  489. time-frame (12h for build failures and security fixes, 3 days small changes,
  490. 1 week for big patches) then commit your patch if you think it is OK.
  491. Also note, the maintainer can simply ask for more time to review!
  492. </p>
  493. <a name="Code"></a>
  494. <h3 class="section">3.3 Code<span class="pull-right"><a class="anchor hidden-xs" href="#Code" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Code" aria-hidden="true">TOC</a></span></h3>
  495. <a name="Warnings-for-correct-code-may-be-disabled-if-there-is-no-other-option_002e"></a>
  496. <p>Compiler warnings indicate potential bugs or code with bad style. If a type of
  497. warning always points to correct and clean code, that warning should
  498. be disabled, not the code changed.
  499. Thus the remaining warnings can either be bugs or correct code.
  500. If it is a bug, the bug has to be fixed. If it is not, the code should
  501. be changed to not generate a warning unless that causes a slowdown
  502. or obfuscates the code.
  503. </p>
  504. <a name="Library-public-interfaces"></a>
  505. <h3 class="section">3.4 Library public interfaces<span class="pull-right"><a class="anchor hidden-xs" href="#Library-public-interfaces" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Library-public-interfaces" aria-hidden="true">TOC</a></span></h3>
  506. <p>Every library in FFmpeg provides a set of public APIs in its installed headers,
  507. which are those listed in the variable <code class="code">HEADERS</code> in that library&rsquo;s
  508. <samp class="file">Makefile</samp>. All identifiers defined in those headers (except for those
  509. explicitly documented otherwise), and corresponding symbols exported from
  510. compiled shared or static libraries are considered public interfaces and must
  511. comply with the API and ABI compatibility rules described in this section.
  512. </p>
  513. <p>Public APIs must be backward compatible within a given major version. I.e. any
  514. valid user code that compiles and works with a given library version must still
  515. compile and work with any later version, as long as the major version number is
  516. unchanged. &quot;Valid user code&quot; here means code that is calling our APIs in a
  517. documented and/or intended manner and is not relying on any undefined behavior.
  518. Incrementing the major version may break backward compatibility, but only to the
  519. extent described in <a class="ref" href="#Major-version-bumps">Major version bumps</a>.
  520. </p>
  521. <p>We also guarantee backward ABI compatibility for shared and static libraries.
  522. I.e. it should be possible to replace a shared or static build of our library
  523. with a build of any later version (re-linking the user binary in the static
  524. case) without breaking any valid user binaries, as long as the major version
  525. number remains unchanged.
  526. </p>
  527. <a name="Adding-new-interfaces"></a>
  528. <h4 class="subsection">3.4.1 Adding new interfaces<span class="pull-right"><a class="anchor hidden-xs" href="#Adding-new-interfaces" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Adding-new-interfaces" aria-hidden="true">TOC</a></span></h4>
  529. <p>Any new public identifiers in installed headers are considered new API - this
  530. includes new functions, structs, macros, enum values, typedefs, new fields in
  531. existing structs, new installed headers, etc. Consider the following
  532. guidelines when adding new APIs.
  533. </p>
  534. <a name="Motivation"></a>
  535. <p>While new APIs can be added relatively easily, changing or removing them is much
  536. harder due to abovementioned compatibility requirements. You should then
  537. consider carefully whether the functionality you are adding really needs to be
  538. exposed to our callers as new public API.
  539. </p>
  540. <p>Your new API should have at least one well-established use case outside of the
  541. library that cannot be easily achieved with existing APIs. Every library in
  542. FFmpeg also has a defined scope - your new API must fit within it.
  543. </p>
  544. <a name="Replacing-existing-APIs"></a>
  545. <p>If your new API is replacing an existing one, it should be strictly superior to
  546. it, so that the advantages of using the new API outweigh the cost to the
  547. callers of changing their code. After adding the new API you should then
  548. deprecate the old one and schedule it for removal, as described in
  549. <a class="ref" href="#Removing-interfaces">Removing interfaces</a>.
  550. </p>
  551. <p>If you deem an existing API deficient and want to fix it, the preferred approach
  552. in most cases is to add a differently-named replacement and deprecate the
  553. existing API rather than modify it. It is important to make the changes visible
  554. to our callers (e.g. through compile- or run-time deprecation warnings) and make
  555. it clear how to transition to the new API (e.g. in the Doxygen documentation or
  556. on the wiki).
  557. </p>
  558. <a name="API-design"></a>
  559. <p>The FFmpeg libraries are used by a variety of callers to perform a wide range of
  560. multimedia-related processing tasks. You should therefore - within reason - try
  561. to design your new API for the broadest feasible set of use cases and avoid
  562. unnecessarily limiting it to a specific type of callers (e.g. just media
  563. playback or just transcoding).
  564. </p>
  565. <a name="Consistency"></a>
  566. <p>Check whether similar APIs already exist in FFmpeg. If they do, try to model
  567. your new addition on them to achieve better overall consistency.
  568. </p>
  569. <p>The naming of your new identifiers should follow the <a class="ref" href="#Naming-conventions">Naming conventions</a>
  570. and be aligned with other similar APIs, if applicable.
  571. </p>
  572. <a name="Extensibility"></a>
  573. <p>You should also consider how your API might be extended in the future in a
  574. backward-compatible way. If you are adding a new struct <code class="code">AVFoo</code>, the
  575. standard approach is requiring the caller to always allocate it through a
  576. constructor function, typically named <code class="code">av_foo_alloc()</code>. This way new fields
  577. may be added to the end of the struct without breaking ABI compatibility.
  578. Typically you will also want a destructor - <code class="code">av_foo_free(AVFoo**)</code> that
  579. frees the indirectly supplied object (and its contents, if applicable) and
  580. writes <code class="code">NULL</code> to the supplied pointer, thus eliminating the potential
  581. dangling pointer in the caller&rsquo;s memory.
  582. </p>
  583. <p>If you are adding new functions, consider whether it might be desirable to tweak
  584. their behavior in the future - you may want to add a flags argument, even though
  585. it would be unused initially.
  586. </p>
  587. <a name="Documentation"></a>
  588. <p>All new APIs must be documented as Doxygen-formatted comments above the
  589. identifiers you add to the public headers. You should also briefly mention the
  590. change in <samp class="file">doc/APIchanges</samp>.
  591. </p>
  592. <a name="Bump-the-version"></a>
  593. <p>Backward-incompatible API or ABI changes require incrementing (bumping) the
  594. major version number, as described in <a class="ref" href="#Major-version-bumps">Major version bumps</a>. Major
  595. bumps are significant events that happen on a schedule - so if your change
  596. strictly requires one you should add it under <code class="code">#if</code> preprocessor guards that
  597. disable it until the next major bump happens.
  598. </p>
  599. <p>New APIs that can be added without breaking API or ABI compatibility require
  600. bumping the minor version number.
  601. </p>
  602. <p>Incrementing the third (micro) version component means a noteworthy binary
  603. compatible change (e.g. encoder bug fix that matters for the decoder). The third
  604. component always starts at 100 to distinguish FFmpeg from Libav.
  605. </p>
  606. <a class="anchor" id="Removing-interfaces"></a><a name="Removing-interfaces-1"></a>
  607. <h4 class="subsection">3.4.2 Removing interfaces<span class="pull-right"><a class="anchor hidden-xs" href="#Removing-interfaces-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Removing-interfaces-1" aria-hidden="true">TOC</a></span></h4>
  608. <p>Due to abovementioned compatibility guarantees, removing APIs is an involved
  609. process that should only be undertaken with good reason. Typically a deficient,
  610. restrictive, or otherwise inadequate API is replaced by a superior one, though
  611. it does at times happen that we remove an API without any replacement (e.g. when
  612. the feature it provides is deemed not worth the maintenance effort, out of scope
  613. of the project, fundamentally flawed, etc.).
  614. </p>
  615. <p>The removal has two steps - first the API is deprecated and scheduled for
  616. removal, but remains present and functional. The second step is actually
  617. removing the API - this is described in <a class="ref" href="#Major-version-bumps">Major version bumps</a>.
  618. </p>
  619. <p>To deprecate an API you should signal to our users that they should stop using
  620. it. E.g. if you intend to remove struct members or functions, you should mark
  621. them with <code class="code">attribute_deprecated</code>. When this cannot be done, it may be
  622. possible to detect the use of the deprecated API at runtime and print a warning
  623. (though take care not to print it too often). You should also document the
  624. deprecation (and the replacement, if applicable) in the relevant Doxygen
  625. documentation block.
  626. </p>
  627. <p>Finally, you should define a deprecation guard along the lines of
  628. <code class="code">#define FF_API_&lt;FOO&gt; (LIBAVBAR_VERSION_MAJOR &lt; XX)</code> (where XX is the major
  629. version in which the API will be removed) in <samp class="file">libavbar/version_major.h</samp>
  630. (<samp class="file">version.h</samp> in case of <code class="code">libavutil</code>). Then wrap all uses of the
  631. deprecated API in <code class="code">#if FF_API_&lt;FOO&gt; .... #endif</code>, so that the code will
  632. automatically get disabled once the major version reaches XX. You can also use
  633. <code class="code">FF_DISABLE_DEPRECATION_WARNINGS</code> and <code class="code">FF_ENABLE_DEPRECATION_WARNINGS</code>
  634. to suppress compiler deprecation warnings inside these guards. You should test
  635. that the code compiles and works with the guard macro evaluating to both true
  636. and false.
  637. </p>
  638. <a class="anchor" id="Major-version-bumps"></a><a name="Major-version-bumps-1"></a>
  639. <h4 class="subsection">3.4.3 Major version bumps<span class="pull-right"><a class="anchor hidden-xs" href="#Major-version-bumps-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Major-version-bumps-1" aria-hidden="true">TOC</a></span></h4>
  640. <p>A major version bump signifies an API and/or ABI compatibility break. To reduce
  641. the negative effects on our callers, who are required to adapt their code,
  642. backward-incompatible changes during a major bump should be limited to:
  643. </p><ul class="itemize mark-bullet">
  644. <li>Removing previously deprecated APIs.
  645. </li><li>Performing ABI- but not API-breaking changes, like reordering struct contents.
  646. </li></ul>
  647. <a name="Documentation_002fOther"></a>
  648. <h3 class="section">3.5 Documentation/Other<span class="pull-right"><a class="anchor hidden-xs" href="#Documentation_002fOther" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Documentation_002fOther" aria-hidden="true">TOC</a></span></h3>
  649. <a name="Subscribe-to-the-ffmpeg_002ddevel-mailing-list_002e"></a>
  650. <p>It is important to be subscribed to the
  651. <a class="uref" href="https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel">ffmpeg-devel</a>
  652. mailing list. Almost any non-trivial patch is to be sent there for review.
  653. Other developers may have comments about your contribution. We expect you see
  654. those comments, and to improve it if requested. (N.B. Experienced committers
  655. have other channels, and may sometimes skip review for trivial fixes.) Also,
  656. discussion here about bug fixes and FFmpeg improvements by other developers may
  657. be helpful information for you. Finally, by being a list subscriber, your
  658. contribution will be posted immediately to the list, without the moderation
  659. hold which messages from non-subscribers experience.
  660. </p>
  661. <p>However, it is more important to the project that we receive your patch than
  662. that you be subscribed to the ffmpeg-devel list. If you have a patch, and don&rsquo;t
  663. want to subscribe and discuss the patch, then please do send it to the list
  664. anyway.
  665. </p>
  666. <a name="Subscribe-to-the-ffmpeg_002dcvslog-mailing-list_002e"></a>
  667. <p>Diffs of all commits are sent to the
  668. <a class="uref" href="https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog">ffmpeg-cvslog</a>
  669. mailing list. Some developers read this list to review all code base changes
  670. from all sources. Subscribing to this list is not mandatory.
  671. </p>
  672. <a name="Keep-the-documentation-up-to-date_002e"></a>
  673. <p>Update the documentation if you change behavior or add features. If you are
  674. unsure how best to do this, send a patch to ffmpeg-devel, the documentation
  675. maintainer(s) will review and commit your stuff.
  676. </p>
  677. <a name="Important-discussions-should-be-accessible-to-all_002e"></a>
  678. <p>Try to keep important discussions and requests (also) on the public
  679. developer mailing list, so that all developers can benefit from them.
  680. </p>
  681. <a name="Check-your-entries-in-MAINTAINERS_002e"></a>
  682. <p>Make sure that no parts of the codebase that you maintain are missing from the
  683. <samp class="file">MAINTAINERS</samp> file. If something that you want to maintain is missing add it with
  684. your name after it.
  685. If at some point you no longer want to maintain some code, then please help in
  686. finding a new maintainer and also don&rsquo;t forget to update the <samp class="file">MAINTAINERS</samp> file.
  687. </p>
  688. <p>We think our rules are not too hard. If you have comments, contact us.
  689. </p>
  690. <a class="anchor" id="Submitting-patches"></a><a name="Submitting-patches-1"></a>
  691. <h2 class="chapter">4 Submitting patches<span class="pull-right"><a class="anchor hidden-xs" href="#Submitting-patches-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Submitting-patches-1" aria-hidden="true">TOC</a></span></h2>
  692. <p>First, read the <a class="ref" href="#Coding-Rules">Coding Rules</a> above if you did not yet, in particular
  693. the rules regarding patch submission.
  694. </p>
  695. <p>When you submit your patch, please use <code class="code">git format-patch</code> or
  696. <code class="code">git send-email</code>. We cannot read other diffs :-).
  697. </p>
  698. <p>Also please do not submit a patch which contains several unrelated changes.
  699. Split it into separate, self-contained pieces. This does not mean splitting
  700. file by file. Instead, make the patch as small as possible while still
  701. keeping it as a logical unit that contains an individual change, even
  702. if it spans multiple files. This makes reviewing your patches much easier
  703. for us and greatly increases your chances of getting your patch applied.
  704. </p>
  705. <p>Use the patcheck tool of FFmpeg to check your patch.
  706. The tool is located in the tools directory.
  707. </p>
  708. <p>Run the <a class="ref" href="#Regression-tests">Regression tests</a> before submitting a patch in order to verify
  709. it does not cause unexpected problems.
  710. </p>
  711. <p>It also helps quite a bit if you tell us what the patch does (for example
  712. &rsquo;replaces lrint by lrintf&rsquo;), and why (for example &rsquo;*BSD isn&rsquo;t C99 compliant
  713. and has no lrint()&rsquo;)
  714. </p>
  715. <p>Also please if you send several patches, send each patch as a separate mail,
  716. do not attach several unrelated patches to the same mail.
  717. </p>
  718. <p>Patches should be posted to the
  719. <a class="uref" href="https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel">ffmpeg-devel</a>
  720. mailing list. Use <code class="code">git send-email</code> when possible since it will properly
  721. send patches without requiring extra care. If you cannot, then send patches
  722. as base64-encoded attachments, so your patch is not trashed during
  723. transmission. Also ensure the correct mime type is used
  724. (text/x-diff or text/x-patch or at least text/plain) and that only one
  725. patch is inline or attached per mail.
  726. You can check <a class="url" href="https://patchwork.ffmpeg.org">https://patchwork.ffmpeg.org</a>, if your patch does not show up, its mime type
  727. likely was wrong.
  728. </p>
  729. <a name="How-to-setup-git-send_002demail_003f"></a>
  730. <p>Please see <a class="url" href="https://git-send-email.io/">https://git-send-email.io/</a>.
  731. For gmail additionally see <a class="url" href="https://shallowsky.com/blog/tech/email/gmail-app-passwds.html">https://shallowsky.com/blog/tech/email/gmail-app-passwds.html</a>.
  732. </p>
  733. <a name="Sending-patches-from-email-clients"></a>
  734. <p>Using <code class="code">git send-email</code> might not be desirable for everyone. The
  735. following trick allows to send patches via email clients in a safe
  736. way. It has been tested with Outlook and Thunderbird (with X-Unsent
  737. extension) and might work with other applications.
  738. </p>
  739. <p>Create your patch like this:
  740. </p>
  741. <pre class="verbatim">git format-patch -s -o &quot;outputfolder&quot; --add-header &quot;X-Unsent: 1&quot; --suffix .eml --to ffmpeg-devel@ffmpeg.org -1 1a2b3c4d
  742. </pre>
  743. <p>Now you&rsquo;ll just need to open the eml file with the email application
  744. and execute &rsquo;Send&rsquo;.
  745. </p>
  746. <a name="Reviews"></a>
  747. <p>Your patch will be reviewed on the mailing list. You will likely be asked
  748. to make some changes and are expected to send in an improved version that
  749. incorporates the requests from the review. This process may go through
  750. several iterations. Once your patch is deemed good enough, some developer
  751. will pick it up and commit it to the official FFmpeg tree.
  752. </p>
  753. <p>Give us a few days to react. But if some time passes without reaction,
  754. send a reminder by email. Your patch should eventually be dealt with.
  755. </p>
  756. <a name="New-codecs-or-formats-checklist"></a>
  757. <h2 class="chapter">5 New codecs or formats checklist<span class="pull-right"><a class="anchor hidden-xs" href="#New-codecs-or-formats-checklist" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-New-codecs-or-formats-checklist" aria-hidden="true">TOC</a></span></h2>
  758. <ol class="enumerate">
  759. <li> Did you use av_cold for codec initialization and close functions?
  760. </li><li> Did you add a long_name under NULL_IF_CONFIG_SMALL to the AVCodec or
  761. AVInputFormat/AVOutputFormat struct?
  762. </li><li> Did you bump the minor version number (and reset the micro version
  763. number) in <samp class="file">libavcodec/version.h</samp> or <samp class="file">libavformat/version.h</samp>?
  764. </li><li> Did you register it in <samp class="file">allcodecs.c</samp> or <samp class="file">allformats.c</samp>?
  765. </li><li> Did you add the AVCodecID to <samp class="file">codec_id.h</samp>?
  766. When adding new codec IDs, also add an entry to the codec descriptor
  767. list in <samp class="file">libavcodec/codec_desc.c</samp>.
  768. </li><li> If it has a FourCC, did you add it to <samp class="file">libavformat/riff.c</samp>,
  769. even if it is only a decoder?
  770. </li><li> Did you add a rule to compile the appropriate files in the Makefile?
  771. Remember to do this even if you&rsquo;re just adding a format to a file that is
  772. already being compiled by some other rule, like a raw demuxer.
  773. </li><li> Did you add an entry to the table of supported formats or codecs in
  774. <samp class="file">doc/general_contents.texi</samp>?
  775. </li><li> Did you add an entry in the Changelog?
  776. </li><li> If it depends on a parser or a library, did you add that dependency in
  777. configure?
  778. </li><li> Did you <code class="code">git add</code> the appropriate files before committing?
  779. </li><li> Did you make sure it compiles standalone, i.e. with
  780. <code class="code">configure --disable-everything --enable-decoder=foo</code>
  781. (or <code class="code">--enable-demuxer</code> or whatever your component is)?
  782. </li></ol>
  783. <a name="Patch-submission-checklist"></a>
  784. <h2 class="chapter">6 Patch submission checklist<span class="pull-right"><a class="anchor hidden-xs" href="#Patch-submission-checklist" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Patch-submission-checklist" aria-hidden="true">TOC</a></span></h2>
  785. <ol class="enumerate">
  786. <li> Does <code class="code">make fate</code> pass with the patch applied?
  787. </li><li> Was the patch generated with git format-patch or send-email?
  788. </li><li> Did you sign-off your patch? (<code class="code">git commit -s</code>)
  789. See <a class="uref" href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/process/submitting-patches.rst">Sign your work</a> for the meaning
  790. of <em class="dfn">sign-off</em>.
  791. </li><li> Did you provide a clear git commit log message?
  792. </li><li> Is the patch against latest FFmpeg git master branch?
  793. </li><li> Are you subscribed to ffmpeg-devel?
  794. (the list is subscribers only due to spam)
  795. </li><li> Have you checked that the changes are minimal, so that the same cannot be
  796. achieved with a smaller patch and/or simpler final code?
  797. </li><li> If the change is to speed critical code, did you benchmark it?
  798. </li><li> If you did any benchmarks, did you provide them in the mail?
  799. </li><li> Have you checked that the patch does not introduce buffer overflows or
  800. other security issues?
  801. </li><li> Did you test your decoder or demuxer against damaged data? If no, see
  802. tools/trasher, the noise bitstream filter, and
  803. <a class="uref" href="http://caca.zoy.org/wiki/zzuf">zzuf</a>. Your decoder or demuxer
  804. should not crash, end in a (near) infinite loop, or allocate ridiculous
  805. amounts of memory when fed damaged data.
  806. </li><li> Did you test your decoder or demuxer against sample files?
  807. Samples may be obtained at <a class="url" href="https://samples.ffmpeg.org">https://samples.ffmpeg.org</a>.
  808. </li><li> Does the patch not mix functional and cosmetic changes?
  809. </li><li> Did you add tabs or trailing whitespace to the code? Both are forbidden.
  810. </li><li> Is the patch attached to the email you send?
  811. </li><li> Is the mime type of the patch correct? It should be text/x-diff or
  812. text/x-patch or at least text/plain and not application/octet-stream.
  813. </li><li> If the patch fixes a bug, did you provide a verbose analysis of the bug?
  814. </li><li> If the patch fixes a bug, did you provide enough information, including
  815. a sample, so the bug can be reproduced and the fix can be verified?
  816. Note please do not attach samples &gt;100k to mails but rather provide a
  817. URL, you can upload to <a class="url" href="https://streams.videolan.org/upload/">https://streams.videolan.org/upload/</a>.
  818. </li><li> Did you provide a verbose summary about what the patch does change?
  819. </li><li> Did you provide a verbose explanation why it changes things like it does?
  820. </li><li> Did you provide a verbose summary of the user visible advantages and
  821. disadvantages if the patch is applied?
  822. </li><li> Did you provide an example so we can verify the new feature added by the
  823. patch easily?
  824. </li><li> If you added a new file, did you insert a license header? It should be
  825. taken from FFmpeg, not randomly copied and pasted from somewhere else.
  826. </li><li> You should maintain alphabetical order in alphabetically ordered lists as
  827. long as doing so does not break API/ABI compatibility.
  828. </li><li> Lines with similar content should be aligned vertically when doing so
  829. improves readability.
  830. </li><li> Consider adding a regression test for your code. All new modules
  831. should be covered by tests. That includes demuxers, muxers, decoders, encoders
  832. filters, bitstream filters, parsers. If its not possible to do that, add
  833. an explanation why to your patchset, its ok to not test if there&rsquo;s a reason.
  834. </li><li> If you added NASM code please check that things still work with &ndash;disable-x86asm.
  835. </li><li> Test your code with valgrind and or Address Sanitizer to ensure it&rsquo;s free
  836. of leaks, out of array accesses, etc.
  837. </li></ol>
  838. <a name="Patch-review-process"></a>
  839. <h2 class="chapter">7 Patch review process<span class="pull-right"><a class="anchor hidden-xs" href="#Patch-review-process" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Patch-review-process" aria-hidden="true">TOC</a></span></h2>
  840. <p>All patches posted to ffmpeg-devel will be reviewed, unless they contain a
  841. clear note that the patch is not for the git master branch.
  842. Reviews and comments will be posted as replies to the patch on the
  843. mailing list. The patch submitter then has to take care of every comment,
  844. that can be by resubmitting a changed patch or by discussion. Resubmitted
  845. patches will themselves be reviewed like any other patch. If at some point
  846. a patch passes review with no comments then it is approved, that can for
  847. simple and small patches happen immediately while large patches will generally
  848. have to be changed and reviewed many times before they are approved.
  849. After a patch is approved it will be committed to the repository.
  850. </p>
  851. <p>We will review all submitted patches, but sometimes we are quite busy so
  852. especially for large patches this can take several weeks.
  853. </p>
  854. <p>If you feel that the review process is too slow and you are willing to try to
  855. take over maintainership of the area of code you change then just clone
  856. git master and maintain the area of code there. We will merge each area from
  857. where its best maintained.
  858. </p>
  859. <p>When resubmitting patches, please do not make any significant changes
  860. not related to the comments received during review. Such patches will
  861. be rejected. Instead, submit significant changes or new features as
  862. separate patches.
  863. </p>
  864. <p>Everyone is welcome to review patches. Also if you are waiting for your patch
  865. to be reviewed, please consider helping to review other patches, that is a great
  866. way to get everyone&rsquo;s patches reviewed sooner.
  867. </p>
  868. <a class="anchor" id="Regression-tests"></a><a name="Regression-tests-1"></a>
  869. <h2 class="chapter">8 Regression tests<span class="pull-right"><a class="anchor hidden-xs" href="#Regression-tests-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Regression-tests-1" aria-hidden="true">TOC</a></span></h2>
  870. <p>Before submitting a patch (or committing to the repository), you should at least
  871. test that you did not break anything.
  872. </p>
  873. <p>Running &rsquo;make fate&rsquo; accomplishes this, please see <a class="url" href="fate.html">fate.html</a> for details.
  874. </p>
  875. <p>[Of course, some patches may change the results of the regression tests. In
  876. this case, the reference results of the regression tests shall be modified
  877. accordingly].
  878. </p>
  879. <a name="Adding-files-to-the-fate_002dsuite-dataset"></a>
  880. <h3 class="section">8.1 Adding files to the fate-suite dataset<span class="pull-right"><a class="anchor hidden-xs" href="#Adding-files-to-the-fate_002dsuite-dataset" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Adding-files-to-the-fate_002dsuite-dataset" aria-hidden="true">TOC</a></span></h3>
  881. <p>If you need a sample uploaded send a mail to samples-request.
  882. </p>
  883. <p>When there is no muxer or encoder available to generate test media for a
  884. specific test then the media has to be included in the fate-suite.
  885. First please make sure that the sample file is as small as possible to test the
  886. respective decoder or demuxer sufficiently. Large files increase network
  887. bandwidth and disk space requirements.
  888. Once you have a working fate test and fate sample, provide in the commit
  889. message or introductory message for the patch series that you post to
  890. the ffmpeg-devel mailing list, a direct link to download the sample media.
  891. </p>
  892. <a name="Visualizing-Test-Coverage"></a>
  893. <h3 class="section">8.2 Visualizing Test Coverage<span class="pull-right"><a class="anchor hidden-xs" href="#Visualizing-Test-Coverage" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Visualizing-Test-Coverage" aria-hidden="true">TOC</a></span></h3>
  894. <p>The FFmpeg build system allows visualizing the test coverage in an easy
  895. manner with the coverage tools <code class="code">gcov</code>/<code class="code">lcov</code>. This involves
  896. the following steps:
  897. </p>
  898. <ol class="enumerate">
  899. <li> Configure to compile with instrumentation enabled:
  900. <code class="code">configure --toolchain=gcov</code>.
  901. </li><li> Run your test case, either manually or via FATE. This can be either
  902. the full FATE regression suite, or any arbitrary invocation of any
  903. front-end tool provided by FFmpeg, in any combination.
  904. </li><li> Run <code class="code">make lcov</code> to generate coverage data in HTML format.
  905. </li><li> View <code class="code">lcov/index.html</code> in your preferred HTML viewer.
  906. </li></ol>
  907. <p>You can use the command <code class="code">make lcov-reset</code> to reset the coverage
  908. measurements. You will need to rerun <code class="code">make lcov</code> after running a
  909. new test.
  910. </p>
  911. <a name="Using-Valgrind"></a>
  912. <h3 class="section">8.3 Using Valgrind<span class="pull-right"><a class="anchor hidden-xs" href="#Using-Valgrind" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Using-Valgrind" aria-hidden="true">TOC</a></span></h3>
  913. <p>The configure script provides a shortcut for using valgrind to spot bugs
  914. related to memory handling. Just add the option
  915. <code class="code">--toolchain=valgrind-memcheck</code> or <code class="code">--toolchain=valgrind-massif</code>
  916. to your configure line, and reasonable defaults will be set for running
  917. FATE under the supervision of either the <strong class="strong">memcheck</strong> or the
  918. <strong class="strong">massif</strong> tool of the valgrind suite.
  919. </p>
  920. <p>In case you need finer control over how valgrind is invoked, use the
  921. <code class="code">--target-exec='valgrind &lt;your_custom_valgrind_options&gt;</code> option in
  922. your configure line instead.
  923. </p>
  924. <a class="anchor" id="Maintenance"></a><a name="Maintenance-process"></a>
  925. <h2 class="chapter">9 Maintenance process<span class="pull-right"><a class="anchor hidden-xs" href="#Maintenance-process" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Maintenance-process" aria-hidden="true">TOC</a></span></h2>
  926. <a class="anchor" id="MAINTAINERS"></a><a name="MAINTAINERS-1"></a>
  927. <h3 class="section">9.1 MAINTAINERS<span class="pull-right"><a class="anchor hidden-xs" href="#MAINTAINERS-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-MAINTAINERS-1" aria-hidden="true">TOC</a></span></h3>
  928. <p>The developers maintaining each part of the codebase are listed in <samp class="file">MAINTAINERS</samp>.
  929. Being listed in <samp class="file">MAINTAINERS</samp>, gives one the right to have git write access to
  930. the specific repository.
  931. </p>
  932. <a class="anchor" id="Becoming-a-maintainer"></a><a name="Becoming-a-maintainer-1"></a>
  933. <h3 class="section">9.2 Becoming a maintainer<span class="pull-right"><a class="anchor hidden-xs" href="#Becoming-a-maintainer-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Becoming-a-maintainer-1" aria-hidden="true">TOC</a></span></h3>
  934. <p>People add themselves to <samp class="file">MAINTAINERS</samp> by sending a patch like any other code
  935. change. These get reviewed by the community like any other patch. It is expected
  936. that, if someone has an objection to a new maintainer, she is willing to object
  937. in public with her full name and is willing to take over maintainership for the area.
  938. </p>
  939. <a class="anchor" id="Release-process"></a><a name="Release-process-1"></a>
  940. <h2 class="chapter">10 Release process<span class="pull-right"><a class="anchor hidden-xs" href="#Release-process-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Release-process-1" aria-hidden="true">TOC</a></span></h2>
  941. <p>FFmpeg maintains a set of <strong class="strong">release branches</strong>, which are the
  942. recommended deliverable for system integrators and distributors (such as
  943. Linux distributions, etc.). At regular times, a <strong class="strong">release
  944. manager</strong> prepares, tests and publishes tarballs on the
  945. <a class="url" href="https://ffmpeg.org">https://ffmpeg.org</a> website.
  946. </p>
  947. <p>There are two kinds of releases:
  948. </p>
  949. <ol class="enumerate">
  950. <li> <strong class="strong">Major releases</strong> always include the latest and greatest
  951. features and functionality.
  952. </li><li> <strong class="strong">Point releases</strong> are cut from <strong class="strong">release</strong> branches,
  953. which are named <code class="code">release/X</code>, with <code class="code">X</code> being the release
  954. version number.
  955. </li></ol>
  956. <p>Note that we promise to our users that shared libraries from any FFmpeg
  957. release never break programs that have been <strong class="strong">compiled</strong> against
  958. previous versions of <strong class="strong">the same release series</strong> in any case!
  959. </p>
  960. <p>However, from time to time, we do make API changes that require adaptations
  961. in applications. Such changes are only allowed in (new) major releases and
  962. require further steps such as bumping library version numbers and/or
  963. adjustments to the symbol versioning file. Please discuss such changes
  964. on the <strong class="strong">ffmpeg-devel</strong> mailing list in time to allow forward planning.
  965. </p>
  966. <a class="anchor" id="Criteria-for-Point-Releases"></a><a name="Criteria-for-Point-Releases-1"></a>
  967. <h3 class="section">10.1 Criteria for Point Releases<span class="pull-right"><a class="anchor hidden-xs" href="#Criteria-for-Point-Releases-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Criteria-for-Point-Releases-1" aria-hidden="true">TOC</a></span></h3>
  968. <p>Changes that match the following criteria are valid candidates for
  969. inclusion into a point release:
  970. </p>
  971. <ol class="enumerate">
  972. <li> Fixes a security issue, preferably identified by a <strong class="strong">CVE
  973. number</strong> issued by <a class="url" href="http://cve.mitre.org/">http://cve.mitre.org/</a>.
  974. </li><li> Fixes a documented bug in <a class="url" href="https://trac.ffmpeg.org">https://trac.ffmpeg.org</a>.
  975. </li><li> Improves the included documentation.
  976. </li><li> Retains both source code and binary compatibility with previous
  977. point releases of the same release branch.
  978. </li></ol>
  979. <p>The order for checking the rules is (1 OR 2 OR 3) AND 4.
  980. </p>
  981. <a name="Release-Checklist"></a>
  982. <h3 class="section">10.2 Release Checklist<span class="pull-right"><a class="anchor hidden-xs" href="#Release-Checklist" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Release-Checklist" aria-hidden="true">TOC</a></span></h3>
  983. <p>The release process involves the following steps:
  984. </p>
  985. <ol class="enumerate">
  986. <li> Ensure that the <samp class="file">RELEASE</samp> file contains the version number for
  987. the upcoming release.
  988. </li><li> Add the release at <a class="url" href="https://trac.ffmpeg.org/admin/ticket/versions">https://trac.ffmpeg.org/admin/ticket/versions</a>.
  989. </li><li> Announce the intent to do a release to the mailing list.
  990. </li><li> Make sure all relevant security fixes have been backported. See
  991. <a class="url" href="https://ffmpeg.org/security.html">https://ffmpeg.org/security.html</a>.
  992. </li><li> Ensure that the FATE regression suite still passes in the release
  993. branch on at least <strong class="strong">i386</strong> and <strong class="strong">amd64</strong>
  994. (cf. <a class="ref" href="#Regression-tests">Regression tests</a>).
  995. </li><li> Prepare the release tarballs in <code class="code">bz2</code> and <code class="code">gz</code> formats, and
  996. supplementing files that contain <code class="code">gpg</code> signatures
  997. </li><li> Publish the tarballs at <a class="url" href="https://ffmpeg.org/releases">https://ffmpeg.org/releases</a>. Create and
  998. push an annotated tag in the form <code class="code">nX</code>, with <code class="code">X</code>
  999. containing the version number.
  1000. </li><li> Propose and send a patch to the <strong class="strong">ffmpeg-devel</strong> mailing list
  1001. with a news entry for the website.
  1002. </li><li> Publish the news entry.
  1003. </li><li> Send an announcement to the mailing list.
  1004. </li></ol>
  1005. <p style="font-size: small;">
  1006. This document was generated using <a class="uref" href="https://www.gnu.org/software/texinfo/"><em class="emph">makeinfo</em></a>.
  1007. </p>
  1008. </div>
  1009. </body>
  1010. </html>