Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf21cc4

Browse files
committed
small refactorings.
1 parent 041905e commit cf21cc4

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

VCamSampleSource/FrameGenerator.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,22 +195,20 @@ HRESULT FrameGenerator::Generate(IMFSample* sample, REFGUID format, IMFSample**
195195
wil::com_ptr_nothrow<IDWriteTextLayout> layout;
196196
RETURN_IF_FAILED(_dwrite->CreateTextLayout(text, len, _textFormat.get(), (FLOAT)_width, (FLOAT)_height, &layout));
197197

198-
DWRITE_TEXT_METRICS metrics;
199-
RETURN_IF_FAILED(layout->GetMetrics(&metrics));
200198
_renderTarget->DrawTextLayout(D2D1::Point2F(0, 0), layout.get(), _whiteBrush.get());
201199
_renderTarget->EndDraw();
202200
}
203201

204202
// build a sample using either D3D/DXGI (GPU) or WIC (CPU)
205-
wil::com_ptr_nothrow<IMFMediaBuffer> buffer;
203+
wil::com_ptr_nothrow<IMFMediaBuffer> mediaBuffer;
206204
if (HasD3DManager())
207205
{
208206
// remove all existing buffers
209207
RETURN_IF_FAILED(sample->RemoveAllBuffers());
210208

211209
// create a buffer from this and add to sample
212-
RETURN_IF_FAILED(MFCreateDXGISurfaceBuffer(__uuidof(ID3D11Texture2D), _texture.get(), 0, 0, &buffer));
213-
RETURN_IF_FAILED(sample->AddBuffer(buffer.get()));
210+
RETURN_IF_FAILED(MFCreateDXGISurfaceBuffer(__uuidof(ID3D11Texture2D), _texture.get(), 0, 0, &mediaBuffer));
211+
RETURN_IF_FAILED(sample->AddBuffer(mediaBuffer.get()));
214212

215213
// if we're on GPU & format is not RGB, convert using GPU
216214
if (format == MFVideoFormat_NV12)
@@ -234,13 +232,13 @@ HRESULT FrameGenerator::Generate(IMFSample* sample, REFGUID format, IMFSample**
234232
return S_OK;
235233
}
236234

237-
RETURN_IF_FAILED(sample->GetBufferByIndex(0, &buffer));
235+
RETURN_IF_FAILED(sample->GetBufferByIndex(0, &mediaBuffer));
238236
wil::com_ptr_nothrow<IMF2DBuffer2> buffer2D;
239237
BYTE* scanline;
240238
LONG pitch;
241239
BYTE* start;
242240
DWORD length;
243-
RETURN_IF_FAILED(buffer->QueryInterface(IID_PPV_ARGS(&buffer2D)));
241+
RETURN_IF_FAILED(mediaBuffer->QueryInterface(IID_PPV_ARGS(&buffer2D)));
244242
RETURN_IF_FAILED(buffer2D->Lock2DSize(MF2DBuffer_LockFlags_Write, &scanline, &pitch, &start, &length));
245243

246244
wil::com_ptr_nothrow<IWICBitmapLock> lock;

0 commit comments

Comments
 (0)