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

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


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/avcodec.h |    2 ++
 libavcodec/utils.c   |   12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fca8a8f..618effc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3606,6 +3606,8 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
                                int linesize_align[AV_NUM_DATA_POINTERS]);
 
+int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
+
 #if FF_API_OLD_DECODE_AUDIO
 /**
  * Wrapper function which calls avcodec_decode_audio4.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index ff26c58..0b33170 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -338,6 +338,18 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height)
     *width              = FFALIGN(*width, align);
 }
 
+int avcodec_enum_to_chroma_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;
+}
+
 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