[FFmpeg-devel] GSoC project (JPEG 2000)

rukhsana afroz rukhsana.afroz at gmail.com
Wed Apr 20 06:09:28 CEST 2011


On Tue, Apr 19, 2011 at 2:59 PM, Nicolas George <
nicolas.george at 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:

diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c
index 0f8864d..e000df0 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,12 @@ 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))){
+                    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 +691,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 +703,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));
                     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 +917,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;

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.

Thanks



-- 
Rukhsana Ruby
Phd Student
Department of Electrical & Computer Engineering
The University of British Columbia
============================


More information about the ffmpeg-devel mailing list