Skip to content

Commit

Permalink
lib*/version: Move library version functions into files of their own
Browse files Browse the repository at this point in the history
This avoids having to rebuild big files every time FFMPEG_VERSION
changes (which it does with every commit).

Signed-off-by: Andreas Rheinhardt <[email protected]>
  • Loading branch information
mkver committed May 10, 2022
1 parent 3417379 commit f2b79c5
Show file tree
Hide file tree
Showing 26 changed files with 397 additions and 202 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ vpath %/fate_config.sh.template $(SRC_PATH)
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options

ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale swresample

# $(FFLIBS-yes) needs to be in linking order
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
FFLIBS-$(CONFIG_AVFILTER) += avfilter
Expand Down Expand Up @@ -113,7 +115,7 @@ include $(SRC_PATH)/fftools/Makefile
include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/doc/examples/Makefile

libavcodec/avcodec.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
$(ALLFFLIBS:%=lib%/version.o): libavutil/ffversion.h

$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
ifeq ($(STRIPTYPE),direct)
Expand Down
2 changes: 0 additions & 2 deletions ffbuild/common.mak
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
endif

ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale swresample

# NASM requires -I path terminated with /
IFLAGS := -I. -I$(SRC_LINK)/
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
Expand Down
1 change: 1 addition & 0 deletions libavcodec/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ OBJS = ac3_parser.o \
qsv_api.o \
raw.o \
utils.o \
version.o \
vlc.o \
vorbis_parser.o \
xiph.o \
Expand Down
25 changes: 0 additions & 25 deletions libavcodec/avcodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,6 @@
#include "frame_thread_encoder.h"
#include "internal.h"
#include "thread.h"
#include "version.h"

#include "libavutil/ffversion.h"
const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION;

unsigned avcodec_version(void)
{
av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563);
av_assert0(AV_CODEC_ID_ADPCM_G722==69660);
av_assert0(AV_CODEC_ID_SRT==94216);
av_assert0(LIBAVCODEC_VERSION_MICRO >= 100);

return LIBAVCODEC_VERSION_INT;
}

const char *avcodec_configuration(void)
{
return FFMPEG_CONFIGURATION;
}

const char *avcodec_license(void)
{
#define LICENSE_PREFIX "libavcodec license: "
return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}

int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
{
Expand Down
50 changes: 50 additions & 0 deletions libavcodec/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Version functions.
*
* 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 "libavutil/avassert.h"
#include "avcodec.h"
#include "codec_id.h"
#include "version.h"

#include "libavutil/ffversion.h"
const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION;

unsigned avcodec_version(void)
{
av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563);
av_assert0(AV_CODEC_ID_ADPCM_G722==69660);
av_assert0(AV_CODEC_ID_SRT==94216);
av_assert0(LIBAVCODEC_VERSION_MICRO >= 100);

return LIBAVCODEC_VERSION_INT;
}

const char *avcodec_configuration(void)
{
return FFMPEG_CONFIGURATION;
}

const char *avcodec_license(void)
{
#define LICENSE_PREFIX "libavcodec license: "
return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}
1 change: 1 addition & 0 deletions libavdevice/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ HEADERS = avdevice.h \
OBJS = alldevices.o \
avdevice.o \
utils.o \
version.o \

OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o

Expand Down
24 changes: 0 additions & 24 deletions libavdevice/avdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,15 @@
*/

#include "libavutil/avassert.h"
#include "libavutil/samplefmt.h"
#include "libavutil/pixfmt.h"
#include "avdevice.h"
#include "internal.h"
#include "config.h"
#include "version.h"

#include "libavutil/ffversion.h"
const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;

#if FF_API_DEVICE_CAPABILITIES
const AVOption av_device_capabilities[] = {
{ NULL }
};
#endif

unsigned avdevice_version(void)
{
av_assert0(LIBAVDEVICE_VERSION_MICRO >= 100);
return LIBAVDEVICE_VERSION_INT;
}

const char * avdevice_configuration(void)
{
return FFMPEG_CONFIGURATION;
}

const char * avdevice_license(void)
{
#define LICENSE_PREFIX "libavdevice license: "
return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}

