developer.html 61 KB

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