Lines Matching defs:jpeg
1 /* stbi-1.29 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c
9 JPEG baseline (no JPEG progressive)
31 minor perf improvements for jpeg
55 Sean Barrett (jpeg, png, bmp) Fabian "ryg" Giesen
86 // - no jpeg progressive support
87 // - non-HDR formats support 8-bit samples only (jpeg, png)
88 // - no delayed line count (jpeg) -- IJG doesn't support either
314 // is it a jpeg?
502 // is it a jpeg?
967 // individual types do this automatically as much as possible (e.g. jpeg
1083 // "baseline" JPEG/JFIF decoder (not actually fully baseline implementation)
1137 // definition of jpeg image component
1152 uint32 code_buffer; // jpeg entropy-coded buffer
1159 } jpeg;
1164 // build size list for each symbol (from JPEG spec)
1170 // compute actual symbols (from jpeg spec)
1179 if (code-1 >= (1 << j)) return e("bad code lengths","Corrupt JPEG");
1202 static void grow_buffer_unsafe(jpeg *j)
1222 // decode a jpeg huffman value from the bitstream
1223 __forceinline static int decode(jpeg *j, huffman *h)
1272 // combined JPEG 'receive' and JPEG 'extend', since baseline
1274 __forceinline static int extend_receive(jpeg *j, int n)
1317 static int decode_block(jpeg *j, short data[64], huffman *hdc, huffman *hac, int b)
1321 if (t < 0) return e("bad huffman code","Corrupt JPEG");
1331 // decode AC components, see JPEG spec
1336 if (rs < 0) return e("bad huffman code","Corrupt JPEG");
1484 static uint8 get_marker(jpeg *j)
1501 static void reset(jpeg *j)
1513 static int parse_entropy_coded_data(jpeg *z)
1585 static int process_marker(jpeg *z, int marker)
1590 return e("expected marker","Corrupt JPEG");
1593 return e("progressive jpeg","JPEG format not supported (progressive)");
1596 if (get16(&z->s) != 4) return e("bad DRI len","Corrupt JPEG");
1606 if (p != 0) return e("bad DQT type","Corrupt JPEG");
1607 if (t > 3) return e("bad DQT table","Corrupt JPEG");
1626 if (tc > 1 || th > 3) return e("bad DHT header","Corrupt JPEG");
1654 static int process_scan_header(jpeg *z)
1659 if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s.img_n) return e("bad SOS component count","Corrupt JPEG");
1660 if (Ls != 6+2*z->scan_n) return e("bad SOS len","Corrupt JPEG");
1668 z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return e("bad DC huff","Corrupt JPEG");
1669 z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return e("bad AC huff","Corrupt JPEG");
1672 if (get8(&z->s) != 0) return e("bad SOS","Corrupt JPEG");
1674 if (get8(&z->s) != 0) return e("bad SOS","Corrupt JPEG");
1679 static int process_frame_header(jpeg *z, int scan)
1683 Lf = get16(s); if (Lf < 11) return e("bad SOF len","Corrupt JPEG"); // JPEG
1684 p = get8(s); if (p != 8) return e("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline
1685 s->img_y = get16(s); if (s->img_y == 0) return e("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG
1686 s->img_x = get16(s); if (s->img_x == 0) return e("0 width","Corrupt JPEG"); // JPEG requires
1688 if (c != 3 && c != 1) return e("bad component count","Corrupt JPEG"); // JFIF requires
1695 if (Lf != 8+3*s->img_n) return e("bad SOF len","Corrupt JPEG");
1701 return e("bad component ID","Corrupt JPEG");
1703 z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return e("bad H","Corrupt JPEG");
1704 z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return e("bad V","Corrupt JPEG");
1705 z->img_comp[i].tq = get8(s); if (z->img_comp[i].tq > 3) return e("bad TQ","Corrupt JPEG");
1758 static int decode_jpeg_header(jpeg *z, int scan)
1763 if (!SOI(m)) return e("no SOI","Corrupt JPEG");
1771 if (at_eof(&z->s)) return e("no SOF", "Corrupt JPEG");
1779 static int decode_jpeg_image(jpeg *j)
1941 static void cleanup_jpeg(jpeg *j)
1966 static uint8 *load_jpeg_image(jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)
1973 // load a jpeg image from whichever source
2069 jpeg j;
2089 jpeg *j = MALLOC(sizeof(*j));
2095 jpeg j;
2101 static int stbi_jpeg_info_raw(jpeg *j, int *x, int *y, int *comp)
2115 jpeg j;
2125 jpeg j;
2147 jpeg *j;
2160 jpeg *j;
2184 // fast-way is faster to check than jpeg huffman, but slow way is slower
2237 if (code-1 >= (1 << i)) return e("bad codelengths","Corrupt JPEG");
2320 // use jpeg approach, which requires MSbits at top
5021 minor perf improvements for jpeg
5060 0.97 jpeg errors on too large a file; also catch another malloc failure
5078 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments