early-access version 1680
This commit is contained in:
65
externals/ffmpeg/libavcodec/jpeg2000dec.c
vendored
65
externals/ffmpeg/libavcodec/jpeg2000dec.c
vendored
@@ -269,6 +269,8 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
||||
const enum AVPixelFormat *possible_fmts = NULL;
|
||||
int possible_fmts_nb = 0;
|
||||
int ret;
|
||||
int o_dimx, o_dimy; //original image dimensions.
|
||||
int dimx, dimy;
|
||||
|
||||
if (bytestream2_get_bytes_left(&s->g) < 36) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for SIZ\n");
|
||||
@@ -286,10 +288,6 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
||||
s->tile_offset_y = bytestream2_get_be32u(&s->g); // YT0Siz
|
||||
ncomponents = bytestream2_get_be16u(&s->g); // CSiz
|
||||
|
||||
if (s->image_offset_x || s->image_offset_y) {
|
||||
avpriv_request_sample(s->avctx, "Support for image offsets");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
if (av_image_check_size2(s->width, s->height, s->avctx->max_pixels, AV_PIX_FMT_NONE, 0, s->avctx)) {
|
||||
avpriv_request_sample(s->avctx, "Large Dimensions");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
@@ -371,11 +369,18 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
||||
}
|
||||
|
||||
/* compute image size with reduction factor */
|
||||
ret = ff_set_dimensions(s->avctx,
|
||||
ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
|
||||
s->reduction_factor),
|
||||
ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
|
||||
s->reduction_factor));
|
||||
o_dimx = ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
|
||||
s->reduction_factor);
|
||||
o_dimy = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
|
||||
s->reduction_factor);
|
||||
dimx = ff_jpeg2000_ceildiv(o_dimx, s->cdx[0]);
|
||||
dimy = ff_jpeg2000_ceildiv(o_dimy, s->cdy[0]);
|
||||
for (i = 1; i < s->ncomponents; i++) {
|
||||
dimx = FFMAX(dimx, ff_jpeg2000_ceildiv(o_dimx, s->cdx[i]));
|
||||
dimy = FFMAX(dimy, ff_jpeg2000_ceildiv(o_dimy, s->cdy[i]));
|
||||
}
|
||||
|
||||
ret = ff_set_dimensions(s->avctx, dimx, dimy);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -427,6 +432,18 @@ static int get_siz(Jpeg2000DecoderContext *s)
|
||||
s->cdef[3] = 3;
|
||||
i = 0;
|
||||
}
|
||||
} else if (ncomponents == 3 && s->precision == 8 &&
|
||||
s->cdx[0] == s->cdx[1] && s->cdx[0] == s->cdx[2] &&
|
||||
s->cdy[0] == s->cdy[1] && s->cdy[0] == s->cdy[2]) {
|
||||
s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
|
||||
i = 0;
|
||||
} else if (ncomponents == 2 && s->precision == 8 &&
|
||||
s->cdx[0] == s->cdx[1] && s->cdy[0] == s->cdy[1]) {
|
||||
s->avctx->pix_fmt = AV_PIX_FMT_YA8;
|
||||
i = 0;
|
||||
} else if (ncomponents == 1 && s->precision == 8) {
|
||||
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,7 +575,7 @@ static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
|
||||
|
||||
if ((ret = get_cox(s, &tmp)) < 0)
|
||||
return ret;
|
||||
|
||||
tmp.init = 1;
|
||||
for (compno = 0; compno < s->ncomponents; compno++)
|
||||
if (!(properties[compno] & HAD_COC))
|
||||
memcpy(c + compno, &tmp, sizeof(tmp));
|
||||
@@ -596,6 +613,7 @@ static int get_coc(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
|
||||
return ret;
|
||||
|
||||
properties[compno] |= HAD_COC;
|
||||
c->init = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -969,12 +987,11 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
|
||||
comp->coord_o[0][1] = tile->coord[0][1];
|
||||
comp->coord_o[1][0] = tile->coord[1][0];
|
||||
comp->coord_o[1][1] = tile->coord[1][1];
|
||||
if (compno) {
|
||||
comp->coord_o[0][0] /= s->cdx[compno];
|
||||
comp->coord_o[0][1] /= s->cdx[compno];
|
||||
comp->coord_o[1][0] /= s->cdy[compno];
|
||||
comp->coord_o[1][1] /= s->cdy[compno];
|
||||
}
|
||||
|
||||
comp->coord_o[0][0] = ff_jpeg2000_ceildiv(comp->coord_o[0][0], s->cdx[compno]);
|
||||
comp->coord_o[0][1] = ff_jpeg2000_ceildiv(comp->coord_o[0][1], s->cdx[compno]);
|
||||
comp->coord_o[1][0] = ff_jpeg2000_ceildiv(comp->coord_o[1][0], s->cdy[compno]);
|
||||
comp->coord_o[1][1] = ff_jpeg2000_ceildiv(comp->coord_o[1][1], s->cdy[compno]);
|
||||
|
||||
comp->coord[0][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], s->reduction_factor);
|
||||
comp->coord[0][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][1], s->reduction_factor);
|
||||
@@ -983,7 +1000,8 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
|
||||
|
||||
if (!comp->roi_shift)
|
||||
comp->roi_shift = s->roi_shift[compno];
|
||||
|
||||
if (!codsty->init)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (ret = ff_jpeg2000_init_component(comp, codsty, qntsty,
|
||||
s->cbps[compno], s->cdx[compno],
|
||||
s->cdy[compno], s->avctx))
|
||||
@@ -1927,18 +1945,23 @@ static inline void tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
|
||||
float *datap = comp->f_data; \
|
||||
int32_t *i_datap = comp->i_data; \
|
||||
int cbps = s->cbps[compno]; \
|
||||
int w = tile->comp[compno].coord[0][1] - s->image_offset_x; \
|
||||
int w = tile->comp[compno].coord[0][1] - \
|
||||
ff_jpeg2000_ceildiv(s->image_offset_x, s->cdx[compno]); \
|
||||
int h = tile->comp[compno].coord[1][1] - \
|
||||
ff_jpeg2000_ceildiv(s->image_offset_y, s->cdy[compno]); \
|
||||
int plane = 0; \
|
||||
\
|
||||
if (planar) \
|
||||
plane = s->cdef[compno] ? s->cdef[compno]-1 : (s->ncomponents-1); \
|
||||
\
|
||||
y = tile->comp[compno].coord[1][0] - s->image_offset_y / s->cdy[compno]; \
|
||||
y = tile->comp[compno].coord[1][0] - \
|
||||
ff_jpeg2000_ceildiv(s->image_offset_y, s->cdy[compno]); \
|
||||
line = (PIXEL *)picture->data[plane] + y * (picture->linesize[plane] / sizeof(PIXEL));\
|
||||
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y++) { \
|
||||
for (; y < h; y++) { \
|
||||
PIXEL *dst; \
|
||||
\
|
||||
x = tile->comp[compno].coord[0][0] - s->image_offset_x / s->cdx[compno]; \
|
||||
x = tile->comp[compno].coord[0][0] - \
|
||||
ff_jpeg2000_ceildiv(s->image_offset_x, s->cdx[compno]); \
|
||||
dst = line + x * pixelsize + compno*!planar; \
|
||||
\
|
||||
if (codsty->transform == FF_DWT97) { \
|
||||
|
Reference in New Issue
Block a user