[FFmpeg-devel] [PATCH] libopenjpeg wrapper for jpeg2k decoding

Michael Niedermayer michaelni
Wed Jan 28 23:57:55 CET 2009


On Wed, Jan 28, 2009 at 02:23:46PM +0530, Jai Menon wrote:
[...]
> +static int libopenjpeg_decode_frame(AVCodecContext *avctx,
> +                                    void *data, int *data_size,
> +                                    const uint8_t *buf, int buf_size)
> +{
> +    LibOpenJPEGContext *ctx = avctx->priv_data;
> +    AVPicture *picture = data;
> +    opj_dinfo_t *dec = NULL;
> +    opj_cio_t *stream = NULL;
> +    opj_image_t *image = NULL;
> +    int width, height, has_alpha = 0, ret = -1;
> +    int x, y, index;
> +    int picture_size;
> +    uint8_t *img_ptr;
> +    float scale;
> +
> +    *data_size = 0;
> +
> +    // Check if input is a raw jpeg2k codestream or in jp2 wrapping

> +    if((AV_RB32(buf) == 12) && (AV_RB32(buf + 4) == JP2_SIG_TYPE)
> +        && (AV_RB32(buf + 8) == JP2_SIG_VALUE))
> +        dec = opj_create_decompress(CODEC_JP2);
> +    else dec = opj_create_decompress(CODEC_J2K);

if{
}else
and this can be vertically aligned prettier


[...]
> +    width = image->comps[0].w;
> +    height = image->comps[0].h;

vertical align


[...]
> +    img_ptr = ctx->img_buf;
> +    picture->data[0] = ctx->img_buf;
> +    scale = 255.0f / (float)((1 << image->comps[0].prec) - 1);
> +    for(y = 0; y < height; y++) {
> +        index = y*width;
> +        for(x = 0; x < width; x++, index++) {
> +            *img_ptr++ = image->comps[0].data[index] * scale;

> +            if((image->numcomps > 2) && check_image_attributes(image)) {

superflous ()

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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090128/f3644439/attachment.pgp>



More information about the ffmpeg-devel mailing list