From 737eb5976f6a37703923ce3c3d5e6ca8eeabb43a Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 7 Feb 2011 14:37:08 +0100 Subject: 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 --- Makefile | 1 - cmdutils.c | 2 - common.mak | 2 +- configure | 13 +- doc/APIchanges | 4 +- doc/general.texi | 2 +- ffmpeg.c | 6 +- ffplay.c | 6 +- ffserver.c | 2 +- libavcodec/Makefile | 2 +- libavcodec/aacdectab.h | 2 +- libavcodec/ac3_parser.c | 2 +- libavcodec/ac3enc.c | 2 +- libavcodec/ac3tab.c | 2 +- libavcodec/alsdec.c | 2 +- libavcodec/apedec.c | 2 +- libavcodec/audioconvert.c | 2 +- libavcodec/audioconvert.h | 2 +- libavcodec/avcodec.h | 4 +- libavcodec/bink.c | 2 +- libavcodec/bmpenc.c | 2 +- libavcodec/cook.c | 2 +- libavcodec/dca.c | 2 +- libavcodec/dirac.c | 2 +- libavcodec/dnxhddec.c | 2 +- libavcodec/dpx.c | 2 +- libavcodec/dsputil.c | 2 +- libavcodec/eacmv.c | 2 +- libavcodec/eamad.c | 2 +- libavcodec/eatgv.c | 2 +- libavcodec/flvdec.c | 2 +- libavcodec/gifdec.c | 2 +- libavcodec/h264.c | 2 +- libavcodec/h264_ps.c | 2 +- libavcodec/iff.c | 2 +- libavcodec/imc.c | 2 +- libavcodec/imgconvert.c | 3 +- libavcodec/indeo3.c | 2 +- libavcodec/kgv1dec.c | 2 +- libavcodec/libdiracdec.c | 2 +- libavcodec/libopenjpeg.c | 2 +- libavcodec/libschroedingerdec.c | 2 +- libavcodec/libvpxdec.c | 2 +- libavcodec/mjpegdec.c | 2 +- libavcodec/mpc7.c | 2 +- libavcodec/mpc8.c | 2 +- libavcodec/mpegvideo.c | 2 +- libavcodec/nellymoserdec.c | 2 +- libavcodec/nuv.c | 2 +- libavcodec/pcm-mpeg.c | 2 +- libavcodec/pcx.c | 2 +- libavcodec/pgssubdec.c | 2 +- libavcodec/pictordec.c | 2 +- libavcodec/pngdec.c | 2 +- libavcodec/pnm.c | 2 +- libavcodec/ptx.c | 2 +- libavcodec/qtrleenc.c | 2 +- libavcodec/rawdec.c | 3 +- libavcodec/resample.c | 2 +- libavcodec/rv10.c | 2 +- libavcodec/rv40.c | 2 +- libavcodec/sgidec.c | 2 +- libavcodec/smacker.c | 2 +- libavcodec/srtdec.c | 2 +- libavcodec/sunrast.c | 2 +- libavcodec/targa.c | 2 +- libavcodec/tiff.c | 2 +- libavcodec/truemotion1.c | 2 +- libavcodec/txd.c | 2 +- libavcodec/utils.c | 9 +- libavcodec/vorbis_data.c | 2 +- libavcodec/vp3.c | 2 +- libavcodec/vp8.c | 2 +- libavcodec/vqavideo.c | 2 +- libavcodec/wavpack.c | 2 +- libavcodec/xsubdec.c | 2 +- libavcodec/yop.c | 2 +- libavcore/Makefile | 20 -- libavcore/audioconvert.c | 116 ---------- libavcore/audioconvert.h | 95 -------- libavcore/avcore.h | 70 ------ libavcore/imgutils.c | 297 ------------------------- libavcore/imgutils.h | 147 ------------- libavcore/internal.h | 31 --- libavcore/libavcore.v | 4 - libavcore/parseutils.c | 474 ---------------------------------------- libavcore/parseutils.h | 75 ------- libavcore/samplefmt.c | 70 ------ libavcore/samplefmt.h | 72 ------ libavcore/utils.c | 41 ---- libavdevice/Makefile | 2 +- libavdevice/v4l.c | 2 +- libavdevice/v4l2.c | 2 +- libavfilter/Makefile | 2 +- libavfilter/asrc_anullsrc.c | 2 +- libavfilter/avfilter.c | 4 +- libavfilter/avfilter.h | 5 +- libavfilter/defaults.c | 6 +- libavfilter/vf_crop.c | 2 +- libavfilter/vf_cropdetect.c | 2 +- libavfilter/vf_drawbox.c | 2 +- libavfilter/vf_frei0r.c | 4 +- libavfilter/vf_gradfun.c | 2 +- libavfilter/vf_hflip.c | 2 +- libavfilter/vf_overlay.c | 2 +- libavfilter/vf_pad.c | 4 +- libavfilter/vf_transpose.c | 2 +- libavfilter/vsrc_buffer.c | 2 +- libavfilter/vsrc_movie.c | 2 +- libavfilter/vsrc_nullsrc.c | 2 +- libavformat/Makefile | 2 +- libavformat/aea.c | 2 +- libavformat/flic.c | 2 +- libavformat/matroskaenc.c | 2 +- libavformat/utils.c | 2 +- libavformat/wv.c | 2 +- libavutil/Makefile | 8 + libavutil/audioconvert.c | 117 ++++++++++ libavutil/audioconvert.h | 95 ++++++++ libavutil/avutil.h | 14 +- libavutil/imgutils.c | 297 +++++++++++++++++++++++++ libavutil/imgutils.h | 149 +++++++++++++ libavutil/parseutils.c | 474 ++++++++++++++++++++++++++++++++++++++++ libavutil/parseutils.h | 75 +++++++ libavutil/samplefmt.c | 73 +++++++ libavutil/samplefmt.h | 70 ++++++ libswscale/Makefile | 1 - libswscale/swscale-test.c | 2 +- 128 files changed, 1491 insertions(+), 1646 deletions(-) delete mode 100644 libavcore/Makefile delete mode 100644 libavcore/audioconvert.c delete mode 100644 libavcore/audioconvert.h delete mode 100644 libavcore/avcore.h delete mode 100644 libavcore/imgutils.c delete mode 100644 libavcore/imgutils.h delete mode 100644 libavcore/internal.h delete mode 100644 libavcore/libavcore.v delete mode 100644 libavcore/parseutils.c delete mode 100644 libavcore/parseutils.h delete mode 100644 libavcore/samplefmt.c delete mode 100644 libavcore/samplefmt.h delete mode 100644 libavcore/utils.c create mode 100644 libavutil/audioconvert.c create mode 100644 libavutil/audioconvert.h create mode 100644 libavutil/imgutils.c create mode 100644 libavutil/imgutils.h create mode 100644 libavutil/parseutils.c create mode 100644 libavutil/parseutils.h create mode 100644 libavutil/samplefmt.c create mode 100644 libavutil/samplefmt.h diff --git a/Makefile b/Makefile index 99d264a446..4ed003b7a5 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,6 @@ FFLIBS-$(CONFIG_AVFORMAT) += avformat FFLIBS-$(CONFIG_AVCODEC) += avcodec FFLIBS-$(CONFIG_POSTPROC) += postproc FFLIBS-$(CONFIG_SWSCALE) += swscale -FFLIBS-$(CONFIG_AVCORE) += avcore FFLIBS := avutil diff --git a/cmdutils.c b/cmdutils.c index c68f37fe20..9809d2fe8a 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -38,7 +38,6 @@ #include "libavutil/pixdesc.h" #include "libavutil/eval.h" #include "libavcodec/opt.h" -#include "libavcore/avcore.h" #include "cmdutils.h" #include "version.h" #if CONFIG_NETWORK @@ -413,7 +412,6 @@ static int warned_cfg = 0; static void print_all_libs_info(FILE* outstream, int flags) { PRINT_LIB_INFO(outstream, avutil, AVUTIL, flags); - PRINT_LIB_INFO(outstream, avcore, AVCORE, flags); PRINT_LIB_INFO(outstream, avcodec, AVCODEC, flags); PRINT_LIB_INFO(outstream, avformat, AVFORMAT, flags); PRINT_LIB_INFO(outstream, avdevice, AVDEVICE, flags); diff --git a/common.mak b/common.mak index 110f5056c4..3d1a1293fb 100644 --- a/common.mak +++ b/common.mak @@ -31,7 +31,7 @@ $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL)) endif -ALLFFLIBS = avcodec avcore avdevice avfilter avformat avutil postproc swscale +ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale IFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) CPPFLAGS := $(IFLAGS) $(CPPFLAGS) diff --git a/configure b/configure index 90eeaa0b66..ed2934d33f 100755 --- a/configure +++ b/configure @@ -86,7 +86,6 @@ Configuration options: --disable-ffserver disable ffserver build --disable-avdevice disable libavdevice build --disable-avcodec disable libavcodec build - --disable-avcore disable libavcore build --disable-avformat disable libavformat build --disable-swscale disable libswscale build --enable-postproc enable GPLed postprocessing support [no] @@ -871,7 +870,6 @@ CONFIG_LIST=" $COMPONENT_LIST aandct avcodec - avcore avdevice avfilter avformat @@ -1589,7 +1587,6 @@ host_os=$target_os_default # configurable options enable avcodec -enable avcore enable avdevice enable avfilter enable avformat @@ -2933,7 +2930,7 @@ enabled extra_warnings && check_cflags -Winline # add some linker flags check_ldflags -Wl,--warn-common check_ldflags -Wl,--as-needed -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' +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' test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic echo "X{};" > $TMPV @@ -3143,7 +3140,6 @@ if enabled source_path_used; then doc libavcodec libavcodec/$arch - libavcore libavdevice libavfilter libavfilter/$arch @@ -3163,7 +3159,6 @@ if enabled source_path_used; then doc/texi2pod.pl libavcodec/Makefile libavcodec/${arch}/Makefile - libavcore/Makefile libavdevice/Makefile libavfilter/Makefile libavfilter/${arch}/Makefile @@ -3266,7 +3261,6 @@ get_version(){ get_version LIBSWSCALE libswscale/swscale.h get_version LIBPOSTPROC libpostproc/postprocess.h get_version LIBAVCODEC libavcodec/avcodec.h -get_version LIBAVCORE libavcore/avcore.h get_version LIBAVDEVICE libavdevice/avdevice.h get_version LIBAVFORMAT libavformat/version.h get_version LIBAVUTIL libavutil/avutil.h @@ -3394,10 +3388,9 @@ EOF } pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" -pkgconfig_generate libavcore "FFmpeg multimedia shared core utilities library" "$LIBAVCORE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION" +pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION" pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION" -pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION" +pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION" pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" diff --git a/doc/APIchanges b/doc/APIchanges index ce61cfcf72..421df01336 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,7 +2,6 @@ Never assume the API of libav* to be stable unless at least 1 week has passed si the last major version increase. The last version increases were: libavcodec: ? -libavcore: 2010-07-21 libavdevice: ? libavfilter: 2009-10-18 libavformat: ? @@ -13,6 +12,9 @@ libavutil: 2009-03-08 API changes, most recent first: +2011-02-15 - lavu 52.38.0 - merge libavcore + libavcore is merged back completely into libavutil + 2011-02-10 - 55bad0c - lavc 52.113.0 - vbv_delay Add vbv_delay field to AVCodecContext diff --git a/doc/general.texi b/doc/general.texi index 3fc4d00e26..cd126f9868 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -986,7 +986,7 @@ you should only need to add the directory where the LIB files are installed (i.e. @file{c:\msys\usr\local\bin}). This is not a typo, the LIB files are installed in the @file{bin} directory. And instead of adding the static libraries (@file{libxxx.a} files) you should add the MSVC import libraries -(@file{avcodec.lib}, @file{avformat.lib}, @file{avcore.lib}, and +(@file{avcodec.lib}, @file{avformat.lib}, and @file{avutil.lib}). Note that you should not use the GCC import libraries (@file{libxxx.dll.a} files), as these will give you undefined reference errors. There should be no need for @file{libmingwex.a}, diff --git a/ffmpeg.c b/ffmpeg.c index 85149a7935..1cad57d809 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -36,9 +36,9 @@ #include "libswscale/swscale.h" #include "libavcodec/opt.h" #include "libavcodec/audioconvert.h" -#include "libavcore/audioconvert.h" -#include "libavcore/parseutils.h" -#include "libavcore/samplefmt.h" +#include "libavutil/audioconvert.h" +#include "libavutil/parseutils.h" +#include "libavutil/samplefmt.h" #include "libavutil/colorspace.h" #include "libavutil/fifo.h" #include "libavutil/intreadwrite.h" diff --git a/ffplay.c b/ffplay.c index 6b4f38ee35..b6343287ac 100644 --- a/ffplay.c +++ b/ffplay.c @@ -28,9 +28,9 @@ #include "libavutil/avstring.h" #include "libavutil/colorspace.h" #include "libavutil/pixdesc.h" -#include "libavcore/imgutils.h" -#include "libavcore/parseutils.h" -#include "libavcore/samplefmt.h" +#include "libavutil/imgutils.h" +#include "libavutil/parseutils.h" +#include "libavutil/samplefmt.h" #include "libavformat/avformat.h" #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" diff --git a/ffserver.c b/ffserver.c index 9a3240808b..cbf04aa4a5 100644 --- a/ffserver.c +++ b/ffserver.c @@ -36,7 +36,7 @@ #include "libavutil/avstring.h" #include "libavutil/lfg.h" #include "libavutil/random_seed.h" -#include "libavcore/parseutils.h" +#include "libavutil/parseutils.h" #include "libavcodec/opt.h" #include #include diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 682b626800..930affbb7a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1,7 +1,7 @@ include $(SUBDIR)../config.mak NAME = avcodec -FFLIBS = avcore avutil +FFLIBS = avutil HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h index 500e8f2ad0..0bccb84cb7 100644 --- a/libavcodec/aacdectab.h +++ b/libavcodec/aacdectab.h @@ -30,7 +30,7 @@ #ifndef AVCODEC_AACDECTAB_H #define AVCODEC_AACDECTAB_H -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "aac.h" #include diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c index bab354d6b9..301aadcd84 100644 --- a/libavcodec/ac3_parser.c +++ b/libavcodec/ac3_parser.c @@ -24,7 +24,7 @@ #include "ac3_parser.h" #include "aac_ac3_parser.h" #include "get_bits.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #define AC3_HEADER_SIZE 7 diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 851fdc9caf..c15fd5109c 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -28,7 +28,7 @@ //#define DEBUG -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "libavutil/crc.h" #include "avcodec.h" #include "put_bits.h" diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c index 7c0ebcdcd3..f7b030209c 100644 --- a/libavcodec/ac3tab.c +++ b/libavcodec/ac3tab.c @@ -24,7 +24,7 @@ * tables taken directly from the AC-3 spec. */ -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "avcodec.h" #include "ac3tab.h" diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index bfc589d26d..41b3f0caf5 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -36,7 +36,7 @@ #include "bytestream.h" #include "bgmc.h" #include "dsputil.h" -#include "libavcore/samplefmt.h" +#include "libavutil/samplefmt.h" #include "libavutil/crc.h" #include diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index e673b88bee..05498777b4 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -25,7 +25,7 @@ #include "dsputil.h" #include "get_bits.h" #include "bytestream.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" /** * @file diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c index b29b030644..67cacbdcf1 100644 --- a/libavcodec/audioconvert.c +++ b/libavcodec/audioconvert.c @@ -27,7 +27,7 @@ #include "libavutil/avstring.h" #include "libavutil/libm.h" -#include "libavcore/samplefmt.h" +#include "libavutil/samplefmt.h" #include "avcodec.h" #include "audioconvert.h" diff --git a/libavcodec/audioconvert.h b/libavcodec/audioconvert.h index ae6016a611..5f38cca513 100644 --- a/libavcodec/audioconvert.h +++ b/libavcodec/audioconvert.h @@ -31,7 +31,7 @@ #include "libavutil/cpu.h" #include "avcodec.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #if FF_API_OLD_SAMPLE_FMT /** diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 9ed6f50856..84c3b6fc79 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -27,7 +27,7 @@ */ #include -#include "libavcore/samplefmt.h" +#include "libavutil/samplefmt.h" #include "libavutil/avutil.h" #include "libavutil/cpu.h" @@ -437,7 +437,7 @@ enum CodecID { #endif #if FF_API_OLD_AUDIOCONVERT -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" /* Audio channel masks */ #define CH_FRONT_LEFT AV_CH_FRONT_LEFT diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 95cfc92721..b77e9db0f6 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" #include "binkdata.h" diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index d424662b5c..b8f9047c55 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/internal.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "bmp.h" diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 9d3d001297..da31e9f520 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -53,7 +53,7 @@ #include "dsputil.h" #include "bytestream.h" #include "fft.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "cookdata.h" diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 67195b1917..bdbe018be2 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -29,7 +29,7 @@ #include "libavutil/common.h" #include "libavutil/intmath.h" #include "libavutil/intreadwrite.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "avcodec.h" #include "dsputil.h" #include "fft.h" diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c index bacd1f8e9f..c8dc7a0f62 100644 --- a/libavcodec/dirac.c +++ b/libavcodec/dirac.c @@ -25,7 +25,7 @@ * @author Marco Gerards */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "dirac.h" #include "avcodec.h" #include "golomb.h" diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 58893acaf9..9b37d1d632 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -22,7 +22,7 @@ //#define TRACE //#define DEBUG -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "get_bits.h" #include "dnxhddata.h" diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 55ae4e7248..ade4e8cbc0 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -20,7 +20,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "bytestream.h" #include "avcodec.h" diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 84714def41..c89e58f529 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -27,7 +27,7 @@ * DSP utils */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" #include "simple_idct.h" diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index 6770cd195e..7f6c2a4577 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -29,7 +29,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" typedef struct CmvContext { diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index 1dd3b79755..d4881ab843 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -34,7 +34,7 @@ #include "aandcttab.h" #include "mpeg12.h" #include "mpeg12data.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #define EA_PREAMBLE_SIZE 8 #define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD i-frame */ diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index 075405a907..9ad083475b 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -32,7 +32,7 @@ #define ALT_BITSTREAM_READER_LE #include "get_bits.h" #include "libavutil/lzo.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #define EA_PREAMBLE_SIZE 8 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T') diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index b1a7578173..cf4dfe43bc 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -20,7 +20,7 @@ #include "mpegvideo.h" #include "h263.h" #include "flv.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){ int is11 = get_bits1(gb); diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index 7be284cb14..39d0db9c24 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -22,7 +22,7 @@ //#define DEBUG -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "lzw.h" diff --git a/libavcodec/h264.c b/libavcodec/h264.c index e6f9ec9b8d..5ebf929ee9 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -25,7 +25,7 @@ * @author Michael Niedermayer */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "internal.h" #include "dsputil.h" #include "avcodec.h" diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 3fe5815ea6..469d3d8bd2 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -25,7 +25,7 @@ * @author Michael Niedermayer */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "internal.h" #include "dsputil.h" #include "avcodec.h" diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 18ad7004d9..e64ce1eeb6 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -25,7 +25,7 @@ * IFF PBM/ILBM bitmap decoder */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "bytestream.h" #include "avcodec.h" #include "get_bits.h" diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 2b9de0b021..4cbb287a57 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -40,7 +40,7 @@ #include "get_bits.h" #include "dsputil.h" #include "fft.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "imcdata.h" diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 6b0c049e2a..b37c343b93 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -36,8 +36,7 @@ #include "imgconvert.h" #include "libavutil/colorspace.h" #include "libavutil/pixdesc.h" -#include "libavcore/imgutils.h" -#include "libavcore/internal.h" +#include "libavutil/imgutils.h" #if HAVE_MMX && HAVE_YASM #include "x86/dsputil_mmx.h" diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 5c4cd0564a..c9d8573692 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -23,7 +23,7 @@ #include #include -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" #include "bytestream.h" diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index efc477f37d..2f6a80c2c6 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -25,7 +25,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" typedef struct { diff --git a/libavcodec/libdiracdec.c b/libavcodec/libdiracdec.c index 520ec3f03a..fb6ff45f0a 100644 --- a/libavcodec/libdiracdec.c +++ b/libavcodec/libdiracdec.c @@ -28,7 +28,7 @@ * (http://dirac.sourceforge.net/specification.html). */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "libdirac.h" #undef NDEBUG diff --git a/libavcodec/libopenjpeg.c b/libavcodec/libopenjpeg.c index 0a9ded896d..1f8530c7c6 100644 --- a/libavcodec/libopenjpeg.c +++ b/libavcodec/libopenjpeg.c @@ -24,7 +24,7 @@ * JPEG 2000 decoder using libopenjpeg */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "libavutil/intreadwrite.h" #define OPJ_STATIC diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index e733d9e34d..7603f7e15f 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -27,7 +27,7 @@ * (http://dirac.sourceforge.net/specification.html). */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "libdirac_libschro.h" #include "libschroedinger.h" diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index f912322c50..29b8eec43e 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -27,7 +27,7 @@ #include #include -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" typedef struct VP8DecoderContext { diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index fbc637aa30..69a1837472 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -33,7 +33,7 @@ //#define DEBUG #include -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" #include "mjpeg.h" diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 8bdb9e5813..04657e5ff2 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -30,7 +30,7 @@ #include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "mpc.h" #include "mpc7data.h" diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 865ffc1b98..cf65ffe904 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -30,7 +30,7 @@ #include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "mpc.h" #include "mpcdata.h" diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index c8706bcf60..efb0365905 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -28,7 +28,7 @@ */ #include "libavutil/intmath.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" #include "internal.h" diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c index 80e04ee0a2..fd8568d5ab 100644 --- a/libavcodec/nellymoserdec.c +++ b/libavcodec/nellymoserdec.c @@ -34,7 +34,7 @@ #include "nellymoser.h" #include "libavutil/lfg.h" #include "libavutil/random_seed.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "avcodec.h" #include "dsputil.h" #include "fft.h" diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index d53d4578ba..84ee6af9b3 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -23,7 +23,7 @@ #include "libavutil/bswap.h" #include "libavutil/lzo.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" #include "rtjpeg.h" diff --git a/libavcodec/pcm-mpeg.c b/libavcodec/pcm-mpeg.c index 189b2b5691..030507502d 100644 --- a/libavcodec/pcm-mpeg.c +++ b/libavcodec/pcm-mpeg.c @@ -24,7 +24,7 @@ * PCM codecs for encodings found in MPEG streams (DVD/Blu-ray) */ -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #include "avcodec.h" #include "bytestream.h" diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index cafade2d7d..d47417e3f7 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -22,7 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "get_bits.h" diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 1ed475787f..b7fe560953 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -28,7 +28,7 @@ #include "dsputil.h" #include "bytestream.h" #include "libavutil/colorspace.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" //#define DEBUG_PACKET_CONTENTS diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index 59885ae383..f1b3607082 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -24,7 +24,7 @@ * Pictor/PC Paint decoder */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "cga_data.h" diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 4bc5c3705a..2f9b343e5b 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -18,7 +18,7 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "png.h" diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c index c104e23427..2cbbdf60ea 100644 --- a/libavcodec/pnm.c +++ b/libavcodec/pnm.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "pnm.h" diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index 86b06b4aaa..28df0b6f2e 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -20,7 +20,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" typedef struct PTXContext { diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 78149e5ed8..8815736e87 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -22,7 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 29cc5e44d8..baffceb51b 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -28,8 +28,7 @@ #include "imgconvert.h" #include "raw.h" #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" -#include "libavcore/internal.h" +#include "libavutil/imgutils.h" typedef struct RawVideoContext { uint32_t palette[AVPALETTE_COUNT]; diff --git a/libavcodec/resample.c b/libavcodec/resample.c index 272831520d..45fba69f45 100644 --- a/libavcodec/resample.c +++ b/libavcodec/resample.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "audioconvert.h" #include "libavutil/opt.h" -#include "libavcore/samplefmt.h" +#include "libavutil/samplefmt.h" struct AVResampleContext; diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index f47540d8f1..e6e9afafb0 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -25,7 +25,7 @@ * RV10/RV20 decoder */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index acebeb7da5..5d4aafc004 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -24,7 +24,7 @@ * RV40 decoder */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index ac2adfe7ca..96af5c6fc1 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "sgi.h" diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 61f1604616..e3f00b8415 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -32,7 +32,7 @@ #include #include "avcodec.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #define ALT_BITSTREAM_READER_LE #include "get_bits.h" diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c index 30fdc12fe7..af03cc4d1c 100644 --- a/libavcodec/srtdec.c +++ b/libavcodec/srtdec.c @@ -20,7 +20,7 @@ */ #include "libavutil/avstring.h" -#include "libavcore/parseutils.h" +#include "libavutil/parseutils.h" #include "avcodec.h" #include "ass.h" diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index 76b65b356c..73e4b5b91c 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -20,7 +20,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #define RT_OLD 0 diff --git a/libavcodec/targa.c b/libavcodec/targa.c index e6e1ca6f21..ef6e92bddf 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -20,7 +20,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "targa.h" diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index b012baa994..8295a4b4c0 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -33,7 +33,7 @@ #include "faxcompr.h" #include "libavutil/common.h" #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" typedef struct TiffContext { AVCodecContext *avctx; diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index 448da84c57..c7d414a648 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -35,7 +35,7 @@ #include "avcodec.h" #include "dsputil.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "truemotion1data.h" diff --git a/libavcodec/txd.c b/libavcodec/txd.c index b394e1f5be..da1f5c1e20 100644 --- a/libavcodec/txd.c +++ b/libavcodec/txd.c @@ -22,7 +22,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "s3tc.h" diff --git a/libavcodec/utils.c b/libavcodec/utils.c index c4bba376bb..03fa7baeb5 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -29,10 +29,9 @@ #include "libavutil/integer.h" #include "libavutil/crc.h" #include "libavutil/pixdesc.h" -#include "libavcore/audioconvert.h" -#include "libavcore/imgutils.h" -#include "libavcore/internal.h" -#include "libavcore/samplefmt.h" +#include "libavutil/audioconvert.h" +#include "libavutil/imgutils.h" +#include "libavutil/samplefmt.h" #include "avcodec.h" #include "dsputil.h" #include "libavutil/opt.h" @@ -1169,7 +1168,7 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v) } #if LIBAVCODEC_VERSION_MAJOR < 53 -#include "libavcore/parseutils.h" +#include "libavutil/parseutils.h" int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str) { diff --git a/libavcodec/vorbis_data.c b/libavcodec/vorbis_data.c index 783a5daa00..8fa624168a 100644 --- a/libavcodec/vorbis_data.c +++ b/libavcodec/vorbis_data.c @@ -20,7 +20,7 @@ #include "dsputil.h" #include "vorbis.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" const uint8_t ff_vorbis_channel_layout_offsets[8][8] = { { 0 }, diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 726f18cb92..ee41846e74 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -33,7 +33,7 @@ #include #include -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "dsputil.h" #include "get_bits.h" diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 3cd76249d0..a66c10d655 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -22,7 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "vp56.h" #include "vp8data.h" diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index c3b5ba6556..f0ecda6217 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -68,7 +68,7 @@ #include #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #define PALETTE_COUNT 256 diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index ffb5018c57..d5102320fd 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -22,7 +22,7 @@ #include "avcodec.h" #include "get_bits.h" #include "unary.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" /** * @file diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 872b227d64..d24588b8d9 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -18,7 +18,7 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "get_bits.h" #include "bytestream.h" diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 6a75e74b7a..a117e2d791 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -24,7 +24,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avcodec.h" #include "get_bits.h" diff --git a/libavcore/Makefile b/libavcore/Makefile deleted file mode 100644 index f2e829702e..0000000000 --- a/libavcore/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -include $(SUBDIR)../config.mak - -NAME = avcore -FFLIBS = avutil - -HEADERS = \ - audioconvert.h \ - avcore.h \ - imgutils.h \ - parseutils.h \ - samplefmt.h \ - -OBJS = \ - audioconvert.o \ - imgutils.o \ - parseutils.o \ - samplefmt.o \ - utils.o \ - -include $(SUBDIR)../subdir.mak diff --git a/libavcore/audioconvert.c b/libavcore/audioconvert.c deleted file mode 100644 index c7207338a4..0000000000 --- a/libavcore/audioconvert.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * audio conversion routines - */ - -#include "libavutil/avstring.h" -#include "audioconvert.h" - -static const char * const channel_names[] = { - "FL", "FR", "FC", "LFE", "BL", "BR", "FLC", "FRC", - "BC", "SL", "SR", "TC", "TFL", "TFC", "TFR", "TBL", - "TBC", "TBR", - [29] = "DL", - [30] = "DR", -}; - -static const char *get_channel_name(int channel_id) -{ - if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names)) - return NULL; - return channel_names[channel_id]; -} - -static const struct { - const char *name; - int nb_channels; - int64_t layout; -} channel_layout_map[] = { - { "mono", 1, AV_CH_LAYOUT_MONO }, - { "stereo", 2, AV_CH_LAYOUT_STEREO }, - { "4.0", 4, AV_CH_LAYOUT_4POINT0 }, - { "quad", 4, AV_CH_LAYOUT_QUAD }, - { "5.0", 5, AV_CH_LAYOUT_5POINT0 }, - { "5.0", 5, AV_CH_LAYOUT_5POINT0_BACK }, - { "5.1", 6, AV_CH_LAYOUT_5POINT1 }, - { "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK }, - { "5.1+downmix", 8, AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, }, - { "7.1", 8, AV_CH_LAYOUT_7POINT1 }, - { "7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE }, - { "7.1+downmix", 10, AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, }, - { 0 } -}; - -int64_t av_get_channel_layout(const char *name) -{ - int i = 0; - do { - if (!strcmp(channel_layout_map[i].name, name)) - return channel_layout_map[i].layout; - i++; - } while (channel_layout_map[i].name); - - return 0; -} - -void av_get_channel_layout_string(char *buf, int buf_size, - int nb_channels, int64_t channel_layout) -{ - int i; - - if (nb_channels <= 0) - nb_channels = av_get_channel_layout_nb_channels(channel_layout); - - for (i = 0; channel_layout_map[i].name; i++) - if (nb_channels == channel_layout_map[i].nb_channels && - channel_layout == channel_layout_map[i].layout) { - av_strlcpy(buf, channel_layout_map[i].name, buf_size); - return; - } - - snprintf(buf, buf_size, "%d channels", nb_channels); - if (channel_layout) { - int i,ch; - av_strlcat(buf, " (", buf_size); - for(i=0,ch=0; i<64; i++) { - if ((channel_layout & (1L<0) av_strlcat(buf, "|", buf_size); - av_strlcat(buf, name, buf_size); - } - ch++; - } - } - av_strlcat(buf, ")", buf_size); - } -} - -int av_get_channel_layout_nb_channels(int64_t channel_layout) -{ - int count; - uint64_t x = channel_layout; - for (count = 0; x; count++) - x &= x-1; // unset lowest set bit - return count; -} diff --git a/libavcore/audioconvert.h b/libavcore/audioconvert.h deleted file mode 100644 index 89e9c55d17..0000000000 --- a/libavcore/audioconvert.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2006 Michael Niedermayer - * Copyright (c) 2008 Peter Ross - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCORE_AUDIOCONVERT_H -#define AVCORE_AUDIOCONVERT_H - -/** - * @file - * audio conversion routines - */ - -#include "avcore.h" - -/* Audio channel masks */ -#define AV_CH_FRONT_LEFT 0x00000001 -#define AV_CH_FRONT_RIGHT 0x00000002 -#define AV_CH_FRONT_CENTER 0x00000004 -#define AV_CH_LOW_FREQUENCY 0x00000008 -#define AV_CH_BACK_LEFT 0x00000010 -#define AV_CH_BACK_RIGHT 0x00000020 -#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040 -#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080 -#define AV_CH_BACK_CENTER 0x00000100 -#define AV_CH_SIDE_LEFT 0x00000200 -#define AV_CH_SIDE_RIGHT 0x00000400 -#define AV_CH_TOP_CENTER 0x00000800 -#define AV_CH_TOP_FRONT_LEFT 0x00001000 -#define AV_CH_TOP_FRONT_CENTER 0x00002000 -#define AV_CH_TOP_FRONT_RIGHT 0x00004000 -#define AV_CH_TOP_BACK_LEFT 0x00008000 -#define AV_CH_TOP_BACK_CENTER 0x00010000 -#define AV_CH_TOP_BACK_RIGHT 0x00020000 -#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. -#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT. - -/** Channel mask value used for AVCodecContext.request_channel_layout - to indicate that the user requests the channel order of the decoder output - to be the native codec channel order. */ -#define AV_CH_LAYOUT_NATIVE 0x8000000000000000LL - -/* Audio channel convenience macros */ -#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER) -#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) -#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER) -#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) -#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER) -#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) -#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) -#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY) -#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY) -#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) -#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) - -/** - * Return a channel layout id that matches name, 0 if no match. - */ -int64_t av_get_channel_layout(const char *name); - -/** - * Return a description of a channel layout. - * If nb_channels is <= 0, it is guessed from the channel_layout. - * - * @param buf put here the string containing the channel layout - * @param buf_size size in bytes of the buffer - */ -void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout); - -/** - * Return the number of channels in the channel layout. - */ -int av_get_channel_layout_nb_channels(int64_t channel_layout); - -#endif /* AVCORE_AUDIOCONVERT_H */ diff --git a/libavcore/avcore.h b/libavcore/avcore.h deleted file mode 100644 index 9b02c3b58c..0000000000 --- a/libavcore/avcore.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCORE_AVCORE_H -#define AVCORE_AVCORE_H - -/** - * @file - * shared media utilities for the libav* libraries - */ - -#include "libavutil/avutil.h" - -#define LIBAVCORE_VERSION_MAJOR 0 -#define LIBAVCORE_VERSION_MINOR 16 -#define LIBAVCORE_VERSION_MICRO 1 - -#define LIBAVCORE_VERSION_INT AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \ - LIBAVCORE_VERSION_MINOR, \ - LIBAVCORE_VERSION_MICRO) -#define LIBAVCORE_VERSION AV_VERSION(LIBAVCORE_VERSION_MAJOR, \ - LIBAVCORE_VERSION_MINOR, \ - LIBAVCORE_VERSION_MICRO) -#define LIBAVCORE_BUILD LIBAVCORE_VERSION_INT - -#define LIBAVCORE_IDENT "Lavcore" AV_STRINGIFY(LIBAVCORE_VERSION) - -/** - * Return the LIBAVCORE_VERSION_INT constant. - */ -unsigned avcore_version(void); - -/** - * Return the libavcore build-time configuration. - */ -const char *avcore_configuration(void); - -/** - * Return the libavcore license. - */ -const char *avcore_license(void); - -#define AV_NOPTS_VALUE INT64_C(0x8000000000000000) -#define AV_TIME_BASE 1000000 -#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} - -/** - * Those FF_API_* defines are not part of public API. - * They may change, break or disappear at any time. - */ -#ifndef FF_API_OLD_IMAGE_NAMES -#define FF_API_OLD_IMAGE_NAMES (LIBAVCORE_VERSION_MAJOR < 1) -#endif - -#endif /* AVCORE_AVCORE_H */ diff --git a/libavcore/imgutils.c b/libavcore/imgutils.c deleted file mode 100644 index 0f449ff427..0000000000 --- a/libavcore/imgutils.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * misc image utilities - */ - -#include "imgutils.h" -#include "internal.h" -#include "libavutil/pixdesc.h" - -void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], - const AVPixFmtDescriptor *pixdesc) -{ - int i; - memset(max_pixsteps, 0, 4*sizeof(max_pixsteps[0])); - if (max_pixstep_comps) - memset(max_pixstep_comps, 0, 4*sizeof(max_pixstep_comps[0])); - - for (i = 0; i < 4; i++) { - const AVComponentDescriptor *comp = &(pixdesc->comp[i]); - if ((comp->step_minus1+1) > max_pixsteps[comp->plane]) { - max_pixsteps[comp->plane] = comp->step_minus1+1; - if (max_pixstep_comps) - max_pixstep_comps[comp->plane] = i; - } - } -} - -int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane) -{ - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; - int max_step [4]; /* max pixel step for each plane */ - int max_step_comp[4]; /* the component for each plane which has the max pixel step */ - int s; - - if (desc->flags & PIX_FMT_BITSTREAM) - return (width * (desc->comp[0].step_minus1+1) + 7) >> 3; - - av_image_fill_max_pixsteps(max_step, max_step_comp, desc); - s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->log2_chroma_w : 0; - return max_step[plane] * (((width + (1 << s) - 1)) >> s); -} - -int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width) -{ - int i; - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; - int max_step [4]; /* max pixel step for each plane */ - int max_step_comp[4]; /* the component for each plane which has the max pixel step */ - - memset(linesizes, 0, 4*sizeof(linesizes[0])); - - if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL) - return AVERROR(EINVAL); - - if (desc->flags & PIX_FMT_BITSTREAM) { - if (width > (INT_MAX -7) / (desc->comp[0].step_minus1+1)) - return AVERROR(EINVAL); - linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3; - return 0; - } - - av_image_fill_max_pixsteps(max_step, max_step_comp, desc); - for (i = 0; i < 4; i++) { - int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0; - int shifted_w = ((width + (1 << s) - 1)) >> s; - if (max_step[i] > INT_MAX / shifted_w) - return AVERROR(EINVAL); - linesizes[i] = max_step[i] * shifted_w; - } - - return 0; -} - -int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, - uint8_t *ptr, const int linesizes[4]) -{ - int i, total_size, size[4], has_plane[4]; - - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; - memset(data , 0, sizeof(data[0])*4); - memset(size , 0, sizeof(size)); - memset(has_plane, 0, sizeof(has_plane)); - - if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL) - return AVERROR(EINVAL); - - data[0] = ptr; - if (linesizes[0] > (INT_MAX - 1024) / height) - return AVERROR(EINVAL); - size[0] = linesizes[0] * height; - - if (desc->flags & PIX_FMT_PAL) { - size[0] = (size[0] + 3) & ~3; - data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */ - return size[0] + 256 * 4; - } - - for (i = 0; i < 4; i++) - has_plane[desc->comp[i].plane] = 1; - - total_size = size[0]; - for (i = 1; has_plane[i] && i < 4; i++) { - int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; - data[i] = data[i-1] + size[i-1]; - h = (height + (1 << s) - 1) >> s; - if (linesizes[i] > INT_MAX / h) - return AVERROR(EINVAL); - size[i] = h * linesizes[i]; - if (total_size > INT_MAX - size[i]) - return AVERROR(EINVAL); - total_size += size[i]; - } - - return total_size; -} - -int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt) -{ - int i; - - for (i = 0; i < 256; i++) { - int r, g, b; - - switch (pix_fmt) { - case PIX_FMT_RGB8: - r = (i>>5 )*36; - g = ((i>>2)&7)*36; - b = (i&3 )*85; - break; - case PIX_FMT_BGR8: - b = (i>>6 )*85; - g = ((i>>3)&7)*36; - r = (i&7 )*36; - break; - case PIX_FMT_RGB4_BYTE: - r = (i>>3 )*255; - g = ((i>>1)&3)*85; - b = (i&1 )*255; - break; - case PIX_FMT_BGR4_BYTE: - b = (i>>3 )*255; - g = ((i>>1)&3)*85; - r = (i&1 )*255; - break; - case PIX_FMT_GRAY8: - r = b = g = i; - break; - default: - return AVERROR(EINVAL); - } - pal[i] = b + (g<<8) + (r<<16); - } - - return 0; -} - -int av_image_alloc(uint8_t *pointers[4], int linesizes[4], - int w, int h, enum PixelFormat pix_fmt, int align) -{ - int i, ret; - uint8_t *buf; - - if ((ret = av_image_check_size(w, h, 0, NULL)) < 0) - return ret; - if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, w)) < 0) - return ret; - - for (i = 0; i < 4; i++) - linesizes[i] = FFALIGN(linesizes[i], align); - - if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0) - return ret; - buf = av_malloc(ret + align); - if (!buf) - return AVERROR(ENOMEM); - if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) { - av_free(buf); - return ret; - } - if (av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_PAL) - ff_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt); - - return ret; -} - -typedef struct ImgUtils { - const AVClass *class; - int log_offset; - void *log_ctx; -} ImgUtils; - -static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) }; - -int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) -{ - ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx }; - - if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) - return 0; - - av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h); - return AVERROR(EINVAL); -} - -void av_image_copy_plane(uint8_t *dst, int dst_linesize, - const uint8_t *src, int src_linesize, - int bytewidth, int height) -{ - if (!dst || !src) - return; - for (;height > 0; height--) { - memcpy(dst, src, bytewidth); - dst += dst_linesize; - src += src_linesize; - } -} - -void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], - const uint8_t *src_data[4], const int src_linesizes[4], - enum PixelFormat pix_fmt, int width, int height) -{ - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; - - if (desc->flags & PIX_FMT_HWACCEL) - return; - - if (desc->flags & PIX_FMT_PAL) { - av_image_copy_plane(dst_data[0], dst_linesizes[0], - src_data[0], src_linesizes[0], - width, height); - /* copy the palette */ - memcpy(dst_data[1], src_data[1], 4*256); - } else { - int i, planes_nb = 0; - - for (i = 0; i < desc->nb_components; i++) - planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1); - - for (i = 0; i < planes_nb; i++) { - int h = height; - int bwidth = av_image_get_linesize(pix_fmt, width, i); - if (i == 1 || i == 2) { - h= -((-height)>>desc->log2_chroma_h); - } - av_image_copy_plane(dst_data[i], dst_linesizes[i], - src_data[i], src_linesizes[i], - bwidth, h); - } - } -} - -#if FF_API_OLD_IMAGE_NAMES -void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], - const AVPixFmtDescriptor *pixdesc) -{ - av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, pixdesc); -} - -int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane) -{ - return av_image_get_linesize(pix_fmt, width, plane); -} - -int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width) -{ - return av_image_fill_linesizes(linesizes, pix_fmt, width); -} - -int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, - uint8_t *ptr, const int linesizes[4]) -{ - return av_image_fill_pointers(data, pix_fmt, height, ptr, linesizes); -} - -int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) -{ - return av_image_check_size(w, h, log_offset, log_ctx); -} -#endif diff --git a/libavcore/imgutils.h b/libavcore/imgutils.h deleted file mode 100644 index 6c39d53119..0000000000 --- a/libavcore/imgutils.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCORE_IMGUTILS_H -#define AVCORE_IMGUTILS_H - -/** - * @file - * misc image utilities - */ - -#include "libavutil/pixdesc.h" -#include "avcore.h" - -/** - * Compute the max pixel step for each plane of an image with a - * format described by pixdesc. - * - * The pixel step is the distance in bytes between the first byte of - * the group of bytes which describe a pixel component and the first - * byte of the successive group in the same plane for the same - * component. - * - * @param max_pixsteps an array which is filled with the max pixel step - * for each plane. Since a plane may contain different pixel - * components, the computed max_pixsteps[plane] is relative to the - * component in the plane with the max pixel step. - * @param max_pixstep_comps an array which is filled with the component - * for each plane which has the max pixel step. May be NULL. - */ -void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], - const AVPixFmtDescriptor *pixdesc); - -/** - * Compute the size of an image line with format pix_fmt and width - * width for the plane plane. - * - * @return the computed size in bytes - */ -int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane); - -/** - * Fill plane linesizes for an image with pixel format pix_fmt and - * width width. - * - * @param linesizes array to be filled with the linesize for each plane - * @return >= 0 in case of success, a negative error code otherwise - */ -int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width); - -/** - * Fill plane data pointers for an image with pixel format pix_fmt and - * height height. - * - * @param data pointers array to be filled with the pointer for each image plane - * @param ptr the pointer to a buffer which will contain the image - * @param linesizes[4] the array containing the linesize for each - * plane, should be filled by av_image_fill_linesizes() - * @return the size in bytes required for the image buffer, a negative - * error code in case of failure - */ -int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, - uint8_t *ptr, const int linesizes[4]); - -/** - * Allocate an image with size w and h and pixel format pix_fmt, and - * fill pointers and linesizes accordingly. - * The allocated image buffer has to be freed by using - * av_freep(&pointers[0]). - * - * @param align the value to use for buffer size alignment - * @return the size in bytes required for the image buffer, a negative - * error code in case of failure - */ -int av_image_alloc(uint8_t *pointers[4], int linesizes[4], - int w, int h, enum PixelFormat pix_fmt, int align); - -/** - * Copy image plane from src to dst. - * That is, copy "height" number of lines of "bytewidth" bytes each. - * The first byte of each successive line is separated by *_linesize - * bytes. - * - * @param dst_linesize linesize for the image plane in dst - * @param src_linesize linesize for the image plane in src - */ -void av_image_copy_plane(uint8_t *dst, int dst_linesize, - const uint8_t *src, int src_linesize, - int bytewidth, int height); - -/** - * Copy image in src_data to dst_data. - * - * @param dst_linesize linesizes for the image in dst_data - * @param src_linesize linesizes for the image in src_data - */ -void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], - const uint8_t *src_data[4], const int src_linesizes[4], - enum PixelFormat pix_fmt, int width, int height); - -/** - * Check if the given dimension of an image is valid, meaning that all - * bytes of the image can be addressed with a signed int. - * - * @param w the width of the picture - * @param h the height of the picture - * @param log_offset the offset to sum to the log level for logging with log_ctx - * @param log_ctx the parent logging context, it may be NULL - * @return >= 0 if valid, a negative error code otherwise - */ -int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); - -#if FF_API_OLD_IMAGE_NAMES -attribute_deprecated -void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], - const AVPixFmtDescriptor *pixdesc); - -attribute_deprecated -int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane); - -attribute_deprecated -int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width); - -attribute_deprecated -int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, - uint8_t *ptr, const int linesizes[4]); - -attribute_deprecated -int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); -#endif - -#endif /* AVCORE_IMGUTILS_H */ diff --git a/libavcore/internal.h b/libavcore/internal.h deleted file mode 100644 index 3960bd3986..0000000000 --- a/libavcore/internal.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCORE_INTERNAL_H -#define AVCORE_INTERNAL_H - -/** - * @file - * internal functions - */ - -#include "avcore.h" - -int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt); - -#endif /* AVCORE_INTERNAL_H */ diff --git a/libavcore/libavcore.v b/libavcore/libavcore.v deleted file mode 100644 index dc84cc4965..0000000000 --- a/libavcore/libavcore.v +++ /dev/null @@ -1,4 +0,0 @@ -LIBAVCORE_$MAJOR { - global: av_*; ff_*; avcore*; - local: *; -}; diff --git a/libavcore/parseutils.c b/libavcore/parseutils.c deleted file mode 100644 index abf0422ff4..0000000000 --- a/libavcore/parseutils.c +++ /dev/null @@ -1,474 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * misc parsing utilities for libavcore - */ - -#include -#include "parseutils.h" -#include "libavutil/avutil.h" -#include "libavutil/eval.h" -#include "libavutil/avstring.h" -#include "libavutil/random_seed.h" - -typedef struct { - const char *abbr; - int width, height; -} VideoSizeAbbr; - -typedef struct { - const char *abbr; - AVRational rate; -} VideoRateAbbr; - -static const VideoSizeAbbr video_size_abbrs[] = { - { "ntsc", 720, 480 }, - { "pal", 720, 576 }, - { "qntsc", 352, 240 }, /* VCD compliant NTSC */ - { "qpal", 352, 288 }, /* VCD compliant PAL */ - { "sntsc", 640, 480 }, /* square pixel NTSC */ - { "spal", 768, 576 }, /* square pixel PAL */ - { "film", 352, 240 }, - { "ntsc-film", 352, 240 }, - { "sqcif", 128, 96 }, - { "qcif", 176, 144 }, - { "cif", 352, 288 }, - { "4cif", 704, 576 }, - { "16cif", 1408,1152 }, - { "qqvga", 160, 120 }, - { "qvga", 320, 240 }, - { "vga", 640, 480 }, - { "svga", 800, 600 }, - { "xga", 1024, 768 }, - { "uxga", 1600,1200 }, - { "qxga", 2048,1536 }, - { "sxga", 1280,1024 }, - { "qsxga", 2560,2048 }, - { "hsxga", 5120,4096 }, - { "wvga", 852, 480 }, - { "wxga", 1366, 768 }, - { "wsxga", 1600,1024 }, - { "wuxga", 1920,1200 }, - { "woxga", 2560,1600 }, - { "wqsxga", 3200,2048 }, - { "wquxga", 3840,2400 }, - { "whsxga", 6400,4096 }, - { "whuxga", 7680,4800 }, - { "cga", 320, 200 }, - { "ega", 640, 350 }, - { "hd480", 852, 480 }, - { "hd720", 1280, 720 }, - { "hd1080", 1920,1080 }, -}; - -static const VideoRateAbbr video_rate_abbrs[]= { - { "ntsc", { 30000, 1001 } }, - { "pal", { 25, 1 } }, - { "qntsc", { 30000, 1001 } }, /* VCD compliant NTSC */ - { "qpal", { 25, 1 } }, /* VCD compliant PAL */ - { "sntsc", { 30000, 1001 } }, /* square pixel NTSC */ - { "spal", { 25, 1 } }, /* square pixel PAL */ - { "film", { 24, 1 } }, - { "ntsc-film", { 24000, 1001 } }, -}; - -int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str) -{ - int i; - int n = FF_ARRAY_ELEMS(video_size_abbrs); - char *p; - int width = 0, height = 0; - - for (i = 0; i < n; i++) { - if (!strcmp(video_size_abbrs[i].abbr, str)) { - width = video_size_abbrs[i].width; - height = video_size_abbrs[i].height; - break; - } - } - if (i == n) { - p = str; - width = strtol(p, &p, 10); - if (*p) - p++; - height = strtol(p, &p, 10); - } - if (width <= 0 || height <= 0) - return AVERROR(EINVAL); - *width_ptr = width; - *height_ptr = height; - return 0; -} - -int av_parse_video_rate(AVRational *rate, const char *arg) -{ - int i, ret; - int n = FF_ARRAY_ELEMS(video_rate_abbrs); - double res; - - /* First, we check our abbreviation table */ - for (i = 0; i < n; ++i) - if (!strcmp(video_rate_abbrs[i].abbr, arg)) { - *rate = video_rate_abbrs[i].rate; - return 0; - } - - /* Then, we try to parse it as fraction */ - if ((ret = av_expr_parse_and_eval(&res, arg, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, 0, NULL)) < 0) - return ret; - *rate = av_d2q(res, 1001000); - if (rate->num <= 0 || rate->den <= 0) - return AVERROR(EINVAL); - return 0; -} - -typedef struct { - const char *name; ///< a string representing the name of the color - uint8_t rgb_color[3]; ///< RGB values for the color -} ColorEntry; - -static ColorEntry color_table[] = { - { "AliceBlue", { 0xF0, 0xF8, 0xFF } }, - { "AntiqueWhite", { 0xFA, 0xEB, 0xD7 } }, - { "Aqua", { 0x00, 0xFF, 0xFF } }, - { "Aquamarine", { 0x7F, 0xFF, 0xD4 } }, - { "Azure", { 0xF0, 0xFF, 0xFF } }, - { "Beige", { 0xF5, 0xF5, 0xDC } }, - { "Bisque", { 0xFF, 0xE4, 0xC4 } }, - { "Black", { 0x00, 0x00, 0x00 } }, - { "BlanchedAlmond", { 0xFF, 0xEB, 0xCD } }, - { "Blue", { 0x00, 0x00, 0xFF } }, - { "BlueViolet", { 0x8A, 0x2B, 0xE2 } }, - { "Brown", { 0xA5, 0x2A, 0x2A } }, - { "BurlyWood", { 0xDE, 0xB8, 0x87 } }, - { "CadetBlue", { 0x5F, 0x9E, 0xA0 } }, - { "Chartreuse", { 0x7F, 0xFF, 0x00 } }, - { "Chocolate", { 0xD2, 0x69, 0x1E } }, - { "Coral", { 0xFF, 0x7F, 0x50 } }, - { "CornflowerBlue", { 0x64, 0x95, 0xED } }, - { "Cornsilk", { 0xFF, 0xF8, 0xDC } }, - { "Crimson", { 0xDC, 0x14, 0x3C } }, - { "Cyan", { 0x00, 0xFF, 0xFF } }, - { "DarkBlue", { 0x00, 0x00, 0x8B } }, - { "DarkCyan", { 0x00, 0x8B, 0x8B } }, - { "DarkGoldenRod", { 0xB8, 0x86, 0x0B } }, - { "DarkGray", { 0xA9, 0xA9, 0xA9 } }, - { "DarkGreen", { 0x00, 0x64, 0x00 } }, - { "DarkKhaki", { 0xBD, 0xB7, 0x6B } }, - { "DarkMagenta", { 0x8B, 0x00, 0x8B } }, - { "DarkOliveGreen", { 0x55, 0x6B, 0x2F } }, - { "Darkorange", { 0xFF, 0x8C, 0x00 } }, - { "DarkOrchid", { 0x99, 0x32, 0xCC } }, - { "DarkRed", { 0x8B, 0x00, 0x00 } }, - { "DarkSalmon", { 0xE9, 0x96, 0x7A } }, - { "DarkSeaGreen", { 0x8F, 0xBC, 0x8F } }, - { "DarkSlateBlue", { 0x48, 0x3D, 0x8B } }, - { "DarkSlateGray", { 0x2F, 0x4F, 0x4F } }, - { "DarkTurquoise", { 0x00, 0xCE, 0xD1 } }, - { "DarkViolet", { 0x94, 0x00, 0xD3 } }, - { "DeepPink", { 0xFF, 0x14, 0x93 } }, - { "DeepSkyBlue", { 0x00, 0xBF, 0xFF } }, - { "DimGray", { 0x69, 0x69, 0x69 } }, - { "DodgerBlue", { 0x1E, 0x90, 0xFF } }, - { "FireBrick", { 0xB2, 0x22, 0x22 } }, - { "FloralWhite", { 0xFF, 0xFA, 0xF0 } }, - { "ForestGreen", { 0x22, 0x8B, 0x22 } }, - { "Fuchsia", { 0xFF, 0x00, 0xFF } }, - { "Gainsboro", { 0xDC, 0xDC, 0xDC } }, - { "GhostWhite", { 0xF8, 0xF8, 0xFF } }, - { "Gold", { 0xFF, 0xD7, 0x00 } }, - { "GoldenRod", { 0xDA, 0xA5, 0x20 } }, - { "Gray", { 0x80, 0x80, 0x80 } }, - { "Green", { 0x00, 0x80, 0x00 } }, - { "GreenYellow", { 0xAD, 0xFF, 0x2F } }, - { "HoneyDew", { 0xF0, 0xFF, 0xF0 } }, - { "HotPink", { 0xFF, 0x69, 0xB4 } }, - { "IndianRed", { 0xCD, 0x5C, 0x5C } }, - { "Indigo", { 0x4B, 0x00, 0x82 } }, - { "Ivory", { 0xFF, 0xFF, 0xF0 } }, - { "Khaki", { 0xF0, 0xE6, 0x8C } }, - { "Lavender", { 0xE6, 0xE6, 0xFA } }, - { "LavenderBlush", { 0xFF, 0xF0, 0xF5 } }, - { "LawnGreen", { 0x7C, 0xFC, 0x00 } }, - { "LemonChiffon", { 0xFF, 0xFA, 0xCD } }, - { "LightBlue", { 0xAD, 0xD8, 0xE6 } }, - { "LightCoral", { 0xF0, 0x80, 0x80 } }, - { "LightCyan", { 0xE0, 0xFF, 0xFF } }, - { "LightGoldenRodYellow", { 0xFA, 0xFA, 0xD2 } }, - { "LightGrey", { 0xD3, 0xD3, 0xD3 } }, - { "LightGreen", { 0x90, 0xEE, 0x90 } }, - { "LightPink", { 0xFF, 0xB6, 0xC1 } }, - { "LightSalmon", { 0xFF, 0xA0, 0x7A } }, - { "LightSeaGreen", { 0x20, 0xB2, 0xAA } }, - { "LightSkyBlue", { 0x87, 0xCE, 0xFA } }, - { "LightSlateGray", { 0x77, 0x88, 0x99 } }, - { "LightSteelBlue", { 0xB0, 0xC4, 0xDE } }, - { "LightYellow", { 0xFF, 0xFF, 0xE0 } }, - { "Lime", { 0x00, 0xFF, 0x00 } }, - { "LimeGreen", { 0x32, 0xCD, 0x32 } }, - { "Linen", { 0xFA, 0xF0, 0xE6 } }, - { "Magenta", { 0xFF, 0x00, 0xFF } }, - { "Maroon", { 0x80, 0x00, 0x00 } }, - { "MediumAquaMarine", { 0x66, 0xCD, 0xAA } }, - { "MediumBlue", { 0x00, 0x00, 0xCD } }, - { "MediumOrchid", { 0xBA, 0x55, 0xD3 } }, - { "MediumPurple", { 0x93, 0x70, 0xD8 } }, - { "MediumSeaGreen", { 0x3C, 0xB3, 0x71 } }, - { "MediumSlateBlue", { 0x7B, 0x68, 0xEE } }, - { "MediumSpringGreen", { 0x00, 0xFA, 0x9A } }, - { "MediumTurquoise", { 0x48, 0xD1, 0xCC } }, - { "MediumVioletRed", { 0xC7, 0x15, 0x85 } }, - { "MidnightBlue", { 0x19, 0x19, 0x70 } }, - { "MintCream", { 0xF5, 0xFF, 0xFA } }, - { "MistyRose", { 0xFF, 0xE4, 0xE1 } }, - { "Moccasin", { 0xFF, 0xE4, 0xB5 } }, - { "NavajoWhite", { 0xFF, 0xDE, 0xAD } }, - { "Navy", { 0x00, 0x00, 0x80 } }, - { "OldLace", { 0xFD, 0xF5, 0xE6 } }, - { "Olive", { 0x80, 0x80, 0x00 } }, - { "OliveDrab", { 0x6B, 0x8E, 0x23 } }, - { "Orange", { 0xFF, 0xA5, 0x00 } }, - { "OrangeRed", { 0xFF, 0x45, 0x00 } }, - { "Orchid", { 0xDA, 0x70, 0xD6 } }, - { "PaleGoldenRod", { 0xEE, 0xE8, 0xAA } }, - { "PaleGreen", { 0x98, 0xFB, 0x98 } }, - { "PaleTurquoise", { 0xAF, 0xEE, 0xEE } }, - { "PaleVioletRed", { 0xD8, 0x70, 0x93 } }, - { "PapayaWhip", { 0xFF, 0xEF, 0xD5 } }, - { "PeachPuff", { 0xFF, 0xDA, 0xB9 } }, - { "Peru", { 0xCD, 0x85, 0x3F } }, - { "Pink", { 0xFF, 0xC0, 0xCB } }, - { "Plum", { 0xDD, 0xA0, 0xDD } }, - { "PowderBlue", { 0xB0, 0xE0, 0xE6 } }, - { "Purple", { 0x80, 0x00, 0x80 } }, - { "Red", { 0xFF, 0x00, 0x00 } }, - { "RosyBrown", { 0xBC, 0x8F, 0x8F } }, - { "RoyalBlue", { 0x41, 0x69, 0xE1 } }, - { "SaddleBrown", { 0x8B, 0x45, 0x13 } }, - { "Salmon", { 0xFA, 0x80, 0x72 } }, - { "SandyBrown", { 0xF4, 0xA4, 0x60 } }, - { "SeaGreen", { 0x2E, 0x8B, 0x57 } }, - { "SeaShell", { 0xFF, 0xF5, 0xEE } }, - { "Sienna", { 0xA0, 0x52, 0x2D } }, - { "Silver", { 0xC0, 0xC0, 0xC0 } }, - { "SkyBlue", { 0x87, 0xCE, 0xEB } }, - { "SlateBlue", { 0x6A, 0x5A, 0xCD } }, - { "SlateGray", { 0x70, 0x80, 0x90 } }, - { "Snow", { 0xFF, 0xFA, 0xFA } }, - { "SpringGreen", { 0x00, 0xFF, 0x7F } }, - { "SteelBlue", { 0x46, 0x82, 0xB4 } }, - { "Tan", { 0xD2, 0xB4, 0x8C } }, - { "Teal", { 0x00, 0x80, 0x80 } }, - { "Thistle", { 0xD8, 0xBF, 0xD8 } }, - { "Tomato", { 0xFF, 0x63, 0x47 } }, - { "Turquoise", { 0x40, 0xE0, 0xD0 } }, - { "Violet", { 0xEE, 0x82, 0xEE } }, - { "Wheat", { 0xF5, 0xDE, 0xB3 } }, - { "White", { 0xFF, 0xFF, 0xFF } }, - { "WhiteSmoke", { 0xF5, 0xF5, 0xF5 } }, - { "Yellow", { 0xFF, 0xFF, 0x00 } }, - { "YellowGreen", { 0x9A, 0xCD, 0x32 } }, -}; - -static int color_table_compare(const void *lhs, const void *rhs) -{ - return strcasecmp(lhs, ((const ColorEntry *)rhs)->name); -} - -#define ALPHA_SEP '@' - -int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, - void *log_ctx) -{ - char *tail, color_string2[128]; - const ColorEntry *entry; - int len, hex_offset = 0; - - if (color_string[0] == '#') { - hex_offset = 1; - } else if (!strncmp(color_string, "0x", 2)) - hex_offset = 2; - - if (slen < 0) - slen = strlen(color_string); - av_strlcpy(color_string2, color_string + hex_offset, - FFMIN(slen-hex_offset+1, sizeof(color_string2))); - if ((tail = strchr(color_string2, ALPHA_SEP))) - *tail++ = 0; - len = strlen(color_string2); - rgba_color[3] = 255; - - if (!strcasecmp(color_string2, "random") || !strcasecmp(color_string2, "bikeshed")) { - int rgba = av_get_random_seed(); - rgba_color[0] = rgba >> 24; - rgba_color[1] = rgba >> 16; - rgba_color[2] = rgba >> 8; - rgba_color[3] = rgba; - } else if (hex_offset || - strspn(color_string2, "0123456789ABCDEFabcdef") == len) { - char *tail; - unsigned int rgba = strtoul(color_string2, &tail, 16); - - if (*tail || (len != 6 && len != 8)) { - av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string2); - return AVERROR(EINVAL); - } - if (len == 8) { - rgba_color[3] = rgba; - rgba >>= 8; - } - rgba_color[0] = rgba >> 16; - rgba_color[1] = rgba >> 8; - rgba_color[2] = rgba; - } else { - entry = bsearch(color_string2, - color_table, - FF_ARRAY_ELEMS(color_table), - sizeof(ColorEntry), - color_table_compare); - if (!entry) { - av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string2); - return AVERROR(EINVAL); - } - memcpy(rgba_color, entry->rgb_color, 3); - } - - if (tail) { - unsigned long int alpha; - const char *alpha_string = tail; - if (!strncmp(alpha_string, "0x", 2)) { - alpha = strtoul(alpha_string, &tail, 16); - } else { - alpha = 255 * strtod(alpha_string, &tail); - } - - if (tail == alpha_string || *tail || alpha > 255) { - av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n", - alpha_string, color_string); - return AVERROR(EINVAL); - } - rgba_color[3] = alpha; - } - - return 0; -} - -#ifdef TEST - -#undef printf - -int main(void) -{ - printf("Testing av_parse_video_rate()\n"); - { - int i; - const char *rates[] = { - "-inf", - "inf", - "nan", - "123/0", - "-123 / 0", - "", - "/", - " 123 / 321", - "foo/foo", - "foo/1", - "1/foo", - "0/0", - "/0", - "1/", - "1", - "0", - "-123/123", - "-foo", - "123.23", - ".23", - "-.23", - "-0.234", - "-0.0000001", - " 21332.2324 ", - " -21332.2324 ", - }; - - for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) { - int ret; - AVRational q = (AVRational){0, 0}; - ret = av_parse_video_rate(&q, rates[i]), - printf("'%s' -> %d/%d ret:%d\n", - rates[i], q.num, q.den, ret); - } - } - - printf("\nTesting av_parse_color()\n"); - { - int i; - uint8_t rgba[4]; - const char *color_names[] = { - "bikeshed", - "RaNdOm", - "foo", - "red", - "Red ", - "RED", - "Violet", - "Yellow", - "Red", - "0x000000", - "0x0000000", - "0xff000000", - "0x3e34ff", - "0x3e34ffaa", - "0xffXXee", - "0xfoobar", - "0xffffeeeeeeee", - "#ff0000", - "#ffXX00", - "ff0000", - "ffXX00", - "red@foo", - "random@10", - "0xff0000@1.0", - "red@", - "red@0xfff", - "red@0xf", - "red@2", - "red@0.1", - "red@-1", - "red@0.5", - "red@1.0", - "red@256", - "red@10foo", - "red@-1.0", - "red@-0.0", - }; - - av_log_set_level(AV_LOG_DEBUG); - - for (i = 0; i < FF_ARRAY_ELEMS(color_names); i++) { - if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0) - printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]); - } - } - - return 0; -} - -#endif /* TEST */ diff --git a/libavcore/parseutils.h b/libavcore/parseutils.h deleted file mode 100644 index 052427bbfd..0000000000 --- a/libavcore/parseutils.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCORE_PARSEUTILS_H -#define AVCORE_PARSEUTILS_H - -#include "libavutil/rational.h" - -/** - * @file - * misc parsing utilities for libavcore - */ - -/** - * Parse str and put in width_ptr and height_ptr the detected values. - * - * @param[in,out] width_ptr pointer to the variable which will contain the detected - * width value - * @param[in,out] height_ptr pointer to the variable which will contain the detected - * height value - * @param[in] str the string to parse: it has to be a string in the format - * width x height or a valid video size abbreviation. - * @return >= 0 on success, a negative error code otherwise - */ -int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str); - -/** - * Parse str and store the detected values in *rate. - * - * @param[in,out] rate pointer to the AVRational which will contain the detected - * frame rate - * @param[in] str the string to parse: it has to be a string in the format - * rate_num / rate_den, a float number or a valid video rate abbreviation - * @return >= 0 on success, a negative error code otherwise - */ -int av_parse_video_rate(AVRational *rate, const char *str); - -/** - * Put the RGBA values that correspond to color_string in rgba_color. - * - * @param color_string a string specifying a color. It can be the name of - * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, - * possibly followed by "@" and a string representing the alpha - * component. - * The alpha component may be a string composed by "0x" followed by an - * hexadecimal number or a decimal number between 0.0 and 1.0, which - * represents the opacity value (0x00/0.0 means completely transparent, - * 0xff/1.0 completely opaque). - * If the alpha component is not specified then 0xff is assumed. - * The string "random" will result in a random color. - * @param slen length of the initial part of color_string containing the - * color. It can be set to -1 if color_string is a null terminated string - * containing nothing else than the color. - * @return >= 0 in case of success, a negative value in case of - * failure (for example if color_string cannot be parsed). - */ -int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, - void *log_ctx); - -#endif /* AVCORE_PARSEUTILS_H */ diff --git a/libavcore/samplefmt.c b/libavcore/samplefmt.c deleted file mode 100644 index 532acd9507..0000000000 --- a/libavcore/samplefmt.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "avcore.h" -#include "samplefmt.h" - -typedef struct SampleFmtInfo { - const char *name; - int bits; -} SampleFmtInfo; - -/** this table gives more information about formats */ -static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = { - [AV_SAMPLE_FMT_U8] = { .name = "u8", .bits = 8 }, - [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16 }, - [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32 }, - [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32 }, - [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64 }, -}; - -const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt) -{ - if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) - return NULL; - return sample_fmt_info[sample_fmt].name; -} - -enum AVSampleFormat av_get_sample_fmt(const char *name) -{ - int i; - - for (i = 0; i < AV_SAMPLE_FMT_NB; i++) - if (!strcmp(sample_fmt_info[i].name, name)) - return i; - return AV_SAMPLE_FMT_NONE; -} - -char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt) -{ - /* print header */ - if (sample_fmt < 0) - snprintf(buf, buf_size, "name " " depth"); - else if (sample_fmt < AV_SAMPLE_FMT_NB) { - SampleFmtInfo info = sample_fmt_info[sample_fmt]; - snprintf (buf, buf_size, "%-6s" " %2d ", info.name, info.bits); - } - - return buf; -} - -int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) -{ - return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? - 0 : sample_fmt_info[sample_fmt].bits; -} diff --git a/libavcore/samplefmt.h b/libavcore/samplefmt.h deleted file mode 100644 index 9701efe7be..0000000000 --- a/libavcore/samplefmt.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCORE_SAMPLEFMT_H -#define AVCORE_SAMPLEFMT_H - -#include "avcore.h" - -/** - * all in native-endian format - */ -enum AVSampleFormat { - AV_SAMPLE_FMT_NONE = -1, - AV_SAMPLE_FMT_U8, ///< unsigned 8 bits - AV_SAMPLE_FMT_S16, ///< signed 16 bits - AV_SAMPLE_FMT_S32, ///< signed 32 bits - AV_SAMPLE_FMT_FLT, ///< float - AV_SAMPLE_FMT_DBL, ///< double - AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcore -}; - -/** - * Return the name of sample_fmt, or NULL if sample_fmt is not - * recognized. - */ -const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt); - -/** - * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE - * on error. - */ -enum AVSampleFormat av_get_sample_fmt(const char *name); - -/** - * Generate a string corresponding to the sample format with - * sample_fmt, or a header if sample_fmt is negative. - * - * @param buf the buffer where to write the string - * @param buf_size the size of buf - * @param sample_fmt the number of the sample format to print the - * corresponding info string, or a negative value to print the - * corresponding header. - * @return the pointer to the filled buffer or NULL if sample_fmt is - * unknown or in case of other errors - */ -char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); - -/** - * Return sample format bits per sample. - * - * @param sample_fmt the sample format - * @return number of bits per sample or zero if unknown for the given - * sample format - */ -int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); - -#endif /* AVCORE_SAMPLEFMT_H */ diff --git a/libavcore/utils.c b/libavcore/utils.c deleted file mode 100644 index 8350a9bcad..0000000000 --- a/libavcore/utils.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "avcore.h" - -/** - * @file - * various utility functions - */ - -unsigned avcore_version(void) -{ - return LIBAVCORE_VERSION_INT; -} - -const char *avcore_configuration(void) -{ - return FFMPEG_CONFIGURATION; -} - -const char *avcore_license(void) -{ -#define LICENSE_PREFIX "libavcore license: " - return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1; -} diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 1c0630b38c..be28f4a0ad 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -1,7 +1,7 @@ include $(SUBDIR)../config.mak NAME = avdevice -FFLIBS = avformat avcodec avcore avutil +FFLIBS = avformat avcodec avutil HEADERS = avdevice.h diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c index c107684bff..9a155f9df6 100644 --- a/libavdevice/v4l.c +++ b/libavdevice/v4l.c @@ -22,7 +22,7 @@ #undef __STRICT_ANSI__ //workaround due to broken kernel headers #include "config.h" #include "libavutil/rational.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "libavformat/avformat.h" #include "libavcodec/dsputil.h" #include diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 993e2adcec..1f1a4bcfb8 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -43,7 +43,7 @@ #endif #include #include -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" static const int desired_video_buffers = 256; diff --git a/libavfilter/Makefile b/libavfilter/Makefile index ce1caa5bdc..abb68c811d 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -1,7 +1,7 @@ include $(SUBDIR)../config.mak NAME = avfilter -FFLIBS = avcore avutil +FFLIBS = avutil FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec FFLIBS-$(CONFIG_SCALE_FILTER) += swscale diff --git a/libavfilter/asrc_anullsrc.c b/libavfilter/asrc_anullsrc.c index 306e0a3d5a..4f49c3f186 100644 --- a/libavfilter/asrc_anullsrc.c +++ b/libavfilter/asrc_anullsrc.c @@ -22,7 +22,7 @@ */ #include "avfilter.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" typedef struct { int64_t channel_layout; diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 4d183294cb..039e04bf64 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -23,8 +23,8 @@ #include "libavutil/pixdesc.h" #include "libavutil/rational.h" -#include "libavcore/audioconvert.h" -#include "libavcore/imgutils.h" +#include "libavutil/audioconvert.h" +#include "libavutil/imgutils.h" #include "avfilter.h" #include "internal.h" diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 451d0befff..935214da68 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -23,8 +23,7 @@ #define AVFILTER_AVFILTER_H #include "libavutil/avutil.h" -#include "libavcore/avcore.h" -#include "libavcore/samplefmt.h" +#include "libavutil/samplefmt.h" #define LIBAVFILTER_VERSION_MAJOR 1 #define LIBAVFILTER_VERSION_MINOR 76 @@ -585,7 +584,7 @@ struct AVFilterLink { int h; ///< agreed upon image height AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio /* These two parameters apply only to audio */ - int64_t channel_layout; ///< channel layout of current buffer (see libavcore/audioconvert.h) + int64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h) int64_t sample_rate; ///< samples per second int format; ///< agreed upon media format diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c index 9f245c306f..1da2630471 100644 --- a/libavfilter/defaults.c +++ b/libavfilter/defaults.c @@ -19,9 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcore/audioconvert.h" -#include "libavcore/imgutils.h" -#include "libavcore/samplefmt.h" +#include "libavutil/audioconvert.h" +#include "libavutil/imgutils.h" +#include "libavutil/samplefmt.h" #include "avfilter.h" #include "internal.h" diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index e768fbb594..e02c24fe84 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -29,7 +29,7 @@ #include "libavutil/eval.h" #include "libavutil/avstring.h" #include "libavutil/libm.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" static const char *var_names[] = { "E", diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c index 62c68640a3..000c8bb2c2 100644 --- a/libavfilter/vf_cropdetect.c +++ b/libavfilter/vf_cropdetect.c @@ -23,7 +23,7 @@ * Ported from MPlayer libmpcodecs/vf_cropdetect.c. */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avfilter.h" typedef struct { diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c index 40d5e16e1b..3785072920 100644 --- a/libavfilter/vf_drawbox.c +++ b/libavfilter/vf_drawbox.c @@ -26,7 +26,7 @@ #include "libavutil/colorspace.h" #include "libavutil/pixdesc.h" -#include "libavcore/parseutils.h" +#include "libavutil/parseutils.h" #include "avfilter.h" enum { Y, U, V, A }; diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c index 03d4f28f2d..adccccb95b 100644 --- a/libavfilter/vf_frei0r.c +++ b/libavfilter/vf_frei0r.c @@ -27,8 +27,8 @@ #include #include #include "libavutil/avstring.h" -#include "libavcore/imgutils.h" -#include "libavcore/parseutils.h" +#include "libavutil/imgutils.h" +#include "libavutil/parseutils.h" #include "avfilter.h" typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height); diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c index 3a400a04eb..83ed3d79e4 100644 --- a/libavfilter/vf_gradfun.c +++ b/libavfilter/vf_gradfun.c @@ -32,7 +32,7 @@ * Dither it back to 8bit. */ -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "libavutil/cpu.h" #include "libavutil/pixdesc.h" #include "avfilter.h" diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c index 4deb14a53d..5250695f3f 100644 --- a/libavfilter/vf_hflip.c +++ b/libavfilter/vf_hflip.c @@ -27,7 +27,7 @@ #include "avfilter.h" #include "libavutil/pixdesc.h" #include "libavutil/intreadwrite.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" typedef struct { int max_step[4]; ///< max pixel step for each plane, expressed as a number of bytes diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index a170e817a2..0eb24b9682 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -29,7 +29,7 @@ #include "libavutil/eval.h" #include "libavutil/avstring.h" #include "libavutil/pixdesc.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "internal.h" static const char *var_names[] = { diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 467db5bf68..7413071913 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -28,8 +28,8 @@ #include "libavutil/pixdesc.h" #include "libavutil/colorspace.h" #include "libavutil/avassert.h" -#include "libavcore/imgutils.h" -#include "libavcore/parseutils.h" +#include "libavutil/imgutils.h" +#include "libavutil/parseutils.h" enum { RED = 0, GREEN, BLUE, ALPHA }; diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index 272b17ff1a..ed91aaade5 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -27,7 +27,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/pixdesc.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avfilter.h" typedef struct { diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c index 74d9bf6201..3c48a71c71 100644 --- a/libavfilter/vsrc_buffer.c +++ b/libavfilter/vsrc_buffer.c @@ -25,7 +25,7 @@ #include "avfilter.h" #include "vsrc_buffer.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" typedef struct { int64_t pts; diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c index 4fd56febad..fac30f9a2f 100644 --- a/libavfilter/vsrc_movie.c +++ b/libavfilter/vsrc_movie.c @@ -33,7 +33,7 @@ #include #include "libavutil/avstring.h" #include "libavutil/opt.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "libavformat/avformat.h" #include "avfilter.h" diff --git a/libavfilter/vsrc_nullsrc.c b/libavfilter/vsrc_nullsrc.c index 1cd06e13f3..487aa50069 100644 --- a/libavfilter/vsrc_nullsrc.c +++ b/libavfilter/vsrc_nullsrc.c @@ -23,7 +23,7 @@ #include "libavutil/avstring.h" #include "libavutil/eval.h" -#include "libavcore/parseutils.h" +#include "libavutil/parseutils.h" #include "avfilter.h" static const char *var_names[] = { diff --git a/libavformat/Makefile b/libavformat/Makefile index 1d4e75e75c..f319031c26 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -1,7 +1,7 @@ include $(SUBDIR)../config.mak NAME = avformat -FFLIBS = avcodec avcore avutil +FFLIBS = avcodec avutil HEADERS = avformat.h avio.h version.h diff --git a/libavformat/aea.c b/libavformat/aea.c index 8a508ec50a..16a11c86af 100644 --- a/libavformat/aea.c +++ b/libavformat/aea.c @@ -23,7 +23,7 @@ #include "avformat.h" #include "pcm.h" #include "libavutil/intreadwrite.h" -#include "libavcore/audioconvert.h" +#include "libavutil/audioconvert.h" #define AT1_SU_SIZE 212 diff --git a/libavformat/flic.c b/libavformat/flic.c index 2e03c3b3a1..5942f721dc 100644 --- a/libavformat/flic.c +++ b/libavformat/flic.c @@ -32,8 +32,8 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/audioconvert.h" #include "avformat.h" -#include "libavcore/audioconvert.h" #define FLIC_FILE_MAGIC_1 0xAF11 #define FLIC_FILE_MAGIC_2 0xAF12 diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index a288c7f85f..1d0dc38ca8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -26,7 +26,7 @@ #include "avc.h" #include "flacenc.h" #include "avlanguage.h" -#include "libavcore/samplefmt.h" +#include "libavutil/samplefmt.h" #include "libavutil/intreadwrite.h" #include "libavutil/random_seed.h" #include "libavutil/lfg.h" diff --git a/libavformat/utils.c b/libavformat/utils.c index 2303244d4c..225b9f22da 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3341,7 +3341,7 @@ void dump_format(AVFormatContext *ic, } #if FF_API_PARSE_FRAME_PARAM -#include "libavcore/parseutils.h" +#include "libavutil/parseutils.h" int parse_image_size(int *width_ptr, int *height_ptr, const char *str) { diff --git a/libavformat/wv.c b/libavformat/wv.c index 182f900f36..c9a1f0ed9c 100644 --- a/libavformat/wv.c +++ b/libavformat/wv.c @@ -19,11 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/audioconvert.h" #include "libavutil/intreadwrite.h" #include "avformat.h" #include "apetag.h" #include "id3v1.h" -#include "libavcore/audioconvert.h" // specs say that maximum block size is 1Mb #define WV_BLOCK_LIMIT 1047576 diff --git a/libavutil/Makefile b/libavutil/Makefile index fe0302c3b4..300acb1896 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -4,6 +4,7 @@ NAME = avutil HEADERS = adler32.h \ attributes.h \ + audioconvert.h \ avassert.h \ avstring.h \ avutil.h \ @@ -16,6 +17,7 @@ HEADERS = adler32.h \ eval.h \ fifo.h \ file.h \ + imgutils.h \ intfloat_readwrite.h \ intreadwrite.h \ lfg.h \ @@ -25,16 +27,19 @@ HEADERS = adler32.h \ md5.h \ mem.h \ opt.h \ + parseutils.h \ pixdesc.h \ pixfmt.h \ random_seed.h \ rational.h \ + samplefmt.h \ sha1.h \ BUILT_HEADERS = avconfig.h OBJS = adler32.o \ aes.o \ + audioconvert.o \ avstring.o \ base64.o \ cpu.o \ @@ -44,6 +49,7 @@ OBJS = adler32.o \ eval.o \ fifo.o \ file.o \ + imgutils.o \ intfloat_readwrite.o \ inverse.o \ lfg.o \ @@ -54,10 +60,12 @@ OBJS = adler32.o \ md5.o \ mem.o \ opt.o \ + parseutils.o \ pixdesc.o \ random_seed.o \ rational.o \ rc4.o \ + samplefmt.o \ sha.o \ tree.o \ utils.o \ diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c new file mode 100644 index 0000000000..8bc43f8936 --- /dev/null +++ b/libavutil/audioconvert.c @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * audio conversion routines + */ + +#include "libavutil/avutil.h" +#include "libavutil/avstring.h" +#include "audioconvert.h" + +static const char * const channel_names[] = { + "FL", "FR", "FC", "LFE", "BL", "BR", "FLC", "FRC", + "BC", "SL", "SR", "TC", "TFL", "TFC", "TFR", "TBL", + "TBC", "TBR", + [29] = "DL", + [30] = "DR", +}; + +static const char *get_channel_name(int channel_id) +{ + if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names)) + return NULL; + return channel_names[channel_id]; +} + +static const struct { + const char *name; + int nb_channels; + int64_t layout; +} channel_layout_map[] = { + { "mono", 1, AV_CH_LAYOUT_MONO }, + { "stereo", 2, AV_CH_LAYOUT_STEREO }, + { "4.0", 4, AV_CH_LAYOUT_4POINT0 }, + { "quad", 4, AV_CH_LAYOUT_QUAD }, + { "5.0", 5, AV_CH_LAYOUT_5POINT0 }, + { "5.0", 5, AV_CH_LAYOUT_5POINT0_BACK }, + { "5.1", 6, AV_CH_LAYOUT_5POINT1 }, + { "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK }, + { "5.1+downmix", 8, AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, }, + { "7.1", 8, AV_CH_LAYOUT_7POINT1 }, + { "7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE }, + { "7.1+downmix", 10, AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, }, + { 0 } +}; + +int64_t av_get_channel_layout(const char *name) +{ + int i = 0; + do { + if (!strcmp(channel_layout_map[i].name, name)) + return channel_layout_map[i].layout; + i++; + } while (channel_layout_map[i].name); + + return 0; +} + +void av_get_channel_layout_string(char *buf, int buf_size, + int nb_channels, int64_t channel_layout) +{ + int i; + + if (nb_channels <= 0) + nb_channels = av_get_channel_layout_nb_channels(channel_layout); + + for (i = 0; channel_layout_map[i].name; i++) + if (nb_channels == channel_layout_map[i].nb_channels && + channel_layout == channel_layout_map[i].layout) { + av_strlcpy(buf, channel_layout_map[i].name, buf_size); + return; + } + + snprintf(buf, buf_size, "%d channels", nb_channels); + if (channel_layout) { + int i,ch; + av_strlcat(buf, " (", buf_size); + for(i=0,ch=0; i<64; i++) { + if ((channel_layout & (1L<0) av_strlcat(buf, "|", buf_size); + av_strlcat(buf, name, buf_size); + } + ch++; + } + } + av_strlcat(buf, ")", buf_size); + } +} + +int av_get_channel_layout_nb_channels(int64_t channel_layout) +{ + int count; + uint64_t x = channel_layout; + for (count = 0; x; count++) + x &= x-1; // unset lowest set bit + return count; +} diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h new file mode 100644 index 0000000000..134c6107c9 --- /dev/null +++ b/libavutil/audioconvert.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2006 Michael Niedermayer + * Copyright (c) 2008 Peter Ross + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AUDIOCONVERT_H +#define AVUTIL_AUDIOCONVERT_H + +#include + +/** + * @file + * audio conversion routines + */ + +/* Audio channel masks */ +#define AV_CH_FRONT_LEFT 0x00000001 +#define AV_CH_FRONT_RIGHT 0x00000002 +#define AV_CH_FRONT_CENTER 0x00000004 +#define AV_CH_LOW_FREQUENCY 0x00000008 +#define AV_CH_BACK_LEFT 0x00000010 +#define AV_CH_BACK_RIGHT 0x00000020 +#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040 +#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080 +#define AV_CH_BACK_CENTER 0x00000100 +#define AV_CH_SIDE_LEFT 0x00000200 +#define AV_CH_SIDE_RIGHT 0x00000400 +#define AV_CH_TOP_CENTER 0x00000800 +#define AV_CH_TOP_FRONT_LEFT 0x00001000 +#define AV_CH_TOP_FRONT_CENTER 0x00002000 +#define AV_CH_TOP_FRONT_RIGHT 0x00004000 +#define AV_CH_TOP_BACK_LEFT 0x00008000 +#define AV_CH_TOP_BACK_CENTER 0x00010000 +#define AV_CH_TOP_BACK_RIGHT 0x00020000 +#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. +#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT. + +/** Channel mask value used for AVCodecContext.request_channel_layout + to indicate that the user requests the channel order of the decoder output + to be the native codec channel order. */ +#define AV_CH_LAYOUT_NATIVE 0x8000000000000000LL + +/* Audio channel convenience macros */ +#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER) +#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) +#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) +#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) +#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) +#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) + +/** + * Return a channel layout id that matches name, 0 if no match. + */ +int64_t av_get_channel_layout(const char *name); + +/** + * Return a description of a channel layout. + * If nb_channels is <= 0, it is guessed from the channel_layout. + * + * @param buf put here the string containing the channel layout + * @param buf_size size in bytes of the buffer + */ +void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout); + +/** + * Return the number of channels in the channel layout. + */ +int av_get_channel_layout_nb_channels(int64_t channel_layout); + +#endif /* AVUTIL_AUDIOCONVERT_H */ diff --git a/libavutil/avutil.h b/libavutil/avutil.h index d6338a7689..7d1d4ccd0f 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 50 -#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MINOR 38 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -93,6 +93,18 @@ enum AVMediaType { #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove +#define AV_NOPTS_VALUE INT64_C(0x8000000000000000) +#define AV_TIME_BASE 1000000 +#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} + +/** + * Those FF_API_* defines are not part of public API. + * They may change, break or disappear at any time. + */ +#ifndef FF_API_OLD_IMAGE_NAMES +#define FF_API_OLD_IMAGE_NAMES (LIBAVUTIL_VERSION_MAJOR < 51) +#endif + #include "common.h" #include "error.h" #include "mathematics.h" diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c new file mode 100644 index 0000000000..0f449ff427 --- /dev/null +++ b/libavutil/imgutils.c @@ -0,0 +1,297 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * misc image utilities + */ + +#include "imgutils.h" +#include "internal.h" +#include "libavutil/pixdesc.h" + +void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], + const AVPixFmtDescriptor *pixdesc) +{ + int i; + memset(max_pixsteps, 0, 4*sizeof(max_pixsteps[0])); + if (max_pixstep_comps) + memset(max_pixstep_comps, 0, 4*sizeof(max_pixstep_comps[0])); + + for (i = 0; i < 4; i++) { + const AVComponentDescriptor *comp = &(pixdesc->comp[i]); + if ((comp->step_minus1+1) > max_pixsteps[comp->plane]) { + max_pixsteps[comp->plane] = comp->step_minus1+1; + if (max_pixstep_comps) + max_pixstep_comps[comp->plane] = i; + } + } +} + +int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane) +{ + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + int max_step [4]; /* max pixel step for each plane */ + int max_step_comp[4]; /* the component for each plane which has the max pixel step */ + int s; + + if (desc->flags & PIX_FMT_BITSTREAM) + return (width * (desc->comp[0].step_minus1+1) + 7) >> 3; + + av_image_fill_max_pixsteps(max_step, max_step_comp, desc); + s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->log2_chroma_w : 0; + return max_step[plane] * (((width + (1 << s) - 1)) >> s); +} + +int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width) +{ + int i; + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + int max_step [4]; /* max pixel step for each plane */ + int max_step_comp[4]; /* the component for each plane which has the max pixel step */ + + memset(linesizes, 0, 4*sizeof(linesizes[0])); + + if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL) + return AVERROR(EINVAL); + + if (desc->flags & PIX_FMT_BITSTREAM) { + if (width > (INT_MAX -7) / (desc->comp[0].step_minus1+1)) + return AVERROR(EINVAL); + linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3; + return 0; + } + + av_image_fill_max_pixsteps(max_step, max_step_comp, desc); + for (i = 0; i < 4; i++) { + int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0; + int shifted_w = ((width + (1 << s) - 1)) >> s; + if (max_step[i] > INT_MAX / shifted_w) + return AVERROR(EINVAL); + linesizes[i] = max_step[i] * shifted_w; + } + + return 0; +} + +int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, + uint8_t *ptr, const int linesizes[4]) +{ + int i, total_size, size[4], has_plane[4]; + + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + memset(data , 0, sizeof(data[0])*4); + memset(size , 0, sizeof(size)); + memset(has_plane, 0, sizeof(has_plane)); + + if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL) + return AVERROR(EINVAL); + + data[0] = ptr; + if (linesizes[0] > (INT_MAX - 1024) / height) + return AVERROR(EINVAL); + size[0] = linesizes[0] * height; + + if (desc->flags & PIX_FMT_PAL) { + size[0] = (size[0] + 3) & ~3; + data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */ + return size[0] + 256 * 4; + } + + for (i = 0; i < 4; i++) + has_plane[desc->comp[i].plane] = 1; + + total_size = size[0]; + for (i = 1; has_plane[i] && i < 4; i++) { + int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; + data[i] = data[i-1] + size[i-1]; + h = (height + (1 << s) - 1) >> s; + if (linesizes[i] > INT_MAX / h) + return AVERROR(EINVAL); + size[i] = h * linesizes[i]; + if (total_size > INT_MAX - size[i]) + return AVERROR(EINVAL); + total_size += size[i]; + } + + return total_size; +} + +int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt) +{ + int i; + + for (i = 0; i < 256; i++) { + int r, g, b; + + switch (pix_fmt) { + case PIX_FMT_RGB8: + r = (i>>5 )*36; + g = ((i>>2)&7)*36; + b = (i&3 )*85; + break; + case PIX_FMT_BGR8: + b = (i>>6 )*85; + g = ((i>>3)&7)*36; + r = (i&7 )*36; + break; + case PIX_FMT_RGB4_BYTE: + r = (i>>3 )*255; + g = ((i>>1)&3)*85; + b = (i&1 )*255; + break; + case PIX_FMT_BGR4_BYTE: + b = (i>>3 )*255; + g = ((i>>1)&3)*85; + r = (i&1 )*255; + break; + case PIX_FMT_GRAY8: + r = b = g = i; + break; + default: + return AVERROR(EINVAL); + } + pal[i] = b + (g<<8) + (r<<16); + } + + return 0; +} + +int av_image_alloc(uint8_t *pointers[4], int linesizes[4], + int w, int h, enum PixelFormat pix_fmt, int align) +{ + int i, ret; + uint8_t *buf; + + if ((ret = av_image_check_size(w, h, 0, NULL)) < 0) + return ret; + if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, w)) < 0) + return ret; + + for (i = 0; i < 4; i++) + linesizes[i] = FFALIGN(linesizes[i], align); + + if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0) + return ret; + buf = av_malloc(ret + align); + if (!buf) + return AVERROR(ENOMEM); + if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) { + av_free(buf); + return ret; + } + if (av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_PAL) + ff_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt); + + return ret; +} + +typedef struct ImgUtils { + const AVClass *class; + int log_offset; + void *log_ctx; +} ImgUtils; + +static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) }; + +int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) +{ + ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx }; + + if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) + return 0; + + av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h); + return AVERROR(EINVAL); +} + +void av_image_copy_plane(uint8_t *dst, int dst_linesize, + const uint8_t *src, int src_linesize, + int bytewidth, int height) +{ + if (!dst || !src) + return; + for (;height > 0; height--) { + memcpy(dst, src, bytewidth); + dst += dst_linesize; + src += src_linesize; + } +} + +void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], + const uint8_t *src_data[4], const int src_linesizes[4], + enum PixelFormat pix_fmt, int width, int height) +{ + const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + + if (desc->flags & PIX_FMT_HWACCEL) + return; + + if (desc->flags & PIX_FMT_PAL) { + av_image_copy_plane(dst_data[0], dst_linesizes[0], + src_data[0], src_linesizes[0], + width, height); + /* copy the palette */ + memcpy(dst_data[1], src_data[1], 4*256); + } else { + int i, planes_nb = 0; + + for (i = 0; i < desc->nb_components; i++) + planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1); + + for (i = 0; i < planes_nb; i++) { + int h = height; + int bwidth = av_image_get_linesize(pix_fmt, width, i); + if (i == 1 || i == 2) { + h= -((-height)>>desc->log2_chroma_h); + } + av_image_copy_plane(dst_data[i], dst_linesizes[i], + src_data[i], src_linesizes[i], + bwidth, h); + } + } +} + +#if FF_API_OLD_IMAGE_NAMES +void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], + const AVPixFmtDescriptor *pixdesc) +{ + av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, pixdesc); +} + +int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane) +{ + return av_image_get_linesize(pix_fmt, width, plane); +} + +int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width) +{ + return av_image_fill_linesizes(linesizes, pix_fmt, width); +} + +int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, + uint8_t *ptr, const int linesizes[4]) +{ + return av_image_fill_pointers(data, pix_fmt, height, ptr, linesizes); +} + +int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) +{ + return av_image_check_size(w, h, log_offset, log_ctx); +} +#endif diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h new file mode 100644 index 0000000000..c181863579 --- /dev/null +++ b/libavutil/imgutils.h @@ -0,0 +1,149 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_IMGUTILS_H +#define AVUTIL_IMGUTILS_H + +/** + * @file + * misc image utilities + */ + +#include "libavutil/pixdesc.h" +#include "avutil.h" + +/** + * Compute the max pixel step for each plane of an image with a + * format described by pixdesc. + * + * The pixel step is the distance in bytes between the first byte of + * the group of bytes which describe a pixel component and the first + * byte of the successive group in the same plane for the same + * component. + * + * @param max_pixsteps an array which is filled with the max pixel step + * for each plane. Since a plane may contain different pixel + * components, the computed max_pixsteps[plane] is relative to the + * component in the plane with the max pixel step. + * @param max_pixstep_comps an array which is filled with the component + * for each plane which has the max pixel step. May be NULL. + */ +void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], + const AVPixFmtDescriptor *pixdesc); + +/** + * Compute the size of an image line with format pix_fmt and width + * width for the plane plane. + * + * @return the computed size in bytes + */ +int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane); + +/** + * Fill plane linesizes for an image with pixel format pix_fmt and + * width width. + * + * @param linesizes array to be filled with the linesize for each plane + * @return >= 0 in case of success, a negative error code otherwise + */ +int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width); + +/** + * Fill plane data pointers for an image with pixel format pix_fmt and + * height height. + * + * @param data pointers array to be filled with the pointer for each image plane + * @param ptr the pointer to a buffer which will contain the image + * @param linesizes[4] the array containing the linesize for each + * plane, should be filled by av_image_fill_linesizes() + * @return the size in bytes required for the image buffer, a negative + * error code in case of failure + */ +int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, + uint8_t *ptr, const int linesizes[4]); + +/** + * Allocate an image with size w and h and pixel format pix_fmt, and + * fill pointers and linesizes accordingly. + * The allocated image buffer has to be freed by using + * av_freep(&pointers[0]). + * + * @param align the value to use for buffer size alignment + * @return the size in bytes required for the image buffer, a negative + * error code in case of failure + */ +int av_image_alloc(uint8_t *pointers[4], int linesizes[4], + int w, int h, enum PixelFormat pix_fmt, int align); + +/** + * Copy image plane from src to dst. + * That is, copy "height" number of lines of "bytewidth" bytes each. + * The first byte of each successive line is separated by *_linesize + * bytes. + * + * @param dst_linesize linesize for the image plane in dst + * @param src_linesize linesize for the image plane in src + */ +void av_image_copy_plane(uint8_t *dst, int dst_linesize, + const uint8_t *src, int src_linesize, + int bytewidth, int height); + +/** + * Copy image in src_data to dst_data. + * + * @param dst_linesize linesizes for the image in dst_data + * @param src_linesize linesizes for the image in src_data + */ +void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], + const uint8_t *src_data[4], const int src_linesizes[4], + enum PixelFormat pix_fmt, int width, int height); + +/** + * Check if the given dimension of an image is valid, meaning that all + * bytes of the image can be addressed with a signed int. + * + * @param w the width of the picture + * @param h the height of the picture + * @param log_offset the offset to sum to the log level for logging with log_ctx + * @param log_ctx the parent logging context, it may be NULL + * @return >= 0 if valid, a negative error code otherwise + */ +int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); + +int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt); + +#if FF_API_OLD_IMAGE_NAMES +attribute_deprecated +void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], + const AVPixFmtDescriptor *pixdesc); + +attribute_deprecated +int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane); + +attribute_deprecated +int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width); + +attribute_deprecated +int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, + uint8_t *ptr, const int linesizes[4]); + +attribute_deprecated +int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); +#endif + +#endif /* AVUTIL_IMGUTILS_H */ diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c new file mode 100644 index 0000000000..09eebcf56f --- /dev/null +++ b/libavutil/parseutils.c @@ -0,0 +1,474 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * misc parsing utilities + */ + +#include +#include "parseutils.h" +#include "libavutil/avutil.h" +#include "libavutil/eval.h" +#include "libavutil/avstring.h" +#include "libavutil/random_seed.h" + +typedef struct { + const char *abbr; + int width, height; +} VideoSizeAbbr; + +typedef struct { + const char *abbr; + AVRational rate; +} VideoRateAbbr; + +static const VideoSizeAbbr video_size_abbrs[] = { + { "ntsc", 720, 480 }, + { "pal", 720, 576 }, + { "qntsc", 352, 240 }, /* VCD compliant NTSC */ + { "qpal", 352, 288 }, /* VCD compliant PAL */ + { "sntsc", 640, 480 }, /* square pixel NTSC */ + { "spal", 768, 576 }, /* square pixel PAL */ + { "film", 352, 240 }, + { "ntsc-film", 352, 240 }, + { "sqcif", 128, 96 }, + { "qcif", 176, 144 }, + { "cif", 352, 288 }, + { "4cif", 704, 576 }, + { "16cif", 1408,1152 }, + { "qqvga", 160, 120 }, + { "qvga", 320, 240 }, + { "vga", 640, 480 }, + { "svga", 800, 600 }, + { "xga", 1024, 768 }, + { "uxga", 1600,1200 }, + { "qxga", 2048,1536 }, + { "sxga", 1280,1024 }, + { "qsxga", 2560,2048 }, + { "hsxga", 5120,4096 }, + { "wvga", 852, 480 }, + { "wxga", 1366, 768 }, + { "wsxga", 1600,1024 }, + { "wuxga", 1920,1200 }, + { "woxga", 2560,1600 }, + { "wqsxga", 3200,2048 }, + { "wquxga", 3840,2400 }, + { "whsxga", 6400,4096 }, + { "whuxga", 7680,4800 }, + { "cga", 320, 200 }, + { "ega", 640, 350 }, + { "hd480", 852, 480 }, + { "hd720", 1280, 720 }, + { "hd1080", 1920,1080 }, +}; + +static const VideoRateAbbr video_rate_abbrs[]= { + { "ntsc", { 30000, 1001 } }, + { "pal", { 25, 1 } }, + { "qntsc", { 30000, 1001 } }, /* VCD compliant NTSC */ + { "qpal", { 25, 1 } }, /* VCD compliant PAL */ + { "sntsc", { 30000, 1001 } }, /* square pixel NTSC */ + { "spal", { 25, 1 } }, /* square pixel PAL */ + { "film", { 24, 1 } }, + { "ntsc-film", { 24000, 1001 } }, +}; + +int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str) +{ + int i; + int n = FF_ARRAY_ELEMS(video_size_abbrs); + char *p; + int width = 0, height = 0; + + for (i = 0; i < n; i++) { + if (!strcmp(video_size_abbrs[i].abbr, str)) { + width = video_size_abbrs[i].width; + height = video_size_abbrs[i].height; + break; + } + } + if (i == n) { + p = str; + width = strtol(p, &p, 10); + if (*p) + p++; + height = strtol(p, &p, 10); + } + if (width <= 0 || height <= 0) + return AVERROR(EINVAL); + *width_ptr = width; + *height_ptr = height; + return 0; +} + +int av_parse_video_rate(AVRational *rate, const char *arg) +{ + int i, ret; + int n = FF_ARRAY_ELEMS(video_rate_abbrs); + double res; + + /* First, we check our abbreviation table */ + for (i = 0; i < n; ++i) + if (!strcmp(video_rate_abbrs[i].abbr, arg)) { + *rate = video_rate_abbrs[i].rate; + return 0; + } + + /* Then, we try to parse it as fraction */ + if ((ret = av_expr_parse_and_eval(&res, arg, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, 0, NULL)) < 0) + return ret; + *rate = av_d2q(res, 1001000); + if (rate->num <= 0 || rate->den <= 0) + return AVERROR(EINVAL); + return 0; +} + +typedef struct { + const char *name; ///< a string representing the name of the color + uint8_t rgb_color[3]; ///< RGB values for the color +} ColorEntry; + +static ColorEntry color_table[] = { + { "AliceBlue", { 0xF0, 0xF8, 0xFF } }, + { "AntiqueWhite", { 0xFA, 0xEB, 0xD7 } }, + { "Aqua", { 0x00, 0xFF, 0xFF } }, + { "Aquamarine", { 0x7F, 0xFF, 0xD4 } }, + { "Azure", { 0xF0, 0xFF, 0xFF } }, + { "Beige", { 0xF5, 0xF5, 0xDC } }, + { "Bisque", { 0xFF, 0xE4, 0xC4 } }, + { "Black", { 0x00, 0x00, 0x00 } }, + { "BlanchedAlmond", { 0xFF, 0xEB, 0xCD } }, + { "Blue", { 0x00, 0x00, 0xFF } }, + { "BlueViolet", { 0x8A, 0x2B, 0xE2 } }, + { "Brown", { 0xA5, 0x2A, 0x2A } }, + { "BurlyWood", { 0xDE, 0xB8, 0x87 } }, + { "CadetBlue", { 0x5F, 0x9E, 0xA0 } }, + { "Chartreuse", { 0x7F, 0xFF, 0x00 } }, + { "Chocolate", { 0xD2, 0x69, 0x1E } }, + { "Coral", { 0xFF, 0x7F, 0x50 } }, + { "CornflowerBlue", { 0x64, 0x95, 0xED } }, + { "Cornsilk", { 0xFF, 0xF8, 0xDC } }, + { "Crimson", { 0xDC, 0x14, 0x3C } }, + { "Cyan", { 0x00, 0xFF, 0xFF } }, + { "DarkBlue", { 0x00, 0x00, 0x8B } }, + { "DarkCyan", { 0x00, 0x8B, 0x8B } }, + { "DarkGoldenRod", { 0xB8, 0x86, 0x0B } }, + { "DarkGray", { 0xA9, 0xA9, 0xA9 } }, + { "DarkGreen", { 0x00, 0x64, 0x00 } }, + { "DarkKhaki", { 0xBD, 0xB7, 0x6B } }, + { "DarkMagenta", { 0x8B, 0x00, 0x8B } }, + { "DarkOliveGreen", { 0x55, 0x6B, 0x2F } }, + { "Darkorange", { 0xFF, 0x8C, 0x00 } }, + { "DarkOrchid", { 0x99, 0x32, 0xCC } }, + { "DarkRed", { 0x8B, 0x00, 0x00 } }, + { "DarkSalmon", { 0xE9, 0x96, 0x7A } }, + { "DarkSeaGreen", { 0x8F, 0xBC, 0x8F } }, + { "DarkSlateBlue", { 0x48, 0x3D, 0x8B } }, + { "DarkSlateGray", { 0x2F, 0x4F, 0x4F } }, + { "DarkTurquoise", { 0x00, 0xCE, 0xD1 } }, + { "DarkViolet", { 0x94, 0x00, 0xD3 } }, + { "DeepPink", { 0xFF, 0x14, 0x93 } }, + { "DeepSkyBlue", { 0x00, 0xBF, 0xFF } }, + { "DimGray", { 0x69, 0x69, 0x69 } }, + { "DodgerBlue", { 0x1E, 0x90, 0xFF } }, + { "FireBrick", { 0xB2, 0x22, 0x22 } }, + { "FloralWhite", { 0xFF, 0xFA, 0xF0 } }, + { "ForestGreen", { 0x22, 0x8B, 0x22 } }, + { "Fuchsia", { 0xFF, 0x00, 0xFF } }, + { "Gainsboro", { 0xDC, 0xDC, 0xDC } }, + { "GhostWhite", { 0xF8, 0xF8, 0xFF } }, + { "Gold", { 0xFF, 0xD7, 0x00 } }, + { "GoldenRod", { 0xDA, 0xA5, 0x20 } }, + { "Gray", { 0x80, 0x80, 0x80 } }, + { "Green", { 0x00, 0x80, 0x00 } }, + { "GreenYellow", { 0xAD, 0xFF, 0x2F } }, + { "HoneyDew", { 0xF0, 0xFF, 0xF0 } }, + { "HotPink", { 0xFF, 0x69, 0xB4 } }, + { "IndianRed", { 0xCD, 0x5C, 0x5C } }, + { "Indigo", { 0x4B, 0x00, 0x82 } }, + { "Ivory", { 0xFF, 0xFF, 0xF0 } }, + { "Khaki", { 0xF0, 0xE6, 0x8C } }, + { "Lavender", { 0xE6, 0xE6, 0xFA } }, + { "LavenderBlush", { 0xFF, 0xF0, 0xF5 } }, + { "LawnGreen", { 0x7C, 0xFC, 0x00 } }, + { "LemonChiffon", { 0xFF, 0xFA, 0xCD } }, + { "LightBlue", { 0xAD, 0xD8, 0xE6 } }, + { "LightCoral", { 0xF0, 0x80, 0x80 } }, + { "LightCyan", { 0xE0, 0xFF, 0xFF } }, + { "LightGoldenRodYellow", { 0xFA, 0xFA, 0xD2 } }, + { "LightGrey", { 0xD3, 0xD3, 0xD3 } }, + { "LightGreen", { 0x90, 0xEE, 0x90 } }, + { "LightPink", { 0xFF, 0xB6, 0xC1 } }, + { "LightSalmon", { 0xFF, 0xA0, 0x7A } }, + { "LightSeaGreen", { 0x20, 0xB2, 0xAA } }, + { "LightSkyBlue", { 0x87, 0xCE, 0xFA } }, + { "LightSlateGray", { 0x77, 0x88, 0x99 } }, + { "LightSteelBlue", { 0xB0, 0xC4, 0xDE } }, + { "LightYellow", { 0xFF, 0xFF, 0xE0 } }, + { "Lime", { 0x00, 0xFF, 0x00 } }, + { "LimeGreen", { 0x32, 0xCD, 0x32 } }, + { "Linen", { 0xFA, 0xF0, 0xE6 } }, + { "Magenta", { 0xFF, 0x00, 0xFF } }, + { "Maroon", { 0x80, 0x00, 0x00 } }, + { "MediumAquaMarine", { 0x66, 0xCD, 0xAA } }, + { "MediumBlue", { 0x00, 0x00, 0xCD } }, + { "MediumOrchid", { 0xBA, 0x55, 0xD3 } }, + { "MediumPurple", { 0x93, 0x70, 0xD8 } }, + { "MediumSeaGreen", { 0x3C, 0xB3, 0x71 } }, + { "MediumSlateBlue", { 0x7B, 0x68, 0xEE } }, + { "MediumSpringGreen", { 0x00, 0xFA, 0x9A } }, + { "MediumTurquoise", { 0x48, 0xD1, 0xCC } }, + { "MediumVioletRed", { 0xC7, 0x15, 0x85 } }, + { "MidnightBlue", { 0x19, 0x19, 0x70 } }, + { "MintCream", { 0xF5, 0xFF, 0xFA } }, + { "MistyRose", { 0xFF, 0xE4, 0xE1 } }, + { "Moccasin", { 0xFF, 0xE4, 0xB5 } }, + { "NavajoWhite", { 0xFF, 0xDE, 0xAD } }, + { "Navy", { 0x00, 0x00, 0x80 } }, + { "OldLace", { 0xFD, 0xF5, 0xE6 } }, + { "Olive", { 0x80, 0x80, 0x00 } }, + { "OliveDrab", { 0x6B, 0x8E, 0x23 } }, + { "Orange", { 0xFF, 0xA5, 0x00 } }, + { "OrangeRed", { 0xFF, 0x45, 0x00 } }, + { "Orchid", { 0xDA, 0x70, 0xD6 } }, + { "PaleGoldenRod", { 0xEE, 0xE8, 0xAA } }, + { "PaleGreen", { 0x98, 0xFB, 0x98 } }, + { "PaleTurquoise", { 0xAF, 0xEE, 0xEE } }, + { "PaleVioletRed", { 0xD8, 0x70, 0x93 } }, + { "PapayaWhip", { 0xFF, 0xEF, 0xD5 } }, + { "PeachPuff", { 0xFF, 0xDA, 0xB9 } }, + { "Peru", { 0xCD, 0x85, 0x3F } }, + { "Pink", { 0xFF, 0xC0, 0xCB } }, + { "Plum", { 0xDD, 0xA0, 0xDD } }, + { "PowderBlue", { 0xB0, 0xE0, 0xE6 } }, + { "Purple", { 0x80, 0x00, 0x80 } }, + { "Red", { 0xFF, 0x00, 0x00 } }, + { "RosyBrown", { 0xBC, 0x8F, 0x8F } }, + { "RoyalBlue", { 0x41, 0x69, 0xE1 } }, + { "SaddleBrown", { 0x8B, 0x45, 0x13 } }, + { "Salmon", { 0xFA, 0x80, 0x72 } }, + { "SandyBrown", { 0xF4, 0xA4, 0x60 } }, + { "SeaGreen", { 0x2E, 0x8B, 0x57 } }, + { "SeaShell", { 0xFF, 0xF5, 0xEE } }, + { "Sienna", { 0xA0, 0x52, 0x2D } }, + { "Silver", { 0xC0, 0xC0, 0xC0 } }, + { "SkyBlue", { 0x87, 0xCE, 0xEB } }, + { "SlateBlue", { 0x6A, 0x5A, 0xCD } }, + { "SlateGray", { 0x70, 0x80, 0x90 } }, + { "Snow", { 0xFF, 0xFA, 0xFA } }, + { "SpringGreen", { 0x00, 0xFF, 0x7F } }, + { "SteelBlue", { 0x46, 0x82, 0xB4 } }, + { "Tan", { 0xD2, 0xB4, 0x8C } }, + { "Teal", { 0x00, 0x80, 0x80 } }, + { "Thistle", { 0xD8, 0xBF, 0xD8 } }, + { "Tomato", { 0xFF, 0x63, 0x47 } }, + { "Turquoise", { 0x40, 0xE0, 0xD0 } }, + { "Violet", { 0xEE, 0x82, 0xEE } }, + { "Wheat", { 0xF5, 0xDE, 0xB3 } }, + { "White", { 0xFF, 0xFF, 0xFF } }, + { "WhiteSmoke", { 0xF5, 0xF5, 0xF5 } }, + { "Yellow", { 0xFF, 0xFF, 0x00 } }, + { "YellowGreen", { 0x9A, 0xCD, 0x32 } }, +}; + +static int color_table_compare(const void *lhs, const void *rhs) +{ + return strcasecmp(lhs, ((const ColorEntry *)rhs)->name); +} + +#define ALPHA_SEP '@' + +int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, + void *log_ctx) +{ + char *tail, color_string2[128]; + const ColorEntry *entry; + int len, hex_offset = 0; + + if (color_string[0] == '#') { + hex_offset = 1; + } else if (!strncmp(color_string, "0x", 2)) + hex_offset = 2; + + if (slen < 0) + slen = strlen(color_string); + av_strlcpy(color_string2, color_string + hex_offset, + FFMIN(slen-hex_offset+1, sizeof(color_string2))); + if ((tail = strchr(color_string2, ALPHA_SEP))) + *tail++ = 0; + len = strlen(color_string2); + rgba_color[3] = 255; + + if (!strcasecmp(color_string2, "random") || !strcasecmp(color_string2, "bikeshed")) { + int rgba = av_get_random_seed(); + rgba_color[0] = rgba >> 24; + rgba_color[1] = rgba >> 16; + rgba_color[2] = rgba >> 8; + rgba_color[3] = rgba; + } else if (hex_offset || + strspn(color_string2, "0123456789ABCDEFabcdef") == len) { + char *tail; + unsigned int rgba = strtoul(color_string2, &tail, 16); + + if (*tail || (len != 6 && len != 8)) { + av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string2); + return AVERROR(EINVAL); + } + if (len == 8) { + rgba_color[3] = rgba; + rgba >>= 8; + } + rgba_color[0] = rgba >> 16; + rgba_color[1] = rgba >> 8; + rgba_color[2] = rgba; + } else { + entry = bsearch(color_string2, + color_table, + FF_ARRAY_ELEMS(color_table), + sizeof(ColorEntry), + color_table_compare); + if (!entry) { + av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string2); + return AVERROR(EINVAL); + } + memcpy(rgba_color, entry->rgb_color, 3); + } + + if (tail) { + unsigned long int alpha; + const char *alpha_string = tail; + if (!strncmp(alpha_string, "0x", 2)) { + alpha = strtoul(alpha_string, &tail, 16); + } else { + alpha = 255 * strtod(alpha_string, &tail); + } + + if (tail == alpha_string || *tail || alpha > 255) { + av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n", + alpha_string, color_string); + return AVERROR(EINVAL); + } + rgba_color[3] = alpha; + } + + return 0; +} + +#ifdef TEST + +#undef printf + +int main(void) +{ + printf("Testing av_parse_video_rate()\n"); + { + int i; + const char *rates[] = { + "-inf", + "inf", + "nan", + "123/0", + "-123 / 0", + "", + "/", + " 123 / 321", + "foo/foo", + "foo/1", + "1/foo", + "0/0", + "/0", + "1/", + "1", + "0", + "-123/123", + "-foo", + "123.23", + ".23", + "-.23", + "-0.234", + "-0.0000001", + " 21332.2324 ", + " -21332.2324 ", + }; + + for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) { + int ret; + AVRational q = (AVRational){0, 0}; + ret = av_parse_video_rate(&q, rates[i]), + printf("'%s' -> %d/%d ret:%d\n", + rates[i], q.num, q.den, ret); + } + } + + printf("\nTesting av_parse_color()\n"); + { + int i; + uint8_t rgba[4]; + const char *color_names[] = { + "bikeshed", + "RaNdOm", + "foo", + "red", + "Red ", + "RED", + "Violet", + "Yellow", + "Red", + "0x000000", + "0x0000000", + "0xff000000", + "0x3e34ff", + "0x3e34ffaa", + "0xffXXee", + "0xfoobar", + "0xffffeeeeeeee", + "#ff0000", + "#ffXX00", + "ff0000", + "ffXX00", + "red@foo", + "random@10", + "0xff0000@1.0", + "red@", + "red@0xfff", + "red@0xf", + "red@2", + "red@0.1", + "red@-1", + "red@0.5", + "red@1.0", + "red@256", + "red@10foo", + "red@-1.0", + "red@-0.0", + }; + + av_log_set_level(AV_LOG_DEBUG); + + for (i = 0; i < FF_ARRAY_ELEMS(color_names); i++) { + if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0) + printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]); + } + } + + return 0; +} + +#endif /* TEST */ diff --git a/libavutil/parseutils.h b/libavutil/parseutils.h new file mode 100644 index 0000000000..2c99872289 --- /dev/null +++ b/libavutil/parseutils.h @@ -0,0 +1,75 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_PARSEUTILS_H +#define AVUTIL_PARSEUTILS_H + +#include "libavutil/rational.h" + +/** + * @file + * misc parsing utilities + */ + +/** + * Parse str and put in width_ptr and height_ptr the detected values. + * + * @param[in,out] width_ptr pointer to the variable which will contain the detected + * width value + * @param[in,out] height_ptr pointer to the variable which will contain the detected + * height value + * @param[in] str the string to parse: it has to be a string in the format + * width x height or a valid video size abbreviation. + * @return >= 0 on success, a negative error code otherwise + */ +int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str); + +/** + * Parse str and store the detected values in *rate. + * + * @param[in,out] rate pointer to the AVRational which will contain the detected + * frame rate + * @param[in] str the string to parse: it has to be a string in the format + * rate_num / rate_den, a float number or a valid video rate abbreviation + * @return >= 0 on success, a negative error code otherwise + */ +int av_parse_video_rate(AVRational *rate, const char *str); + +/** + * Put the RGBA values that correspond to color_string in rgba_color. + * + * @param color_string a string specifying a color. It can be the name of + * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, + * possibly followed by "@" and a string representing the alpha + * component. + * The alpha component may be a string composed by "0x" followed by an + * hexadecimal number or a decimal number between 0.0 and 1.0, which + * represents the opacity value (0x00/0.0 means completely transparent, + * 0xff/1.0 completely opaque). + * If the alpha component is not specified then 0xff is assumed. + * The string "random" will result in a random color. + * @param slen length of the initial part of color_string containing the + * color. It can be set to -1 if color_string is a null terminated string + * containing nothing else than the color. + * @return >= 0 in case of success, a negative value in case of + * failure (for example if color_string cannot be parsed). + */ +int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, + void *log_ctx); + +#endif /* AVUTIL_PARSEUTILS_H */ diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c new file mode 100644 index 0000000000..c9ffd1ac55 --- /dev/null +++ b/libavutil/samplefmt.c @@ -0,0 +1,73 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "samplefmt.h" + +#include +#include +#include + +typedef struct SampleFmtInfo { + const char *name; + int bits; +} SampleFmtInfo; + +/** this table gives more information about formats */ +static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = { + [AV_SAMPLE_FMT_U8] = { .name = "u8", .bits = 8 }, + [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16 }, + [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32 }, + [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32 }, + [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64 }, +}; + +const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt) +{ + if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) + return NULL; + return sample_fmt_info[sample_fmt].name; +} + +enum AVSampleFormat av_get_sample_fmt(const char *name) +{ + int i; + + for (i = 0; i < AV_SAMPLE_FMT_NB; i++) + if (!strcmp(sample_fmt_info[i].name, name)) + return i; + return AV_SAMPLE_FMT_NONE; +} + +char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt) +{ + /* print header */ + if (sample_fmt < 0) + snprintf(buf, buf_size, "name " " depth"); + else if (sample_fmt < AV_SAMPLE_FMT_NB) { + SampleFmtInfo info = sample_fmt_info[sample_fmt]; + snprintf (buf, buf_size, "%-6s" " %2d ", info.name, info.bits); + } + + return buf; +} + +int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) +{ + return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? + 0 : sample_fmt_info[sample_fmt].bits; +} diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h new file mode 100644 index 0000000000..0604580a7a --- /dev/null +++ b/libavutil/samplefmt.h @@ -0,0 +1,70 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_SAMPLEFMT_H +#define AVUTIL_SAMPLEFMT_H + +/** + * all in native-endian format + */ +enum AVSampleFormat { + AV_SAMPLE_FMT_NONE = -1, + AV_SAMPLE_FMT_U8, ///< unsigned 8 bits + AV_SAMPLE_FMT_S16, ///< signed 16 bits + AV_SAMPLE_FMT_S32, ///< signed 32 bits + AV_SAMPLE_FMT_FLT, ///< float + AV_SAMPLE_FMT_DBL, ///< double + AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically +}; + +/** + * Return the name of sample_fmt, or NULL if sample_fmt is not + * recognized. + */ +const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt); + +/** + * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE + * on error. + */ +enum AVSampleFormat av_get_sample_fmt(const char *name); + +/** + * Generate a string corresponding to the sample format with + * sample_fmt, or a header if sample_fmt is negative. + * + * @param buf the buffer where to write the string + * @param buf_size the size of buf + * @param sample_fmt the number of the sample format to print the + * corresponding info string, or a negative value to print the + * corresponding header. + * @return the pointer to the filled buffer or NULL if sample_fmt is + * unknown or in case of other errors + */ +char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); + +/** + * Return sample format bits per sample. + * + * @param sample_fmt the sample format + * @return number of bits per sample or zero if unknown for the given + * sample format + */ +int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); + +#endif /* AVUTIL_SAMPLEFMT_H */ diff --git a/libswscale/Makefile b/libswscale/Makefile index 8c5c4b9da4..6976079686 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -20,4 +20,3 @@ TESTPROGS = colorspace swscale DIRS = bfin mlib ppc sparc x86 include $(SUBDIR)../subdir.mak -$(SUBDIR)swscale-test$(EXESUF): ELIBS = -lavcore diff --git a/libswscale/swscale-test.c b/libswscale/swscale-test.c index bd24f3e006..7f171ea725 100644 --- a/libswscale/swscale-test.c +++ b/libswscale/swscale-test.c @@ -25,7 +25,7 @@ #include #undef HAVE_AV_CONFIG_H -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "libavutil/mem.h" #include "libavutil/avutil.h" #include "libavutil/crc.h" -- cgit v1.2.3