[FFmpeg-devel] GSoC project (JPEG 2000)
rukhsana afroz
rukhsana.afroz at gmail.com
Sun Apr 17 13:51:08 CEST 2011
On Fri, Apr 15, 2011 at 5:13 PM, rukhsana afroz <rukhsana.afroz at gmail.com>wrote:
>
>
> Hi Michael,
>
> I am in little bit problem of understanding the spec for implementing clean
> pass operation on a particular code block with different cblk_style. Page
> number of these implementations in spec is 112-119. Could you please have a
> look at the spec to help me on this? I appreciate your help.
Hi Michael,
I still could not implement the part of code block decode for different
cblk_style. However, I believe, I understand the spec now better than
before. I have one question regarding cblk_style J2K_CBLK_SEGSYM. It has
been implemneted in the code. The spec explanation about this is below:
*
D.5 Error resilience segmentation symbol
*
A segmentation symbol is a special symbol. Whether it is used is signalled
in the COD or COC marker segments (AnnexA.6.1 and Annex A.6.2). The symbol
is coded with the UNIFORM context of the arithmetic coder at the end of each
bitplane.The correct decoding of this symbol confirms the correctness of the
decoding of this bit-plane, which allows error detection. At the decoder, a
segmentation symbol “1010” or “0xA” should be decoded at the end of each
bit-plane. If the segmentation symbol is not decoded correctly, then bit
errors occurred for this bit-plane.
And the implemented code is below:
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");
}
}
*}
Could you please let me know how the implemented code match with the spec. I
have made the code bold for this code block style. I am wondering everytime
why "val" is left shifted after decoding each co-efficient in the bit-plane.
Please help me on this. I need to understand this first before implementing
the rest of the code block styles.
Thanks
> --
> Rukhsana Ruby
> Phd Student
> Department of Electrical & Computer Engineering
> The University of British Columbia
> ============================
>
>
>
--
Rukhsana Ruby
Phd Student
Department of Electrical & Computer Engineering
The University of British Columbia
============================
More information about the ffmpeg-devel
mailing list