diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-06-14 02:28:35 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-06-14 02:28:35 +0000 |
commit | 021deacadeae467dff01bd95e144d55e6644a80f (patch) | |
tree | 55b83be46bb8dfdf9a0e5fe6826327e28f653644 /apps/recorder/jpeg_load.c | |
parent | e40075e5b74c69f7a5358e65d3b997dcd2649cfc (diff) | |
download | rockbox-021deacadeae467dff01bd95e144d55e6644a80f.tar.gz rockbox-021deacadeae467dff01bd95e144d55e6644a80f.zip |
Remove explicit counter for rows/columns in IDCT, instead testing against a pointer calculated in store_row_jpeg.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21284 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/jpeg_load.c')
-rw-r--r-- | apps/recorder/jpeg_load.c | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c index c4de7c2004..dc8bb33862 100644 --- a/apps/recorder/jpeg_load.c +++ b/apps/recorder/jpeg_load.c | |||
@@ -259,36 +259,31 @@ INLINE unsigned range_limit(int value) | |||
259 | */ | 259 | */ |
260 | 260 | ||
261 | /* horizontal-pass 1-point IDCT */ | 261 | /* horizontal-pass 1-point IDCT */ |
262 | static void idct1h(int16_t *ws, unsigned char *out, int rows, int rowstep) | 262 | static void idct1h(int16_t *ws, unsigned char *out, int16_t *end, int rowstep) |
263 | { | 263 | { |
264 | int row; | 264 | for (; ws < end; ws += 8) |
265 | for (row = 0; row < rows; row++) | ||
266 | { | 265 | { |
267 | *out = range_limit(128 + (int) DESCALE(*ws, 3 + PASS1_BITS)); | 266 | *out = range_limit(128 + (int) DESCALE(*ws, 3 + PASS1_BITS)); |
268 | out += rowstep; | 267 | out += rowstep; |
269 | ws += 8; | ||
270 | } | 268 | } |
271 | } | 269 | } |
272 | 270 | ||
273 | /* vertical-pass 2-point IDCT */ | 271 | /* vertical-pass 2-point IDCT */ |
274 | static void idct2v(int16_t *ws, int cols) | 272 | static void idct2v(int16_t *ws, int16_t *end) |
275 | { | 273 | { |
276 | int col; | 274 | for (; ws < end; ws++) |
277 | for (col = 0; col < cols; col++) | ||
278 | { | 275 | { |
279 | int tmp1 = ws[0]; | 276 | int tmp1 = ws[0]; |
280 | int tmp2 = ws[8]; | 277 | int tmp2 = ws[8]; |
281 | ws[0] = tmp1 + tmp2; | 278 | ws[0] = tmp1 + tmp2; |
282 | ws[8] = tmp1 - tmp2; | 279 | ws[8] = tmp1 - tmp2; |
283 | ws++; | ||
284 | } | 280 | } |
285 | } | 281 | } |
286 | 282 | ||
287 | /* horizontal-pass 2-point IDCT */ | 283 | /* horizontal-pass 2-point IDCT */ |
288 | static void idct2h(int16_t *ws, unsigned char *out, int rows, int rowstep) | 284 | static void idct2h(int16_t *ws, unsigned char *out, int16_t *end, int rowstep) |
289 | { | 285 | { |
290 | int row; | 286 | for (; ws < end; ws += 8, out += rowstep) |
291 | for (row = 0; row < rows; row++) | ||
292 | { | 287 | { |
293 | int tmp1 = ws[0] + (ONE << (PASS1_BITS + 2)) | 288 | int tmp1 = ws[0] + (ONE << (PASS1_BITS + 2)) |
294 | + (128 << (PASS1_BITS + 3)); | 289 | + (128 << (PASS1_BITS + 3)); |
@@ -297,16 +292,13 @@ static void idct2h(int16_t *ws, unsigned char *out, int rows, int rowstep) | |||
297 | PASS1_BITS + 3)); | 292 | PASS1_BITS + 3)); |
298 | out[JPEG_PIX_SZ*1] = range_limit((int) RIGHT_SHIFT(tmp1 - tmp2, | 293 | out[JPEG_PIX_SZ*1] = range_limit((int) RIGHT_SHIFT(tmp1 - tmp2, |
299 | PASS1_BITS + 3)); | 294 | PASS1_BITS + 3)); |
300 | out += rowstep; | ||
301 | ws += 8; | ||
302 | } | 295 | } |
303 | } | 296 | } |
304 | 297 | ||
305 | /* vertical-pass 4-point IDCT */ | 298 | /* vertical-pass 4-point IDCT */ |
306 | static void idct4v(int16_t *ws, int cols) | 299 | static void idct4v(int16_t *ws, int16_t *end) |
307 | { | 300 | { |
308 | int col; | 301 | for (; ws < end; ws++) |
309 | for (col = 0; col < cols; col++, ws++) | ||
310 | { | 302 | { |
311 | #if defined(CPU_ARM) | 303 | #if defined(CPU_ARM) |
312 | int t0, t1, t2, t3, t4; | 304 | int t0, t1, t2, t3, t4; |
@@ -400,10 +392,9 @@ static void idct4v(int16_t *ws, int cols) | |||
400 | } | 392 | } |
401 | 393 | ||
402 | /* horizontal-pass 4-point IDCT */ | 394 | /* horizontal-pass 4-point IDCT */ |
403 | static void idct4h(int16_t *ws, unsigned char *out, int rows, int rowstep) | 395 | static void idct4h(int16_t *ws, unsigned char *out, int16_t *end, int rowstep) |
404 | { | 396 | { |
405 | int row; | 397 | for (; ws < end; out += rowstep, ws += 8) |
406 | for (row = 0; row < rows; row++, out += rowstep, ws += 8) | ||
407 | { | 398 | { |
408 | #if defined(CPU_ARM) | 399 | #if defined(CPU_ARM) |
409 | int t0, t1, t2, t3, t4; | 400 | int t0, t1, t2, t3, t4; |
@@ -514,13 +505,12 @@ static void idct4h(int16_t *ws, unsigned char *out, int rows, int rowstep) | |||
514 | } | 505 | } |
515 | 506 | ||
516 | /* vertical-pass 8-point IDCT */ | 507 | /* vertical-pass 8-point IDCT */ |
517 | static void idct8v(int16_t *ws, int cols) | 508 | static void idct8v(int16_t *ws, int16_t *end) |
518 | { | 509 | { |
519 | long tmp0, tmp1, tmp2, tmp3; | 510 | long tmp0, tmp1, tmp2, tmp3; |
520 | long tmp10, tmp11, tmp12, tmp13; | 511 | long tmp10, tmp11, tmp12, tmp13; |
521 | long z1, z2, z3, z4, z5; | 512 | long z1, z2, z3, z4, z5; |
522 | int col; | 513 | for (; ws < end; ws++) |
523 | for (col = 0; col < cols; col++, ws++) | ||
524 | { | 514 | { |
525 | /* Due to quantization, we will usually find that many of the input | 515 | /* Due to quantization, we will usually find that many of the input |
526 | * coefficients are zero, especially the AC terms. We can exploit this | 516 | * coefficients are zero, especially the AC terms. We can exploit this |
@@ -608,13 +598,12 @@ static void idct8v(int16_t *ws, int cols) | |||
608 | } | 598 | } |
609 | 599 | ||
610 | /* horizontal-pass 8-point IDCT */ | 600 | /* horizontal-pass 8-point IDCT */ |
611 | static void idct8h(int16_t *ws, unsigned char *out, int rows, int rowstep) | 601 | static void idct8h(int16_t *ws, unsigned char *out, int16_t *end, int rowstep) |
612 | { | 602 | { |
613 | long tmp0, tmp1, tmp2, tmp3; | 603 | long tmp0, tmp1, tmp2, tmp3; |
614 | long tmp10, tmp11, tmp12, tmp13; | 604 | long tmp10, tmp11, tmp12, tmp13; |
615 | long z1, z2, z3, z4, z5; | 605 | long z1, z2, z3, z4, z5; |
616 | int row; | 606 | for (; ws < end; out += rowstep, ws += 8) |
617 | for (row = 0; row < rows; row++, out += rowstep, ws += 8) | ||
618 | { | 607 | { |
619 | /* Rows of zeroes can be exploited in the same way as we did with | 608 | /* Rows of zeroes can be exploited in the same way as we did with |
620 | * columns. However, the column calculation has created many nonzero AC | 609 | * columns. However, the column calculation has created many nonzero AC |
@@ -720,13 +709,12 @@ static void idct8h(int16_t *ws, unsigned char *out, int rows, int rowstep) | |||
720 | 709 | ||
721 | #ifdef HAVE_LCD_COLOR | 710 | #ifdef HAVE_LCD_COLOR |
722 | /* vertical-pass 16-point IDCT */ | 711 | /* vertical-pass 16-point IDCT */ |
723 | static void idct16v(int16_t *ws, int cols) | 712 | static void idct16v(int16_t *ws, int16_t *end) |
724 | { | 713 | { |
725 | long tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; | 714 | long tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; |
726 | long tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; | 715 | long tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; |
727 | long z1, z2, z3, z4; | 716 | long z1, z2, z3, z4; |
728 | int col; | 717 | for (; ws < end; ws++) |
729 | for (col = 0; col < cols; col++, ws++) | ||
730 | { | 718 | { |
731 | /* Even part */ | 719 | /* Even part */ |
732 | 720 | ||
@@ -827,13 +815,12 @@ static void idct16v(int16_t *ws, int cols) | |||
827 | } | 815 | } |
828 | 816 | ||
829 | /* horizontal-pass 16-point IDCT */ | 817 | /* horizontal-pass 16-point IDCT */ |
830 | static void idct16h(int16_t *ws, unsigned char *out, int rows, int rowstep) | 818 | static void idct16h(int16_t *ws, unsigned char *out, int16_t *end, int rowstep) |
831 | { | 819 | { |
832 | long tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; | 820 | long tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; |
833 | long tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; | 821 | long tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; |
834 | long z1, z2, z3, z4; | 822 | long z1, z2, z3, z4; |
835 | int row; | 823 | for (; ws < end; out += rowstep, ws += 8) |
836 | for (row = 0; row < rows; row++, out += rowstep, ws += 8) | ||
837 | { | 824 | { |
838 | /* Even part */ | 825 | /* Even part */ |
839 | 826 | ||
@@ -954,8 +941,8 @@ static void idct16h(int16_t *ws, unsigned char *out, int rows, int rowstep) | |||
954 | 941 | ||
955 | struct idct_entry { | 942 | struct idct_entry { |
956 | int scale; | 943 | int scale; |
957 | void (*v_idct)(int16_t *ws, int cols); | 944 | void (*v_idct)(int16_t *ws, int16_t *end); |
958 | void (*h_idct)(int16_t *ws, unsigned char *out, int rows, int rowstep); | 945 | void (*h_idct)(int16_t *ws, unsigned char *out, int16_t *end, int rowstep); |
959 | }; | 946 | }; |
960 | 947 | ||
961 | struct idct_entry idct_tbl[] = { | 948 | struct idct_entry idct_tbl[] = { |
@@ -2002,9 +1989,9 @@ block_end: | |||
2002 | unsigned char *b_out = out + (ci ? ci : store_offs[blkn]); | 1989 | unsigned char *b_out = out + (ci ? ci : store_offs[blkn]); |
2003 | if (idct_tbl[p_jpeg->v_scale[!!ci]].v_idct) | 1990 | if (idct_tbl[p_jpeg->v_scale[!!ci]].v_idct) |
2004 | idct_tbl[p_jpeg->v_scale[!!ci]].v_idct(block, | 1991 | idct_tbl[p_jpeg->v_scale[!!ci]].v_idct(block, |
2005 | idct_cols); | 1992 | block + idct_cols); |
2006 | idct_tbl[p_jpeg->h_scale[!!ci]].h_idct(block, b_out, | 1993 | idct_tbl[p_jpeg->h_scale[!!ci]].h_idct(block, b_out, |
2007 | idct_rows, b_width); | 1994 | block + idct_rows * 8, b_width); |
2008 | } | 1995 | } |
2009 | } /* for blkn */ | 1996 | } /* for blkn */ |
2010 | /* don't starve other threads while an MCU row decodes */ | 1997 | /* don't starve other threads while an MCU row decodes */ |