Index: media/tools/mfdecoder/main.cc |
diff --git a/media/tools/mfdecoder/main.cc b/media/tools/mfdecoder/main.cc |
index 788bda0ef2d592b32b62fdd1501653db1a56c96c..ef31c486a17f26a98d5bfb4c16eb1b2ffa20c58d 100644 |
--- a/media/tools/mfdecoder/main.cc |
+++ b/media/tools/mfdecoder/main.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -26,20 +26,18 @@ |
#include "media/tools/mfdecoder/mfdecoder.h" |
#include "ui/gfx/gdi_util.h" |
-namespace { |
+static const char* const kWindowClass = "Chrome_MF_Decoder"; |
+static const char* const kWindowTitle = "MF Decoder"; |
+static const int kWindowStyleFlags = |
+ (WS_OVERLAPPEDWINDOW | WS_VISIBLE) & ~(WS_MAXIMIZEBOX | WS_THICKFRAME); |
+static bool g_render_to_window = false; |
+static bool g_render_asap = false; |
-const char* const kWindowClass = "Chrome_MF_Decoder"; |
-const char* const kWindowTitle = "MF Decoder"; |
-const int kWindowStyleFlags = (WS_OVERLAPPEDWINDOW | WS_VISIBLE) & |
- ~(WS_MAXIMIZEBOX | WS_THICKFRAME); |
-bool g_render_to_window = false; |
-bool g_render_asap = false; |
+static base::TimeDelta* g_decode_time; |
+static base::TimeDelta* g_render_time; |
+static int64 g_num_frames = 0; |
-base::TimeDelta* g_decode_time; |
-base::TimeDelta* g_render_time; |
-int64 g_num_frames = 0; |
- |
-void usage() { |
+static void usage() { |
static char* usage_msg = "Usage: mfdecoder (-s|-h) (-d|-r|-f) input-file\n" |
"-s: Use software decoding\n" |
"-h: Use hardware decoding\n" |
@@ -57,7 +55,7 @@ void usage() { |
// space for the returned Unicode string from the heap and it is caller's |
// responsibility to free it. |
// Returns: An equivalent Unicode string if successful, NULL otherwise. |
-wchar_t* ConvertASCIIStringToUnicode(const char* source) { |
+static wchar_t* ConvertASCIIStringToUnicode(const char* source) { |
if (source == NULL) { |
LOG(ERROR) << "ConvertASCIIStringToUnicode: source cannot be NULL"; |
return NULL; |
@@ -83,8 +81,8 @@ wchar_t* ConvertASCIIStringToUnicode(const char* source) { |
// Converts the given raw data buffer into RGB32 format, and drawing the result |
// into the given window. This is only used when DXVA2 is not enabled. |
// Returns: true on success. |
-bool ConvertToRGBAndDrawToWindow(HWND video_window, uint8* data, int width, |
- int height, int stride) { |
+static bool ConvertToRGBAndDrawToWindow(HWND video_window, uint8* data, |
+ int width, int height, int stride) { |
CHECK(video_window != NULL); |
CHECK(data != NULL); |
CHECK_GT(width, 0); |
@@ -132,8 +130,9 @@ bool ConvertToRGBAndDrawToWindow(HWND video_window, uint8* data, int width, |
// Obtains the underlying raw data buffer for the given IMFMediaBuffer, and |
// calls ConvertToRGBAndDrawToWindow() with it. |
// Returns: true on success. |
-bool PaintMediaBufferOntoWindow(HWND video_window, IMFMediaBuffer* video_buffer, |
- int width, int height, int stride) { |
+static bool PaintMediaBufferOntoWindow(HWND video_window, |
+ IMFMediaBuffer* video_buffer, |
+ int width, int height, int stride) { |
CHECK(video_buffer != NULL); |
HRESULT hr; |
BYTE* data; |
@@ -164,8 +163,8 @@ bool PaintMediaBufferOntoWindow(HWND video_window, IMFMediaBuffer* video_buffer, |
// Obtains the D3D9 surface from the given IMFMediaBuffer, then calls methods |
// in the D3D device to draw to the window associated with it. |
// Returns: true on success. |
-bool PaintD3D9BufferOntoWindow(IDirect3DDevice9* device, |
- IMFMediaBuffer* video_buffer) { |
+static bool PaintD3D9BufferOntoWindow(IDirect3DDevice9* device, |
+ IMFMediaBuffer* video_buffer) { |
CHECK(device != NULL); |
ScopedComPtr<IDirect3DSurface9> surface; |
HRESULT hr = MFGetService(video_buffer, MR_BUFFER_SERVICE, |
@@ -219,8 +218,8 @@ bool PaintD3D9BufferOntoWindow(IDirect3DDevice9* device, |
// For H.264 format, there should only be 1 buffer per sample, so each buffer |
// represents 1 frame. |
// Returns: true if successful. |
-bool DrawVideoSample(HWND video_window, media::MFDecoder* decoder, |
- IDirect3DDevice9* device) { |
+static bool DrawVideoSample(HWND video_window, media::MFDecoder* decoder, |
+ IDirect3DDevice9* device) { |
CHECK(video_window != NULL); |
CHECK(decoder != NULL); |
CHECK(decoder->initialized()); |
@@ -268,7 +267,7 @@ bool DrawVideoSample(HWND video_window, media::MFDecoder* decoder, |
// Creates a window with the given width and height. |
// Returns: A handle to the window on success, NULL otherwise. |
-HWND CreateDrawWindow(int width, int height) { |
+static HWND CreateDrawWindow(int width, int height) { |
WNDCLASS window_class = {0}; |
window_class.lpszClassName = kWindowClass; |
window_class.hInstance = NULL; |
@@ -303,8 +302,8 @@ HWND CreateDrawWindow(int width, int height) { |
// device. This function is used by mfdecoder.cc during the call to |
// MFDecoder::GetDXVA2AttributesForSourceReader(). |
// Returns: The D3D manager object if successful. Otherwise, NULL is returned. |
-IDirect3DDeviceManager9* CreateD3DDevManager(HWND video_window, |
- IDirect3DDevice9** device) { |
+static IDirect3DDeviceManager9* CreateD3DDevManager(HWND video_window, |
+ IDirect3DDevice9** device) { |
CHECK(video_window != NULL); |
CHECK(device != NULL); |
int ret = -1; |
@@ -366,9 +365,9 @@ IDirect3DDeviceManager9* CreateD3DDevManager(HWND video_window, |
// buffer dimensions to the actual video frame dimensions. |
// Both the decoder and device should be initialized before calling this method. |
// Returns: true if successful. |
-bool AdjustD3DDeviceBackBufferDimensions(media::MFDecoder* decoder, |
- IDirect3DDevice9* device, |
- HWND video_window) { |
+static bool AdjustD3DDeviceBackBufferDimensions(media::MFDecoder* decoder, |
+ IDirect3DDevice9* device, |
+ HWND video_window) { |
CHECK(decoder != NULL); |
CHECK(decoder->initialized()); |
CHECK(decoder->use_dxva2()); |
@@ -390,8 +389,8 @@ bool AdjustD3DDeviceBackBufferDimensions(media::MFDecoder* decoder, |
// Post this task in the MessageLoop. This function keeps posting itself |
// until DrawVideoSample fails. |
-void RepaintTask(media::MFDecoder* decoder, HWND video_window, |
- IDirect3DDevice9* device) { |
+static void RepaintTask(media::MFDecoder* decoder, HWND video_window, |
+ IDirect3DDevice9* device) { |
// This sends a WM_PAINT message so we can paint on the window later. |
// If we are using D3D9, then we do not send a WM_PAINT message since the two |
// do not work well together. |
@@ -418,8 +417,6 @@ void RepaintTask(media::MFDecoder* decoder, HWND video_window, |
} |
} |
-} // namespace |
- |
int main(int argc, char** argv) { |
if (argc < 2) { |
fprintf(stderr, "missing arguments\n"); |