Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
isom: sort and pretty-print codec_movaudio_tags[]
isom: remove pointless comments in codec_movaudio_tags[]
isom: remove commented-out tag for vorbis
movenc: write 'chan' tag for AC-3 in MOV
mov: add support for reading and writing the 'chan' tag
audioconvert: add some additional channel and channel layout macros
audioconvert: change 7.1 "wide" layout to use side surround channels
movenc: simplify handling of pcm vs. adpcm vs. other compressed codecs
doc: update documentation to use avconv
doc: update demuxers section
doc: extend external library coverage
doc: split platform specific information
doc: port the git-howto to texinfo
doc: provide fallback css and customize @float
doc: document fate in a texinfo
doxy: change hue value to match our green

Conflicts:
doc/fate.txt
doc/ffserver.texi
doc/general.texi
doc/muxers.texi
doc/protocols.texi
doc/t2h.init
libavformat/isom.c
libavformat/mov.c
libavutil/avutil.h
tests/ref/acodec/pcm_s16be
tests/ref/acodec/pcm_s24be
tests/ref/acodec/pcm_s32be
tests/ref/acodec/pcm_s8
tests/ref/lavf/mov

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/12/10 09:25:15
Showing 27 changed files
... ...
@@ -820,7 +820,7 @@ HTML_STYLESHEET        =
820 820
 # 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
821 821
 # The allowed range is 0 to 359.
822 822
 
823
-HTML_COLORSTYLE_HUE    = 220
823
+HTML_COLORSTYLE_HUE    = 120
824 824
 
825 825
 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
826 826
 # the colors in the HTML output. For a value of 0 the output will use
... ...
@@ -3,8 +3,11 @@ PODPAGES    = $(PROGS-yes:%=doc/%.pod)
3 3
 HTMLPAGES   = $(PROGS-yes:%=doc/%.html)                                 \
4 4
               doc/developer.html                                        \
5 5
               doc/faq.html                                              \
6
+              doc/fate.html                                             \
6 7
               doc/general.html                                          \
8
+              doc/git-howto.html                                        \
7 9
               doc/libavfilter.html                                      \
10
+              doc/platform.html                                         \
8 11
 
9 12
 DOCS = $(HTMLPAGES) $(MANPAGES) $(PODPAGES)
10 13
 
... ...
@@ -132,8 +132,8 @@ libavcodec libraries. To see the list of available AVOptions, use the
132 132
 @option{-help} option. They are separated into two categories:
133 133
 @table @option
134 134
 @item generic
135
-These options can be set for any container, codec or device. Generic options are
136
-listed under AVFormatContext options for containers/devices and under
135
+These options can be set for any container, codec or device. Generic options
136
+are listed under AVFormatContext options for containers/devices and under
137 137
 AVCodecContext options for codecs.
138 138
 @item private
139 139
 These options are specific to the given container, device or codec. Private
... ...
@@ -150,8 +150,8 @@ ffmpeg -i input.flac -id3v2_version 3 out.mp3
150 150
 All codec AVOptions are obviously per-stream, so the chapter on stream
151 151
 specifiers applies to them
152 152
 
153
-Note -nooption syntax cannot be used for boolean AVOptions, use -option
154
-0/-option 1.
153
+Note @option{-nooption} syntax cannot be used for boolean AVOptions,
154
+use @option{-option 0}/@option{-option 1}.
155 155
 
156 156
 Note2 old undocumented way of specifying per-stream AVOptions by prepending
157 157
 v/a/s to the options name is now obsolete and will be removed soon.
... ...
@@ -34,7 +34,7 @@ JPEG image. The individual frames can be extracted without loss,
34 34
 e.g. by
35 35
 
36 36
 @example
37
-ffmpeg -i ../some_mjpeg.avi -vcodec copy frames_%d.jpg
37
+ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
38 38
 @end example
39 39
 
40 40
 Unfortunately, these chunks are incomplete JPEG images, because
... ...
@@ -57,9 +57,9 @@ stream (carrying the AVI1 header ID and lacking a DHT segment) to
57 57
 produce fully qualified JPEG images.
58 58
 
59 59
 @example
60
-ffmpeg -i mjpeg-movie.avi -vcodec copy -vbsf mjpeg2jpeg frame_%d.jpg
60
+ffmpeg -i mjpeg-movie.avi -c:v copy -vbsf mjpeg2jpeg frame_%d.jpg
61 61
 exiftran -i -9 frame*.jpg
62
-ffmpeg -i frame_%d.jpg -vcodec copy rotated.avi
62
+ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
63 63
 @end example
64 64
 
65 65
 @section mjpega_dump_header
... ...
@@ -49,19 +49,19 @@ sequence of filenames of the form @file{i%m%g-1.jpg},
49 49
 The size, the pixel format, and the format of each image must be the
50 50
 same for all the files in the sequence.
51 51
 
52
-The following example shows how to use @file{ffmpeg} for creating a
52
+The following example shows how to use @command{ffmpeg} for creating a
53 53
 video from the images in the file sequence @file{img-001.jpeg},
54 54
 @file{img-002.jpeg}, ..., assuming an input frame rate of 10 frames per
55 55
 second:
56 56
 @example
57
-ffmpeg -r 10 -f image2 -i 'img-%03d.jpeg' out.avi
57
+ffmpeg -i 'img-%03d.jpeg' -r 10 out.mkv
58 58
 @end example
59 59
 
60 60
 Note that the pattern must not necessarily contain "%d" or
61 61
 "%0@var{N}d", for example to convert a single image file
62 62
 @file{img.jpeg} you can employ the command:
63 63
 @example
64
-ffmpeg -f image2 -i img.jpeg img.png
64
+ffmpeg -i img.jpeg img.png
65 65
 @end example
66 66
 
67 67
 @section applehttp
68 68
new file mode 100644
... ...
@@ -0,0 +1,135 @@
0
+\input texinfo @c -*- texinfo -*-
1
+
2
+@settitle FATE Automated Testing Environment
3
+@titlepage
4
+@center @titlefont{FATE Automated Testing Environment}
5
+@end titlepage
6
+
7
+@top
8
+
9
+@contents
10
+
11
+@chapter Introduction
12
+
13
+FATE provides a regression testsuite embedded within the FFmpeg build system.
14
+It can be run locally and optionally configured to send reports to a web
15
+aggregator and viewer @url{http://fate.ffmpeg.org}.
16
+
17
+It is advised to run FATE before submitting patches to the current codebase
18
+and provide new tests when submitting patches to add additional features.
19
+
20
+@chapter Running FATE
21
+
22
+@section Samples and References
23
+In order to run, FATE needs a large amount of data (samples and references)
24
+that is provided separately from the actual source distribution.
25
+
26
+To inform the build system about the testsuite location, pass
27
+@option{--samples=<path to the samples>} to @command{configure} or set the
28
+@var{SAMPLES} Make variable or the @var{FATE_SAMPLES} environment variable
29
+to a suitable value.
30
+
31
+The dataset is available through @command{rsync}, is possible to fetch
32
+the current sample using the straight rsync command or through a specific
33
+@ref{Makefile target}.
34
+
35
+@example
36
+# rsync -aL rsync://fate.ffmpeg.org/fate-suite/ fate-suite
37
+@end example
38
+
39
+@example
40
+# make fate-rsync SAMPLES=fate-suite
41
+@end example
42
+
43
+
44
+@chapter Manual Run
45
+FATE regression test can be run through @command{make}.
46
+Specific Makefile targets and Makefile variables are available:
47
+
48
+@anchor{Makefile target}
49
+@section FATE Makefile targets
50
+@table @option
51
+@item fate-list
52
+List all fate/regression test targets.
53
+@item fate-rsync
54
+Shortcut to download the fate test samples to the specified testsuite location.
55
+@item fate
56
+Run the FATE test suite (requires the fate-suite dataset).
57
+@end table
58
+
59
+@section Fate Makefile variables
60
+@table @option
61
+@item V
62
+Verbosity level, can be set to 0, 1 or 2.
63
+@table @option
64
+    @item 0
65
+    show just the test arguments
66
+    @item 1
67
+    show just the command used in the test
68
+    @item 2
69
+    show everything
70
+@end table
71
+@item SAMPLES
72
+Specify or override the path to the FATE samples at make time, it has a
73
+meaning only while running the regression tests.
74
+@item THREADS
75
+Specify how many threads to use while running regression tests, it is
76
+quite useful to detect thread-related regressions.
77
+@end table
78
+
79
+@example
80
+    make V=1 SAMPLES=/var/fate/samples THREADS=2 fate
81
+@end example
82
+
83
+@chapter Automated Tests
84
+In order to automatically testing specific configurations, e.g. multiple
85
+compilers, @command{tests/fate.sh} is provided.
86
+
87
+This shell script builds FFmpeg, runs the regression tests and prepares a
88
+report that can be sent to @url{fate.ffmpeg.org} or directly examined locally.
89
+
90
+@section Testing Profiles
91
+The configuration file passed to @command{fate.sh} is shell scripts as well.
92
+
93
+It must provide at least a @var{slot} identifier, the @var{repo} from
94
+which fetch the sources, the @var{samples} directory, a @var{workdir} with
95
+enough space to build and run all the tests.
96
+Optional submit command @var{fate_recv} and a @var{comment} to describe
97
+the testing profile are available.
98
+
99
+Additional optional parameter to tune the FFmpeg building and reporting process
100
+can be passed.
101
+
102
+@example
103
+slot=                                   # some unique identifier
104
+repo=git://source.ffmpeg.org/ffmpeg.git # the source repository
105
+samples=/path/to/fate/samples
106
+workdir=                                # directory in which to do all the work
107
+fate_recv="ssh -T fate@fate.ffmpeg.org" # command to submit report
108
+comment=                                # optional description
109
+
110
+# the following are optional and map to configure options
111
+arch=
112
+cpu=
113
+cross_prefix=
114
+cc=
115
+target_os=
116
+sysroot=
117
+target_exec=
118
+target_path=
119
+extra_cflags=
120
+extra_ldflags=
121
+extra_libs=
122
+extra_conf=     # extra configure options not covered above
123
+
124
+#make=          # name of GNU make if not 'make'
125
+makeopts=       # extra options passed to 'make'
126
+#tar=           # command to create a tar archive from its arguments on
127
+                # stdout, defaults to 'tar c'
128
+@end example
129
+
130
+@section Submitting Reports
131
+In order to send reports you need to create an @command{ssh} key and send it
132
+to the fate server administrator.
133
+The current server fingerprint is @var{b1:31:c8:79:3f:04:1d:f8:f2:23:26:5a:fd:55:fa:92}
134
+
... ...
@@ -34,7 +34,7 @@ file.
34 34
 
35 35
 This documentation covers only the streaming aspects of ffserver /
36 36
 ffmpeg. All questions about parameters for ffmpeg, codec questions,
37
-etc. are not covered here. Read @file{ffmpeg-doc.html} for more
37
+etc. are not covered here. Read @file{ffmpeg.html} for more
38 38
 information.
39 39
 
40 40
 @section How does it work?
... ...
@@ -265,7 +265,7 @@ rather than as a daemon.
265 265
 
266 266
 @c man begin SEEALSO
267 267
 
268
-ffmpeg(1), ffplay(1), ffprobe(1), the @file{ffmpeg/doc/ffserver.conf}
268
+ffmpeg(1), ffplay(1), ffprobe(1), the @file{ffserver.conf}
269 269
 example and the FFmpeg HTML documentation
270 270
 @c man end
271 271
 
... ...
@@ -9,7 +9,7 @@
9 9
 
10 10
 @contents
11 11
 
12
-@chapter external libraries
12
+@chapter External libraries
13 13
 
14 14
 FFmpeg can be hooked up with a number of external libraries to add support
15 15
 for more formats. None of them are used by default, their use has to be
... ...
@@ -23,20 +23,75 @@ instructions.  To enable using OpenJPEG in FFmpeg, pass @code{--enable-libopenjp
23 23
 @file{./configure}.
24 24
 
25 25
 
26
-@section OpenCORE AMR
26
+@section OpenCORE and VisualOn libraries
27 27
 
28
-FFmpeg can make use of the OpenCORE libraries for AMR-NB
29
-decoding/encoding and AMR-WB decoding.
28
+Spun off Google Android sources, OpenCore and VisualOn libraries provide
29
+encoders for a number of audio codecs.
30 30
 
31
-Go to @url{http://sourceforge.net/projects/opencore-amr/} and follow the instructions for
32
-installing the libraries. Then pass @code{--enable-libopencore-amrnb} and/or
33
-@code{--enable-libopencore-amrwb} to configure to enable the libraries.
34
-
35
-Note that OpenCORE is under the Apache License 2.0 (see
36
-@url{http://www.apache.org/licenses/LICENSE-2.0} for details), which is
31
+@float NOTE
32
+OpenCORE and VisualOn libraries are under the Apache License 2.0
33
+(see @url{http://www.apache.org/licenses/LICENSE-2.0} for details), which is
37 34
 incompatible with the LGPL version 2.1 and GPL version 2. You have to
38 35
 upgrade FFmpeg's license to LGPL version 3 (or if you have enabled
39 36
 GPL components, GPL version 3) to use it.
37
+@end float
38
+
39
+@subsection OpenCORE AMR
40
+
41
+FFmpeg can make use of the OpenCORE libraries for AMR-NB
42
+decoding/encoding and AMR-WB decoding.
43
+
44
+Go to @url{http://sourceforge.net/projects/opencore-amr/} and follow the
45
+instructions for installing the libraries.
46
+Then pass @code{--enable-libopencore-amrnb} and/or
47
+@code{--enable-libopencore-amrwb} to configure to enable them.
48
+
49
+@subsection VisualOn AAC encoder library
50
+
51
+FFmpeg can make use of the VisualOn AACenc library for AAC encoding.
52
+
53
+Go to @url{http://sourceforge.net/projects/opencore-amr/} and follow the
54
+instructions for installing the library.
55
+Then pass @code{--enable-libvo-aacenc} to configure to enable it.
56
+
57
+@subsection VisualOn AMR-WB encoder library
58
+
59
+FFmpeg can make use of the VisualOn AMR-WBenc library for AMR-WB encoding.
60
+
61
+Go to @url{http://sourceforge.net/projects/opencore-amr/} and follow the
62
+instructions for installing the library.
63
+Then pass @code{--enable-libvo-amrwbenc} to configure to enable it.
64
+
65
+@section LAME
66
+
67
+FFmpeg can make use of the LAME library for MP3 encoding.
68
+
69
+Go to @url{http://lame.sourceforge.net/} and follow the
70
+instructions for installing the library.
71
+Then pass @code{--enable-libmp3lame} to configure to enable it.
72
+
73
+@section libvpx
74
+
75
+FFmpeg can make use of the libvpx library for VP8 encoding.
76
+
77
+Go to @url{http://www.webmproject.org/} and follow the instructions for
78
+installing the library. Then pass @code{--enable-libvpx} to configure to
79
+enable it.
80
+
81
+@section x264
82
+
83
+FFmpeg can make use of the x264 library for H.264 encoding.
84
+
85
+Go to @url{http://www.videolan.org/developers/x264.html} and follow the
86
+instructions for installing the library. Then pass @code{--enable-libx264} to
87
+configure to enable it.
88
+
89
+@float NOTE
90
+x264 is under the GNU Public License Version 2 or later
91
+(see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
92
+details), you must upgrade FFmpeg's license to GPL in order to use it.
93
+@end float
94
+
40 95
 
41 96
 
42 97
 @chapter Supported File Formats and Codecs
... ...
@@ -797,378 +852,4 @@ performance on systems without hardware floating point support).
797 797
 
798 798
 @code{X} means that input/output is supported.
799 799
 
800
-
801
-@chapter Platform Specific information
802
-
803
-@section DOS
804
-
805
-Using a cross-compiler is preferred for various reasons.
806
-
807
-@section OS/2
808
-
809
-For information about compiling FFmpeg on OS/2 see
810
-@url{http://www.edm2.com/index.php/FFmpeg}.
811
-
812
-@section Unix-like
813
-
814
-Some parts of FFmpeg cannot be built with version 2.15 of the GNU
815
-assembler which is still provided by a few AMD64 distributions. To
816
-make sure your compiler really uses the required version of gas
817
-after a binutils upgrade, run:
818
-
819
-@example
820
-$(gcc -print-prog-name=as) --version
821
-@end example
822
-
823
-If not, then you should install a different compiler that has no
824
-hard-coded path to gas. In the worst case pass @code{--disable-asm}
825
-to configure.
826
-
827
-@subsection BSD
828
-
829
-BSD make will not build FFmpeg, you need to install and use GNU Make
830
-(@file{gmake}).
831
-
832
-@subsection (Open)Solaris
833
-
834
-GNU Make is required to build FFmpeg, so you have to invoke (@file{gmake}),
835
-standard Solaris Make will not work. When building with a non-c99 front-end
836
-(gcc, generic suncc) add either @code{--extra-libs=/usr/lib/values-xpg6.o}
837
-or @code{--extra-libs=/usr/lib/64/values-xpg6.o} to the configure options
838
-since the libc is not c99-compliant by default. The probes performed by
839
-configure may raise an exception leading to the death of configure itself
840
-due to a bug in the system shell. Simply invoke a different shell such as
841
-bash directly to work around this:
842
-
843
-@example
844
-bash ./configure
845
-@end example
846
-
847
-@anchor{Darwin}
848
-@subsection Darwin (OSX, iPhone)
849
-
850
-The toolchain provided with Xcode is sufficient to build the basic
851
-unacelerated code.
852
-
853
-OSX on PowerPC or ARM (iPhone) requires a preprocessor from
854
-@url{http://github.com/yuvi/gas-preprocessor} to build the optimized
855
-assembler functions. Just download the Perl script and put it somewhere
856
-in your PATH, FFmpeg's configure will pick it up automatically.
857
-
858
-OSX on amd64 and x86 requires @command{yasm} to build most of the
859
-optimized assembler functions @url{http://mxcl.github.com/homebrew/, Homebrew},
860
-@url{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix}
861
-or @url{http://www.macports.org, MacPorts} can easily provide it.
862
-
863
-@section Windows
864
-
865
-To get help and instructions for building FFmpeg under Windows, check out
866
-the FFmpeg Windows Help Forum at
867
-@url{http://ffmpeg.arrozcru.org/}.
868
-
869
-@subsection Native Windows compilation
870
-
871
-FFmpeg can be built to run natively on Windows using the MinGW tools. Install
872
-the latest versions of MSYS and MinGW from @url{http://www.mingw.org/}.
873
-You can find detailed installation instructions in the download
874
-section and the FAQ.
875
-
876
-FFmpeg does not build out-of-the-box with the packages the automated MinGW
877
-installer provides. It also requires coreutils to be installed and many other
878
-packages updated to the latest version. The minimum version for some packages
879
-are listed below:
880
-
881
-@itemize
882
-@item bash 3.1
883
-@item msys-make 3.81-2 (note: not mingw32-make)
884
-@item w32api 3.13
885
-@item mingw-runtime 3.15
886
-@end itemize
887
-
888
-FFmpeg automatically passes @code{-fno-common} to the compiler to work around
889
-a GCC bug (see @url{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216}).
890
-
891
-Notes:
892
-
893
-@itemize
894
-
895
-@item Building natively using MSYS can be sped up by disabling implicit rules
896
-in the Makefile by calling @code{make -r} instead of plain @code{make}. This
897
-speed up is close to non-existent for normal one-off builds and is only
898
-noticeable when running make for a second time (for example in
899
-@code{make install}).
900
-
901
-@item In order to compile FFplay, you must have the MinGW development library
902
-of @uref{http://www.libsdl.org/, SDL}.
903
-Edit the @file{bin/sdl-config} script so that it points to the correct prefix
904
-where SDL was installed. Verify that @file{sdl-config} can be launched from
905
-the MSYS command line.
906
-
907
-@item By using @code{./configure --enable-shared} when configuring FFmpeg,
908
-you can build the FFmpeg libraries (e.g. libavutil, libavcodec,
909
-libavformat) as DLLs.
910
-
911
-@end itemize
912
-
913
-@subsection Microsoft Visual C++ compatibility
914
-
915
-As stated in the FAQ, FFmpeg will not compile under MSVC++. However, if you
916
-want to use the libav* libraries in your own applications, you can still
917
-compile those applications using MSVC++. But the libav* libraries you link
918
-to @emph{must} be built with MinGW. However, you will not be able to debug
919
-inside the libav* libraries, since MSVC++ does not recognize the debug
920
-symbols generated by GCC.
921
-We strongly recommend you to move over from MSVC++ to MinGW tools.
922
-
923
-This description of how to use the FFmpeg libraries with MSVC++ is based on
924
-Microsoft Visual C++ 2005 Express Edition. If you have a different version,
925
-you might have to modify the procedures slightly.
926
-
927
-@subsubsection Using static libraries
928
-
929
-Assuming you have just built and installed FFmpeg in @file{/usr/local}.
930
-
931
-@enumerate
932
-
933
-@item Create a new console application ("File / New / Project") and then
934
-select "Win32 Console Application". On the appropriate page of the
935
-Application Wizard, uncheck the "Precompiled headers" option.
936
-
937
-@item Write the source code for your application, or, for testing, just
938
-copy the code from an existing sample application into the source file
939
-that MSVC++ has already created for you. For example, you can copy
940
-@file{libavformat/output-example.c} from the FFmpeg distribution.
941
-
942
-@item Open the "Project / Properties" dialog box. In the "Configuration"
943
-combo box, select "All Configurations" so that the changes you make will
944
-affect both debug and release builds. In the tree view on the left hand
945
-side, select "C/C++ / General", then edit the "Additional Include
946
-Directories" setting to contain the path where the FFmpeg includes were
947
-installed (i.e. @file{c:\msys\1.0\local\include}).
948
-Do not add MinGW's include directory here, or the include files will
949
-conflict with MSVC's.
950
-
951
-@item Still in the "Project / Properties" dialog box, select
952
-"Linker / General" from the tree view and edit the
953
-"Additional Library Directories" setting to contain the @file{lib}
954
-directory where FFmpeg was installed (i.e. @file{c:\msys\1.0\local\lib}),
955
-the directory where MinGW libs are installed (i.e. @file{c:\mingw\lib}),
956
-and the directory where MinGW's GCC libs are installed
957
-(i.e. @file{C:\mingw\lib\gcc\mingw32\4.2.1-sjlj}). Then select
958
-"Linker / Input" from the tree view, and add the files @file{libavformat.a},
959
-@file{libavcodec.a}, @file{libavutil.a}, @file{libmingwex.a},
960
-@file{libgcc.a}, and any other libraries you used (i.e. @file{libz.a})
961
-to the end of "Additional Dependencies".
962
-
963
-@item Now, select "C/C++ / Code Generation" from the tree view. Select
964
-"Debug" in the "Configuration" combo box. Make sure that "Runtime
965
-Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in
966
-the "Configuration" combo box and make sure that "Runtime Library" is
967
-set to "Multi-threaded DLL".
968
-
969
-@item Click "OK" to close the "Project / Properties" dialog box.
970
-
971
-@item MSVC++ lacks some C99 header files that are fundamental for FFmpeg.
972
-Get msinttypes from @url{http://code.google.com/p/msinttypes/downloads/list}
973
-and install it in MSVC++'s include directory
974
-(i.e. @file{C:\Program Files\Microsoft Visual Studio 8\VC\include}).
975
-
976
-@item MSVC++ also does not understand the @code{inline} keyword used by
977
-FFmpeg, so you must add this line before @code{#include}ing libav*:
978
-@example
979
-#define inline _inline
980
-@end example
981
-
982
-@item Build your application, everything should work.
983
-
984
-@end enumerate
985
-
986
-@subsubsection Using shared libraries
987
-
988
-This is how to create DLL and LIB files that are compatible with MSVC++:
989
-
990
-@enumerate
991
-
992
-@item Add a call to @file{vcvars32.bat} (which sets up the environment
993
-variables for the Visual C++ tools) as the first line of @file{msys.bat}.
994
-The standard location for @file{vcvars32.bat} is
995
-@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat},
996
-and the standard location for @file{msys.bat} is @file{C:\msys\1.0\msys.bat}.
997
-If this corresponds to your setup, add the following line as the first line
998
-of @file{msys.bat}:
999
-
1000
-@example
1001
-call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
1002
-@end example
1003
-
1004
-Alternatively, you may start the @file{Visual Studio 2005 Command Prompt},
1005
-and run @file{c:\msys\1.0\msys.bat} from there.
1006
-
1007
-@item Within the MSYS shell, run @code{lib.exe}. If you get a help message
1008
-from @file{Microsoft (R) Library Manager}, this means your environment
1009
-variables are set up correctly, the @file{Microsoft (R) Library Manager}
1010
-is on the path and will be used by FFmpeg to create
1011
-MSVC++-compatible import libraries.
1012
-
1013
-@item Build FFmpeg with
1014
-
1015
-@example
1016
-./configure --enable-shared
1017
-make
1018
-make install
1019
-@end example
1020
-
1021
-Your install path (@file{/usr/local/} by default) should now have the
1022
-necessary DLL and LIB files under the @file{bin} directory.
1023
-
1024
-Alternatively, build the libraries with a cross compiler, according to
1025
-the instructions below in @ref{Cross compilation for Windows with Linux}.
1026
-
1027
-To use those files with MSVC++, do the same as you would do with
1028
-the static libraries, as described above. But in Step 4,
1029
-you should only need to add the directory where the LIB files are installed
1030
-(i.e. @file{c:\msys\usr\local\bin}). This is not a typo, the LIB files are
1031
-installed in the @file{bin} directory. And instead of adding the static
1032
-libraries (@file{libxxx.a} files) you should add the MSVC import libraries
1033
-(@file{avcodec.lib}, @file{avformat.lib}, and
1034
-@file{avutil.lib}). Note that you should not use the GCC import
1035
-libraries (@file{libxxx.dll.a} files), as these will give you undefined
1036
-reference errors. There should be no need for @file{libmingwex.a},
1037
-@file{libgcc.a}, and @file{wsock32.lib}, nor any other external library
1038
-statically linked into the DLLs.
1039
-
1040
-FFmpeg headers do not declare global data for Windows DLLs through the usual
1041
-dllexport/dllimport interface. Such data will be exported properly while
1042
-building, but to use them in your MSVC++ code you will have to edit the
1043
-appropriate headers and mark the data as dllimport. For example, in
1044
-libavutil/pixdesc.h you should have:
1045
-@example
1046
-extern __declspec(dllimport) const AVPixFmtDescriptor av_pix_fmt_descriptors[];
1047
-@end example
1048
-
1049
-Note that using import libraries created by dlltool requires
1050
-the linker optimization option to be set to
1051
-"References: Keep Unreferenced Data (@code{/OPT:NOREF})", otherwise
1052
-the resulting binaries will fail during runtime. This isn't
1053
-required when using import libraries generated by lib.exe.
1054
-This issue is reported upstream at
1055
-@url{http://sourceware.org/bugzilla/show_bug.cgi?id=12633}.
1056
-
1057
-To create import libraries that work with the @code{/OPT:REF} option
1058
-(which is enabled by default in Release mode), follow these steps:
1059
-
1060
-@enumerate
1061
-
1062
-@item Open @file{Visual Studio 2005 Command Prompt}.
1063
-
1064
-Alternatively, in a normal command line prompt, call @file{vcvars32.bat}
1065
-which sets up the environment variables for the Visual C++ tools
1066
-(the standard location for this file is
1067
-@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat}).
1068
-
1069
-@item Enter the @file{bin} directory where the created LIB and DLL files
1070
-are stored.
1071
-
1072
-@item Generate new import libraries with @file{lib.exe}:
1073
-
1074
-@example
1075
-lib /machine:i386 /def:..\lib\avcodec-53.def  /out:avcodec.lib
1076
-lib /machine:i386 /def:..\lib\avdevice-53.def /out:avdevice.lib
1077
-lib /machine:i386 /def:..\lib\avfilter-2.def  /out:avfilter.lib
1078
-lib /machine:i386 /def:..\lib\avformat-53.def /out:avformat.lib
1079
-lib /machine:i386 /def:..\lib\avutil-51.def   /out:avutil.lib
1080
-lib /machine:i386 /def:..\lib\swscale-2.def   /out:swscale.lib
1081
-@end example
1082
-
1083
-@end enumerate
1084
-
1085
-@anchor{Cross compilation for Windows with Linux}
1086
-@subsection Cross compilation for Windows with Linux
1087
-
1088
-You must use the MinGW cross compilation tools available at
1089
-@url{http://www.mingw.org/}.
1090
-
1091
-Then configure FFmpeg with the following options:
1092
-@example
1093
-./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
1094
-@end example
1095
-(you can change the cross-prefix according to the prefix chosen for the
1096
-MinGW tools).
1097
-
1098
-Then you can easily test FFmpeg with @uref{http://www.winehq.com/, Wine}.
1099
-
1100
-@subsection Compilation under Cygwin
1101
-
1102
-Please use Cygwin 1.7.x as the obsolete 1.5.x Cygwin versions lack
1103
-llrint() in its C library.
1104
-
1105
-Install your Cygwin with all the "Base" packages, plus the
1106
-following "Devel" ones:
1107
-@example
1108
-binutils, gcc4-core, make, git, mingw-runtime, texi2html
1109
-@end example
1110
-
1111
-And the following "Utils" one:
1112
-@example
1113
-diffutils
1114
-@end example
1115
-
1116
-Then run
1117
-
1118
-@example
1119
-./configure
1120
-@end example
1121
-
1122
-to make a static build.
1123
-
1124
-The current @code{gcc4-core} package is buggy and needs this flag to build
1125
-shared libraries:
1126
-
1127
-@example
1128
-./configure --enable-shared --disable-static --extra-cflags=-fno-reorder-functions
1129
-@end example
1130
-
1131
-If you want to build FFmpeg with additional libraries, download Cygwin
1132
-"Devel" packages for Ogg and Vorbis from any Cygwin packages repository:
1133
-@example
1134
-libogg-devel, libvorbis-devel
1135
-@end example
1136
-
1137
-These library packages are only available from
1138
-@uref{http://sourceware.org/cygwinports/, Cygwin Ports}:
1139
-
1140
-@example
1141
-yasm, libSDL-devel, libdirac-devel, libfaac-devel, libaacplus-devel, libgsm-devel,
1142
-libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel,
1143
-libxvidcore-devel
1144
-@end example
1145
-
1146
-The recommendation for libnut and x264 is to build them from source by
1147
-yourself, as they evolve too quickly for Cygwin Ports to be up to date.
1148
-
1149
-Cygwin 1.7.x has IPv6 support. You can add IPv6 to Cygwin 1.5.x by means
1150
-of the @code{libgetaddrinfo-devel} package, available at Cygwin Ports.
1151
-
1152
-@subsection Cross compilation for Windows under Cygwin
1153
-
1154
-With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
1155
-
1156
-Just install your Cygwin as explained before, plus these additional
1157
-"Devel" packages:
1158
-@example
1159
-gcc-mingw-core, mingw-runtime, mingw-zlib
1160
-@end example
1161
-
1162
-and add some special flags to your configure invocation.
1163
-
1164
-For a static build run
1165
-@example
1166
-./configure --target-os=mingw32 --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
1167
-@end example
1168
-
1169
-and for a build with shared libraries
1170
-@example
1171
-./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
1172
-@end example
1173
-
1174 800
 @bye
1175 801
new file mode 100644
... ...
@@ -0,0 +1,344 @@
0
+\input texinfo @c -*- texinfo -*-
1
+
2
+@settitle Using git to develop FFmpeg
3
+
4
+@titlepage
5
+@center @titlefont{Using git to develop FFmpeg}
6
+@end titlepage
7
+
8
+@top
9
+
10
+@contents
11
+
12
+@chapter Introduction
13
+
14
+This document aims in giving some quick references on a set of useful git
15
+commands. You should always use the extensive and detailed documentation
16
+provided directly by git:
17
+
18
+@example
19
+git --help
20
+man git
21
+@end example
22
+
23
+shows you the available subcommands,
24
+
25
+@example
26
+git <command> --help
27
+man git-<command>
28
+@end example
29
+
30
+shows information about the subcommand <command>.
31
+
32
+Additional information could be found on the
33
+@url{http://gitref.org, Git Reference} website
34
+
35
+For more information about the Git project, visit the
36
+
37
+@url{http://git-scm.com/, Git website}
38
+
39
+Consult these resources whenever you have problems, they are quite exhaustive.
40
+
41
+What follows now is a basic introduction to Git and some FFmpeg-specific
42
+guidelines to ease the contribution to the project
43
+
44
+@chapter Basics Usage
45
+
46
+@section Get GIT
47
+
48
+You can get git from @url{http://git-scm.com/}
49
+Most distribution and operating system provide a package for it.
50
+
51
+
52
+@section Cloning the source tree
53
+
54
+@example
55
+git clone git://source.ffmpeg.org/ffmpeg <target>
56
+@end example
57
+
58
+This will put the FFmpeg sources into the directory @var{<target>}.
59
+
60
+@example
61
+git clone git@@source.ffmpeg.org:ffmpeg <target>
62
+@end example
63
+
64
+This will put the FFmpeg sources into the directory @var{<target>} and let
65
+you push back your changes to the remote repository.
66
+
67
+
68
+@section Updating the source tree to the latest revision
69
+
70
+@example
71
+git pull (--rebase)
72
+@end example
73
+
74
+pulls in the latest changes from the tracked branch. The tracked branch
75
+can be remote. By default the master branch tracks the branch master in
76
+the remote origin.
77
+
78
+@float IMPORTANT
79
+@command{--rebase} (see below) is recommended.
80
+@end float
81
+
82
+@section Rebasing your local branches
83
+
84
+@example
85
+git pull --rebase
86
+@end example
87
+
88
+fetches the changes from the main repository and replays your local commits
89
+over it. This is required to keep all your local changes at the top of
90
+FFmpeg's master tree. The master tree will reject pushes with merge commits.
91
+
92
+
93
+@section Adding/removing files/directories
94
+
95
+@example
96
+git add [-A] <filename/dirname>
97
+git rm [-r] <filename/dirname>
98
+@end example
99
+
100
+GIT needs to get notified of all changes you make to your working
101
+directory that makes files appear or disappear.
102
+Line moves across files are automatically tracked.
103
+
104
+
105
+@section Showing modifications
106
+
107
+@example
108
+git diff <filename(s)>
109
+@end example
110
+
111
+will show all local modifications in your working directory as unified diff.
112
+
113
+
114
+@section Inspecting the changelog
115
+
116
+@example
117
+git log <filename(s)>
118
+@end example
119
+
120
+You may also use the graphical tools like gitview or gitk or the web
121
+interface available at http://source.ffmpeg.org/
122
+
123
+@section Checking source tree status
124
+
125
+@example
126
+git status
127
+@end example
128
+
129
+detects all the changes you made and lists what actions will be taken in case
130
+of a commit (additions, modifications, deletions, etc.).
131
+
132
+
133
+@section Committing
134
+
135
+@example
136
+git diff --check
137
+@end example
138
+
139
+to double check your changes before committing them to avoid trouble later
140
+on. All experienced developers do this on each and every commit, no matter
141
+how small.
142
+Every one of them has been saved from looking like a fool by this many times.
143
+It's very easy for stray debug output or cosmetic modifications to slip in,
144
+please avoid problems through this extra level of scrutiny.
145
+
146
+For cosmetics-only commits you should get (almost) empty output from
147
+
148
+@example
149
+git diff -w -b <filename(s)>
150
+@end example
151
+
152
+Also check the output of
153
+
154
+@example
155
+git status
156
+@end example
157
+
158
+to make sure you don't have untracked files or deletions.
159
+
160
+@example
161
+git add [-i|-p|-A] <filenames/dirnames>
162
+@end example
163
+
164
+Make sure you have told git your name and email address
165
+
166
+@example
167
+git config --global user.name "My Name"
168
+git config --global user.email my@@email.invalid
169
+@end example
170
+
171
+Use @var{--global} to set the global configuration for all your git checkouts.
172
+
173
+Git will select the changes to the files for commit. Optionally you can use
174
+the interactive or the patch mode to select hunk by hunk what should be
175
+added to the commit.
176
+
177
+
178
+@example
179
+git commit
180
+@end example
181
+
182
+Git will commit the selected changes to your current local branch.
183
+
184
+You will be prompted for a log message in an editor, which is either
185
+set in your personal configuration file through
186
+
187
+@example
188
+git config --global core.editor
189
+@end example
190
+
191
+or set by one of the following environment variables:
192
+@var{GIT_EDITOR}, @var{VISUAL} or @var{EDITOR}.
193
+
194
+Log messages should be concise but descriptive. Explain why you made a change,
195
+what you did will be obvious from the changes themselves most of the time.
196
+Saying just "bug fix" or "10l" is bad. Remember that people of varying skill
197
+levels look at and educate themselves while reading through your code. Don't
198
+include filenames in log messages, Git provides that information.
199
+
200
+Possibly make the commit message have a terse, descriptive first line, an
201
+empty line and then a full description. The first line will be used to name
202
+the patch by git format-patch.
203
+
204
+@section Preparing a patchset
205
+
206
+@example
207
+git format-patch <commit> [-o directory]
208
+@end example
209
+
210
+will generate a set of patches for each commit between @var{<commit>} and
211
+current @var{HEAD}. E.g.
212
+
213
+@example
214
+git format-patch origin/master
215
+@end example
216
+
217
+will generate patches for all commits on current branch which are not
218
+present in upstream.
219
+A useful shortcut is also
220
+
221
+@example
222
+git format-patch -n
223
+@end example
224
+
225
+which will generate patches from last @var{n} commits.
226
+By default the patches are created in the current directory.
227
+
228
+@section Sending patches for review
229
+
230
+@example
231
+git send-email <commit list|directory>
232
+@end example
233
+
234
+will send the patches created by @command{git format-patch} or directly
235
+generates them. All the email fields can be configured in the global/local
236
+configuration or overridden by command line.
237
+Note that this tool must often be installed separately (e.g. @var{git-email}
238
+package on Debian-based distros).
239
+
240
+
241
+@section Renaming/moving/copying files or contents of files
242
+
243
+Git automatically tracks such changes, making those normal commits.
244
+
245
+@example
246
+mv/cp path/file otherpath/otherfile
247
+git add [-A] .
248
+git commit
249
+@end example
250
+
251
+
252
+@chapter FFmpeg specific
253
+
254
+@section Reverting broken commits
255
+
256
+@example
257
+git reset <commit>
258
+@end example
259
+
260
+@command{git reset} will uncommit the changes till @var{<commit>} rewriting
261
+the current branch history.
262
+
263
+@example
264
+git commit --amend
265
+@end example
266
+
267
+allows to amend the last commit details quickly.
268
+
269
+@example
270
+git rebase -i origin/master
271
+@end example
272
+
273
+will replay local commits over the main repository allowing to edit, merge
274
+or remove some of them in the process.
275
+
276
+@float NOTE
277
+@command{git reset}, @command{git commit --amend} and @command{git rebase}
278
+rewrite history, so you should use them ONLY on your local or topic branches.
279
+The main repository will reject those changes.
280
+@end float
281
+
282
+@example
283
+git revert <commit>
284
+@end example
285
+
286
+@command{git revert} will generate a revert commit. This will not make the
287
+faulty commit disappear from the history.
288
+
289
+@section Pushing changes to remote trees
290
+
291
+@example
292
+git push
293
+@end example
294
+
295
+Will push the changes to the default remote (@var{origin}).
296
+Git will prevent you from pushing changes if the local and remote trees are
297
+out of sync. Refer to and to sync the local tree.
298
+
299
+@example
300
+git remote add <name> <url>
301
+@end example
302
+
303
+Will add additional remote with a name reference, it is useful if you want
304
+to push your local branch for review on a remote host.
305
+
306
+@example
307
+git push <remote> <refspec>
308
+@end example
309
+
310
+Will push the changes to the @var{<remote>} repository.
311
+Omitting @var{<refspec>} makes @command{git push} update all the remote
312
+branches matching the local ones.
313
+
314
+@section Finding a specific svn revision
315
+
316
+Since version 1.7.1 git supports @var{:/foo} syntax for specifying commits
317
+based on a regular expression. see man gitrevisions
318
+
319
+@example
320
+git show :/'as revision 23456'
321
+@end example
322
+
323
+will show the svn changeset @var{r23456}. With older git versions searching in
324
+the @command{git log} output is the easiest option (especially if a pager with
325
+search capabilities is used).
326
+This commit can be checked out with
327
+
328
+@example
329
+git checkout -b svn_23456 :/'as revision 23456'
330
+@end example
331
+
332
+or for git < 1.7.1 with
333
+
334
+@example
335
+git checkout -b svn_23456 $SHA1
336
+@end example
337
+
338
+where @var{$SHA1} is the commit hash from the @command{git log} output.
339
+
340
+@chapter Server Issues
341
+
342
+Contact the project admins @email{root@@ffmpeg.org} if you have technical
343
+problems with the GIT server.
... ...
@@ -42,7 +42,7 @@ specify card number or identifier, device number and subdevice number
42 42
 To see the list of cards currently recognized by your system check the
43 43
 files @file{/proc/asound/cards} and @file{/proc/asound/devices}.
44 44
 
45
-For example to capture with @file{ffmpeg} from an ALSA device with
45
+For example to capture with @command{ffmpeg} from an ALSA device with
46 46
 card id 0, you may run the command:
47 47
 @example
48 48
 ffmpeg -f alsa -i hw:0 alsaout.wav
... ...
@@ -167,14 +167,14 @@ For more detailed information read the file
167 167
 Documentation/fb/framebuffer.txt included in the Linux source tree.
168 168
 
169 169
 To record from the framebuffer device @file{/dev/fb0} with
170
-@file{ffmpeg}:
170
+@command{ffmpeg}:
171 171
 @example
172 172
 ffmpeg -f fbdev -r 10 -i /dev/fb0 out.avi
173 173
 @end example
174 174
 
175 175
 You can take a single screenshot image with the command:
176 176
 @example
177
-ffmpeg -f fbdev -vframes 1 -r 1 -i /dev/fb0 screenshot.jpeg
177
+ffmpeg -f fbdev -frames:v 1 -r 1 -i /dev/fb0 screenshot.jpeg
178 178
 @end example
179 179
 
180 180
 See also @url{http://linux-fbdev.sourceforge.net/}, and fbset(1).
... ...
@@ -204,7 +204,7 @@ To list the JACK clients and their properties you can invoke the command
204 204
 @file{jack_lsp}.
205 205
 
206 206
 Follows an example which shows how to capture a JACK readable client
207
-with @file{ffmpeg}.
207
+with @command{ffmpeg}.
208 208
 @example
209 209
 # Create a JACK writable client with name "ffmpeg".
210 210
 $ ffmpeg -f jack -i ffmpeg -y out.wav
... ...
@@ -395,7 +395,7 @@ The filename to provide to the input device is the device node
395 395
 representing the OSS input device, and is usually set to
396 396
 @file{/dev/dsp}.
397 397
 
398
-For example to grab from @file{/dev/dsp} using @file{ffmpeg} use the
398
+For example to grab from @file{/dev/dsp} using @command{ffmpeg} use the
399 399
 command:
400 400
 @example
401 401
 ffmpeg -f oss -i /dev/dsp /tmp/oss.wav
... ...
@@ -418,7 +418,7 @@ To list the pulse source devices and their properties you can invoke
418 418
 the command @file{pactl list sources}.
419 419
 
420 420
 @example
421
-avconv -f pulse -i default /tmp/pulse.wav
421
+ffmpeg -f pulse -i default /tmp/pulse.wav
422 422
 @end example
423 423
 
424 424
 @subsection @var{server} AVOption
... ...
@@ -498,7 +498,7 @@ The filename to provide to the input device is the device node
498 498
 representing the sndio input device, and is usually set to
499 499
 @file{/dev/audio0}.
500 500
 
501
-For example to grab from @file{/dev/audio0} using @file{ffmpeg} use the
501
+For example to grab from @file{/dev/audio0} using @command{ffmpeg} use the
502 502
 command:
503 503
 @example
504 504
 ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav
... ...
@@ -582,7 +582,7 @@ Check the X11 documentation (e.g. man X) for more detailed information.
582 582
 Use the @file{dpyinfo} program for getting basic information about the
583 583
 properties of your X11 display (e.g. grep for "name" or "dimensions").
584 584
 
585
-For example to grab from @file{:0.0} using @file{ffmpeg}:
585
+For example to grab from @file{:0.0} using @command{ffmpeg}:
586 586
 @example
587 587
 ffmpeg -f x11grab -r 25 -s cif -i :0.0 out.mpg
588 588
 
... ...
@@ -43,12 +43,12 @@ You can print the CRC to stdout with the command:
43 43
 ffmpeg -i INPUT -f crc -
44 44
 @end example
45 45
 
46
-You can select the output format of each frame with @file{ffmpeg} by
46
+You can select the output format of each frame with @command{ffmpeg} by
47 47
 specifying the audio and video codec and format. For example to
48 48
 compute the CRC of the input audio converted to PCM unsigned 8-bit
49 49
 and the input video converted to MPEG-2 video, use the command:
50 50
 @example
51
-ffmpeg -i INPUT -acodec pcm_u8 -vcodec mpeg2video -f crc -
51
+ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f crc -
52 52
 @end example
53 53
 
54 54
 See also the @ref{framecrc} muxer.
... ...
@@ -79,13 +79,13 @@ You can print the CRC of each decoded frame to stdout with the command:
79 79
 ffmpeg -i INPUT -f framecrc -
80 80
 @end example
81 81
 
82
-You can select the output format of each frame with @file{ffmpeg} by
82
+You can select the output format of each frame with @command{ffmpeg} by
83 83
 specifying the audio and video codec and format. For example, to
84 84
 compute the CRC of each decoded input audio frame converted to PCM
85 85
 unsigned 8-bit and of each decoded input video frame converted to
86 86
 MPEG-2 video, use the command:
87 87
 @example
88
-ffmpeg -i INPUT -acodec pcm_u8 -vcodec mpeg2video -f framecrc -
88
+ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f framecrc -
89 89
 @end example
90 90
 
91 91
 See also the @ref{crc} muxer.
... ...
@@ -119,26 +119,26 @@ The pattern "img%%-%d.jpg" will specify a sequence of filenames of the
119 119
 form @file{img%-1.jpg}, @file{img%-2.jpg}, ..., @file{img%-10.jpg},
120 120
 etc.
121 121
 
122
-The following example shows how to use @file{ffmpeg} for creating a
122
+The following example shows how to use @command{ffmpeg} for creating a
123 123
 sequence of files @file{img-001.jpeg}, @file{img-002.jpeg}, ...,
124 124
 taking one image every second from the input video:
125 125
 @example
126
-ffmpeg -i in.avi -r 1 -f image2 'img-%03d.jpeg'
126
+ffmpeg -i in.avi -vsync 1 -r 1 -f image2 'img-%03d.jpeg'
127 127
 @end example
128 128
 
129
-Note that with @file{ffmpeg}, if the format is not specified with the
129
+Note that with @command{ffmpeg}, if the format is not specified with the
130 130
 @code{-f} option and the output filename specifies an image file
131 131
 format, the image2 muxer is automatically selected, so the previous
132 132
 command can be written as:
133 133
 @example
134
-ffmpeg -i in.avi -r 1 'img-%03d.jpeg'
134
+ffmpeg -i in.avi -vsync 1 -r 1 'img-%03d.jpeg'
135 135
 @end example
136 136
 
137 137
 Note also that the pattern must not necessarily contain "%d" or
138 138
 "%0@var{N}d", for example to create a single image file
139 139
 @file{img.jpeg} from the input video you can employ the command:
140 140
 @example
141
-ffmpeg -i in.avi -f image2 -vframes 1 img.jpeg
141
+ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg
142 142
 @end example
143 143
 
144 144
 The image muxer supports the .Y.U.V image file format. This format is
... ...
@@ -189,7 +189,7 @@ and @code{service_name}. If they are not set the default for
189 189
 @code{service_name} is "Service01".
190 190
 
191 191
 @example
192
-ffmpeg -i file.mpg -acodec copy -vcodec copy \
192
+ffmpeg -i file.mpg -c copy \
193 193
      -mpegts_original_network_id 0x1122 \
194 194
      -mpegts_transport_stream_id 0x3344 \
195 195
      -mpegts_service_id 0x5566 \
... ...
@@ -207,14 +207,14 @@ Null muxer.
207 207
 This muxer does not generate any output file, it is mainly useful for
208 208
 testing or benchmarking purposes.
209 209
 
210
-For example to benchmark decoding with @file{ffmpeg} you can use the
210
+For example to benchmark decoding with @command{ffmpeg} you can use the
211 211
 command:
212 212
 @example
213 213
 ffmpeg -benchmark -i INPUT -f null out.null
214 214
 @end example
215 215
 
216 216
 Note that the above command does not read or write the @file{out.null}
217
-file, but specifying the output file is required by the @file{ffmpeg}
217
+file, but specifying the output file is required by the @command{ffmpeg}
218 218
 syntax.
219 219
 
220 220
 Alternatively you can write the command as:
... ...
@@ -282,7 +282,7 @@ Both eyes laced in one Block, Right-eye view is first
282 282
 
283 283
 For example a 3D WebM clip can be created using the following command line:
284 284
 @example
285
-ffmpeg -i sample_left_right_clip.mpg -an -vcodec libvpx -metadata stereo_mode=left_right -y stereo_clip.webm
285
+ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_right -y stereo_clip.webm
286 286
 @end example
287 287
 
288 288
 @c man end MUXERS
289 289
new file mode 100644
... ...
@@ -0,0 +1,387 @@
0
+\input texinfo @c -*- texinfo -*-
1
+
2
+@settitle Platform Specific information
3
+@titlepage
4
+@center @titlefont{Platform Specific information}
5
+@end titlepage
6
+
7
+@top
8
+
9
+@contents
10
+
11
+@chapter Unix-like
12
+
13
+Some parts of FFmpeg cannot be built with version 2.15 of the GNU
14
+assembler which is still provided by a few AMD64 distributions. To
15
+make sure your compiler really uses the required version of gas
16
+after a binutils upgrade, run:
17
+
18
+@example
19
+$(gcc -print-prog-name=as) --version
20
+@end example
21
+
22
+If not, then you should install a different compiler that has no
23
+hard-coded path to gas. In the worst case pass @code{--disable-asm}
24
+to configure.
25
+
26
+@section BSD
27
+
28
+BSD make will not build FFmpeg, you need to install and use GNU Make
29
+(@file{gmake}).
30
+
31
+@section (Open)Solaris
32
+
33
+GNU Make is required to build FFmpeg, so you have to invoke (@file{gmake}),
34
+standard Solaris Make will not work. When building with a non-c99 front-end
35
+(gcc, generic suncc) add either @code{--extra-libs=/usr/lib/values-xpg6.o}
36
+or @code{--extra-libs=/usr/lib/64/values-xpg6.o} to the configure options
37
+since the libc is not c99-compliant by default. The probes performed by
38
+configure may raise an exception leading to the death of configure itself
39
+due to a bug in the system shell. Simply invoke a different shell such as
40
+bash directly to work around this:
41
+
42
+@example
43
+bash ./configure
44
+@end example
45
+
46
+@anchor{Darwin}
47
+@section Darwin (OSX, iPhone)
48
+
49
+The toolchain provided with Xcode is sufficient to build the basic
50
+unacelerated code.
51
+
52
+OSX on PowerPC or ARM (iPhone) requires a preprocessor from
53
+@url{http://github.com/yuvi/gas-preprocessor} to build the optimized
54
+assembler functions. Just download the Perl script and put it somewhere
55
+in your PATH, FFmpeg's configure will pick it up automatically.
56
+
57
+OSX on amd64 and x86 requires @command{yasm} to build most of the
58
+optimized assembler functions @url{http://mxcl.github.com/homebrew/, Homebrew},
59
+@url{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix}
60
+or @url{http://www.macports.org, MacPorts} can easily provide it.
61
+
62
+
63
+@chapter DOS
64
+
65
+Using a cross-compiler is preferred for various reasons.
66
+@url{http://www.delorie.com/howto/djgpp/linux-x-djgpp.html}
67
+
68
+
69
+@chapter OS/2
70
+
71
+For information about compiling FFmpeg on OS/2 see
72
+@url{http://www.edm2.com/index.php/FFmpeg}.
73
+
74
+
75
+@chapter Windows
76
+
77
+To get help and instructions for building FFmpeg under Windows, check out
78
+the FFmpeg Windows Help Forum at
79
+@url{http://ffmpeg.arrozcru.org/}.
80
+
81
+@section Native Windows compilation
82
+
83
+FFmpeg can be built to run natively on Windows using the MinGW tools. Install
84
+the latest versions of MSYS and MinGW from @url{http://www.mingw.org/}.
85
+You can find detailed installation instructions in the download
86
+section and the FAQ.
87
+
88
+FFmpeg does not build out-of-the-box with the packages the automated MinGW
89
+installer provides. It also requires coreutils to be installed and many other
90
+packages updated to the latest version. The minimum version for some packages
91
+are listed below:
92
+
93
+@itemize
94
+@item bash 3.1
95
+@item msys-make 3.81-2 (note: not mingw32-make)
96
+@item w32api 3.13
97
+@item mingw-runtime 3.15
98
+@end itemize
99
+
100
+FFmpeg automatically passes @code{-fno-common} to the compiler to work around
101
+a GCC bug (see @url{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216}).
102
+
103
+Notes:
104
+
105
+@itemize
106
+
107
+@item Building natively using MSYS can be sped up by disabling implicit rules
108
+in the Makefile by calling @code{make -r} instead of plain @code{make}. This
109
+speed up is close to non-existent for normal one-off builds and is only
110
+noticeable when running make for a second time (for example in
111
+@code{make install}).
112
+
113
+@item In order to compile FFplay, you must have the MinGW development library
114
+of @uref{http://www.libsdl.org/, SDL}.
115
+Edit the @file{bin/sdl-config} script so that it points to the correct prefix
116
+where SDL was installed. Verify that @file{sdl-config} can be launched from
117
+the MSYS command line.
118
+
119
+@item By using @code{./configure --enable-shared} when configuring FFmpeg,
120
+you can build the FFmpeg libraries (e.g. libavutil, libavcodec,
121
+libavformat) as DLLs.
122
+
123
+@end itemize
124
+
125
+@section Microsoft Visual C++ compatibility
126
+
127
+As stated in the FAQ, FFmpeg will not compile under MSVC++. However, if you
128
+want to use the libav* libraries in your own applications, you can still
129
+compile those applications using MSVC++. But the libav* libraries you link
130
+to @emph{must} be built with MinGW. However, you will not be able to debug
131
+inside the libav* libraries, since MSVC++ does not recognize the debug
132
+symbols generated by GCC.
133
+We strongly recommend you to move over from MSVC++ to MinGW tools.
134
+
135
+This description of how to use the FFmpeg libraries with MSVC++ is based on
136
+Microsoft Visual C++ 2005 Express Edition. If you have a different version,
137
+you might have to modify the procedures slightly.
138
+
139
+@subsection Using static libraries
140
+
141
+Assuming you have just built and installed FFmpeg in @file{/usr/local}.
142
+
143
+@enumerate
144
+
145
+@item Create a new console application ("File / New / Project") and then
146
+select "Win32 Console Application". On the appropriate page of the
147
+Application Wizard, uncheck the "Precompiled headers" option.
148
+
149
+@item Write the source code for your application, or, for testing, just
150
+copy the code from an existing sample application into the source file
151
+that MSVC++ has already created for you. For example, you can copy
152
+@file{libavformat/output-example.c} from the FFmpeg distribution.
153
+
154
+@item Open the "Project / Properties" dialog box. In the "Configuration"
155
+combo box, select "All Configurations" so that the changes you make will
156
+affect both debug and release builds. In the tree view on the left hand
157
+side, select "C/C++ / General", then edit the "Additional Include
158
+Directories" setting to contain the path where the FFmpeg includes were
159
+installed (i.e. @file{c:\msys\1.0\local\include}).
160
+Do not add MinGW's include directory here, or the include files will
161
+conflict with MSVC's.
162
+
163
+@item Still in the "Project / Properties" dialog box, select
164
+"Linker / General" from the tree view and edit the
165
+"Additional Library Directories" setting to contain the @file{lib}
166
+directory where FFmpeg was installed (i.e. @file{c:\msys\1.0\local\lib}),
167
+the directory where MinGW libs are installed (i.e. @file{c:\mingw\lib}),
168
+and the directory where MinGW's GCC libs are installed
169
+(i.e. @file{C:\mingw\lib\gcc\mingw32\4.2.1-sjlj}). Then select
170
+"Linker / Input" from the tree view, and add the files @file{libavformat.a},
171
+@file{libavcodec.a}, @file{libavutil.a}, @file{libmingwex.a},
172
+@file{libgcc.a}, and any other libraries you used (i.e. @file{libz.a})
173
+to the end of "Additional Dependencies".
174
+
175
+@item Now, select "C/C++ / Code Generation" from the tree view. Select
176
+"Debug" in the "Configuration" combo box. Make sure that "Runtime
177
+Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in
178
+the "Configuration" combo box and make sure that "Runtime Library" is
179
+set to "Multi-threaded DLL".
180
+
181
+@item Click "OK" to close the "Project / Properties" dialog box.
182
+
183
+@item MSVC++ lacks some C99 header files that are fundamental for FFmpeg.
184
+Get msinttypes from @url{http://code.google.com/p/msinttypes/downloads/list}
185
+and install it in MSVC++'s include directory
186
+(i.e. @file{C:\Program Files\Microsoft Visual Studio 8\VC\include}).
187
+
188
+@item MSVC++ also does not understand the @code{inline} keyword used by
189
+FFmpeg, so you must add this line before @code{#include}ing libav*:
190
+@example
191
+#define inline _inline
192
+@end example
193
+
194
+@item Build your application, everything should work.
195
+
196
+@end enumerate
197
+
198
+@subsection Using shared libraries
199
+
200
+This is how to create DLL and LIB files that are compatible with MSVC++:
201
+
202
+@enumerate
203
+
204
+@item Add a call to @file{vcvars32.bat} (which sets up the environment
205
+variables for the Visual C++ tools) as the first line of @file{msys.bat}.
206
+The standard location for @file{vcvars32.bat} is
207
+@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat},
208
+and the standard location for @file{msys.bat} is @file{C:\msys\1.0\msys.bat}.
209
+If this corresponds to your setup, add the following line as the first line
210
+of @file{msys.bat}:
211
+
212
+@example
213
+call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
214
+@end example
215
+
216
+Alternatively, you may start the @file{Visual Studio 2005 Command Prompt},
217
+and run @file{c:\msys\1.0\msys.bat} from there.
218
+
219
+@item Within the MSYS shell, run @code{lib.exe}. If you get a help message
220
+from @file{Microsoft (R) Library Manager}, this means your environment
221
+variables are set up correctly, the @file{Microsoft (R) Library Manager}
222
+is on the path and will be used by FFmpeg to create
223
+MSVC++-compatible import libraries.
224
+
225
+@item Build FFmpeg with
226
+
227
+@example
228
+./configure --enable-shared
229
+make
230
+make install
231
+@end example
232
+
233
+Your install path (@file{/usr/local/} by default) should now have the
234
+necessary DLL and LIB files under the @file{bin} directory.
235
+
236
+Alternatively, build the libraries with a cross compiler, according to
237
+the instructions below in @ref{Cross compilation for Windows with Linux}.
238
+
239
+To use those files with MSVC++, do the same as you would do with
240
+the static libraries, as described above. But in Step 4,
241
+you should only need to add the directory where the LIB files are installed
242
+(i.e. @file{c:\msys\usr\local\bin}). This is not a typo, the LIB files are
243
+installed in the @file{bin} directory. And instead of adding the static
244
+libraries (@file{libxxx.a} files) you should add the MSVC import libraries
245
+(@file{avcodec.lib}, @file{avformat.lib}, and
246
+@file{avutil.lib}). Note that you should not use the GCC import
247
+libraries (@file{libxxx.dll.a} files), as these will give you undefined
248
+reference errors. There should be no need for @file{libmingwex.a},
249
+@file{libgcc.a}, and @file{wsock32.lib}, nor any other external library
250
+statically linked into the DLLs.
251
+
252
+FFmpeg headers do not declare global data for Windows DLLs through the usual
253
+dllexport/dllimport interface. Such data will be exported properly while
254
+building, but to use them in your MSVC++ code you will have to edit the
255
+appropriate headers and mark the data as dllimport. For example, in
256
+libavutil/pixdesc.h you should have:
257
+@example
258
+extern __declspec(dllimport) const AVPixFmtDescriptor av_pix_fmt_descriptors[];
259
+@end example
260
+
261
+Note that using import libraries created by dlltool requires
262
+the linker optimization option to be set to
263
+"References: Keep Unreferenced Data (@code{/OPT:NOREF})", otherwise
264
+the resulting binaries will fail during runtime. This isn't
265
+required when using import libraries generated by lib.exe.
266
+This issue is reported upstream at
267
+@url{http://sourceware.org/bugzilla/show_bug.cgi?id=12633}.
268
+
269
+To create import libraries that work with the @code{/OPT:REF} option
270
+(which is enabled by default in Release mode), follow these steps:
271
+
272
+@enumerate
273
+
274
+@item Open @file{Visual Studio 2005 Command Prompt}.
275
+
276
+Alternatively, in a normal command line prompt, call @file{vcvars32.bat}
277
+which sets up the environment variables for the Visual C++ tools
278
+(the standard location for this file is
279
+@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat}).
280
+
281
+@item Enter the @file{bin} directory where the created LIB and DLL files
282
+are stored.
283
+
284
+@item Generate new import libraries with @file{lib.exe}:
285
+
286
+@example
287
+lib /machine:i386 /def:..\lib\avcodec-53.def  /out:avcodec.lib
288
+lib /machine:i386 /def:..\lib\avdevice-53.def /out:avdevice.lib
289
+lib /machine:i386 /def:..\lib\avfilter-2.def  /out:avfilter.lib
290
+lib /machine:i386 /def:..\lib\avformat-53.def /out:avformat.lib
291
+lib /machine:i386 /def:..\lib\avutil-51.def   /out:avutil.lib
292
+lib /machine:i386 /def:..\lib\swscale-2.def   /out:swscale.lib
293
+@end example
294
+
295
+@end enumerate
296
+
297
+@anchor{Cross compilation for Windows with Linux}
298
+@section Cross compilation for Windows with Linux
299
+
300
+You must use the MinGW cross compilation tools available at
301
+@url{http://www.mingw.org/}.
302
+
303
+Then configure FFmpeg with the following options:
304
+@example
305
+./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
306
+@end example
307
+(you can change the cross-prefix according to the prefix chosen for the
308
+MinGW tools).
309
+
310
+Then you can easily test FFmpeg with @uref{http://www.winehq.com/, Wine}.
311
+
312
+@section Compilation under Cygwin
313
+
314
+Please use Cygwin 1.7.x as the obsolete 1.5.x Cygwin versions lack
315
+llrint() in its C library.
316
+
317
+Install your Cygwin with all the "Base" packages, plus the
318
+following "Devel" ones:
319
+@example
320
+binutils, gcc4-core, make, git, mingw-runtime, texi2html
321
+@end example
322
+
323
+And the following "Utils" one:
324
+@example
325
+diffutils
326
+@end example
327
+
328
+Then run
329
+
330
+@example
331
+./configure
332
+@end example
333
+
334
+to make a static build.
335
+
336
+The current @code{gcc4-core} package is buggy and needs this flag to build
337
+shared libraries:
338
+
339
+@example
340
+./configure --enable-shared --disable-static --extra-cflags=-fno-reorder-functions
341
+@end example
342
+
343
+If you want to build FFmpeg with additional libraries, download Cygwin
344
+"Devel" packages for Ogg and Vorbis from any Cygwin packages repository:
345
+@example
346
+libogg-devel, libvorbis-devel
347
+@end example
348
+
349
+These library packages are only available from
350
+@uref{http://sourceware.org/cygwinports/, Cygwin Ports}:
351
+
352
+@example
353
+yasm, libSDL-devel, libdirac-devel, libfaac-devel, libaacplus-devel, libgsm-devel,
354
+libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel,
355
+libxvidcore-devel
356
+@end example
357
+
358
+The recommendation for libnut and x264 is to build them from source by
359
+yourself, as they evolve too quickly for Cygwin Ports to be up to date.
360
+
361
+Cygwin 1.7.x has IPv6 support. You can add IPv6 to Cygwin 1.5.x by means
362
+of the @code{libgetaddrinfo-devel} package, available at Cygwin Ports.
363
+
364
+@section Crosscompilation for Windows under Cygwin
365
+
366
+With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
367
+
368
+Just install your Cygwin as explained before, plus these additional
369
+"Devel" packages:
370
+@example
371
+gcc-mingw-core, mingw-runtime, mingw-zlib
372
+@end example
373
+
374
+and add some special flags to your configure invocation.
375
+
376
+For a static build run
377
+@example
378
+./configure --target-os=mingw32 --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
379
+@end example
380
+
381
+and for a build with shared libraries
382
+@example
383
+./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
384
+@end example
385
+
386
+@bye
... ...
@@ -67,7 +67,7 @@ File access protocol.
67 67
 
68 68
 Allow to read from or read to a file.
69 69
 
70
-For example to read from a file @file{input.mpeg} with @file{ffmpeg}
70
+For example to read from a file @file{input.mpeg} with @command{ffmpeg}
71 71
 use the command:
72 72
 @example
73 73
 ffmpeg -i file:input.mpeg output.mpeg
... ...
@@ -134,14 +134,14 @@ pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr).  If @var{number}
134 134
 is not specified, by default the stdout file descriptor will be used
135 135
 for writing, stdin for reading.
136 136
 
137
-For example to read from stdin with @file{ffmpeg}:
137
+For example to read from stdin with @command{ffmpeg}:
138 138
 @example
139 139
 cat test.wav | ffmpeg -i pipe:0
140 140
 # ...this is the same as...
141 141
 cat test.wav | ffmpeg -i pipe:
142 142
 @end example
143 143
 
144
-For writing to stdout with @file{ffmpeg}:
144
+For writing to stdout with @command{ffmpeg}:
145 145
 @example
146 146
 ffmpeg -i test.wav -f avi pipe:1 | cat > test.avi
147 147
 # ...this is the same as...
... ...
@@ -219,7 +219,7 @@ meaning as specified for the RTMP native protocol.
219 219
 See the librtmp manual page (man 3 librtmp) for more information.
220 220
 
221 221
 For example, to stream a file in real-time to an RTMP server using
222
-@file{ffmpeg}:
222
+@command{ffmpeg}:
223 223
 @example
224 224
 ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
225 225
 @end example
... ...
@@ -249,7 +249,7 @@ The required syntax for a RTSP url is:
249 249
 rtsp://@var{hostname}[:@var{port}]/@var{path}
250 250
 @end example
251 251
 
252
-The following options (set on the @file{ffmpeg}/@file{ffplay} command
252
+The following options (set on the @command{ffmpeg}/@file{ffplay} command
253 253
 line, or set in code via @code{AVOption}s or in @code{avformat_open_input}),
254 254
 are supported:
255 255
 
... ...
@@ -472,7 +472,7 @@ For receiving, this gives the benefit of only receiving packets from
472 472
 the specified peer address/port.
473 473
 @end table
474 474
 
475
-Some usage examples of the udp protocol with @file{ffmpeg} follow.
475
+Some usage examples of the udp protocol with @command{ffmpeg} follow.
476 476
 
477 477
 To stream over UDP to a remote endpoint:
478 478
 @example
... ...
@@ -9,6 +9,63 @@ $EXTRA_HEAD =
9 9
 <link rel="stylesheet" type="text/css" href="default.css" />
10 10
 ';
11 11
 
12
+$CSS_LINES = <<EOT;
13
+<style type="text/css">
14
+<!--
15
+a.summary-letter { text-decoration: none }
16
+a { color: #2D6198; }
17
+a:visited { color: #884488; }
18
+h1 a, h2 a, h3 a { text-decoration: inherit; color: inherit; }
19
+p { margin-left: 1em; margin-right: 1em; }
20
+table { margin-left: 2em; }
21
+pre { margin-left: 2em; }
22
+#footer { text-align: center; }
23
+#body { margin-left: 1em; margin-right: 1em; }
24
+body { background-color: #313131; margin: 0; }
25
+
26
+#container {
27
+    background-color: white;
28
+    color: #202020;
29
+    margin-left: 1em;
30
+    margin-right: 1em;
31
+}
32
+
33
+h1 {
34
+    background-color: #7BB37B;
35
+    border: 1px solid #6A996A;
36
+    color: #151515;
37
+    font-size: 1.2em;
38
+    padding-bottom: 0.2em;
39
+    padding-left: 0.4em;
40
+    padding-top: 0.2em;
41
+}
42
+
43
+h2 {
44
+    color: #313131;
45
+    font-size: 1.2em;
46
+}
47
+
48
+h3 {
49
+    color: #313131;
50
+    font-size: 0.8em;
51
+    margin-bottom: -8px;
52
+}
53
+
54
+.note {
55
+    margin: 1em;
56
+    border: 1px solid #bbc9d8;
57
+    background-color: #dde1e1;
58
+}
59
+
60
+.important {
61
+    margin: 1em;
62
+    border: 1px solid #d26767;
63
+    background-color: #f8e1e1;
64
+}
65
+
66
+-->
67
+</style>
68
+EOT
12 69
 
13 70
 my $FFMPEG_NAVBAR = $ENV{"FFMPEG_NAVBAR"} || '';
14 71
 
... ...
@@ -31,6 +88,35 @@ sub FFmpeg_print_page_foot($$)
31 31
     print $fh "</div>\n";
32 32
 }
33 33
 
34
+$float = \&FFmpeg_float;
35
+
36
+sub FFmpeg_float($$$$)
37
+{
38
+    my $text = shift;
39
+    my $float = shift;
40
+    my $caption = shift;
41
+    my $shortcaption = shift;
42
+
43
+    my $label = '';
44
+    if (exists($float->{'id'}))
45
+    {
46
+        $label = &$anchor($float->{'id'});
47
+    }
48
+    my $class = '';
49
+    my $subject = '';
50
+
51
+    if ($caption =~ /NOTE/)
52
+    {
53
+        $class = "note";
54
+    }
55
+    elsif ($caption =~ /IMPORTANT/)
56
+    {
57
+        $class = "important";
58
+    }
59
+
60
+    return '<div class="float ' . $class . '">' . "$label\n" . $text . '</div>';
61
+}
62
+
34 63
 $print_page_head = \&FFmpeg_print_page_head;
35 64
 sub FFmpeg_print_page_head($$)
36 65
 {
... ...
@@ -148,9 +148,10 @@ OBJS-$(CONFIG_MLP_MUXER)                 += rawenc.o
148 148
 OBJS-$(CONFIG_MM_DEMUXER)                += mm.o
149 149
 OBJS-$(CONFIG_MMF_DEMUXER)               += mmf.o pcm.o
150 150
 OBJS-$(CONFIG_MMF_MUXER)                 += mmf.o riff.o
151
-OBJS-$(CONFIG_MOV_DEMUXER)               += mov.o riff.o isom.o
151
+OBJS-$(CONFIG_MOV_DEMUXER)               += mov.o riff.o isom.o mov_chan.o
152 152
 OBJS-$(CONFIG_MOV_MUXER)                 += movenc.o riff.o isom.o avc.o \
153
-                                            movenchint.o rtpenc_chain.o
153
+                                            movenchint.o rtpenc_chain.o \
154
+                                            mov_chan.o
154 155
 OBJS-$(CONFIG_MP2_MUXER)                 += mp3enc.o rawenc.o
155 156
 OBJS-$(CONFIG_MP3_DEMUXER)               += mp3dec.o
156 157
 OBJS-$(CONFIG_MP3_MUXER)                 += mp3enc.o rawenc.o id3v2enc.o
... ...
@@ -224,64 +224,49 @@ const AVCodecTag codec_movvideo_tags[] = {
224 224
 };
225 225
 
226 226
 const AVCodecTag codec_movaudio_tags[] = {
227
-    { CODEC_ID_PCM_S32BE, MKTAG('i', 'n', '3', '2') },
228
-    { CODEC_ID_PCM_S32LE, MKTAG('i', 'n', '3', '2') },
229
-    { CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') },
230
-    { CODEC_ID_PCM_S24LE, MKTAG('i', 'n', '2', '4') },
231
-    { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') }, /* 16 bits */
232
-    { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') }, /*  */
233
-    { CODEC_ID_PCM_S16LE, MKTAG('l', 'p', 'c', 'm') },
234
-    { CODEC_ID_PCM_F32BE, MKTAG('f', 'l', '3', '2') },
235
-    { CODEC_ID_PCM_F32LE, MKTAG('f', 'l', '3', '2') },
236
-    { CODEC_ID_PCM_F64BE, MKTAG('f', 'l', '6', '4') },
237
-    { CODEC_ID_PCM_F64LE, MKTAG('f', 'l', '6', '4') },
238
-    { CODEC_ID_PCM_S8,    MKTAG('s', 'o', 'w', 't') },
239
-    { CODEC_ID_PCM_U8,    MKTAG('r', 'a', 'w', ' ') }, /* 8 bits unsigned */
240
-    { CODEC_ID_PCM_U8,    MKTAG('N', 'O', 'N', 'E') }, /* uncompressed */
241
-    { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') }, /*  */
242
-    { CODEC_ID_PCM_ALAW,  MKTAG('a', 'l', 'a', 'w') }, /*  */
243
-
244
-    { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') }, /* IMA-4 ADPCM */
245
-
246
-    { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') }, /* Macintosh Audio Compression and Expansion 3:1 */
247
-    { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') }, /* Macintosh Audio Compression and Expansion 6:1 */
248
-
249
-    { CODEC_ID_MP1, MKTAG('.', 'm', 'p', '1') }, /* MPEG layer 1 */
250
-    { CODEC_ID_MP2, MKTAG('.', 'm', 'p', '2') }, /* MPEG layer 2 */
251
-
252
-    { CODEC_ID_MP3, MKTAG('.', 'm', 'p', '3') }, /* MPEG layer 3 */ /* sample files at http://www.3ivx.com/showcase.html use this tag */
253
-    { CODEC_ID_MP3, 0x6D730055 }, /* MPEG layer 3 */
254
-
255
-/*  { CODEC_ID_OGG_VORBIS, MKTAG('O', 'g', 'g', 'S') }, *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
256
-
257
-    { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') }, /* MPEG-4 AAC */
258
-    { CODEC_ID_AC3, MKTAG('a', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */
259
-    { CODEC_ID_AC3, MKTAG('s', 'a', 'c', '3') }, /* Nero Recode */
260
-    { CODEC_ID_DTS, MKTAG('d', 't', 's', 'c') }, /* mp4ra.org */
261
-    { CODEC_ID_DTS, MKTAG('D', 'T', 'S', ' ') }, /* non-standard */
262
-    { CODEC_ID_EAC3, MKTAG('e', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */
263
-
264
-    { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */
265
-    { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */
266
-
267
-    { CODEC_ID_GSM,  MKTAG('a', 'g', 's', 'm') },
268
-    { CODEC_ID_NELLYMOSER, MKTAG('n', 'm', 'o', 's') }, /* Flash Media Server */
269
-    { CODEC_ID_ALAC, MKTAG('a', 'l', 'a', 'c') }, /* Apple Lossless */
270
-
271
-    { CODEC_ID_QCELP, MKTAG('Q','c','l','p') },
272
-    { CODEC_ID_QCELP, MKTAG('Q','c','l','q') },
273
-    { CODEC_ID_QCELP, MKTAG('s','q','c','p') }, /* ISO Media fourcc */
274
-
275
-    { CODEC_ID_QDMC, MKTAG('Q', 'D', 'M', 'C') }, /* QDMC */
276
-    { CODEC_ID_QDM2, MKTAG('Q', 'D', 'M', '2') }, /* QDM2 */
277
-
278
-    { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
279
-    { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },
280
-
281
-    { CODEC_ID_SPEEX, MKTAG('s','p','e','x') }, /* Flash Media Server */
282
-
283
-    { CODEC_ID_WMAV2, MKTAG('W', 'M', 'A', '2') },
284
-
227
+    { CODEC_ID_AAC,             MKTAG('m', 'p', '4', 'a') },
228
+    { CODEC_ID_AC3,             MKTAG('a', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */
229
+    { CODEC_ID_AC3,             MKTAG('s', 'a', 'c', '3') }, /* Nero Recode */
230
+    { CODEC_ID_ADPCM_IMA_QT,    MKTAG('i', 'm', 'a', '4') },
231
+    { CODEC_ID_ALAC,            MKTAG('a', 'l', 'a', 'c') },
232
+    { CODEC_ID_AMR_NB,          MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */
233
+    { CODEC_ID_AMR_WB,          MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */
234
+    { CODEC_ID_DTS,             MKTAG('d', 't', 's', 'c') }, /* mp4ra.org */
235
+    { CODEC_ID_DTS,             MKTAG('D', 'T', 'S', ' ') }, /* non-standard */
236
+    { CODEC_ID_DVAUDIO,         MKTAG('v', 'd', 'v', 'a') },
237
+    { CODEC_ID_DVAUDIO,         MKTAG('d', 'v', 'c', 'a') },
238
+    { CODEC_ID_EAC3,            MKTAG('e', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */
239
+    { CODEC_ID_GSM,             MKTAG('a', 'g', 's', 'm') },
240
+    { CODEC_ID_MACE3,           MKTAG('M', 'A', 'C', '3') },
241
+    { CODEC_ID_MACE6,           MKTAG('M', 'A', 'C', '6') },
242
+    { CODEC_ID_MP1,             MKTAG('.', 'm', 'p', '1') },
243
+    { CODEC_ID_MP2,             MKTAG('.', 'm', 'p', '2') },
244
+    { CODEC_ID_MP3,             MKTAG('.', 'm', 'p', '3') },
245
+    { CODEC_ID_MP3,             0x6D730055                },
246
+    { CODEC_ID_NELLYMOSER,      MKTAG('n', 'm', 'o', 's') }, /* Flash Media Server */
247
+    { CODEC_ID_PCM_ALAW,        MKTAG('a', 'l', 'a', 'w') },
248
+    { CODEC_ID_PCM_F32BE,       MKTAG('f', 'l', '3', '2') },
249
+    { CODEC_ID_PCM_F32LE,       MKTAG('f', 'l', '3', '2') },
250
+    { CODEC_ID_PCM_F64BE,       MKTAG('f', 'l', '6', '4') },
251
+    { CODEC_ID_PCM_F64LE,       MKTAG('f', 'l', '6', '4') },
252
+    { CODEC_ID_PCM_MULAW,       MKTAG('u', 'l', 'a', 'w') },
253
+    { CODEC_ID_PCM_S16BE,       MKTAG('t', 'w', 'o', 's') },
254
+    { CODEC_ID_PCM_S16LE,       MKTAG('s', 'o', 'w', 't') },
255
+    { CODEC_ID_PCM_S16LE,       MKTAG('l', 'p', 'c', 'm') },
256
+    { CODEC_ID_PCM_S24BE,       MKTAG('i', 'n', '2', '4') },
257
+    { CODEC_ID_PCM_S24LE,       MKTAG('i', 'n', '2', '4') },
258
+    { CODEC_ID_PCM_S32BE,       MKTAG('i', 'n', '3', '2') },
259
+    { CODEC_ID_PCM_S32LE,       MKTAG('i', 'n', '3', '2') },
260
+    { CODEC_ID_PCM_S8,          MKTAG('s', 'o', 'w', 't') },
261
+    { CODEC_ID_PCM_U8,          MKTAG('r', 'a', 'w', ' ') },
262
+    { CODEC_ID_PCM_U8,          MKTAG('N', 'O', 'N', 'E') },
263
+    { CODEC_ID_QCELP,           MKTAG('Q', 'c', 'l', 'p') },
264
+    { CODEC_ID_QCELP,           MKTAG('Q', 'c', 'l', 'q') },
265
+    { CODEC_ID_QCELP,           MKTAG('s', 'q', 'c', 'p') }, /* ISO Media fourcc */
266
+    { CODEC_ID_QDM2,            MKTAG('Q', 'D', 'M', '2') },
267
+    { CODEC_ID_QDMC,            MKTAG('Q', 'D', 'M', 'C') },
268
+    { CODEC_ID_SPEEX,           MKTAG('s', 'p', 'e', 'x') }, /* Flash Media Server */
269
+    { CODEC_ID_WMAV2,           MKTAG('W', 'M', 'A', '2') },
285 270
     { CODEC_ID_NONE, 0 },
286 271
 };
287 272
 
... ...
@@ -37,6 +37,7 @@
37 37
 #include "isom.h"
38 38
 #include "libavcodec/get_bits.h"
39 39
 #include "id3v1.h"
40
+#include "mov_chan.h"
40 41
 
41 42
 #if CONFIG_ZLIB
42 43
 #include <zlib.h>
... ...
@@ -568,6 +569,51 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
568 568
     return 0;
569 569
 }
570 570
 
571
+static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
572
+{
573
+    AVStream *st;
574
+    uint8_t version;
575
+    uint32_t flags, layout_tag, bitmap, num_descr;
576
+
577
+    if (c->fc->nb_streams < 1)
578
+        return 0;
579
+    st = c->fc->streams[c->fc->nb_streams-1];
580
+
581
+    if (atom.size < 16)
582
+        return 0;
583
+
584
+    version = avio_r8(pb);
585
+    flags   = avio_rb24(pb);
586
+
587
+    layout_tag = avio_rb32(pb);
588
+    bitmap     = avio_rb32(pb);
589
+    num_descr  = avio_rb32(pb);
590
+
591
+    if (atom.size < 16ULL + num_descr * 20ULL)
592
+        return 0;
593
+
594
+    av_dlog(c->fc, "chan: size=%ld version=%u flags=%u layout=%u bitmap=%u num_descr=%u\n",
595
+            atom.size, version, flags, layout_tag, bitmap, num_descr);
596
+
597
+#if 0
598
+    /* TODO: use the channel descriptions if the layout tag is 0 */
599
+    int i;
600
+    for (i = 0; i < num_descr; i++) {
601
+        uint32_t label, cflags;
602
+        float coords[3];
603
+        label     = avio_rb32(pb);          // mChannelLabel
604
+        cflags    = avio_rb32(pb);          // mChannelFlags
605
+        AV_WN32(&coords[0], avio_rl32(pb)); // mCoordinates[0]
606
+        AV_WN32(&coords[1], avio_rl32(pb)); // mCoordinates[1]
607
+        AV_WN32(&coords[2], avio_rl32(pb)); // mCoordinates[2]
608
+    }
609
+#endif
610
+
611
+    st->codec->channel_layout = ff_mov_get_channel_layout(layout_tag, bitmap);
612
+
613
+    return 0;
614
+}
615
+
571 616
 static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
572 617
 {
573 618
     AVStream *st;
... ...
@@ -2346,7 +2392,7 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
2346 2346
     return 0;
2347 2347
 }
2348 2348
 
2349
-static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
2349
+static int mov_read_chan2(MOVContext *c, AVIOContext *pb, MOVAtom atom)
2350 2350
 {
2351 2351
     if (atom.size < 16)
2352 2352
         return 0;
... ...
@@ -2409,7 +2455,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
2409 2409
 { MKTAG('w','i','d','e'), mov_read_wide }, /* place holder */
2410 2410
 { MKTAG('w','f','e','x'), mov_read_wfex },
2411 2411
 { MKTAG('c','m','o','v'), mov_read_cmov },
2412
-{ MKTAG('c','h','a','n'), mov_read_chan },
2412
+{ MKTAG('c','h','a','n'), mov_read_chan }, /* channel layout */
2413 2413
 { 0, NULL }
2414 2414
 };
2415 2415
 
2416 2416
new file mode 100644
... ...
@@ -0,0 +1,505 @@
0
+/*
1
+ * Copyright (c) 2011 Justin Ruggles
2
+ *
3
+ * This file is part of Libav.
4
+ *
5
+ * Libav is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * Libav is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with Libav; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+/**
21
+ * mov 'chan' tag reading/writing.
22
+ * @author Justin Ruggles
23
+ */
24
+
25
+#include <stdint.h>
26
+
27
+#include "libavutil/audioconvert.h"
28
+#include "libavcodec/avcodec.h"
29
+#include "mov_chan.h"
30
+
31
+/**
32
+ * Channel Layout Tag
33
+ * This tells which channels are present in the audio stream and the order in
34
+ * which they appear.
35
+ *
36
+ * @note We're using the channel layout tag to indicate channel order
37
+ *       when the value is greater than 0x10000. The Apple documentation has
38
+ *       some contradictions as to how this is actually supposed to be handled.
39
+ *
40
+ *       Core Audio File Format Spec:
41
+ *           "The high 16 bits indicates a specific ordering of the channels."
42
+ *       Core Audio Data Types Reference:
43
+ *           "These identifiers specify the channels included in a layout but
44
+ *            do not specify a particular ordering of those channels."
45
+ */
46
+enum MovChannelLayoutTag {
47
+    MOV_CH_LAYOUT_UNKNOWN               = 0xFFFF0000,
48
+    MOV_CH_LAYOUT_USE_DESCRIPTIONS      = (  0 << 16) | 0,
49
+    MOV_CH_LAYOUT_USE_BITMAP            = (  1 << 16) | 0,
50
+    MOV_CH_LAYOUT_DISCRETEINORDER       = (147 << 16) | 0,
51
+    MOV_CH_LAYOUT_MONO                  = (100 << 16) | 1,
52
+    MOV_CH_LAYOUT_STEREO                = (101 << 16) | 2,
53
+    MOV_CH_LAYOUT_STEREOHEADPHONES      = (102 << 16) | 2,
54
+    MOV_CH_LAYOUT_MATRIXSTEREO          = (103 << 16) | 2,
55
+    MOV_CH_LAYOUT_MIDSIDE               = (104 << 16) | 2,
56
+    MOV_CH_LAYOUT_XY                    = (105 << 16) | 2,
57
+    MOV_CH_LAYOUT_BINAURAL              = (106 << 16) | 2,
58
+    MOV_CH_LAYOUT_AMBISONIC_B_FORMAT    = (107 << 16) | 4,
59
+    MOV_CH_LAYOUT_QUADRAPHONIC          = (108 << 16) | 4,
60
+    MOV_CH_LAYOUT_PENTAGONAL            = (109 << 16) | 5,
61
+    MOV_CH_LAYOUT_HEXAGONAL             = (110 << 16) | 6,
62
+    MOV_CH_LAYOUT_OCTAGONAL             = (111 << 16) | 8,
63
+    MOV_CH_LAYOUT_CUBE                  = (112 << 16) | 8,
64
+    MOV_CH_LAYOUT_MPEG_3_0_A            = (113 << 16) | 3,
65
+    MOV_CH_LAYOUT_MPEG_3_0_B            = (114 << 16) | 3,
66
+    MOV_CH_LAYOUT_MPEG_4_0_A            = (115 << 16) | 4,
67
+    MOV_CH_LAYOUT_MPEG_4_0_B            = (116 << 16) | 4,
68
+    MOV_CH_LAYOUT_MPEG_5_0_A            = (117 << 16) | 5,
69
+    MOV_CH_LAYOUT_MPEG_5_0_B            = (118 << 16) | 5,
70
+    MOV_CH_LAYOUT_MPEG_5_0_C            = (119 << 16) | 5,
71
+    MOV_CH_LAYOUT_MPEG_5_0_D            = (120 << 16) | 5,
72
+    MOV_CH_LAYOUT_MPEG_5_1_A            = (121 << 16) | 6,
73
+    MOV_CH_LAYOUT_MPEG_5_1_B            = (122 << 16) | 6,
74
+    MOV_CH_LAYOUT_MPEG_5_1_C            = (123 << 16) | 6,
75
+    MOV_CH_LAYOUT_MPEG_5_1_D            = (124 << 16) | 6,
76
+    MOV_CH_LAYOUT_MPEG_6_1_A            = (125 << 16) | 7,
77
+    MOV_CH_LAYOUT_MPEG_7_1_A            = (126 << 16) | 8,
78
+    MOV_CH_LAYOUT_MPEG_7_1_B            = (127 << 16) | 8,
79
+    MOV_CH_LAYOUT_MPEG_7_1_C            = (128 << 16) | 8,
80
+    MOV_CH_LAYOUT_EMAGIC_DEFAULT_7_1    = (129 << 16) | 8,
81
+    MOV_CH_LAYOUT_SMPTE_DTV             = (130 << 16) | 8,
82
+    MOV_CH_LAYOUT_ITU_2_1               = (131 << 16) | 3,
83
+    MOV_CH_LAYOUT_ITU_2_2               = (132 << 16) | 4,
84
+    MOV_CH_LAYOUT_DVD_4                 = (133 << 16) | 3,
85
+    MOV_CH_LAYOUT_DVD_5                 = (134 << 16) | 4,
86
+    MOV_CH_LAYOUT_DVD_6                 = (135 << 16) | 5,
87
+    MOV_CH_LAYOUT_DVD_10                = (136 << 16) | 4,
88
+    MOV_CH_LAYOUT_DVD_11                = (137 << 16) | 5,
89
+    MOV_CH_LAYOUT_DVD_18                = (138 << 16) | 5,
90
+    MOV_CH_LAYOUT_AUDIOUNIT_6_0         = (139 << 16) | 6,
91
+    MOV_CH_LAYOUT_AUDIOUNIT_7_0         = (140 << 16) | 7,
92
+    MOV_CH_LAYOUT_AUDIOUNIT_7_0_FRONT   = (148 << 16) | 7,
93
+    MOV_CH_LAYOUT_AAC_6_0               = (141 << 16) | 6,
94
+    MOV_CH_LAYOUT_AAC_6_1               = (142 << 16) | 7,
95
+    MOV_CH_LAYOUT_AAC_7_0               = (143 << 16) | 7,
96
+    MOV_CH_LAYOUT_AAC_OCTAGONAL         = (144 << 16) | 8,
97
+    MOV_CH_LAYOUT_TMH_10_2_STD          = (145 << 16) | 16,
98
+    MOV_CH_LAYOUT_TMH_10_2_FULL         = (146 << 16) | 21,
99
+    MOV_CH_LAYOUT_AC3_1_0_1             = (149 << 16) | 2,
100
+    MOV_CH_LAYOUT_AC3_3_0               = (150 << 16) | 3,
101
+    MOV_CH_LAYOUT_AC3_3_1               = (151 << 16) | 4,
102
+    MOV_CH_LAYOUT_AC3_3_0_1             = (152 << 16) | 4,
103
+    MOV_CH_LAYOUT_AC3_2_1_1             = (153 << 16) | 4,
104
+    MOV_CH_LAYOUT_AC3_3_1_1             = (154 << 16) | 5,
105
+    MOV_CH_LAYOUT_EAC3_6_0_A            = (155 << 16) | 6,
106
+    MOV_CH_LAYOUT_EAC3_7_0_A            = (156 << 16) | 7,
107
+    MOV_CH_LAYOUT_EAC3_6_1_A            = (157 << 16) | 7,
108
+    MOV_CH_LAYOUT_EAC3_6_1_B            = (158 << 16) | 7,
109
+    MOV_CH_LAYOUT_EAC3_6_1_C            = (159 << 16) | 7,
110
+    MOV_CH_LAYOUT_EAC3_7_1_A            = (160 << 16) | 8,
111
+    MOV_CH_LAYOUT_EAC3_7_1_B            = (161 << 16) | 8,
112
+    MOV_CH_LAYOUT_EAC3_7_1_C            = (162 << 16) | 8,
113
+    MOV_CH_LAYOUT_EAC3_7_1_D            = (163 << 16) | 8,
114
+    MOV_CH_LAYOUT_EAC3_7_1_E            = (164 << 16) | 8,
115
+    MOV_CH_LAYOUT_EAC3_7_1_F            = (165 << 16) | 8,
116
+    MOV_CH_LAYOUT_EAC3_7_1_G            = (166 << 16) | 8,
117
+    MOV_CH_LAYOUT_EAC3_7_1_H            = (167 << 16) | 8,
118
+    MOV_CH_LAYOUT_DTS_3_1               = (168 << 16) | 4,
119
+    MOV_CH_LAYOUT_DTS_4_1               = (169 << 16) | 5,
120
+    MOV_CH_LAYOUT_DTS_6_0_A             = (170 << 16) | 6,
121
+    MOV_CH_LAYOUT_DTS_6_0_B             = (171 << 16) | 6,
122
+    MOV_CH_LAYOUT_DTS_6_0_C             = (172 << 16) | 6,
123
+    MOV_CH_LAYOUT_DTS_6_1_A             = (173 << 16) | 7,
124
+    MOV_CH_LAYOUT_DTS_6_1_B             = (174 << 16) | 7,
125
+    MOV_CH_LAYOUT_DTS_6_1_C             = (175 << 16) | 7,
126
+    MOV_CH_LAYOUT_DTS_6_1_D             = (182 << 16) | 7,
127
+    MOV_CH_LAYOUT_DTS_7_0               = (176 << 16) | 7,
128
+    MOV_CH_LAYOUT_DTS_7_1               = (177 << 16) | 8,
129
+    MOV_CH_LAYOUT_DTS_8_0_A             = (178 << 16) | 8,
130
+    MOV_CH_LAYOUT_DTS_8_0_B             = (179 << 16) | 8,
131
+    MOV_CH_LAYOUT_DTS_8_1_A             = (180 << 16) | 9,
132
+    MOV_CH_LAYOUT_DTS_8_1_B             = (181 << 16) | 9,
133
+};
134
+
135
+struct MovChannelLayoutMap {
136
+    uint32_t tag;
137
+    uint64_t layout;
138
+};
139
+
140
+static const struct MovChannelLayoutMap mov_ch_layout_map_misc[] = {
141
+    { MOV_CH_LAYOUT_USE_DESCRIPTIONS,   0 },
142
+    { MOV_CH_LAYOUT_USE_BITMAP,         0 },
143
+    { MOV_CH_LAYOUT_DISCRETEINORDER,    0 },
144
+    { MOV_CH_LAYOUT_UNKNOWN,            0 },
145
+    { MOV_CH_LAYOUT_TMH_10_2_STD,       0 }, // L,   R,  C,    Vhc, Lsd, Rsd,
146
+                                             // Ls,  Rs, Vhl,  Vhr, Lw,  Rw,
147
+                                             // Csd, Cs, LFE1, LFE2
148
+    { MOV_CH_LAYOUT_TMH_10_2_FULL,      0 }, // L,   R,  C,    Vhc,  Lsd, Rsd,
149
+                                             // Ls,  Rs, Vhl,  Vhr,  Lw,  Rw,
150
+                                             // Csd, Cs, LFE1, LFE2, Lc,  Rc,
151
+                                             // HI,  VI, Haptic
152
+    { 0, 0 },
153
+};
154
+
155
+static const struct MovChannelLayoutMap mov_ch_layout_map_1ch[] = {
156
+    { MOV_CH_LAYOUT_MONO,               AV_CH_LAYOUT_MONO }, // C
157
+};
158
+
159
+static const struct MovChannelLayoutMap mov_ch_layout_map_2ch[] = {
160
+    { MOV_CH_LAYOUT_STEREO,             AV_CH_LAYOUT_STEREO         }, // L, R
161
+    { MOV_CH_LAYOUT_STEREOHEADPHONES,   AV_CH_LAYOUT_STEREO         }, // L, R
162
+    { MOV_CH_LAYOUT_BINAURAL,           AV_CH_LAYOUT_STEREO         }, // L, R
163
+    { MOV_CH_LAYOUT_MIDSIDE,            AV_CH_LAYOUT_STEREO         }, // C, sides
164
+    { MOV_CH_LAYOUT_XY,                 AV_CH_LAYOUT_STEREO         }, // X (left), Y (right)
165
+
166
+    { MOV_CH_LAYOUT_MATRIXSTEREO,       AV_CH_LAYOUT_STEREO_DOWNMIX }, // Lt, Rt
167
+
168
+    { MOV_CH_LAYOUT_AC3_1_0_1,          AV_CH_LAYOUT_MONO |            // C, LFE
169
+                                        AV_CH_LOW_FREQUENCY         },
170
+    { 0, 0 },
171
+};
172
+
173
+static const struct MovChannelLayoutMap mov_ch_layout_map_3ch[] = {
174
+    { MOV_CH_LAYOUT_MPEG_3_0_A,         AV_CH_LAYOUT_SURROUND }, // L, R, C
175
+    { MOV_CH_LAYOUT_MPEG_3_0_B,         AV_CH_LAYOUT_SURROUND }, // C, L, R
176
+    { MOV_CH_LAYOUT_AC3_3_0,            AV_CH_LAYOUT_SURROUND }, // L, C, R
177
+
178
+    { MOV_CH_LAYOUT_ITU_2_1,            AV_CH_LAYOUT_2_1      }, // L, R, Cs
179
+
180
+    { MOV_CH_LAYOUT_DVD_4,              AV_CH_LAYOUT_2POINT1  }, // L, R, LFE
181
+    { 0, 0 },
182
+};
183
+
184
+static const struct MovChannelLayoutMap mov_ch_layout_map_4ch[] = {
185
+    { MOV_CH_LAYOUT_AMBISONIC_B_FORMAT, 0 },                    // W, X, Y, Z
186
+
187
+    { MOV_CH_LAYOUT_QUADRAPHONIC,       AV_CH_LAYOUT_QUAD    }, // L, R, Rls, Rrs
188
+
189
+    { MOV_CH_LAYOUT_MPEG_4_0_A,         AV_CH_LAYOUT_4POINT0 }, // L, R, C, Cs
190
+    { MOV_CH_LAYOUT_MPEG_4_0_B,         AV_CH_LAYOUT_4POINT0 }, // C, L, R, Cs
191
+    { MOV_CH_LAYOUT_AC3_3_1,            AV_CH_LAYOUT_4POINT0 }, // L, C, R, Cs
192
+
193
+    { MOV_CH_LAYOUT_ITU_2_2,            AV_CH_LAYOUT_2_2     }, // L, R, Ls, Rs
194
+
195
+    { MOV_CH_LAYOUT_DVD_5,              AV_CH_LAYOUT_2_1 |      // L, R, LFE, Cs
196
+                                        AV_CH_LOW_FREQUENCY  },
197
+    { MOV_CH_LAYOUT_AC3_2_1_1,          AV_CH_LAYOUT_2_1 |      // L, R, Cs, LFE
198
+                                        AV_CH_LOW_FREQUENCY  },
199
+
200
+    { MOV_CH_LAYOUT_DVD_10,             AV_CH_LAYOUT_3POINT1 }, // L, R, C, LFE
201
+    { MOV_CH_LAYOUT_AC3_3_0_1,          AV_CH_LAYOUT_3POINT1 }, // L, C, R, LFE
202
+    { MOV_CH_LAYOUT_DTS_3_1,            AV_CH_LAYOUT_3POINT1 }, // C, L, R, LFE
203
+    { 0, 0 },
204
+};
205
+
206
+static const struct MovChannelLayoutMap mov_ch_layout_map_5ch[] = {
207
+    { MOV_CH_LAYOUT_PENTAGONAL,         AV_CH_LAYOUT_5POINT0_BACK }, // L, R, Rls, Rrs, C
208
+
209
+    { MOV_CH_LAYOUT_MPEG_5_0_A,         AV_CH_LAYOUT_5POINT0 },      // L, R, C,  Ls, Rs
210
+    { MOV_CH_LAYOUT_MPEG_5_0_B,         AV_CH_LAYOUT_5POINT0 },      // L, R, Ls, Rs, C
211
+    { MOV_CH_LAYOUT_MPEG_5_0_C,         AV_CH_LAYOUT_5POINT0 },      // L, C, R,  Ls, Rs
212
+    { MOV_CH_LAYOUT_MPEG_5_0_D,         AV_CH_LAYOUT_5POINT0 },      // C, L, R,  Ls, Rs
213
+
214
+    { MOV_CH_LAYOUT_DVD_6,              AV_CH_LAYOUT_2_2 |           // L, R, LFE, Ls, Rs
215
+                                        AV_CH_LOW_FREQUENCY },
216
+    { MOV_CH_LAYOUT_DVD_18,             AV_CH_LAYOUT_2_2 |           // L, R, Ls, Rs, LFE
217
+                                        AV_CH_LOW_FREQUENCY },
218
+
219
+    { MOV_CH_LAYOUT_DVD_11,             AV_CH_LAYOUT_4POINT1 },      // L, R, C, LFE, Cs
220
+    { MOV_CH_LAYOUT_AC3_3_1_1,          AV_CH_LAYOUT_4POINT1 },      // L, C, R, Cs,  LFE
221
+    { MOV_CH_LAYOUT_DTS_4_1,            AV_CH_LAYOUT_4POINT1 },      // C, L, R, Cs,  LFE
222
+    { 0, 0 },
223
+};
224
+
225
+static const struct MovChannelLayoutMap mov_ch_layout_map_6ch[] = {
226
+    { MOV_CH_LAYOUT_HEXAGONAL,          AV_CH_LAYOUT_HEXAGONAL },      // L, R,  Rls, Rrs, C,   Cs
227
+    { MOV_CH_LAYOUT_DTS_6_0_C,          AV_CH_LAYOUT_HEXAGONAL },      // C, Cs, L,   R,   Rls, Rrs
228
+
229
+    { MOV_CH_LAYOUT_MPEG_5_1_A,         AV_CH_LAYOUT_5POINT1 },        // L, R, C,  LFE, Ls, Rs
230
+    { MOV_CH_LAYOUT_MPEG_5_1_B,         AV_CH_LAYOUT_5POINT1 },        // L, R, Ls, Rs,  C,  LFE
231
+    { MOV_CH_LAYOUT_MPEG_5_1_C,         AV_CH_LAYOUT_5POINT1 },        // L, C, R,  Ls,  Rs, LFE
232
+    { MOV_CH_LAYOUT_MPEG_5_1_D,         AV_CH_LAYOUT_5POINT1 },        // C, L, R,  Ls,  Rs, LFE
233
+
234
+    { MOV_CH_LAYOUT_AUDIOUNIT_6_0,      AV_CH_LAYOUT_6POINT0 },        // L, R, Ls, Rs, C,  Cs
235
+    { MOV_CH_LAYOUT_AAC_6_0,            AV_CH_LAYOUT_6POINT0 },        // C, L, R,  Ls, Rs, Cs
236
+    { MOV_CH_LAYOUT_EAC3_6_0_A,         AV_CH_LAYOUT_6POINT0 },        // L, C, R,  Ls, Rs, Cs
237
+
238
+    { MOV_CH_LAYOUT_DTS_6_0_A,          AV_CH_LAYOUT_6POINT0_FRONT },  // Lc, Rc, L, R, Ls, Rs
239
+
240
+    { MOV_CH_LAYOUT_DTS_6_0_B,          AV_CH_LAYOUT_5POINT0_BACK |    // C, L, R, Rls, Rrs, Ts
241
+                                        AV_CH_TOP_CENTER },
242
+    { 0, 0 },
243
+};
244
+
245
+static const struct MovChannelLayoutMap mov_ch_layout_map_7ch[] = {
246
+    { MOV_CH_LAYOUT_MPEG_6_1_A,          AV_CH_LAYOUT_6POINT1 },        // L, R, C, LFE, Ls, Rs,  Cs
247
+    { MOV_CH_LAYOUT_AAC_6_1,             AV_CH_LAYOUT_6POINT1 },        // C, L, R, Ls,  Rs, Cs,  LFE
248
+    { MOV_CH_LAYOUT_EAC3_6_1_A,          AV_CH_LAYOUT_6POINT1 },        // L, C, R, Ls,  Rs, LFE, Cs
249
+    { MOV_CH_LAYOUT_DTS_6_1_D,           AV_CH_LAYOUT_6POINT1 },        // C, L, R, Ls,  Rs, LFE, Cs
250
+
251
+    { MOV_CH_LAYOUT_AUDIOUNIT_7_0,       AV_CH_LAYOUT_7POINT0 },        // L, R, Ls, Rs, C,  Rls, Rrs
252
+    { MOV_CH_LAYOUT_AAC_7_0,             AV_CH_LAYOUT_7POINT0 },        // C, L, R,  Ls, Rs, Rls, Rrs
253
+    { MOV_CH_LAYOUT_EAC3_7_0_A,          AV_CH_LAYOUT_7POINT0 },        // L, C, R,  Ls, Rs, Rls, Rrs
254
+
255
+    { MOV_CH_LAYOUT_AUDIOUNIT_7_0_FRONT, AV_CH_LAYOUT_7POINT0_FRONT },  // L,  R, Ls, Rs, C, Lc, Rc
256
+    { MOV_CH_LAYOUT_DTS_7_0,             AV_CH_LAYOUT_7POINT0_FRONT },  // Lc, C, Rc, L,  R, Ls, Rs
257
+
258
+    { MOV_CH_LAYOUT_EAC3_6_1_B,          AV_CH_LAYOUT_5POINT1 |         // L, C, R, Ls, Rs, LFE, Ts
259
+                                         AV_CH_TOP_CENTER },
260
+
261
+    { MOV_CH_LAYOUT_EAC3_6_1_C,          AV_CH_LAYOUT_5POINT1 |         // L, C, R, Ls, Rs, LFE, Vhc
262
+                                         AV_CH_TOP_FRONT_CENTER },
263
+
264
+    { MOV_CH_LAYOUT_DTS_6_1_A,           AV_CH_LAYOUT_6POINT1_FRONT },  // Lc, Rc, L, R, Ls, Rs, LFE
265
+
266
+    { MOV_CH_LAYOUT_DTS_6_1_B,           AV_CH_LAYOUT_5POINT1_BACK |    // C, L, R, Rls, Rrs, Ts, LFE
267
+                                         AV_CH_TOP_CENTER },
268
+
269
+    { MOV_CH_LAYOUT_DTS_6_1_C,           AV_CH_LAYOUT_6POINT1_BACK },   // C, Cs, L, R, Rls, Rrs, LFE
270
+    { 0, 0 },
271
+};
272
+
273
+static const struct MovChannelLayoutMap mov_ch_layout_map_8ch[] = {
274
+    { MOV_CH_LAYOUT_OCTAGONAL,           AV_CH_LAYOUT_OCTAGONAL },      // L, R, Rls, Rrs, C,  Cs,  Ls,  Rs
275
+    { MOV_CH_LAYOUT_AAC_OCTAGONAL,       AV_CH_LAYOUT_OCTAGONAL },      // C, L, R,   Ls,  Rs, Rls, Rrs, Cs
276
+
277
+    { MOV_CH_LAYOUT_CUBE,                AV_CH_LAYOUT_QUAD     |        // L, R, Rls, Rrs, Vhl, Vhr, Rlt, Rrt
278
+                                         AV_CH_TOP_FRONT_LEFT  |
279
+                                         AV_CH_TOP_FRONT_RIGHT |
280
+                                         AV_CH_TOP_BACK_LEFT   |
281
+                                         AV_CH_TOP_BACK_RIGHT },
282
+
283
+    { MOV_CH_LAYOUT_MPEG_7_1_A,          AV_CH_LAYOUT_7POINT1_WIDE },   // L,  R,  C,  LFE, Ls, Rs,  Lc, Rc
284
+    { MOV_CH_LAYOUT_MPEG_7_1_B,          AV_CH_LAYOUT_7POINT1_WIDE },   // C,  Lc, Rc, L,   R,  Ls,  Rs, LFE
285
+    { MOV_CH_LAYOUT_EMAGIC_DEFAULT_7_1,  AV_CH_LAYOUT_7POINT1_WIDE },   // L,  R,  Ls, Rs,  C,  LFE, Lc, Rc
286
+    { MOV_CH_LAYOUT_EAC3_7_1_B,          AV_CH_LAYOUT_7POINT1_WIDE },   // L,  C,  R,  Ls,  Rs, LFE, Lc, Rc
287
+    { MOV_CH_LAYOUT_DTS_7_1,             AV_CH_LAYOUT_7POINT1_WIDE },   // Lc, C,  Rc, L,   R,  Ls,  Rs, LFE
288
+
289
+    { MOV_CH_LAYOUT_MPEG_7_1_C,          AV_CH_LAYOUT_7POINT1 },        // L, R, C, LFE, Ls, Rs,  Rls, Rrs
290
+    { MOV_CH_LAYOUT_EAC3_7_1_A,          AV_CH_LAYOUT_7POINT1 },        // L, C, R, Ls,  Rs, LFE, Rls, Rrs
291
+
292
+    { MOV_CH_LAYOUT_SMPTE_DTV,           AV_CH_LAYOUT_5POINT1 |         // L, R, C, LFE, Ls, Rs, Lt, Rt
293
+                                         AV_CH_LAYOUT_STEREO_DOWNMIX },
294
+
295
+    { MOV_CH_LAYOUT_EAC3_7_1_C,          AV_CH_LAYOUT_5POINT1        |  // L, C, R, Ls, Rs, LFE, Lsd, Rsd
296
+                                         AV_CH_SURROUND_DIRECT_LEFT  |
297
+                                         AV_CH_SURROUND_DIRECT_RIGHT },
298
+
299
+    { MOV_CH_LAYOUT_EAC3_7_1_D,          AV_CH_LAYOUT_5POINT1 |         // L, C, R, Ls, Rs, LFE, Lw, Rw
300
+                                         AV_CH_WIDE_LEFT      |
301
+                                         AV_CH_WIDE_RIGHT },
302
+
303
+    { MOV_CH_LAYOUT_EAC3_7_1_E,          AV_CH_LAYOUT_5POINT1 |         // L, C, R, Ls, Rs, LFE, Vhl, Vhr
304
+                                         AV_CH_TOP_FRONT_LEFT |
305
+                                         AV_CH_TOP_FRONT_RIGHT },
306
+
307
+    { MOV_CH_LAYOUT_EAC3_7_1_F,          AV_CH_LAYOUT_5POINT1 |         // L, C, R, Ls, Rs, LFE, Cs, Ts
308
+                                         AV_CH_BACK_CENTER    |
309
+                                         AV_CH_TOP_CENTER },
310
+
311
+    { MOV_CH_LAYOUT_EAC3_7_1_G,          AV_CH_LAYOUT_5POINT1 |         // L, C, R, Ls, Rs, LFE, Cs, Vhc
312
+                                         AV_CH_BACK_CENTER    |
313
+                                         AV_CH_TOP_FRONT_CENTER },
314
+
315
+    { MOV_CH_LAYOUT_EAC3_7_1_H,          AV_CH_LAYOUT_5POINT1 |         // L, C, R, Ls, Rs, LFE, Ts, Vhc
316
+                                         AV_CH_TOP_CENTER     |
317
+                                         AV_CH_TOP_FRONT_CENTER },
318
+
319
+    { MOV_CH_LAYOUT_DTS_8_0_A,           AV_CH_LAYOUT_2_2           |   // Lc, Rc, L, R, Ls, Rs, Rls, Rrs
320
+                                         AV_CH_BACK_LEFT            |
321
+                                         AV_CH_BACK_RIGHT           |
322
+                                         AV_CH_FRONT_LEFT_OF_CENTER |
323
+                                         AV_CH_FRONT_RIGHT_OF_CENTER },
324
+
325
+    { MOV_CH_LAYOUT_DTS_8_0_B,           AV_CH_LAYOUT_5POINT0        |  // Lc, C, Rc, L, R, Ls, Cs, Rs
326
+                                         AV_CH_FRONT_LEFT_OF_CENTER  |
327
+                                         AV_CH_FRONT_RIGHT_OF_CENTER |
328
+                                         AV_CH_BACK_CENTER },
329
+    { 0, 0 },
330
+};
331
+
332
+static const struct MovChannelLayoutMap mov_ch_layout_map_9ch[] = {
333
+    { MOV_CH_LAYOUT_DTS_8_1_A,           AV_CH_LAYOUT_2_2            | // Lc, Rc, L, R, Ls, Rs, Rls, Rrs, LFE
334
+                                         AV_CH_BACK_LEFT             |
335
+                                         AV_CH_BACK_RIGHT            |
336
+                                         AV_CH_FRONT_LEFT_OF_CENTER  |
337
+                                         AV_CH_FRONT_RIGHT_OF_CENTER |
338
+                                         AV_CH_LOW_FREQUENCY },
339
+
340
+    { MOV_CH_LAYOUT_DTS_8_1_B,           AV_CH_LAYOUT_7POINT1_WIDE   | // Lc, C, Rc, L, R, Ls, Cs, Rs, LFE
341
+                                         AV_CH_BACK_CENTER },
342
+    { 0, 0 },
343
+};
344
+
345
+static const struct MovChannelLayoutMap *mov_ch_layout_map[] = {
346
+    mov_ch_layout_map_misc,
347
+    mov_ch_layout_map_1ch,
348
+    mov_ch_layout_map_2ch,
349
+    mov_ch_layout_map_3ch,
350
+    mov_ch_layout_map_4ch,
351
+    mov_ch_layout_map_5ch,
352
+    mov_ch_layout_map_6ch,
353
+    mov_ch_layout_map_7ch,
354
+    mov_ch_layout_map_8ch,
355
+    mov_ch_layout_map_9ch,
356
+};
357
+
358
+static const enum MovChannelLayoutTag mov_ch_layouts_aac[] = {
359
+    MOV_CH_LAYOUT_MONO,
360
+    MOV_CH_LAYOUT_STEREO,
361
+    MOV_CH_LAYOUT_AC3_1_0_1,
362
+    MOV_CH_LAYOUT_MPEG_3_0_B,
363
+    MOV_CH_LAYOUT_ITU_2_1,
364
+    MOV_CH_LAYOUT_DVD_4,
365
+    MOV_CH_LAYOUT_QUADRAPHONIC,
366
+    MOV_CH_LAYOUT_MPEG_4_0_B,
367
+    MOV_CH_LAYOUT_ITU_2_2,
368
+    MOV_CH_LAYOUT_AC3_2_1_1,
369
+    MOV_CH_LAYOUT_DTS_3_1,
370
+    MOV_CH_LAYOUT_MPEG_5_0_D,
371
+    MOV_CH_LAYOUT_DVD_18,
372
+    MOV_CH_LAYOUT_DTS_4_1,
373
+    MOV_CH_LAYOUT_MPEG_5_1_D,
374
+    MOV_CH_LAYOUT_AAC_6_0,
375
+    MOV_CH_LAYOUT_DTS_6_0_A,
376
+    MOV_CH_LAYOUT_AAC_6_1,
377
+    MOV_CH_LAYOUT_AAC_7_0,
378
+    MOV_CH_LAYOUT_DTS_6_1_A,
379
+    MOV_CH_LAYOUT_AAC_OCTAGONAL,
380
+    MOV_CH_LAYOUT_MPEG_7_1_B,
381
+    MOV_CH_LAYOUT_DTS_8_0_A,
382
+    0,
383
+};
384
+
385
+static const enum MovChannelLayoutTag mov_ch_layouts_ac3[] = {
386
+    MOV_CH_LAYOUT_MONO,
387
+    MOV_CH_LAYOUT_STEREO,
388
+    MOV_CH_LAYOUT_AC3_1_0_1,
389
+    MOV_CH_LAYOUT_AC3_3_0,
390
+    MOV_CH_LAYOUT_ITU_2_1,
391
+    MOV_CH_LAYOUT_DVD_4,
392
+    MOV_CH_LAYOUT_AC3_3_1,
393
+    MOV_CH_LAYOUT_ITU_2_2,
394
+    MOV_CH_LAYOUT_AC3_2_1_1,
395
+    MOV_CH_LAYOUT_AC3_3_0_1,
396
+    MOV_CH_LAYOUT_MPEG_5_0_C,
397
+    MOV_CH_LAYOUT_DVD_18,
398
+    MOV_CH_LAYOUT_AC3_3_1_1,
399
+    MOV_CH_LAYOUT_MPEG_5_1_C,
400
+    0,
401
+};
402
+
403
+static const enum MovChannelLayoutTag mov_ch_layouts_alac[] = {
404
+    MOV_CH_LAYOUT_MONO,
405
+    MOV_CH_LAYOUT_STEREO,
406
+    MOV_CH_LAYOUT_MPEG_3_0_B,
407
+    MOV_CH_LAYOUT_MPEG_4_0_B,
408
+    MOV_CH_LAYOUT_MPEG_5_0_D,
409
+    MOV_CH_LAYOUT_MPEG_5_1_D,
410
+    MOV_CH_LAYOUT_AAC_6_1,
411
+    MOV_CH_LAYOUT_MPEG_7_1_B,
412
+    0,
413
+};
414
+
415
+static const struct {
416
+    enum CodecID codec_id;
417
+    const enum MovChannelLayoutTag *layouts;
418
+} mov_codec_ch_layouts[] = {
419
+    { CODEC_ID_AAC,     mov_ch_layouts_aac      },
420
+    { CODEC_ID_AC3,     mov_ch_layouts_ac3      },
421
+    { CODEC_ID_ALAC,    mov_ch_layouts_alac     },
422
+    { CODEC_ID_NONE,    NULL                    },
423
+};
424
+
425
+uint64_t ff_mov_get_channel_layout(uint32_t tag, uint32_t bitmap)
426
+{
427
+    int i, channels;
428
+    const struct MovChannelLayoutMap *layout_map;
429
+
430
+    /* handle the use of the channel descriptions */
431
+    /* TODO: map MOV channel labels to FFmpeg channels */
432
+    if (tag == MOV_CH_LAYOUT_USE_DESCRIPTIONS)
433
+        return 0;
434
+
435
+    /* handle the use of the channel bitmap */
436
+    if (tag == MOV_CH_LAYOUT_USE_BITMAP)
437
+        return bitmap < 0x40000 ? bitmap : 0;
438
+
439
+    /* get the layout map based on the channel count for the specified layout tag */
440
+    channels = tag & 0xFFFF;
441
+    if (channels > 9)
442
+        channels = 0;
443
+    layout_map = mov_ch_layout_map[channels];
444
+
445
+    /* find the channel layout for the specified layout tag */
446
+    for (i = 0; layout_map[i].tag != 0; i++) {
447
+        if (layout_map[i].tag == tag)
448
+            break;
449
+    }
450
+    return layout_map[i].layout;
451
+}
452
+
453
+uint32_t ff_mov_get_channel_layout_tag(enum CodecID codec_id,
454
+                                       uint64_t channel_layout,
455
+                                       uint32_t *bitmap)
456
+{
457
+    int i, j;
458
+    uint32_t tag = 0;
459
+    const enum MovChannelLayoutTag *layouts = NULL;
460
+
461
+    /* find the layout list for the specified codec */
462
+    for (i = 0; mov_codec_ch_layouts[i].codec_id != CODEC_ID_NONE; i++) {
463
+        if (mov_codec_ch_layouts[i].codec_id == codec_id)
464
+            break;
465
+    }
466
+    if (mov_codec_ch_layouts[i].codec_id != CODEC_ID_NONE)
467
+        layouts = mov_codec_ch_layouts[i].layouts;
468
+
469
+    if (layouts) {
470
+        int channels;
471
+        const struct MovChannelLayoutMap *layout_map;
472
+
473
+        /* get the layout map based on the channel count */
474
+        channels = av_get_channel_layout_nb_channels(channel_layout);
475
+        if (channels > 9)
476
+            channels = 0;
477
+        layout_map = mov_ch_layout_map[channels];
478
+
479
+        /* find the layout tag for the specified channel layout */
480
+        for (i = 0; layouts[i] != 0; i++) {
481
+            if (layouts[i] & 0xFFFF != channels)
482
+                continue;
483
+            for (j = 0; layout_map[j].tag != 0; j++) {
484
+                if (layout_map[j].tag    == layouts[i] &&
485
+                    layout_map[j].layout == channel_layout)
486
+                    break;
487
+            }
488
+            if (layout_map[j].tag)
489
+                break;
490
+        }
491
+        tag = layouts[i];
492
+    }
493
+
494
+    /* if no tag was found, use channel bitmap as a backup if possible */
495
+    if (tag == 0 && channel_layout > 0 && channel_layout < 0x40000) {
496
+        tag     = MOV_CH_LAYOUT_USE_BITMAP;
497
+        *bitmap = (uint32_t)channel_layout;
498
+    } else
499
+        *bitmap = 0;
500
+
501
+    /* TODO: set channel descriptions as a secondary backup */
502
+
503
+    return tag;
504
+}
0 505
new file mode 100644
... ...
@@ -0,0 +1,55 @@
0
+/*
1
+ * Copyright (c) 2011 Justin Ruggles
2
+ *
3
+ * This file is part of Libav.
4
+ *
5
+ * Libav is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * Libav is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with Libav; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+/**
21
+ * mov 'chan' tag reading/writing.
22
+ * @author Justin Ruggles
23
+ */
24
+
25
+#ifndef AVFORMAT_MOV_CHAN_H
26
+#define AVFORMAT_MOV_CHAN_H
27
+
28
+#include <stdint.h>
29
+
30
+#include "libavcodec/avcodec.h"
31
+
32
+/**
33
+ * Get the channel layout for the specified channel layout tag.
34
+ *
35
+ * @param[in]  tag     channel layout tag
36
+ * @param[out] bitmap  channel bitmap (only used if needed)
37
+ * @return             channel layout
38
+ */
39
+uint64_t ff_mov_get_channel_layout(uint32_t tag, uint32_t bitmap);
40
+
41
+/**
42
+ * Get the channel layout tag for the specified codec id and channel layout.
43
+ * If the layout tag was not found, use a channel bitmap if possible.
44
+ *
45
+ * @param[in]  codec_id        codec id
46
+ * @param[in]  channel_layout  channel layout
47
+ * @param[out] bitmap          channel bitmap
48
+ * @return                     channel layout tag
49
+ */
50
+uint32_t ff_mov_get_channel_layout_tag(enum CodecID codec_id,
51
+                                       uint64_t channel_layout,
52
+                                       uint32_t *bitmap);
53
+
54
+#endif /* AVFORMAT_MOV_CHAN_H */
... ...
@@ -37,6 +37,7 @@
37 37
 #include "libavutil/opt.h"
38 38
 #include "libavutil/dict.h"
39 39
 #include "rtpenc.h"
40
+#include "mov_chan.h"
40 41
 
41 42
 #undef NDEBUG
42 43
 #include <assert.h>
... ...
@@ -354,6 +355,31 @@ static int mov_write_ms_tag(AVIOContext *pb, MOVTrack *track)
354 354
     return updateSize(pb, pos);
355 355
 }
356 356
 
357
+static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track)
358
+{
359
+    uint32_t layout_tag, bitmap;
360
+    int64_t pos = avio_tell(pb);
361
+
362
+    layout_tag = ff_mov_get_channel_layout_tag(track->enc->codec_id,
363
+                                               track->enc->channel_layout,
364
+                                               &bitmap);
365
+    if (!layout_tag) {
366
+        av_log(track->enc, AV_LOG_WARNING, "not writing 'chan' tag due to "
367
+               "lack of channel information\n");
368
+        return 0;
369
+    }
370
+
371
+    avio_wb32(pb, 0);           // Size
372
+    ffio_wfourcc(pb, "chan");   // Type
373
+    avio_w8(pb, 0);             // Version
374
+    avio_wb24(pb, 0);           // Flags
375
+    avio_wb32(pb, layout_tag);  // mChannelLayoutTag
376
+    avio_wb32(pb, bitmap);      // mChannelBitmap
377
+    avio_wb32(pb, 0);           // mNumberChannelDescriptions
378
+
379
+    return updateSize(pb, pos);
380
+}
381
+
357 382
 static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
358 383
 {
359 384
     int64_t pos = avio_tell(pb);
... ...
@@ -376,6 +402,7 @@ static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
376 376
     } else if (track->enc->codec_id == CODEC_ID_AMR_NB) {
377 377
         mov_write_amr_tag(pb, track);
378 378
     } else if (track->enc->codec_id == CODEC_ID_AC3) {
379
+        mov_write_chan_tag(pb, track);
379 380
         mov_write_ac3_tag(pb, track);
380 381
     } else if (track->enc->codec_id == CODEC_ID_ALAC) {
381 382
         mov_write_extradata_tag(pb, track);
... ...
@@ -434,15 +461,9 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
434 434
     uint32_t tag = track->tag;
435 435
 
436 436
     if (track->mode == MODE_MOV) {
437
-        if (track->timescale > UINT16_MAX) {
438
-            if (mov_get_lpcm_flags(track->enc->codec_id))
439
-                tag = AV_RL32("lpcm");
440
-            version = 2;
441
-        } else if (track->audio_vbr || mov_pcm_le_gt16(track->enc->codec_id) ||
442
-                   track->enc->codec_id == CODEC_ID_ADPCM_MS ||
443
-                   track->enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
444
-            version = 1;
445
-        }
437
+        if (mov_get_lpcm_flags(track->enc->codec_id))
438
+            tag = AV_RL32("lpcm");
439
+        version = 2;
446 440
     }
447 441
 
448 442
     avio_wb32(pb, 0); /* size */
... ...
@@ -469,34 +490,18 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
469 469
         avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id));
470 470
         avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id));
471 471
         avio_wb32(pb, track->sampleSize);
472
-        avio_wb32(pb, track->enc->frame_size);
472
+        avio_wb32(pb, track->audio_vbr ? track->enc->frame_size : 1);
473 473
     } else {
474
-        if (track->mode == MODE_MOV) {
475
-            avio_wb16(pb, track->enc->channels);
476
-            if (track->enc->codec_id == CODEC_ID_PCM_U8 ||
477
-                track->enc->codec_id == CODEC_ID_PCM_S8)
478
-                avio_wb16(pb, 8); /* bits per sample */
479
-            else
480
-                avio_wb16(pb, 16);
481
-            avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
482
-        } else { /* reserved for mp4/3gp */
483
-            avio_wb16(pb, 2);
484
-            avio_wb16(pb, 16);
485
-            avio_wb16(pb, 0);
486
-        }
474
+        /* reserved for mp4/3gp */
475
+        avio_wb16(pb, 2);
476
+        avio_wb16(pb, 16);
477
+        avio_wb16(pb, 0);
487 478
 
488 479
         avio_wb16(pb, 0); /* packet size (= 0) */
489 480
         avio_wb16(pb, track->timescale); /* Time scale */
490 481
         avio_wb16(pb, 0); /* Reserved */
491 482
     }
492 483
 
493
-    if(version == 1) { /* SoundDescription V1 extended info */
494
-        avio_wb32(pb, track->enc->frame_size); /* Samples per packet */
495
-        avio_wb32(pb, track->sampleSize / track->enc->channels); /* Bytes per packet */
496
-        avio_wb32(pb, track->sampleSize); /* Bytes per frame */
497
-        avio_wb32(pb, 2); /* Bytes per sample */
498
-    }
499
-
500 484
     if(track->mode == MODE_MOV &&
501 485
        (track->enc->codec_id == CODEC_ID_AAC ||
502 486
         track->enc->codec_id == CODEC_ID_AC3 ||
... ...
@@ -2226,9 +2231,6 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
2226 2226
             av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n");
2227 2227
             return -1;
2228 2228
         }
2229
-    } else if (enc->codec_id == CODEC_ID_ADPCM_MS ||
2230
-               enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
2231
-        samplesInChunk = enc->frame_size;
2232 2229
     } else if (trk->sampleSize)
2233 2230
         samplesInChunk = size/trk->sampleSize;
2234 2231
     else
... ...
@@ -2458,21 +2460,21 @@ static int mov_write_header(AVFormatContext *s)
2458 2458
                        "or choose different container.\n");
2459 2459
         }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
2460 2460
             track->timescale = st->codec->sample_rate;
2461
-            if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
2462
-                av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i);
2463
-                goto error;
2464
-            }else if(st->codec->codec_id == CODEC_ID_ADPCM_MS ||
2465
-                     st->codec->codec_id == CODEC_ID_ADPCM_IMA_WAV){
2461
+            /* set sampleSize for PCM and ADPCM */
2462
+            if (av_get_bits_per_sample(st->codec->codec_id)) {
2466 2463
                 if (!st->codec->block_align) {
2467
-                    av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
2464
+                    av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i);
2468 2465
                     goto error;
2469 2466
                 }
2470 2467
                 track->sampleSize = st->codec->block_align;
2471
-            }else if(st->codec->frame_size > 1){ /* assume compressed audio */
2468
+            }
2469
+            /* set audio_vbr for compressed audio */
2470
+            if (av_get_bits_per_sample(st->codec->codec_id) < 8) {
2471
+                if (!st->codec->frame_size) {
2472
+                    av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i);
2473
+                    goto error;
2474
+                }
2472 2475
                 track->audio_vbr = 1;
2473
-            }else{
2474
-                st->codec->frame_size = 1;
2475
-                track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
2476 2476
             }
2477 2477
             if (track->mode != MODE_MOV) {
2478 2478
                 if (track->timescale > UINT16_MAX) {
... ...
@@ -58,6 +58,10 @@
58 58
 #define AV_CH_TOP_BACK_RIGHT         0x00020000
59 59
 #define AV_CH_STEREO_LEFT            0x20000000  ///< Stereo downmix.
60 60
 #define AV_CH_STEREO_RIGHT           0x40000000  ///< See AV_CH_STEREO_LEFT.
61
+#define AV_CH_WIDE_LEFT              0x0000000080000000ULL
62
+#define AV_CH_WIDE_RIGHT             0x0000000100000000ULL
63
+#define AV_CH_SURROUND_DIRECT_LEFT   0x0000000200000000ULL
64
+#define AV_CH_SURROUND_DIRECT_RIGHT  0x0000000400000000ULL
61 65
 
62 66
 /** Channel mask value used for AVCodecContext.request_channel_layout
63 67
     to indicate that the user requests the channel order of the decoder output
... ...
@@ -71,18 +75,29 @@
71 71
  * */
72 72
 #define AV_CH_LAYOUT_MONO              (AV_CH_FRONT_CENTER)
73 73
 #define AV_CH_LAYOUT_STEREO            (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
74
+#define AV_CH_LAYOUT_2POINT1           (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
74 75
 #define AV_CH_LAYOUT_2_1               (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
75 76
 #define AV_CH_LAYOUT_SURROUND          (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
77
+#define AV_CH_LAYOUT_3POINT1           (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
76 78
 #define AV_CH_LAYOUT_4POINT0           (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
79
+#define AV_CH_LAYOUT_4POINT1           (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
77 80
 #define AV_CH_LAYOUT_2_2               (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
78 81
 #define AV_CH_LAYOUT_QUAD              (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
79 82
 #define AV_CH_LAYOUT_5POINT0           (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
80 83
 #define AV_CH_LAYOUT_5POINT1           (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
81 84
 #define AV_CH_LAYOUT_5POINT0_BACK      (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
82 85
 #define AV_CH_LAYOUT_5POINT1_BACK      (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
86
+#define AV_CH_LAYOUT_6POINT0           (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
87
+#define AV_CH_LAYOUT_6POINT0_FRONT     (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
88
+#define AV_CH_LAYOUT_HEXAGONAL         (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
89
+#define AV_CH_LAYOUT_6POINT1           (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
90
+#define AV_CH_LAYOUT_6POINT1_BACK      (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
91
+#define AV_CH_LAYOUT_6POINT1_FRONT     (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
83 92
 #define AV_CH_LAYOUT_7POINT0           (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
93
+#define AV_CH_LAYOUT_7POINT0_FRONT     (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
84 94
 #define AV_CH_LAYOUT_7POINT1           (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
85
-#define AV_CH_LAYOUT_7POINT1_WIDE      (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
95
+#define AV_CH_LAYOUT_7POINT1_WIDE      (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
96
+#define AV_CH_LAYOUT_OCTAGONAL         (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
86 97
 #define AV_CH_LAYOUT_STEREO_DOWNMIX    (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
87 98
 
88 99
 /**
... ...
@@ -153,7 +153,7 @@
153 153
  */
154 154
 
155 155
 #define LIBAVUTIL_VERSION_MAJOR 51
156
-#define LIBAVUTIL_VERSION_MINOR 31
156
+#define LIBAVUTIL_VERSION_MINOR 32
157 157
 #define LIBAVUTIL_VERSION_MICRO  0
158 158
 
159 159
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
... ...
@@ -1,4 +1,4 @@
1
-aeec610f33d8eec7031c5c6a9aab4cc0 *./tests/data/acodec/pcm_s16be.mov
2
-1059029 ./tests/data/acodec/pcm_s16be.mov
1
+d07e475322765c20b1fcdb822ad5dc04 *./tests/data/acodec/pcm_s16be.mov
2
+1059065 ./tests/data/acodec/pcm_s16be.mov
3 3
 64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s16be.acodec.out.wav
4 4
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  1058400/  1058400
... ...
@@ -1,4 +1,4 @@
1
-9ea74aa6d09fcfe9a1e232efecfb07fe *./tests/data/acodec/pcm_s24be.mov
2
-1588229 ./tests/data/acodec/pcm_s24be.mov
1
+f66d9543a4e04346818e802c4f2d7a30 *./tests/data/acodec/pcm_s24be.mov
2
+1588265 ./tests/data/acodec/pcm_s24be.mov
3 3
 64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s24be.acodec.out.wav
4 4
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  1058400/  1058400
... ...
@@ -1,4 +1,4 @@
1
-25535c11babbc971b6a958e92feaee37 *./tests/data/acodec/pcm_s32be.mov
2
-2117429 ./tests/data/acodec/pcm_s32be.mov
1
+09c919947211de14b3ad0e7603e5b44e *./tests/data/acodec/pcm_s32be.mov
2
+2117465 ./tests/data/acodec/pcm_s32be.mov
3 3
 64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s32be.acodec.out.wav
4 4
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  1058400/  1058400
... ...
@@ -1,4 +1,4 @@
1
-d63813e9255a74324ea4559d6a8a1f7c *./tests/data/acodec/pcm_s8.mov
2
-529829 ./tests/data/acodec/pcm_s8.mov
1
+52d8c65c4987227979785d5ac2030175 *./tests/data/acodec/pcm_s8.mov
2
+529865 ./tests/data/acodec/pcm_s8.mov
3 3
 651d4eb8d98dfcdda96ae6c43d8f156b *./tests/data/pcm_s8.acodec.out.wav
4 4
 stddev:  147.89 PSNR: 52.93 MAXDIFF:  255 bytes:  1058400/  1058400
... ...
@@ -1,3 +1,3 @@
1
-93ed3b20190daa51aeb19f62f939d04a *./tests/data/lavf/lavf.mov
2
-357821 ./tests/data/lavf/lavf.mov
1
+3340b7ffe1b1d98a50622bd53f786d41 *./tests/data/lavf/lavf.mov
2
+357857 ./tests/data/lavf/lavf.mov
3 3
 ./tests/data/lavf/lavf.mov CRC=0x2f6a9b26