On Tue, Apr 19, 2011 at 10:03 PM, rukhsana afroz <rukhsana.af...@gmail.com>wrote:
> > > On Tue, Apr 19, 2011 at 9:09 PM, rukhsana afroz > <rukhsana.af...@gmail.com>wrote: > >> >> >> On Tue, Apr 19, 2011 at 2:59 PM, Nicolas George < >> nicolas.geo...@normalesup.org> wrote: >> >>> I suggest you produce your patch using the revision control tool (svn or >>> git), and attach it as a file to avoid its mangling. >>> >>> Hi Ronald and Nicolas, >> >> Thanks for your suggestion. Now I have used git diff for creating my >> patch. Also, I have modified the code for cblk_csty "Vertical stripe causal >> context formation" along with "Selective arithmetic coding bypass" code >> block style. Please, have a look at my patch: >> >> >> The pages 115-118 from the spec have illustrated these ideas. Other code >> block styles are already implicitly implemneted in the previous code. >> Please, let me know if you have any suggestions. >> >> > There was a mistake in the previous patch. Here, I have put the new patch. > > Sorry, there was again another mistake in the previous patch. Here is new patch: diff --git a/libavcodec/j2k.c b/libavcodec/j2k.c index f1337ed..0f23b5b 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..750ba47 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_ERROR, "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_ERROR, "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_symbols = 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_symbols & (clnpass_cnt > 4), vert_causal_ctx_csty_symbol); break; - case 1: decode_refpass(t1, width, height, bpno+1); + case 1: + if (clnpass_cnt > 4) + ff_mqc_initdec(&t1->mqc, cblk->data); + decode_refpass(t1, width, height, bpno+1); break; - case 2: decode_clnpass(s, t1, width, height, bpno+1, bandpos, + case 2: + if (clnpass_cnt > 4) + ff_mqc_initdec(&t1->mqc, cblk->data); + decode_clnpass(s, t1, width, height, bpno+1, bandpos, codsty->cblk_style & J2K_CBLK_SEGSYM); + clnpass_cnt = clnpass_cnt + 1; break; } @@ -899,6 +918,7 @@ static int decode_codestream(J2kDecoderContext *s) oldbuf = s->buf; if (marker == J2K_SOD){ + av_log(s->avctx, AV_LOG_ERROR, "Inside J2K_SOD\n"); J2kTile *tile = s->tile + s->curtileno; if (ret = init_tile(s, s->curtileno)) return ret; -- Rukhsana Ruby Phd Student Department of Electrical & Computer Engineering The University of British Columbia ============================
_______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel