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

Side by Side Diff: content/common/gpu/media/vaapi_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: Created 6 years 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
Pawel Osciak 2014/12/26 04:47:40 This class could be in media/filters.
kcwu 2014/12/27 13:27:35 Done.
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 CONTENT_COMMON_GPU_MEDIA_VAAPI_JPEG_PARSER_H_
6 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_JPEG_PARSER_H_
7
8 #include "base/big_endian.h"
9 #include "base/macros.h"
10 #include "content/common/content_export.h"
11
12 namespace content {
13
14 static const int kJpegHuffmanTableNum_baseline = 2;
Pawel Osciak 2014/12/26 04:47:40 all size_t please.
kcwu 2014/12/27 13:27:35 Done.
15 static const int kJpegComponentNum = 4;
16 static const int kJpegQuantizationTableNum = 4;
17
18 enum JpegMarker {
Owen Lin 2014/12/26 07:13:39 Do we need to export this ? Or it should be hide i
kcwu 2014/12/27 13:27:35 Done.
19 SOF0 = 0xC0, // start of frame (baseline)
20 DHT = 0xC4, // define huffman table
21 SOI = 0xD8, // start of image
22 SOS = 0xDA, // start of scan
23 DQT = 0xDB, // define quantization table
24 DRI = 0xDD, // define restart internal
25 MARKER1 = 0xFF, // jpeg marker prefix
26 };
27
28 // Parsing result of JPEG DHT marker
Pawel Osciak 2014/12/26 04:47:40 Dots at end of sentences everywhere please.
kcwu 2014/12/27 13:27:35 Done.
29 struct JpegHuffmanTable {
30 bool valid;
31 uint8_t code_length[16];
32 uint8_t code_value[256];
33 };
34
35 // Parsing result of JPEG DQT marker
36 struct JpegQuantizationTable {
37 bool valid;
38 uint8_t value[64]; // only support 8 bits quantization table
Pawel Osciak 2014/12/26 04:47:40 Is this a limitation of this parser, or is this ac
kcwu 2014/12/27 13:27:35 Done.
39 };
40
41 // Parsing result of a JPEG component
42 struct JpegComponent {
43 uint8_t id;
44 uint8_t horizontal_sampling_factor;
45 uint8_t vertical_sampling_factor;
46 uint8_t quantization_table_selector;
47 };
48
49 // Parsing result of JPEG SOS marker
50 struct JpegScan {
51 uint8_t num_component;
52 struct Component {
53 uint8_t component_selector;
54 uint8_t dc_selector;
55 uint8_t ac_selector;
56 } components[kJpegComponentNum];
57 const char* data;
Pawel Osciak 2014/12/26 04:47:40 const uint8_t*
kcwu 2014/12/27 13:27:35 Done.
kcwu 2015/01/07 11:07:31 I decided go back to const char*. Otherwise reinte
58 size_t data_size;
59 };
60
61 struct JpegParseResult {
62 uint16_t visible_width;
Pawel Osciak 2014/12/26 04:47:40 gfx::Size ?
kcwu 2014/12/27 13:27:35 Done. The drawback is needing ctor since it is no
63 uint16_t visible_height;
64 uint8_t num_component;
Pawel Osciak 2014/12/26 04:47:40 num_components. Please describe how this differs f
kcwu 2014/12/27 13:27:35 Done.
65 JpegComponent components[kJpegComponentNum];
66 JpegHuffmanTable dc_table[kJpegHuffmanTableNum_baseline];
67 JpegHuffmanTable ac_table[kJpegHuffmanTableNum_baseline];
68 JpegQuantizationTable q_table[kJpegQuantizationTableNum];
69 uint16_t restart_interval;
70 JpegScan scan;
71 };
72
73 // VaapiJpegParser parses JPEG header. It's not a full feature JPEG parser
Owen Lin 2014/12/26 07:13:39 full featured ?
kcwu 2014/12/27 13:27:35 Done.
74 // implememtation. It only parses subset of JPEG baseline mode needed by
75 // VAAPI JPEG decoder. For explanations of each struct and its members,
76 // see JPEG specification at http://www.w3.org/Graphics/JPEG/itu-t81.pdf.
77 class CONTENT_EXPORT VaapiJpegParser {
78 public:
79 // JPEG buffer and its size. The parser doesn't own the memory.
Pawel Osciak 2014/12/26 04:47:40 |buffer| |sizes| What does the buffer have to cont
kcwu 2014/12/27 13:27:35 Acknowledged.
80 VaapiJpegParser(const uint8_t* buffer, size_t length);
Pawel Osciak 2014/12/26 04:47:40 Feels to me that we could easily make this not Vaa
kcwu 2014/12/27 13:27:35 Done.
81 ~VaapiJpegParser();
82
83 // Parse JPEG header. Returns the parsed result iff header is valid and
84 // supported by VAAPI. Otherwise returns NULL. The parser still owns
85 // the returned result memory.
Owen Lin 2014/12/26 07:13:39 It is not convincing that the life time of the par
kcwu 2014/12/27 13:27:35 Done.
86 const JpegParseResult* Parse();
87
88 private:
89 bool ParseSOF(base::BigEndianReader reader);
Owen Lin 2014/12/26 07:13:39 Why |reader| is not base::BigEndianReader* or cons
kcwu 2014/12/27 13:27:35 Done.
90 bool ParseDQT(base::BigEndianReader reader);
91 bool ParseDHT(base::BigEndianReader reader);
92 bool ParseDRI(base::BigEndianReader reader);
93 bool ParseSOS(base::BigEndianReader reader);
94 bool ParseSOI(base::BigEndianReader reader);
95
96 // JPEG buffer. The parser doesn't own the memory.
97 const uint8_t* buffer_;
98 // Length of data in buffer
99 size_t length_;
100
101 // Parsed result
102 JpegParseResult result_;
103
104 DISALLOW_COPY_AND_ASSIGN(VaapiJpegParser);
105 };
106
107 } // namespace content
108
109 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_JPEG_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/media/vaapi_jpeg_parser.cc » ('j') | content/common/gpu/media/vaapi_jpeg_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698