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

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: move to media/filters/ 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 | « no previous file | media/filters/jpeg_parser.cc » ('j') | media/filters/jpeg_parser.cc » ('J')
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
wuchengli 2015/01/05 07:32:55 Can you explain why we are not using ffmpeg/libavc
kcwu 2015/01/05 08:50:50 ffmpeg/libavcodec/mjpeg_parser.c only scans for 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 "base/big_endian.h"
wuchengli 2015/01/05 07:32:55 Move this to jpeg_parser.cc?
kcwu 2015/01/05 08:50:51 Done.
9 #include "base/macros.h"
10 #include "media/base/media_export.h"
11 #include "ui/gfx/geometry/size.h"
12
13 namespace media {
14
15 static const size_t kJpegMaxHuffmanTableNum_baseline = 2;
16 static const size_t kJpegMaxComponents = 4;
17 static const size_t kJpegMaxQuantizationTableNum = 4;
18
19 // Parsing result of JPEG DHT marker.
20 struct JpegHuffmanTable {
21 bool valid;
22 uint8_t code_length[16];
23 uint8_t code_value[256];
24 };
25
26 // Parsing result of JPEG DQT marker.
27 struct JpegQuantizationTable {
28 bool valid;
29 uint8_t value[64]; // only support 8 bits quantization table for baseline
30 };
31
32 // Parsing result of a JPEG component.
33 struct JpegComponent {
34 uint8_t id;
35 uint8_t horizontal_sampling_factor;
36 uint8_t vertical_sampling_factor;
37 uint8_t quantization_table_selector;
38 };
39
40 // Parsing result of JPEG SOS marker.
41 struct JpegScan {
42 uint8_t num_components;
43 struct Component {
44 uint8_t component_selector;
45 uint8_t dc_selector;
46 uint8_t ac_selector;
47 } components[kJpegMaxComponents];
48 const uint8_t* data;
49 size_t data_size;
50 };
51
52 struct JpegParseResult {
53 JpegParseResult();
wuchengli 2015/01/05 07:32:55 Do we need the constructor?
kcwu 2015/01/05 08:50:50 gfx::Size is not plain data structure, thus it nee
wuchengli 2015/01/05 08:57:13 I wouldn't use gfx::Size because it brings ui/gfx
54 gfx::Size visible_size;
55 uint8_t num_components;
56 JpegComponent components[kJpegMaxComponents];
57 JpegHuffmanTable dc_table[kJpegMaxHuffmanTableNum_baseline];
58 JpegHuffmanTable ac_table[kJpegMaxHuffmanTableNum_baseline];
59 JpegQuantizationTable q_table[kJpegMaxQuantizationTableNum];
60 uint16_t restart_interval;
61 JpegScan scan;
62 };
63
64 // JpegParser parses JPEG header. It's not a full featured JPEG parser
65 // implememtation. It only parses JPEG baseline sequential process. For
66 // explanations of each struct and its members, see JPEG specification at
67 // http://www.w3.org/Graphics/JPEG/itu-t81.pdf.
68 class MEDIA_EXPORT JpegParser {
69 public:
70 JpegParser();
71 ~JpegParser();
72
73 // Parses JPEG picture in |buffer| with |length|. Returns true iff header is
74 // valid and supported JPEG baseline sequential process. If parsed
wuchengli 2015/01/05 07:32:55 "supported" sounds strange. s/supported JPEG basel
kcwu 2015/01/05 08:50:50 Done.
75 // successfully, |result| is the parsed result.
76 static bool Parse(const uint8_t* buffer,
77 size_t length,
78 JpegParseResult* result);
79
80 private:
81 static bool ParseSOF(const char* buffer,
82 size_t length,
83 JpegParseResult* result);
84 static bool ParseDQT(const char* buffer,
85 size_t length,
86 JpegParseResult* result);
87 static bool ParseDHT(const char* buffer,
88 size_t length,
89 JpegParseResult* result);
90 static bool ParseDRI(const char* buffer,
91 size_t length,
92 JpegParseResult* result);
93 static bool ParseSOS(const char* buffer,
94 size_t length,
95 JpegParseResult* result);
96 static bool ParseSOI(const char* buffer,
97 size_t length,
98 JpegParseResult* result);
99
100 DISALLOW_COPY_AND_ASSIGN(JpegParser);
101 };
102
103 } // namespace media
104
105 #endif // MEDIA_FILTERS_JPEG_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/jpeg_parser.cc » ('j') | media/filters/jpeg_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698