Signed-off-by: James Almer <jamrial@gmail.com>
James Almer authored on 2014/08/20 05:04:01... | ... |
@@ -283,6 +283,34 @@ static int deinvert_buffer(TiffContext *s, const uint8_t *src, int size) |
283 | 283 |
return 0; |
284 | 284 |
} |
285 | 285 |
|
286 |
+static void unpack_yuv(TiffContext *s, AVFrame *p, |
|
287 |
+ const uint8_t *src, int lnum) |
|
288 |
+{ |
|
289 |
+ int i, j, k; |
|
290 |
+ int w = (s->width - 1) / s->subsampling[0] + 1; |
|
291 |
+ uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]]; |
|
292 |
+ uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]]; |
|
293 |
+ if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) { |
|
294 |
+ for (i = 0; i < w; i++) { |
|
295 |
+ for (j = 0; j < s->subsampling[1]; j++) |
|
296 |
+ for (k = 0; k < s->subsampling[0]; k++) |
|
297 |
+ p->data[0][FFMIN(lnum + j, s->height-1) * p->linesize[0] + |
|
298 |
+ FFMIN(i * s->subsampling[0] + k, s->width-1)] = *src++; |
|
299 |
+ *pu++ = *src++; |
|
300 |
+ *pv++ = *src++; |
|
301 |
+ } |
|
302 |
+ }else{ |
|
303 |
+ for (i = 0; i < w; i++) { |
|
304 |
+ for (j = 0; j < s->subsampling[1]; j++) |
|
305 |
+ for (k = 0; k < s->subsampling[0]; k++) |
|
306 |
+ p->data[0][(lnum + j) * p->linesize[0] + |
|
307 |
+ i * s->subsampling[0] + k] = *src++; |
|
308 |
+ *pu++ = *src++; |
|
309 |
+ *pv++ = *src++; |
|
310 |
+ } |
|
311 |
+ } |
|
312 |
+} |
|
313 |
+ |
|
286 | 314 |
#if CONFIG_ZLIB |
287 | 315 |
static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src, |
288 | 316 |
int size) |
... | ... |
@@ -383,35 +411,6 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride, |
383 | 383 |
return ret; |
384 | 384 |
} |
385 | 385 |
|
386 |
-static void unpack_yuv(TiffContext *s, AVFrame *p, |
|
387 |
- const uint8_t *src, int lnum) |
|
388 |
-{ |
|
389 |
- int i, j, k; |
|
390 |
- int w = (s->width - 1) / s->subsampling[0] + 1; |
|
391 |
- uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]]; |
|
392 |
- uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]]; |
|
393 |
- if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) { |
|
394 |
- for (i = 0; i < w; i++) { |
|
395 |
- for (j = 0; j < s->subsampling[1]; j++) |
|
396 |
- for (k = 0; k < s->subsampling[0]; k++) |
|
397 |
- p->data[0][FFMIN(lnum + j, s->height-1) * p->linesize[0] + |
|
398 |
- FFMIN(i * s->subsampling[0] + k, s->width-1)] = *src++; |
|
399 |
- *pu++ = *src++; |
|
400 |
- *pv++ = *src++; |
|
401 |
- } |
|
402 |
- }else{ |
|
403 |
- for (i = 0; i < w; i++) { |
|
404 |
- for (j = 0; j < s->subsampling[1]; j++) |
|
405 |
- for (k = 0; k < s->subsampling[0]; k++) |
|
406 |
- p->data[0][(lnum + j) * p->linesize[0] + |
|
407 |
- i * s->subsampling[0] + k] = *src++; |
|
408 |
- *pu++ = *src++; |
|
409 |
- *pv++ = *src++; |
|
410 |
- } |
|
411 |
- } |
|
412 |
-} |
|
413 |
- |
|
414 |
- |
|
415 | 386 |
static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int stride, |
416 | 387 |
const uint8_t *src, int size, int strip_start, int lines) |
417 | 388 |
{ |