[FFmpeg-devel] [PATCH 2/2] Deprecate avcodec_check_dimensions() in favor of the new function av_check_image_size() declared in libavcore/imgutils.h.
Stefano Sabatini
stefano.sabatini-lala
Fri Jul 30 12:13:57 CEST 2010
---
libavcodec/avcodec.h | 10 ++++------
libavcodec/utils.c | 8 +++-----
libavcore/imgutils.c | 9 +++++++++
libavcore/imgutils.h | 10 ++++++++++
libavfilter/vf_pad.c | 2 +-
5 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a38b630..fd18dc4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3392,15 +3392,13 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
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);
+
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
int avcodec_thread_init(AVCodecContext *s, int thread_count);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1d12f69..dfc1c06 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -213,13 +213,11 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
*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(av_log_ctx, w, h);
}
+#endif
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
int i;
diff --git a/libavcore/imgutils.c b/libavcore/imgutils.c
index 54c10d2..7680c8b 100644
--- a/libavcore/imgutils.c
+++ b/libavcore/imgutils.c
@@ -95,3 +95,12 @@ int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int heigh
return total_size;
}
+
+int av_check_image_size(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);
+}
diff --git a/libavcore/imgutils.h b/libavcore/imgutils.h
index 4a4d6a1..abdc12a 100644
--- a/libavcore/imgutils.h
+++ b/libavcore/imgutils.h
@@ -50,4 +50,14 @@ int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int widt
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[in] w the width of the picture
+ * @param[in] h the height of the picture
+ * @return >= 0 if valid, a negative error code otherwise
+ */
+int av_check_image_size(void *av_log_ctx, unsigned int w, unsigned int h);
+
#endif /* AVCORE_IMGUTILS_H */
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index bfa2dd5..a318a35 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -406,7 +406,7 @@ static int color_config_props(AVFilterLink *inlink)
color->w &= ~((1 << color->hsub) - 1);
color->h &= ~((1 << color->vsub) - 1);
- if (avcodec_check_dimensions(ctx, color->w, color->h) < 0)
+ if (av_check_image_size(ctx, color->w, color->h) < 0)
return AVERROR(EINVAL);
memcpy(rgba_color, color->color, sizeof(rgba_color));
--
1.7.0.4
More information about the ffmpeg-devel
mailing list