[FFmpeg-devel] [PATCH 03/13] Implement ff_get_codec_tag_from_pix_fmt() and ff_get_pix_fmt_from_codec_tag() internal functions.

Stefano Sabatini stefano.sabatini-lala
Sun May 9 16:29:08 CEST 2010


---
 libavcodec/internal.h |   13 +++++++++++++
 libavcodec/utils.c    |   20 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 97c0dcb..1acef72 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -26,6 +26,7 @@
 
 #include <stdint.h>
 #include "avcodec.h"
+#include "raw.h"
 
 /**
  * Determines whether pix_fmt is a hardware accelerated format.
@@ -48,4 +49,16 @@ AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt);
  */
 int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
 
+/**
+ * Returns the first codec tag found in tags corresponding to the
+ * pixel format fmt. If no codec tag is found returns 0.
+ */
+unsigned int ff_get_codec_tag_from_pix_fmt(const PixelFormatTag *tags, enum PixelFormat fmt);
+
+/**
+ * Returns the first pixel format found in tags corresponding to the
+ * codec tag tag. If no pixel format is found returns PIX_FMT_NONE.
+ */
+enum PixelFormat ff_get_pix_fmt_from_codec_tag(const PixelFormatTag *tags, unsigned int tag);
+
 #endif /* AVCODEC_INTERNAL_H */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 87facec..f53d105 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1293,3 +1293,23 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
     }
     return 0;
 }
+
+unsigned int ff_get_codec_tag_from_pix_fmt(const PixelFormatTag *tags, enum PixelFormat fmt)
+{
+    while (tags->pix_fmt >= 0) {
+        if (tags->pix_fmt == fmt)
+            return tags->fourcc;
+        tags++;
+    }
+    return 0;
+}
+
+enum PixelFormat ff_get_pix_fmt_from_codec_tag(const PixelFormatTag *tags, unsigned int tag)
+{
+    while (tags->pix_fmt >= 0) {
+        if (tags->fourcc == tag)
+            return tags->pix_fmt;
+        tags++;
+    }
+    return PIX_FMT_NONE;
+}
-- 
1.7.0




More information about the ffmpeg-devel mailing list