diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-06 04:53:56 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-06 04:53:56 +0000 |
commit | eef7945a970e4da69b95c638a44a8ee1a9205430 (patch) | |
tree | ec015938370aaa6e84d3652f914c1766a963582d /apps/recorder/jpeg_common.h | |
parent | f779160de53686e45f57fad882a6d8f8db6360fd (diff) | |
download | rockbox-eef7945a970e4da69b95c638a44a8ee1a9205430.tar.gz rockbox-eef7945a970e4da69b95c638a44a8ee1a9205430.zip |
Move YUV->RGB in JPEG load from before scaler to after scaler. Required change to struct custom_format, so sorted the plugin API as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20856 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/jpeg_common.h')
-rw-r--r-- | apps/recorder/jpeg_common.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/apps/recorder/jpeg_common.h b/apps/recorder/jpeg_common.h index 44bf81e435..061cfc8e64 100644 --- a/apps/recorder/jpeg_common.h +++ b/apps/recorder/jpeg_common.h | |||
@@ -28,6 +28,8 @@ | |||
28 | #ifndef _JPEG_COMMON_H | 28 | #ifndef _JPEG_COMMON_H |
29 | #define _JPEG_COMMON_H | 29 | #define _JPEG_COMMON_H |
30 | 30 | ||
31 | #include "bmp.h" | ||
32 | |||
31 | #define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ | 33 | #define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ |
32 | #define JPEG_READ_BUF_SIZE 16 | 34 | #define JPEG_READ_BUF_SIZE 16 |
33 | struct derived_tbl | 35 | struct derived_tbl |
@@ -51,6 +53,55 @@ struct derived_tbl | |||
51 | 53 | ||
52 | #define QUANT_TABLE_LENGTH 64 | 54 | #define QUANT_TABLE_LENGTH 64 |
53 | 55 | ||
56 | /* | ||
57 | * Conversion of full 0-255 range YCrCb to RGB: | ||
58 | * |R| |1.000000 -0.000001 1.402000| |Y'| | ||
59 | * |G| = |1.000000 -0.334136 -0.714136| |Pb| | ||
60 | * |B| |1.000000 1.772000 0.000000| |Pr| | ||
61 | * Scaled (yields s15-bit output): | ||
62 | * |R| |128 0 179| |Y | | ||
63 | * |G| = |128 -43 -91| |Cb - 128| | ||
64 | * |B| |128 227 0| |Cr - 128| | ||
65 | */ | ||
66 | #define YFAC 128 | ||
67 | #define RVFAC 179 | ||
68 | #define GUFAC (-43) | ||
69 | #define GVFAC (-91) | ||
70 | #define BUFAC 227 | ||
71 | #define COMPONENT_SHIFT 15 | ||
72 | |||
73 | struct uint8_yuv { | ||
74 | uint8_t y; | ||
75 | uint8_t u; | ||
76 | uint8_t v; | ||
77 | }; | ||
78 | |||
79 | union uint8_rgbyuv { | ||
80 | struct uint8_yuv yuv; | ||
81 | struct uint8_rgb rgb; | ||
82 | }; | ||
83 | |||
84 | static inline int clamp_component(int x) | ||
85 | { | ||
86 | if ((unsigned)x > 255) | ||
87 | x = x < 0 ? 0 : 255; | ||
88 | return x; | ||
89 | } | ||
90 | #include <debug.h> | ||
91 | static inline void yuv_to_rgb(int y, int u, int v, unsigned *r, unsigned *g, unsigned *b) | ||
92 | { | ||
93 | int rv, guv, bu; | ||
94 | y = y * YFAC + (YFAC >> 1); | ||
95 | u = u - 128; | ||
96 | v = v - 128; | ||
97 | rv = RVFAC * v; | ||
98 | guv = GUFAC * u + GVFAC * v; | ||
99 | bu = BUFAC * u; | ||
100 | *r = clamp_component((y + rv) / YFAC); | ||
101 | *g = clamp_component((y + guv) / YFAC); | ||
102 | *b = clamp_component((y + bu) / YFAC); | ||
103 | } | ||
104 | |||
54 | /* for type of Huffman table */ | 105 | /* for type of Huffman table */ |
55 | #define DC_LEN 28 | 106 | #define DC_LEN 28 |
56 | #define AC_LEN 178 | 107 | #define AC_LEN 178 |