Browse code

Merge libavcore into libavutil

It is pretty hopeless that other considerable projects will adopt
libavutil alone in other projects. Projects that need small footprint
are better off with more specialized libraries such as gnulib or rather
just copy the necessary parts that they need. With this in mind, nobody
is helped by having libavutil and libavcore split. In order to ease
maintenance inside and around FFmpeg and to reduce confusion where to
put common code, avcore's functionality is merged (back) to avutil.

Signed-off-by: Reinhard Tartler <siretart@tauware.de>

Reinhard Tartler authored on 2011/02/07 22:37:08
Showing 128 changed files
... ...
@@ -30,7 +30,6 @@ FFLIBS-$(CONFIG_AVFORMAT) += avformat
30 30
 FFLIBS-$(CONFIG_AVCODEC)  += avcodec
31 31
 FFLIBS-$(CONFIG_POSTPROC) += postproc
32 32
 FFLIBS-$(CONFIG_SWSCALE)  += swscale
33
-FFLIBS-$(CONFIG_AVCORE)   += avcore
34 33
 
35 34
 FFLIBS := avutil
36 35
 
... ...
@@ -38,7 +38,6 @@
38 38
 #include "libavutil/pixdesc.h"
39 39
 #include "libavutil/eval.h"
40 40
 #include "libavcodec/opt.h"
41
-#include "libavcore/avcore.h"
42 41
 #include "cmdutils.h"
43 42
 #include "version.h"
44 43
 #if CONFIG_NETWORK
... ...
@@ -413,7 +412,6 @@ static int warned_cfg = 0;
413 413
 static void print_all_libs_info(FILE* outstream, int flags)
