[FFmpeg-soc] [PATCH] jpeg2k : support higher sample precision
Michael Niedermayer
michaelni at gmx.at
Wed Jun 24 15:27:20 CEST 2009
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
[...]
> @@ -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
> + *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()
> + }
> + }
> + line += s->picture.linesize[0];
> + }
> + }
> return 0;
> }
>
> _______________________________________________
> FFmpeg-soc mailing list
> FFmpeg-soc at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc
--
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-soc/attachments/20090624/35345930/attachment.pgp>
More information about the FFmpeg-soc
mailing list