[FFmpeg-devel] GSoC project (JPEG 2000)

rukhsana afroz rukhsana.afroz at gmail.com
Wed Apr 6 01:37:08 CEST 2011

On Tue, Apr 5, 2011 at 11:28 AM, Michael Niedermayer <michaelni at gmx.at>wrote:

> This results in
> J2K_SIZ = 0xff51
> J2K_COD = 0xff52
> J2K_COC = 0xff53

Thanks Michael, I understood that, it was my mistake. While processing
0xff52 (J2K_SOD) marker, the current decoder fails in the following code

/** get common part for COD and COC segments */
static int get_cox(J2kDecoderContext *s, J2kCodingStyle *c)
    if (s->buf_end - s->buf < 5)
        return AVERROR(EINVAL);
          c->nreslevels = bytestream_get_byte(&s->buf) + 1; // num of
resolution levels - 1
     c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2; // cblk width
    c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; // cblk height

    c->cblk_style = bytestream_get_byte(&s->buf);
    if (c->cblk_style != 0){ // cblk style
        av_log(s->avctx, AV_LOG_ERROR, "no extra cblk styles supported\n");
        return -1;
    c->transform = bytestream_get_byte(&s->buf); // transformation
    if (c->csty & J2K_CSTY_PREC) {
        int i;
        for (i = 0; i < c->nreslevels; i++)
    return 0;

/** get coding parameters for a particular tile or whole image*/
static int get_cod(J2kDecoderContext *s, J2kCodingStyle *c, uint8_t
    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);

    tmp.log2_prec_width  =
    tmp.log2_prec_height = 15;

    tmp.csty = bytestream_get_byte(&s->buf);

    if (bytestream_get_byte(&s->buf)){ // progression level
        av_log(s->avctx, AV_LOG_ERROR, "only LRCP progression supported\n");
        return -1;

    tmp.nlayers = bytestream_get_be16(&s->buf);
        tmp.mct = bytestream_get_byte(&s->buf); // multiple component

    get_cox(s, &tmp);
    for (compno = 0; compno < s->ncomponents; compno++){
        if (!(properties[compno] & HAD_COC))
            memcpy(c + compno, &tmp, sizeof(J2kCodingStyle));
    return 0;

In the get_cox function, the decoder shows the error "no extra cblk style
supported". But, I am wondering, why this IF statement. The specification
(page-45) says, there could be one byte in this position

Code-block style 8 Table A-17 Style of the code-block coding passes (8 means
size of this field in bits, Table A-17 is for the meaning of this parameter)

I cannot print the entire table here.
if (c->cblk_style != 0){ // cblk style
        av_log(s->avctx, AV_LOG_ERROR, "no extra cblk styles supported\n");
        return -1;

However, if I comment this IF block, I can get rid of this problem. However,
I get errors while processing other subsequent markers

[j2k @ 0xab98210] unsupported marker 0xA17D at pos 0x145
[j2k @ 0xab98210] unsupported marker 0xEFC8 at pos 0xbfa
[j2k @ 0xab98210] Missing EOC
[j2k @ 0xab98210] Segmentation symbol value incorrect

These errors only occur while decoding the files in codestrem_profile0
folder, not other files in testfiles_jp2folder. I am also looking how these
markers have been processed.


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

More information about the ffmpeg-devel mailing list