414 414
 {
415 415
     PRINT_LIB_INFO(outstream, avutil,   AVUTIL,   flags);
416
-    PRINT_LIB_INFO(outstream, avcore,   AVCORE,   flags);
417 416
     PRINT_LIB_INFO(outstream, avcodec,  AVCODEC,  flags);
418 417
     PRINT_LIB_INFO(outstream, avformat, AVFORMAT, flags);
419 418
     PRINT_LIB_INFO(outstream, avdevice, AVDEVICE, flags);
... ...
@@ -31,7 +31,7 @@ $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
31 31
 $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
32 32
 endif
33 33
 
34
-ALLFFLIBS = avcodec avcore avdevice avfilter avformat avutil postproc swscale
34
+ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
35 35
 
36 36
 IFLAGS   := -I$(BUILD_ROOT_REL) -I$(SRC_PATH)
37 37
 CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
... ...
@@ -86,7 +86,6 @@ Configuration options:
86 86
   --disable-ffserver       disable ffserver build
87 87
   --disable-avdevice       disable libavdevice build
88 88
   --disable-avcodec        disable libavcodec build
89
-  --disable-avcore         disable libavcore build
90 89
   --disable-avformat       disable libavformat build
91 90
   --disable-swscale        disable libswscale build
92 91
   --enable-postproc        enable GPLed postprocessing support [no]
... ...
@@ -871,7 +870,6 @@ CONFIG_LIST="
871 871
     $COMPONENT_LIST
872 872
     aandct
873 873
     avcodec
874
-    avcore
875 874
     avdevice
876 875
     avfilter
877 876
     avformat
... ...
@@ -1589,7 +1587,6 @@ host_os=$target_os_default
1589 1589
 
1590 1590
 # configurable options
1591 1591
 enable avcodec
1592
-enable avcore
1593 1592
 enable avdevice
1594 1593
 enable avfilter
1595 1594
 enable avformat
... ...
@@ -2933,7 +2930,7 @@ enabled extra_warnings && check_cflags -Winline
2933 2933
 # add some linker flags
2934 2934
 check_ldflags -Wl,--warn-common
2935 2935
 check_ldflags -Wl,--as-needed
2936
-check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavcore -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
2936
+check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
2937 2937
 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
2938 2938
 
2939 2939
 echo "X{};" > $TMPV
... ...
@@ -3143,7 +3140,6 @@ if enabled source_path_used; then
3143 3143
         doc
3144 3144
         libavcodec
3145 3145
         libavcodec/$arch
3146
-        libavcore
3147 3146
         libavdevice
3148 3147
         libavfilter
3149 3148
         libavfilter/$arch
... ...
@@ -3163,7 +3159,6 @@ if enabled source_path_used; then
3163 3163
         doc/texi2pod.pl
3164 3164
         libavcodec/Makefile
3165 3165
         libavcodec/${arch}/Makefile
3166
-        libavcore/Makefile
3167 3166
         libavdevice/Makefile
3168 3167
         libavfilter/Makefile
3169 3168
         libavfilter/${arch}/Makefile
... ...
@@ -3266,7 +3261,6 @@ get_version(){
3266 3266
 get_version LIBSWSCALE  libswscale/swscale.h
3267 3267
 get_version LIBPOSTPROC libpostproc/postprocess.h
3268 3268
 get_version LIBAVCODEC  libavcodec/avcodec.h
3269
-get_version LIBAVCORE   libavcore/avcore.h
3270 3269
 get_version LIBAVDEVICE libavdevice/avdevice.h
3271 3270
 get_version LIBAVFORMAT libavformat/version.h
3272 3271
 get_version LIBAVUTIL   libavutil/avutil.h
... ...
@@ -3394,10 +3388,9 @@ EOF
3394 3394
 }
3395 3395
 
3396 3396
 pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
3397
-pkgconfig_generate libavcore "FFmpeg multimedia shared core utilities library" "$LIBAVCORE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
3398
-pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
3397
+pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs"
3399 3398
 pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3400 3399
 pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3401
-pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
3400
+pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
3402 3401
 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
3403 3402
 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
... ...
@@ -2,7 +2,6 @@ Never assume the API of libav* to be stable unless at least 1 week has passed si
2 2
 the last major version increase.
3 3
 The last version increases were:
4 4
 libavcodec:  ?
5
-libavcore:   2010-07-21
6 5
 libavdevice: ?
7 6
 libavfilter: 2009-10-18
8 7
 libavformat: ?
... ...
@@ -13,6 +12,9 @@ libavutil:   2009-03-08
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2011-02-15 - lavu 52.38.0 - merge libavcore
17
+  libavcore is merged back completely into libavutil
18
+
16 19
 2011-02-10 - 55bad0c - lavc 52.113.0 - vbv_delay
17 20
   Add vbv_delay field to AVCodecContext
18 21
 
... ...
@@ -986,7 +986,7 @@ you should only need to add the directory where the LIB files are installed
986 986
 (i.e. @file{c:\msys\usr\local\bin}). This is not a typo, the LIB files are
987 987
 installed in the @file{bin} directory. And instead of adding the static
988 988
 libraries (@file{libxxx.a} files) you should add the MSVC import libraries
989
-(@file{avcodec.lib}, @file{avformat.lib}, @file{avcore.lib}, and
989
+(@file{avcodec.lib}, @file{avformat.lib}, and
990 990
 @file{avutil.lib}). Note that you should not use the GCC import
991 991
 libraries (@file{libxxx.dll.a} files), as these will give you undefined
992 992
 reference errors. There should be no need for @file{libmingwex.a},
... ...
@@ -36,9 +36,9 @@
36 36
 #include "libswscale/swscale.h"
37 37
 #include "libavcodec/opt.h"
38 38
 #include "libavcodec/audioconvert.h"
39
-#include "libavcore/audioconvert.h"
40
-#include "libavcore/parseutils.h"
41
-#include "libavcore/samplefmt.h"
39
+#include "libavutil/audioconvert.h"
40
+#include "libavutil/parseutils.h"
41
+#include "libavutil/samplefmt.h"
42 42
 #include "libavutil/colorspace.h"
43 43
 #include "libavutil/fifo.h"
44 44
 #include "libavutil/intreadwrite.h"
... ...
@@ -28,9 +28,9 @@
28 28
 #include "libavutil/avstring.h"
29 29
 #include "libavutil/colorspace.h"
30 30
 #include "libavutil/pixdesc.h"
31
-#include "libavcore/imgutils.h"
32
-#include "libavcore/parseutils.h"
33
-#include "libavcore/samplefmt.h"
31
+#include "libavutil/imgutils.h"
32
+#include "libavutil/parseutils.h"
33
+#include "libavutil/samplefmt.h"
34 34
 #include "libavformat/avformat.h"
35 35
 #include "libavdevice/avdevice.h"
36 36
 #include "libswscale/swscale.h"
... ...
@@ -36,7 +36,7 @@
36 36
 #include "libavutil/avstring.h"
37 37
 #include "libavutil/lfg.h"
38 38
 #include "libavutil/random_seed.h"
39
-#include "libavcore/parseutils.h"
39
+#include "libavutil/parseutils.h"
40 40
 #include "libavcodec/opt.h"
41 41
 #include <stdarg.h>
42 42
 #include <unistd.h>
... ...
@@ -1,7 +1,7 @@
1 1
 include $(SUBDIR)../config.mak
2 2
 
3 3
 NAME = avcodec
4
-FFLIBS = avcore avutil
4
+FFLIBS = avutil
5 5
 
6 6
 HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
7 7
 
... ...
@@ -30,7 +30,7 @@
30 30
 #ifndef AVCODEC_AACDECTAB_H
31 31
 #define AVCODEC_AACDECTAB_H
32 32
 
33
-#include "libavcore/audioconvert.h"
33
+#include "libavutil/audioconvert.h"
34 34
 #include "aac.h"
35 35
 
36 36
 #include <stdint.h>
... ...
@@ -24,7 +24,7 @@
24 24
 #include "ac3_parser.h"
25 25
 #include "aac_ac3_parser.h"
26 26
 #include "get_bits.h"
27
-#include "libavcore/audioconvert.h"
27
+#include "libavutil/audioconvert.h"
28 28
 
29 29
 
30 30
 #define AC3_HEADER_SIZE 7
... ...
@@ -28,7 +28,7 @@
28 28
 
29 29
 //#define DEBUG
30 30
 
31
-#include "libavcore/audioconvert.h"
31
+#include "libavutil/audioconvert.h"
32 32
 #include "libavutil/crc.h"
33 33
 #include "avcodec.h"
34 34
 #include "put_bits.h"
... ...
@@ -24,7 +24,7 @@
24 24
  * tables taken directly from the AC-3 spec.
25 25
  */
26 26
 
27
-#include "libavcore/audioconvert.h"
27
+#include "libavutil/audioconvert.h"
28 28
 #include "avcodec.h"
29 29
 #include "ac3tab.h"
30 30
 
... ...
@@ -36,7 +36,7 @@
36 36
 #include "bytestream.h"
37 37
 #include "bgmc.h"
38 38
 #include "dsputil.h"
39
-#include "libavcore/samplefmt.h"
39
+#include "libavutil/samplefmt.h"
40 40
 #include "libavutil/crc.h"
41 41
 
42 42
 #include <stdint.h>
... ...
@@ -25,7 +25,7 @@
25 25
 #include "dsputil.h"
26 26
 #include "get_bits.h"
27 27
 #include "bytestream.h"
28
-#include "libavcore/audioconvert.h"
28
+#include "libavutil/audioconvert.h"
29 29
 
30 30
 /**
31 31
  * @file
... ...
@@ -27,7 +27,7 @@
27 27
 
28 28
 #include "libavutil/avstring.h"
29 29
 #include "libavutil/libm.h"
30
-#include "libavcore/samplefmt.h"
30
+#include "libavutil/samplefmt.h"
31 31
 #include "avcodec.h"
32 32
 #include "audioconvert.h"
33 33
 
... ...
@@ -31,7 +31,7 @@
31 31
 
32 32
 #include "libavutil/cpu.h"
33 33
 #include "avcodec.h"
34
-#include "libavcore/audioconvert.h"
34
+#include "libavutil/audioconvert.h"
35 35
 
36 36
 #if FF_API_OLD_SAMPLE_FMT
37 37
 /**
... ...
@@ -27,7 +27,7 @@
27 27
  */
28 28
 
29 29
 #include <errno.h>
30
-#include "libavcore/samplefmt.h"
30
+#include "libavutil/samplefmt.h"
31 31
 #include "libavutil/avutil.h"
32 32
 #include "libavutil/cpu.h"
33 33
 
... ...
@@ -437,7 +437,7 @@ enum CodecID {
437 437
 #endif
438 438
 
439 439
 #if FF_API_OLD_AUDIOCONVERT
440
-#include "libavcore/audioconvert.h"
440
+#include "libavutil/audioconvert.h"
441 441
 
442 442
 /* Audio channel masks */
443 443
 #define CH_FRONT_LEFT            AV_CH_FRONT_LEFT
... ...
@@ -20,7 +20,7 @@
20 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 21
  */
22 22
 
23
-#include "libavcore/imgutils.h"
23
+#include "libavutil/imgutils.h"
24 24
 #include "avcodec.h"
25 25
 #include "dsputil.h"
26 26
 #include "binkdata.h"
... ...
@@ -20,7 +20,7 @@
20 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 21
  */
22 22
 
23
-#include "libavcore/internal.h"
23
+#include "libavutil/imgutils.h"
24 24
 #include "avcodec.h"
25 25
 #include "bytestream.h"
26 26
 #include "bmp.h"
... ...
@@ -53,7 +53,7 @@
53 53
 #include "dsputil.h"
54 54
 #include "bytestream.h"
55 55
 #include "fft.h"
56
-#include "libavcore/audioconvert.h"
56
+#include "libavutil/audioconvert.h"
57 57
 
58 58
 #include "cookdata.h"
59 59
 
... ...
@@ -29,7 +29,7 @@
29 29
 #include "libavutil/common.h"
30 30
 #include "libavutil/intmath.h"
31 31
 #include "libavutil/intreadwrite.h"
32
-#include "libavcore/audioconvert.h"
32
+#include "libavutil/audioconvert.h"
33 33
 #include "avcodec.h"
34 34
 #include "dsputil.h"
35 35
 #include "fft.h"
... ...
@@ -25,7 +25,7 @@
25 25
  * @author Marco Gerards <marco@gnu.org>
26 26
  */
27 27
 
28
-#include "libavcore/imgutils.h"
28
+#include "libavutil/imgutils.h"
29 29
 #include "dirac.h"
30 30
 #include "avcodec.h"
31 31
 #include "golomb.h"
... ...
@@ -22,7 +22,7 @@
22 22
 //#define TRACE
23 23
 //#define DEBUG
24 24
 
25
-#include "libavcore/imgutils.h"
25
+#include "libavutil/imgutils.h"
26 26
 #include "avcodec.h"
27 27
 #include "get_bits.h"
28 28
 #include "dnxhddata.h"
... ...
@@ -20,7 +20,7 @@
20 20
  */
21 21
 
22 22
 #include "libavutil/intreadwrite.h"
23
-#include "libavcore/imgutils.h"
23
+#include "libavutil/imgutils.h"
24 24
 #include "bytestream.h"
25 25
 #include "avcodec.h"
26 26
 
... ...
@@ -27,7 +27,7 @@
27 27
  * DSP utils
28 28
  */
29 29
 
30
-#include "libavcore/imgutils.h"
30
+#include "libavutil/imgutils.h"
31 31
 #include "avcodec.h"
32 32
 #include "dsputil.h"
33 33
 #include "simple_idct.h"
... ...
@@ -29,7 +29,7 @@
29 29
  */
30 30
 
31 31
 #include "libavutil/intreadwrite.h"
32
-#include "libavcore/imgutils.h"
32
+#include "libavutil/imgutils.h"
33 33
 #include "avcodec.h"
34 34
 
35 35
 typedef struct CmvContext {
... ...
@@ -34,7 +34,7 @@
34 34
 #include "aandcttab.h"
35 35
 #include "mpeg12.h"
36 36
 #include "mpeg12data.h"
37
-#include "libavcore/imgutils.h"
37
+#include "libavutil/imgutils.h"
38 38
 
39 39
 #define EA_PREAMBLE_SIZE    8
40 40
 #define MADk_TAG MKTAG('M', 'A', 'D', 'k')    /* MAD i-frame */
... ...
@@ -32,7 +32,7 @@
32 32
 #define ALT_BITSTREAM_READER_LE
33 33
 #include "get_bits.h"
34 34
 #include "libavutil/lzo.h"
35
-#include "libavcore/imgutils.h"
35
+#include "libavutil/imgutils.h"
36 36
 
37 37
 #define EA_PREAMBLE_SIZE    8
38 38
 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T')
... ...
@@ -20,7 +20,7 @@
20 20
 #include "mpegvideo.h"
21 21
 #include "h263.h"
22 22
 #include "flv.h"
23
-#include "libavcore/imgutils.h"
23
+#include "libavutil/imgutils.h"
24 24
 
25 25
 void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){
26 26
     int is11 = get_bits1(gb);
... ...
@@ -22,7 +22,7 @@
22 22
 
23 23
 //#define DEBUG
24 24
 
25
-#include "libavcore/imgutils.h"
25
+#include "libavutil/imgutils.h"
26 26
 #include "avcodec.h"
27 27
 #include "bytestream.h"
28 28
 #include "lzw.h"
... ...
@@ -25,7 +25,7 @@
25 25
  * @author Michael Niedermayer <michaelni@gmx.at>
26 26
  */
27 27
 
28
-#include "libavcore/imgutils.h"
28
+#include "libavutil/imgutils.h"
29 29
 #include "internal.h"
30 30
 #include "dsputil.h"
31 31
 #include "avcodec.h"
... ...
@@ -25,7 +25,7 @@
25 25
  * @author Michael Niedermayer <michaelni@gmx.at>
26 26
  */
27 27
 
28
-#include "libavcore/imgutils.h"
28
+#include "libavutil/imgutils.h"
29 29
 #include "internal.h"
30 30
 #include "dsputil.h"
31 31
 #include "avcodec.h"
... ...
@@ -25,7 +25,7 @@
25 25
  * IFF PBM/ILBM bitmap decoder
26 26
  */
27 27
 
28
-#include "libavcore/imgutils.h"
28
+#include "libavutil/imgutils.h"
29 29
 #include "bytestream.h"
30 30
 #include "avcodec.h"
31 31
 #include "get_bits.h"
... ...
@@ -40,7 +40,7 @@
40 40
 #include "get_bits.h"
41 41
 #include "dsputil.h"
42 42
 #include "fft.h"
43
-#include "libavcore/audioconvert.h"
43
+#include "libavutil/audioconvert.h"
44 44
 
45 45
 #include "imcdata.h"
46 46
 
... ...
@@ -36,8 +36,7 @@
36 36
 #include "imgconvert.h"
37 37
 #include "libavutil/colorspace.h"
38 38
 #include "libavutil/pixdesc.h"
39
-#include "libavcore/imgutils.h"
40
-#include "libavcore/internal.h"
39
+#include "libavutil/imgutils.h"
41 40
 
42 41
 #if HAVE_MMX && HAVE_YASM
43 42
 #include "x86/dsputil_mmx.h"
... ...
@@ -23,7 +23,7 @@
23 23
 #include <stdlib.h>
24 24
 #include <string.h>
25 25
 
26
-#include "libavcore/imgutils.h"
26
+#include "libavutil/imgutils.h"
27 27
 #include "avcodec.h"
28 28
 #include "dsputil.h"
29 29
 #include "bytestream.h"
... ...
@@ -25,7 +25,7 @@
25 25
  */
26 26
 
27 27
 #include "libavutil/intreadwrite.h"
28
-#include "libavcore/imgutils.h"
28
+#include "libavutil/imgutils.h"
29 29
 #include "avcodec.h"
30 30
 
31 31
 typedef struct {
... ...
@@ -28,7 +28,7 @@
28 28
 * (http://dirac.sourceforge.net/specification.html).
29 29
 */
30 30
 
31
-#include "libavcore/imgutils.h"
31
+#include "libavutil/imgutils.h"
32 32
 #include "libdirac.h"
33 33
 
34 34
 #undef NDEBUG
... ...
@@ -24,7 +24,7 @@
24 24
 * JPEG 2000 decoder using libopenjpeg
25 25
 */
26 26
 
27
-#include "libavcore/imgutils.h"
27
+#include "libavutil/imgutils.h"
28 28
 #include "avcodec.h"
29 29
 #include "libavutil/intreadwrite.h"
30 30
 #define  OPJ_STATIC
... ...
@@ -27,7 +27,7 @@
27 27
 * (http://dirac.sourceforge.net/specification.html).
28 28
 */
29 29
 
30
-#include "libavcore/imgutils.h"
30
+#include "libavutil/imgutils.h"
31 31
 #include "avcodec.h"
32 32
 #include "libdirac_libschro.h"
33 33
 #include "libschroedinger.h"
... ...
@@ -27,7 +27,7 @@
27 27
 #include <vpx/vpx_decoder.h>
28 28
 #include <vpx/vp8dx.h>
29 29
 
30
-#include "libavcore/imgutils.h"
30
+#include "libavutil/imgutils.h"
31 31
 #include "avcodec.h"
32 32
 
33 33
 typedef struct VP8DecoderContext {
... ...
@@ -33,7 +33,7 @@
33 33
 //#define DEBUG
34 34
 #include <assert.h>
35 35
 
36
-#include "libavcore/imgutils.h"
36
+#include "libavutil/imgutils.h"
37 37
 #include "avcodec.h"
38 38
 #include "dsputil.h"
39 39
 #include "mjpeg.h"
... ...
@@ -30,7 +30,7 @@
30 30
 #include "get_bits.h"
31 31
 #include "dsputil.h"
32 32
 #include "mpegaudio.h"
33
-#include "libavcore/audioconvert.h"
33
+#include "libavutil/audioconvert.h"
34 34
 
35 35
 #include "mpc.h"
36 36
 #include "mpc7data.h"
... ...
@@ -30,7 +30,7 @@
30 30
 #include "get_bits.h"
31 31
 #include "dsputil.h"
32 32
 #include "mpegaudio.h"
33
-#include "libavcore/audioconvert.h"
33
+#include "libavutil/audioconvert.h"
34 34
 
35 35
 #include "mpc.h"
36 36
 #include "mpcdata.h"
... ...
@@ -28,7 +28,7 @@
28 28
  */
29 29
 
30 30
 #include "libavutil/intmath.h"
31
-#include "libavcore/imgutils.h"
31
+#include "libavutil/imgutils.h"
32 32
 #include "avcodec.h"
33 33
 #include "dsputil.h"
34 34
 #include "internal.h"
... ...
@@ -34,7 +34,7 @@
34 34
 #include "nellymoser.h"
35 35
 #include "libavutil/lfg.h"
36 36
 #include "libavutil/random_seed.h"
37
-#include "libavcore/audioconvert.h"
37
+#include "libavutil/audioconvert.h"
38 38
 #include "avcodec.h"
39 39
 #include "dsputil.h"
40 40
 #include "fft.h"
... ...
@@ -23,7 +23,7 @@
23 23
 
24 24
 #include "libavutil/bswap.h"
25 25
 #include "libavutil/lzo.h"
26
-#include "libavcore/imgutils.h"
26
+#include "libavutil/imgutils.h"
27 27
 #include "avcodec.h"
28 28
 #include "dsputil.h"
29 29
 #include "rtjpeg.h"
... ...
@@ -24,7 +24,7 @@
24 24
  * PCM codecs for encodings found in MPEG streams (DVD/Blu-ray)
25 25
  */
26 26
 
27
-#include "libavcore/audioconvert.h"
27
+#include "libavutil/audioconvert.h"
28 28
 #include "avcodec.h"
29 29
 #include "bytestream.h"
30 30
 
... ...
@@ -22,7 +22,7 @@
22 22
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 23
  */
24 24
 
25
-#include "libavcore/imgutils.h"
25
+#include "libavutil/imgutils.h"
26 26
 #include "avcodec.h"
27 27
 #include "bytestream.h"
28 28
 #include "get_bits.h"
... ...
@@ -28,7 +28,7 @@
28 28
 #include "dsputil.h"
29 29
 #include "bytestream.h"
30 30
 #include "libavutil/colorspace.h"
31
-#include "libavcore/imgutils.h"
31
+#include "libavutil/imgutils.h"
32 32
 
33 33
 //#define DEBUG_PACKET_CONTENTS
34 34
 
... ...
@@ -24,7 +24,7 @@
24 24
  * Pictor/PC Paint decoder
25 25
  */
26 26
 
27
-#include "libavcore/imgutils.h"
27
+#include "libavutil/imgutils.h"
28 28
 #include "avcodec.h"
29 29
 #include "bytestream.h"
30 30
 #include "cga_data.h"
... ...
@@ -18,7 +18,7 @@
18 18
  * License along with FFmpeg; if not, write to the Free Software
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21
-#include "libavcore/imgutils.h"
21
+#include "libavutil/imgutils.h"
22 22
 #include "avcodec.h"
23 23
 #include "bytestream.h"
24 24
 #include "png.h"
... ...
@@ -19,7 +19,7 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-#include "libavcore/imgutils.h"
22
+#include "libavutil/imgutils.h"
23 23
 #include "avcodec.h"
24 24
 #include "pnm.h"
25 25
 
... ...
@@ -20,7 +20,7 @@
20 20
  */
21 21
 
22 22
 #include "libavutil/intreadwrite.h"
23
-#include "libavcore/imgutils.h"
23
+#include "libavutil/imgutils.h"
24 24
 #include "avcodec.h"
25 25
 
26 26
 typedef struct PTXContext {
... ...
@@ -22,7 +22,7 @@
22 22
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 23
  */
24 24
 
25
-#include "libavcore/imgutils.h"
25
+#include "libavutil/imgutils.h"
26 26
 #include "avcodec.h"
27 27
 #include "bytestream.h"
28 28
 
... ...
@@ -28,8 +28,7 @@
28 28
 #include "imgconvert.h"
29 29
 #include "raw.h"
30 30
 #include "libavutil/intreadwrite.h"
31
-#include "libavcore/imgutils.h"
32
-#include "libavcore/internal.h"
31
+#include "libavutil/imgutils.h"
33 32
 
34 33
 typedef struct RawVideoContext {
35 34
     uint32_t palette[AVPALETTE_COUNT];
... ...
@@ -27,7 +27,7 @@
27 27
 #include "avcodec.h"
28 28
 #include "audioconvert.h"
29 29
 #include "libavutil/opt.h"
30
-#include "libavcore/samplefmt.h"
30
+#include "libavutil/samplefmt.h"
31 31
 
32 32
 struct AVResampleContext;
33 33
 
... ...
@@ -25,7 +25,7 @@
25 25
  * RV10/RV20 decoder
26 26
  */
27 27
 
28
-#include "libavcore/imgutils.h"
28
+#include "libavutil/imgutils.h"
29 29
 #include "avcodec.h"
30 30
 #include "dsputil.h"
31 31
 #include "mpegvideo.h"
... ...
@@ -24,7 +24,7 @@
24 24
  * RV40 decoder
25 25
  */
26 26
 
27
-#include "libavcore/imgutils.h"
27
+#include "libavutil/imgutils.h"
28 28
 
29 29
 #include "avcodec.h"
30 30
 #include "dsputil.h"
... ...
@@ -19,7 +19,7 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-#include "libavcore/imgutils.h"
22
+#include "libavutil/imgutils.h"
23 23
 #include "avcodec.h"
24 24
 #include "bytestream.h"
25 25
 #include "sgi.h"
... ...
@@ -32,7 +32,7 @@
32 32
 #include <stdlib.h>
33 33
 
34 34
 #include "avcodec.h"
35
-#include "libavcore/audioconvert.h"
35
+#include "libavutil/audioconvert.h"
36 36
 
37 37
 #define ALT_BITSTREAM_READER_LE
38 38
 #include "get_bits.h"
... ...
@@ -20,7 +20,7 @@
20 20
  */
21 21
 
22 22
 #include "libavutil/avstring.h"
23
-#include "libavcore/parseutils.h"
23
+#include "libavutil/parseutils.h"
24 24
 #include "avcodec.h"
25 25
 #include "ass.h"
26 26
 
... ...
@@ -20,7 +20,7 @@
20 20
  */
21 21
 
22 22
 #include "libavutil/intreadwrite.h"
23
-#include "libavcore/imgutils.h"
23
+#include "libavutil/imgutils.h"
24 24
 #include "avcodec.h"
25 25
 
26 26
 #define RT_OLD          0
... ...
@@ -20,7 +20,7 @@
20 20
  */
21 21
 
22 22
 #include "libavutil/intreadwrite.h"
23
-#include "libavcore/imgutils.h"
23
+#include "libavutil/imgutils.h"
24 24
 #include "avcodec.h"
25 25
 #include "targa.h"
26 26
 
... ...
@@ -33,7 +33,7 @@
33 33
 #include "faxcompr.h"
34 34
 #include "libavutil/common.h"
35 35
 #include "libavutil/intreadwrite.h"
36
-#include "libavcore/imgutils.h"
36
+#include "libavutil/imgutils.h"
37 37
 
38 38
 typedef struct TiffContext {
39 39
     AVCodecContext *avctx;
... ...
@@ -35,7 +35,7 @@
35 35
 
36 36
 #include "avcodec.h"
37 37
 #include "dsputil.h"
38
-#include "libavcore/imgutils.h"
38
+#include "libavutil/imgutils.h"
39 39
 
40 40
 #include "truemotion1data.h"
41 41
 
... ...
@@ -22,7 +22,7 @@
22 22
  */
23 23
 
24 24
 #include "libavutil/intreadwrite.h"
25
-#include "libavcore/imgutils.h"
25
+#include "libavutil/imgutils.h"
26 26
 #include "avcodec.h"
27 27
 #include "s3tc.h"
28 28
 
... ...
@@ -29,10 +29,9 @@
29 29
 #include "libavutil/integer.h"
30 30
 #include "libavutil/crc.h"
31 31
 #include "libavutil/pixdesc.h"
32
-#include "libavcore/audioconvert.h"
33
-#include "libavcore/imgutils.h"
34
-#include "libavcore/internal.h"
35
-#include "libavcore/samplefmt.h"
32
+#include "libavutil/audioconvert.h"
33
+#include "libavutil/imgutils.h"
34
+#include "libavutil/samplefmt.h"
36 35
 #include "avcodec.h"
37 36
 #include "dsputil.h"
38 37
 #include "libavutil/opt.h"
... ...
@@ -1169,7 +1168,7 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
1169 1169
 }
1170 1170
 
1171 1171
 #if LIBAVCODEC_VERSION_MAJOR < 53
1172
-#include "libavcore/parseutils.h"
1172
+#include "libavutil/parseutils.h"
1173 1173
 
1174 1174
 int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str)
1175 1175
 {
... ...
@@ -20,7 +20,7 @@
20 20
 
21 21
 #include "dsputil.h"
22 22
 #include "vorbis.h"
23
-#include "libavcore/audioconvert.h"
23
+#include "libavutil/audioconvert.h"
24 24
 
25 25
 const uint8_t ff_vorbis_channel_layout_offsets[8][8] = {
26 26
     { 0 },
... ...
@@ -33,7 +33,7 @@
33 33
 #include <stdlib.h>
34 34
 #include <string.h>
35 35
 
36
-#include "libavcore/imgutils.h"
36
+#include "libavutil/imgutils.h"
37 37
 #include "avcodec.h"
38 38
 #include "dsputil.h"
39 39
 #include "get_bits.h"
... ...
@@ -22,7 +22,7 @@
22 22
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 23
  */
24 24
 
25
-#include "libavcore/imgutils.h"
25
+#include "libavutil/imgutils.h"
26 26
 #include "avcodec.h"
27 27
 #include "vp56.h"
28 28
 #include "vp8data.h"
... ...
@@ -68,7 +68,7 @@
68 68
 #include <string.h>
69 69
 
70 70
 #include "libavutil/intreadwrite.h"
71
-#include "libavcore/imgutils.h"
71
+#include "libavutil/imgutils.h"
72 72
 #include "avcodec.h"
73 73
 
74 74
 #define PALETTE_COUNT 256
... ...
@@ -22,7 +22,7 @@
22 22
 #include "avcodec.h"
23 23
 #include "get_bits.h"
24 24
 #include "unary.h"
25
-#include "libavcore/audioconvert.h"
25
+#include "libavutil/audioconvert.h"
26 26
 
27 27
 /**
28 28
  * @file
... ...
@@ -18,7 +18,7 @@
18 18
  * License along with FFmpeg; if not, write to the Free Software
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21
-#include "libavcore/imgutils.h"
21
+#include "libavutil/imgutils.h"
22 22
 #include "avcodec.h"
23 23
 #include "get_bits.h"
24 24
 #include "bytestream.h"
... ...
@@ -24,7 +24,7 @@
24 24
  */
25 25
 
26 26
 #include "libavutil/intreadwrite.h"
27
-#include "libavcore/imgutils.h"
27
+#include "libavutil/imgutils.h"
28 28
 
29 29
 #include "avcodec.h"
30 30
 #include "get_bits.h"
31 31
deleted file mode 100644
... ...
@@ -1,20 +0,0 @@
1
-include $(SUBDIR)../config.mak
2
-
3
-NAME = avcore
4
-FFLIBS = avutil
5
-
6
-HEADERS = \
7
-          audioconvert.h                                                \
8
-          avcore.h                                                      \
9
-          imgutils.h                                                    \
10
-          parseutils.h                                                  \
11
-          samplefmt.h                                                   \
12
-
13
-OBJS = \
14
-       audioconvert.o                                                   \
15
-       imgutils.o                                                       \
16
-       parseutils.o                                                     \
17
-       samplefmt.o                                                      \
18
-       utils.o                                                          \
19
-
20
-include $(SUBDIR)../subdir.mak
21 1
deleted file mode 100644
... ...
@@ -1,116 +0,0 @@
1
-/*
2
- * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3
- *
4
- * This file is part of FFmpeg.
5
- *
6
- * FFmpeg is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU Lesser General Public
8
- * License as published by the Free Software Foundation; either
9
- * version 2.1 of the License, or (at your option) any later version.
10
- *
11
- * FFmpeg is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
- * Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public
17
- * License along with FFmpeg; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
- */
20
-
21
-/**
22
- * @file
23
- * audio conversion routines
24
- */
25
-
26
-#include "libavutil/avstring.h"
27
-#include "audioconvert.h"
28
-
29
-static const char * const channel_names[] = {
30
-    "FL", "FR", "FC", "LFE", "BL",  "BR",  "FLC", "FRC",
31
-    "BC", "SL", "SR", "TC",  "TFL", "TFC", "TFR", "TBL",
32
-    "TBC", "TBR",
33
-    [29] = "DL",
34
-    [30] = "DR",
35
-};
36
-
37
-static const char *get_channel_name(int channel_id)
38
-{
39
-    if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names))
40
-        return NULL;
41
-    return channel_names[channel_id];
42
-}
43
-
44
-static const struct {
45
-    const char *name;
46
-    int         nb_channels;
47
-    int64_t     layout;
48
-} channel_layout_map[] = {
49
-    { "mono",        1,  AV_CH_LAYOUT_MONO },
50
-    { "stereo",      2,  AV_CH_LAYOUT_STEREO },
51
-    { "4.0",         4,  AV_CH_LAYOUT_4POINT0 },
52
-    { "quad",        4,  AV_CH_LAYOUT_QUAD },
53
-    { "5.0",         5,  AV_CH_LAYOUT_5POINT0 },
54
-    { "5.0",         5,  AV_CH_LAYOUT_5POINT0_BACK },
55
-    { "5.1",         6,  AV_CH_LAYOUT_5POINT1 },
56
-    { "5.1",         6,  AV_CH_LAYOUT_5POINT1_BACK },
57
-    { "5.1+downmix", 8,  AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
58
-    { "7.1",         8,  AV_CH_LAYOUT_7POINT1 },
59
-    { "7.1(wide)",   8,  AV_CH_LAYOUT_7POINT1_WIDE },
60
-    { "7.1+downmix", 10, AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
61
-    { 0 }
62
-};
63
-
64
-int64_t av_get_channel_layout(const char *name)
65
-{
66
-    int i = 0;
67
-    do {
68
-        if (!strcmp(channel_layout_map[i].name, name))
69
-            return channel_layout_map[i].layout;
70
-        i++;
71
-    } while (channel_layout_map[i].name);
72
-
73
-    return 0;
74
-}
75
-
76
-void av_get_channel_layout_string(char *buf, int buf_size,
77
-                                  int nb_channels, int64_t channel_layout)
78
-{
79
-    int i;
80
-
81
-    if (nb_channels <= 0)
82
-        nb_channels = av_get_channel_layout_nb_channels(channel_layout);
83
-
84
-    for (i = 0; channel_layout_map[i].name; i++)
85
-        if (nb_channels    == channel_layout_map[i].nb_channels &&
86
-            channel_layout == channel_layout_map[i].layout) {
87
-            av_strlcpy(buf, channel_layout_map[i].name, buf_size);
88
-            return;
89
-        }
90
-
91
-    snprintf(buf, buf_size, "%d channels", nb_channels);
92
-    if (channel_layout) {
93
-        int i,ch;
94
-        av_strlcat(buf, " (", buf_size);
95
-        for(i=0,ch=0; i<64; i++) {
96
-            if ((channel_layout & (1L<<i))) {
97
-                const char *name = get_channel_name(i);
98
-                if (name) {
99
-                    if (ch>0) av_strlcat(buf, "|", buf_size);
100
-                    av_strlcat(buf, name, buf_size);
101
-                }
102
-                ch++;
103
-            }
104
-        }
105
-        av_strlcat(buf, ")", buf_size);
106
-    }
107
-}
108
-
109
-int av_get_channel_layout_nb_channels(int64_t channel_layout)
110
-{
111
-    int count;
112
-    uint64_t x = channel_layout;
113
-    for (count = 0; x; count++)
114
-        x &= x-1; // unset lowest set bit
115
-    return count;
116
-}
117 1
deleted file mode 100644
... ...
@@ -1,95 +0,0 @@
1
-/*
2
- * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3
- * Copyright (c) 2008 Peter Ross
4
- *
5
- * This file is part of FFmpeg.
6
- *
7
- * FFmpeg is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * FFmpeg is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with FFmpeg; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
- */
21
-
22
-#ifndef AVCORE_AUDIOCONVERT_H
23
-#define AVCORE_AUDIOCONVERT_H
24
-
25
-/**
26
- * @file
27
- * audio conversion routines
28
- */
29
-
30
-#include "avcore.h"
31
-
32
-/* Audio channel masks */
33
-#define AV_CH_FRONT_LEFT             0x00000001
34
-#define AV_CH_FRONT_RIGHT            0x00000002
35
-#define AV_CH_FRONT_CENTER           0x00000004
36
-#define AV_CH_LOW_FREQUENCY          0x00000008
37
-#define AV_CH_BACK_LEFT              0x00000010
38
-#define AV_CH_BACK_RIGHT             0x00000020
39
-#define AV_CH_FRONT_LEFT_OF_CENTER   0x00000040
40
-#define AV_CH_FRONT_RIGHT_OF_CENTER  0x00000080
41
-#define AV_CH_BACK_CENTER            0x00000100
42
-#define AV_CH_SIDE_LEFT              0x00000200
43
-#define AV_CH_SIDE_RIGHT             0x00000400
44
-#define AV_CH_TOP_CENTER             0x00000800
45
-#define AV_CH_TOP_FRONT_LEFT         0x00001000
46
-#define AV_CH_TOP_FRONT_CENTER       0x00002000
47
-#define AV_CH_TOP_FRONT_RIGHT        0x00004000
48
-#define AV_CH_TOP_BACK_LEFT          0x00008000
49
-#define AV_CH_TOP_BACK_CENTER        0x00010000
50
-#define AV_CH_TOP_BACK_RIGHT         0x00020000
51
-#define AV_CH_STEREO_LEFT            0x20000000  ///< Stereo downmix.
52
-#define AV_CH_STEREO_RIGHT           0x40000000  ///< See AV_CH_STEREO_LEFT.
53
-
54
-/** Channel mask value used for AVCodecContext.request_channel_layout
55
-    to indicate that the user requests the channel order of the decoder output
56
-    to be the native codec channel order. */
57
-#define AV_CH_LAYOUT_NATIVE          0x8000000000000000LL
58
-
59
-/* Audio channel convenience macros */
60
-#define AV_CH_LAYOUT_MONO              (AV_CH_FRONT_CENTER)
61
-#define AV_CH_LAYOUT_STEREO            (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
62
-#define AV_CH_LAYOUT_2_1               (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
63
-#define AV_CH_LAYOUT_SURROUND          (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
64
-#define AV_CH_LAYOUT_4POINT0           (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
65
-#define AV_CH_LAYOUT_2_2               (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
66
-#define AV_CH_LAYOUT_QUAD              (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
67
-#define AV_CH_LAYOUT_5POINT0           (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
68
-#define AV_CH_LAYOUT_5POINT1           (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
69
-#define AV_CH_LAYOUT_5POINT0_BACK      (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
70
-#define AV_CH_LAYOUT_5POINT1_BACK      (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
71
-#define AV_CH_LAYOUT_7POINT0           (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
72
-#define AV_CH_LAYOUT_7POINT1           (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
73
-#define AV_CH_LAYOUT_7POINT1_WIDE      (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
74
-#define AV_CH_LAYOUT_STEREO_DOWNMIX    (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
75
-
76
-/**
77
- * Return a channel layout id that matches name, 0 if no match.
78
- */
79
-int64_t av_get_channel_layout(const char *name);
80
-
81
-/**
82
- * Return a description of a channel layout.
83
- * If nb_channels is <= 0, it is guessed from the channel_layout.
84
- *
85
- * @param buf put here the string containing the channel layout
86
- * @param buf_size size in bytes of the buffer
87
- */
88
-void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
89
-
90
-/**
91
- * Return the number of channels in the channel layout.
92
- */
93
-int av_get_channel_layout_nb_channels(int64_t channel_layout);
94
-
95
-#endif /* AVCORE_AUDIOCONVERT_H */
96 1
deleted file mode 100644
... ...
@@ -1,70 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#ifndef AVCORE_AVCORE_H
20
-#define AVCORE_AVCORE_H
21
-
22
-/**
23
- * @file
24
- * shared media utilities for the libav* libraries
25
- */
26
-
27
-#include "libavutil/avutil.h"
28
-
29
-#define LIBAVCORE_VERSION_MAJOR  0
30
-#define LIBAVCORE_VERSION_MINOR 16
31
-#define LIBAVCORE_VERSION_MICRO  1
32
-
33
-#define LIBAVCORE_VERSION_INT   AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \
34
-                                               LIBAVCORE_VERSION_MINOR, \
35
-                                               LIBAVCORE_VERSION_MICRO)
36
-#define LIBAVCORE_VERSION       AV_VERSION(LIBAVCORE_VERSION_MAJOR,     \
37
-                                           LIBAVCORE_VERSION_MINOR,     \
38
-                                           LIBAVCORE_VERSION_MICRO)
39
-#define LIBAVCORE_BUILD         LIBAVCORE_VERSION_INT
40
-
41
-#define LIBAVCORE_IDENT         "Lavcore" AV_STRINGIFY(LIBAVCORE_VERSION)
42
-
43
-/**
44
- * Return the LIBAVCORE_VERSION_INT constant.
45
- */
46
-unsigned avcore_version(void);
47
-
48
-/**
49
- * Return the libavcore build-time configuration.
50
- */
51
-const char *avcore_configuration(void);
52
-
53
-/**
54
- * Return the libavcore license.
55
- */
56
-const char *avcore_license(void);
57
-
58
-#define AV_NOPTS_VALUE          INT64_C(0x8000000000000000)
59
-#define AV_TIME_BASE            1000000
60
-#define AV_TIME_BASE_Q          (AVRational){1, AV_TIME_BASE}
61
-
62
-/**
63
- * Those FF_API_* defines are not part of public API.
64
- * They may change, break or disappear at any time.
65
- */
66
-#ifndef FF_API_OLD_IMAGE_NAMES
67
-#define FF_API_OLD_IMAGE_NAMES (LIBAVCORE_VERSION_MAJOR < 1)
68
-#endif
69
-
70
-#endif /* AVCORE_AVCORE_H */
71 1
deleted file mode 100644
... ...
@@ -1,297 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-/**
20
- * @file
21
- * misc image utilities
22
- */
23
-
24
-#include "imgutils.h"
25
-#include "internal.h"
26
-#include "libavutil/pixdesc.h"
27
-
28
-void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
29
-                                const AVPixFmtDescriptor *pixdesc)
30
-{
31
-    int i;
32
-    memset(max_pixsteps, 0, 4*sizeof(max_pixsteps[0]));
33
-    if (max_pixstep_comps)
34
-        memset(max_pixstep_comps, 0, 4*sizeof(max_pixstep_comps[0]));
35
-
36
-    for (i = 0; i < 4; i++) {
37
-        const AVComponentDescriptor *comp = &(pixdesc->comp[i]);
38
-        if ((comp->step_minus1+1) > max_pixsteps[comp->plane]) {
39
-            max_pixsteps[comp->plane] = comp->step_minus1+1;
40
-            if (max_pixstep_comps)
41
-                max_pixstep_comps[comp->plane] = i;
42
-        }
43
-    }
44
-}
45
-
46
-int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane)
47
-{
48
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
49
-    int max_step     [4];       /* max pixel step for each plane */
50
-    int max_step_comp[4];       /* the component for each plane which has the max pixel step */
51
-    int s;
52
-
53
-    if (desc->flags & PIX_FMT_BITSTREAM)
54
-        return (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
55
-
56
-    av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
57
-    s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->log2_chroma_w : 0;
58
-    return max_step[plane] * (((width + (1 << s) - 1)) >> s);
59
-}
60
-
61
-int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
62
-{
63
-    int i;
64
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
65
-    int max_step     [4];       /* max pixel step for each plane */
66
-    int max_step_comp[4];       /* the component for each plane which has the max pixel step */
67
-
68
-    memset(linesizes, 0, 4*sizeof(linesizes[0]));
69
-
70
-    if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
71
-        return AVERROR(EINVAL);
72
-
73
-    if (desc->flags & PIX_FMT_BITSTREAM) {
74
-        if (width > (INT_MAX -7) / (desc->comp[0].step_minus1+1))
75
-            return AVERROR(EINVAL);
76
-        linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
77
-        return 0;
78
-    }
79
-
80
-    av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
81
-    for (i = 0; i < 4; i++) {
82
-        int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0;
83
-        int shifted_w = ((width + (1 << s) - 1)) >> s;
84
-        if (max_step[i] > INT_MAX / shifted_w)
85
-            return AVERROR(EINVAL);
86
-        linesizes[i] = max_step[i] * shifted_w;
87
-    }
88
-
89
-    return 0;
90
-}
91
-
92
-int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
93
-                           uint8_t *ptr, const int linesizes[4])
94
-{
95
-    int i, total_size, size[4], has_plane[4];
96
-
97
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
98
-    memset(data     , 0, sizeof(data[0])*4);
99
-    memset(size     , 0, sizeof(size));
100
-    memset(has_plane, 0, sizeof(has_plane));
101
-
102
-    if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
103
-        return AVERROR(EINVAL);
104
-
105
-    data[0] = ptr;
106
-    if (linesizes[0] > (INT_MAX - 1024) / height)
107
-        return AVERROR(EINVAL);
108
-    size[0] = linesizes[0] * height;
109
-
110
-    if (desc->flags & PIX_FMT_PAL) {
111
-        size[0] = (size[0] + 3) & ~3;
112
-        data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */
113
-        return size[0] + 256 * 4;
114
-    }
115
-
116
-    for (i = 0; i < 4; i++)
117
-        has_plane[desc->comp[i].plane] = 1;
118
-
119
-    total_size = size[0];
120
-    for (i = 1; has_plane[i] && i < 4; i++) {
121
-        int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
122
-        data[i] = data[i-1] + size[i-1];
123
-        h = (height + (1 << s) - 1) >> s;
124
-        if (linesizes[i] > INT_MAX / h)
125
-            return AVERROR(EINVAL);
126
-        size[i] = h * linesizes[i];
127
-        if (total_size > INT_MAX - size[i])
128
-            return AVERROR(EINVAL);
129
-        total_size += size[i];
130
-    }
131
-
132
-    return total_size;
133
-}
134
-
135
-int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt)
136
-{
137
-    int i;
138
-
139
-    for (i = 0; i < 256; i++) {
140
-        int r, g, b;
141
-
142
-        switch (pix_fmt) {
143
-        case PIX_FMT_RGB8:
144
-            r = (i>>5    )*36;
145
-            g = ((i>>2)&7)*36;
146
-            b = (i&3     )*85;
147
-            break;
148
-        case PIX_FMT_BGR8:
149
-            b = (i>>6    )*85;
150
-            g = ((i>>3)&7)*36;
151
-            r = (i&7     )*36;
152
-            break;
153
-        case PIX_FMT_RGB4_BYTE:
154
-            r = (i>>3    )*255;
155
-            g = ((i>>1)&3)*85;
156
-            b = (i&1     )*255;
157
-            break;
158
-        case PIX_FMT_BGR4_BYTE:
159
-            b = (i>>3    )*255;
160
-            g = ((i>>1)&3)*85;
161
-            r = (i&1     )*255;
162
-            break;
163
-        case PIX_FMT_GRAY8:
164
-            r = b = g = i;
165
-            break;
166
-        default:
167
-            return AVERROR(EINVAL);
168
-        }
169
-        pal[i] = b + (g<<8) + (r<<16);
170
-    }
171
-
172
-    return 0;
173
-}
174
-
175
-int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
176
-                   int w, int h, enum PixelFormat pix_fmt, int align)
177
-{
178
-    int i, ret;
179
-    uint8_t *buf;
180
-
181
-    if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)
182
-        return ret;
183
-    if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, w)) < 0)
184
-        return ret;
185
-
186
-    for (i = 0; i < 4; i++)
187
-        linesizes[i] = FFALIGN(linesizes[i], align);
188
-
189
-    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)
190
-        return ret;
191
-    buf = av_malloc(ret + align);
192
-    if (!buf)
193
-        return AVERROR(ENOMEM);
194
-    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {
195
-        av_free(buf);
196
-        return ret;
197
-    }
198
-    if (av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_PAL)
199
-        ff_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
200
-
201
-    return ret;
202
-}
203
-
204
-typedef struct ImgUtils {
205
-    const AVClass *class;
206
-    int   log_offset;
207
-    void *log_ctx;
208
-} ImgUtils;
209
-
210
-static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) };
211
-
212
-int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
213
-{
214
-    ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
215
-
216
-    if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
217
-        return 0;
218
-
219
-    av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
220
-    return AVERROR(EINVAL);
221
-}
222
-
223
-void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
224
-                         const uint8_t *src, int src_linesize,
225
-                         int bytewidth, int height)
226
-{
227
-    if (!dst || !src)
228
-        return;
229
-    for (;height > 0; height--) {
230
-        memcpy(dst, src, bytewidth);
231
-        dst += dst_linesize;
232
-        src += src_linesize;
233
-    }
234
-}
235
-
236
-void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
237
-                   const uint8_t *src_data[4], const int src_linesizes[4],
238
-                   enum PixelFormat pix_fmt, int width, int height)
239
-{
240
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
241
-
242
-    if (desc->flags & PIX_FMT_HWACCEL)
243
-        return;
244
-
245
-    if (desc->flags & PIX_FMT_PAL) {
246
-        av_image_copy_plane(dst_data[0], dst_linesizes[0],
247
-                            src_data[0], src_linesizes[0],
248
-                            width, height);
249
-        /* copy the palette */
250
-        memcpy(dst_data[1], src_data[1], 4*256);
251
-    } else {
252
-        int i, planes_nb = 0;
253
-
254
-        for (i = 0; i < desc->nb_components; i++)
255
-            planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
256
-
257
-        for (i = 0; i < planes_nb; i++) {
258
-            int h = height;
259
-            int bwidth = av_image_get_linesize(pix_fmt, width, i);
260
-            if (i == 1 || i == 2) {
261
-                h= -((-height)>>desc->log2_chroma_h);
262
-            }
263
-            av_image_copy_plane(dst_data[i], dst_linesizes[i],
264
-                                src_data[i], src_linesizes[i],
265
-                                bwidth, h);
266
-        }
267
-    }
268
-}
269
-
270
-#if FF_API_OLD_IMAGE_NAMES
271
-void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
272
-                                const AVPixFmtDescriptor *pixdesc)
273
-{
274
-    av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, pixdesc);
275
-}
276
-
277
-int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane)
278
-{
279
-    return av_image_get_linesize(pix_fmt, width, plane);
280
-}
281
-
282
-int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
283
-{
284
-    return av_image_fill_linesizes(linesizes, pix_fmt, width);
285
-}
286
-
287
-int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
288
-                           uint8_t *ptr, const int linesizes[4])
289
-{
290
-    return av_image_fill_pointers(data, pix_fmt, height, ptr, linesizes);
291
-}
292
-
293
-int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
294
-{
295
-    return av_image_check_size(w, h, log_offset, log_ctx);
296
-}
297
-#endif
298 1
deleted file mode 100644
... ...
@@ -1,147 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#ifndef AVCORE_IMGUTILS_H
20
-#define AVCORE_IMGUTILS_H
21
-
22
-/**
23
- * @file
24
- * misc image utilities
25
- */
26
-
27
-#include "libavutil/pixdesc.h"
28
-#include "avcore.h"
29
-
30
-/**
31
- * Compute the max pixel step for each plane of an image with a
32
- * format described by pixdesc.
33
- *
34
- * The pixel step is the distance in bytes between the first byte of
35
- * the group of bytes which describe a pixel component and the first
36
- * byte of the successive group in the same plane for the same
37
- * component.
38
- *
39
- * @param max_pixsteps an array which is filled with the max pixel step
40
- * for each plane. Since a plane may contain different pixel
41
- * components, the computed max_pixsteps[plane] is relative to the
42
- * component in the plane with the max pixel step.
43
- * @param max_pixstep_comps an array which is filled with the component
44
- * for each plane which has the max pixel step. May be NULL.
45
- */
46
-void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
47
-                                const AVPixFmtDescriptor *pixdesc);
48
-
49
-/**
50
- * Compute the size of an image line with format pix_fmt and width
51
- * width for the plane plane.
52
- *
53
- * @return the computed size in bytes
54
- */
55
-int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane);
56
-
57
-/**
58
- * Fill plane linesizes for an image with pixel format pix_fmt and
59
- * width width.
60
- *
61
- * @param linesizes array to be filled with the linesize for each plane
62
- * @return >= 0 in case of success, a negative error code otherwise
63
- */
64
-int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width);
65
-
66
-/**
67
- * Fill plane data pointers for an image with pixel format pix_fmt and
68
- * height height.
69
- *
70
- * @param data pointers array to be filled with the pointer for each image plane
71
- * @param ptr the pointer to a buffer which will contain the image
72
- * @param linesizes[4] the array containing the linesize for each
73
- * plane, should be filled by av_image_fill_linesizes()
74
- * @return the size in bytes required for the image buffer, a negative
75
- * error code in case of failure
76
- */
77
-int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
78
-                           uint8_t *ptr, const int linesizes[4]);
79
-
80
-/**
81
- * Allocate an image with size w and h and pixel format pix_fmt, and
82
- * fill pointers and linesizes accordingly.
83
- * The allocated image buffer has to be freed by using
84
- * av_freep(&pointers[0]).
85
- *
86
- * @param align the value to use for buffer size alignment
87
- * @return the size in bytes required for the image buffer, a negative
88
- * error code in case of failure
89
- */
90
-int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
91
-                   int w, int h, enum PixelFormat pix_fmt, int align);
92
-
93
-/**
94
- * Copy image plane from src to dst.
95
- * That is, copy "height" number of lines of "bytewidth" bytes each.
96
- * The first byte of each successive line is separated by *_linesize
97
- * bytes.
98
- *
99
- * @param dst_linesize linesize for the image plane in dst
100
- * @param src_linesize linesize for the image plane in src
101
- */
102
-void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
103
-                         const uint8_t *src, int src_linesize,
104
-                         int bytewidth, int height);
105
-
106
-/**
107
- * Copy image in src_data to dst_data.
108
- *
109
- * @param dst_linesize linesizes for the image in dst_data
110
- * @param src_linesize linesizes for the image in src_data
111
- */
112
-void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
113
-                   const uint8_t *src_data[4], const int src_linesizes[4],
114
-                   enum PixelFormat pix_fmt, int width, int height);
115
-
116
-/**
117
- * Check if the given dimension of an image is valid, meaning that all
118
- * bytes of the image can be addressed with a signed int.
119
- *
120
- * @param w the width of the picture
121
- * @param h the height of the picture
122
- * @param log_offset the offset to sum to the log level for logging with log_ctx
123
- * @param log_ctx the parent logging context, it may be NULL
124
- * @return >= 0 if valid, a negative error code otherwise
125
- */
126
-int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
127
-
128
-#if FF_API_OLD_IMAGE_NAMES
129
-attribute_deprecated
130
-void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
131
-                                const AVPixFmtDescriptor *pixdesc);
132
-
133
-attribute_deprecated
134
-int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane);
135
-
136
-attribute_deprecated
137
-int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width);
138
-
139
-attribute_deprecated
140
-int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
141
-                           uint8_t *ptr, const int linesizes[4]);
142
-
143
-attribute_deprecated
144
-int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
145
-#endif
146
-
147
-#endif /* AVCORE_IMGUTILS_H */
148 1
deleted file mode 100644
... ...
@@ -1,31 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#ifndef AVCORE_INTERNAL_H
20
-#define AVCORE_INTERNAL_H
21
-
22
-/**
23
- * @file
24
- * internal functions
25
- */
26
-
27
-#include "avcore.h"
28
-
29
-int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt);
30
-
31
-#endif /* AVCORE_INTERNAL_H */
32 1
deleted file mode 100644
... ...
@@ -1,4 +0,0 @@
1
-LIBAVCORE_$MAJOR {
2
-        global: av_*; ff_*; avcore*;
3
-        local: *;
4
-};
5 1
deleted file mode 100644
... ...
@@ -1,474 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-/**
20
- * @file
21
- * misc parsing utilities for libavcore
22
- */
23
-
24
-#include <strings.h>
25
-#include "parseutils.h"
26
-#include "libavutil/avutil.h"
27
-#include "libavutil/eval.h"
28
-#include "libavutil/avstring.h"
29
-#include "libavutil/random_seed.h"
30
-
31
-typedef struct {
32
-    const char *abbr;
33
-    int width, height;
34
-} VideoSizeAbbr;
35
-
36
-typedef struct {
37
-    const char *abbr;
38
-    AVRational rate;
39
-} VideoRateAbbr;
40
-
41
-static const VideoSizeAbbr video_size_abbrs[] = {
42
-    { "ntsc",      720, 480 },
43
-    { "pal",       720, 576 },
44
-    { "qntsc",     352, 240 }, /* VCD compliant NTSC */
45
-    { "qpal",      352, 288 }, /* VCD compliant PAL */
46
-    { "sntsc",     640, 480 }, /* square pixel NTSC */
47
-    { "spal",      768, 576 }, /* square pixel PAL */
48
-    { "film",      352, 240 },
49
-    { "ntsc-film", 352, 240 },
50
-    { "sqcif",     128,  96 },
51
-    { "qcif",      176, 144 },
52
-    { "cif",       352, 288 },
53
-    { "4cif",      704, 576 },
54
-    { "16cif",    1408,1152 },
55
-    { "qqvga",     160, 120 },
56
-    { "qvga",      320, 240 },
57
-    { "vga",       640, 480 },
58
-    { "svga",      800, 600 },
59
-    { "xga",      1024, 768 },
60
-    { "uxga",     1600,1200 },
61
-    { "qxga",     2048,1536 },
62
-    { "sxga",     1280,1024 },
63
-    { "qsxga",    2560,2048 },
64
-    { "hsxga",    5120,4096 },
65
-    { "wvga",      852, 480 },
66
-    { "wxga",     1366, 768 },
67
-    { "wsxga",    1600,1024 },
68
-    { "wuxga",    1920,1200 },
69
-    { "woxga",    2560,1600 },
70
-    { "wqsxga",   3200,2048 },
71
-    { "wquxga",   3840,2400 },
72
-    { "whsxga",   6400,4096 },
73
-    { "whuxga",   7680,4800 },
74
-    { "cga",       320, 200 },
75
-    { "ega",       640, 350 },
76
-    { "hd480",     852, 480 },
77
-    { "hd720",    1280, 720 },
78
-    { "hd1080",   1920,1080 },
79
-};
80
-
81
-static const VideoRateAbbr video_rate_abbrs[]= {
82
-    { "ntsc",      { 30000, 1001 } },
83
-    { "pal",       {    25,    1 } },
84
-    { "qntsc",     { 30000, 1001 } }, /* VCD compliant NTSC */
85
-    { "qpal",      {    25,    1 } }, /* VCD compliant PAL */
86
-    { "sntsc",     { 30000, 1001 } }, /* square pixel NTSC */
87
-    { "spal",      {    25,    1 } }, /* square pixel PAL */
88
-    { "film",      {    24,    1 } },
89
-    { "ntsc-film", { 24000, 1001 } },
90
-};
91
-
92
-int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
93
-{
94
-    int i;
95
-    int n = FF_ARRAY_ELEMS(video_size_abbrs);
96
-    char *p;
97
-    int width = 0, height = 0;
98
-
99
-    for (i = 0; i < n; i++) {
100
-        if (!strcmp(video_size_abbrs[i].abbr, str)) {
101
-            width  = video_size_abbrs[i].width;
102
-            height = video_size_abbrs[i].height;
103
-            break;
104
-        }
105
-    }
106
-    if (i == n) {
107
-        p = str;
108
-        width = strtol(p, &p, 10);
109
-        if (*p)
110
-            p++;
111
-        height = strtol(p, &p, 10);
112
-    }
113
-    if (width <= 0 || height <= 0)
114
-        return AVERROR(EINVAL);
115
-    *width_ptr  = width;
116
-    *height_ptr = height;
117
-    return 0;
118
-}
119
-
120
-int av_parse_video_rate(AVRational *rate, const char *arg)
121
-{
122
-    int i, ret;
123
-    int n = FF_ARRAY_ELEMS(video_rate_abbrs);
124
-    double res;
125
-
126
-    /* First, we check our abbreviation table */
127
-    for (i = 0; i < n; ++i)
128
-        if (!strcmp(video_rate_abbrs[i].abbr, arg)) {
129
-            *rate = video_rate_abbrs[i].rate;
130
-            return 0;
131
-        }
132
-
133
-    /* Then, we try to parse it as fraction */
134
-    if ((ret = av_expr_parse_and_eval(&res, arg, NULL, NULL, NULL, NULL, NULL, NULL,
135
-                                      NULL, 0, NULL)) < 0)
136
-        return ret;
137
-    *rate = av_d2q(res, 1001000);
138
-    if (rate->num <= 0 || rate->den <= 0)
139
-        return AVERROR(EINVAL);
140
-    return 0;
141
-}
142
-
143
-typedef struct {
144
-    const char *name;            ///< a string representing the name of the color
145
-    uint8_t     rgb_color[3];    ///< RGB values for the color
146
-} ColorEntry;
147
-
148
-static ColorEntry color_table[] = {
149
-    { "AliceBlue",            { 0xF0, 0xF8, 0xFF } },
150
-    { "AntiqueWhite",         { 0xFA, 0xEB, 0xD7 } },
151
-    { "Aqua",                 { 0x00, 0xFF, 0xFF } },
152
-    { "Aquamarine",           { 0x7F, 0xFF, 0xD4 } },
153
-    { "Azure",                { 0xF0, 0xFF, 0xFF } },
154
-    { "Beige",                { 0xF5, 0xF5, 0xDC } },
155
-    { "Bisque",               { 0xFF, 0xE4, 0xC4 } },
156
-    { "Black",                { 0x00, 0x00, 0x00 } },
157
-    { "BlanchedAlmond",       { 0xFF, 0xEB, 0xCD } },
158
-    { "Blue",                 { 0x00, 0x00, 0xFF } },
159
-    { "BlueViolet",           { 0x8A, 0x2B, 0xE2 } },
160
-    { "Brown",                { 0xA5, 0x2A, 0x2A } },
161
-    { "BurlyWood",            { 0xDE, 0xB8, 0x87 } },
162
-    { "CadetBlue",            { 0x5F, 0x9E, 0xA0 } },
163
-    { "Chartreuse",           { 0x7F, 0xFF, 0x00 } },
164
-    { "Chocolate",            { 0xD2, 0x69, 0x1E } },
165
-    { "Coral",                { 0xFF, 0x7F, 0x50 } },
166
-    { "CornflowerBlue",       { 0x64, 0x95, 0xED } },
167
-    { "Cornsilk",             { 0xFF, 0xF8, 0xDC } },
168
-    { "Crimson",              { 0xDC, 0x14, 0x3C } },
169
-    { "Cyan",                 { 0x00, 0xFF, 0xFF } },
170
-    { "DarkBlue",             { 0x00, 0x00, 0x8B } },
171
-    { "DarkCyan",             { 0x00, 0x8B, 0x8B } },
172
-    { "DarkGoldenRod",        { 0xB8, 0x86, 0x0B } },
173
-    { "DarkGray",             { 0xA9, 0xA9, 0xA9 } },
174
-    { "DarkGreen",            { 0x00, 0x64, 0x00 } },
175
-    { "DarkKhaki",            { 0xBD, 0xB7, 0x6B } },
176
-    { "DarkMagenta",          { 0x8B, 0x00, 0x8B } },
177
-    { "DarkOliveGreen",       { 0x55, 0x6B, 0x2F } },
178
-    { "Darkorange",           { 0xFF, 0x8C, 0x00 } },
179
-    { "DarkOrchid",           { 0x99, 0x32, 0xCC } },
180
-    { "DarkRed",              { 0x8B, 0x00, 0x00 } },
181
-    { "DarkSalmon",           { 0xE9, 0x96, 0x7A } },
182
-    { "DarkSeaGreen",         { 0x8F, 0xBC, 0x8F } },
183
-    { "DarkSlateBlue",        { 0x48, 0x3D, 0x8B } },
184
-    { "DarkSlateGray",        { 0x2F, 0x4F, 0x4F } },
185
-    { "DarkTurquoise",        { 0x00, 0xCE, 0xD1 } },
186
-    { "DarkViolet",           { 0x94, 0x00, 0xD3 } },
187
-    { "DeepPink",             { 0xFF, 0x14, 0x93 } },
188
-    { "DeepSkyBlue",          { 0x00, 0xBF, 0xFF } },
189
-    { "DimGray",              { 0x69, 0x69, 0x69 } },
190
-    { "DodgerBlue",           { 0x1E, 0x90, 0xFF } },
191
-    { "FireBrick",            { 0xB2, 0x22, 0x22 } },
192
-    { "FloralWhite",          { 0xFF, 0xFA, 0xF0 } },
193
-    { "ForestGreen",          { 0x22, 0x8B, 0x22 } },
194
-    { "Fuchsia",              { 0xFF, 0x00, 0xFF } },
195
-    { "Gainsboro",            { 0xDC, 0xDC, 0xDC } },
196
-    { "GhostWhite",           { 0xF8, 0xF8, 0xFF } },
197
-    { "Gold",                 { 0xFF, 0xD7, 0x00 } },
198
-    { "GoldenRod",            { 0xDA, 0xA5, 0x20 } },
199
-    { "Gray",                 { 0x80, 0x80, 0x80 } },
200
-    { "Green",                { 0x00, 0x80, 0x00 } },
201
-    { "GreenYellow",          { 0xAD, 0xFF, 0x2F } },
202
-    { "HoneyDew",             { 0xF0, 0xFF, 0xF0 } },
203
-    { "HotPink",              { 0xFF, 0x69, 0xB4 } },
204
-    { "IndianRed",            { 0xCD, 0x5C, 0x5C } },
205
-    { "Indigo",               { 0x4B, 0x00, 0x82 } },
206
-    { "Ivory",                { 0xFF, 0xFF, 0xF0 } },
207
-    { "Khaki",                { 0xF0, 0xE6, 0x8C } },
208
-    { "Lavender",             { 0xE6, 0xE6, 0xFA } },
209
-    { "LavenderBlush",        { 0xFF, 0xF0, 0xF5 } },
210
-    { "LawnGreen",            { 0x7C, 0xFC, 0x00 } },
211
-    { "LemonChiffon",         { 0xFF, 0xFA, 0xCD } },
212
-    { "LightBlue",            { 0xAD, 0xD8, 0xE6 } },
213
-    { "LightCoral",           { 0xF0, 0x80, 0x80 } },
214
-    { "LightCyan",            { 0xE0, 0xFF, 0xFF } },
215
-    { "LightGoldenRodYellow", { 0xFA, 0xFA, 0xD2 } },
216
-    { "LightGrey",            { 0xD3, 0xD3, 0xD3 } },
217
-    { "LightGreen",           { 0x90, 0xEE, 0x90 } },
218
-    { "LightPink",            { 0xFF, 0xB6, 0xC1 } },
219
-    { "LightSalmon",          { 0xFF, 0xA0, 0x7A } },
220
-    { "LightSeaGreen",        { 0x20, 0xB2, 0xAA } },
221
-    { "LightSkyBlue",         { 0x87, 0xCE, 0xFA } },
222
-    { "LightSlateGray",       { 0x77, 0x88, 0x99 } },
223
-    { "LightSteelBlue",       { 0xB0, 0xC4, 0xDE } },
224
-    { "LightYellow",          { 0xFF, 0xFF, 0xE0 } },
225
-    { "Lime",                 { 0x00, 0xFF, 0x00 } },
226
-    { "LimeGreen",            { 0x32, 0xCD, 0x32 } },
227
-    { "Linen",                { 0xFA, 0xF0, 0xE6 } },
228
-    { "Magenta",              { 0xFF, 0x00, 0xFF } },
229
-    { "Maroon",               { 0x80, 0x00, 0x00 } },
230
-    { "MediumAquaMarine",     { 0x66, 0xCD, 0xAA } },
231
-    { "MediumBlue",           { 0x00, 0x00, 0xCD } },
232
-    { "MediumOrchid",         { 0xBA, 0x55, 0xD3 } },
233
-    { "MediumPurple",         { 0x93, 0x70, 0xD8 } },
234
-    { "MediumSeaGreen",       { 0x3C, 0xB3, 0x71 } },
235
-    { "MediumSlateBlue",      { 0x7B, 0x68, 0xEE } },
236
-    { "MediumSpringGreen",    { 0x00, 0xFA, 0x9A } },
237
-    { "MediumTurquoise",      { 0x48, 0xD1, 0xCC } },
238
-    { "MediumVioletRed",      { 0xC7, 0x15, 0x85 } },
239
-    { "MidnightBlue",         { 0x19, 0x19, 0x70 } },
240
-    { "MintCream",            { 0xF5, 0xFF, 0xFA } },
241
-    { "MistyRose",            { 0xFF, 0xE4, 0xE1 } },
242
-    { "Moccasin",             { 0xFF, 0xE4, 0xB5 } },
243
-    { "NavajoWhite",          { 0xFF, 0xDE, 0xAD } },
244
-    { "Navy",                 { 0x00, 0x00, 0x80 } },
245
-    { "OldLace",              { 0xFD, 0xF5, 0xE6 } },
246
-    { "Olive",                { 0x80, 0x80, 0x00 } },
247
-    { "OliveDrab",            { 0x6B, 0x8E, 0x23 } },
248
-    { "Orange",               { 0xFF, 0xA5, 0x00 } },
249
-    { "OrangeRed",            { 0xFF, 0x45, 0x00 } },
250
-    { "Orchid",               { 0xDA, 0x70, 0xD6 } },
251
-    { "PaleGoldenRod",        { 0xEE, 0xE8, 0xAA } },
252
-    { "PaleGreen",            { 0x98, 0xFB, 0x98 } },
253
-    { "PaleTurquoise",        { 0xAF, 0xEE, 0xEE } },
254
-    { "PaleVioletRed",        { 0xD8, 0x70, 0x93 } },
255
-    { "PapayaWhip",           { 0xFF, 0xEF, 0xD5 } },
256
-    { "PeachPuff",            { 0xFF, 0xDA, 0xB9 } },
257
-    { "Peru",                 { 0xCD, 0x85, 0x3F } },
258
-    { "Pink",                 { 0xFF, 0xC0, 0xCB } },
259
-    { "Plum",                 { 0xDD, 0xA0, 0xDD } },
260
-    { "PowderBlue",           { 0xB0, 0xE0, 0xE6 } },
261
-    { "Purple",               { 0x80, 0x00, 0x80 } },
262
-    { "Red",                  { 0xFF, 0x00, 0x00 } },
263
-    { "RosyBrown",            { 0xBC, 0x8F, 0x8F } },
264
-    { "RoyalBlue",            { 0x41, 0x69, 0xE1 } },
265
-    { "SaddleBrown",          { 0x8B, 0x45, 0x13 } },
266
-    { "Salmon",               { 0xFA, 0x80, 0x72 } },
267
-    { "SandyBrown",           { 0xF4, 0xA4, 0x60 } },
268
-    { "SeaGreen",             { 0x2E, 0x8B, 0x57 } },
269
-    { "SeaShell",             { 0xFF, 0xF5, 0xEE } },
270
-    { "Sienna",               { 0xA0, 0x52, 0x2D } },
271
-    { "Silver",               { 0xC0, 0xC0, 0xC0 } },
272
-    { "SkyBlue",              { 0x87, 0xCE, 0xEB } },
273
-    { "SlateBlue",            { 0x6A, 0x5A, 0xCD } },
274
-    { "SlateGray",            { 0x70, 0x80, 0x90 } },
275
-    { "Snow",                 { 0xFF, 0xFA, 0xFA } },
276
-    { "SpringGreen",          { 0x00, 0xFF, 0x7F } },
277
-    { "SteelBlue",            { 0x46, 0x82, 0xB4 } },
278
-    { "Tan",                  { 0xD2, 0xB4, 0x8C } },
279
-    { "Teal",                 { 0x00, 0x80, 0x80 } },
280
-    { "Thistle",              { 0xD8, 0xBF, 0xD8 } },
281
-    { "Tomato",               { 0xFF, 0x63, 0x47 } },
282
-    { "Turquoise",            { 0x40, 0xE0, 0xD0 } },
283
-    { "Violet",               { 0xEE, 0x82, 0xEE } },
284
-    { "Wheat",                { 0xF5, 0xDE, 0xB3 } },
285
-    { "White",                { 0xFF, 0xFF, 0xFF } },
286
-    { "WhiteSmoke",           { 0xF5, 0xF5, 0xF5 } },
287
-    { "Yellow",               { 0xFF, 0xFF, 0x00 } },
288
-    { "YellowGreen",          { 0x9A, 0xCD, 0x32 } },
289
-};
290
-
291
-static int color_table_compare(const void *lhs, const void *rhs)
292
-{
293
-    return strcasecmp(lhs, ((const ColorEntry *)rhs)->name);
294
-}
295
-
296
-#define ALPHA_SEP '@'
297
-
298
-int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
299
-                   void *log_ctx)
300
-{
301
-    char *tail, color_string2[128];
302
-    const ColorEntry *entry;
303
-    int len, hex_offset = 0;
304
-
305
-    if (color_string[0] == '#') {
306
-        hex_offset = 1;
307
-    } else if (!strncmp(color_string, "0x", 2))
308
-        hex_offset = 2;
309
-
310
-    if (slen < 0)
311
-        slen = strlen(color_string);
312
-    av_strlcpy(color_string2, color_string + hex_offset,
313
-               FFMIN(slen-hex_offset+1, sizeof(color_string2)));
314
-    if ((tail = strchr(color_string2, ALPHA_SEP)))
315
-        *tail++ = 0;
316
-    len = strlen(color_string2);
317
-    rgba_color[3] = 255;
318
-
319
-    if (!strcasecmp(color_string2, "random") || !strcasecmp(color_string2, "bikeshed")) {
320
-        int rgba = av_get_random_seed();
321
-        rgba_color[0] = rgba >> 24;
322
-        rgba_color[1] = rgba >> 16;
323
-        rgba_color[2] = rgba >> 8;
324
-        rgba_color[3] = rgba;
325
-    } else if (hex_offset ||
326
-               strspn(color_string2, "0123456789ABCDEFabcdef") == len) {
327
-        char *tail;
328
-        unsigned int rgba = strtoul(color_string2, &tail, 16);
329
-
330
-        if (*tail || (len != 6 && len != 8)) {
331
-            av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string2);
332
-            return AVERROR(EINVAL);
333
-        }
334
-        if (len == 8) {
335
-            rgba_color[3] = rgba;
336
-            rgba >>= 8;
337
-        }
338
-        rgba_color[0] = rgba >> 16;
339
-        rgba_color[1] = rgba >> 8;
340
-        rgba_color[2] = rgba;
341
-    } else {
342
-        entry = bsearch(color_string2,
343
-                        color_table,
344
-                        FF_ARRAY_ELEMS(color_table),
345
-                        sizeof(ColorEntry),
346
-                        color_table_compare);
347
-        if (!entry) {
348
-            av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string2);
349
-            return AVERROR(EINVAL);
350
-        }
351
-        memcpy(rgba_color, entry->rgb_color, 3);
352
-    }
353
-
354
-    if (tail) {
355
-        unsigned long int alpha;
356
-        const char *alpha_string = tail;
357
-        if (!strncmp(alpha_string, "0x", 2)) {
358
-            alpha = strtoul(alpha_string, &tail, 16);
359
-        } else {
360
-            alpha = 255 * strtod(alpha_string, &tail);
361
-        }
362
-
363
-        if (tail == alpha_string || *tail || alpha > 255) {
364
-            av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n",
365
-                   alpha_string, color_string);
366
-            return AVERROR(EINVAL);
367
-        }
368
-        rgba_color[3] = alpha;
369
-    }
370
-
371
-    return 0;
372
-}
373
-
374
-#ifdef TEST
375
-
376
-#undef printf
377
-
378
-int main(void)
379
-{
380
-    printf("Testing av_parse_video_rate()\n");
381
-    {
382
-        int i;
383
-        const char *rates[] = {
384
-            "-inf",
385
-            "inf",
386
-            "nan",
387
-            "123/0",
388
-            "-123 / 0",
389
-            "",
390
-            "/",
391
-            " 123  /  321",
392
-            "foo/foo",
393
-            "foo/1",
394
-            "1/foo",
395
-            "0/0",
396
-            "/0",
397
-            "1/",
398
-            "1",
399
-            "0",
400
-            "-123/123",
401
-            "-foo",
402
-            "123.23",
403
-            ".23",
404
-            "-.23",
405
-            "-0.234",
406
-            "-0.0000001",
407
-            "  21332.2324   ",
408
-            " -21332.2324   ",
409
-        };
410
-
411
-        for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) {
412
-            int ret;
413
-            AVRational q = (AVRational){0, 0};
414
-            ret = av_parse_video_rate(&q, rates[i]),
415
-            printf("'%s' -> %d/%d ret:%d\n",
416
-                   rates[i], q.num, q.den, ret);
417
-        }
418
-    }
419
-
420
-    printf("\nTesting av_parse_color()\n");
421
-    {
422
-        int i;
423
-        uint8_t rgba[4];
424
-        const char *color_names[] = {
425
-            "bikeshed",
426
-            "RaNdOm",
427
-            "foo",
428
-            "red",
429
-            "Red ",
430
-            "RED",
431
-            "Violet",
432
-            "Yellow",
433
-            "Red",
434
-            "0x000000",
435
-            "0x0000000",
436
-            "0xff000000",
437
-            "0x3e34ff",
438
-            "0x3e34ffaa",
439
-            "0xffXXee",
440
-            "0xfoobar",
441
-            "0xffffeeeeeeee",
442
-            "#ff0000",
443
-            "#ffXX00",
444
-            "ff0000",
445
-            "ffXX00",
446
-            "red@foo",
447
-            "random@10",
448
-            "0xff0000@1.0",
449
-            "red@",
450
-            "red@0xfff",
451
-            "red@0xf",
452
-            "red@2",
453
-            "red@0.1",
454
-            "red@-1",
455
-            "red@0.5",
456
-            "red@1.0",
457
-            "red@256",
458
-            "red@10foo",
459
-            "red@-1.0",
460
-            "red@-0.0",
461
-        };
462
-
463
-        av_log_set_level(AV_LOG_DEBUG);
464
-
465
-        for (i = 0;  i < FF_ARRAY_ELEMS(color_names); i++) {
466
-            if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0)
467
-                printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]);
468
-        }
469
-    }
470
-
471
-    return 0;
472
-}
473
-
474
-#endif /* TEST */
475 1
deleted file mode 100644
... ...
@@ -1,75 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#ifndef AVCORE_PARSEUTILS_H
20
-#define AVCORE_PARSEUTILS_H
21
-
22
-#include "libavutil/rational.h"
23
-
24
-/**
25
- * @file
26
- * misc parsing utilities for libavcore
27
- */
28
-
29
-/**
30
- * Parse str and put in width_ptr and height_ptr the detected values.
31
- *
32
- * @param[in,out] width_ptr pointer to the variable which will contain the detected
33
- * width value
34
- * @param[in,out] height_ptr pointer to the variable which will contain the detected
35
- * height value
36
- * @param[in] str the string to parse: it has to be a string in the format
37
- * width x height or a valid video size abbreviation.
38
- * @return >= 0 on success, a negative error code otherwise
39
- */
40
-int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str);
41
-
42
-/**
43
- * Parse str and store the detected values in *rate.
44
- *
45
- * @param[in,out] rate pointer to the AVRational which will contain the detected
46
- * frame rate
47
- * @param[in] str the string to parse: it has to be a string in the format
48
- * rate_num / rate_den, a float number or a valid video rate abbreviation
49
- * @return >= 0 on success, a negative error code otherwise
50
- */
51
-int av_parse_video_rate(AVRational *rate, const char *str);
52
-
53
-/**
54
- * Put the RGBA values that correspond to color_string in rgba_color.
55
- *
56
- * @param color_string a string specifying a color. It can be the name of
57
- * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence,
58
- * possibly followed by "@" and a string representing the alpha
59
- * component.
60
- * The alpha component may be a string composed by "0x" followed by an
61
- * hexadecimal number or a decimal number between 0.0 and 1.0, which
62
- * represents the opacity value (0x00/0.0 means completely transparent,
63
- * 0xff/1.0 completely opaque).
64
- * If the alpha component is not specified then 0xff is assumed.
65
- * The string "random" will result in a random color.
66
- * @param slen length of the initial part of color_string containing the
67
- * color. It can be set to -1 if color_string is a null terminated string
68
- * containing nothing else than the color.
69
- * @return >= 0 in case of success, a negative value in case of
70
- * failure (for example if color_string cannot be parsed).
71
- */
72
-int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
73
-                   void *log_ctx);
74
-
75
-#endif /* AVCORE_PARSEUTILS_H */
76 1
deleted file mode 100644
... ...
@@ -1,70 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#include "avcore.h"
20
-#include "samplefmt.h"
21
-
22
-typedef struct SampleFmtInfo {
23
-    const char *name;
24
-    int bits;
25
-} SampleFmtInfo;
26
-
27
-/** this table gives more information about formats */
28
-static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = {
29
-    [AV_SAMPLE_FMT_U8]  = { .name = "u8",  .bits = 8 },
30
-    [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16 },
31
-    [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32 },
32
-    [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32 },
33
-    [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64 },
34
-};
35
-
36
-const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
37
-{
38
-    if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
39
-        return NULL;
40
-    return sample_fmt_info[sample_fmt].name;
41
-}
42
-
43
-enum AVSampleFormat av_get_sample_fmt(const char *name)
44
-{
45
-    int i;
46
-
47
-    for (i = 0; i < AV_SAMPLE_FMT_NB; i++)
48
-        if (!strcmp(sample_fmt_info[i].name, name))
49
-            return i;
50
-    return AV_SAMPLE_FMT_NONE;
51
-}
52
-
53
-char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt)
54
-{
55
-    /* print header */
56
-    if (sample_fmt < 0)
57
-        snprintf(buf, buf_size, "name  " " depth");
58
-    else if (sample_fmt < AV_SAMPLE_FMT_NB) {
59
-        SampleFmtInfo info = sample_fmt_info[sample_fmt];
60
-        snprintf (buf, buf_size, "%-6s" "   %2d ", info.name, info.bits);
61
-    }
62
-
63
-    return buf;
64
-}
65
-
66
-int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt)
67
-{
68
-    return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ?
69
-        0 : sample_fmt_info[sample_fmt].bits;
70
-}
71 1
deleted file mode 100644
... ...
@@ -1,72 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#ifndef AVCORE_SAMPLEFMT_H
20
-#define AVCORE_SAMPLEFMT_H
21
-
22
-#include "avcore.h"
23
-
24
-/**
25
- * all in native-endian format
26
- */
27
-enum AVSampleFormat {
28
-    AV_SAMPLE_FMT_NONE = -1,
29
-    AV_SAMPLE_FMT_U8,          ///< unsigned 8 bits
30
-    AV_SAMPLE_FMT_S16,         ///< signed 16 bits
31
-    AV_SAMPLE_FMT_S32,         ///< signed 32 bits
32
-    AV_SAMPLE_FMT_FLT,         ///< float
33
-    AV_SAMPLE_FMT_DBL,         ///< double
34
-    AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if dynamically linking to libavcore
35
-};
36
-
37
-/**
38
- * Return the name of sample_fmt, or NULL if sample_fmt is not
39
- * recognized.
40
- */
41
-const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
42
-
43
-/**
44
- * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
45
- * on error.
46
- */
47
-enum AVSampleFormat av_get_sample_fmt(const char *name);
48
-
49
-/**
50
- * Generate a string corresponding to the sample format with
51
- * sample_fmt, or a header if sample_fmt is negative.
52
- *
53
- * @param buf the buffer where to write the string
54
- * @param buf_size the size of buf
55
- * @param sample_fmt the number of the sample format to print the
56
- * corresponding info string, or a negative value to print the
57
- * corresponding header.
58
- * @return the pointer to the filled buffer or NULL if sample_fmt is
59
- * unknown or in case of other errors
60
- */
61
-char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
62
-
63
-/**
64
- * Return sample format bits per sample.
65
- *
66
- * @param sample_fmt the sample format
67
- * @return number of bits per sample or zero if unknown for the given
68
- * sample format
69
- */
70
-int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
71
-
72
-#endif /* AVCORE_SAMPLEFMT_H */
73 1
deleted file mode 100644
... ...
@@ -1,41 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#include "config.h"
20
-#include "avcore.h"
21
-
22
-/**
23
- * @file
24
- * various utility functions
25
- */
26
-
27
-unsigned avcore_version(void)
28
-{
29
-    return LIBAVCORE_VERSION_INT;
30
-}
31
-
32
-const char *avcore_configuration(void)
33
-{
34
-    return FFMPEG_CONFIGURATION;
35
-}
36
-
37
-const char *avcore_license(void)
38
-{
39
-#define LICENSE_PREFIX "libavcore license: "
40
-    return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
41
-}
... ...
@@ -1,7 +1,7 @@
1 1
 include $(SUBDIR)../config.mak
2 2
 
3 3
 NAME    = avdevice
4
-FFLIBS  = avformat avcodec avcore avutil
4
+FFLIBS  = avformat avcodec avutil
5 5
 
6 6
 HEADERS = avdevice.h
7 7
 
... ...
@@ -22,7 +22,7 @@
22 22
 #undef __STRICT_ANSI__ //workaround due to broken kernel headers
23 23
 #include "config.h"
24 24
 #include "libavutil/rational.h"
25
-#include "libavcore/imgutils.h"
25
+#include "libavutil/imgutils.h"
26 26
 #include "libavformat/avformat.h"
27 27
 #include "libavcodec/dsputil.h"
28 28
 #include <unistd.h>
... ...
@@ -43,7 +43,7 @@
43 43
 #endif
44 44
 #include <time.h>
45 45
 #include <strings.h>
46
-#include "libavcore/imgutils.h"
46
+#include "libavutil/imgutils.h"
47 47
 
48 48
 static const int desired_video_buffers = 256;
49 49
 
... ...
@@ -1,7 +1,7 @@
1 1
 include $(SUBDIR)../config.mak
2 2
 
3 3
 NAME = avfilter
4
-FFLIBS = avcore avutil
4
+FFLIBS = avutil
5 5
 FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec
6 6
 FFLIBS-$(CONFIG_SCALE_FILTER) += swscale
