diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-07 15:26:05 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-07 15:26:05 +0000 |
commit | 2770c95a50db703c322d65d286aa5771e58ac25a (patch) | |
tree | 595b2adf92be75f65eccbbb0760e3969d2d840c3 /media/tools | |
parent | eac3ba4f0f315bb2c68289062cb9f4f5ec632f90 (diff) | |
download | chromium_src-2770c95a50db703c322d65d286aa5771e58ac25a.zip chromium_src-2770c95a50db703c322d65d286aa5771e58ac25a.tar.gz chromium_src-2770c95a50db703c322d65d286aa5771e58ac25a.tar.bz2 |
Cleaning up src/media to be consistent with static versus anonymous namespaces.
We were using a mix of both (and sometimes even static functions *inside* anonymous namespaces!) so we decided to stick to using static.
Also moved static/test code into media namespace and removed media:: prefixes.
BUG=none
TEST=compiles
Review URL: http://codereview.chromium.org/6628020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77135 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r-- | media/tools/mfdecoder/main.cc | 61 | ||||
-rw-r--r-- | media/tools/mfplayer/mfplayer.cc | 11 | ||||
-rw-r--r-- | media/tools/scaler_bench/scaler_bench.cc | 24 | ||||
-rw-r--r-- | media/tools/shader_bench/window_linux.cc | 20 | ||||
-rw-r--r-- | media/tools/shader_bench/window_win.cc | 17 |
5 files changed, 58 insertions, 75 deletions
diff --git a/media/tools/mfdecoder/main.cc b/media/tools/mfdecoder/main.cc index 788bda0..ef31c48 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"); diff --git a/media/tools/mfplayer/mfplayer.cc b/media/tools/mfplayer/mfplayer.cc index fbeb32f..79894ee 100644 --- a/media/tools/mfplayer/mfplayer.cc +++ b/media/tools/mfplayer/mfplayer.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. @@ -11,17 +11,16 @@ #include <cassert> -namespace { - template <class T> -void SafeRelease(T** pptr) { +static void SafeRelease(T** pptr) { if (pptr && *pptr) { (*pptr)->Release(); *pptr = NULL; } } -HRESULT ProbeTopology(IMFMediaEvent* event, IMFTopology** topology_ptr) { +static HRESULT ProbeTopology(IMFMediaEvent* event, + IMFTopology** topology_ptr) { HRESULT hr = S_OK; PROPVARIANT var; PropVariantInit(&var); @@ -36,8 +35,6 @@ HRESULT ProbeTopology(IMFMediaEvent* event, IMFTopology** topology_ptr) { return hr; } -} // namespace - namespace mfplayer { // Public methods diff --git a/media/tools/scaler_bench/scaler_bench.cc b/media/tools/scaler_bench/scaler_bench.cc index f9be6c6..86ee335 100644 --- a/media/tools/scaler_bench/scaler_bench.cc +++ b/media/tools/scaler_bench/scaler_bench.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. @@ -22,16 +22,14 @@ using base::TimeDelta; using base::TimeTicks; using media::VideoFrame; -namespace { +static int source_width = 1280; +static int source_height = 720; +static int dest_width = 1366; +static int dest_height = 768; +static int num_frames = 500; +static int num_buffers = 50; -int source_width = 1280; -int source_height = 720; -int dest_width = 1366; -int dest_height = 768; -int num_frames = 500; -int num_buffers = 50; - -double BenchmarkSkia() { +static double BenchmarkSkia() { std::vector<scoped_refptr<VideoFrame> > source_frames; ScopedVector<SkBitmap> dest_frames; for (int i = 0; i < num_buffers; i++) { @@ -87,7 +85,7 @@ double BenchmarkSkia() { return static_cast<double>((end - start).InMilliseconds()) / num_frames; } -double BenchmarkRGBToYUV() { +static double BenchmarkRGBToYUV() { int rgb_stride = source_width * 4; scoped_array<uint8> rgb_frame(new uint8[rgb_stride * source_height]); @@ -115,7 +113,7 @@ double BenchmarkRGBToYUV() { return static_cast<double>((end - start).InMilliseconds()) / num_frames; } -double BenchmarkFilter(media::ScaleFilter filter) { +static double BenchmarkFilter(media::ScaleFilter filter) { std::vector<scoped_refptr<VideoFrame> > source_frames; std::vector<scoped_refptr<VideoFrame> > dest_frames; @@ -158,8 +156,6 @@ double BenchmarkFilter(media::ScaleFilter filter) { return static_cast<double>((end - start).InMilliseconds()) / num_frames; } -} // namespace - int main(int argc, const char** argv) { CommandLine::Init(argc, argv); const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); diff --git a/media/tools/shader_bench/window_linux.cc b/media/tools/shader_bench/window_linux.cc index 1c43505..0063a8d 100644 --- a/media/tools/shader_bench/window_linux.cc +++ b/media/tools/shader_bench/window_linux.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. @@ -10,24 +10,22 @@ #include <gdk/gdkx.h> #include <gtk/gtk.h> -namespace { +namespace media { -gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) { +static gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) { gtk_main_quit(); return FALSE; } -gboolean OnExpose(GtkWidget* widget, GdkEventExpose* event, gpointer data) { - media::Window* window = reinterpret_cast<media::Window*>(data); +static gboolean OnExpose(GtkWidget* widget, + GdkEventExpose* event, + gpointer data) { + Window* window = reinterpret_cast<Window*>(data); if (window) window->OnPaint(); return FALSE; } -} // namespace - -namespace media { - gfx::NativeWindow Window::CreateNativeWindow(int width, int height) { GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -52,12 +50,12 @@ void Window::Start(int limit, Task* done_task, Painter* painter) { gtk_signal_connect(GTK_OBJECT(window_handle_), "delete_event", - reinterpret_cast<GtkSignalFunc>(::OnDelete), + reinterpret_cast<GtkSignalFunc>(OnDelete), NULL); gtk_signal_connect(GTK_OBJECT(window_handle_), "expose_event", - reinterpret_cast<GtkSignalFunc>(::OnExpose), + reinterpret_cast<GtkSignalFunc>(OnExpose), this); gtk_widget_queue_draw(GTK_WIDGET(window_handle_)); diff --git a/media/tools/shader_bench/window_win.cc b/media/tools/shader_bench/window_win.cc index 0d9c3f9..827e210 100644 --- a/media/tools/shader_bench/window_win.cc +++ b/media/tools/shader_bench/window_win.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. @@ -7,10 +7,10 @@ #include "base/task.h" #include "media/tools/shader_bench/painter.h" -namespace { +namespace media { -LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, - WPARAM w_param, LPARAM l_param) { +static LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, + WPARAM w_param, LPARAM l_param) { LRESULT result = 0; switch (msg) { case WM_CLOSE: @@ -25,9 +25,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, result = 1; break; case WM_PAINT: { - media::Window* window = - reinterpret_cast<media::Window*>( - GetWindowLongPtr(hwnd, GWL_USERDATA)); + Window* window = + reinterpret_cast<Window*>(GetWindowLongPtr(hwnd, GWL_USERDATA)); if (window != NULL) window->OnPaint(); ::ValidateRect(hwnd, NULL); @@ -40,10 +39,6 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, return result; } -} // namespace - -namespace media { - gfx::NativeWindow Window::CreateNativeWindow(int width, int height) { WNDCLASS wnd_class = {0}; HINSTANCE instance = GetModuleHandle(NULL); |