[FFmpeg-cvslog] r24709 - in trunk: libavcodec/avcodec.h libavcodec/utils.c libavcore/avcore.h libavcore/imgutils.c libavcore/imgutils.h

stefano subversion
Fri Aug 6 11:36:45 CEST 2010


Author: stefano
Date: Fri Aug  6 11:36:45 2010
New Revision: 24709

Log:
Deprecate avcodec_check_dimensions() in favor of the new function
av_check_image_size() declared in libavcore/imgutils.h.

Modified:
   trunk/libavcodec/avcodec.h
   trunk/libavcodec/utils.c
   trunk/libavcore/avcore.h
   trunk/libavcore/imgutils.c
   trunk/libavcore/imgutils.h

Modified: trunk/libavcodec/avcodec.h
==============================================================================
--- trunk/libavcodec/avcodec.h	Fri Aug  6 09:09:12 2010	(r24708)
+++ trunk/libavcodec/avcodec.h	Fri Aug  6 11:36:45 2010	(r24709)
@@ -31,7 +31,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 52
 #define LIBAVCODEC_VERSION_MINOR 84
-#define LIBAVCODEC_VERSION_MICRO  2
+#define LIBAVCODEC_VERSION_MICRO  3
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
@@ -3392,15 +3392,14 @@ void avcodec_align_dimensions(AVCodecCon
 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
                                int linesize_align[4]);
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
 /**
- * Check if the given dimension of a picture is valid, meaning that all
- * bytes of the picture can be addressed with a signed int.
- *
- * @param[in] w Width of the picture.
- * @param[in] h Height of the picture.
- * @return Zero if valid, a negative value if invalid.
+ * @deprecated Deprecated in favor of av_check_image_size().
  */
+attribute_deprecated
 int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
+#endif
+
 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
 
 int avcodec_thread_init(AVCodecContext *s, int thread_count);

Modified: trunk/libavcodec/utils.c
==============================================================================
--- trunk/libavcodec/utils.c	Fri Aug  6 09:09:12 2010	(r24708)
+++ trunk/libavcodec/utils.c	Fri Aug  6 11:36:45 2010	(r24709)
@@ -213,13 +213,11 @@ void avcodec_align_dimensions(AVCodecCon
     *width=FFALIGN(*width, align);
 }
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
 int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
-    if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
-        return 0;
-
-    av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h);
-    return AVERROR(EINVAL);
+    return av_check_image_size(w, h, 0, av_log_ctx);
 }
+#endif
 
 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
     int i;

Modified: trunk/libavcore/avcore.h
==============================================================================
--- trunk/libavcore/avcore.h	Fri Aug  6 09:09:12 2010	(r24708)
+++ trunk/libavcore/avcore.h	Fri Aug  6 11:36:45 2010	(r24709)
@@ -27,7 +27,7 @@
 #include <libavutil/avutil.h>
 
 #define LIBAVCORE_VERSION_MAJOR  0
-#define LIBAVCORE_VERSION_MINOR  2
+#define LIBAVCORE_VERSION_MINOR  3
 #define LIBAVCORE_VERSION_MICRO  0
 
 #define LIBAVCORE_VERSION_INT   AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \

Modified: trunk/libavcore/imgutils.c
==============================================================================
--- trunk/libavcore/imgutils.c	Fri Aug  6 09:09:12 2010	(r24708)
+++ trunk/libavcore/imgutils.c	Fri Aug  6 11:36:45 2010	(r24709)
@@ -95,3 +95,22 @@ int av_fill_image_pointers(uint8_t *data
 
     return total_size;
 }
+
+typedef struct ImgUtils {
+    const AVClass *class;
+    int   log_offset;
+    void *log_ctx;
+} ImgUtils;
+
+static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) };
+
+int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
+{
+    ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
+
+    if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
+        return 0;
+
+    av_log(&imgutils, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h);
+    return AVERROR(EINVAL);
+}

Modified: trunk/libavcore/imgutils.h
==============================================================================
--- trunk/libavcore/imgutils.h	Fri Aug  6 09:09:12 2010	(r24708)
+++ trunk/libavcore/imgutils.h	Fri Aug  6 11:36:45 2010	(r24709)
@@ -50,4 +50,16 @@ int av_fill_image_linesizes(int linesize
 int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
                            uint8_t *ptr, const int linesizes[4]);
 
+/**
+ * Check if the given dimension of an image is valid, meaning that all
+ * bytes of the image can be addressed with a signed int.
+ *
+ * @param w the width of the picture
+ * @param h the height of the picture
+ * @param log_offset the offset to sum to the log level for logging with log_ctx
+ * @param log_ctx the parent logging context, it may be NULL
+ * @return >= 0 if valid, a negative error code otherwise
+ */
+int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
+
 #endif /* AVCORE_IMGUTILS_H */



More information about the ffmpeg-cvslog mailing list