[FFmpeg-soc] [PATCH] jpeg2k : support higher sample precision
Jai Menon
jmenon86 at gmail.com
Wed Jun 24 15:42:08 CEST 2009
On Wed, Jun 24, 2009 at 1:27 PM, Michael Niedermayer<michaelni at gmx.at> wrote:
> On Sun, Jun 21, 2009 at 04:35:20PM +0000, Jai Menon wrote:
>> Hi,
>>
>> Attached patch fixes decoding of files where component precision > 8.
>>
>> Possible test files are :
>>
>> codestreams_profile1/p1_04.j2k
>> testfiles_jp2/file6.jp2
>> testfiles_jp2/file7.jp2
>>
>> Posting here for comments.
>>
>> --
>> Regards,
>>
>> Jai
>
>> j2kdec.c | 35 ++++++++++++++++++++++++++++++++---
>> 1 file changed, 32 insertions(+), 3 deletions(-)
>> 10381c8c4a6486b49b3013bc0683cb6d62f9161e high_precision.patch
>> Index: j2kdec.c
>> ===================================================================
>> --- j2kdec.c (revision 4434)
>> +++ j2kdec.c (working copy)
>> @@ -54,7 +54,7 @@
>> uint8_t cbps[4]; ///< bits per sample in particular components
>> uint8_t sgnd[4]; ///< if a component is signed
>> uint8_t properties[4];
>> -
>> + int precision;
>> int ncomponents;
>> int tile_width, tile_height; ///< tile size
>> int numXtiles, numYtiles;
>
>> @@ -225,6 +225,8 @@
>> for (i = 0; i < s->ncomponents; i++){ // Ssiz_i XRsiz_i, YRsiz_i
>> uint8_t x = bytestream_get_byte(&s->buf);
>> s->cbps[i] = (x & 0x7f) + 1;
>> + if (s->cbps[i] > s->precision)
>> + s->precision = s->cbps[i];
>> s->sgnd[i] = (x & 0x80) == 1;
>> if (bytestream_get_byte(&s->buf) != 1)
>> return -1;
>
> FFMAX
Changed locally.
> [...]
>> @@ -806,6 +815,26 @@
>>
>> line += s->picture.linesize[0];
>> }
>> + } else {
>> + for (; y < tile->comp[0].coord[1][1] - s->image_offset_y; y++) {
>> + uint16_t *dst;
>> + x = tile->comp[0].coord[0][0] - s->image_offset_x;
>> + dst = line + x * s->ncomponents * 2;
>> + for (; x < tile->comp[0].coord[0][1] - s->image_offset_x; x++) {
>> + for (compno = 0; compno < s->ncomponents; compno++) {
>
>> + *src[compno] = av_rescale(*src[compno], (1 << 16) - 1,
>> + (1 << s->cbps[compno]) - 1);
>
> av_rescale is too slow
So just (*src[compno]/((1 << s->cbps[compno]) - 1)) * ((1 << 16) - 1) ?
>
>> + *src[compno] += 1 << 15;
>> + if (*src[compno] < 0)
>> + *src[compno] = 0;
>> + else if (*src[compno] >= (1 << 16))
>> + *src[compno] = (1 << 16) - 1;
>> + *dst++ = *src[compno]++;
>
> av_clip()
Ah yes, fixed. I'll change it in the other case as well.
Thanks for the review.
--
Regards,
Jai
More information about the FFmpeg-soc
mailing list