summaryrefslogtreecommitdiff
path: root/libavutil/pixdesc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-21 02:30:39 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-26 03:02:25 +0200
commit8be6552aa4bff1ce1016739a77733a2dcbdfaa8b (patch)
tree1bace4dca8377a42da7a1854ccda46e84158ecee /libavutil/pixdesc.c
parentcf856d8957f82a3b15071b8f1f551b06a65b9b3f (diff)
downloadffmpeg-8be6552aa4bff1ce1016739a77733a2dcbdfaa8b.tar.gz
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(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavutil/pixdesc.c')
-rw-r--r--libavutil/pixdesc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index bfba414167..3ac44614a7 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -3315,3 +3315,26 @@ int av_chroma_location_from_name(const char *name)
return AVERROR(EINVAL);
}
+
+int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
+{
+ if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB)
+ return AVERROR(EINVAL);
+ pos--;
+
+ *xpos = (pos&1) * 128;
+ *ypos = ((pos>>1)^(pos<4)) * 128;
+
+ return 0;
+}
+
+enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos)
+{
+ int pos, xout, yout;
+
+ for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) {
+ if (av_chroma_location_enum_to_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos)
+ return pos;
+ }
+ return AVCHROMA_LOC_UNSPECIFIED;
+}