[FFmpeg-cvslog] Merge commit 'c95169f0ec68bdeeabc5fde8aa4076f406242524'
James Almer
git at videolan.org
Mon Oct 2 00:28:18 EEST 2017
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Oct 1 18:21:02 2017 -0300| [fd5f4ac0813c27c34c387f00044905a859e29e37] | committer: James Almer
Merge commit 'c95169f0ec68bdeeabc5fde8aa4076f406242524'
* commit 'c95169f0ec68bdeeabc5fde8aa4076f406242524':
build: Move cli tool sources to a separate subdirectory
Merged-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fd5f4ac0813c27c34c387f00044905a859e29e37
---
Makefile | 60 ++--------------------
doc/examples/Makefile | 2 +-
fftools/Makefile | 57 ++++++++++++++++++++
cmdutils.c => fftools/cmdutils.c | 0
cmdutils.h => fftools/cmdutils.h | 6 +--
cmdutils_opencl.c => fftools/cmdutils_opencl.c | 0
ffmpeg.c => fftools/ffmpeg.c | 0
ffmpeg.h => fftools/ffmpeg.h | 6 +--
ffmpeg_cuvid.c => fftools/ffmpeg_cuvid.c | 0
ffmpeg_filter.c => fftools/ffmpeg_filter.c | 0
ffmpeg_hw.c => fftools/ffmpeg_hw.c | 0
ffmpeg_opt.c => fftools/ffmpeg_opt.c | 0
ffmpeg_qsv.c => fftools/ffmpeg_qsv.c | 0
.../ffmpeg_videotoolbox.c | 0
ffplay.c => fftools/ffplay.c | 0
ffprobe.c => fftools/ffprobe.c | 0
ffserver.c => fftools/ffserver.c | 0
ffserver_config.c => fftools/ffserver_config.c | 0
ffserver_config.h => fftools/ffserver_config.h | 6 +--
19 files changed, 71 insertions(+), 66 deletions(-)
diff --git a/Makefile b/Makefile
index 6de5a3d145..3007da50f7 100644
--- a/Makefile
+++ b/Makefile
@@ -15,31 +15,6 @@ vpath %.cu $(SRC_PATH)
vpath %.ptx $(SRC_PATH)
vpath %/fate_config.sh.template $(SRC_PATH)
-AVPROGS-$(CONFIG_FFMPEG) += ffmpeg
-AVPROGS-$(CONFIG_FFPLAY) += ffplay
-AVPROGS-$(CONFIG_FFPROBE) += ffprobe
-AVPROGS-$(CONFIG_FFSERVER) += ffserver
-
-AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
-INSTPROGS = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
-PROGS += $(AVPROGS)
-
-AVBASENAMES = ffmpeg ffplay ffprobe ffserver
-ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
-ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
-
-$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
-$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o))
-
-OBJS-ffmpeg += ffmpeg_opt.o ffmpeg_filter.o ffmpeg_hw.o
-OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
-OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o
-ifndef CONFIG_VIDEOTOOLBOX
-OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o
-endif
-OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o
-OBJS-ffserver += ffserver_config.o
-
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
@@ -69,8 +44,6 @@ FF_EXTRALIBS := $(FFEXTRALIBS)
FF_DEP_LIBS := $(DEP_LIBS)
FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
-all: $(AVPROGS)
-
$(TOOLS): %$(EXESUF): %.o
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
@@ -117,27 +90,17 @@ endef
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
+include $(SRC_PATH)/fftools/Makefile
include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/doc/examples/Makefile
-define DOPROG
-OBJS-$(1) += $(1).o $(OBJS-$(1)-yes)
-$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
-$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
-$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
-$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1))
--include $$(OBJS-$(1):.o=.d)
-endef
-
-$(foreach P,$(AVPROGS-yes),$(eval $(call DOPROG,$(P))))
-
-ffprobe.o cmdutils.o libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
+libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
$(CP) $< $@
$(STRIP) $@
-%$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
+%$(PROGSSUF)_g$(EXESUF): $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
VERSION_SH = $(SRC_PATH)/ffbuild/version.sh
@@ -153,37 +116,22 @@ libavutil/ffversion.h .version:
# force version.sh to run whenever version might have changed
-include .version
-ifdef AVPROGS
-install: install-progs install-data
-endif
-
install: install-libs install-headers
install-libs: install-libs-yes
-install-progs-yes:
-install-progs-$(CONFIG_SHARED): install-libs
-
-install-progs: install-progs-yes $(AVPROGS)
- $(Q)mkdir -p "$(BINDIR)"
- $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
-
install-data: $(DATA_FILES) $(EXAMPLES_FILES) $(EXAMPLE_MAKEFILE)
$(Q)mkdir -p "$(DATADIR)/examples"
$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
$(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
$(INSTALL) -m 644 $(EXAMPLE_MAKEFILE:%=%.example) "$(DATADIR)/examples/Makefile"
-uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
-
-uninstall-progs:
- $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
+uninstall: uninstall-libs uninstall-headers uninstall-data
uninstall-data:
$(RM) -r "$(DATADIR)"
clean::
- $(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
$(RM) $(CLEANSUFFIXES)
$(RM) $(CLEANSUFFIXES:%=compat/msvcrt/%)
$(RM) $(CLEANSUFFIXES:%=compat/atomics/pthread/%)
diff --git a/doc/examples/Makefile b/doc/examples/Makefile
index f0c4f7969e..ff958d33c6 100644
--- a/doc/examples/Makefile
+++ b/doc/examples/Makefile
@@ -30,7 +30,7 @@ EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examp
EXAMPLE_MAKEFILE := $(SRC_PATH)/doc/examples/Makefile
$(foreach P,$(DOC_EXAMPLES),$(eval OBJS-$(P:%$(PROGSSUF)$(EXESUF)=%) = $(P:%$(PROGSSUF)$(EXESUF)=%).o))
-$(DOC_EXAMPLES): %$(PROGSSUF)$(EXESUF): %.o
+$(DOC_EXAMPLES_G): %$(PROGSSUF)_g$(EXESUF): %.o
examples: $(DOC_EXAMPLES)
diff --git a/fftools/Makefile b/fftools/Makefile
new file mode 100644
index 0000000000..094f6d6265
--- /dev/null
+++ b/fftools/Makefile
@@ -0,0 +1,57 @@
+AVPROGS-$(CONFIG_FFMPEG) += ffmpeg
+AVPROGS-$(CONFIG_FFPLAY) += ffplay
+AVPROGS-$(CONFIG_FFPROBE) += ffprobe
+AVPROGS-$(CONFIG_FFSERVER) += ffserver
+
+AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
+PROGS += $(AVPROGS)
+
+AVBASENAMES = ffmpeg ffplay ffprobe ffserver
+ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
+ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
+
+OBJS-ffmpeg += fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o
+OBJS-ffmpeg-$(CONFIG_CUVID) += fftools/ffmpeg_cuvid.o
+OBJS-ffmpeg-$(CONFIG_LIBMFX) += fftools/ffmpeg_qsv.o
+ifndef CONFIG_VIDEOTOOLBOX
+OBJS-ffmpeg-$(CONFIG_VDA) += fftools/ffmpeg_videotoolbox.o
+endif
+OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += fftools/ffmpeg_videotoolbox.o
+OBJS-ffserver += fftools/ffserver_config.o
+
+define DOFFTOOL
+OBJS-$(1)-$(CONFIG_OPENCL) += fftools/cmdutils_opencl.o
+OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes)
+$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
+$$(OBJS-$(1)): | fftools
+$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
+$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
+$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1))
+-include $$(OBJS-$(1):.o=.d)
+endef
+
+$(foreach P,$(AVPROGS-yes),$(eval $(call DOFFTOOL,$(P))))
+
+all: $(AVPROGS)
+
+fftools/ffprobe.o fftools/cmdutils.o: libavutil/ffversion.h | fftools
+OBJDIRS += fftools
+
+ifdef AVPROGS
+install: install-progs install-data
+endif
+
+install-progs-yes:
+install-progs-$(CONFIG_SHARED): install-libs
+
+install-progs: install-progs-yes $(AVPROGS)
+ $(Q)mkdir -p "$(BINDIR)"
+ $(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)"
+
+uninstall: uninstall-progs
+
+uninstall-progs:
+ $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
+
+clean::
+ $(RM) $(ALLAVPROGS) $(ALLAVPROGS_G) $(CLEANSUFFIXES:%=fftools/%)
diff --git a/cmdutils.c b/fftools/cmdutils.c
similarity index 100%
rename from cmdutils.c
rename to fftools/cmdutils.c
diff --git a/cmdutils.h b/fftools/cmdutils.h
similarity index 99%
rename from cmdutils.h
rename to fftools/cmdutils.h
index e1d64d8986..2997ee37b5 100644
--- a/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -19,8 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef CMDUTILS_H
-#define CMDUTILS_H
+#ifndef FFTOOLS_CMDUTILS_H
+#define FFTOOLS_CMDUTILS_H
#include <stdint.h>
@@ -659,4 +659,4 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
double get_rotation(AVStream *st);
-#endif /* CMDUTILS_H */
+#endif /* FFTOOLS_CMDUTILS_H */
diff --git a/cmdutils_opencl.c b/fftools/cmdutils_opencl.c
similarity index 100%
rename from cmdutils_opencl.c
rename to fftools/cmdutils_opencl.c
diff --git a/ffmpeg.c b/fftools/ffmpeg.c
similarity index 100%
rename from ffmpeg.c
rename to fftools/ffmpeg.c
diff --git a/ffmpeg.h b/fftools/ffmpeg.h
similarity index 99%
rename from ffmpeg.h
rename to fftools/ffmpeg.h
index d2deb432b7..f6c76bcc55 100644
--- a/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef FFMPEG_H
-#define FFMPEG_H
+#ifndef FFTOOLS_FFMPEG_H
+#define FFTOOLS_FFMPEG_H
#include "config.h"
@@ -676,4 +676,4 @@ int hw_device_setup_for_encode(OutputStream *ost);
int hwaccel_decode_init(AVCodecContext *avctx);
-#endif /* FFMPEG_H */
+#endif /* FFTOOLS_FFMPEG_H */
diff --git a/ffmpeg_cuvid.c b/fftools/ffmpeg_cuvid.c
similarity index 100%
rename from ffmpeg_cuvid.c
rename to fftools/ffmpeg_cuvid.c
diff --git a/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
similarity index 100%
rename from ffmpeg_filter.c
rename to fftools/ffmpeg_filter.c
diff --git a/ffmpeg_hw.c b/fftools/ffmpeg_hw.c
similarity index 100%
rename from ffmpeg_hw.c
rename to fftools/ffmpeg_hw.c
diff --git a/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
similarity index 100%
rename from ffmpeg_opt.c
rename to fftools/ffmpeg_opt.c
diff --git a/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
similarity index 100%
rename from ffmpeg_qsv.c
rename to fftools/ffmpeg_qsv.c
diff --git a/ffmpeg_videotoolbox.c b/fftools/ffmpeg_videotoolbox.c
similarity index 100%
rename from ffmpeg_videotoolbox.c
rename to fftools/ffmpeg_videotoolbox.c
diff --git a/ffplay.c b/fftools/ffplay.c
similarity index 100%
rename from ffplay.c
rename to fftools/ffplay.c
diff --git a/ffprobe.c b/fftools/ffprobe.c
similarity index 100%
rename from ffprobe.c
rename to fftools/ffprobe.c
diff --git a/ffserver.c b/fftools/ffserver.c
similarity index 100%
rename from ffserver.c
rename to fftools/ffserver.c
diff --git a/ffserver_config.c b/fftools/ffserver_config.c
similarity index 100%
rename from ffserver_config.c
rename to fftools/ffserver_config.c
diff --git a/ffserver_config.h b/fftools/ffserver_config.h
similarity index 98%
rename from ffserver_config.h
rename to fftools/ffserver_config.h
index 48d38dc325..089b8484da 100644
--- a/ffserver_config.h
+++ b/fftools/ffserver_config.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef FFSERVER_CONFIG_H
-#define FFSERVER_CONFIG_H
+#ifndef FFTOOLS_FFSERVER_CONFIG_H
+#define FFTOOLS_FFSERVER_CONFIG_H
#define FFM_PACKET_SIZE 4096
@@ -152,4 +152,4 @@ int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config);
void ffserver_free_child_args(void *argsp);
-#endif /* FFSERVER_CONFIG_H */
+#endif /* FFTOOLS_FFSERVER_CONFIG_H */
======================================================================
diff --cc Makefile
index 6de5a3d145,a3cd0846e1..3007da50f7
--- a/Makefile
+++ b/Makefile
@@@ -1,46 -1,75 +1,21 @@@
-include avbuild/config.mak
+MAIN_MAKEFILE=1
+include ffbuild/config.mak
vpath %.c $(SRC_PATH)
-vpath %.m $(SRC_PATH)
+vpath %.cpp $(SRC_PATH)
vpath %.h $(SRC_PATH)
+vpath %.inc $(SRC_PATH)
+vpath %.m $(SRC_PATH)
vpath %.S $(SRC_PATH)
vpath %.asm $(SRC_PATH)
+vpath %.rc $(SRC_PATH)
vpath %.v $(SRC_PATH)
vpath %.texi $(SRC_PATH)
+vpath %.cu $(SRC_PATH)
+vpath %.ptx $(SRC_PATH)
+vpath %/fate_config.sh.template $(SRC_PATH)
- AVPROGS-$(CONFIG_FFMPEG) += ffmpeg
- AVPROGS-$(CONFIG_FFPLAY) += ffplay
- AVPROGS-$(CONFIG_FFPROBE) += ffprobe
- AVPROGS-$(CONFIG_FFSERVER) += ffserver
-ifndef V
-Q = @
-ECHO = printf "$(1)\t%s\n" $(2)
-BRIEF = CC HOSTCC HOSTLD AS YASM AR LD
-SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM STRIP
-MSG = $@
-M = @$(call ECHO,$(TAG),$@);
-$(foreach VAR,$(BRIEF), \
- $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
-$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
-$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL))
-endif
--
- AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
- INSTPROGS = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
- PROGS += $(AVPROGS)
-ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil swscale
--
- AVBASENAMES = ffmpeg ffplay ffprobe ffserver
- ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
- ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
-IFLAGS := -I. -I$(SRC_PATH)
-CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
-CFLAGS += $(ECFLAGS)
-CCFLAGS = $(CPPFLAGS) $(CFLAGS)
-OBJCFLAGS += $(EOBJCFLAGS)
-OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
-ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
-YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
-HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
-LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
--
- $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
- $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o))
-define COMPILE
- $(call $(1)DEP,$(1))
- $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
-endef
--
- OBJS-ffmpeg += ffmpeg_opt.o ffmpeg_filter.o ffmpeg_hw.o
- OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
- OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o
- ifndef CONFIG_VIDEOTOOLBOX
- OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o
- endif
- OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o
- OBJS-ffserver += ffserver_config.o
-COMPILE_C = $(call COMPILE,CC)
-COMPILE_S = $(call COMPILE,AS)
-COMPILE_M = $(call COMPILE,OBJCC)
-COMPILE_HOSTC = $(call COMPILE,HOSTCC)
-
-%.o: %.c
- $(COMPILE_C)
-
-%.o: %.S
- $(COMPILE_S)
-
-%.o: %.m
- $(COMPILE_M)
-
-%_host.o: %.c
- $(COMPILE_HOSTC)
-
-%.o: %.asm
- $(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
- $(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $<
- -$(STRIP) $(STRIPFLAGS) $@
-
-%.i: %.c
- $(CC) $(CCFLAGS) $(CC_E) $<
-
-%.h.c:
- $(Q)echo '#include "$*.h"' >$@
-
-%.c %.h %.pc %.ver %.version: TAG = GEN
--
-TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
+TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
# $(FFLIBS-yes) needs to be in linking order
@@@ -69,19 -96,8 +44,17 @@@ FF_EXTRALIBS := $(FFEXTRALIBS
FF_DEP_LIBS := $(DEP_LIBS)
FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
- all: $(AVPROGS)
-
$(TOOLS): %$(EXESUF): %.o
- $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(EXTRALIBS) $(ELIBS)
+ $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
+
+target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS)
+ $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
+
+tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
+tools/sofa2wavs$(EXESUF): ELIBS = $(FF_EXTRALIBS)
+tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
+tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
+tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS)
CONFIGURABLE_COMPONENTS = \
$(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \
@@@ -117,37 -132,22 +90,27 @@@ ende
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
-include $(SRC_PATH)/avtools/Makefile
++include $(SRC_PATH)/fftools/Makefile
include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/doc/examples/Makefile
- define DOPROG
- OBJS-$(1) += $(1).o $(OBJS-$(1)-yes)
- $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
- $$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
- $(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
- $(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1))
- -include $$(OBJS-$(1):.o=.d)
- endef
-
- $(foreach P,$(AVPROGS-yes),$(eval $(call DOPROG,$(P))))
-
- ffprobe.o cmdutils.o libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
-$(PROGS): %$(EXESUF): $(FF_DEP_LIBS)
++libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
+
+$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
+ $(CP) $< $@
+ $(STRIP) $@
+
- %$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
++%$(PROGSSUF)_g$(EXESUF): $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
-VERSION_SH = $(SRC_PATH)/avbuild/version.sh
+VERSION_SH = $(SRC_PATH)/ffbuild/version.sh
GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
-.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) avbuild/config.mak
+.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) ffbuild/config.mak
.version: M=@
-libavutil/utils.o: avversion.h
-avversion.h .version:
- $(M)$(VERSION_SH) $(SRC_PATH) avversion.h $(EXTRA_VERSION)
+libavutil/ffversion.h .version:
+ $(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
$(Q)touch .version
# force version.sh to run whenever version might have changed
@@@ -161,35 -157,18 +120,24 @@@ install: install-libs install-header
install-libs: install-libs-yes
- install-progs-yes:
- install-progs-$(CONFIG_SHARED): install-libs
-
- install-progs: install-progs-yes $(AVPROGS)
- $(Q)mkdir -p "$(BINDIR)"
- $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
-
-install-data: $(DATA_FILES)
- $(Q)mkdir -p "$(DATADIR)"
+install-data: $(DATA_FILES) $(EXAMPLES_FILES) $(EXAMPLE_MAKEFILE)
+ $(Q)mkdir -p "$(DATADIR)/examples"
$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
+ $(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
+ $(INSTALL) -m 644 $(EXAMPLE_MAKEFILE:%=%.example) "$(DATADIR)/examples/Makefile"
- uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
-
- uninstall-progs:
- $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
+ uninstall: uninstall-libs uninstall-headers uninstall-data
uninstall-data:
$(RM) -r "$(DATADIR)"
clean::
- $(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
$(RM) $(CLEANSUFFIXES)
- $(RM) -rf coverage.info lcov
+ $(RM) $(CLEANSUFFIXES:%=compat/msvcrt/%)
+ $(RM) $(CLEANSUFFIXES:%=compat/atomics/pthread/%)
+ $(RM) $(CLEANSUFFIXES:%=compat/%)
+ $(RM) -r coverage-html
+ $(RM) -rf coverage.info coverage.info.in lcov
distclean::
$(RM) $(DISTCLEANSUFFIXES)
diff --cc doc/examples/Makefile
index f0c4f7969e,c42c68fd54..ff958d33c6
--- a/doc/examples/Makefile
+++ b/doc/examples/Makefile
@@@ -1,36 -1,19 +1,36 @@@
-DOC_EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
-DOC_EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video
-DOC_EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio
-DOC_EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video
-DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
-DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata
-DOC_EXAMPLES-$(CONFIG_OUTPUT_EXAMPLE) += output
-DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE) += qsvdec
-DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
-
-DOC_EXAMPLES := $(DOC_EXAMPLES-yes:%=doc/examples/%$(EXESUF))
-ALL_DOC_EXAMPLES := $(DOC_EXAMPLES) $(DOC_EXAMPLES-:%=doc/examples/%$(EXESUF))
-PROGS += $(DOC_EXAMPLES)
-
-$(foreach P,$(DOC_EXAMPLES),$(eval OBJS-$(P:%$(EXESUF)=%) = $(P:%$(EXESUF)=%).o))
-$(DOC_EXAMPLES): %$(EXESUF): %.o
+DOC_EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd
+DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
+DOC_EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
+DOC_EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video
+DOC_EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding
+DOC_EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio
+DOC_EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video
+DOC_EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs
+DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
+DOC_EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio
+DOC_EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video
+DOC_EXAMPLES-$(CONFIG_HTTP_MULTICLIENT_EXAMPLE) += http_multiclient
+DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) += hw_decode
+DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata
+DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE) += muxing
+DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE) += qsvdec
+DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing
+DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio
+DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video
+DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
+DOC_EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding
+
+DOC_EXAMPLES := $(DOC_EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
+DOC_EXAMPLES_G := $(DOC_EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
+ALL_DOC_EXAMPLES := $(DOC_EXAMPLES) $(DOC_EXAMPLES-:%=doc/examples/%$(PROGSSUF)$(EXESUF))
+ALL_DOC_EXAMPLES_G := $(DOC_EXAMPLES_G) $(DOC_EXAMPLES-:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
+PROGS += $(DOC_EXAMPLES)
+
+EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/README
+EXAMPLE_MAKEFILE := $(SRC_PATH)/doc/examples/Makefile
+
+$(foreach P,$(DOC_EXAMPLES),$(eval OBJS-$(P:%$(PROGSSUF)$(EXESUF)=%) = $(P:%$(PROGSSUF)$(EXESUF)=%).o))
- $(DOC_EXAMPLES): %$(PROGSSUF)$(EXESUF): %.o
++$(DOC_EXAMPLES_G): %$(PROGSSUF)_g$(EXESUF): %.o
examples: $(DOC_EXAMPLES)
diff --cc fftools/Makefile
index 0000000000,0000000000..094f6d6265
new file mode 100644
--- /dev/null
+++ b/fftools/Makefile
@@@ -1,0 -1,0 +1,57 @@@
++AVPROGS-$(CONFIG_FFMPEG) += ffmpeg
++AVPROGS-$(CONFIG_FFPLAY) += ffplay
++AVPROGS-$(CONFIG_FFPROBE) += ffprobe
++AVPROGS-$(CONFIG_FFSERVER) += ffserver
++
++AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
++PROGS += $(AVPROGS)
++
++AVBASENAMES = ffmpeg ffplay ffprobe ffserver
++ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
++ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
++
++OBJS-ffmpeg += fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o
++OBJS-ffmpeg-$(CONFIG_CUVID) += fftools/ffmpeg_cuvid.o
++OBJS-ffmpeg-$(CONFIG_LIBMFX) += fftools/ffmpeg_qsv.o
++ifndef CONFIG_VIDEOTOOLBOX
++OBJS-ffmpeg-$(CONFIG_VDA) += fftools/ffmpeg_videotoolbox.o
++endif
++OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += fftools/ffmpeg_videotoolbox.o
++OBJS-ffserver += fftools/ffserver_config.o
++
++define DOFFTOOL
++OBJS-$(1)-$(CONFIG_OPENCL) += fftools/cmdutils_opencl.o
++OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes)
++$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
++$$(OBJS-$(1)): | fftools
++$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
++$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
++$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1))
++-include $$(OBJS-$(1):.o=.d)
++endef
++
++$(foreach P,$(AVPROGS-yes),$(eval $(call DOFFTOOL,$(P))))
++
++all: $(AVPROGS)
++
++fftools/ffprobe.o fftools/cmdutils.o: libavutil/ffversion.h | fftools
++OBJDIRS += fftools
++
++ifdef AVPROGS
++install: install-progs install-data
++endif
++
++install-progs-yes:
++install-progs-$(CONFIG_SHARED): install-libs
++
++install-progs: install-progs-yes $(AVPROGS)
++ $(Q)mkdir -p "$(BINDIR)"
++ $(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)"
++
++uninstall: uninstall-progs
++
++uninstall-progs:
++ $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
++
++clean::
++ $(RM) $(ALLAVPROGS) $(ALLAVPROGS_G) $(CLEANSUFFIXES:%=fftools/%)
diff --cc fftools/cmdutils.c
index 3d428f3eea,0000000000..3d428f3eea
mode 100644,000000..100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
diff --cc fftools/cmdutils.h
index e1d64d8986,0000000000..2997ee37b5
mode 100644,000000..100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@@ -1,662 -1,0 +1,662 @@@
+/*
+ * Various utilities for command line tools
+ * copyright (c) 2003 Fabrice Bellard
+ *
+ * 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 CMDUTILS_H
- #define CMDUTILS_H
++#ifndef FFTOOLS_CMDUTILS_H
++#define FFTOOLS_CMDUTILS_H
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavcodec/avcodec.h"
+#include "libavfilter/avfilter.h"
+#include "libavformat/avformat.h"
+#include "libswscale/swscale.h"
+
+#ifdef _WIN32
+#undef main /* We don't want SDL to override our main() */
+#endif
+
+/**
+ * program name, defined by the program for show_version().
+ */
+extern const char program_name[];
+
+/**
+ * program birth year, defined by the program for show_banner()
+ */
+extern const int program_birth_year;
+
+extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
+extern AVFormatContext *avformat_opts;
+extern AVDictionary *sws_dict;
+extern AVDictionary *swr_opts;
+extern AVDictionary *format_opts, *codec_opts, *resample_opts;
+extern int hide_banner;
+
+/**
+ * Register a program-specific cleanup routine.
+ */
+void register_exit(void (*cb)(int ret));
+
+/**
+ * Wraps exit with a program-specific cleanup routine.
+ */
+void exit_program(int ret) av_noreturn;
+
+/**
+ * Initialize dynamic library loading
+ */
+void init_dynload(void);
+
+/**
+ * Initialize the cmdutils option system, in particular
+ * allocate the *_opts contexts.
+ */
+void init_opts(void);
+/**
+ * Uninitialize the cmdutils option system, in particular
+ * free the *_opts contexts and their contents.
+ */
+void uninit_opts(void);
+
+/**
+ * Trivial log callback.
+ * Only suitable for opt_help and similar since it lacks prefix handling.
+ */
+void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
+
+/**
+ * Override the cpuflags.
+ */
+int opt_cpuflags(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Fallback for options that are not explicitly handled, these will be
+ * parsed through AVOptions.
+ */
+int opt_default(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Set the libav* libraries log level.
+ */
+int opt_loglevel(void *optctx, const char *opt, const char *arg);
+
+int opt_report(const char *opt);
+
+int opt_max_alloc(void *optctx, const char *opt, const char *arg);
+
+int opt_codec_debug(void *optctx, const char *opt, const char *arg);
+
+#if CONFIG_OPENCL
+int opt_opencl(void *optctx, const char *opt, const char *arg);
+
+int opt_opencl_bench(void *optctx, const char *opt, const char *arg);
+#endif
+
+/**
+ * Limit the execution time.
+ */
+int opt_timelimit(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Parse a string and return its corresponding value as a double.
+ * Exit from the application if the string cannot be correctly
+ * parsed or the corresponding value is invalid.
+ *
+ * @param context the context of the value to be set (e.g. the
+ * corresponding command line option name)
+ * @param numstr the string to be parsed
+ * @param type the type (OPT_INT64 or OPT_FLOAT) as which the
+ * string should be parsed
+ * @param min the minimum valid accepted value
+ * @param max the maximum valid accepted value
+ */
+double parse_number_or_die(const char *context, const char *numstr, int type,
+ double min, double max);
+
+/**
+ * Parse a string specifying a time and return its corresponding
+ * value as a number of microseconds. Exit from the application if
+ * the string cannot be correctly parsed.
+ *
+ * @param context the context of the value to be set (e.g. the
+ * corresponding command line option name)
+ * @param timestr the string to be parsed
+ * @param is_duration a flag which tells how to interpret timestr, if
+ * not zero timestr is interpreted as a duration, otherwise as a
+ * date
+ *
+ * @see av_parse_time()
+ */
+int64_t parse_time_or_die(const char *context, const char *timestr,
+ int is_duration);
+
+typedef struct SpecifierOpt {
+ char *specifier; /**< stream/chapter/program/... specifier */
+ union {
+ uint8_t *str;
+ int i;
+ int64_t i64;
+ float f;
+ double dbl;
+ } u;
+} SpecifierOpt;
+
+typedef struct OptionDef {
+ const char *name;
+ int flags;
+#define HAS_ARG 0x0001
+#define OPT_BOOL 0x0002
+#define OPT_EXPERT 0x0004
+#define OPT_STRING 0x0008
+#define OPT_VIDEO 0x0010
+#define OPT_AUDIO 0x0020
+#define OPT_INT 0x0080
+#define OPT_FLOAT 0x0100
+#define OPT_SUBTITLE 0x0200
+#define OPT_INT64 0x0400
+#define OPT_EXIT 0x0800
+#define OPT_DATA 0x1000
+#define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only).
+ implied by OPT_OFFSET or OPT_SPEC */
+#define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */
+#define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt.
+ Implies OPT_OFFSET. Next element after the offset is
+ an int containing element count in the array. */
+#define OPT_TIME 0x10000
+#define OPT_DOUBLE 0x20000
+#define OPT_INPUT 0x40000
+#define OPT_OUTPUT 0x80000
+ union {
+ void *dst_ptr;
+ int (*func_arg)(void *, const char *, const char *);
+ size_t off;
+ } u;
+ const char *help;
+ const char *argname;
+} OptionDef;
+
+/**
+ * Print help for all options matching specified flags.
+ *
+ * @param options a list of options
+ * @param msg title of this group. Only printed if at least one option matches.
+ * @param req_flags print only options which have all those flags set.
+ * @param rej_flags don't print options which have any of those flags set.
+ * @param alt_flags print only options that have at least one of those flags set
+ */
+void show_help_options(const OptionDef *options, const char *msg, int req_flags,
+ int rej_flags, int alt_flags);
+
+#if CONFIG_OPENCL
+#define CMDUTILS_COMMON_OPTIONS_OPENCL \
+ { "opencl_bench", OPT_EXIT, {.func_arg = opt_opencl_bench}, \
+ "run benchmark on all OpenCL devices and show results" }, \
+ { "opencl_options", HAS_ARG, {.func_arg = opt_opencl}, \
+ "set OpenCL environment options" }, \
+
+#else
+#define CMDUTILS_COMMON_OPTIONS_OPENCL
+#endif
+
+#if CONFIG_AVDEVICE
+#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \
+ { "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, \
+ "list sources of the input device", "device" }, \
+ { "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, \
+ "list sinks of the output device", "device" }, \
+
+#else
+#define CMDUTILS_COMMON_OPTIONS_AVDEVICE
+#endif
+
+#define CMDUTILS_COMMON_OPTIONS \
+ { "L", OPT_EXIT, { .func_arg = show_license }, "show license" }, \
+ { "h", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
+ { "?", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
+ { "help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
+ { "-help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
+ { "version", OPT_EXIT, { .func_arg = show_version }, "show version" }, \
+ { "buildconf", OPT_EXIT, { .func_arg = show_buildconf }, "show build configuration" }, \
+ { "formats", OPT_EXIT, { .func_arg = show_formats }, "show available formats" }, \
+ { "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" }, \
+ { "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" }, \
+ { "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" }, \
+ { "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" }, \
+ { "decoders", OPT_EXIT, { .func_arg = show_decoders }, "show available decoders" }, \
+ { "encoders", OPT_EXIT, { .func_arg = show_encoders }, "show available encoders" }, \
+ { "bsfs", OPT_EXIT, { .func_arg = show_bsfs }, "show available bit stream filters" }, \
+ { "protocols", OPT_EXIT, { .func_arg = show_protocols }, "show available protocols" }, \
+ { "filters", OPT_EXIT, { .func_arg = show_filters }, "show available filters" }, \
+ { "pix_fmts", OPT_EXIT, { .func_arg = show_pix_fmts }, "show available pixel formats" }, \
+ { "layouts", OPT_EXIT, { .func_arg = show_layouts }, "show standard channel layouts" }, \
+ { "sample_fmts", OPT_EXIT, { .func_arg = show_sample_fmts }, "show available audio sample formats" }, \
+ { "colors", OPT_EXIT, { .func_arg = show_colors }, "show available color names" }, \
+ { "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \
+ { "v", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \
+ { "report", 0, { (void*)opt_report }, "generate a report" }, \
+ { "max_alloc", HAS_ARG, { .func_arg = opt_max_alloc }, "set maximum size of a single allocated block", "bytes" }, \
+ { "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" }, \
+ { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" }, \
+ CMDUTILS_COMMON_OPTIONS_OPENCL \
+ CMDUTILS_COMMON_OPTIONS_AVDEVICE \
+
+/**
+ * Show help for all options with given flags in class and all its
+ * children.
+ */
+void show_help_children(const AVClass *class, int flags);
+
+/**
+ * Per-fftool specific help handler. Implemented in each
+ * fftool, called by show_help().
+ */
+void show_help_default(const char *opt, const char *arg);
+
+/**
+ * Generic -h handler common to all fftools.
+ */
+int show_help(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Parse the command line arguments.
+ *
+ * @param optctx an opaque options context
+ * @param argc number of command line arguments
+ * @param argv values of command line arguments
+ * @param options Array with the definitions required to interpret every
+ * option of the form: -option_name [argument]
+ * @param parse_arg_function Name of the function called to process every
+ * argument without a leading option name flag. NULL if such arguments do
+ * not have to be processed.
+ */
+void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
+ void (* parse_arg_function)(void *optctx, const char*));
+
+/**
+ * Parse one given option.
+ *
+ * @return on success 1 if arg was consumed, 0 otherwise; negative number on error
+ */
+int parse_option(void *optctx, const char *opt, const char *arg,
+ const OptionDef *options);
+
+/**
+ * An option extracted from the commandline.
+ * Cannot use AVDictionary because of options like -map which can be
+ * used multiple times.
+ */
+typedef struct Option {
+ const OptionDef *opt;
+ const char *key;
+ const char *val;
+} Option;
+
+typedef struct OptionGroupDef {
+ /**< group name */
+ const char *name;
+ /**
+ * Option to be used as group separator. Can be NULL for groups which
+ * are terminated by a non-option argument (e.g. ffmpeg output files)
+ */
+ const char *sep;
+ /**
+ * Option flags that must be set on each option that is
+ * applied to this group
+ */
+ int flags;
+} OptionGroupDef;
+
+typedef struct OptionGroup {
+ const OptionGroupDef *group_def;
+ const char *arg;
+
+ Option *opts;
+ int nb_opts;
+
+ AVDictionary *codec_opts;
+ AVDictionary *format_opts;
+ AVDictionary *resample_opts;
+ AVDictionary *sws_dict;
+ AVDictionary *swr_opts;
+} OptionGroup;
+
+/**
+ * A list of option groups that all have the same group type
+ * (e.g. input files or output files)
+ */
+typedef struct OptionGroupList {
+ const OptionGroupDef *group_def;
+
+ OptionGroup *groups;
+ int nb_groups;
+} OptionGroupList;
+
+typedef struct OptionParseContext {
+ OptionGroup global_opts;
+
+ OptionGroupList *groups;
+ int nb_groups;
+
+ /* parsing state */
+ OptionGroup cur_group;
+} OptionParseContext;
+
+/**
+ * Parse an options group and write results into optctx.
+ *
+ * @param optctx an app-specific options context. NULL for global options group
+ */
+int parse_optgroup(void *optctx, OptionGroup *g);
+
+/**
+ * Split the commandline into an intermediate form convenient for further
+ * processing.
+ *
+ * The commandline is assumed to be composed of options which either belong to a
+ * group (those with OPT_SPEC, OPT_OFFSET or OPT_PERFILE) or are global
+ * (everything else).
+ *
+ * A group (defined by an OptionGroupDef struct) is a sequence of options
+ * terminated by either a group separator option (e.g. -i) or a parameter that
+ * is not an option (doesn't start with -). A group without a separator option
+ * must always be first in the supplied groups list.
+ *
+ * All options within the same group are stored in one OptionGroup struct in an
+ * OptionGroupList, all groups with the same group definition are stored in one
+ * OptionGroupList in OptionParseContext.groups. The order of group lists is the
+ * same as the order of group definitions.
+ */
+int split_commandline(OptionParseContext *octx, int argc, char *argv[],
+ const OptionDef *options,
+ const OptionGroupDef *groups, int nb_groups);
+
+/**
+ * Free all allocated memory in an OptionParseContext.
+ */
+void uninit_parse_context(OptionParseContext *octx);
+
+/**
+ * Find the '-loglevel' option in the command line args and apply it.
+ */
+void parse_loglevel(int argc, char **argv, const OptionDef *options);
+
+/**
+ * Return index of option opt in argv or 0 if not found.
+ */
+int locate_option(int argc, char **argv, const OptionDef *options,
+ const char *optname);
+
+/**
+ * Check if the given stream matches a stream specifier.
+ *
+ * @param s Corresponding format context.
+ * @param st Stream from s to be checked.
+ * @param spec A stream specifier of the [v|a|s|d]:[\<stream index\>] form.
+ *
+ * @return 1 if the stream matches, 0 if it doesn't, <0 on error
+ */
+int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
+
+/**
+ * Filter out options for given codec.
+ *
+ * Create a new options dictionary containing only the options from
+ * opts which apply to the codec with ID codec_id.
+ *
+ * @param opts dictionary to place options in
+ * @param codec_id ID of the codec that should be filtered for
+ * @param s Corresponding format context.
+ * @param st A stream from s for which the options should be filtered.
+ * @param codec The particular codec for which the options should be filtered.
+ * If null, the default one is looked up according to the codec id.
+ * @return a pointer to the created dictionary
+ */
+AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
+ AVFormatContext *s, AVStream *st, AVCodec *codec);
+
+/**
+ * Setup AVCodecContext options for avformat_find_stream_info().
+ *
+ * Create an array of dictionaries, one dictionary for each stream
+ * contained in s.
+ * Each dictionary will contain the options from codec_opts which can
+ * be applied to the corresponding stream codec context.
+ *
+ * @return pointer to the created array of dictionaries, NULL if it
+ * cannot be created
+ */
+AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
+ AVDictionary *codec_opts);
+
+/**
+ * Print an error message to stderr, indicating filename and a human
+ * readable description of the error code err.
+ *
+ * If strerror_r() is not available the use of this function in a
+ * multithreaded application may be unsafe.
+ *
+ * @see av_strerror()
+ */
+void print_error(const char *filename, int err);
+
+/**
+ * Print the program banner to stderr. The banner contents depend on the
+ * current version of the repository and of the libav* libraries used by
+ * the program.
+ */
+void show_banner(int argc, char **argv, const OptionDef *options);
+
+/**
+ * Print the version of the program to stdout. The version message
+ * depends on the current versions of the repository and of the libav*
+ * libraries.
+ * This option processing function does not utilize the arguments.
+ */
+int show_version(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print the build configuration of the program to stdout. The contents
+ * depend on the definition of FFMPEG_CONFIGURATION.
+ * This option processing function does not utilize the arguments.
+ */
+int show_buildconf(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print the license of the program to stdout. The license depends on
+ * the license of the libraries compiled into the program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_license(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the formats supported by the
+ * program (including devices).
+ * This option processing function does not utilize the arguments.
+ */
+int show_formats(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the muxers supported by the
+ * program (including devices).
+ * This option processing function does not utilize the arguments.
+ */
+int show_muxers(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the demuxer supported by the
+ * program (including devices).
+ * This option processing function does not utilize the arguments.
+ */
+int show_demuxers(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the devices supported by the
+ * program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_devices(void *optctx, const char *opt, const char *arg);
+
+#if CONFIG_AVDEVICE
+/**
+ * Print a listing containing autodetected sinks of the output device.
+ * Device name with options may be passed as an argument to limit results.
+ */
+int show_sinks(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing autodetected sources of the input device.
+ * Device name with options may be passed as an argument to limit results.
+ */
+int show_sources(void *optctx, const char *opt, const char *arg);
+#endif
+
+/**
+ * Print a listing containing all the codecs supported by the
+ * program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_codecs(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the decoders supported by the
+ * program.
+ */
+int show_decoders(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the encoders supported by the
+ * program.
+ */
+int show_encoders(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the filters supported by the
+ * program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_filters(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the bit stream filters supported by the
+ * program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_bsfs(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the protocols supported by the
+ * program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_protocols(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the pixel formats supported by the
+ * program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_pix_fmts(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the standard channel layouts supported by
+ * the program.
+ * This option processing function does not utilize the arguments.
+ */
+int show_layouts(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the sample formats supported by the
+ * program.
+ */
+int show_sample_fmts(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Print a listing containing all the color names and values recognized
+ * by the program.
+ */
+int show_colors(void *optctx, const char *opt, const char *arg);
+
+/**
+ * Return a positive value if a line read from standard input
+ * starts with [yY], otherwise return 0.
+ */
+int read_yesno(void);
+
+/**
+ * Get a file corresponding to a preset file.
+ *
+ * If is_path is non-zero, look for the file in the path preset_name.
+ * Otherwise search for a file named arg.ffpreset in the directories
+ * $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined
+ * at configuration time or in a "ffpresets" folder along the executable
+ * on win32, in that order. If no such file is found and
+ * codec_name is defined, then search for a file named
+ * codec_name-preset_name.avpreset in the above-mentioned directories.
+ *
+ * @param filename buffer where the name of the found filename is written
+ * @param filename_size size in bytes of the filename buffer
+ * @param preset_name name of the preset to search
+ * @param is_path tell if preset_name is a filename path
+ * @param codec_name name of the codec for which to look for the
+ * preset, may be NULL
+ */
+FILE *get_preset_file(char *filename, size_t filename_size,
+ const char *preset_name, int is_path, const char *codec_name);
+
+/**
+ * Realloc array to hold new_size elements of elem_size.
+ * Calls exit() on failure.
+ *
+ * @param array array to reallocate
+ * @param elem_size size in bytes of each element
+ * @param size new element count will be written here
+ * @param new_size number of elements to place in reallocated array
+ * @return reallocated array
+ */
+void *grow_array(void *array, int elem_size, int *size, int new_size);
+
+#define media_type_string av_get_media_type_string
+
+#define GROW_ARRAY(array, nb_elems)\
+ array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
+
+#define GET_PIX_FMT_NAME(pix_fmt)\
+ const char *name = av_get_pix_fmt_name(pix_fmt);
+
+#define GET_SAMPLE_FMT_NAME(sample_fmt)\
+ const char *name = av_get_sample_fmt_name(sample_fmt)
+
+#define GET_SAMPLE_RATE_NAME(rate)\
+ char name[16];\
+ snprintf(name, sizeof(name), "%d", rate);
+
+#define GET_CH_LAYOUT_NAME(ch_layout)\
+ char name[16];\
+ snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
+
+#define GET_CH_LAYOUT_DESC(ch_layout)\
+ char name[128];\
+ av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
+
+double get_rotation(AVStream *st);
+
- #endif /* CMDUTILS_H */
++#endif /* FFTOOLS_CMDUTILS_H */
diff --cc fftools/cmdutils_opencl.c
index 906aef4836,0000000000..906aef4836
mode 100644,000000..100644
--- a/fftools/cmdutils_opencl.c
+++ b/fftools/cmdutils_opencl.c
diff --cc fftools/ffmpeg.c
index 1d248bc269,0000000000..1d248bc269
mode 100644,000000..100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
diff --cc fftools/ffmpeg.h
index d2deb432b7,0000000000..f6c76bcc55
mode 100644,000000..100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@@ -1,679 -1,0 +1,679 @@@
+/*
+ * 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 FFMPEG_H
- #define FFMPEG_H
++#ifndef FFTOOLS_FFMPEG_H
++#define FFTOOLS_FFMPEG_H
+
+#include "config.h"
+
+#include <stdint.h>
+#include <stdio.h>
+#include <signal.h>
+
+#if HAVE_PTHREADS
+#include <pthread.h>
+#endif
+
+#include "cmdutils.h"
+
+#include "libavformat/avformat.h"
+#include "libavformat/avio.h"
+
+#include "libavcodec/avcodec.h"
+
+#include "libavfilter/avfilter.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/dict.h"
+#include "libavutil/eval.h"
+#include "libavutil/fifo.h"
+#include "libavutil/hwcontext.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/rational.h"
+#include "libavutil/threadmessage.h"
+
+#include "libswresample/swresample.h"
+
+#define VSYNC_AUTO -1
+#define VSYNC_PASSTHROUGH 0
+#define VSYNC_CFR 1
+#define VSYNC_VFR 2
+#define VSYNC_VSCFR 0xfe
+#define VSYNC_DROP 0xff
+
+#define MAX_STREAMS 1024 /* arbitrary sanity check value */
+
+enum HWAccelID {
+ HWACCEL_NONE = 0,
+ HWACCEL_AUTO,
+ HWACCEL_VDPAU,
+ HWACCEL_DXVA2,
+ HWACCEL_VDA,
+ HWACCEL_VIDEOTOOLBOX,
+ HWACCEL_QSV,
+ HWACCEL_VAAPI,
+ HWACCEL_CUVID,
+ HWACCEL_D3D11VA,
+};
+
+typedef struct HWAccel {
+ const char *name;
+ int (*init)(AVCodecContext *s);
+ enum HWAccelID id;
+ enum AVPixelFormat pix_fmt;
+ enum AVHWDeviceType device_type;
+} HWAccel;
+
+typedef struct HWDevice {
+ char *name;
+ enum AVHWDeviceType type;
+ AVBufferRef *device_ref;
+} HWDevice;
+
+/* select an input stream for an output stream */
+typedef struct StreamMap {
+ int disabled; /* 1 is this mapping is disabled by a negative map */
+ int file_index;
+ int stream_index;
+ int sync_file_index;
+ int sync_stream_index;
+ char *linklabel; /* name of an output link, for mapping lavfi outputs */
+} StreamMap;
+
+typedef struct {
+ int file_idx, stream_idx, channel_idx; // input
+ int ofile_idx, ostream_idx; // output
+} AudioChannelMap;
+
+typedef struct OptionsContext {
+ OptionGroup *g;
+
+ /* input/output options */
+ int64_t start_time;
+ int64_t start_time_eof;
+ int seek_timestamp;
+ const char *format;
+
+ SpecifierOpt *codec_names;
+ int nb_codec_names;
+ SpecifierOpt *audio_channels;
+ int nb_audio_channels;
+ SpecifierOpt *audio_sample_rate;
+ int nb_audio_sample_rate;
+ SpecifierOpt *frame_rates;
+ int nb_frame_rates;
+ SpecifierOpt *frame_sizes;
+ int nb_frame_sizes;
+ SpecifierOpt *frame_pix_fmts;
+ int nb_frame_pix_fmts;
+
+ /* input options */
+ int64_t input_ts_offset;
+ int loop;
+ int rate_emu;
+ int accurate_seek;
+ int thread_queue_size;
+
+ SpecifierOpt *ts_scale;
+ int nb_ts_scale;
+ SpecifierOpt *dump_attachment;
+ int nb_dump_attachment;
+ SpecifierOpt *hwaccels;
+ int nb_hwaccels;
+ SpecifierOpt *hwaccel_devices;
+ int nb_hwaccel_devices;
+ SpecifierOpt *hwaccel_output_formats;
+ int nb_hwaccel_output_formats;
+ SpecifierOpt *autorotate;
+ int nb_autorotate;
+
+ /* output options */
+ StreamMap *stream_maps;
+ int nb_stream_maps;
+ AudioChannelMap *audio_channel_maps; /* one info entry per -map_channel */
+ int nb_audio_channel_maps; /* number of (valid) -map_channel settings */
+ int metadata_global_manual;
+ int metadata_streams_manual;
+ int metadata_chapters_manual;
+ const char **attachments;
+ int nb_attachments;
+
+ int chapters_input_file;
+
+ int64_t recording_time;
+ int64_t stop_time;
+ uint64_t limit_filesize;
+ float mux_preload;
+ float mux_max_delay;
+ int shortest;
+
+ int video_disable;
+ int audio_disable;
+ int subtitle_disable;
+ int data_disable;
+
+ /* indexed by output file stream index */
+ int *streamid_map;
+ int nb_streamid_map;
+
+ SpecifierOpt *metadata;
+ int nb_metadata;
+ SpecifierOpt *max_frames;
+ int nb_max_frames;
+ SpecifierOpt *bitstream_filters;
+ int nb_bitstream_filters;
+ SpecifierOpt *codec_tags;
+ int nb_codec_tags;
+ SpecifierOpt *sample_fmts;
+ int nb_sample_fmts;
+ SpecifierOpt *qscale;
+ int nb_qscale;
+ SpecifierOpt *forced_key_frames;
+ int nb_forced_key_frames;
+ SpecifierOpt *force_fps;
+ int nb_force_fps;
+ SpecifierOpt *frame_aspect_ratios;
+ int nb_frame_aspect_ratios;
+ SpecifierOpt *rc_overrides;
+ int nb_rc_overrides;
+ SpecifierOpt *intra_matrices;
+ int nb_intra_matrices;
+ SpecifierOpt *inter_matrices;
+ int nb_inter_matrices;
+ SpecifierOpt *chroma_intra_matrices;
+ int nb_chroma_intra_matrices;
+ SpecifierOpt *top_field_first;
+ int nb_top_field_first;
+ SpecifierOpt *metadata_map;
+ int nb_metadata_map;
+ SpecifierOpt *presets;
+ int nb_presets;
+ SpecifierOpt *copy_initial_nonkeyframes;
+ int nb_copy_initial_nonkeyframes;
+ SpecifierOpt *copy_prior_start;
+ int nb_copy_prior_start;
+ SpecifierOpt *filters;
+ int nb_filters;
+ SpecifierOpt *filter_scripts;
+ int nb_filter_scripts;
+ SpecifierOpt *reinit_filters;
+ int nb_reinit_filters;
+ SpecifierOpt *fix_sub_duration;
+ int nb_fix_sub_duration;
+ SpecifierOpt *canvas_sizes;
+ int nb_canvas_sizes;
+ SpecifierOpt *pass;
+ int nb_pass;
+ SpecifierOpt *passlogfiles;
+ int nb_passlogfiles;
+ SpecifierOpt *max_muxing_queue_size;
+ int nb_max_muxing_queue_size;
+ SpecifierOpt *guess_layout_max;
+ int nb_guess_layout_max;
+ SpecifierOpt *apad;
+ int nb_apad;
+ SpecifierOpt *discard;
+ int nb_discard;
+ SpecifierOpt *disposition;
+ int nb_disposition;
+ SpecifierOpt *program;
+ int nb_program;
+ SpecifierOpt *time_bases;
+ int nb_time_bases;
+ SpecifierOpt *enc_time_bases;
+ int nb_enc_time_bases;
+} OptionsContext;
+
+typedef struct InputFilter {
+ AVFilterContext *filter;
+ struct InputStream *ist;
+ struct FilterGraph *graph;
+ uint8_t *name;
+ enum AVMediaType type; // AVMEDIA_TYPE_SUBTITLE for sub2video
+
+ AVFifoBuffer *frame_queue;
+
+ // parameters configured for this input
+ int format;
+
+ int width, height;
+ AVRational sample_aspect_ratio;
+
+ int sample_rate;
+ int channels;
+ uint64_t channel_layout;
+
+ AVBufferRef *hw_frames_ctx;
+
+ int eof;
+} InputFilter;
+
+typedef struct OutputFilter {
+ AVFilterContext *filter;
+ struct OutputStream *ost;
+ struct FilterGraph *graph;
+ uint8_t *name;
+
+ /* temporary storage until stream maps are processed */
+ AVFilterInOut *out_tmp;
+ enum AVMediaType type;
+
+ /* desired output stream properties */
+ int width, height;
+ AVRational frame_rate;
+ int format;
+ int sample_rate;
+ uint64_t channel_layout;
+
+ // those are only set if no format is specified and the encoder gives us multiple options
+ int *formats;
+ uint64_t *channel_layouts;
+ int *sample_rates;
+} OutputFilter;
+
+typedef struct FilterGraph {
+ int index;
+ const char *graph_desc;
+
+ AVFilterGraph *graph;
+ int reconfiguration;
+
+ InputFilter **inputs;
+ int nb_inputs;
+ OutputFilter **outputs;
+ int nb_outputs;
+} FilterGraph;
+
+typedef struct InputStream {
+ int file_index;
+ AVStream *st;
+ int discard; /* true if stream data should be discarded */
+ int user_set_discard;
+ int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
+#define DECODING_FOR_OST 1
+#define DECODING_FOR_FILTER 2
+
+ AVCodecContext *dec_ctx;
+ AVCodec *dec;
+ AVFrame *decoded_frame;
+ AVFrame *filter_frame; /* a ref of decoded_frame, to be sent to filters */
+
+ int64_t start; /* time when read started */
+ /* predicted dts of the next packet read for this stream or (when there are
+ * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
+ int64_t next_dts;
+ int64_t dts; ///< dts of the last packet read for this stream (in AV_TIME_BASE units)
+
+ int64_t next_pts; ///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
+ int64_t pts; ///< current pts of the decoded frame (in AV_TIME_BASE units)
+ int wrap_correction_done;
+
+ int64_t filter_in_rescale_delta_last;
+
+ int64_t min_pts; /* pts with the smallest value in a current stream */
+ int64_t max_pts; /* pts with the higher value in a current stream */
+
+ // when forcing constant input framerate through -r,
+ // this contains the pts that will be given to the next decoded frame
+ int64_t cfr_next_pts;
+
+ int64_t nb_samples; /* number of samples in the last decoded audio frame before looping */
+
+ double ts_scale;
+ int saw_first_ts;
+ AVDictionary *decoder_opts;
+ AVRational framerate; /* framerate forced with -r */
+ int top_field_first;
+ int guess_layout_max;
+
+ int autorotate;
+
+ int fix_sub_duration;
+ struct { /* previous decoded subtitle and related variables */
+ int got_output;
+ int ret;
+ AVSubtitle subtitle;
+ } prev_sub;
+
+ struct sub2video {
+ int64_t last_pts;
+ int64_t end_pts;
+ AVFifoBuffer *sub_queue; ///< queue of AVSubtitle* before filter init
+ AVFrame *frame;
+ int w, h;
+ } sub2video;
+
+ int dr1;
+
+ /* decoded data from this stream goes into all those filters
+ * currently video and audio only */
+ InputFilter **filters;
+ int nb_filters;
+
+ int reinit_filters;
+
+ /* hwaccel options */
+ enum HWAccelID hwaccel_id;
+ char *hwaccel_device;
+ enum AVPixelFormat hwaccel_output_format;
+
+ /* hwaccel context */
+ enum HWAccelID active_hwaccel_id;
+ void *hwaccel_ctx;
+ void (*hwaccel_uninit)(AVCodecContext *s);
+ int (*hwaccel_get_buffer)(AVCodecContext *s, AVFrame *frame, int flags);
+ int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
+ enum AVPixelFormat hwaccel_pix_fmt;
+ enum AVPixelFormat hwaccel_retrieved_pix_fmt;
+ AVBufferRef *hw_frames_ctx;
+
+ /* stats */
+ // combined size of all the packets read
+ uint64_t data_size;
+ /* number of packets successfully read for this stream */
+ uint64_t nb_packets;
+ // number of frames/samples retrieved from the decoder
+ uint64_t frames_decoded;
+ uint64_t samples_decoded;
+
+ int64_t *dts_buffer;
+ int nb_dts_buffer;
+
+ int got_output;
+} InputStream;
+
+typedef struct InputFile {
+ AVFormatContext *ctx;
+ int eof_reached; /* true if eof reached */
+ int eagain; /* true if last read attempt returned EAGAIN */
+ int ist_index; /* index of first stream in input_streams */
+ int loop; /* set number of times input stream should be looped */
+ int64_t duration; /* actual duration of the longest stream in a file
+ at the moment when looping happens */
+ AVRational time_base; /* time base of the duration */
+ int64_t input_ts_offset;
+
+ int64_t ts_offset;
+ int64_t last_ts;
+ int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
+ int seek_timestamp;
+ int64_t recording_time;
+ int nb_streams; /* number of stream that ffmpeg is aware of; may be different
+ from ctx.nb_streams if new streams appear during av_read_frame() */
+ int nb_streams_warn; /* number of streams that the user was warned of */
+ int rate_emu;
+ int accurate_seek;
+
+#if HAVE_PTHREADS
+ AVThreadMessageQueue *in_thread_queue;
+ pthread_t thread; /* thread reading from this file */
+ int non_blocking; /* reading packets from the thread should not block */
+ int joined; /* the thread has been joined */
+ int thread_queue_size; /* maximum number of queued packets */
+#endif
+} InputFile;
+
+enum forced_keyframes_const {
+ FKF_N,
+ FKF_N_FORCED,
+ FKF_PREV_FORCED_N,
+ FKF_PREV_FORCED_T,
+ FKF_T,
+ FKF_NB
+};
+
+#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
+
+extern const char *const forced_keyframes_const_names[];
+
+typedef enum {
+ ENCODER_FINISHED = 1,
+ MUXER_FINISHED = 2,
+} OSTFinished ;
+
+typedef struct OutputStream {
+ int file_index; /* file index */
+ int index; /* stream index in the output file */
+ int source_index; /* InputStream index */
+ AVStream *st; /* stream in the output file */
+ int encoding_needed; /* true if encoding needed for this stream */
+ int frame_number;
+ /* input pts and corresponding output pts
+ for A/V sync */
+ struct InputStream *sync_ist; /* input stream to sync against */
+ int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ // FIXME look at frame_number
+ /* pts of the first frame encoded for this stream, used for limiting
+ * recording time */
+ int64_t first_pts;
+ /* dts of the last packet sent to the muxer */
+ int64_t last_mux_dts;
+ // the timebase of the packets sent to the muxer
+ AVRational mux_timebase;
+ AVRational enc_timebase;
+
+ int nb_bitstream_filters;
+ AVBSFContext **bsf_ctx;
+
+ AVCodecContext *enc_ctx;
+ AVCodecParameters *ref_par; /* associated input codec parameters with encoders options applied */
+ AVCodec *enc;
+ int64_t max_frames;
+ AVFrame *filtered_frame;
+ AVFrame *last_frame;
+ int last_dropped;
+ int last_nb0_frames[3];
+
+ void *hwaccel_ctx;
+
+ /* video only */
+ AVRational frame_rate;
+ int is_cfr;
+ int force_fps;
+ int top_field_first;
+ int rotate_overridden;
+ double rotate_override_value;
+
+ AVRational frame_aspect_ratio;
+
+ /* forced key frames */
+ int64_t *forced_kf_pts;
+ int forced_kf_count;
+ int forced_kf_index;
+ char *forced_keyframes;
+ AVExpr *forced_keyframes_pexpr;
+ double forced_keyframes_expr_const_values[FKF_NB];
+
+ /* audio only */
+ int *audio_channels_map; /* list of the channels id to pick from the source stream */
+ int audio_channels_mapped; /* number of channels in audio_channels_map */
+
+ char *logfile_prefix;
+ FILE *logfile;
+
+ OutputFilter *filter;
+ char *avfilter;
+ char *filters; ///< filtergraph associated to the -filter option
+ char *filters_script; ///< filtergraph script associated to the -filter_script option
+
+ AVDictionary *encoder_opts;
+ AVDictionary *sws_dict;
+ AVDictionary *swr_opts;
+ AVDictionary *resample_opts;
+ char *apad;
+ OSTFinished finished; /* no more packets should be written for this stream */
+ int unavailable; /* true if the steram is unavailable (possibly temporarily) */
+ int stream_copy;
+
+ // init_output_stream() has been called for this stream
+ // The encoder and the bitstream filters have been initialized and the stream
+ // parameters are set in the AVStream.
+ int initialized;
+
+ int inputs_done;
+
+ const char *attachment_filename;
+ int copy_initial_nonkeyframes;
+ int copy_prior_start;
+ char *disposition;
+
+ int keep_pix_fmt;
+
+ AVCodecParserContext *parser;
+ AVCodecContext *parser_avctx;
+
+ /* stats */
+ // combined size of all the packets written
+ uint64_t data_size;
+ // number of packets send to the muxer
+ uint64_t packets_written;
+ // number of frames/samples sent to the encoder
+ uint64_t frames_encoded;
+ uint64_t samples_encoded;
+
+ /* packet quality factor */
+ int quality;
+
+ int max_muxing_queue_size;
+
+ /* the packets are buffered here until the muxer is ready to be initialized */
+ AVFifoBuffer *muxing_queue;
+
+ /* packet picture type */
+ int pict_type;
+
+ /* frame encode sum of squared error values */
+ int64_t error[4];
+} OutputStream;
+
+typedef struct OutputFile {
+ AVFormatContext *ctx;
+ AVDictionary *opts;
+ int ost_index; /* index of the first stream in output_streams */
+ int64_t recording_time; ///< desired length of the resulting file in microseconds == AV_TIME_BASE units
+ int64_t start_time; ///< start time in microseconds == AV_TIME_BASE units
+ uint64_t limit_filesize; /* filesize limit expressed in bytes */
+
+ int shortest;
+
+ int header_written;
+} OutputFile;
+
+extern InputStream **input_streams;
+extern int nb_input_streams;
+extern InputFile **input_files;
+extern int nb_input_files;
+
+extern OutputStream **output_streams;
+extern int nb_output_streams;
+extern OutputFile **output_files;
+extern int nb_output_files;
+
+extern FilterGraph **filtergraphs;
+extern int nb_filtergraphs;
+
+extern char *vstats_filename;
+extern char *sdp_filename;
+
+extern float audio_drift_threshold;
+extern float dts_delta_threshold;
+extern float dts_error_threshold;
+
+extern int audio_volume;
+extern int audio_sync_method;
+extern int video_sync_method;
+extern float frame_drop_threshold;
+extern int do_benchmark;
+extern int do_benchmark_all;
+extern int do_deinterlace;
+extern int do_hex_dump;
+extern int do_pkt_dump;
+extern int copy_ts;
+extern int start_at_zero;
+extern int copy_tb;
+extern int debug_ts;
+extern int exit_on_error;
+extern int abort_on_flags;
+extern int print_stats;
+extern int qp_hist;
+extern int stdin_interaction;
+extern int frame_bits_per_raw_sample;
+extern AVIOContext *progress_avio;
+extern float max_error_rate;
+extern char *videotoolbox_pixfmt;
+
+extern int filter_nbthreads;
+extern int filter_complex_nbthreads;
+extern int vstats_version;
+
+extern const AVIOInterruptCB int_cb;
+
+extern const OptionDef options[];
+extern const HWAccel hwaccels[];
+extern int hwaccel_lax_profile_check;
+extern AVBufferRef *hw_device_ctx;
+#if CONFIG_QSV
+extern char *qsv_device;
+#endif
+extern HWDevice *filter_hw_device;
+
+
+void term_init(void);
+void term_exit(void);
+
+void reset_options(OptionsContext *o, int is_input);
+void show_usage(void);
+
+void opt_output_file(void *optctx, const char *filename);
+
+void remove_avoptions(AVDictionary **a, AVDictionary *b);
+void assert_avoptions(AVDictionary *m);
+
+int guess_input_channel_layout(InputStream *ist);
+
+enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx, AVCodec *codec, enum AVPixelFormat target);
+void choose_sample_fmt(AVStream *st, AVCodec *codec);
+
+int configure_filtergraph(FilterGraph *fg);
+int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);
+void check_filter_outputs(void);
+int ist_in_filtergraph(FilterGraph *fg, InputStream *ist);
+int filtergraph_is_simple(FilterGraph *fg);
+int init_simple_filtergraph(InputStream *ist, OutputStream *ost);
+int init_complex_filtergraph(FilterGraph *fg);
+
+void sub2video_update(InputStream *ist, AVSubtitle *sub);
+
+int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame);
+
+int ffmpeg_parse_options(int argc, char **argv);
+
+int vda_init(AVCodecContext *s);
+int videotoolbox_init(AVCodecContext *s);
+int qsv_init(AVCodecContext *s);
+int cuvid_init(AVCodecContext *s);
+
+HWDevice *hw_device_get_by_name(const char *name);
+int hw_device_init_from_string(const char *arg, HWDevice **dev);
+void hw_device_free_all(void);
+
+int hw_device_setup_for_decode(InputStream *ist);
+int hw_device_setup_for_encode(OutputStream *ost);
+
+int hwaccel_decode_init(AVCodecContext *avctx);
+
- #endif /* FFMPEG_H */
++#endif /* FFTOOLS_FFMPEG_H */
diff --cc fftools/ffmpeg_cuvid.c
index 3ff3b40f17,0000000000..3ff3b40f17
mode 100644,000000..100644
--- a/fftools/ffmpeg_cuvid.c
+++ b/fftools/ffmpeg_cuvid.c
diff --cc fftools/ffmpeg_filter.c
index aacc185059,0000000000..aacc185059
mode 100644,000000..100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
diff --cc fftools/ffmpeg_hw.c
index a4d1cada59,0000000000..a4d1cada59
mode 100644,000000..100644
--- a/fftools/ffmpeg_hw.c
+++ b/fftools/ffmpeg_hw.c
diff --cc fftools/ffmpeg_opt.c
index 100fa76e46,0000000000..100fa76e46
mode 100644,000000..100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
diff --cc fftools/ffmpeg_qsv.c
index 7442750029,0000000000..7442750029
mode 100644,000000..100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
diff --cc fftools/ffmpeg_videotoolbox.c
index e9039654b9,0000000000..e9039654b9
mode 100644,000000..100644
--- a/fftools/ffmpeg_videotoolbox.c
+++ b/fftools/ffmpeg_videotoolbox.c
diff --cc fftools/ffplay.c
index 9f7774613c,0000000000..9f7774613c
mode 100644,000000..100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
diff --cc fftools/ffprobe.c
index b2e8949d9f,0000000000..b2e8949d9f
mode 100644,000000..100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
diff --cc fftools/ffserver.c
index d4885dfa0e,0000000000..d4885dfa0e
mode 100644,000000..100644
--- a/fftools/ffserver.c
+++ b/fftools/ffserver.c
diff --cc fftools/ffserver_config.c
index 54135be989,0000000000..54135be989
mode 100644,000000..100644
--- a/fftools/ffserver_config.c
+++ b/fftools/ffserver_config.c
diff --cc fftools/ffserver_config.h
index 48d38dc325,0000000000..089b8484da
mode 100644,000000..100644
--- a/fftools/ffserver_config.h
+++ b/fftools/ffserver_config.h
@@@ -1,155 -1,0 +1,155 @@@
+/*
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
+ *
+ * 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 FFSERVER_CONFIG_H
- #define FFSERVER_CONFIG_H
++#ifndef FFTOOLS_FFSERVER_CONFIG_H
++#define FFTOOLS_FFSERVER_CONFIG_H
+
+#define FFM_PACKET_SIZE 4096
+
+#include "libavutil/dict.h"
+#include "libavformat/avformat.h"
+#include "libavformat/network.h"
+
+#define FFSERVER_MAX_STREAMS 20
+
+/* each generated stream is described here */
+enum FFServerStreamType {
+ STREAM_TYPE_LIVE,
+ STREAM_TYPE_STATUS,
+ STREAM_TYPE_REDIRECT,
+};
+
+enum FFServerIPAddressAction {
+ IP_ALLOW = 1,
+ IP_DENY,
+};
+
+typedef struct FFServerIPAddressACL {
+ struct FFServerIPAddressACL *next;
+ enum FFServerIPAddressAction action;
+ /* These are in host order */
+ struct in_addr first;
+ struct in_addr last;
+} FFServerIPAddressACL;
+
+/**
+ * This holds the stream parameters for an AVStream, it cannot be a AVStream
+ * because AVStreams cannot be instanciated without a AVFormatContext, especially
+ * not outside libavformat.
+ *
+ * The fields of this struct have the same semantics as the fields of an AVStream.
+ */
+typedef struct LayeredAVStream {
+ int index;
+ int id;
+ AVCodecParameters *codecpar;
+ AVCodecContext *codec;
+ AVRational time_base;
+ int pts_wrap_bits;
+ AVRational sample_aspect_ratio;
+ char *recommended_encoder_configuration;
+} LayeredAVStream;
+
+/* description of each stream of the ffserver.conf file */
+typedef struct FFServerStream {
+ enum FFServerStreamType stream_type;
+ char filename[1024]; /* stream filename */
+ struct FFServerStream *feed; /* feed we are using (can be null if coming from file) */
+ AVDictionary *in_opts; /* input parameters */
+ AVDictionary *metadata; /* metadata to set on the stream */
+ AVInputFormat *ifmt; /* if non NULL, force input format */
+ AVOutputFormat *fmt;
+ FFServerIPAddressACL *acl;
+ char dynamic_acl[1024];
+ int nb_streams;
+ int prebuffer; /* Number of milliseconds early to start */
+ int64_t max_time; /* Number of milliseconds to run */
+ int send_on_key;
+ LayeredAVStream *streams[FFSERVER_MAX_STREAMS];
+ int feed_streams[FFSERVER_MAX_STREAMS]; /* index of streams in the feed */
+ char feed_filename[1024]; /* file name of the feed storage, or
+ input file name for a stream */
+ pid_t pid; /* Of ffmpeg process */
+ time_t pid_start; /* Of ffmpeg process */
+ char **child_argv;
+ struct FFServerStream *next;
+ unsigned bandwidth; /* bandwidth, in kbits/s */
+ /* RTSP options */
+ char *rtsp_option;
+ /* multicast specific */
+ int is_multicast;
+ struct in_addr multicast_ip;
+ int multicast_port; /* first port used for multicast */
+ int multicast_ttl;
+ int loop; /* if true, send the stream in loops (only meaningful if file) */
+ char single_frame; /* only single frame */
+
+ /* feed specific */
+ int feed_opened; /* true if someone is writing to the feed */
+ int is_feed; /* true if it is a feed */
+ int readonly; /* True if writing is prohibited to the file */
+ int truncate; /* True if feeder connection truncate the feed file */
+ int conns_served;
+ int64_t bytes_served;
+ int64_t feed_max_size; /* maximum storage size, zero means unlimited */
+ int64_t feed_write_index; /* current write position in feed (it wraps around) */
+ int64_t feed_size; /* current size of feed */
+ struct FFServerStream *next_feed;
+} FFServerStream;
+
+typedef struct FFServerConfig {
+ char *filename;
+ FFServerStream *first_feed; /* contains only feeds */
+ FFServerStream *first_stream; /* contains all streams, including feeds */
+ unsigned int nb_max_http_connections;
+ unsigned int nb_max_connections;
+ uint64_t max_bandwidth;
+ int debug;
+ int bitexact;
+ char logfilename[1024];
+ struct sockaddr_in http_addr;
+ struct sockaddr_in rtsp_addr;
+ int errors;
+ int warnings;
+ int use_defaults;
+ // Following variables MUST NOT be used outside configuration parsing code.
+ enum AVCodecID guessed_audio_codec_id;
+ enum AVCodecID guessed_video_codec_id;
+ AVDictionary *video_opts; /* AVOptions for video encoder */
+ AVDictionary *audio_opts; /* AVOptions for audio encoder */
+ AVCodecContext *dummy_actx; /* Used internally to test audio AVOptions. */
+ AVCodecContext *dummy_vctx; /* Used internally to test video AVOptions. */
+ int no_audio;
+ int no_video;
+ int line_num;
+ int stream_use_defaults;
+} FFServerConfig;
+
+void ffserver_get_arg(char *buf, int buf_size, const char **pp);
+
+void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
+ FFServerIPAddressACL *ext_acl,
+ const char *p, const char *filename, int line_num);
+
+int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config);
+
+void ffserver_free_child_args(void *argsp);
+
- #endif /* FFSERVER_CONFIG_H */
++#endif /* FFTOOLS_FFSERVER_CONFIG_H */
More information about the ffmpeg-cvslog
mailing list