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

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

Issue 748023002: Add JPEG parser for JPEG decode acceleration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const char* for data Created 5 years, 11 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/BUILD.gn ('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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 #ifndef MEDIA_FILTERS_JPEG_PARSER_H_
6 #define MEDIA_FILTERS_JPEG_PARSER_H_
7
8 #include <stdint.h>
9 #include "base/macros.h"
10 #include "media/base/media_export.h"
11
12 namespace media {
13
14 static const size_t kJpegMaxHuffmanTableNum_baseline = 2;
15 static const size_t kJpegMaxComponents = 4;
16 static const size_t kJpegMaxQuantizationTableNum = 4;
17
18 // Parsing result of JPEG DHT marker.
19 struct JpegHuffmanTable {
20 bool valid;
21 uint8_t code_length[16];
22 uint8_t code_value[256];
23 };
24
25 // Parsing result of JPEG DQT marker.
26 struct JpegQuantizationTable {
27 bool valid;
28 uint8_t value[64]; // only support 8 bits quantization table for baseline
wuchengli 2015/01/12 05:23:16 I think "baseline only supports 8 bits quantizatio
kcwu 2015/01/12 06:17:08 Done.
29 };
30
31 // Parsing result of a JPEG component.
32 struct JpegComponent {
33 uint8_t id;
34 uint8_t horizontal_sampling_factor;
35 uint8_t vertical_sampling_factor;
36 uint8_t quantization_table_selector;
37 };
38
39 // Parsing result of JPEG SOS marker.
40 struct JpegScan {
41 uint8_t num_components;
42 struct Component {
43 uint8_t component_selector;
44 uint8_t dc_selector;
45 uint8_t ac_selector;
46 } components[kJpegMaxComponents];
47 const char* data;
48 size_t data_size;
49 };
50
51 struct JpegParseResult {
52 uint16_t visible_width;
53 uint16_t visible_height;
54 uint8_t num_components;
55 JpegComponent components[kJpegMaxComponents];
56 JpegHuffmanTable dc_table[kJpegMaxHuffmanTableNum_baseline];
57 JpegHuffmanTable ac_table[kJpegMaxHuffmanTableNum_baseline];
58 JpegQuantizationTable q_table[kJpegMaxQuantizationTableNum];
59 uint16_t restart_interval;
60 JpegScan scan;
61 };
62
63 // JpegParser parses JPEG header. It's not a full featured JPEG parser
64 // implememtation. It only parses JPEG baseline sequential process. For
65 // explanations of each struct and its members, see JPEG specification at
66 // http://www.w3.org/Graphics/JPEG/itu-t81.pdf.
67 class MEDIA_EXPORT JpegParser {
68 public:
69 // Parses JPEG picture in |buffer| with |length|. Returns true iff header is
70 // valid and JPEG baseline sequential process is present. If parsed
71 // successfully, |result| is the parsed result.
72 static bool Parse(const uint8_t* buffer,
73 size_t length,
74 JpegParseResult* result);
75
76 private:
77 static bool ParseSOF(const char* buffer,
78 size_t length,
79 JpegParseResult* result);
80 static bool ParseDQT(const char* buffer,
81 size_t length,
82 JpegParseResult* result);
83 static bool ParseDHT(const char* buffer,
84 size_t length,
85 JpegParseResult* result);
86 static bool ParseDRI(const char* buffer,
87 size_t length,
88 JpegParseResult* result);
89 static bool ParseSOS(const char* buffer,
90 size_t length,
91 JpegParseResult* result);
92 static bool ParseSOI(const char* buffer,
93 size_t length,
94 JpegParseResult* result);
95
96 DISALLOW_COPY_AND_ASSIGN(JpegParser);
97 };
98
99 } // namespace media
100
101 #endif // MEDIA_FILTERS_JPEG_PARSER_H_
OLDNEW
« no previous file with comments | « media/BUILD.gn ('k') | media/filters/jpeg_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698