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

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: fix windows compile error 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
« no previous file with comments | « media/capture/video/file_video_capture_device_factory.cc ('k') | media/filters/jpeg_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 11
12 namespace media { 12 namespace media {
13 13
14 // It's not a full featured JPEG parser implememtation. It only parses JPEG
15 // baseline sequential process. For explanations of each struct and its
16 // members, see JPEG specification at
17 // http://www.w3.org/Graphics/JPEG/itu-t81.pdf.
18
14 enum JpegMarker { 19 enum JpegMarker {
15 JPEG_SOF0 = 0xC0, // start of frame (baseline) 20 JPEG_SOF0 = 0xC0, // start of frame (baseline)
16 JPEG_SOF1 = 0xC1, // start of frame (extended sequential) 21 JPEG_SOF1 = 0xC1, // start of frame (extended sequential)
17 JPEG_SOF2 = 0xC2, // start of frame (progressive) 22 JPEG_SOF2 = 0xC2, // start of frame (progressive)
18 JPEG_SOF3 = 0xC3, // start of frame (lossless)) 23 JPEG_SOF3 = 0xC3, // start of frame (lossless))
24 JPEG_DHT = 0xC4, // define huffman table
19 JPEG_SOF5 = 0xC5, // start of frame (differential, sequential) 25 JPEG_SOF5 = 0xC5, // start of frame (differential, sequential)
20 JPEG_SOF6 = 0xC6, // start of frame (differential, progressive) 26 JPEG_SOF6 = 0xC6, // start of frame (differential, progressive)
21 JPEG_SOF7 = 0xC7, // start of frame (differential, lossless) 27 JPEG_SOF7 = 0xC7, // start of frame (differential, lossless)
22 JPEG_SOF9 = 0xC9, // start of frame (arithmetic coding, extended) 28 JPEG_SOF9 = 0xC9, // start of frame (arithmetic coding, extended)
23 JPEG_SOF10 = 0xCA, // start of frame (arithmetic coding, progressive) 29 JPEG_SOF10 = 0xCA, // start of frame (arithmetic coding, progressive)
24 JPEG_SOF11 = 0xCB, // start of frame (arithmetic coding, lossless) 30 JPEG_SOF11 = 0xCB, // start of frame (arithmetic coding, lossless)
25 JPEG_SOF13 = 0xCD, // start of frame (differential, arithmetic, sequential) 31 JPEG_SOF13 = 0xCD, // start of frame (differential, arithmetic, sequential)
26 JPEG_SOF14 = 0xCE, // start of frame (differential, arithmetic, progressive) 32 JPEG_SOF14 = 0xCE, // start of frame (differential, arithmetic, progressive)
27 JPEG_SOF15 = 0xCF, // start of frame (differential, arithmetic, lossless) 33 JPEG_SOF15 = 0xCF, // start of frame (differential, arithmetic, lossless)
28 JPEG_DHT = 0xC4, // define huffman table 34 JPEG_RST0 = 0xD0, // restart
35 JPEG_RST1 = 0xD1, // restart
36 JPEG_RST2 = 0xD2, // restart
37 JPEG_RST3 = 0xD3, // restart
38 JPEG_RST4 = 0xD4, // restart
39 JPEG_RST5 = 0xD5, // restart
40 JPEG_RST6 = 0xD6, // restart
41 JPEG_RST7 = 0xD7, // restart
29 JPEG_SOI = 0xD8, // start of image 42 JPEG_SOI = 0xD8, // start of image
43 JPEG_EOI = 0xD9, // end of image
30 JPEG_SOS = 0xDA, // start of scan 44 JPEG_SOS = 0xDA, // start of scan
31 JPEG_DQT = 0xDB, // define quantization table 45 JPEG_DQT = 0xDB, // define quantization table
32 JPEG_DRI = 0xDD, // define restart internal 46 JPEG_DRI = 0xDD, // define restart internal
33 JPEG_MARKER_PREFIX = 0xFF, // jpeg marker prefix 47 JPEG_MARKER_PREFIX = 0xFF, // jpeg marker prefix
34 }; 48 };
35 49
36 const size_t kJpegMaxHuffmanTableNumBaseline = 2; 50 const size_t kJpegMaxHuffmanTableNumBaseline = 2;
37 const size_t kJpegMaxComponents = 4; 51 const size_t kJpegMaxComponents = 4;
38 const size_t kJpegMaxQuantizationTableNum = 4; 52 const size_t kJpegMaxQuantizationTableNum = 4;
39 53
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }; 93 };
80 94
81 struct JpegParseResult { 95 struct JpegParseResult {
82 JpegFrameHeader frame_header; 96 JpegFrameHeader frame_header;
83 JpegHuffmanTable dc_table[kJpegMaxHuffmanTableNumBaseline]; 97 JpegHuffmanTable dc_table[kJpegMaxHuffmanTableNumBaseline];
84 JpegHuffmanTable ac_table[kJpegMaxHuffmanTableNumBaseline]; 98 JpegHuffmanTable ac_table[kJpegMaxHuffmanTableNumBaseline];
85 JpegQuantizationTable q_table[kJpegMaxQuantizationTableNum]; 99 JpegQuantizationTable q_table[kJpegMaxQuantizationTableNum];
86 uint16_t restart_interval; 100 uint16_t restart_interval;
87 JpegScanHeader scan; 101 JpegScanHeader scan;
88 const char* data; 102 const char* data;
103 // The size of compressed data of the first image.
89 size_t data_size; 104 size_t data_size;
105 // The size of the first entire image including header.
106 size_t image_size;
90 }; 107 };
91 108
92 // Parses JPEG picture in |buffer| with |length|. Returns true iff header is 109 // Parses JPEG picture in |buffer| with |length|. Returns true iff header is
93 // valid and JPEG baseline sequential process is present. If parsed 110 // valid and JPEG baseline sequential process is present. If parsed
94 // successfully, |result| is the parsed result. 111 // successfully, |result| is the parsed result.
95 // It's not a full featured JPEG parser implememtation. It only parses JPEG
96 // baseline sequential process. For explanations of each struct and its
97 // members, see JPEG specification at
98 // http://www.w3.org/Graphics/JPEG/itu-t81.pdf.
99 MEDIA_EXPORT bool ParseJpegPicture(const uint8_t* buffer, 112 MEDIA_EXPORT bool ParseJpegPicture(const uint8_t* buffer,
100 size_t length, 113 size_t length,
101 JpegParseResult* result); 114 JpegParseResult* result);
102 115
116 // Parses the first image of JPEG stream in |buffer| with |length|. Returns
117 // true iff header is valid and JPEG baseline sequential process is present.
118 // If parsed successfully, |result| is the parsed result.
119 MEDIA_EXPORT bool ParseJpegStream(const uint8_t* buffer,
120 size_t length,
121 JpegParseResult* result);
122
103 } // namespace media 123 } // namespace media
104 124
105 #endif // MEDIA_FILTERS_JPEG_PARSER_H_ 125 #endif // MEDIA_FILTERS_JPEG_PARSER_H_
OLDNEW
« no previous file with comments | « media/capture/video/file_video_capture_device_factory.cc ('k') | media/filters/jpeg_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698