[FFmpeg-devel] GSoC project (JPEG 2000)

Michael Niedermayer michaelni at gmx.at
Wed Apr 13 22:46:09 CEST 2011


On Mon, Apr 11, 2011 at 10:32:19PM -0700, rukhsana afroz wrote:
> On Wed, Apr 6, 2011 at 6:35 PM, rukhsana afroz <rukhsana.afroz at gmail.com>wrote:
> 
> >
> >
> > On Wed, Apr 6, 2011 at 9:24 AM, Michael Niedermayer <michaelni at gmx.at>wrote:
> >
> >>  I suspect the If statement is there as the implementation only supports
> >> cblk_style==0
> >> the others simply are not implemented
> >>
> >> Do you think you can implement them?
> >>
> >> Thanks Michael for your reply. I read the specification once. I believe, I
> > will be able to implement existing missing features of decoder. Later on, I
> > can work on encoder once I know the JPEG 2000 coding standard thoroughly. I
> > will submit my SoC application tonight, or tomorrow morning.
> >
> > Thanks
> > Ruby
> >
> >
> I have found what to do for particularly this missing feature. It looks
> like, parameters have been defined for all values of cblk_style in j2k.h
> file.
> 
> // Codeblock coding styles
> #define J2K_CBLK_BYPASS    0x01 // Selective arithmetic coding bypass
> #define J2K_CBLK_RESET     0x02 // Reset context probabilities
> #define J2K_CBLK_TERMALL   0x04 // Terminate after each coding pass
> #define J2K_CBLK_VSC       0x08 // Vertical stripe causal context formation
> #define J2K_CBLK_PREDTERM  0x10 // Predictable termination
> #define J2K_CBLK_SEGSYM    0x20 // Segmentation symbols present
> 
> Specification also says, these are the at most number of code block styles.
> These cblk_style is used while decoding the a particular code block (which
> is resided inside one band, one component-tile contains a number of bands,
> one tile is subdivided again into a number of component-tiles, entire
> codestream consists of a number of tiles). From the code, i see only the
> code block style J2K_CBLK_SEGSYM has been implemented. When code block style
> is zero, no action has been taken and it is default. Logic for this
> implementation is in the function decode_cblk and then from there main logic
> is  in decode_clnpass function.
> 
> 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;
> 
>     for (y = 0; y < height+2; y++)
>         memset(t1->flags[y], 0, (width+2)*sizeof(int));
> 
>     for (y = 0; y < height; y++)
>         memset(t1->data[y], 0, width*sizeof(int));
> 
>     ff_mqc_initdec(&t1->mqc, cblk->data);
>     cblk->data[cblk->length] = 0xff;
>     cblk->data[cblk->length+1] = 0xff;
> 
>     while(passno--){
>         switch(pass_t){
>             case 0: decode_sigpass(t1, width, height, bpno+1, bandpos);
>                     break;
>             case 1: decode_refpass(t1, width, height, bpno+1);
>                     break;
>            * case 2: decode_clnpass(s, t1, width, height, bpno+1, bandpos,
>                                    codsty->cblk_style & J2K_CBLK_SEGSYM);*
>                     break;
>         }
> 
>         pass_t++;
>         if (pass_t == 3){
>             bpno--;
>             pass_t = 0;
>         }
>     }
>     return 0;
> }
> 
> static void decode_clnpass(J2kDecoderContext *s, J2kT1Context *t1, int
> width, int height,
>                            int bpno, int bandno, int seg_symbols)
> {
>     int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;
> 
>     for (y0 = 0; y0 < height; y0 += 4) {
>         for (x = 0; x < width; x++){
>             if (y0 + 3 < height && !(
>             (t1->flags[y0+1][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS |
> J2K_T1_SIG)) ||
>             (t1->flags[y0+2][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS |
> J2K_T1_SIG)) ||
>             (t1->flags[y0+3][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS |
> J2K_T1_SIG)) ||
>             (t1->flags[y0+4][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS |
> J2K_T1_SIG)))){
>                 if (!ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL))
>                     continue;
>                 runlen = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states +
> MQC_CX_UNI);
>                 runlen = (runlen << 1) | ff_mqc_decode(&t1->mqc,
> t1->mqc.cx_states + MQC_CX_UNI);
>                 dec = 1;
>             } else{
>                 runlen = 0;
>                 dec = 0;
>             }
> 
>             for (y = y0 + runlen; y < y0 + 4 && y < height; y++){
>                 if (!dec){
>                     if (!(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS)))
>                         dec = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states +
> ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno));
>                 }
>                 if (dec){
>                     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;
>                     ff_j2k_set_significant(t1, x, y, t1->data[y][x] < 0);
>                 }
>                 dec = 0;
>                 t1->flags[y+1][x+1] &= ~J2K_T1_VIS;
>             }
>         }
>     }
>  *   if (seg_symbols) {
>         int val;
>         val = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);
>         val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states +
> MQC_CX_UNI);
>         val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states +
> MQC_CX_UNI);
>         val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states +
> MQC_CX_UNI);
>         if (val != 0xa) {
>             av_log(s->avctx, AV_LOG_ERROR,"Segmentation symbol value
> incorrect\n");
>         }*
>     }
> }
> 
> 
> I am working on the modification to take into account all code block styles.

great


> Please let me know if you have any suggestion. I truly appreciate all of
> your helps.

i dont see a specific question in your mail, my suggestion is just to
implement the missing feature.
If you have specific questions ill try my best to help

and sorry for my slow reply


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110413/7ce3b5a7/attachment.asc>


More information about the ffmpeg-devel mailing list