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

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: Cleaned emacs buffers. 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 media_type->majortype = MEDIATYPE_Video; 44 media_type->majortype = MEDIATYPE_Video;
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 = requested_format_.ImageAllocationSize();
55 requested_format_.frame_size.GetArea() * 3 / 2;
56 media_type->subtype = kMediaSubTypeI420; 55 media_type->subtype = kMediaSubTypeI420;
57 break; 56 break;
58 } 57 }
59 case 1: { 58 case 1: {
60 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2'); 59 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2');
61 pvi->bmiHeader.biBitCount = 16; 60 pvi->bmiHeader.biBitCount = 16;
62 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 61 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
63 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 62 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
64 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 2; 63 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize();
65 media_type->subtype = MEDIASUBTYPE_YUY2; 64 media_type->subtype = MEDIASUBTYPE_YUY2;
66 break; 65 break;
67 } 66 }
68 case 2: { 67 case 2: {
69 pvi->bmiHeader.biCompression = MAKEFOURCC('M', 'J', 'P', 'G'); 68 pvi->bmiHeader.biCompression = MAKEFOURCC('M', 'J', 'P', 'G');
70 pvi->bmiHeader.biBitCount = 0; 69 pvi->bmiHeader.biBitCount = 0;
71 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 70 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
72 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 71 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
73 pvi->bmiHeader.biSizeImage = 0; 72 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize();
74 media_type->subtype = MEDIASUBTYPE_MJPG; 73 media_type->subtype = MEDIASUBTYPE_MJPG;
75 break; 74 break;
76 } 75 }
77 case 3: { 76 case 3: {
78 pvi->bmiHeader.biCompression = BI_RGB; 77 pvi->bmiHeader.biCompression = BI_RGB;
79 pvi->bmiHeader.biBitCount = 24; 78 pvi->bmiHeader.biBitCount = 24;
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() * 3; 81 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize();
83 media_type->subtype = MEDIASUBTYPE_RGB24; 82 media_type->subtype = MEDIASUBTYPE_RGB24;
84 break; 83 break;
85 } 84 }
86 default: 85 default:
87 return false; 86 return false;
88 } 87 }
89 88
90 media_type->bFixedSizeSamples = TRUE; 89 media_type->bFixedSizeSamples = TRUE;
91 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; 90 media_type->lSampleSize = pvi->bmiHeader.biSizeImage;
92 return true; 91 return true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 resulting_format_.frame_size.SetSize(0, 0); 154 resulting_format_.frame_size.SetSize(0, 0);
156 resulting_format_.frame_rate = 0; 155 resulting_format_.frame_rate = 0;
157 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; 156 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN;
158 } 157 }
159 158
160 const VideoCaptureFormat& SinkInputPin::ResultingFormat() { 159 const VideoCaptureFormat& SinkInputPin::ResultingFormat() {
161 return resulting_format_; 160 return resulting_format_;
162 } 161 }
163 162
164 } // namespace media 163 } // 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