OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 #ifndef MEDIA_FILTERS_JPEG_PARSER_H_ | 5 #ifndef MEDIA_FILTERS_JPEG_PARSER_H_ |
6 #define MEDIA_FILTERS_JPEG_PARSER_H_ | 6 #define MEDIA_FILTERS_JPEG_PARSER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 JPEG_SOF10 = 0xCA, // start of frame (arithmetic coding, progressive) | 23 JPEG_SOF10 = 0xCA, // start of frame (arithmetic coding, progressive) |
24 JPEG_SOF11 = 0xCB, // start of frame (arithmetic coding, lossless) | 24 JPEG_SOF11 = 0xCB, // start of frame (arithmetic coding, lossless) |
25 JPEG_SOF13 = 0xCD, // start of frame (differential, arithmetic, sequential) | 25 JPEG_SOF13 = 0xCD, // start of frame (differential, arithmetic, sequential) |
26 JPEG_SOF14 = 0xCE, // start of frame (differential, arithmetic, progressive) | 26 JPEG_SOF14 = 0xCE, // start of frame (differential, arithmetic, progressive) |
27 JPEG_SOF15 = 0xCF, // start of frame (differential, arithmetic, lossless) | 27 JPEG_SOF15 = 0xCF, // start of frame (differential, arithmetic, lossless) |
28 JPEG_DHT = 0xC4, // define huffman table | 28 JPEG_DHT = 0xC4, // define huffman table |
29 JPEG_SOI = 0xD8, // start of image | 29 JPEG_SOI = 0xD8, // start of image |
30 JPEG_SOS = 0xDA, // start of scan | 30 JPEG_SOS = 0xDA, // start of scan |
31 JPEG_DQT = 0xDB, // define quantization table | 31 JPEG_DQT = 0xDB, // define quantization table |
32 JPEG_DRI = 0xDD, // define restart internal | 32 JPEG_DRI = 0xDD, // define restart internal |
33 JPEG_RST0 = 0xD0, // Restart | |
kcwu
2015/08/14 09:01:38
s/R/r/
henryhsu
2015/08/14 11:22:27
Done.
| |
34 JPEG_RST1 = 0xD1, // Restart | |
35 JPEG_RST2 = 0xD2, // Restart | |
36 JPEG_RST3 = 0xD3, // Restart | |
37 JPEG_RST4 = 0xD4, // Restart | |
38 JPEG_RST5 = 0xD5, // Restart | |
39 JPEG_RST6 = 0xD6, // Restart | |
40 JPEG_RST7 = 0xD7, // Restart | |
41 JPEG_EOI = 0xD9, // end of image | |
33 JPEG_MARKER_PREFIX = 0xFF, // jpeg marker prefix | 42 JPEG_MARKER_PREFIX = 0xFF, // jpeg marker prefix |
34 }; | 43 }; |
35 | 44 |
36 const size_t kJpegMaxHuffmanTableNumBaseline = 2; | 45 const size_t kJpegMaxHuffmanTableNumBaseline = 2; |
37 const size_t kJpegMaxComponents = 4; | 46 const size_t kJpegMaxComponents = 4; |
38 const size_t kJpegMaxQuantizationTableNum = 4; | 47 const size_t kJpegMaxQuantizationTableNum = 4; |
39 | 48 |
40 // Parsing result of JPEG DHT marker. | 49 // Parsing result of JPEG DHT marker. |
41 struct JpegHuffmanTable { | 50 struct JpegHuffmanTable { |
42 bool valid; | 51 bool valid; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 | 89 |
81 struct JpegParseResult { | 90 struct JpegParseResult { |
82 JpegFrameHeader frame_header; | 91 JpegFrameHeader frame_header; |
83 JpegHuffmanTable dc_table[kJpegMaxHuffmanTableNumBaseline]; | 92 JpegHuffmanTable dc_table[kJpegMaxHuffmanTableNumBaseline]; |
84 JpegHuffmanTable ac_table[kJpegMaxHuffmanTableNumBaseline]; | 93 JpegHuffmanTable ac_table[kJpegMaxHuffmanTableNumBaseline]; |
85 JpegQuantizationTable q_table[kJpegMaxQuantizationTableNum]; | 94 JpegQuantizationTable q_table[kJpegMaxQuantizationTableNum]; |
86 uint16_t restart_interval; | 95 uint16_t restart_interval; |
87 JpegScanHeader scan; | 96 JpegScanHeader scan; |
88 const char* data; | 97 const char* data; |
89 size_t data_size; | 98 size_t data_size; |
99 size_t image_size; | |
kcwu
2015/08/14 09:01:37
add comment to explain data_size and image_size. T
kcwu
2015/08/14 09:01:38
Please exam this new value in the unit test.
henryhsu
2015/08/14 11:22:27
Done.
henryhsu
2015/08/14 11:22:27
Done.
| |
90 }; | 100 }; |
91 | 101 |
92 // Parses JPEG picture in |buffer| with |length|. Returns true iff header is | 102 // Parses JPEG picture in |buffer| with |length|. Returns true iff header is |
93 // valid and JPEG baseline sequential process is present. If parsed | 103 // valid and JPEG baseline sequential process is present. If parsed |
94 // successfully, |result| is the parsed result. | 104 // successfully, |result| is the parsed result. |
95 // It's not a full featured JPEG parser implememtation. It only parses JPEG | 105 // It's not a full featured JPEG parser implememtation. It only parses JPEG |
96 // baseline sequential process. For explanations of each struct and its | 106 // baseline sequential process. For explanations of each struct and its |
97 // members, see JPEG specification at | 107 // members, see JPEG specification at |
98 // http://www.w3.org/Graphics/JPEG/itu-t81.pdf. | 108 // http://www.w3.org/Graphics/JPEG/itu-t81.pdf. |
99 MEDIA_EXPORT bool ParseJpegPicture(const uint8_t* buffer, | 109 MEDIA_EXPORT bool ParseJpegPicture(const uint8_t* buffer, |
100 size_t length, | 110 size_t length, |
101 JpegParseResult* result); | 111 JpegParseResult* result); |
102 | 112 |
103 } // namespace media | 113 } // namespace media |
104 | 114 |
105 #endif // MEDIA_FILTERS_JPEG_PARSER_H_ | 115 #endif // MEDIA_FILTERS_JPEG_PARSER_H_ |
OLD | NEW |