1 Dirac software development practices
2 ====================================
7 1. Licenses and submitting work
9 2. Sourceforge Developers forum
13 4. Using the CVS repository
19 7. Profiling & optimisation
23 9. Binary files in CVS
27 1. Licenses and submitting work
28 -------------------------------
30 Developers submitting work to the Dirac project should print out,
31 complete, and sign the Developer's Certificate of Origin contained
32 in the DCO.developers file. It should be posted to:
35 BBC Research and Development
41 For simplicity developers must submit code using the same
42 license that we distribute under, which is the Mozilla Triple
43 license (http://www.mozilla.org/MPL/). Using any other license
44 causes complexity and FUD.
46 Contributions should be in the form of a patch, which may be for a
47 whole directory. For changes to an existing file all that is needed
48 is to add the author's name to the list of contributors, since the
49 license will remain the MPL. For new files, the header in each file
50 should be completed from Exhibit A, the Mozilla Triple License (from the
51 COPYING file). It should NOT be copied from files already obtained
52 in the Dirac project, since some details may differ.
54 To create a context diff patch run the command
56 diff -ruN compress-orig compress-mods > patch.txt
58 where compress-orig is the directory with the original code and
59 compress-mods is the directory with the modified files.
61 The patch.txt file should then be submitted to the Sourceforge Patch
64 2. Sourceforge Developers forum
65 -------------------------------
66 The Developers forum is where Dirac core developers plan and coordinate
67 changes to Dirac. All API changes, new features and implementation
68 difficulties are announced and discussed here.
70 Examples of changes which should be announced in the Developers forum:
72 - Pic API change: return bool instead of void for ReadNextFrame
73 - Pic API change: most methods can now throw ErrorState objects
75 Changes which are small in scope and unlikely to affect developers
76 should not be announced on the forum. Changes which touch
77 many files can fall into this category - for example
79 - Fixed inconsistent CRLF line-endings to be LF.
80 - Fixed "use of uninitialised variable" cases found by gcc.
81 - Fixed memory leak in all instantiations of Pic (found by valgrind).
82 - Add feature test for stdint.h to be portable to Solaris.
84 Developers should 'monitor' the forums by going to the forum page and
85 clicking 'Monitor this forum'. Any new message will then be emailed
86 to their username@users.sourceforge.net email address.
87 http://sourceforge.net/forum/forum.php?forum_id=353620
92 Developers should subscribe to the dirac-announce and dirac-commits
93 mailing lists. dirac-announce is used to announce new releases and
94 dirac-commits is sent mail automatically for every commit.
97 4. Using the CVS repository
98 ---------------------------
100 The latest (but non-stable) version of the code can be downloaded direct
101 from the Sourceforge repository using anonymous CVS. Instructions for
102 doing so can be found at the Dirac CVS page:
104 http://sourceforge.net/cvs/?group_id=102564
106 The Dirac codec module is called 'compress'.
108 To compile the codec from the CVS sources, the configure script must be
109 built using autotools. The required autotool operations have been
110 collated in a bootstrap script - simply type
114 at the command prompt in the installation directory. Then follow the
115 usual install instructions in the INSTALL document.
119 Always indicate why the change is necessary in addition to a succinct summary
120 of what as changed. As the number of developers increases it becomes
121 increasingly difficult for developers to understand the changes going on in
122 areas they are not familiar with. If the changes relate to an API change
123 developers may not realise this if it is not mentioned in the log message
124 as the reason for the change.
129 - Added gamma parameter
130 - Replace stricmp with strcasecmp
134 - Added gamma parameter to record more accurate data on source material
135 - Enhanced portability: stricmp replaced by strcasecmp (the POSIX standard)
138 6. Software practices
139 ---------------------
141 This project aims to be as portable as possible and to that end follows the
143 POSIX 1003.1 - System Interfaces volume (XSH) & Threads
146 The only exception to this practice is for the Microsoft Visual C++ compiler
147 which continues to fall short of all the above standards. Where MS VC++
148 is incompatible with the standards, experiment is often necessary to find
149 an alternative usage which works under MS VC++. Use of the _MSC_VER macro
150 in conditional compilation is the accepted way to accommodate such
155 The following guidelines must be adhered to while developing code.
159 - Include the following RCS tags in all new files (.cpp and .h). Include them
160 on the first line of the licence block
166 /* ***** BEGIN LICENSE BLOCK *****
170 * rest of licence text
171 * ***** END LICENSE BLOCK ***** */
174 - Remove the following tags from all files. Do not include them in new files
179 -- General Source code formatting
181 - Use spaces in assigment statements and compound statements to make code
190 - Curly braces go on a separate line
203 Curly braces can be ommitted if there is only one statment in the block.
205 - Use space between the comment marker and start of text
211 * This is a multiple line
215 - Use spaces instead of tabs for indentation
217 - Indent Constructor initialiser lists from the constructor name
220 MyClass::Myclass (int val) :
227 - All core Dirac functionality must be in the namespace dirac.
228 - All other functionality must be defined in a namespace of its own. E.g.
229 conversion utilities are in the namespace dirac_vu, instrumentation utilities
230 are in the namespace dirac_instr.
232 -- General naming standards
234 - Local variables are lowercase and use underscores to separate words.
240 - Use constants instead of macros
242 - Type definitions and Enumerations start with an uppercase letter and
243 use lowercase multi-word names using an uppercase letter for each new word.
247 typedef int CompressionType;
252 - Class names start with an uppercase letter and the use lowercase with
253 multi-word names using an uppercase letter for each new word.
256 - Class member variables are lowercase with a leading "m_". Use underscores to
262 - Group declaration of member functions and member variables in the class
263 defintion based on access type.
275 void SetValue(int val);
284 - Avoid declaring public member variables. Make them private and define access
285 functions to set/get their values.
287 - Avoid defining functions in class definitions except for trivial functions
289 - The declaration syntax for accessor/mutator functions is as follows
291 void SetVariable (const VariableType& var);
293 VariableType Variable() const;
294 const VariableType& Variable() const;
297 - Use builtin copy constructors and assigment operators whenever appropriate
298 e.g. when the class does not use dynamic memory allocation, but their use
299 should be commented. This is to ensure that changes to the class are properly
300 reflected in these operators.
302 - Encapsulate enumerated types in the class definition if the enumerated type
303 is relevant only to that class.
305 - Nest classes within a class if they have no meaning outside the context of
308 -- Function Definitions
310 - Function names start with an upperccase letter and the use lowercase with
311 multi-word names using an uppercase letter for each new word.
314 - Function parameters are lowercase. Use underscores to separate words.
316 void BandCodec::Resize(const int& context_num)
318 - Use the following notation for reference parameters in a function
319 void BandCodec::Resize(const int& context_num)
321 void BandCodec::Resize(const int &context_num)
323 - Dummy argument names, if used, should be the same in the function
324 declarations and definitions to avoid confusion.
329 All code will be peer-reviewed before being checked in to SourceForge
330 CVS. Developers should use the guidelines specified in the Coding Style
331 sub-section while reviewing code.
333 IV. Testing with "make check"
334 Developers should aim to have all the regression tests succeed. If a
335 developer anticipates breaking the tests (while a significant body of work
336 is being undertaken) this must be announced on the Developer Forum, and
337 the fixing of the tests would be coordinated there.
339 Only one test file is included in the Dirac distribution. In order to run
340 end to end tests, it is necessary to have test Dirac using all supported
341 sizes and formats. The samples.at test case attempts to handle this by
342 running Dirac encoder/decoder/instrumentation tests on all input files in
343 the directory specified by the env variable DIRAC_INPUT_DATA_DIR.
345 Sample files in rgb format are available for download from the Dirac project
346 page on Sourceforge. The main Dirac distribution now includes a scripts
347 create_dirac_testfile.pl that converts an rgb file into all the planar
348 YUV formats supported by Dirac and creates the header files. The -use
349 option to this script display usage information. See Step 3 in section
350 4.2 (File Formats) of the README file for an example of how to use this
354 Developers should also aim to have good test coverage especially when
355 adding functionality. When adding a new feature, expect to be asked
358 A new target 'valgrind-check' has been included which uses valgrind, if
359 available, to check for memory leaks, uninitialised memory reads, invalid
363 7. Profiling & optimisation
364 ---------------------------
365 Dirac is alpha software so developers cannot expect optimisation improvements
366 to survive algorithm improvements or code refactoring and restructuring. That
367 being said, the Dirac maintainers would like to encourage profiling analysis
368 and portable and modular optimisation. Developers are encouraged to share
369 their profiling analysis techniques and results. The following guidelines
372 - Any optimisation patch must be accompanied by at least a summary of
373 profile analysis and timing results for a range of video material. There
374 must be sufficient information for other developers to reproduce the
377 - The preferred method for introducing MMX/SSE/SSE2 optimisation is C/C++
378 intrinsics, since this is well supported by GNU C++, Intel C++ and (more or
379 less) MSVC. See libdirac_motionest/me_utils_mmx.cpp.
381 - Developers should take extra care to check their optimisation produces
382 indentical bitstream output for the encoder, or identical uncompressed
383 output for the decoder compared to the unoptimised version.
385 - x86-specific optimisations need not be limited to MMX since SSE is
386 readily available on PentiumIII and AMD Athlons. SSE2 optimisation is
387 encouraged since it becoming more commonly available (on Pentium4,
388 Athlon64 and Opteron), but take care to use a portable 16byte memory
391 - ./configure detects MMX availability and sets the macro HAVE_MMX, if
392 MMX optimisations is available, by default. To disable MMX optimisations
393 use the --disable-mmx flag with configure.
395 Profiling can be supported by adding the following parameter to ./configure
400 The code can then be profiled by, for example, gprof.
405 All source code and documentation will have LF line-endings, include makefiles
406 and scripts. The only exception will be for .vcproj and .sln (and any other
407 WIN32 specific) files which will not function under MS VC++ unless they use
411 9. Binary files in CVS
412 ----------------------
413 CVS will modify files during checkin and checkout unless they are tagged as
414 binary. The modifications include translation of CR-LF <-> LF (depending on
415 the OS of the CVS client) and expansion of CVS keywords such as $Id and $Log.
417 Files which must not be modified in this way must be tagged as binary either
418 using the add command or admin command:
420 cvs admin -kb fig1.jpg (for files already in CVS)
422 MS VC++ project files, such as .vcproj and .sln, fall into this category since
423 they do not function if their line-endings are not CR-LF.