Browse code

lavu: add av_get_pix_fmt_name() convenience function

Also deprecate avcodec_get_pix_fmt_name() in its favor.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>

Stefano Sabatini authored on 2011/05/28 09:39:20
Showing 7 changed files
... ...
@@ -13,6 +13,10 @@ libavutil:   2011-04-18
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2011-05-XX - xxxxxx - lavu 51.X.0 - pixdesc.h
17
+  Add av_get_pix_fmt_name() in libavutil/pixdesc.h, and deprecate
18
+  avcodec_get_pix_fmt_name() in libavcodec/avcodec.h in its favor.
19
+
16 20
 2011-05-25 - 30315a8 - lavf 53.1.0 - avformat.h
17 21
   Add fps_probe_size to AVFormatContext.
18 22
 
... ...
@@ -3306,7 +3306,15 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width,
3306 3306
  */
3307 3307
 int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
3308 3308
 void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
3309
+
3310
+#if FF_API_GET_PIX_FMT_NAME
3311
+/**
3312
+ * @deprecated Deprecated in favor of av_get_pix_fmt_name().
3313
+ */
3314
+attribute_deprecated
3309 3315
 const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
3316
+#endif
3317
+
3310 3318
 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
3311 3319
 
3312 3320
 /**
... ...
@@ -417,13 +417,12 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *
417 417
     *v_shift = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h;
418 418
 }
419 419
 
420
+#if FF_API_GET_PIX_FMT_NAME
420 421
 const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt)
421 422
 {
422
-    if ((unsigned)pix_fmt >= PIX_FMT_NB)
423
-        return NULL;
424
-    else
425
-        return av_pix_fmt_descriptors[pix_fmt].name;
423
+    return av_get_pix_fmt_name(pix_fmt);
426 424
 }
425
+#endif
427 426
 
428 427
 int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt)
429 428
 {
... ...
@@ -65,5 +65,8 @@
65 65
 #ifndef FF_API_FLAC_GLOBAL_OPTS
66 66
 #define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
67 67
 #endif
68
+#ifndef FF_API_GET_PIX_FMT_NAME
69
+#define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54)
70
+#endif
68 71
 
69 72
 #endif /* AVCODEC_VERSION_H */
... ...
@@ -40,7 +40,7 @@
40 40
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41 41
 
42 42
 #define LIBAVUTIL_VERSION_MAJOR 51
43
-#define LIBAVUTIL_VERSION_MINOR  1
43
+#define LIBAVUTIL_VERSION_MINOR  2
44 44
 #define LIBAVUTIL_VERSION_MICRO  0
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
... ...
@@ -906,6 +906,12 @@ static enum PixelFormat get_pix_fmt_internal(const char *name)
906 906
     return PIX_FMT_NONE;
907 907
 }
908 908
 
909
+const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt)
910
+{
911
+    return (unsigned)pix_fmt < PIX_FMT_NB ?
912
+        av_pix_fmt_descriptors[pix_fmt].name : NULL;
913
+}
914
+
909 915
 #if HAVE_BIGENDIAN
910 916
 #   define X_NE(be, le) be
911 917
 #else
... ...
@@ -23,6 +23,7 @@
23 23
 #define AVUTIL_PIXDESC_H
24 24
 
25 25
 #include <inttypes.h>
26
+#include "pixfmt.h"
26 27
 
27 28
 typedef struct AVComponentDescriptor{
28 29
     uint16_t plane        :2;            ///< which of the 4 planes contains the component
... ...
@@ -142,6 +143,14 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi
142 142
 enum PixelFormat av_get_pix_fmt(const char *name);
143 143
 
144 144
 /**
145
+ * Return the short name for a pixel format, NULL in case pix_fmt is
146
+ * unknown.
147
+ *
148
+ * @see av_get_pix_fmt(), av_get_pix_fmt_string()
149
+ */
150
+const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt);
151
+
152
+/**
145 153
  * Print in buf the string corresponding to the pixel format with
146 154
  * number pix_fmt, or an header if pix_fmt is negative.
147 155
  *