7 7
 
... ...
@@ -22,7 +22,7 @@
22 22
  */
23 23
 
24 24
 #include "avfilter.h"
25
-#include "libavcore/audioconvert.h"
25
+#include "libavutil/audioconvert.h"
26 26
 
27 27
 typedef struct {
28 28
     int64_t channel_layout;
... ...
@@ -23,8 +23,8 @@
23 23
 
24 24
 #include "libavutil/pixdesc.h"
25 25
 #include "libavutil/rational.h"
26
-#include "libavcore/audioconvert.h"
27
-#include "libavcore/imgutils.h"
26
+#include "libavutil/audioconvert.h"
27
+#include "libavutil/imgutils.h"
28 28
 #include "avfilter.h"
29 29
 #include "internal.h"
30 30
 
... ...
@@ -23,8 +23,7 @@
23 23
 #define AVFILTER_AVFILTER_H
24 24
 
25 25
 #include "libavutil/avutil.h"
26
-#include "libavcore/avcore.h"
27
-#include "libavcore/samplefmt.h"
26
+#include "libavutil/samplefmt.h"
28 27
 
29 28
 #define LIBAVFILTER_VERSION_MAJOR  1
30 29
 #define LIBAVFILTER_VERSION_MINOR 76
... ...
@@ -585,7 +584,7 @@ struct AVFilterLink {
585 585
     int h;                      ///< agreed upon image height
586 586
     AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
587 587
     /* These two parameters apply only to audio */
588
-    int64_t channel_layout;     ///< channel layout of current buffer (see libavcore/audioconvert.h)
588
+    int64_t channel_layout;     ///< channel layout of current buffer (see libavutil/audioconvert.h)
589 589
     int64_t sample_rate;        ///< samples per second
590 590
 
591 591
     int format;                 ///< agreed upon media format
... ...
@@ -19,9 +19,9 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-#include "libavcore/audioconvert.h"
23
-#include "libavcore/imgutils.h"
24
-#include "libavcore/samplefmt.h"
22
+#include "libavutil/audioconvert.h"
23
+#include "libavutil/imgutils.h"
24
+#include "libavutil/samplefmt.h"
25 25
 #include "avfilter.h"
26 26
 #include "internal.h"
27 27
 
... ...
@@ -29,7 +29,7 @@
29 29
 #include "libavutil/eval.h"
30 30
 #include "libavutil/avstring.h"
31 31
 #include "libavutil/libm.h"
32
-#include "libavcore/imgutils.h"
32
+#include "libavutil/imgutils.h"
33 33
 
34 34
 static const char *var_names[] = {
35 35
     "E",
... ...
@@ -23,7 +23,7 @@
23 23
  * Ported from MPlayer libmpcodecs/vf_cropdetect.c.
24 24
  */
25 25
 
26
-#include "libavcore/imgutils.h"
26
+#include "libavutil/imgutils.h"
27 27
 #include "avfilter.h"
28 28
 
29 29
 typedef struct {
... ...
@@ -26,7 +26,7 @@
26 26
 
27 27
 #include "libavutil/colorspace.h"
28 28
 #include "libavutil/pixdesc.h"
29
-#include "libavcore/parseutils.h"
29
+#include "libavutil/parseutils.h"
30 30
 #include "avfilter.h"
31 31
 
32 32
 enum { Y, U, V, A };
... ...
@@ -27,8 +27,8 @@
27 27
 #include <dlfcn.h>
28 28
 #include <frei0r.h>
29 29
 #include "libavutil/avstring.h"
30
-#include "libavcore/imgutils.h"
31
-#include "libavcore/parseutils.h"
30
+#include "libavutil/imgutils.h"
31
+#include "libavutil/parseutils.h"
32 32
 #include "avfilter.h"
33 33
 
34 34
 typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height);
... ...
@@ -32,7 +32,7 @@
32 32
  * Dither it back to 8bit.
33 33
  */
34 34
 
35
-#include "libavcore/imgutils.h"
35
+#include "libavutil/imgutils.h"
36 36
 #include "libavutil/cpu.h"
37 37
 #include "libavutil/pixdesc.h"
38 38
 #include "avfilter.h"
... ...
@@ -27,7 +27,7 @@
27 27
 #include "avfilter.h"
28 28
 #include "libavutil/pixdesc.h"
29 29
 #include "libavutil/intreadwrite.h"
30
-#include "libavcore/imgutils.h"
30
+#include "libavutil/imgutils.h"
31 31
 
32 32
 typedef struct {
33 33
     int max_step[4];    ///< max pixel step for each plane, expressed as a number of bytes
... ...
@@ -29,7 +29,7 @@
29 29
 #include "libavutil/eval.h"
30 30
 #include "libavutil/avstring.h"
31 31
 #include "libavutil/pixdesc.h"
32
-#include "libavcore/imgutils.h"
32
+#include "libavutil/imgutils.h"
33 33
 #include "internal.h"
34 34
 
35 35
 static const char *var_names[] = {
... ...
@@ -28,8 +28,8 @@
28 28
 #include "libavutil/pixdesc.h"
29 29
 #include "libavutil/colorspace.h"
30 30
 #include "libavutil/avassert.h"
31
-#include "libavcore/imgutils.h"
32
-#include "libavcore/parseutils.h"
31
+#include "libavutil/imgutils.h"
32
+#include "libavutil/parseutils.h"
33 33
 
34 34
 enum { RED = 0, GREEN, BLUE, ALPHA };
35 35
 
... ...
@@ -27,7 +27,7 @@
27 27
 
28 28
 #include "libavutil/intreadwrite.h"
29 29
 #include "libavutil/pixdesc.h"
30
-#include "libavcore/imgutils.h"
30
+#include "libavutil/imgutils.h"
31 31
 #include "avfilter.h"
32 32
 
33 33
 typedef struct {
... ...
@@ -25,7 +25,7 @@
25 25
 
26 26
 #include "avfilter.h"
27 27
 #include "vsrc_buffer.h"
28
-#include "libavcore/imgutils.h"
28
+#include "libavutil/imgutils.h"
29 29
 
30 30
 typedef struct {
31 31
     int64_t           pts;
... ...
@@ -33,7 +33,7 @@
33 33
 #include <float.h>
34 34
 #include "libavutil/avstring.h"
35 35
 #include "libavutil/opt.h"
36
-#include "libavcore/imgutils.h"
36
+#include "libavutil/imgutils.h"
37 37
 #include "libavformat/avformat.h"
38 38
 #include "avfilter.h"
39 39
 
... ...
@@ -23,7 +23,7 @@
23 23
 
24 24
 #include "libavutil/avstring.h"
25 25
 #include "libavutil/eval.h"
26
-#include "libavcore/parseutils.h"
26
+#include "libavutil/parseutils.h"
27 27
 #include "avfilter.h"
28 28
 
29 29
 static const char *var_names[] = {
... ...
@@ -1,7 +1,7 @@
1 1
 include $(SUBDIR)../config.mak
2 2
 
3 3
 NAME = avformat
4
-FFLIBS = avcodec avcore avutil
4
+FFLIBS = avcodec avutil
5 5
 
6 6
 HEADERS = avformat.h avio.h version.h
7 7
 
... ...
@@ -23,7 +23,7 @@
23 23
 #include "avformat.h"
24 24
 #include "pcm.h"
25 25
 #include "libavutil/intreadwrite.h"
26
-#include "libavcore/audioconvert.h"
26
+#include "libavutil/audioconvert.h"
27 27
 
28 28
 #define AT1_SU_SIZE     212
29 29
 
... ...
@@ -32,8 +32,8 @@
32 32
  */
33 33
 
34 34
 #include "libavutil/intreadwrite.h"
35
+#include "libavutil/audioconvert.h"
35 36
 #include "avformat.h"
36
-#include "libavcore/audioconvert.h"
37 37
 
38 38
 #define FLIC_FILE_MAGIC_1 0xAF11
39 39
 #define FLIC_FILE_MAGIC_2 0xAF12
... ...
@@ -26,7 +26,7 @@
26 26
 #include "avc.h"
27 27
 #include "flacenc.h"
28 28
 #include "avlanguage.h"
29
-#include "libavcore/samplefmt.h"
29
+#include "libavutil/samplefmt.h"
30 30
 #include "libavutil/intreadwrite.h"
31 31
 #include "libavutil/random_seed.h"
32 32
 #include "libavutil/lfg.h"
... ...
@@ -3341,7 +3341,7 @@ void dump_format(AVFormatContext *ic,
3341 3341
 }
3342 3342
 
3343 3343
 #if FF_API_PARSE_FRAME_PARAM
3344
-#include "libavcore/parseutils.h"
3344
+#include "libavutil/parseutils.h"
3345 3345
 
3346 3346
 int parse_image_size(int *width_ptr, int *height_ptr, const char *str)
3347 3347
 {
... ...
@@ -19,11 +19,11 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
+#include "libavutil/audioconvert.h"
22 23
 #include "libavutil/intreadwrite.h"
23 24
 #include "avformat.h"
24 25
 #include "apetag.h"
25 26
 #include "id3v1.h"
26
-#include "libavcore/audioconvert.h"
27 27
 
28 28
 // specs say that maximum block size is 1Mb
29 29
 #define WV_BLOCK_LIMIT 1047576
... ...
@@ -4,6 +4,7 @@ NAME = avutil
4 4
 
5 5
 HEADERS = adler32.h                                                     \
6 6
           attributes.h                                                  \
7
+          audioconvert.h                                                \
7 8
           avassert.h                                                    \
8 9
           avstring.h                                                    \
9 10
           avutil.h                                                      \
... ...
@@ -16,6 +17,7 @@ HEADERS = adler32.h                                                     \
16 16
           eval.h                                                        \
17 17
           fifo.h                                                        \
18 18
           file.h                                                        \
19
+          imgutils.h                                                    \
19 20
           intfloat_readwrite.h                                          \
20 21
           intreadwrite.h                                                \
21 22
           lfg.h                                                         \
... ...
@@ -25,16 +27,19 @@ HEADERS = adler32.h                                                     \
25 25
           md5.h                                                         \
26 26
           mem.h                                                         \
27 27
           opt.h                                                         \
28
+          parseutils.h                                                  \
28 29
           pixdesc.h                                                     \
29 30
           pixfmt.h                                                      \
30 31
           random_seed.h                                                 \
31 32
           rational.h                                                    \
33
+          samplefmt.h                                                   \
32 34
           sha1.h                                                        \
33 35
 
34 36
 BUILT_HEADERS = avconfig.h
35 37
 
36 38
 OBJS = adler32.o                                                        \
37 39
        aes.o                                                            \
40
+       audioconvert.o                                                   \
38 41
        avstring.o                                                       \
39 42
        base64.o                                                         \
40 43
        cpu.o                                                            \
... ...
@@ -44,6 +49,7 @@ OBJS = adler32.o                                                        \
44 44
        eval.o                                                           \
45 45
        fifo.o                                                           \
46 46
        file.o                                                           \
47
+       imgutils.o                                                       \
47 48
        intfloat_readwrite.o                                             \
48 49
        inverse.o                                                        \
49 50
        lfg.o                                                            \
... ...
@@ -54,10 +60,12 @@ OBJS = adler32.o                                                        \
54 54
        md5.o                                                            \
55 55
        mem.o                                                            \
56 56
        opt.o                                                            \
57
+       parseutils.o                                                     \
57 58
        pixdesc.o                                                        \
58 59
        random_seed.o                                                    \
59 60
        rational.o                                                       \
60 61
        rc4.o                                                            \
62
+       samplefmt.o                                                      \
61 63
        sha.o                                                            \
62 64
        tree.o                                                           \
63 65
        utils.o                                                          \
64 66
new file mode 100644
... ...
@@ -0,0 +1,117 @@
0
+/*
1
+ * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
2
+ *
3
+ * This file is part of FFmpeg.
4
+ *
5
+ * FFmpeg 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
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+/**
21
+ * @file
22
+ * audio conversion routines
23
+ */
24
+
25
+#include "libavutil/avutil.h"
26
+#include "libavutil/avstring.h"
27
+#include "audioconvert.h"
28
+
29
+static const char * const channel_names[] = {
30
+    "FL", "FR", "FC", "LFE", "BL",  "BR",  "FLC", "FRC",
31
+    "BC", "SL", "SR", "TC",  "TFL", "TFC", "TFR", "TBL",
32
+    "TBC", "TBR",
33
+    [29] = "DL",
34
+    [30] = "DR",
35
+};
36
+
37
+static const char *get_channel_name(int channel_id)
38
+{
39
+    if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names))
40
+        return NULL;
41
+    return channel_names[channel_id];
42
+}
43
+
44
+static const struct {
45
+    const char *name;
46
+    int         nb_channels;
47
+    int64_t     layout;
48
+} channel_layout_map[] = {
49
+    { "mono",        1,  AV_CH_LAYOUT_MONO },
50
+    { "stereo",      2,  AV_CH_LAYOUT_STEREO },
51
+    { "4.0",         4,  AV_CH_LAYOUT_4POINT0 },
52
+    { "quad",        4,  AV_CH_LAYOUT_QUAD },
53
+    { "5.0",         5,  AV_CH_LAYOUT_5POINT0 },
54
+    { "5.0",         5,  AV_CH_LAYOUT_5POINT0_BACK },
55
+    { "5.1",         6,  AV_CH_LAYOUT_5POINT1 },
56
+    { "5.1",         6,  AV_CH_LAYOUT_5POINT1_BACK },
57
+    { "5.1+downmix", 8,  AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
58
+    { "7.1",         8,  AV_CH_LAYOUT_7POINT1 },
59
+    { "7.1(wide)",   8,  AV_CH_LAYOUT_7POINT1_WIDE },
60
+    { "7.1+downmix", 10, AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, },
61
+    { 0 }
62
+};
63
+
64
+int64_t av_get_channel_layout(const char *name)
65
+{
66
+    int i = 0;
67
+    do {
68
+        if (!strcmp(channel_layout_map[i].name, name))
69
+            return channel_layout_map[i].layout;
70
+        i++;
71
+    } while (channel_layout_map[i].name);
72
+
73
+    return 0;
74
+}
75
+
76
+void av_get_channel_layout_string(char *buf, int buf_size,
77
+                                  int nb_channels, int64_t channel_layout)
78
+{
79
+    int i;
80
+
81
+    if (nb_channels <= 0)
82
+        nb_channels = av_get_channel_layout_nb_channels(channel_layout);
83
+
84
+    for (i = 0; channel_layout_map[i].name; i++)
85
+        if (nb_channels    == channel_layout_map[i].nb_channels &&
86
+            channel_layout == channel_layout_map[i].layout) {
87
+            av_strlcpy(buf, channel_layout_map[i].name, buf_size);
88
+            return;
89
+        }
90
+
91
+    snprintf(buf, buf_size, "%d channels", nb_channels);
92
+    if (channel_layout) {
93
+        int i,ch;
94
+        av_strlcat(buf, " (", buf_size);
95
+        for(i=0,ch=0; i<64; i++) {
96
+            if ((channel_layout & (1L<<i))) {
97
+                const char *name = get_channel_name(i);
98
+                if (name) {
99
+                    if (ch>0) av_strlcat(buf, "|", buf_size);
100
+                    av_strlcat(buf, name, buf_size);
101
+                }
102
+                ch++;
103
+            }
104
+        }
105
+        av_strlcat(buf, ")", buf_size);
106
+    }
107
+}
108
+
109
+int av_get_channel_layout_nb_channels(int64_t channel_layout)
110
+{
111
+    int count;
112
+    uint64_t x = channel_layout;
113
+    for (count = 0; x; count++)
114
+        x &= x-1; // unset lowest set bit
115
+    return count;
116
+}
0 117
new file mode 100644
... ...
@@ -0,0 +1,95 @@
0
+/*
1
+ * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
2
+ * Copyright (c) 2008 Peter Ross
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+#ifndef AVUTIL_AUDIOCONVERT_H
22
+#define AVUTIL_AUDIOCONVERT_H
23
+
24
+#include <stdint.h>
25
+
26
+/**
27
+ * @file
28
+ * audio conversion routines
29
+ */
30
+
31
+/* Audio channel masks */
32
+#define AV_CH_FRONT_LEFT             0x00000001
33
+#define AV_CH_FRONT_RIGHT            0x00000002
34
+#define AV_CH_FRONT_CENTER           0x00000004
35
+#define AV_CH_LOW_FREQUENCY          0x00000008
36
+#define AV_CH_BACK_LEFT              0x00000010
37
+#define AV_CH_BACK_RIGHT             0x00000020
38
+#define AV_CH_FRONT_LEFT_OF_CENTER   0x00000040
39
+#define AV_CH_FRONT_RIGHT_OF_CENTER  0x00000080
40
+#define AV_CH_BACK_CENTER            0x00000100
41
+#define AV_CH_SIDE_LEFT              0x00000200
42
+#define AV_CH_SIDE_RIGHT             0x00000400
43
+#define AV_CH_TOP_CENTER             0x00000800
44
+#define AV_CH_TOP_FRONT_LEFT         0x00001000
45
+#define AV_CH_TOP_FRONT_CENTER       0x00002000
46
+#define AV_CH_TOP_FRONT_RIGHT        0x00004000
47
+#define AV_CH_TOP_BACK_LEFT          0x00008000
48
+#define AV_CH_TOP_BACK_CENTER        0x00010000
49
+#define AV_CH_TOP_BACK_RIGHT         0x00020000
50
+#define AV_CH_STEREO_LEFT            0x20000000  ///< Stereo downmix.
51
+#define AV_CH_STEREO_RIGHT           0x40000000  ///< See AV_CH_STEREO_LEFT.
52
+
53
+/** Channel mask value used for AVCodecContext.request_channel_layout
54
+    to indicate that the user requests the channel order of the decoder output
55
+    to be the native codec channel order. */
56
+#define AV_CH_LAYOUT_NATIVE          0x8000000000000000LL
57
+
58
+/* Audio channel convenience macros */
59
+#define AV_CH_LAYOUT_MONO              (AV_CH_FRONT_CENTER)
60
+#define AV_CH_LAYOUT_STEREO            (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
61
+#define AV_CH_LAYOUT_2_1               (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
62
+#define AV_CH_LAYOUT_SURROUND          (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
63
+#define AV_CH_LAYOUT_4POINT0           (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
64
+#define AV_CH_LAYOUT_2_2               (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
65
+#define AV_CH_LAYOUT_QUAD              (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
66
+#define AV_CH_LAYOUT_5POINT0           (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
67
+#define AV_CH_LAYOUT_5POINT1           (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
68
+#define AV_CH_LAYOUT_5POINT0_BACK      (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
69
+#define AV_CH_LAYOUT_5POINT1_BACK      (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
70
+#define AV_CH_LAYOUT_7POINT0           (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
71
+#define AV_CH_LAYOUT_7POINT1           (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
72
+#define AV_CH_LAYOUT_7POINT1_WIDE      (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
73
+#define AV_CH_LAYOUT_STEREO_DOWNMIX    (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
74
+
75
+/**
76
+ * Return a channel layout id that matches name, 0 if no match.
77
+ */
78
+int64_t av_get_channel_layout(const char *name);
79
+
80
+/**
81
+ * Return a description of a channel layout.
82
+ * If nb_channels is <= 0, it is guessed from the channel_layout.
83
+ *
84
+ * @param buf put here the string containing the channel layout
85
+ * @param buf_size size in bytes of the buffer
86
+ */
87
+void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
88
+
89
+/**
90
+ * Return the number of channels in the channel layout.
91
+ */
92
+int av_get_channel_layout_nb_channels(int64_t channel_layout);
93
+
94
+#endif /* AVUTIL_AUDIOCONVERT_H */
... ...
@@ -40,7 +40,7 @@
40 40
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41 41
 
42 42
 #define LIBAVUTIL_VERSION_MAJOR 50
43
-#define LIBAVUTIL_VERSION_MINOR 37
43
+#define LIBAVUTIL_VERSION_MINOR 38
44 44
 #define LIBAVUTIL_VERSION_MICRO  0
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
... ...
@@ -93,6 +93,18 @@ enum AVMediaType {
93 93
 
94 94
 #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
95 95
 
96
+#define AV_NOPTS_VALUE          INT64_C(0x8000000000000000)
97
+#define AV_TIME_BASE            1000000
98
+#define AV_TIME_BASE_Q          (AVRational){1, AV_TIME_BASE}
99
+
100
+/**
101
+ * Those FF_API_* defines are not part of public API.
102
+ * They may change, break or disappear at any time.
103
+ */
104
+#ifndef FF_API_OLD_IMAGE_NAMES
105
+#define FF_API_OLD_IMAGE_NAMES (LIBAVUTIL_VERSION_MAJOR < 51)
106
+#endif
107
+
96 108
 #include "common.h"
97 109
 #include "error.h"
98 110
 #include "mathematics.h"
99 111
new file mode 100644
... ...
@@ -0,0 +1,297 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+/**
19
+ * @file
20
+ * misc image utilities
21
+ */
22
+
23
+#include "imgutils.h"
24
+#include "internal.h"
25
+#include "libavutil/pixdesc.h"
26
+
27
+void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
28
+                                const AVPixFmtDescriptor *pixdesc)
29
+{
30
+    int i;
31
+    memset(max_pixsteps, 0, 4*sizeof(max_pixsteps[0]));
32
+    if (max_pixstep_comps)
33
+        memset(max_pixstep_comps, 0, 4*sizeof(max_pixstep_comps[0]));
34
+
35
+    for (i = 0; i < 4; i++) {
36
+        const AVComponentDescriptor *comp = &(pixdesc->comp[i]);
37
+        if ((comp->step_minus1+1) > max_pixsteps[comp->plane]) {
38
+            max_pixsteps[comp->plane] = comp->step_minus1+1;
39
+            if (max_pixstep_comps)
40
+                max_pixstep_comps[comp->plane] = i;
41
+        }
42
+    }
43
+}
44
+
45
+int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane)
46
+{
47
+    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
48
+    int max_step     [4];       /* max pixel step for each plane */
49
+    int max_step_comp[4];       /* the component for each plane which has the max pixel step */
50
+    int s;
51
+
52
+    if (desc->flags & PIX_FMT_BITSTREAM)
53
+        return (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
54
+
55
+    av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
56
+    s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->log2_chroma_w : 0;
57
+    return max_step[plane] * (((width + (1 << s) - 1)) >> s);
58
+}
59
+
60
+int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
61
+{
62
+    int i;
63
+    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
64
+    int max_step     [4];       /* max pixel step for each plane */
65
+    int max_step_comp[4];       /* the component for each plane which has the max pixel step */
66
+
67
+    memset(linesizes, 0, 4*sizeof(linesizes[0]));
68
+
69
+    if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
70
+        return AVERROR(EINVAL);
71
+
72
+    if (desc->flags & PIX_FMT_BITSTREAM) {
73
+        if (width > (INT_MAX -7) / (desc->comp[0].step_minus1+1))
74
+            return AVERROR(EINVAL);
75
+        linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
76
+        return 0;
77
+    }
78
+
79
+    av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
80
+    for (i = 0; i < 4; i++) {
81
+        int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0;
82
+        int shifted_w = ((width + (1 << s) - 1)) >> s;
83
+        if (max_step[i] > INT_MAX / shifted_w)
84
+            return AVERROR(EINVAL);
85
+        linesizes[i] = max_step[i] * shifted_w;
86
+    }
87
+
88
+    return 0;
89
+}
90
+
91
+int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
92
+                           uint8_t *ptr, const int linesizes[4])
93
+{
94
+    int i, total_size, size[4], has_plane[4];
95
+
96
+    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
97
+    memset(data     , 0, sizeof(data[0])*4);
98
+    memset(size     , 0, sizeof(size));
99
+    memset(has_plane, 0, sizeof(has_plane));
100
+
101
+    if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
102
+        return AVERROR(EINVAL);
103
+
104
+    data[0] = ptr;
105
+    if (linesizes[0] > (INT_MAX - 1024) / height)
106
+        return AVERROR(EINVAL);
107
+    size[0] = linesizes[0] * height;
108
+
109
+    if (desc->flags & PIX_FMT_PAL) {
110
+        size[0] = (size[0] + 3) & ~3;
111
+        data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */
112
+        return size[0] + 256 * 4;
113
+    }
114
+
115
+    for (i = 0; i < 4; i++)
116
+        has_plane[desc->comp[i].plane] = 1;
117
+
118
+    total_size = size[0];
119
+    for (i = 1; has_plane[i] && i < 4; i++) {
120
+        int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
121
+        data[i] = data[i-1] + size[i-1];
122
+        h = (height + (1 << s) - 1) >> s;
123
+        if (linesizes[i] > INT_MAX / h)
124
+            return AVERROR(EINVAL);
125
+        size[i] = h * linesizes[i];
126
+        if (total_size > INT_MAX - size[i])
127
+            return AVERROR(EINVAL);
128
+        total_size += size[i];
129
+    }
130
+
131
+    return total_size;
132
+}
133
+
134
+int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt)
135
+{
136
+    int i;
137
+
138
+    for (i = 0; i < 256; i++) {
139
+        int r, g, b;
140
+
141
+        switch (pix_fmt) {
142
+        case PIX_FMT_RGB8:
143
+            r = (i>>5    )*36;
144
+            g = ((i>>2)&7)*36;
145
+            b = (i&3     )*85;
146
+            break;
147
+        case PIX_FMT_BGR8:
148
+            b = (i>>6    )*85;
149
+            g = ((i>>3)&7)*36;
150
+            r = (i&7     )*36;
151
+            break;
152
+        case PIX_FMT_RGB4_BYTE:
153
+            r = (i>>3    )*255;
154
+            g = ((i>>1)&3)*85;
155
+            b = (i&1     )*255;
156
+            break;
157
+        case PIX_FMT_BGR4_BYTE:
158
+            b = (i>>3    )*255;
159
+            g = ((i>>1)&3)*85;
160
+            r = (i&1     )*255;
161
+            break;
162
+        case PIX_FMT_GRAY8:
163
+            r = b = g = i;
164
+            break;
165
+        default:
166
+            return AVERROR(EINVAL);
167
+        }
168
+        pal[i] = b + (g<<8) + (r<<16);
169
+    }
170
+
171
+    return 0;
172
+}
173
+
174
+int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
175
+                   int w, int h, enum PixelFormat pix_fmt, int align)
176
+{
177
+    int i, ret;
178
+    uint8_t *buf;
179
+
180
+    if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)
181
+        return ret;
182
+    if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, w)) < 0)
183
+        return ret;
184
+
185
+    for (i = 0; i < 4; i++)
186
+        linesizes[i] = FFALIGN(linesizes[i], align);
187
+
188
+    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)
189
+        return ret;
190
+    buf = av_malloc(ret + align);
191
+    if (!buf)
192
+        return AVERROR(ENOMEM);
193
+    if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {
194
+        av_free(buf);
195
+        return ret;
196
+    }
197
+    if (av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_PAL)
198
+        ff_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
199
+
200
+    return ret;
201
+}
202
+
203
+typedef struct ImgUtils {
204
+    const AVClass *class;
205
+    int   log_offset;
206
+    void *log_ctx;
207
+} ImgUtils;
208
+
209
+static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) };
210
+
211
+int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
212
+{
213
+    ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
214
+
215
+    if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
216
+        return 0;
217
+
218
+    av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
219
+    return AVERROR(EINVAL);
220
+}
221
+
222
+void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
223
+                         const uint8_t *src, int src_linesize,
224
+                         int bytewidth, int height)
225
+{
226
+    if (!dst || !src)
227
+        return;
228
+    for (;height > 0; height--) {
229
+        memcpy(dst, src, bytewidth);
230
+        dst += dst_linesize;
231
+        src += src_linesize;
232
+    }
233
+}
234
+
235
+void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
236
+                   const uint8_t *src_data[4], const int src_linesizes[4],
237
+                   enum PixelFormat pix_fmt, int width, int height)
238
+{
239
+    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
240
+
241
+    if (desc->flags & PIX_FMT_HWACCEL)
242
+        return;
243
+
244
+    if (desc->flags & PIX_FMT_PAL) {
245
+        av_image_copy_plane(dst_data[0], dst_linesizes[0],
246
+                            src_data[0], src_linesizes[0],
247
+                            width, height);
248
+        /* copy the palette */
249
+        memcpy(dst_data[1], src_data[1], 4*256);
250
+    } else {
251
+        int i, planes_nb = 0;
252
+
253
+        for (i = 0; i < desc->nb_components; i++)
254
+            planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
255
+
256
+        for (i = 0; i < planes_nb; i++) {
257
+            int h = height;
258
+            int bwidth = av_image_get_linesize(pix_fmt, width, i);
259
+            if (i == 1 || i == 2) {
260
+                h= -((-height)>>desc->log2_chroma_h);
261
+            }
262
+            av_image_copy_plane(dst_data[i], dst_linesizes[i],
263
+                                src_data[i], src_linesizes[i],
264
+                                bwidth, h);
265
+        }
266
+    }
267
+}
268
+
269
+#if FF_API_OLD_IMAGE_NAMES
270
+void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
271
+                                const AVPixFmtDescriptor *pixdesc)
272
+{
273
+    av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, pixdesc);
274
+}
275
+
276
+int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane)
277
+{
278
+    return av_image_get_linesize(pix_fmt, width, plane);
279
+}
280
+
281
+int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
282
+{
283
+    return av_image_fill_linesizes(linesizes, pix_fmt, width);
284
+}
285
+
286
+int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
287
+                           uint8_t *ptr, const int linesizes[4])
288
+{
289
+    return av_image_fill_pointers(data, pix_fmt, height, ptr, linesizes);
290
+}
291
+
292
+int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
293
+{
294
+    return av_image_check_size(w, h, log_offset, log_ctx);
295
+}
296
+#endif
0 297
new file mode 100644
... ...
@@ -0,0 +1,149 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#ifndef AVUTIL_IMGUTILS_H
19
+#define AVUTIL_IMGUTILS_H
20
+
21
+/**
22
+ * @file
23
+ * misc image utilities
24
+ */
25
+
26
+#include "libavutil/pixdesc.h"
27
+#include "avutil.h"
28
+
29
+/**
30
+ * Compute the max pixel step for each plane of an image with a
31
+ * format described by pixdesc.
32
+ *
33
+ * The pixel step is the distance in bytes between the first byte of
34
+ * the group of bytes which describe a pixel component and the first
35
+ * byte of the successive group in the same plane for the same
36
+ * component.
37
+ *
38
+ * @param max_pixsteps an array which is filled with the max pixel step
39
+ * for each plane. Since a plane may contain different pixel
40
+ * components, the computed max_pixsteps[plane] is relative to the
41
+ * component in the plane with the max pixel step.
42
+ * @param max_pixstep_comps an array which is filled with the component
43
+ * for each plane which has the max pixel step. May be NULL.
44
+ */
45
+void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
46
+                                const AVPixFmtDescriptor *pixdesc);
47
+
48
+/**
49
+ * Compute the size of an image line with format pix_fmt and width
50
+ * width for the plane plane.
51
+ *
52
+ * @return the computed size in bytes
53
+ */
54
+int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane);
55
+
56
+/**
57
+ * Fill plane linesizes for an image with pixel format pix_fmt and
58
+ * width width.
59
+ *
60
+ * @param linesizes array to be filled with the linesize for each plane
61
+ * @return >= 0 in case of success, a negative error code otherwise
62
+ */
63
+int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width);
64
+
65
+/**
66
+ * Fill plane data pointers for an image with pixel format pix_fmt and
67
+ * height height.
68
+ *
69
+ * @param data pointers array to be filled with the pointer for each image plane
70
+ * @param ptr the pointer to a buffer which will contain the image
71
+ * @param linesizes[4] the array containing the linesize for each
72
+ * plane, should be filled by av_image_fill_linesizes()
73
+ * @return the size in bytes required for the image buffer, a negative
74
+ * error code in case of failure
75
+ */
76
+int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
77
+                           uint8_t *ptr, const int linesizes[4]);
78
+
79
+/**
80
+ * Allocate an image with size w and h and pixel format pix_fmt, and
81
+ * fill pointers and linesizes accordingly.
82
+ * The allocated image buffer has to be freed by using
83
+ * av_freep(&pointers[0]).
84
+ *
85
+ * @param align the value to use for buffer size alignment
86
+ * @return the size in bytes required for the image buffer, a negative
87
+ * error code in case of failure
88
+ */
89
+int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
90
+                   int w, int h, enum PixelFormat pix_fmt, int align);
91
+
92
+/**
93
+ * Copy image plane from src to dst.
94
+ * That is, copy "height" number of lines of "bytewidth" bytes each.
95
+ * The first byte of each successive line is separated by *_linesize
96
+ * bytes.
97
+ *
98
+ * @param dst_linesize linesize for the image plane in dst
99
+ * @param src_linesize linesize for the image plane in src
100
+ */
101
+void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
102
+                         const uint8_t *src, int src_linesize,
103
+                         int bytewidth, int height);
104
+
105
+/**
106
+ * Copy image in src_data to dst_data.
107
+ *
108
+ * @param dst_linesize linesizes for the image in dst_data
109
+ * @param src_linesize linesizes for the image in src_data
110
+ */
111
+void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
112
+                   const uint8_t *src_data[4], const int src_linesizes[4],
113
+                   enum PixelFormat pix_fmt, int width, int height);
114
+
115
+/**
116
+ * Check if the given dimension of an image is valid, meaning that all
117
+ * bytes of the image can be addressed with a signed int.
118
+ *
119
+ * @param w the width of the picture
120
+ * @param h the height of the picture
121
+ * @param log_offset the offset to sum to the log level for logging with log_ctx
122
+ * @param log_ctx the parent logging context, it may be NULL
123
+ * @return >= 0 if valid, a negative error code otherwise
124
+ */
125
+int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
126
+
127
+int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt);
128
+
129
+#if FF_API_OLD_IMAGE_NAMES
130
+attribute_deprecated
131
+void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
132
+                                const AVPixFmtDescriptor *pixdesc);
133
+
134
+attribute_deprecated
135
+int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane);
136
+
137
+attribute_deprecated
138
+int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width);
139
+
140
+attribute_deprecated
141
+int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
142
+                           uint8_t *ptr, const int linesizes[4]);
143
+
144
+attribute_deprecated
145
+int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
146
+#endif
147
+
148
+#endif /* AVUTIL_IMGUTILS_H */
0 149
new file mode 100644
... ...
@@ -0,0 +1,474 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+/**
19
+ * @file
20
+ * misc parsing utilities
21
+ */
22
+
23
+#include <strings.h>
24
+#include "parseutils.h"
25
+#include "libavutil/avutil.h"
26
+#include "libavutil/eval.h"
27
+#include "libavutil/avstring.h"
28
+#include "libavutil/random_seed.h"
29
+
30
+typedef struct {
31
+    const char *abbr;
32
+    int width, height;
33
+} VideoSizeAbbr;
34
+
35
+typedef struct {
36
+    const char *abbr;
37
+    AVRational rate;
38
+} VideoRateAbbr;
39
+
40
+static const VideoSizeAbbr video_size_abbrs[] = {
41
+    { "ntsc",      720, 480 },
42
+    { "pal",       720, 576 },
43
+    { "qntsc",     352, 240 }, /* VCD compliant NTSC */
44
+    { "qpal",      352, 288 }, /* VCD compliant PAL */
45
+    { "sntsc",     640, 480 }, /* square pixel NTSC */
46
+    { "spal",      768, 576 }, /* square pixel PAL */
47
+    { "film",      352, 240 },
48
+    { "ntsc-film", 352, 240 },
49
+    { "sqcif",     128,  96 },
50
+    { "qcif",      176, 144 },
51
+    { "cif",       352, 288 },
52
+    { "4cif",      704, 576 },
53
+    { "16cif",    1408,1152 },
54
+    { "qqvga",     160, 120 },
55
+    { "qvga",      320, 240 },
56
+    { "vga",       640, 480 },
57
+    { "svga",      800, 600 },
58
+    { "xga",      1024, 768 },
59
+    { "uxga",     1600,1200 },
60
+    { "qxga",     2048,1536 },
61
+    { "sxga",     1280,1024 },
62
+    { "qsxga",    2560,2048 },
63
+    { "hsxga",    5120,4096 },
64
+    { "wvga",      852, 480 },
65
+    { "wxga",     1366, 768 },
66
+    { "wsxga",    1600,1024 },
67
+    { "wuxga",    1920,1200 },
68
+    { "woxga",    2560,1600 },
69
+    { "wqsxga",   3200,2048 },
70
+    { "wquxga",   3840,2400 },
71
+    { "whsxga",   6400,4096 },
72
+    { "whuxga",   7680,4800 },
73
+    { "cga",       320, 200 },
74
+    { "ega",       640, 350 },
75
+    { "hd480",     852, 480 },
76
+    { "hd720",    1280, 720 },
77
+    { "hd1080",   1920,1080 },
78
+};
79
+
80
+static const VideoRateAbbr video_rate_abbrs[]= {
81
+    { "ntsc",      { 30000, 1001 } },
82
+    { "pal",       {    25,    1 } },
83
+    { "qntsc",     { 30000, 1001 } }, /* VCD compliant NTSC */
84
+    { "qpal",      {    25,    1 } }, /* VCD compliant PAL */
85
+    { "sntsc",     { 30000, 1001 } }, /* square pixel NTSC */
86
+    { "spal",      {    25,    1 } }, /* square pixel PAL */
87
+    { "film",      {    24,    1 } },
88
+    { "ntsc-film", { 24000, 1001 } },
89
+};
90
+
91
+int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
92
+{
93
+    int i;
94
+    int n = FF_ARRAY_ELEMS(video_size_abbrs);
95
+    char *p;
96
+    int width = 0, height = 0;
97
+
98
+    for (i = 0; i < n; i++) {
99
+        if (!strcmp(video_size_abbrs[i].abbr, str)) {
100
+            width  = video_size_abbrs[i].width;
101
+            height = video_size_abbrs[i].height;
102
+            break;
103
+        }
104
+    }
105
+    if (i == n) {
106
+        p = str;
107
+        width = strtol(p, &p, 10);
108
+        if (*p)
109
+            p++;
110
+        height = strtol(p, &p, 10);
111
+    }
112
+    if (width <= 0 || height <= 0)
113
+        return AVERROR(EINVAL);
114
+    *width_ptr  = width;
115
+    *height_ptr = height;
116
+    return 0;
117
+}
118
+
119
+int av_parse_video_rate(AVRational *rate, const char *arg)
120
+{
121
+    int i, ret;
122
+    int n = FF_ARRAY_ELEMS(video_rate_abbrs);
123
+    double res;
124
+
125
+    /* First, we check our abbreviation table */
126
+    for (i = 0; i < n; ++i)
127
+        if (!strcmp(video_rate_abbrs[i].abbr, arg)) {
128
+            *rate = video_rate_abbrs[i].rate;
129
+            return 0;
130
+        }
131
+
132
+    /* Then, we try to parse it as fraction */
133
+    if ((ret = av_expr_parse_and_eval(&res, arg, NULL, NULL, NULL, NULL, NULL, NULL,
134
+                                      NULL, 0, NULL)) < 0)
135
+        return ret;
136
+    *rate = av_d2q(res, 1001000);
137
+    if (rate->num <= 0 || rate->den <= 0)
138
+        return AVERROR(EINVAL);
139
+    return 0;
140
+}
141
+
142
+typedef struct {
143
+    const char *name;            ///< a string representing the name of the color
144
+    uint8_t     rgb_color[3];    ///< RGB values for the color
145
+} ColorEntry;
146
+
147
+static ColorEntry color_table[] = {
148
+    { "AliceBlue",            { 0xF0, 0xF8, 0xFF } },
149
+    { "AntiqueWhite",         { 0xFA, 0xEB, 0xD7 } },
150
+    { "Aqua",                 { 0x00, 0xFF, 0xFF } },
151
+    { "Aquamarine",           { 0x7F, 0xFF, 0xD4 } },
152
+    { "Azure",                { 0xF0, 0xFF, 0xFF } },
153
+    { "Beige",                { 0xF5, 0xF5, 0xDC } },
154
+    { "Bisque",               { 0xFF, 0xE4, 0xC4 } },
155
+    { "Black",                { 0x00, 0x00, 0x00 } },
156
+    { "BlanchedAlmond",       { 0xFF, 0xEB, 0xCD } },
157
+    { "Blue",                 { 0x00, 0x00, 0xFF } },
158
+    { "BlueViolet",           { 0x8A, 0x2B, 0xE2 } },
159
+    { "Brown",                { 0xA5, 0x2A, 0x2A } },
160
+    { "BurlyWood",            { 0xDE, 0xB8, 0x87 } },
161
+    { "CadetBlue",            { 0x5F, 0x9E, 0xA0 } },
162
+    { "Chartreuse",           { 0x7F, 0xFF, 0x00 } },
163
+    { "Chocolate",            { 0xD2, 0x69, 0x1E } },
164
+    { "Coral",                { 0xFF, 0x7F, 0x50 } },
165
+    { "CornflowerBlue",       { 0x64, 0x95, 0xED } },
166
+    { "Cornsilk",             { 0xFF, 0xF8, 0xDC } },
167
+    { "Crimson",              { 0xDC, 0x14, 0x3C } },
168
+    { "Cyan",                 { 0x00, 0xFF, 0xFF } },
169
+    { "DarkBlue",             { 0x00, 0x00, 0x8B } },
170
+    { "DarkCyan",             { 0x00, 0x8B, 0x8B } },
171
+    { "DarkGoldenRod",        { 0xB8, 0x86, 0x0B } },
172
+    { "DarkGray",             { 0xA9, 0xA9, 0xA9 } },
173
+    { "DarkGreen",            { 0x00, 0x64, 0x00 } },
174
+    { "DarkKhaki",            { 0xBD, 0xB7, 0x6B } },
175
+    { "DarkMagenta",          { 0x8B, 0x00, 0x8B } },
176
+    { "DarkOliveGreen",       { 0x55, 0x6B, 0x2F } },
177
+    { "Darkorange",           { 0xFF, 0x8C, 0x00 } },
178
+    { "DarkOrchid",           { 0x99, 0x32, 0xCC } },
179
+    { "DarkRed",              { 0x8B, 0x00, 0x00 } },
180
+    { "DarkSalmon",           { 0xE9, 0x96, 0x7A } },
181
+    { "DarkSeaGreen",         { 0x8F, 0xBC, 0x8F } },
182
+    { "DarkSlateBlue",        { 0x48, 0x3D, 0x8B } },
183
+    { "DarkSlateGray",        { 0x2F, 0x4F, 0x4F } },
184
+    { "DarkTurquoise",        { 0x00, 0xCE, 0xD1 } },
185
+    { "DarkViolet",           { 0x94, 0x00, 0xD3 } },
186
+    { "DeepPink",             { 0xFF, 0x14, 0x93 } },
187
+    { "DeepSkyBlue",          { 0x00, 0xBF, 0xFF } },
188
+    { "DimGray",              { 0x69, 0x69, 0x69 } },
189
+    { "DodgerBlue",           { 0x1E, 0x90, 0xFF } },
190
+    { "FireBrick",            { 0xB2, 0x22, 0x22 } },
191
+    { "FloralWhite",          { 0xFF, 0xFA, 0xF0 } },
192
+    { "ForestGreen",          { 0x22, 0x8B, 0x22 } },
193
+    { "Fuchsia",              { 0xFF, 0x00, 0xFF } },
194
+    { "Gainsboro",            { 0xDC, 0xDC, 0xDC } },
195
+    { "GhostWhite",           { 0xF8, 0xF8, 0xFF } },
196
+    { "Gold",                 { 0xFF, 0xD7, 0x00 } },
197
+    { "GoldenRod",            { 0xDA, 0xA5, 0x20 } },
198
+    { "Gray",                 { 0x80, 0x80, 0x80 } },
199
+    { "Green",                { 0x00, 0x80, 0x00 } },
200
+    { "GreenYellow",          { 0xAD, 0xFF, 0x2F } },
201
+    { "HoneyDew",             { 0xF0, 0xFF, 0xF0 } },
202
+    { "HotPink",              { 0xFF, 0x69, 0xB4 } },
203
+    { "IndianRed",            { 0xCD, 0x5C, 0x5C } },
204
+    { "Indigo",               { 0x4B, 0x00, 0x82 } },
205
+    { "Ivory",                { 0xFF, 0xFF, 0xF0 } },
206
+    { "Khaki",                { 0xF0, 0xE6, 0x8C } },
207
+    { "Lavender",             { 0xE6, 0xE6, 0xFA } },
208
+    { "LavenderBlush",        { 0xFF, 0xF0, 0xF5 } },
209
+    { "LawnGreen",            { 0x7C, 0xFC, 0x00 } },
210
+    { "LemonChiffon",         { 0xFF, 0xFA, 0xCD } },
211
+    { "LightBlue",            { 0xAD, 0xD8, 0xE6 } },
212
+    { "LightCoral",           { 0xF0, 0x80, 0x80 } },
213
+    { "LightCyan",            { 0xE0, 0xFF, 0xFF } },
214
+    { "LightGoldenRodYellow", { 0xFA, 0xFA, 0xD2 } },
215
+    { "LightGrey",            { 0xD3, 0xD3, 0xD3 } },
216
+    { "LightGreen",           { 0x90, 0xEE, 0x90 } },
217
+    { "LightPink",            { 0xFF, 0xB6, 0xC1 } },
218
+    { "LightSalmon",          { 0xFF, 0xA0, 0x7A } },
219
+    { "LightSeaGreen",        { 0x20, 0xB2, 0xAA } },
220
+    { "LightSkyBlue",         { 0x87, 0xCE, 0xFA } },
221
+    { "LightSlateGray",       { 0x77, 0x88, 0x99 } },
222
+    { "LightSteelBlue",       { 0xB0, 0xC4, 0xDE } },
223
+    { "LightYellow",          { 0xFF, 0xFF, 0xE0 } },
224
+    { "Lime",                 { 0x00, 0xFF, 0x00 } },
225
+    { "LimeGreen",            { 0x32, 0xCD, 0x32 } },
226
+    { "Linen",                { 0xFA, 0xF0, 0xE6 } },
227
+    { "Magenta",              { 0xFF, 0x00, 0xFF } },
228
+    { "Maroon",               { 0x80, 0x00, 0x00 } },
229
+    { "MediumAquaMarine",     { 0x66, 0xCD, 0xAA } },
230
+    { "MediumBlue",           { 0x00, 0x00, 0xCD } },
231
+    { "MediumOrchid",         { 0xBA, 0x55, 0xD3 } },
232
+    { "MediumPurple",         { 0x93, 0x70, 0xD8 } },
233
+    { "MediumSeaGreen",       { 0x3C, 0xB3, 0x71 } },
234
+    { "MediumSlateBlue",      { 0x7B, 0x68, 0xEE } },
235
+    { "MediumSpringGreen",    { 0x00, 0xFA, 0x9A } },
236
+    { "MediumTurquoise",      { 0x48, 0xD1, 0xCC } },
237
+    { "MediumVioletRed",      { 0xC7, 0x15, 0x85 } },
238
+    { "MidnightBlue",         { 0x19, 0x19, 0x70 } },
239
+    { "MintCream",            { 0xF5, 0xFF, 0xFA } },
240
+    { "MistyRose",            { 0xFF, 0xE4, 0xE1 } },
241
+    { "Moccasin",             { 0xFF, 0xE4, 0xB5 } },
242
+    { "NavajoWhite",          { 0xFF, 0xDE, 0xAD } },
243
+    { "Navy",                 { 0x00, 0x00, 0x80 } },
244
+    { "OldLace",              { 0xFD, 0xF5, 0xE6 } },
245
+    { "Olive",                { 0x80, 0x80, 0x00 } },
246
+    { "OliveDrab",            { 0x6B, 0x8E, 0x23 } },
247
+    { "Orange",               { 0xFF, 0xA5, 0x00 } },
248
+    { "OrangeRed",            { 0xFF, 0x45, 0x00 } },
249
+    { "Orchid",               { 0xDA, 0x70, 0xD6 } },
250
+    { "PaleGoldenRod",        { 0xEE, 0xE8, 0xAA } },
251
+    { "PaleGreen",            { 0x98, 0xFB, 0x98 } },
252
+    { "PaleTurquoise",        { 0xAF, 0xEE, 0xEE } },
253
+    { "PaleVioletRed",        { 0xD8, 0x70, 0x93 } },
254
+    { "PapayaWhip",           { 0xFF, 0xEF, 0xD5 } },
255
+    { "PeachPuff",            { 0xFF, 0xDA, 0xB9 } },
256
+    { "Peru",                 { 0xCD, 0x85, 0x3F } },
257
+    { "Pink",                 { 0xFF, 0xC0, 0xCB } },
258
+    { "Plum",                 { 0xDD, 0xA0, 0xDD } },
259
+    { "PowderBlue",           { 0xB0, 0xE0, 0xE6 } },
260
+    { "Purple",               { 0x80, 0x00, 0x80 } },
261
+    { "Red",                  { 0xFF, 0x00, 0x00 } },
262
+    { "RosyBrown",            { 0xBC, 0x8F, 0x8F } },
263
+    { "RoyalBlue",            { 0x41, 0x69, 0xE1 } },
264
+    { "SaddleBrown",          { 0x8B, 0x45, 0x13 } },
265
+    { "Salmon",               { 0xFA, 0x80, 0x72 } },
266
+    { "SandyBrown",           { 0xF4, 0xA4, 0x60 } },
267
+    { "SeaGreen",             { 0x2E, 0x8B, 0x57 } },
268
+    { "SeaShell",             { 0xFF, 0xF5, 0xEE } },
269
+    { "Sienna",               { 0xA0, 0x52, 0x2D } },
270
+    { "Silver",               { 0xC0, 0xC0, 0xC0 } },
271
+    { "SkyBlue",              { 0x87, 0xCE, 0xEB } },
272
+    { "SlateBlue",            { 0x6A, 0x5A, 0xCD } },
273
+    { "SlateGray",            { 0x70, 0x80, 0x90 } },
274
+    { "Snow",                 { 0xFF, 0xFA, 0xFA } },
275
+    { "SpringGreen",          { 0x00, 0xFF, 0x7F } },
276
+    { "SteelBlue",            { 0x46, 0x82, 0xB4 } },
277
+    { "Tan",                  { 0xD2, 0xB4, 0x8C } },
278
+    { "Teal",                 { 0x00, 0x80, 0x80 } },
279
+    { "Thistle",              { 0xD8, 0xBF, 0xD8 } },
280
+    { "Tomato",               { 0xFF, 0x63, 0x47 } },
281
+    { "Turquoise",            { 0x40, 0xE0, 0xD0 } },
282
+    { "Violet",               { 0xEE, 0x82, 0xEE } },
283
+    { "Wheat",                { 0xF5, 0xDE, 0xB3 } },
284
+    { "White",                { 0xFF, 0xFF, 0xFF } },
285
+    { "WhiteSmoke",           { 0xF5, 0xF5, 0xF5 } },
286
+    { "Yellow",               { 0xFF, 0xFF, 0x00 } },
287
+    { "YellowGreen",          { 0x9A, 0xCD, 0x32 } },
288
+};
289
+
290
+static int color_table_compare(const void *lhs, const void *rhs)
291
+{
292
+    return strcasecmp(lhs, ((const ColorEntry *)rhs)->name);
293
+}
294
+
295
+#define ALPHA_SEP '@'
296
+
297
+int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
298
+                   void *log_ctx)
299
+{
300
+    char *tail, color_string2[128];
301
+    const ColorEntry *entry;
302
+    int len, hex_offset = 0;
303
+
304
+    if (color_string[0] == '#') {
305
+        hex_offset = 1;
306
+    } else if (!strncmp(color_string, "0x", 2))
307
+        hex_offset = 2;
308
+
309
+    if (slen < 0)
310
+        slen = strlen(color_string);
311
+    av_strlcpy(color_string2, color_string + hex_offset,
312
+               FFMIN(slen-hex_offset+1, sizeof(color_string2)));
313
+    if ((tail = strchr(color_string2, ALPHA_SEP)))
314
+        *tail++ = 0;
315
+    len = strlen(color_string2);
316
+    rgba_color[3] = 255;
317
+
318
+    if (!strcasecmp(color_string2, "random") || !strcasecmp(color_string2, "bikeshed")) {
319
+        int rgba = av_get_random_seed();
320
+        rgba_color[0] = rgba >> 24;
321
+        rgba_color[1] = rgba >> 16;
322
+        rgba_color[2] = rgba >> 8;
323
+        rgba_color[3] = rgba;
324
+    } else if (hex_offset ||
325
+               strspn(color_string2, "0123456789ABCDEFabcdef") == len) {
326
+        char *tail;
327
+        unsigned int rgba = strtoul(color_string2, &tail, 16);
328
+
329
+        if (*tail || (len != 6 && len != 8)) {
330
+            av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string2);
331
+            return AVERROR(EINVAL);
332
+        }
333
+        if (len == 8) {
334
+            rgba_color[3] = rgba;
335
+            rgba >>= 8;
336
+        }
337
+        rgba_color[0] = rgba >> 16;
338
+        rgba_color[1] = rgba >> 8;
339
+        rgba_color[2] = rgba;
340
+    } else {
341
+        entry = bsearch(color_string2,
342
+                        color_table,
343
+                        FF_ARRAY_ELEMS(color_table),
344
+                        sizeof(ColorEntry),
345
+                        color_table_compare);
346
+        if (!entry) {
347
+            av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string2);
348
+            return AVERROR(EINVAL);
349
+        }
350
+        memcpy(rgba_color, entry->rgb_color, 3);
351
+    }
352
+
353
+    if (tail) {
354
+        unsigned long int alpha;
355
+        const char *alpha_string = tail;
356
+        if (!strncmp(alpha_string, "0x", 2)) {
357
+            alpha = strtoul(alpha_string, &tail, 16);
358
+        } else {
359
+            alpha = 255 * strtod(alpha_string, &tail);
360
+        }
361
+
362
+        if (tail == alpha_string || *tail || alpha > 255) {
363
+            av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n",
364
+                   alpha_string, color_string);
365
+            return AVERROR(EINVAL);
366
+        }
367
+        rgba_color[3] = alpha;
368
+    }
369
+
370
+    return 0;
371
+}
372
+
373
+#ifdef TEST
374
+
375
+#undef printf
376
+
377
+int main(void)
378
+{
379
+    printf("Testing av_parse_video_rate()\n");
380
+    {
381
+        int i;
382
+        const char *rates[] = {
383
+            "-inf",
384
+            "inf",
385
+            "nan",
386
+            "123/0",
387
+            "-123 / 0",
388
+            "",
389
+            "/",
390
+            " 123  /  321",
391
+            "foo/foo",
392
+            "foo/1",
393
+            "1/foo",
394
+            "0/0",
395
+            "/0",
396
+            "1/",
397
+            "1",
398
+            "0",
399
+            "-123/123",
400
+            "-foo",
401
+            "123.23",
402
+            ".23",
403
+            "-.23",
404
+            "-0.234",
405
+            "-0.0000001",
406
+            "  21332.2324   ",
407
+            " -21332.2324   ",
408
+        };
409
+
410
+        for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) {
411
+            int ret;
412
+            AVRational q = (AVRational){0, 0};
413
+            ret = av_parse_video_rate(&q, rates[i]),
414
+            printf("'%s' -> %d/%d ret:%d\n",
415
+                   rates[i], q.num, q.den, ret);
416
+        }
417
+    }
418
+
419
+    printf("\nTesting av_parse_color()\n");
420
+    {
421
+        int i;
422
+        uint8_t rgba[4];
423
+        const char *color_names[] = {
424
+            "bikeshed",
425
+            "RaNdOm",
426
+            "foo",
427
+            "red",
428
+            "Red ",
429
+            "RED",
430
+            "Violet",
431
+            "Yellow",
432
+            "Red",
433
+            "0x000000",
434
+            "0x0000000",
435
+            "0xff000000",
436
+            "0x3e34ff",
437
+            "0x3e34ffaa",
438
+            "0xffXXee",
439
+            "0xfoobar",
440
+            "0xffffeeeeeeee",
441
+            "#ff0000",
442
+            "#ffXX00",
443
+            "ff0000",
444
+            "ffXX00",
445
+            "red@foo",
446
+            "random@10",
447
+            "0xff0000@1.0",
448
+            "red@",
449
+            "red@0xfff",
450
+            "red@0xf",
451
+            "red@2",
452
+            "red@0.1",
453
+            "red@-1",
454
+            "red@0.5",
455
+            "red@1.0",
456
+            "red@256",
457
+            "red@10foo",
458
+            "red@-1.0",
459
+            "red@-0.0",
460
+        };
461
+
462
+        av_log_set_level(AV_LOG_DEBUG);
463
+
464
+        for (i = 0;  i < FF_ARRAY_ELEMS(color_names); i++) {
465
+            if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0)
466
+                printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]);
467
+        }
468
+    }
469
+
470
+    return 0;
471
+}
472
+
473
+#endif /* TEST */
0 474
new file mode 100644
... ...
@@ -0,0 +1,75 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#ifndef AVUTIL_PARSEUTILS_H
19
+#define AVUTIL_PARSEUTILS_H
20
+
21
+#include "libavutil/rational.h"
22
+
23
+/**
24
+ * @file
25
+ * misc parsing utilities
26
+ */
27
+
28
+/**
29
+ * Parse str and put in width_ptr and height_ptr the detected values.
30
+ *
31
+ * @param[in,out] width_ptr pointer to the variable which will contain the detected
32
+ * width value
33
+ * @param[in,out] height_ptr pointer to the variable which will contain the detected
34
+ * height value
35
+ * @param[in] str the string to parse: it has to be a string in the format
36
+ * width x height or a valid video size abbreviation.
37
+ * @return >= 0 on success, a negative error code otherwise
38
+ */
39
+int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str);
40
+
41
+/**
42
+ * Parse str and store the detected values in *rate.
43
+ *
44
+ * @param[in,out] rate pointer to the AVRational which will contain the detected
45
+ * frame rate
46
+ * @param[in] str the string to parse: it has to be a string in the format
47
+ * rate_num / rate_den, a float number or a valid video rate abbreviation
48
+ * @return >= 0 on success, a negative error code otherwise
49
+ */
50
+int av_parse_video_rate(AVRational *rate, const char *str);
51
+
52
+/**
53
+ * Put the RGBA values that correspond to color_string in rgba_color.
54
+ *
55
+ * @param color_string a string specifying a color. It can be the name of
56
+ * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence,
57
+ * possibly followed by "@" and a string representing the alpha
58
+ * component.
59
+ * The alpha component may be a string composed by "0x" followed by an
60
+ * hexadecimal number or a decimal number between 0.0 and 1.0, which
61
+ * represents the opacity value (0x00/0.0 means completely transparent,
62
+ * 0xff/1.0 completely opaque).
63
+ * If the alpha component is not specified then 0xff is assumed.
64
+ * The string "random" will result in a random color.
65
+ * @param slen length of the initial part of color_string containing the
66
+ * color. It can be set to -1 if color_string is a null terminated string
67
+ * containing nothing else than the color.
68
+ * @return >= 0 in case of success, a negative value in case of
69
+ * failure (for example if color_string cannot be parsed).
70
+ */
71
+int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
72
+                   void *log_ctx);
73
+
74
+#endif /* AVUTIL_PARSEUTILS_H */
0 75
new file mode 100644
... ...
@@ -0,0 +1,73 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#include "samplefmt.h"
19
+
20
+#include <stdio.h>
21
+#include <stdlib.h>
22
+#include <string.h>
23
+
24
+typedef struct SampleFmtInfo {
25
+    const char *name;
26
+    int bits;
27
+} SampleFmtInfo;
28
+
29
+/** this table gives more information about formats */
30
+static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = {
31
+    [AV_SAMPLE_FMT_U8]  = { .name = "u8",  .bits = 8 },
32
+    [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16 },
33
+    [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32 },
34
+    [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32 },
35
+    [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64 },
36
+};
37
+
38
+const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
39
+{
40
+    if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
41
+        return NULL;
42
+    return sample_fmt_info[sample_fmt].name;
43
+}
44
+
45
+enum AVSampleFormat av_get_sample_fmt(const char *name)
46
+{
47
+    int i;
48
+
49
+    for (i = 0; i < AV_SAMPLE_FMT_NB; i++)
50
+        if (!strcmp(sample_fmt_info[i].name, name))
51
+            return i;
52
+    return AV_SAMPLE_FMT_NONE;
53
+}
54
+
55
+char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt)
56
+{
57
+    /* print header */
58
+    if (sample_fmt < 0)
59
+        snprintf(buf, buf_size, "name  " " depth");
60
+    else if (sample_fmt < AV_SAMPLE_FMT_NB) {
61
+        SampleFmtInfo info = sample_fmt_info[sample_fmt];
62
+        snprintf (buf, buf_size, "%-6s" "   %2d ", info.name, info.bits);
63
+    }
64
+
65
+    return buf;
66
+}
67
+
68
+int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt)
69
+{
70
+    return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ?
71
+        0 : sample_fmt_info[sample_fmt].bits;
72
+}
0 73
new file mode 100644
... ...
@@ -0,0 +1,70 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#ifndef AVUTIL_SAMPLEFMT_H
19
+#define AVUTIL_SAMPLEFMT_H
20
+
21
+/**
22
+ * all in native-endian format
23
+ */
24
+enum AVSampleFormat {
25
+    AV_SAMPLE_FMT_NONE = -1,
26
+    AV_SAMPLE_FMT_U8,          ///< unsigned 8 bits
27
+    AV_SAMPLE_FMT_S16,         ///< signed 16 bits
28
+    AV_SAMPLE_FMT_S32,         ///< signed 32 bits
29
+    AV_SAMPLE_FMT_FLT,         ///< float
30
+    AV_SAMPLE_FMT_DBL,         ///< double
31
+    AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically
32
+};
33
+
34
+/**
35
+ * Return the name of sample_fmt, or NULL if sample_fmt is not
36
+ * recognized.
37
+ */
38
+const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
39
+
40
+/**
41
+ * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
42
+ * on error.
43
+ */
44
+enum AVSampleFormat av_get_sample_fmt(const char *name);
45
+
46
+/**
47
+ * Generate a string corresponding to the sample format with
48
+ * sample_fmt, or a header if sample_fmt is negative.
49
+ *
50
+ * @param buf the buffer where to write the string
51
+ * @param buf_size the size of buf
52
+ * @param sample_fmt the number of the sample format to print the
53
+ * corresponding info string, or a negative value to print the
54
+ * corresponding header.
55
+ * @return the pointer to the filled buffer or NULL if sample_fmt is
56
+ * unknown or in case of other errors
57
+ */
58
+char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
59
+
60
+/**
61
+ * Return sample format bits per sample.
62
+ *
63
+ * @param sample_fmt the sample format
64
+ * @return number of bits per sample or zero if unknown for the given
65
+ * sample format
66
+ */
67
+int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
68
+
69
+#endif /* AVUTIL_SAMPLEFMT_H */
... ...
@@ -20,4 +20,3 @@ TESTPROGS = colorspace swscale
20 20
 DIRS = bfin mlib ppc sparc x86
21 21
 
22 22
 include $(SUBDIR)../subdir.mak
23
-$(SUBDIR)swscale-test$(EXESUF): ELIBS = -lavcore
... ...
@@ -25,7 +25,7 @@
25 25
 #include <stdarg.h>
26 26
 
27 27
 #undef HAVE_AV_CONFIG_H
28
-#include "libavcore/imgutils.h"
28
+#include "libavutil/imgutils.h"
29 29
 #include "libavutil/mem.h"
30 30
 #include "libavutil/avutil.h"
31 31
 #include "libavutil/crc.h"