int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum AVAppToDevMessageType type,
void *data, size_t data_size)
{
Expand Down
45 changes: 45 additions & 0 deletions libavdevice/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Version functions.
*
* 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 "libavutil/avassert.h"
#include "avdevice.h"
#include "version.h"

#include "libavutil/ffversion.h"
const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;

unsigned avdevice_version(void)
{
av_assert0(LIBAVDEVICE_VERSION_MICRO >= 100);
return LIBAVDEVICE_VERSION_INT;
}

const char * avdevice_configuration(void)
{
return FFMPEG_CONFIGURATION;
}

const char * avdevice_license(void)
{
#define LICENSE_PREFIX "libavdevice license: "
return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}
1 change: 1 addition & 0 deletions libavfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ OBJS = allfilters.o \
framequeue.o \
graphdump.o \
graphparser.o \
version.o \
video.o \

OBJS-$(HAVE_THREADS) += pthread.o
Expand Down
23 changes: 0 additions & 23 deletions libavfilter/avfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
#include "libavutil/hwcontext.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/rational.h"
#include "libavutil/samplefmt.h"
#include "libavutil/thread.h"

#define FF_INTERNAL_FIELDS 1
#include "framequeue.h"
Expand All @@ -43,10 +41,6 @@
#include "formats.h"
#include "framepool.h"
#include "internal.h"
#include "version.h"

#include "libavutil/ffversion.h"
const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION;

static void tlog_ref(void *ctx, AVFrame *ref, int end)
{
Expand Down Expand Up @@ -75,23 +69,6 @@ static void tlog_ref(void *ctx, AVFrame *ref, int end)
ff_tlog(ctx, "]%s", end ? "\n" : "");
}

unsigned avfilter_version(void)
{
av_assert0(LIBAVFILTER_VERSION_MICRO >= 100);
return LIBAVFILTER_VERSION_INT;
}

const char *avfilter_configuration(void)
{
return FFMPEG_CONFIGURATION;
}

const char *avfilter_license(void)
{
#define LICENSE_PREFIX "libavfilter license: "
return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}

void ff_command_queue_pop(AVFilterContext *filter)
{
AVFilterCommand *c= filter->command_queue;
Expand Down
44 changes: 44 additions & 0 deletions libavfilter/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Version functions.
*
* 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 "libavutil/avassert.h"
#include "avfilter.h"
#include "version.h"

#include "libavutil/ffversion.h"
const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION;

unsigned avfilter_version(void)
{
av_assert0(LIBAVFILTER_VERSION_MICRO >= 100);
return LIBAVFILTER_VERSION_INT;
}

const char *avfilter_configuration(void)
{
return FFMPEG_CONFIGURATION;
}

const char *avfilter_license(void)
{
#define LICENSE_PREFIX "libavfilter license: "
return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}
1 change: 1 addition & 0 deletions libavformat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ OBJS = allformats.o \
seek.o \
url.o \
utils.o \
version.o \

OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o

Expand Down
21 changes: 0 additions & 21 deletions libavformat/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
#if CONFIG_NETWORK
#include "network.h"
#endif
#include "version.h"

#include "libavutil/ffversion.h"
const char av_format_ffversion[] = "FFmpeg version " FFMPEG_VERSION;

static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER;

Expand All @@ -58,23 +54,6 @@ static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER;
* various utility functions for use within FFmpeg
*/

unsigned avformat_version(void)
{
av_assert0(LIBAVFORMAT_VERSION_MICRO >= 100);
return LIBAVFORMAT_VERSION_INT;
}

const char *avformat_configuration(void)
{
return FFMPEG_CONFIGURATION;
}

const char *avformat_license(void)
{
#define LICENSE_PREFIX "libavformat license: "
return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}

int ff_lock_avformat(void)
{
return ff_mutex_lock(&avformat_mutex) ? -1 : 0;
Expand Down
45 changes: 45 additions & 0 deletions libavformat/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Version functions.
*
* 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 "libavutil/avassert.h"
#include "avformat.h"
#include "version.h"

#include "libavutil/ffversion.h"
const char av_format_ffversion[] = "FFmpeg version " FFMPEG_VERSION;

unsigned avformat_version(void)
{
av_assert0(LIBAVFORMAT_VERSION_MICRO >= 100);
return LIBAVFORMAT_VERSION_INT;
}

const char *avformat_configuration(void)
{
return FFMPEG_CONFIGURATION;
}

const char *avformat_license(void)
{
#define LICENSE_PREFIX "libavformat license: "
return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}
Loading

0 comments on commit f2b79c5

Please sign in to comment.