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

Side by Side Diff: media/gpu/vt_video_decode_accelerator_mac.h

Issue 2771923006: Add CVPixelBufferRef memory tracking (Closed)
Patch Set: Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MEDIA_GPU_VT_VIDEO_DECODE_ACCELERATOR_MAC_H_ 5 #ifndef MEDIA_GPU_VT_VIDEO_DECODE_ACCELERATOR_MAC_H_
6 #define MEDIA_GPU_VT_VIDEO_DECODE_ACCELERATOR_MAC_H_ 6 #define MEDIA_GPU_VT_VIDEO_DECODE_ACCELERATOR_MAC_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <queue> 12 #include <queue>
13 13
14 #include <VideoToolbox/VideoToolbox.h> 14 #include <VideoToolbox/VideoToolbox.h>
15 15
16 #include "base/mac/scoped_cftyperef.h" 16 #include "base/mac/scoped_cftyperef.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/linked_ptr.h" 18 #include "base/memory/linked_ptr.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
21 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
22 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
23 #include "base/trace_event/memory_dump_provider.h"
23 #include "media/filters/h264_parser.h" 24 #include "media/filters/h264_parser.h"
24 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" 25 #include "media/gpu/gpu_video_decode_accelerator_helpers.h"
25 #include "media/gpu/media_gpu_export.h" 26 #include "media/gpu/media_gpu_export.h"
26 #include "media/video/h264_poc.h" 27 #include "media/video/h264_poc.h"
27 #include "media/video/video_decode_accelerator.h" 28 #include "media/video/video_decode_accelerator.h"
28 #include "ui/gfx/geometry/size.h" 29 #include "ui/gfx/geometry/size.h"
29 #include "ui/gl/gl_context_cgl.h" 30 #include "ui/gl/gl_context_cgl.h"
30 #include "ui/gl/gl_image_io_surface.h" 31 #include "ui/gl/gl_image_io_surface.h"
31 32
32 namespace media { 33 namespace media {
33 34
34 // Preload VideoToolbox libraries, needed for sandbox warmup. 35 // Preload VideoToolbox libraries, needed for sandbox warmup.
35 MEDIA_GPU_EXPORT bool InitializeVideoToolbox(); 36 MEDIA_GPU_EXPORT bool InitializeVideoToolbox();
36 37
37 // VideoToolbox.framework implementation of the VideoDecodeAccelerator 38 // VideoToolbox.framework implementation of the VideoDecodeAccelerator
38 // interface for Mac OS X (currently limited to 10.9+). 39 // interface for Mac OS X (currently limited to 10.9+).
39 class VTVideoDecodeAccelerator : public VideoDecodeAccelerator { 40 class VTVideoDecodeAccelerator : public VideoDecodeAccelerator,
41 public base::trace_event::MemoryDumpProvider {
40 public: 42 public:
41 explicit VTVideoDecodeAccelerator( 43 explicit VTVideoDecodeAccelerator(
42 const MakeGLContextCurrentCallback& make_context_current_cb, 44 const MakeGLContextCurrentCallback& make_context_current_cb,
43 const BindGLImageCallback& bind_image_cb); 45 const BindGLImageCallback& bind_image_cb);
44 46
45 ~VTVideoDecodeAccelerator() override; 47 ~VTVideoDecodeAccelerator() override;
46 48
47 // VideoDecodeAccelerator implementation. 49 // VideoDecodeAccelerator implementation.
48 bool Initialize(const Config& config, Client* client) override; 50 bool Initialize(const Config& config, Client* client) override;
49 void Decode(const BitstreamBuffer& bitstream) override; 51 void Decode(const BitstreamBuffer& bitstream) override;
50 void AssignPictureBuffers( 52 void AssignPictureBuffers(
51 const std::vector<PictureBuffer>& pictures) override; 53 const std::vector<PictureBuffer>& pictures) override;
52 void ReusePictureBuffer(int32_t picture_id) override; 54 void ReusePictureBuffer(int32_t picture_id) override;
53 void Flush() override; 55 void Flush() override;
54 void Reset() override; 56 void Reset() override;
55 void Destroy() override; 57 void Destroy() override;
56 bool TryToSetupDecodeOnSeparateThread( 58 bool TryToSetupDecodeOnSeparateThread(
57 const base::WeakPtr<Client>& decode_client, 59 const base::WeakPtr<Client>& decode_client,
58 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) 60 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner)
59 override; 61 override;
60 62
63 // MemoryDumpProvider implementation.
64 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
65 base::trace_event::ProcessMemoryDump* pmd) override;
66
61 // Called by OutputThunk() when VideoToolbox finishes decoding a frame. 67 // Called by OutputThunk() when VideoToolbox finishes decoding a frame.
62 void Output(void* source_frame_refcon, 68 void Output(void* source_frame_refcon,
63 OSStatus status, 69 OSStatus status,
64 CVImageBufferRef image_buffer); 70 CVImageBufferRef image_buffer);
65 71
66 static VideoDecodeAccelerator::SupportedProfiles GetSupportedProfiles(); 72 static VideoDecodeAccelerator::SupportedProfiles GetSupportedProfiles();
67 73
68 private: 74 private:
69 // Logged to UMA, so never reuse values. Make sure to update 75 // Logged to UMA, so never reuse values. Make sure to update
70 // VTVDASessionFailureType in histograms.xml to match. 76 // VTVDASessionFailureType in histograms.xml to match.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Last SPS and PPS the decoder was confgured with. 267 // Last SPS and PPS the decoder was confgured with.
262 std::vector<uint8_t> configured_sps_; 268 std::vector<uint8_t> configured_sps_;
263 std::vector<uint8_t> configured_spsext_; 269 std::vector<uint8_t> configured_spsext_;
264 std::vector<uint8_t> configured_pps_; 270 std::vector<uint8_t> configured_pps_;
265 gfx::Size configured_size_; 271 gfx::Size configured_size_;
266 272
267 bool waiting_for_idr_ = true; 273 bool waiting_for_idr_ = true;
268 bool missing_idr_logged_ = false; 274 bool missing_idr_logged_ = false;
269 H264POC poc_; 275 H264POC poc_;
270 276
277 // Id number for this instance for memory dumps.
278 int memory_dump_id_ = 0;
279
271 // 280 //
272 // Shared state (set up and torn down on GPU thread). 281 // Shared state (set up and torn down on GPU thread).
273 // 282 //
274 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; 283 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_;
275 base::WeakPtr<VTVideoDecodeAccelerator> weak_this_; 284 base::WeakPtr<VTVideoDecodeAccelerator> weak_this_;
276 base::Thread decoder_thread_; 285 base::Thread decoder_thread_;
277 286
278 // Declared last to ensure that all weak pointers are invalidated before 287 // Declared last to ensure that all weak pointers are invalidated before
279 // other destructors run. 288 // other destructors run.
280 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_; 289 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_;
281 290
282 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); 291 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator);
283 }; 292 };
284 293
285 } // namespace media 294 } // namespace media
286 295
287 #endif // MEDIA_GPU_VT_VIDEO_DECODE_ACCELERATOR_MAC_H_ 296 #endif // MEDIA_GPU_VT_VIDEO_DECODE_ACCELERATOR_MAC_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | media/gpu/vt_video_decode_accelerator_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698