Browse code

lavu: add av_get_pix_fmt_name() convenience function

Also deprecate avcodec_get_pix_fmt_name() in its favor.

Stefano Sabatini authored on 2011/05/27 02:19:18
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-28 - xxxxxx - lavu 51.3.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-22 - xxxxxx - lavf 53.2.0 - avformat.h
17 21
   Introduce avformat_alloc_output_context2() and deprecate
18 22
   avformat_alloc_output_context().
... ...
@@ -3391,12 +3391,16 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width,
3391 3391
 int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
3392 3392
 void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
3393 3393
 
3394
+#if FF_API_GET_PIX_FMT_NAME
3394 3395
 /**
3395 3396
  * Return the short name for a pixel format.
3396 3397
  *
3397 3398
  * \see av_get_pix_fmt(), av_get_pix_fmt_string().
3399
+ * @deprecated Deprecated in favor of av_get_pix_fmt_name().
3398 3400
  */
3401
+attribute_deprecated
3399 3402
 const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
3403
+#endif
3400 3404
 
3401 3405
 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
3402 3406
 
... ...
@@ -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
 {
... ...
@@ -22,7 +22,7 @@
22 22
 
23 23
 #define LIBAVCODEC_VERSION_MAJOR 53
24 24
 #define LIBAVCODEC_VERSION_MINOR  6
25
-#define LIBAVCODEC_VERSION_MICRO  0
25
+#define LIBAVCODEC_VERSION_MICRO  1
26 26
 
27 27
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
28 28
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -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,8 +40,8 @@
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  2
44
-#define LIBAVUTIL_VERSION_MICRO  2
43
+#define LIBAVUTIL_VERSION_MINOR  3
44
+#define LIBAVUTIL_VERSION_MICRO  0
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
47 47
                                                LIBAVUTIL_VERSION_MINOR, \
... ...
@@ -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
... ...
@@ -22,6 +22,7 @@
22 22
 #ifndef AVUTIL_PIXDESC_H
23 23
 #define AVUTIL_PIXDESC_H
24 24
 
25
+#include "pixfmt.h"
25 26
 #include <inttypes.h>
26 27
 
27 28
 typedef struct AVComponentDescriptor{
... ...
@@ -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
  *