avcodec/avcodec: Deprecate lavc chroma pos API functions

avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum()
deal with enum AVChromaLocation which is defined in lavu.
These functions are therefore replaced by
av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum().
This commit provides the necessary deprecations. Also already make
these functions wrappers around the corresponding lavu functions
as not doing so would force one to disable deprecation warnings.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-09-21 02:42:48 +02:00
parent 832e6563df
commit a02a0e8db4
5 changed files with 17 additions and 17 deletions

View File

@ -14,6 +14,11 @@ libavutil: 2021-04-27
API changes, most recent first: API changes, most recent first:
2022-09-26 - xxxxxxxxxx - lavc 59.48.100 - avcodec.h
Deprecate avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum().
Use av_chroma_location_enum_to_pos() or av_chroma_location_pos_to_enum()
instead.
2022-09-26 - xxxxxxxxxx - lavu 57.37.100 - pixdesc.h 2022-09-26 - xxxxxxxxxx - lavu 57.37.100 - pixdesc.h
Add av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum(). Add av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum().

View File

@ -2496,6 +2496,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[AV_NUM_DATA_POINTERS]); int linesize_align[AV_NUM_DATA_POINTERS]);
#ifdef FF_API_AVCODEC_CHROMA_POS
/** /**
* Converts AVChromaLocation to swscale x/y chroma position. * Converts AVChromaLocation to swscale x/y chroma position.
* *
@ -2504,7 +2505,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
* *
* @param xpos horizontal chroma sample position * @param xpos horizontal chroma sample position
* @param ypos vertical chroma sample position * @param ypos vertical chroma sample position
* @deprecated Use av_chroma_location_enum_to_pos() instead.
*/ */
attribute_deprecated
int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
/** /**
@ -2515,8 +2518,11 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
* *
* @param xpos horizontal chroma sample position * @param xpos horizontal chroma sample position
* @param ypos vertical chroma sample position * @param ypos vertical chroma sample position
* @deprecated Use av_chroma_location_pos_to_enum() instead.
*/ */
attribute_deprecated
enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
#endif
/** /**
* Decode a subtitle message. * Decode a subtitle message.

View File

@ -353,29 +353,17 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height)
align = FFMAX3(align, linesize_align[1], linesize_align[2]); align = FFMAX3(align, linesize_align[1], linesize_align[2]);
*width = FFALIGN(*width, align); *width = FFALIGN(*width, align);
} }
#if FF_API_AVCODEC_CHROMA_POS
int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos) int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
{ {
if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB) return av_chroma_location_enum_to_pos(xpos, ypos, pos);
return AVERROR(EINVAL);
pos--;
*xpos = (pos&1) * 128;
*ypos = ((pos>>1)^(pos<4)) * 128;
return 0;
} }
enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos) enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos)
{ {
int pos, xout, yout; return av_chroma_location_pos_to_enum(xpos, ypos);
for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) {
if (avcodec_enum_to_chroma_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos)
return pos;
}
return AVCHROMA_LOC_UNSPECIFIED;
} }
#endif
int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
enum AVSampleFormat sample_fmt, const uint8_t *buf, enum AVSampleFormat sample_fmt, const uint8_t *buf,

View File

@ -29,7 +29,7 @@
#include "version_major.h" #include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 47 #define LIBAVCODEC_VERSION_MINOR 48
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

View File

@ -52,5 +52,6 @@
#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AYUV_CODECID (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_AYUV_CODECID (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_VT_OUTPUT_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_VT_OUTPUT_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_AVCODEC_CHROMA_POS (LIBAVCODEC_VERSION_MAJOR < 60)
#endif /* AVCODEC_VERSION_MAJOR_H */ #endif /* AVCODEC_VERSION_MAJOR_H */