Skip to content

Commit

Permalink
libavcodec: Split version.h
Browse files Browse the repository at this point in the history
This avoids including version.h in all source files, avoiding
unnecessary rebuilds when the version number is bumped. Only
version_major.h is included by the main header, which defines
availability of e.g. FF_API_* macros, and which is bumped much
less often.

This isn't done for libavutil/version.h, because that header needs
to be included essentially everywhere due to LIBAVUTIL_VERSION_INT
being used wherever an AVClass is constructed.

Signed-off-by: Martin Storsjö <martin@martin.st>
  • Loading branch information
mstorsjo committed Mar 16, 2022
1 parent f2fe17c commit f2da2e1
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 32 deletions.
1 change: 1 addition & 0 deletions fftools/cmdutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "libavutil/ffversion.h"
#include "libavutil/version.h"
#include "libavcodec/bsf.h"
#include "libavcodec/version.h"
#include "cmdutils.h"
#if HAVE_SYS_RESOURCE_H
#include <sys/time.h>
Expand Down
1 change: 1 addition & 0 deletions fftools/ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "libavutil/thread.h"
#include "libavutil/threadmessage.h"
#include "libavcodec/mathops.h"
#include "libavcodec/version.h"
#include "libavformat/os_support.h"

# include "libavfilter/avfilter.h"
Expand Down
1 change: 1 addition & 0 deletions fftools/ffprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/version.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
Expand Down
1 change: 1 addition & 0 deletions libavcodec/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ HEADERS = ac3_parser.h \
qsv.h \
vdpau.h \
version.h \
version_major.h \
videotoolbox.h \
vorbis_parser.h \
xvmc.h \
Expand Down
1 change: 1 addition & 0 deletions libavcodec/aacenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "mpeg4audio.h"
#include "sinewin.h"
#include "profiles.h"
#include "version.h"

#include "aac.h"
#include "aactab.h"
Expand Down
1 change: 1 addition & 0 deletions libavcodec/avcodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#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;
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/avcodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "codec_id.h"
#include "defs.h"
#include "packet.h"
#include "version.h"
#include "version_major.h"

/**
* @defgroup libavc libavcodec
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "libavutil/samplefmt.h"

#include "libavcodec/codec_id.h"
#include "libavcodec/version.h"
#include "libavcodec/version_major.h"

/**
* @addtogroup lavc_core
Expand Down
1 change: 1 addition & 0 deletions libavcodec/dpxenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "avcodec.h"
#include "encode.h"
#include "internal.h"
#include "version.h"

typedef struct DPXContext {
int big_endian;
Expand Down
1 change: 1 addition & 0 deletions libavcodec/j2kenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include "internal.h"
#include "bytestream.h"
#include "jpeg2000.h"
#include "version.h"
#include "libavutil/common.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
Expand Down
1 change: 1 addition & 0 deletions libavcodec/libvorbisenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "audio_frame_queue.h"
#include "encode.h"
#include "internal.h"
#include "version.h"
#include "vorbis.h"
#include "vorbis_parser.h"

Expand Down
1 change: 1 addition & 0 deletions libavcodec/mjpegenc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "mjpegenc.h"
#include "mjpegenc_common.h"
#include "mjpeg.h"
#include "version.h"

/* table_class: 0 = DC coef, 1 = AC coefs */
static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
Expand Down
1 change: 1 addition & 0 deletions libavcodec/mpeg4videoenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "mpeg4videoenc.h"
#include "mpegvideoenc.h"
#include "profiles.h"
#include "version.h"

/* The uni_DCtab_* tables below contain unified bits+length tables to encode DC
* differences in MPEG-4. Unified in the sense that the specification specifies
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/options_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "libavutil/opt.h"
#include "avcodec.h"
#include "version.h"
#include "version_major.h"

#define OFFSET(x) offsetof(AVCodecContext,x)
#define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C
Expand Down
3 changes: 2 additions & 1 deletion libavcodec/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
#include "libavutil/buffer.h"
#include "libavutil/dict.h"
#include "libavutil/rational.h"
#include "libavutil/version.h"

#include "libavcodec/version.h"
#include "libavcodec/version_major.h"

/**
* @defgroup lavc_packet AVPacket
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/pthread_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "pthread_internal.h"
#include "thread.h"
#include "threadframe.h"
#include "version.h"
#include "version_major.h"

#include "libavutil/avassert.h"
#include "libavutil/buffer.h"
Expand Down
1 change: 1 addition & 0 deletions libavcodec/tiffenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "put_bits.h"
#include "rle.h"
#include "tiff.h"
#include "version.h"

#define TIFF_MAX_ENTRY 32

Expand Down
1 change: 1 addition & 0 deletions libavcodec/vaapi_encode_h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "h264_sei.h"
#include "internal.h"
#include "vaapi_encode.h"
#include "version.h"

enum {
SEI_TIMING = 0x01,
Expand Down
1 change: 1 addition & 0 deletions libavcodec/vc2enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "encode.h"
#include "put_bits.h"
#include "internal.h"
#include "version.h"

#include "vc2enc_dwt.h"
#include "diractab.h"
Expand Down
29 changes: 2 additions & 27 deletions libavcodec/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

#include "libavutil/version.h"

#define LIBAVCODEC_VERSION_MAJOR 59
#include "version_major.h"

#define LIBAVCODEC_VERSION_MINOR 24
#define LIBAVCODEC_VERSION_MICRO 100

Expand All @@ -41,30 +42,4 @@

#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)

/**
* FF_API_* defines may be placed below to indicate public API that will be
* dropped at a future version bump. The defines themselves are not part of
* the public API and may change, break or disappear at any time.
*
* @note, when bumping the major version it is recommended to manually
* disable each FF_API_* in its own commit instead of disabling them all
* at once through the bump. This improves the git bisect-ability of the change.
*/

#define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_UNUSED_CODEC_CAPS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_MPEGVIDEO_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_FLAG_TRUNCATED (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SUB_TEXT_FORMAT (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_MJPEG_PRED (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_IDCT_NONE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)

#endif /* AVCODEC_VERSION_H */
56 changes: 56 additions & 0 deletions libavcodec/version_major.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 AVCODEC_VERSION_MAJOR_H
#define AVCODEC_VERSION_MAJOR_H

/**
* @file
* @ingroup libavc
* Libavcodec version macros.
*/

#define LIBAVCODEC_VERSION_MAJOR 59

/**
* FF_API_* defines may be placed below to indicate public API that will be
* dropped at a future version bump. The defines themselves are not part of
* the public API and may change, break or disappear at any time.
*
* @note, when bumping the major version it is recommended to manually
* disable each FF_API_* in its own commit instead of disabling them all
* at once through the bump. This improves the git bisect-ability of the change.
*/

#define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_UNUSED_CODEC_CAPS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_MPEGVIDEO_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_FLAG_TRUNCATED (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SUB_TEXT_FORMAT (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_MJPEG_PRED (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_IDCT_NONE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)

#endif /* AVCODEC_VERSION_MAJOR_H */

0 comments on commit f2da2e1

Please sign in to comment.