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

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: Changed function to a public member. Added tests. 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
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 media_type->formattype = FORMAT_VideoInfo; 45 media_type->formattype = FORMAT_VideoInfo;
46 media_type->bTemporalCompression = FALSE; 46 media_type->bTemporalCompression = FALSE;
47 47
48 switch (index) { 48 switch (index) {
49 case 0: { 49 case 0: {
50 pvi->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0'); 50 pvi->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0');
51 pvi->bmiHeader.biBitCount = 12; // bit per pixel 51 pvi->bmiHeader.biBitCount = 12; // bit per pixel
52 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 52 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
53 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 53 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
54 pvi->bmiHeader.biSizeImage = 54 pvi->bmiHeader.biSizeImage =
55 requested_format_.frame_size.GetArea() * 3 / 2; 55 requested_format_.ImageAllocationSize();
mcasas 2015/02/03 20:48:46 Doesn't this fit in one line? Same for the other c
56 media_type->subtype = kMediaSubTypeI420; 56 media_type->subtype = kMediaSubTypeI420;
57 break; 57 break;
58 } 58 }
59 case 1: { 59 case 1: {
60 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2'); 60 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2');
61 pvi->bmiHeader.biBitCount = 16; 61 pvi->bmiHeader.biBitCount = 16;
62 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 62 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
63 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 63 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
64 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 2; 64 pvi->bmiHeader.biSizeImage =
65 requested_format_.ImageAllocationSize();
65 media_type->subtype = MEDIASUBTYPE_YUY2; 66 media_type->subtype = MEDIASUBTYPE_YUY2;
66 break; 67 break;
67 } 68 }
68 case 2: { 69 case 2: {
69 pvi->bmiHeader.biCompression = MAKEFOURCC('M', 'J', 'P', 'G'); 70 pvi->bmiHeader.biCompression = MAKEFOURCC('M', 'J', 'P', 'G');
70 pvi->bmiHeader.biBitCount = 0; 71 pvi->bmiHeader.biBitCount = 0;
71 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 72 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
72 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 73 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
73 pvi->bmiHeader.biSizeImage = 0; 74 pvi->bmiHeader.biSizeImage =
75 requested_format_.ImageAllocationSize();
74 media_type->subtype = MEDIASUBTYPE_MJPG; 76 media_type->subtype = MEDIASUBTYPE_MJPG;
75 break; 77 break;
76 } 78 }
77 case 3: { 79 case 3: {
78 pvi->bmiHeader.biCompression = BI_RGB; 80 pvi->bmiHeader.biCompression = BI_RGB;
79 pvi->bmiHeader.biBitCount = 24; 81 pvi->bmiHeader.biBitCount = 24;
80 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 82 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
81 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 83 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
82 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 3; 84 pvi->bmiHeader.biSizeImage =
85 requested_format_.ImageAllocationSize();
83 media_type->subtype = MEDIASUBTYPE_RGB24; 86 media_type->subtype = MEDIASUBTYPE_RGB24;
84 break; 87 break;
85 } 88 }
86 default: 89 default:
87 return false; 90 return false;
88 } 91 }
89 92
90 media_type->bFixedSizeSamples = TRUE; 93 media_type->bFixedSizeSamples = TRUE;
91 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; 94 media_type->lSampleSize = pvi->bmiHeader.biSizeImage;
92 return true; 95 return true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 resulting_format_.frame_size.SetSize(0, 0); 158 resulting_format_.frame_size.SetSize(0, 0);
156 resulting_format_.frame_rate = 0; 159 resulting_format_.frame_rate = 0;
157 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; 160 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN;
158 } 161 }
159 162
160 const VideoCaptureFormat& SinkInputPin::ResultingFormat() { 163 const VideoCaptureFormat& SinkInputPin::ResultingFormat() {
161 return resulting_format_; 164 return resulting_format_;
162 } 165 }
163 166
164 } // namespace media 167 } // namespace media
OLDNEW
« media/video/capture/video_capture_types.h ('K') | « 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