Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: media/filters/jpeg_parser.h

Issue 1291933002: File video capture device supports MJPEG format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address wucheng@ Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
xhwang 2015/08/18 17:17:55 Can we order these by value?
henryhsu 2015/08/19 10:05:12 Done.
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } components[kJpegMaxComponents]; 87 } components[kJpegMaxComponents];
79 }; 88 };
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;
xhwang 2015/08/18 17:17:55 Is this for the whole compressed data?
henryhsu 2015/08/19 01:57:24 Yes. But only for one image.
98 // The size of compressed data.
89 size_t data_size; 99 size_t data_size;
100 // The size of entire image including header.
101 size_t image_size;
90 }; 102 };
91 103
92 // Parses JPEG picture in |buffer| with |length|. Returns true iff header is 104 // Parses JPEG picture in |buffer| with |length|. Returns true iff header is
93 // valid and JPEG baseline sequential process is present. If parsed 105 // valid and JPEG baseline sequential process is present. If parsed
94 // successfully, |result| is the parsed result. 106 // successfully, |result| is the parsed result.
95 // It's not a full featured JPEG parser implememtation. It only parses JPEG 107 // It's not a full featured JPEG parser implememtation. It only parses JPEG
96 // baseline sequential process. For explanations of each struct and its 108 // baseline sequential process. For explanations of each struct and its
97 // members, see JPEG specification at 109 // members, see JPEG specification at
98 // http://www.w3.org/Graphics/JPEG/itu-t81.pdf. 110 // http://www.w3.org/Graphics/JPEG/itu-t81.pdf.
99 MEDIA_EXPORT bool ParseJpegPicture(const uint8_t* buffer, 111 MEDIA_EXPORT bool ParseJpegPicture(const uint8_t* buffer,
100 size_t length, 112 size_t length,
101 JpegParseResult* result); 113 JpegParseResult* result);
102 114
103 } // namespace media 115 } // namespace media
104 116
105 #endif // MEDIA_FILTERS_JPEG_PARSER_H_ 117 #endif // MEDIA_FILTERS_JPEG_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698