History

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.

Andreas Rheinhardt committed 4 years ago

Commit a02a0e81 parent 832e6565 files · +17 −17Browse files

Unified · Split

5 files
  1. doc/APIchanges +5 −0
  2. libavcodec/avcodec.h +6 −0
  3. libavcodec/utils.c +4 −16
  4. libavcodec/version.h +1 −1
  5. libavcodec/version_major.h +1 −0
doc/APIchanges+5−0
@@ -14,6 +14,11 @@ libavutil: 2021-04-27 · 13 unmodified lines
1414
1515 API changes, most recent first:
1616
17+2022-09-26 - xxxxxxxxxx - lavc 59.48.100 - avcodec.h
18+ Deprecate avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum().
19+ Use av_chroma_location_enum_to_pos() or av_chroma_location_pos_to_enum()
20+ instead.
21+
1722 2022-09-26 - xxxxxxxxxx - lavu 57.37.100 - pixdesc.h
1823 Add av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum().
1924
libavcodec/avcodec.h+6−0
@@ -2496,6 +2496,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); · 2495 unmodified lines
24962496 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
24972497 int linesize_align[AV_NUM_DATA_POINTERS]);
24982498
2499+#ifdef FF_API_AVCODEC_CHROMA_POS
24992500 /**
25002501 * Converts AVChromaLocation to swscale x/y chroma position.
25012502 *
@@ -2504,7 +2505,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, · 2 unmodified lines
25042505 *
25052506 * @param xpos horizontal chroma sample position
25062507 * @param ypos vertical chroma sample position
2508+ * @deprecated Use av_chroma_location_enum_to_pos() instead.
25072509 */
2510+ attribute_deprecated
25082511 int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
25092512
25102513 /**
@@ -2515,8 +2518,11 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); · 4 unmodified lines
25152518 *
25162519 * @param xpos horizontal chroma sample position
25172520 * @param ypos vertical chroma sample position
2521+ * @deprecated Use av_chroma_location_pos_to_enum() instead.
25182522 */
2523+ attribute_deprecated
25192524 enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
2525+#endif
25202526
25212527 /**
25222528 * Decode a subtitle message.
libavcodec/utils.c+4−16
@@ -353,29 +353,17 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height) · 352 unmodified lines
353353 align = FFMAX3(align, linesize_align[1], linesize_align[2]);
354354 *width = FFALIGN(*width, align);
355355 }
356−
356+#if FF_API_AVCODEC_CHROMA_POS
357357 int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
358358 {
359− if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB)
360− return AVERROR(EINVAL);
361− pos--;
362−
363− *xpos = (pos&1) * 128;
364− *ypos = ((pos>>1)^(pos<4)) * 128;
365−
366− return 0;
359+ return av_chroma_location_enum_to_pos(xpos, ypos, pos);
367360 }
368361
369362 enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos)
370363 {
371− int pos, xout, yout;
372−
373− for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) {
374− if (avcodec_enum_to_chroma_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos)
375− return pos;
376− }
377− return AVCHROMA_LOC_UNSPECIFIED;
364+ return av_chroma_location_pos_to_enum(xpos, ypos);
378365 }
366+#endif
379367
380368 int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
381369 enum AVSampleFormat sample_fmt, const uint8_t *buf,
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #include "version_major.h"
3131
32−#define LIBAVCODEC_VERSION_MINOR 47
32+#define LIBAVCODEC_VERSION_MINOR 48
3333 #define LIBAVCODEC_VERSION_MICRO 100
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
libavcodec/version_major.h+1−0
@@ -52,5 +52,6 @@ · 51 unmodified lines
5252 #define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
5353 #define FF_API_AYUV_CODECID (LIBAVCODEC_VERSION_MAJOR < 60)
5454 #define FF_API_VT_OUTPUT_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 60)
55+#define FF_API_AVCODEC_CHROMA_POS (LIBAVCODEC_VERSION_MAJOR < 60)
5556
5657 #endif /* AVCODEC_VERSION_MAJOR_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t