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

Unified Diff: media/filters/jpeg_parser.cc

Issue 1016773002: MJPEG acceleration for video capture using VAAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix coded size, shm handle Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/jpeg_parser.cc
diff --git a/media/filters/jpeg_parser.cc b/media/filters/jpeg_parser.cc
index 66a3651210dc1add056c0b11dd71aea572b0f3ea..153ab48c8b3b79d84d349ed89025417599225780 100644
--- a/media/filters/jpeg_parser.cc
+++ b/media/filters/jpeg_parser.cc
@@ -49,6 +49,10 @@ static bool InRange(int value, int a, int b) {
return a <= value && value <= b;
}
+static int RoundUp(int value, int mul) {
+ return (value + mul - 1) / mul * mul;
+}
+
// |frame_header| is already initialized to 0 in ParseJpegPicture.
static bool ParseSOF(const char* buffer,
size_t length,
@@ -76,6 +80,8 @@ static bool ParseSOF(const char* buffer,
return false;
}
+ int max_h_factor = 0;
+ int max_v_factor = 0;
for (size_t i = 0; i < frame_header->num_components; i++) {
JpegComponent& component = frame_header->components[i];
READ_U8_OR_RETURN_FALSE(&component.id);
@@ -89,6 +95,10 @@ static bool ParseSOF(const char* buffer,
READ_U8_OR_RETURN_FALSE(&hv);
component.horizontal_sampling_factor = hv / 16;
component.vertical_sampling_factor = hv % 16;
+ if (component.horizontal_sampling_factor > max_h_factor)
+ max_h_factor = component.horizontal_sampling_factor;
+ if (component.vertical_sampling_factor > max_v_factor)
+ max_v_factor = component.vertical_sampling_factor;
if (!InRange(component.horizontal_sampling_factor, 1, 4)) {
DVLOG(1) << "Invalid horizontal sampling factor "
<< static_cast<int>(component.horizontal_sampling_factor);
@@ -102,6 +112,13 @@ static bool ParseSOF(const char* buffer,
READ_U8_OR_RETURN_FALSE(&component.quantization_table_selector);
}
+ // The size of data unit is 8*8 and the coded size should be extended
+ // to complete minimum coded unit, MCU. See Spec A.2.
+ frame_header->coded_width = RoundUp(frame_header->visible_width,
+ max_h_factor * 8);
+ frame_header->coded_height = RoundUp(frame_header->visible_height,
+ max_v_factor * 8);
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698