[FFmpeg-devel] [PATCH] Deprecate avcodec_pix_fmt_string() in favor of av_get_pix_fmt_string(), added to libavutil/pixdesc.h.

Stefano Sabatini stefano.sabatini-lala
Sun Nov 21 22:35:02 CET 2010


---
 libavcodec/avcodec.h    |   12 +++---------
 libavcodec/imgconvert.c |   17 ++---------------
 libavutil/pixdesc.c     |   14 ++++++++++++++
 libavutil/pixdesc.h     |   12 ++++++++++++
 4 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3d1c1aa..8b12f11 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3274,18 +3274,12 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_
 enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
                               int has_alpha, int *loss_ptr);
 
-
+#if LIBAVCODEC_VERSION_MAJOR < 53
 /**
- * Print in buf the string corresponding to the pixel format with
- * number pix_fmt, or an header if pix_fmt is negative.
- *
- * @param[in] buf the buffer where to write the string
- * @param[in] buf_size the size of buf
- * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or
- * a negative value to print the corresponding header.
- * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1.
+ * @deprecated Use av_get_pix_fmt_string() instead.
  */
 void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt);
+#endif
 
 #define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
 #define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 3c112a8..41eb470 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -431,25 +431,12 @@ enum PixelFormat avcodec_get_pix_fmt(const char *name)
 {
     return av_get_pix_fmt(name);
 }
-#endif
 
 void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
 {
-    /* print header */
-    if (pix_fmt < 0)
-        snprintf (buf, buf_size,
-                  "name      " " nb_components" " nb_bits"
-            );
-    else{
-        const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
-        snprintf (buf, buf_size,
-                  "%-11s %7d %10d",
-                  pixdesc->name,
-                  pixdesc->nb_components,
-                  av_get_bits_per_pixel(pixdesc)
-            );
-    }
+    av_get_pix_fmt_string(buf, buf_size, pix_fmt);
 }
+#endif
 
 int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt)
 {
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 54f1d74..83aa8b0 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -851,3 +851,17 @@ int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
 
     return bits >> log2_pixels;
 }
+
+char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
+{
+    /* print header */
+    if (pix_fmt < 0) {
+        snprintf (buf, buf_size, "name      " " nb_components" " nb_bits");
+    } else {
+        const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
+        snprintf(buf, buf_size, "%-11s %7d %10d",
+                 pixdesc->name, pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
+    }
+
+    return buf;
+}
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index 8d131be..727e47f 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -142,6 +142,18 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi
 enum PixelFormat av_get_pix_fmt(const char *name);
 
 /**
+ * Print in buf the string corresponding to the pixel format with
+ * number pix_fmt, or an header if pix_fmt is negative.
+ *
+ * @param buf the buffer where to write the string
+ * @param buf_size the size of buf
+ * @param pix_fmt the number of the pixel format to print the
+ * corresponding info string, or a negative value to print the
+ * corresponding header.
+ */
+char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt);
+
+/**
  * Return the number of bits per pixel used by the pixel format
  * described by pixdesc.
  *
-- 
1.7.1




More information about the ffmpeg-devel mailing list