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

Side by Side Diff: media/video/capture/win/sink_input_pin_win.cc

Issue 897483002: Refactored pixel format resize operations in media/video/capture into a function called VideoCaptu… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added checks for unsupported pixel formats. Created 5 years, 10 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/video/capture/video_capture_types.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "media/video/capture/win/sink_input_pin_win.h" 5 #include "media/video/capture/win/sink_input_pin_win.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 // Avoid including strsafe.h via dshow as it will cause build warnings. 9 // Avoid including strsafe.h via dshow as it will cause build warnings.
10 #define NO_DSHOW_STRSAFE 10 #define NO_DSHOW_STRSAFE
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; 62 media_type->lSampleSize = pvi->bmiHeader.biSizeImage;
63 return true; 63 return true;
64 } 64 }
65 65
66 switch (index) { 66 switch (index) {
67 case 0: { 67 case 0: {
68 pvi->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0'); 68 pvi->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0');
69 pvi->bmiHeader.biBitCount = 12; // bit per pixel 69 pvi->bmiHeader.biBitCount = 12; // bit per pixel
70 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 70 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
71 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 71 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
72 pvi->bmiHeader.biSizeImage = 72 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize();
73 requested_format_.frame_size.GetArea() * 3 / 2;
74 media_type->subtype = kMediaSubTypeI420; 73 media_type->subtype = kMediaSubTypeI420;
75 break; 74 break;
76 } 75 }
77 case 1: { 76 case 1: {
78 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2'); 77 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2');
79 pvi->bmiHeader.biBitCount = 16; 78 pvi->bmiHeader.biBitCount = 16;
80 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 79 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
81 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 80 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
82 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 2; 81 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize();
83 media_type->subtype = MEDIASUBTYPE_YUY2; 82 media_type->subtype = MEDIASUBTYPE_YUY2;
84 break; 83 break;
85 } 84 }
86 case 2: { 85 case 2: {
87 pvi->bmiHeader.biCompression = BI_RGB; 86 pvi->bmiHeader.biCompression = BI_RGB;
88 pvi->bmiHeader.biBitCount = 24; 87 pvi->bmiHeader.biBitCount = 24;
89 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 88 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
90 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 89 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
91 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 3; 90 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize();
92 media_type->subtype = MEDIASUBTYPE_RGB24; 91 media_type->subtype = MEDIASUBTYPE_RGB24;
93 break; 92 break;
94 } 93 }
95 default: 94 default:
96 return false; 95 return false;
97 } 96 }
98 97
99 media_type->bFixedSizeSamples = TRUE; 98 media_type->bFixedSizeSamples = TRUE;
100 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; 99 media_type->lSampleSize = pvi->bmiHeader.biSizeImage;
101 return true; 100 return true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 resulting_format_.frame_size.SetSize(0, 0); 163 resulting_format_.frame_size.SetSize(0, 0);
165 resulting_format_.frame_rate = 0; 164 resulting_format_.frame_rate = 0;
166 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; 165 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN;
167 } 166 }
168 167
169 const VideoCaptureFormat& SinkInputPin::ResultingFormat() { 168 const VideoCaptureFormat& SinkInputPin::ResultingFormat() {
170 return resulting_format_; 169 return resulting_format_;
171 } 170 }
172 171
173 } // namespace media 172 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/video_capture_types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698