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

Unified Diff: content/browser/renderer_host/gpu_jpeg_decoder.h

Issue 1016773002: MJPEG acceleration for video capture using VAAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/gpu_jpeg_decoder.h
diff --git a/content/browser/renderer_host/gpu_jpeg_decoder.h b/content/browser/renderer_host/gpu_jpeg_decoder.h
new file mode 100644
index 0000000000000000000000000000000000000000..bddbbb61081137fcc01c016a7aca1b87b7a8e459
--- /dev/null
+++ b/content/browser/renderer_host/gpu_jpeg_decoder.h
@@ -0,0 +1,113 @@
+// Copyright 2015 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.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_GPU_JPEG_DECODER_H_
+#define CONTENT_BROWSER_RENDERER_HOST_GPU_JPEG_DECODER_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/synchronization/waitable_event.h"
+#include "base/threading/thread.h"
+#include "content/common/content_export.h"
+#include "media/video/capture/video_capture_device.h"
+#include "media/video/jpeg_decode_accelerator.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace media {
+class VideoFrame;
+}
+
+namespace content {
+
+// Adapter to GpuJpegDecodeAccelerator for VideoCaptureDevice::Client. It takes
+// care of GpuJpegDecodeAccelerator creation, shared memory, and threading
+// issues.
+//
+// All public methods, if not specified, are called on the same thread.
wuchengli 2015/05/13 15:04:06 s/are/should/. All public methods except JpegDeco
kcwu 2015/05/25 18:20:34 Done.
+class CONTENT_EXPORT GpuJpegDecoder
+ : public media::JpegDecodeAccelerator::Client,
+ public base::NonThreadSafe {
+ public:
+ typedef base::Callback<void(
+ scoped_ptr<media::VideoCaptureDevice::Client::Buffer>,
+ const scoped_refptr<media::VideoFrame>&,
+ const base::TimeTicks&)> DecodeDoneCB;
+ typedef base::Callback<void(const std::string&)> ErrorCB;
+
+ // Returns true if JPEG hardware decoding is supported on this device.
+ static bool Supported();
+
+ // |decode_done_cb| is called when decode succeed.
+ // |error_cb| is called when error.
+ GpuJpegDecoder(const DecodeDoneCB& decode_done_cb, const ErrorCB& error_cb);
+ ~GpuJpegDecoder();
+
+ // Creates and intializes decoder in GPU side. Returns falses if failed.
+ bool Initialize();
+
+ // Decodes a JPEG picture.
+ void DecodeCapturedData(
+ const uint8* data,
+ size_t in_buffer_size,
+ const media::VideoCaptureFormat& frame_format,
+ const base::TimeTicks& timestamp,
+ scoped_ptr<media::VideoCaptureDevice::Client::Buffer> out_buffer);
+
+ // JpegDecodeAccelerator::Client implementation.
+ // These will be called on jpeg thread.
+ virtual void VideoFrameReady(int32_t buffer_id) override;
+ virtual void NotifyError(int32_t buffer_id,
+ media::JpegDecodeAccelerator::Error error) override;
+
+ private:
+ // Returns true if the decoding of last frame is not finished yet.
+ bool IsDecoding();
+
+ void CreateDecoderOnJpegThread();
wuchengli 2015/05/13 15:04:05 s/CreateDecoderOnJpegThread/InitializeOnJpegThread
kcwu 2015/05/25 18:20:35 Done.
+ void DecodeCapturedDataOnJpegThread(
+ const uint8* data,
+ size_t in_buffer_size,
+ const media::VideoCaptureFormat& frame_format,
+ const base::TimeTicks& timestamp,
+ scoped_ptr<media::VideoCaptureDevice::Client::Buffer> out_buffer);
+
+ base::Thread jpeg_thread_;
+ scoped_refptr<base::MessageLoopProxy> jpeg_thread_proxy_;
+ base::WaitableEvent create_event_;
+ base::WaitableEvent decode_event_;
wuchengli 2015/05/13 15:04:06 |create_event_| is only used once. Let's combine t
kcwu 2015/05/25 18:20:34 Done.
+
+ // The underlying JPEG decode accelerator.
+ scoped_ptr<media::JpegDecodeAccelerator> decoder_;
+
+ // The callback when decode succeed.
wuchengli 2015/05/13 15:04:05 s/succeed/succeeds/. s/callback/callback to run/
kcwu 2015/05/25 18:20:35 Done.
+ DecodeDoneCB decode_done_cb_;
+
+ // The callback when error.
wuchengli 2015/05/13 15:04:05 s/callback/callback to run/. s/error/an error occu
kcwu 2015/05/25 18:20:35 Done.
+ ErrorCB error_cb_;
+
+ // The closure of |decode_done_cb_| with bound parameters.
+ base::Closure decode_done_closure_;
+
+ // Next id for |in_buffer_|.
+ int32 next_bitstream_buffer_id_;
+
+ // Shared memory to store JPEG stream buffer. |in_buffer_| is backed by this.
+ scoped_ptr<base::SharedMemory> in_shared_memory_;
+
+ // JPEG stream buffer as input to JpegDecodeAccelerator.
+ media::BitstreamBuffer in_buffer_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuJpegDecoder);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_GPU_JPEG_DECODER_H_
« no previous file with comments | « no previous file | content/browser/renderer_host/gpu_jpeg_decoder.cc » ('j') | content/browser/renderer_host/gpu_jpeg_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698