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

Unified Diff: media/filters/vpx_video_decoder.cc

Issue 114853002: media: Enabling direct rendering for VP9 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding some comments. Created 7 years 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
« media/filters/vpx_video_decoder.h ('K') | « media/filters/vpx_video_decoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/vpx_video_decoder.cc
diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc
index e270335504a523131f55f0f05325f98eeb79806d..97a48e5b6a399f8ec5fe08b69046c2ec2a74c56f 100644
--- a/media/filters/vpx_video_decoder.cc
+++ b/media/filters/vpx_video_decoder.cc
@@ -31,6 +31,7 @@
extern "C" {
#include "third_party/libvpx/source/libvpx/vpx/vpx_decoder.h"
#include "third_party/libvpx/source/libvpx/vpx/vp8dx.h"
+#include "third_party/libvpx/source/libvpx/vpx/vpx_external_frame_buffer.h"
fgalligan1 2013/12/16 19:38:43 This include should be before vp8dx
vignesh 2013/12/16 21:10:57 Done.
}
namespace media {
@@ -73,7 +74,8 @@ VpxVideoDecoder::VpxVideoDecoder(
weak_factory_(this),
state_(kUninitialized),
vpx_codec_(NULL),
- vpx_codec_alpha_(NULL) {
+ vpx_codec_alpha_(NULL),
+ frame_buffers_(NULL) {
}
VpxVideoDecoder::~VpxVideoDecoder() {
@@ -124,6 +126,21 @@ static vpx_codec_ctx* InitializeVpxContext(vpx_codec_ctx* context,
return context;
}
+int32 VpxVideoDecoder::ReallocVP9FrameBuffer(void *user_priv, size_t new_size,
+ vpx_codec_frame_buffer *fb) {
+ if (!fb)
+ return -1;
+ if (fb->data)
+ delete[] fb->data;
+ fb->data = new uint8[new_size];
+ if (!fb->data) {
+ fb->size = 0;
+ return -1;
+ }
+ fb->size = new_size;
+ return VPX_CODEC_OK;
+}
+
bool VpxVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config) {
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
bool can_handle = false;
@@ -142,6 +159,20 @@ bool VpxVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config) {
if (!vpx_codec_)
return false;
+ // We use our own buffers for VP9 so that there is no need to copy data after
+ // decoding.
+ if (config.codec() == kCodecVP9) {
fgalligan1 2013/12/16 19:38:43 You are going to have to add a check of the ABI he
vignesh 2013/12/16 21:10:57 Done.
+ frame_buffers_ = new vpx_codec_frame_buffer[kVP9MaxFrameBuffers]();
fgalligan1 2013/12/16 19:38:43 parenthesis are not needed.
vignesh 2013/12/16 21:10:57 new operator without paranthesis will not zero ini
+ if (vpx_codec_set_frame_buffers(vpx_codec_,
+ frame_buffers_,
+ kVP9MaxFrameBuffers,
+ VpxVideoDecoder::ReallocVP9FrameBuffer,
+ NULL)) {
+ LOG(ERROR) << "Failed to configure external buffers.";
+ return false;
+ }
+ }
+
if (config.format() == VideoFrame::YV12A) {
vpx_codec_alpha_ = InitializeVpxContext(vpx_codec_alpha_, config);
if (!vpx_codec_alpha_)
@@ -156,6 +187,12 @@ void VpxVideoDecoder::CloseDecoder() {
vpx_codec_destroy(vpx_codec_);
delete vpx_codec_;
vpx_codec_ = NULL;
+ if (frame_buffers_) {
+ for (int i = 0; i < kVP9MaxFrameBuffers; i++)
+ delete[] frame_buffers_[i].data;
+ delete[] frame_buffers_;
+ frame_buffers_ = NULL;
+ }
}
if (vpx_codec_alpha_) {
vpx_codec_destroy(vpx_codec_alpha_);
@@ -342,6 +379,21 @@ void VpxVideoDecoder::CopyVpxImageTo(const vpx_image* vpx_image,
gfx::Size size(vpx_image->d_w, vpx_image->d_h);
+ if (!vpx_codec_alpha_) {
+ *video_frame = VideoFrame::WrapExternalYuvData(
+ VideoFrame::YV12,
+ size, gfx::Rect(size), config_.natural_size(),
+ vpx_image->stride[VPX_PLANE_Y],
+ vpx_image->stride[VPX_PLANE_U],
+ vpx_image->stride[VPX_PLANE_V],
+ vpx_image->planes[VPX_PLANE_Y],
+ vpx_image->planes[VPX_PLANE_U],
+ vpx_image->planes[VPX_PLANE_V],
+ kNoTimestamp(),
+ base::Closure());
+ return;
+ }
+
*video_frame = frame_pool_.CreateFrame(
vpx_codec_alpha_ ? VideoFrame::YV12A : VideoFrame::YV12,
size,
@@ -361,8 +413,6 @@ void VpxVideoDecoder::CopyVpxImageTo(const vpx_image* vpx_image,
vpx_image->stride[VPX_PLANE_V],
(vpx_image->d_h + 1) / 2,
video_frame->get());
- if (!vpx_codec_alpha_)
- return;
if (!vpx_image_alpha) {
MakeOpaqueAPlane(
vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get());
« media/filters/vpx_video_decoder.h ('K') | « media/filters/vpx_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698