Originally committed as revision 24709 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -31,7 +31,7 @@ |
| 31 | 31 |
|
| 32 | 32 |
#define LIBAVCODEC_VERSION_MAJOR 52 |
| 33 | 33 |
#define LIBAVCODEC_VERSION_MINOR 84 |
| 34 |
-#define LIBAVCODEC_VERSION_MICRO 2 |
|
| 34 |
+#define LIBAVCODEC_VERSION_MICRO 3 |
|
| 35 | 35 |
|
| 36 | 36 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 37 | 37 |
LIBAVCODEC_VERSION_MINOR, \ |
| ... | ... |
@@ -3392,15 +3392,14 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); |
| 3392 | 3392 |
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, |
| 3393 | 3393 |
int linesize_align[4]); |
| 3394 | 3394 |
|
| 3395 |
+#if LIBAVCODEC_VERSION_MAJOR < 53 |
|
| 3395 | 3396 |
/** |
| 3396 |
- * Check if the given dimension of a picture is valid, meaning that all |
|
| 3397 |
- * bytes of the picture can be addressed with a signed int. |
|
| 3398 |
- * |
|
| 3399 |
- * @param[in] w Width of the picture. |
|
| 3400 |
- * @param[in] h Height of the picture. |
|
| 3401 |
- * @return Zero if valid, a negative value if invalid. |
|
| 3397 |
+ * @deprecated Deprecated in favor of av_check_image_size(). |
|
| 3402 | 3398 |
*/ |
| 3399 |
+attribute_deprecated |
|
| 3403 | 3400 |
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h); |
| 3401 |
+#endif |
|
| 3402 |
+ |
|
| 3404 | 3403 |
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); |
| 3405 | 3404 |
|
| 3406 | 3405 |
int avcodec_thread_init(AVCodecContext *s, int thread_count); |
| ... | ... |
@@ -213,13 +213,11 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
|
| 213 | 213 |
*width=FFALIGN(*width, align); |
| 214 | 214 |
} |
| 215 | 215 |
|
| 216 |
+#if LIBAVCODEC_VERSION_MAJOR < 53 |
|
| 216 | 217 |
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
|
| 217 |
- if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) |
|
| 218 |
- return 0; |
|
| 219 |
- |
|
| 220 |
- av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h); |
|
| 221 |
- return AVERROR(EINVAL); |
|
| 218 |
+ return av_check_image_size(w, h, 0, av_log_ctx); |
|
| 222 | 219 |
} |
| 220 |
+#endif |
|
| 223 | 221 |
|
| 224 | 222 |
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
|
| 225 | 223 |
int i; |
| ... | ... |
@@ -27,7 +27,7 @@ |
| 27 | 27 |
#include <libavutil/avutil.h> |
| 28 | 28 |
|
| 29 | 29 |
#define LIBAVCORE_VERSION_MAJOR 0 |
| 30 |
-#define LIBAVCORE_VERSION_MINOR 2 |
|
| 30 |
+#define LIBAVCORE_VERSION_MINOR 3 |
|
| 31 | 31 |
#define LIBAVCORE_VERSION_MICRO 0 |
| 32 | 32 |
|
| 33 | 33 |
#define LIBAVCORE_VERSION_INT AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \ |
| ... | ... |
@@ -95,3 +95,22 @@ int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int heigh |
| 95 | 95 |
|
| 96 | 96 |
return total_size; |
| 97 | 97 |
} |
| 98 |
+ |
|
| 99 |
+typedef struct ImgUtils {
|
|
| 100 |
+ const AVClass *class; |
|
| 101 |
+ int log_offset; |
|
| 102 |
+ void *log_ctx; |
|
| 103 |
+} ImgUtils; |
|
| 104 |
+ |
|
| 105 |
+static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) };
|
|
| 106 |
+ |
|
| 107 |
+int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) |
|
| 108 |
+{
|
|
| 109 |
+ ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
|
|
| 110 |
+ |
|
| 111 |
+ if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) |
|
| 112 |
+ return 0; |
|
| 113 |
+ |
|
| 114 |
+ av_log(&imgutils, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h); |
|
| 115 |
+ return AVERROR(EINVAL); |
|
| 116 |
+} |
| ... | ... |
@@ -50,4 +50,16 @@ int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int widt |
| 50 | 50 |
int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, |
| 51 | 51 |
uint8_t *ptr, const int linesizes[4]); |
| 52 | 52 |
|
| 53 |
+/** |
|
| 54 |
+ * Check if the given dimension of an image is valid, meaning that all |
|
| 55 |
+ * bytes of the image can be addressed with a signed int. |
|
| 56 |
+ * |
|
| 57 |
+ * @param w the width of the picture |
|
| 58 |
+ * @param h the height of the picture |
|
| 59 |
+ * @param log_offset the offset to sum to the log level for logging with log_ctx |
|
| 60 |
+ * @param log_ctx the parent logging context, it may be NULL |
|
| 61 |
+ * @return >= 0 if valid, a negative error code otherwise |
|
| 62 |
+ */ |
|
| 63 |
+int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); |
|
| 64 |
+ |
|
| 53 | 65 |
#endif /* AVCORE_IMGUTILS_H */ |