[FFmpeg-devel] [PATCH 1/2] avutil: Add av_get_time_base{_q, }() and deprecate AV_TIME_BASE{_Q, }
James Almer
jamrial at gmail.com
Mon Dec 30 00:47:15 CET 2013
On 29/12/13 8:35 PM, Derek Buitenhuis wrote:
> It was never a good idea to have tehse values as defines in the first place,
> since they are internal values, and may change.
>
> This also fixes the impossibility of using AV_TIME_BASE_Q in pre-C99/C++
> applications, which cannot use compound literals directly in their code.
>
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
> doc/APIchanges | 4 ++++
> libavutil/avutil.h | 41 +++++++++++++++++++++++++++++------------
> libavutil/utils.c | 10 ++++++++++
> libavutil/version.h | 5 ++++-
> 4 files changed, 47 insertions(+), 13 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 21a8c4c..66ae67a 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,10 @@ libavutil: 2012-10-22
>
> API changes, most recent first:
>
> +2013-12-xx - xxxxxxx - lavu 52.60.0 - avutil.h
> + Add av_get_time_base() and deprecate AV_TIME_BASE.
> + Add av_get_time_base_q() and deprecate AV_TIME_BASE_Q.
> +
> 2013-12-22 - xxxxxxx - lavu 52.59.100 - avstring.h
> Add av_strnlen() function.
>
> diff --git a/libavutil/avutil.h b/libavutil/avutil.h
> index d8f4690..22bf099 100644
> --- a/libavutil/avutil.h
> +++ b/libavutil/avutil.h
> @@ -229,18 +229,6 @@ const char *av_get_media_type_string(enum AVMediaType media_type);
> #define AV_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000))
>
> /**
> - * Internal time base represented as integer
> - */
> -
> -#define AV_TIME_BASE 1000000
> -
> -/**
> - * Internal time base represented as fractional value
> - */
> -
> -#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
> -
> -/**
> * @}
> * @}
> * @defgroup lavu_picture Image related
> @@ -276,6 +264,7 @@ char av_get_picture_type_char(enum AVPictureType pict_type);
>
> #include "common.h"
> #include "error.h"
> +#include "rational.h"
> #include "version.h"
> #include "mathematics.h"
> #include "rational.h"
> @@ -323,4 +312,32 @@ FILE *av_fopen_utf8(const char *path, const char *mode);
> * @}
> */
>
> +/**
> + * Returns the integer representation of the internal time base.
> + */
> +int av_get_time_base(void);
> +
> +/**
> + * Returns the fractional representation of the internal time base.
> + */
> +AVRational av_get_time_base_q(void);
> +
> +#if FF_API_TIME_BASE
> +/**
> + * Internal time base represented as integer
> + *
> + * @deprecated use av_get_time_base().
> + */
> +
> +#define AV_TIME_BASE 1000000
> +
> +/**
> + * Internal time base represented as fractional value
> + *
> + * @deprecated use av_get_time_base_q().
> + */
> +
> +#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
> +#endif
> +
> #endif /* AVUTIL_AVUTIL_H */
> diff --git a/libavutil/utils.c b/libavutil/utils.c
> index 9453c30..434c8b3 100644
> --- a/libavutil/utils.c
> +++ b/libavutil/utils.c
> @@ -113,3 +113,13 @@ unsigned av_int_list_length_for_size(unsigned elsize,
> }
> return i;
> }
> +
> +int av_get_time_base(void)
> +{
> + return 1000000;
> +}
> +
> +AVRational av_get_time_base_q(void)
> +{
> + return (AVRational){1, AV_TIME_BASE};
av_get_time_base() or 1000000 would probably be a better idea than using a
newly deprecated symbol.
> +}
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 446e1f2..01d81db 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -75,7 +75,7 @@
> */
>
> #define LIBAVUTIL_VERSION_MAJOR 52
> -#define LIBAVUTIL_VERSION_MINOR 59
> +#define LIBAVUTIL_VERSION_MINOR 60
> #define LIBAVUTIL_VERSION_MICRO 100
>
> #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> @@ -153,6 +153,9 @@
> #ifndef FF_API_INTFLOAT
> #define FF_API_INTFLOAT (LIBAVUTIL_VERSION_MAJOR < 54)
> #endif
> +#ifndef FF_API_TIME_BASE
> +#define FF_API_TIME_BASE (LIBAVUTIL_VERSION_MAJOR < 54)
> +#endif
>
> /**
> * @}
>
More information about the ffmpeg-devel
mailing list