Re: [FFmpeg-devel] [PATCH] lavf/tiff: add support for YUV deflate

2014-08-19 Thread Michael Niedermayer
On Tue, Aug 19, 2014 at 01:54:58AM -0300, James Almer wrote:
 Signed-off-by: James Almer jamr...@gmail.com
 ---
 Seems to work great with yuv deflate tiff images created with our tiff encoder
 
  libavcodec/tiff.c | 71 
 +++
  1 file changed, 35 insertions(+), 36 deletions(-)
 
 diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
 index 73bf828..7acfe7b 100644
 --- a/libavcodec/tiff.c
 +++ b/libavcodec/tiff.c
 @@ -283,6 +283,34 @@ static int deinvert_buffer(TiffContext *s, const uint8_t 
 *src, int size)
  return 0;
  }
  
 +static void unpack_yuv(TiffContext *s, AVFrame *p,
 +   const uint8_t *src, int lnum)
 +{
 +int i, j, k;
 +int w   = (s-width - 1) / s-subsampling[0] + 1;
 +uint8_t *pu = p-data[1][lnum / s-subsampling[1] * p-linesize[1]];
 +uint8_t *pv = p-data[2][lnum / s-subsampling[1] * p-linesize[2]];
 +if (s-width % s-subsampling[0] || s-height % s-subsampling[1]) {
 +for (i = 0; i  w; i++) {
 +for (j = 0; j  s-subsampling[1]; j++)
 +for (k = 0; k  s-subsampling[0]; k++)
 +p-data[0][FFMIN(lnum + j, s-height-1) * p-linesize[0] 
 +
 +   FFMIN(i * s-subsampling[0] + k, s-width-1)] 
 = *src++;
 +*pu++ = *src++;
 +*pv++ = *src++;
 +}
 +}else{
 +for (i = 0; i  w; i++) {
 +for (j = 0; j  s-subsampling[1]; j++)
 +for (k = 0; k  s-subsampling[0]; k++)
 +p-data[0][(lnum + j) * p-linesize[0] +
 +   i * s-subsampling[0] + k] = *src++;
 +*pu++ = *src++;
 +*pv++ = *src++;
 +}
 +}
 +}
 +
  #if CONFIG_ZLIB
  static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t 
 *src,
 int size)
 @@ -305,9 +333,9 @@ static int tiff_uncompress(uint8_t *dst, unsigned long 
 *len, const uint8_t *src,
  return zret == Z_STREAM_END ? Z_OK : zret;
  }
  
 -static int tiff_unpack_zlib(TiffContext *s, uint8_t *dst, int stride,
 +static int tiff_unpack_zlib(TiffContext *s, AVFrame *p, uint8_t *dst, int 
 stride,
  const uint8_t *src, int size,
 -int width, int lines)
 +int width, int lines, int strip_start)
  {
  uint8_t *zbuf;
  unsigned long outlen;
 @@ -338,6 +366,10 @@ static int tiff_unpack_zlib(TiffContext *s, uint8_t 
 *dst, int stride,
  } else {
  memcpy(dst, src, width);
  }
 +if (s-photometric == TIFF_PHOTOMETRIC_YCBCR) {
 +unpack_yuv(s, p, dst, strip_start + line);
 +line += s-subsampling[1] - 1;
 +}

is photometric guranteed to match the pix_fmt ?

iam asking as i dont see that being ensured by the code but i might
be missing something
if they could mismatch, id assume it might crash

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

The real ebay dictionary, page 2
100% positive feedback - All either got their money back or didnt complain
Best seller ever, very honest - Seller refunded buyer after failed scam


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/tiff: add support for YUV deflate

2014-08-19 Thread Carl Eugen Hoyos
James Almer jamrial at gmail.com writes:

 +static void unpack_yuv(TiffContext *s, AVFrame *p,
 +   const uint8_t *src, int lnum)

 -static void unpack_yuv(TiffContext *s, AVFrame *p,
 -   const uint8_t *src, int lnum)

If you want you could split the moving of the function 
in a new patch to make the functional change smaller.

Carl Eugen

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/tiff: add support for YUV deflate

2014-08-19 Thread James Almer
On 19/08/14 7:07 AM, Michael Niedermayer wrote:
 is photometric guranteed to match the pix_fmt ?

 iam asking as i dont see that being ensured by the code but i might
 be missing something
 if they could mismatch, id assume it might crash

TIFF_PHOTOMETRIC_YCBCR seems to simply be a flag to signal yuv data. If it's 
set, 
init_image() chooses the pix_fmt by looking at some other values in the file.
I copied the exact same check used in other compression algorithms (lzw, 
packbits, 
even raw) to know if it's yuv or rgb, and process it if the former. So if there 
hasn't been any kind of mismatch in those, it shouldn't in this one either.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel