History

avutil/pixdesc: Add av_chroma_location_(enum_to_pos|pos_to_enum)

They are intended as replacements for avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum().

Andreas Rheinhardt committed 4 years ago

Commit 8be65521 parent cf856d84 files · +50 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/pixdesc.c +23 −0
  3. libavutil/pixdesc.h +22 −0
  4. libavutil/version.h +2 −2
doc/APIchanges+3−0
@@ -14,6 +14,9 @@ libavutil: 2021-04-27 · 13 unmodified lines
1414
1515 API changes, most recent first:
1616
17+2022-09-26 - xxxxxxxxxx - lavu 57.37.100 - pixdesc.h
18+ Add av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum().
19+
1720 2022-09-26 - xxxxxxxxxx - lavc 59.47.100 - avcodec.h defs.h
1821 Move the AV_EF_* and FF_COMPLIANCE_* defines from avcodec.h to defs.h.
1922
libavutil/pixdesc.c+23−0
@@ -3315,3 +3315,26 @@ int av_chroma_location_from_name(const char *name) · 3314 unmodified lines
33153315
33163316 return AVERROR(EINVAL);
33173317 }
3318+
3319+int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
3320+{
3321+ if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB)
3322+ return AVERROR(EINVAL);
3323+ pos--;
3324+
3325+ *xpos = (pos&1) * 128;
3326+ *ypos = ((pos>>1)^(pos<4)) * 128;
3327+
3328+ return 0;
3329+}
3330+
3331+enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos)
3332+{
3333+ int pos, xout, yout;
3334+
3335+ for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) {
3336+ if (av_chroma_location_enum_to_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos)
3337+ return pos;
3338+ }
3339+ return AVCHROMA_LOC_UNSPECIFIED;
3340+}
libavutil/pixdesc.h+22−0
@@ -264,6 +264,28 @@ const char *av_chroma_location_name(enum AVChromaLocation location); · 263 unmodified lines
264264 */
265265 int av_chroma_location_from_name(const char *name);
266266
267+/**
268+ * Converts AVChromaLocation to swscale x/y chroma position.
269+ *
270+ * The positions represent the chroma (0,0) position in a coordinates system
271+ * with luma (0,0) representing the origin and luma(1,1) representing 256,256
272+ *
273+ * @param xpos horizontal chroma sample position
274+ * @param ypos vertical chroma sample position
275+ */
276+int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
277+
278+/**
279+ * Converts swscale x/y chroma position to AVChromaLocation.
280+ *
281+ * The positions represent the chroma (0,0) position in a coordinates system
282+ * with luma (0,0) representing the origin and luma(1,1) representing 256,256
283+ *
284+ * @param xpos horizontal chroma sample position
285+ * @param ypos vertical chroma sample position
286+ */
287+enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos);
288+
267289 /**
268290 * Return the pixel format corresponding to name.
269291 *
libavutil/version.h+2−2
@@ -79,8 +79,8 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 57
82−#define LIBAVUTIL_VERSION_MINOR 36
83−#define LIBAVUTIL_VERSION_MICRO 102
82+#define LIBAVUTIL_VERSION_MINOR 37
83+#define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
8686 LIBAVUTIL_VERSION_MINOR, \

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