[FFmpeg-devel] [PATCH 2/2] avcodec: add avcodec_chroma_pos_to_enum()

Michael Niedermayer michaelni at gmx.at
Wed Jul 17 23:00:12 CEST 2013


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 doc/APIchanges       |    4 ++++
 libavcodec/avcodec.h |    2 ++
 libavcodec/utils.c   |   11 +++++++++++
 3 files changed, 17 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index aac9d8c..2bb45fa 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil:     2012-10-22
 
 API changes, most recent first:
 
+2013-07-XX - xxxxxxx - XXXXXXXXXXXXXX - avcodec.h
+  Add avcodec_chroma_pos_to_enum()
+  Add avcodec_enum_to_chroma_pos()
+
 2013-07-03 - xxxxxxx - lavfi 3.78.100 - avfilter.h
   Deprecate avfilter_graph_parse() in favor of the equivalent
   avfilter_graph_parse_ptr().
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 618effc..db12326 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3608,6 +3608,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
 
 int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
 
+enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
+
 #if FF_API_OLD_DECODE_AUDIO
 /**
  * Wrapper function which calls avcodec_decode_audio4.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 0b33170..64bae3e 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -350,6 +350,17 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
     return 0;
 }
 
+enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos)
+{
+    int pos, xout, yout;
+
+    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;
+}
+
 int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
                              enum AVSampleFormat sample_fmt, const uint8_t *buf,
                              int buf_size, int align)
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list