Commit 7ec9aa71 authored by liberato@chromium.org's avatar liberato@chromium.org Committed by Commit Bot

Set visible rect properly in D3D11VideoDecoder.

This makes D3D11VideoDecoder use the visible rect from the H264
decoder when constructing a VideoFrame.

Change-Id: Ic8a3095a86bb9282a6d1fcf06aed1cf6aeef60d7
Reviewed-on: https://chromium-review.googlesource.com/1217354Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Frank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590078}
parent 88aa6ccf
...@@ -552,7 +552,7 @@ bool D3D11H264Accelerator::OutputPicture( ...@@ -552,7 +552,7 @@ bool D3D11H264Accelerator::OutputPicture(
scoped_refptr<D3D11H264Picture> our_pic( scoped_refptr<D3D11H264Picture> our_pic(
static_cast<D3D11H264Picture*>(pic.get())); static_cast<D3D11H264Picture*>(pic.get()));
client_->OutputResult(our_pic->picture, pic->get_colorspace()); client_->OutputResult(pic.get(), our_pic->picture);
return true; return true;
} }
......
...@@ -467,28 +467,28 @@ D3D11PictureBuffer* D3D11VideoDecoder::GetPicture() { ...@@ -467,28 +467,28 @@ D3D11PictureBuffer* D3D11VideoDecoder::GetPicture() {
return nullptr; return nullptr;
} }
void D3D11VideoDecoder::OutputResult(D3D11PictureBuffer* buffer, void D3D11VideoDecoder::OutputResult(const CodecPicture* picture,
const VideoColorSpace& buffer_colorspace) { D3D11PictureBuffer* picture_buffer) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
buffer->set_in_client_use(true); picture_buffer->set_in_client_use(true);
// Note: The pixel format doesn't matter. // Note: The pixel format doesn't matter.
gfx::Rect visible_rect(buffer->size()); gfx::Rect visible_rect(picture->visible_rect());
// TODO(liberato): Pixel aspect ratio should come from the VideoDecoderConfig // TODO(liberato): Pixel aspect ratio should come from the VideoDecoderConfig
// (except when it should come from the SPS). // (except when it should come from the SPS).
// https://crbug.com/837337 // https://crbug.com/837337
double pixel_aspect_ratio = 1.0; double pixel_aspect_ratio = 1.0;
base::TimeDelta timestamp = buffer->timestamp_; base::TimeDelta timestamp = picture_buffer->timestamp_;
scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTextures( scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTextures(
PIXEL_FORMAT_NV12, buffer->mailbox_holders(), PIXEL_FORMAT_NV12, picture_buffer->mailbox_holders(),
VideoFrame::ReleaseMailboxCB(), visible_rect.size(), visible_rect, VideoFrame::ReleaseMailboxCB(), visible_rect.size(), visible_rect,
GetNaturalSize(visible_rect, pixel_aspect_ratio), timestamp); GetNaturalSize(visible_rect, pixel_aspect_ratio), timestamp);
// TODO(liberato): bind this to the gpu main thread. // TODO(liberato): bind this to the gpu main thread.
frame->SetReleaseMailboxCB(media::BindToCurrentLoop( frame->SetReleaseMailboxCB(media::BindToCurrentLoop(
base::BindOnce(&D3D11VideoDecoderImpl::OnMailboxReleased, impl_weak_, base::BindOnce(&D3D11VideoDecoderImpl::OnMailboxReleased, impl_weak_,
scoped_refptr<D3D11PictureBuffer>(buffer)))); scoped_refptr<D3D11PictureBuffer>(picture_buffer))));
frame->metadata()->SetBoolean(VideoFrameMetadata::POWER_EFFICIENT, true); frame->metadata()->SetBoolean(VideoFrameMetadata::POWER_EFFICIENT, true);
// For NV12, overlay is allowed by default. If the decoder is going to support // For NV12, overlay is allowed by default. If the decoder is going to support
// non-NV12 textures, then this may have to be conditionally set. Also note // non-NV12 textures, then this may have to be conditionally set. Also note
...@@ -500,7 +500,7 @@ void D3D11VideoDecoder::OutputResult(D3D11PictureBuffer* buffer, ...@@ -500,7 +500,7 @@ void D3D11VideoDecoder::OutputResult(D3D11PictureBuffer* buffer,
frame->metadata()->SetBoolean(VideoFrameMetadata::REQUIRE_OVERLAY, true); frame->metadata()->SetBoolean(VideoFrameMetadata::REQUIRE_OVERLAY, true);
} }
frame->set_color_space(buffer_colorspace.ToGfxColorSpace()); frame->set_color_space(picture->get_colorspace().ToGfxColorSpace());
output_cb_.Run(frame); output_cb_.Run(frame);
} }
......
...@@ -65,8 +65,8 @@ class MEDIA_GPU_EXPORT D3D11VideoDecoder : public VideoDecoder, ...@@ -65,8 +65,8 @@ class MEDIA_GPU_EXPORT D3D11VideoDecoder : public VideoDecoder,
// D3D11VideoDecoderClient implementation. // D3D11VideoDecoderClient implementation.
D3D11PictureBuffer* GetPicture() override; D3D11PictureBuffer* GetPicture() override;
void OutputResult(D3D11PictureBuffer* buffer, void OutputResult(const CodecPicture* picture,
const VideoColorSpace& buffer_colorspace) override; D3D11PictureBuffer* picture_buffer) override;
// Return false |config| definitely isn't going to work, so that we can fail // Return false |config| definitely isn't going to work, so that we can fail
// init without bothering with a thread hop. // init without bothering with a thread hop.
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
namespace media { namespace media {
class CodecPicture;
class D3D11PictureBuffer; class D3D11PictureBuffer;
// Acts as a parent class for the D3D11VideoDecoder to expose // Acts as a parent class for the D3D11VideoDecoder to expose
...@@ -16,8 +17,8 @@ class D3D11PictureBuffer; ...@@ -16,8 +17,8 @@ class D3D11PictureBuffer;
class D3D11VideoDecoderClient { class D3D11VideoDecoderClient {
public: public:
virtual D3D11PictureBuffer* GetPicture() = 0; virtual D3D11PictureBuffer* GetPicture() = 0;
virtual void OutputResult(D3D11PictureBuffer* picture, virtual void OutputResult(const CodecPicture* picture,
const VideoColorSpace& buffer_colorspace) = 0; D3D11PictureBuffer* picture_buffer) = 0;
protected: protected:
virtual ~D3D11VideoDecoderClient() = default; virtual ~D3D11VideoDecoderClient() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment