[FFmpeg-devel] [PATCH] libopenjpeg wrapper for jpeg2k decoding
Jai Menon
jmenon86
Tue Feb 3 07:01:23 CET 2009
Hi,
On Tue, Feb 3, 2009 at 12:58 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Mon, Feb 02, 2009 at 04:48:17PM +0530, Jai Menon wrote:
>> Hi,
>>
>> 2009/1/29 Michael Niedermayer <michaelni at gmx.at>:
>> > On Thu, Jan 29, 2009 at 11:35:31AM +0530, Jai Menon wrote:
>> >> Hi,
>> >>
>> >> On Thu, Jan 29, 2009 at 4:27 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
>> >> > On Wed, Jan 28, 2009 at 02:23:46PM +0530, Jai Menon wrote:
>>
>> [...]
>>
>> > dec is written to twice with no read in between, this applies to more vars
>>
>> fixed.
>>
>> [...]
>>
>> > sec hole when width/height changes
>>
>> fixed (i think).
>>
>> i also reworked most of the code to use get/release_buffer
>> revised patch attached.
> [...]
>> +static int libopenjpeg_decode_frame(AVCodecContext *avctx,
>> + void *data, int *data_size,
>> + const uint8_t *buf, int buf_size)
>> +{
>> + LibOpenJPEGContext *ctx = avctx->priv_data;
>> + AVFrame *picture = &ctx->image, *output = data;
>> + opj_dinfo_t *dec;
>
>> + opj_cio_t *stream = NULL;
>
> written twice before read
this and another one fixed.
>> + opj_image_t *image = NULL;
>> + int width, height, has_alpha = 0, ret = -1;
>> + int x, y, index;
>> + 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);
>
> diego likely wont like this kind of } placement style
changed.
> [...]
>> + scale = 255.0f / (float)((1 << image->comps[0].prec) - 1);
>> + for(y = 0; y < height; y++) {
>> + index = y*width;
>> + img_ptr = picture->data[0] + y*picture->linesize[0];
>> + for(x = 0; x < width; x++, index++) {
>> + *img_ptr++ = image->comps[0].data[index] * scale;
>> + if(image->numcomps > 2 && check_image_attributes(image)) {
>> + *img_ptr++ = image->comps[1].data[index] * scale;
>> + *img_ptr++ = image->comps[2].data[index] * scale;
>> + if(has_alpha)
>> + *img_ptr++ = image->comps[3].data[index] * scale;
>> + }
>> + }
>> + }
>
> lrintf()
hmm...i made this generic and modified it to use integer arithmetic. i
think its better.
revised patch attached.
[...]
--
Regards,
Jai
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libopenjpeg_wrapper.patch
Type: text/x-patch
Size: 12143 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090203/b45ef9f2/attachment.bin>
More information about the ffmpeg-devel
mailing list