On Thu, Apr 21, 2011 at 6:30 PM, rukhsana afroz <[email protected]>wrote:
> Thanks Nicolas for your comments. I will incorporate those in my code.
>
I have attached new patch again.
--
Rukhsana Ruby
Phd Student
Department of Electrical & Computer Engineering
The University of British Columbia
============================
diff --git a/libavcodec/j2k.c b/libavcodec/j2k.c
index f1337ed..59bbb0a 100644
--- a/libavcodec/j2k.c
+++ b/libavcodec/j2k.c
@@ -105,18 +105,20 @@ static void tag_tree_zero(J2kTgtNode *t, int w, int h)
uint8_t ff_j2k_nbctxno_lut[256][4];
-static int getnbctxno(int flag, int bandno)
+static int getnbctxno(int flag, int bandno, int vert_causal_ctx_csty_symbol)
{
int h, v, d;
- h = ((flag & J2K_T1_SIG_E) ? 1:0)+
+ h = ((flag & J2K_T1_SIG_E) ? 1:0)+
((flag & J2K_T1_SIG_W) ? 1:0);
- v = ((flag & J2K_T1_SIG_N) ? 1:0)+
- ((flag & J2K_T1_SIG_S) ? 1:0);
+ v = ((flag & J2K_T1_SIG_N) ? 1:0);
+ if(!vert_causal_ctx_csty_symbol)
+ v = v + ((flag & J2K_T1_SIG_S) ? 1:0);
d = ((flag & J2K_T1_SIG_NE) ? 1:0)+
- ((flag & J2K_T1_SIG_NW) ? 1:0)+
- ((flag & J2K_T1_SIG_SE) ? 1:0)+
- ((flag & J2K_T1_SIG_SW) ? 1:0);
+ ((flag & J2K_T1_SIG_NW) ? 1:0);
+ if(!vert_causal_ctx_csty_symbol)
+ d = d + ((flag & J2K_T1_SIG_SE) ? 1:0)+
+ ((flag & J2K_T1_SIG_SW) ? 1:0);
if (bandno < 3){
if (bandno == 1)
FFSWAP(int, h, v);
diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c
index 0f8864d..1a52a13 100644
--- a/libavcodec/j2kdec.c
+++ b/libavcodec/j2kdec.c
@@ -303,6 +303,8 @@ static int get_cod(J2kDecoderContext *s, J2kCodingStyle *c, uint8_t *properties)
J2kCodingStyle tmp;
int compno;
+ av_log(s->avctx, AV_LOG_DEBUG, "Inside get_cod\n");
+
if (s->buf_end - s->buf < 5)
return AVERROR(EINVAL);
@@ -332,6 +334,8 @@ static int get_coc(J2kDecoderContext *s, J2kCodingStyle *c, uint8_t *properties)
{
int compno;
+ av_log(s->avctx, AV_LOG_DEBUG, "Inside get_coc\n");
+
if (s->buf_end - s->buf < 2)
return AVERROR(EINVAL);
@@ -592,7 +596,7 @@ static int decode_packets(J2kDecoderContext *s, J2kTile *tile)
}
/* TIER-1 routines */
-static void decode_sigpass(J2kT1Context *t1, int width, int height, int bpno, int bandno)
+static void decode_sigpass(J2kT1Context *t1, int width, int height, int bpno, int bandno, int bpass_csty_symbol, int vert_causal_ctx_csty_symbol)
{
int mask = 3 << (bpno - 1), y0, x, y;
@@ -601,10 +605,13 @@ static void decode_sigpass(J2kT1Context *t1, int width, int height, int bpno, in
for (y = y0; y < height && y < y0+4; y++){
if ((t1->flags[y+1][x+1] & J2K_T1_SIG_NB)
&& !(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS))){
- if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno))){
+ vert_causal_ctx_csty_symbol = vert_causal_ctx_csty_symbol && (x == 3 && y == 3);
+ if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno, vert_causal_ctx_csty_symbol))){
int xorbit, ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
-
- t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? -mask : mask;
+ if (bpass_csty_symbol)
+ t1->data[y][x] = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? -mask : mask;
+ else
+ t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? -mask : mask;
ff_j2k_set_significant(t1, x, y, t1->data[y][x] < 0);
}
@@ -685,7 +692,7 @@ static void decode_clnpass(J2kDecoderContext *s, J2kT1Context *t1, int width, in
static int decode_cblk(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kT1Context *t1, J2kCblk *cblk,
int width, int height, int bandpos)
{
- int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y;
+ int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y, clnpass_cnt = 0;
for (y = 0; y < height+2; y++)
memset(t1->flags[y], 0, (width+2)*sizeof(int));
@@ -697,14 +704,26 @@ static int decode_cblk(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kT1Contex
cblk->data[cblk->length] = 0xff;
cblk->data[cblk->length+1] = 0xff;
+ //av_log(s->avctx, AV_LOG_ERROR,"decode_cblk passno: %d, bpno: %d\n", passno, bpno);
+
+ bpass_csty_symbol = J2K_CBLK_BYPASS & codsty->cblk_style;
+ vert_causal_ctx_csty_symbol = J2K_CBLK_VSC & codsty->cblk_style;
+
while(passno--){
switch(pass_t){
- case 0: decode_sigpass(t1, width, height, bpno+1, bandpos);
+ case 0: decode_sigpass(t1, width, height, bpno+1, bandpos, bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol);
break;
- case 1: decode_refpass(t1, width, height, bpno+1);
+ case 1:
+ decode_refpass(t1, width, height, bpno+1);
+ if (bpass_csty_symbol && clnpass_cnt >= 4)
+ ff_mqc_initdec(&t1->mqc, cblk->data);
break;
- case 2: decode_clnpass(s, t1, width, height, bpno+1, bandpos,
+ case 2:
+ decode_clnpass(s, t1, width, height, bpno+1, bandpos,
codsty->cblk_style & J2K_CBLK_SEGSYM);
+ clnpass_cnt = clnpass_cnt + 1;
+ if (bpass_csty_symbol && clnpass_cnt >= 4)
+ ff_mqc_initdec(&t1->mqc, cblk->data);
break;
}
@@ -899,6 +918,7 @@ static int decode_codestream(J2kDecoderContext *s)
oldbuf = s->buf;
if (marker == J2K_SOD){
+ av_log(s->avctx, AV_LOG_DEBUG, "Inside J2K_SOD\n");
J2kTile *tile = s->tile + s->curtileno;
if (ret = init_tile(s, s->curtileno))
return ret;
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel