[FFmpeg-soc] [soc]: r4733 - in jpeg2000: j2k.c j2k.h j2kdec.c
jai_menon
subversion at mplayerhq.hu
Mon Jul 20 15:08:31 CEST 2009
Author: jai_menon
Date: Mon Jul 20 15:08:30 2009
New Revision: 4733
Log:
Add support for component sub-sampling.
Modified:
jpeg2000/j2k.c
jpeg2000/j2k.h
jpeg2000/j2kdec.c
Modified: jpeg2000/j2k.c
==============================================================================
--- jpeg2000/j2k.c Sun Jul 19 16:42:36 2009 (r4732)
+++ jpeg2000/j2k.c Mon Jul 20 15:08:30 2009 (r4733)
@@ -197,7 +197,7 @@ void ff_j2k_set_significant(J2kT1Context
t1->flags[y-1][x-1] |= J2K_T1_SIG_SE;
}
-int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps)
+int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps, int dx, int dy)
{
int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1;
@@ -275,6 +275,14 @@ int ff_j2k_init_component(J2kComponent *
band->cblknx = ff_j2k_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width;
band->cblkny = ff_j2k_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height;
+ for (j = 0; j < 2; j++)
+ band->coord[0][j] = ff_j2k_ceildiv(band->coord[0][j], dx);
+ for (j = 0; j < 2; j++)
+ band->coord[1][j] = ff_j2k_ceildiv(band->coord[1][j], dy);
+
+ band->cblknx = ff_j2k_ceildiv(band->cblknx, dx);
+ band->cblkny = ff_j2k_ceildiv(band->cblkny, dy);
+
band->cblk = av_malloc(band->cblknx * band->cblkny * sizeof(J2kCblk));
if (!band->cblk)
return AVERROR(ENOMEM);
Modified: jpeg2000/j2k.h
==============================================================================
--- jpeg2000/j2k.h Sun Jul 19 16:42:36 2009 (r4732)
+++ jpeg2000/j2k.h Mon Jul 20 15:08:30 2009 (r4733)
@@ -213,7 +213,7 @@ static inline int ff_j2k_getsgnctxno(int
return ff_j2k_sgnctxno_lut[flag&15][(flag>>8)&15];
}
-int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps);
+int ff_j2k_init_component(J2kComponent *comp, J2kCodingStyle *codsty, J2kQuantStyle *qntsty, int cbps, int dx, int dy);
void ff_j2k_reinit(J2kComponent *comp, J2kCodingStyle *codsty);
void ff_j2k_cleanup(J2kComponent *comp, J2kCodingStyle *codsty);
Modified: jpeg2000/j2kdec.c
==============================================================================
--- jpeg2000/j2kdec.c Sun Jul 19 16:42:36 2009 (r4732)
+++ jpeg2000/j2kdec.c Mon Jul 20 15:08:30 2009 (r4733)
@@ -54,7 +54,7 @@ typedef struct {
uint8_t cbps[4]; ///< bits per sample in particular components
uint8_t sgnd[4]; ///< if a component is signed
uint8_t properties[4];
-
+ int cdx[4], cdy[4];
int precision;
int ncomponents;
int tile_width, tile_height; ///< tile size
@@ -228,10 +228,8 @@ static int get_siz(J2kDecoderContext *s)
s->cbps[i] = (x & 0x7f) + 1;
s->precision = FFMAX(s->cbps[i], s->precision);
s->sgnd[i] = (x & 0x80) == 1;
- if (bytestream_get_byte(&s->buf) != 1)
- return -1;
- if (bytestream_get_byte(&s->buf) != 1)
- return -1;
+ s->cdx[i] = bytestream_get_byte(&s->buf);
+ s->cdy[i] = bytestream_get_byte(&s->buf);
}
s->numXtiles = ff_j2k_ceildiv(s->width - s->tile_offset_x, s->tile_width);
@@ -453,7 +451,7 @@ static int init_tile(J2kDecoderContext *
comp->coord[1][0] = FFMAX(tiley * s->tile_height + s->tile_offset_y, s->image_offset_y);
comp->coord[1][1] = FFMIN((tiley+1)*s->tile_height + s->tile_offset_y, s->height);
- if (ret = ff_j2k_init_component(comp, codsty, qntsty, s->cbps[compno]))
+ if (ret = ff_j2k_init_component(comp, codsty, qntsty, s->cbps[compno], s->cdx[compno], s->cdy[compno]))
return ret;
}
return 0;
@@ -760,16 +758,16 @@ static int decode_tile(J2kDecoderContext
int y, x;
decode_cblk(s, &t1, band->cblk + cblkno, xx1 - xx0, yy1 - yy0, bandpos);
if (codsty->transform == FF_DWT53){
- for (y = yy0; y < yy1; y++){
+ for (y = yy0; y < yy1; y+=s->cdy[compno]){
int *ptr = t1.data[y-yy0];
- for (x = xx0; x < xx1; x++){
+ for (x = xx0; x < xx1; x+=s->cdx[compno]){
comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = *ptr++ >> 1;
}
}
} else{
- for (y = yy0; y < yy1; y++){
+ for (y = yy0; y < yy1; y+=s->cdy[compno]){
int *ptr = t1.data[y-yy0];
- for (x = xx0; x < xx1; x++){
+ for (x = xx0; x < xx1; x+=s->cdx[compno]){
int tmp = ((int64_t)*ptr++) * ((int64_t)band->stepsize) >> 13, tmp2;
tmp2 = FFABS(tmp>>1) + FFABS(tmp&1);
comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = tmp < 0 ? -tmp2 : tmp2;
More information about the FFmpeg-soc
mailing list