summaryrefslogtreecommitdiff
path: root/apps/recorder/jpeg_load.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/jpeg_load.c')
-rw-r--r--apps/recorder/jpeg_load.c32
1 files changed, 3 insertions, 29 deletions
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c
index 8b2c3f2fef..14aa024fcf 100644
--- a/apps/recorder/jpeg_load.c
+++ b/apps/recorder/jpeg_load.c
@@ -153,13 +153,6 @@ INLINE unsigned range_limit(int value)
153#endif 153#endif
154} 154}
155 155
156static inline int clamp_component(int x)
157{
158 if ((unsigned)x > 255)
159 x = x < 0 ? 0 : 255;
160 return x;
161}
162
163/* IDCT implementation */ 156/* IDCT implementation */
164 157
165 158
@@ -1810,27 +1803,8 @@ static struct img_part *store_row_jpeg(void *jpeg_args)
1810 unsigned int xp; 1803 unsigned int xp;
1811 int yp; 1804 int yp;
1812 unsigned char *row = out; 1805 unsigned char *row = out;
1813 if (p_jpeg->blocks > 1) { 1806 if (p_jpeg->blocks == 1)
1814 for (yp = 0; yp < height; yp++, row += b_width) 1807 {
1815 {
1816 unsigned char *px = row;
1817 for (xp = 0; xp < 1U << p_jpeg->h_scale[1];
1818 xp++, px += JPEG_PIX_SZ)
1819 {
1820 int y, u, v, rv, guv, bu;
1821 y = px[0] * YFAC + (YFAC >> 1);
1822 u = px[1] - 128;
1823 v = px[2] - 128;
1824 rv = RVFAC * v;
1825 guv = GUFAC * u + GVFAC * v;
1826 bu = BUFAC * u;
1827 struct uint8_rgb *rgb = (struct uint8_rgb *)px;
1828 rgb->red = clamp_component((y + rv) / YFAC);
1829 rgb->green = clamp_component((y + guv) / YFAC);
1830 rgb->blue = clamp_component((y + bu) / YFAC);
1831 }
1832 }
1833 } else {
1834 for (yp = 0; yp < height; yp++, row += b_width) 1808 for (yp = 0; yp < height; yp++, row += b_width)
1835 { 1809 {
1836 unsigned char *px = row; 1810 unsigned char *px = row;
@@ -2003,7 +1977,7 @@ int read_jpeg_fd(int fd,
2003 rset.rowstop = bm->height; 1977 rset.rowstop = bm->height;
2004 rset.rowstep = 1; 1978 rset.rowstep = 1;
2005 if (resize_on_load(bm, dither, &src_dim, &rset, buf_start, maxsize, cformat, 1979 if (resize_on_load(bm, dither, &src_dim, &rset, buf_start, maxsize, cformat,
2006 store_row_jpeg, p_jpeg)) 1980 IF_PIX_FMT(p_jpeg->blocks == 1 ? 0 : 1,) store_row_jpeg, p_jpeg))
2007 return bm_size; 1981 return bm_size;
2008 else 1982 else
2009 return 0; 1983 return 0;