Revision bf176f58 libavcore/imgutils.c

View differences:

libavcore/imgutils.c
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
}

Also available in: Unified diff