[PATCH 3/5] Implement ff_get_codec_tag_from_pix_fmt() and ff_get_pix_fmt_from_codec_tag() internal functions.

Stefano Sabatini stefano.sabatini-lala
Sun Mar 28 11:31:53 CEST 2010


---
 libavcodec/internal.h |   14 ++++++++++++++
 libavcodec/utils.c    |   21 +++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 7ce019c..9b26ddb 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,17 @@ 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 codec tag corresponding to the first tag entry in tags
+ * with pixel format fmt, or 0 if no such entry was found.
+ */
+unsigned int ff_get_codec_tag_from_pix_fmt(const PixelFormatTag *tags, enum PixelFormat fmt);
+
+/**
+ * Returns the pixel format corresponding to the first tag entry in
+ * tags with codec tag tag, or PIX_FMT_NONE if no such entry was
+ * found.
+ */
+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 e48cf6e..0d88a88 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1294,3 +1294,24 @@ 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


--6c2NcOVqGQ03X4Wi
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0004-Define-the-ff_nut_raw_video_pixel_format_tags-table-.patch"




More information about the ffmpeg-devel mailing list