return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
- uint16_t Cx0, Cy0;
+ int Cx0, Cy0;
/* Compute coordinates of codeblocks */
/* Compute Cx0*/
return AVERROR_INVALIDDATA;
csize = (comp->coord[0][1] - comp->coord[0][0]) *
(comp->coord[1][1] - comp->coord[1][0]);
- if (comp->coord[0][1] > 32768 ||
- comp->coord[1][1] > 32768) {
+ if (comp->coord[0][1] - comp->coord[0][0] > 32768 ||
+ comp->coord[1][1] - comp->coord[1][0] > 32768) {
av_log(avctx, AV_LOG_ERROR, "component size too large\n");
return AVERROR_PATCHWELCOME;
}
int nb_terminationsinc;
int data_start[JPEG2000_MAX_PASSES];
Jpeg2000Pass passes[JPEG2000_MAX_PASSES];
- uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
+ int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
} Jpeg2000Cblk; // code block
typedef struct Jpeg2000Prec {
- uint16_t nb_codeblocks_width;
- uint16_t nb_codeblocks_height;
+ int nb_codeblocks_width;
+ int nb_codeblocks_height;
Jpeg2000TgtNode *zerobits;
Jpeg2000TgtNode *cblkincl;
Jpeg2000Cblk *cblk;
int decoded_layers;
- uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
+ int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
} Jpeg2000Prec; // precinct
typedef struct Jpeg2000Band {
- uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
+ int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
uint16_t log2_cblk_width, log2_cblk_height;
int i_stepsize; // quantization stepsize
float f_stepsize; // quantization stepsize
typedef struct Jpeg2000ResLevel {
uint8_t nbands;
- uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
- uint16_t num_precincts_x, num_precincts_y; // number of precincts in x/y direction
+ int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
+ int num_precincts_x, num_precincts_y; // number of precincts in x/y direction
uint8_t log2_prec_width, log2_prec_height; // exponent of precinct size
Jpeg2000Band *band;
} Jpeg2000ResLevel; // resolution level
DWTContext dwt;
float *f_data;
int *i_data;
- uint16_t coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} -- can be reduced with lowres option
- uint16_t coord_o[2][2]; // border coordinates {{x0, x1}, {y0, y1}} -- original values from jpeg2000 headers
+ int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} -- can be reduced with lowres option
+ int coord_o[2][2]; // border coordinates {{x0, x1}, {y0, y1}} -- original values from jpeg2000 headers
} Jpeg2000Component;
/* misc tools */
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/common.h"
+#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
avpriv_request_sample(s->avctx, "Support for image offsets");
return AVERROR_PATCHWELCOME;
}
- if (s->width > 32768U || s->height > 32768U) {
+ if (av_image_check_size(s->width, s->height, 0, s->avctx)) {
avpriv_request_sample(s->avctx, "Large Dimensions");
return AVERROR_PATCHWELCOME;
}
data[i] = (data[i] + ((1<<I_PRESHIFT)>>1)) >> I_PRESHIFT;
}
-int ff_jpeg2000_dwt_init(DWTContext *s, uint16_t border[2][2],
+int ff_jpeg2000_dwt_init(DWTContext *s, int border[2][2],
int decomp_levels, int type)
{
int i, j, lev = decomp_levels, maxlen,
#define MAX_W 256
-static int test_dwt(int *array, int *ref, uint16_t border[2][2], int decomp_levels, int type, int max_diff) {
+static int test_dwt(int *array, int *ref, int border[2][2], int decomp_levels, int type, int max_diff) {
int ret, j;
DWTContext s1={{{0}}}, *s= &s1;
int64_t err2 = 0;
return 0;
}
-static int test_dwtf(float *array, float *ref, uint16_t border[2][2], int decomp_levels, float max_diff) {
+static int test_dwtf(float *array, float *ref, int border[2][2], int decomp_levels, float max_diff) {
int ret, j;
DWTContext s1={{{0}}}, *s= &s1;
double err2 = 0;
int main(void) {
AVLFG prng;
int i,j;
- uint16_t border[2][2];
+ int border[2][2];
int ret, decomp_levels;
av_lfg_init(&prng, 1);
typedef struct DWTContext {
/// line lengths { horizontal, vertical } in consecutive decomposition levels
- uint16_t linelen[FF_DWT_MAX_DECLVLS][2];
+ int linelen[FF_DWT_MAX_DECLVLS][2];
uint8_t mod[FF_DWT_MAX_DECLVLS][2]; ///< coordinates (x0, y0) of decomp. levels mod 2
uint8_t ndeclevels; ///< number of decomposition levels
uint8_t type; ///< 0 for 9/7; 1 for 5/3
* @param decomp_levels number of decomposition levels
* @param type 0 for DWT 9/7; 1 for DWT 5/3
*/
-int ff_jpeg2000_dwt_init(DWTContext *s, uint16_t border[2][2],
+int ff_jpeg2000_dwt_init(DWTContext *s, int border[2][2],
int decomp_levels, int type);
int ff_dwt_encode(DWTContext *s, void *t);