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

Side by Side Diff: media/gpu/vaapi_video_decode_accelerator.cc

Issue 2926593002: V4L2SVDA/VAAPIVDA: use visible size from decoder and pass to client (Closed)
Patch Set: V4L2SVDA/VAAPIVDA: use visible size from decoder and pass to client Created 3 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "media/gpu/vaapi_video_decode_accelerator.h" 5 #include "media/gpu/vaapi_video_decode_accelerator.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } while (0) 60 } while (0)
61 61
62 class VaapiVideoDecodeAccelerator::VaapiDecodeSurface 62 class VaapiVideoDecodeAccelerator::VaapiDecodeSurface
63 : public base::RefCountedThreadSafe<VaapiDecodeSurface> { 63 : public base::RefCountedThreadSafe<VaapiDecodeSurface> {
64 public: 64 public:
65 VaapiDecodeSurface(int32_t bitstream_id, 65 VaapiDecodeSurface(int32_t bitstream_id,
66 const scoped_refptr<VASurface>& va_surface); 66 const scoped_refptr<VASurface>& va_surface);
67 67
68 int32_t bitstream_id() const { return bitstream_id_; } 68 int32_t bitstream_id() const { return bitstream_id_; }
69 scoped_refptr<VASurface> va_surface() { return va_surface_; } 69 scoped_refptr<VASurface> va_surface() { return va_surface_; }
70 gfx::Rect visible_rect() const { return visible_rect_; }
71
72 void SetVisibleRect(const gfx::Rect& visible_rect) {
73 visible_rect_ = visible_rect;
74 }
70 75
71 private: 76 private:
72 friend class base::RefCountedThreadSafe<VaapiDecodeSurface>; 77 friend class base::RefCountedThreadSafe<VaapiDecodeSurface>;
73 ~VaapiDecodeSurface(); 78 ~VaapiDecodeSurface();
74 79
75 int32_t bitstream_id_; 80 int32_t bitstream_id_;
76 scoped_refptr<VASurface> va_surface_; 81 scoped_refptr<VASurface> va_surface_;
82 gfx::Rect visible_rect_;
77 }; 83 };
78 84
79 VaapiVideoDecodeAccelerator::VaapiDecodeSurface::VaapiDecodeSurface( 85 VaapiVideoDecodeAccelerator::VaapiDecodeSurface::VaapiDecodeSurface(
80 int32_t bitstream_id, 86 int32_t bitstream_id,
81 const scoped_refptr<VASurface>& va_surface) 87 const scoped_refptr<VASurface>& va_surface)
82 : bitstream_id_(bitstream_id), va_surface_(va_surface) {} 88 : bitstream_id_(bitstream_id), va_surface_(va_surface) {}
83 89
84 VaapiVideoDecodeAccelerator::VaapiDecodeSurface::~VaapiDecodeSurface() {} 90 VaapiVideoDecodeAccelerator::VaapiDecodeSurface::~VaapiDecodeSurface() {}
85 91
86 class VaapiH264Picture : public H264Picture { 92 class VaapiH264Picture : public H264Picture {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 135
130 bool SubmitSlice(const H264PPS* pps, 136 bool SubmitSlice(const H264PPS* pps,
131 const H264SliceHeader* slice_hdr, 137 const H264SliceHeader* slice_hdr,
132 const H264Picture::Vector& ref_pic_list0, 138 const H264Picture::Vector& ref_pic_list0,
133 const H264Picture::Vector& ref_pic_list1, 139 const H264Picture::Vector& ref_pic_list1,
134 const scoped_refptr<H264Picture>& pic, 140 const scoped_refptr<H264Picture>& pic,
135 const uint8_t* data, 141 const uint8_t* data,
136 size_t size) override; 142 size_t size) override;
137 143
138 bool SubmitDecode(const scoped_refptr<H264Picture>& pic) override; 144 bool SubmitDecode(const scoped_refptr<H264Picture>& pic) override;
139 bool OutputPicture(const scoped_refptr<H264Picture>& pic) override; 145 bool OutputPicture(const scoped_refptr<H264Picture>& pic,
146 const gfx::Rect& visible_rect) override;
140 147
141 void Reset() override; 148 void Reset() override;
142 149
143 private: 150 private:
144 scoped_refptr<VaapiDecodeSurface> H264PictureToVaapiDecodeSurface( 151 scoped_refptr<VaapiDecodeSurface> H264PictureToVaapiDecodeSurface(
145 const scoped_refptr<H264Picture>& pic); 152 const scoped_refptr<H264Picture>& pic);
146 153
147 void FillVAPicture(VAPictureH264* va_pic, scoped_refptr<H264Picture> pic); 154 void FillVAPicture(VAPictureH264* va_pic, scoped_refptr<H264Picture> pic);
148 int FillVARefFramesFromDPB(const H264DPB& dpb, 155 int FillVARefFramesFromDPB(const H264DPB& dpb,
149 VAPictureH264* va_pics, 156 VAPictureH264* va_pics,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 197
191 // VP8Decoder::VP8Accelerator implementation. 198 // VP8Decoder::VP8Accelerator implementation.
192 scoped_refptr<VP8Picture> CreateVP8Picture() override; 199 scoped_refptr<VP8Picture> CreateVP8Picture() override;
193 200
194 bool SubmitDecode(const scoped_refptr<VP8Picture>& pic, 201 bool SubmitDecode(const scoped_refptr<VP8Picture>& pic,
195 const Vp8FrameHeader* frame_hdr, 202 const Vp8FrameHeader* frame_hdr,
196 const scoped_refptr<VP8Picture>& last_frame, 203 const scoped_refptr<VP8Picture>& last_frame,
197 const scoped_refptr<VP8Picture>& golden_frame, 204 const scoped_refptr<VP8Picture>& golden_frame,
198 const scoped_refptr<VP8Picture>& alt_frame) override; 205 const scoped_refptr<VP8Picture>& alt_frame) override;
199 206
200 bool OutputPicture(const scoped_refptr<VP8Picture>& pic) override; 207 bool OutputPicture(const scoped_refptr<VP8Picture>& pic,
208 const gfx::Rect& visible_rect) override;
201 209
202 private: 210 private:
203 scoped_refptr<VaapiDecodeSurface> VP8PictureToVaapiDecodeSurface( 211 scoped_refptr<VaapiDecodeSurface> VP8PictureToVaapiDecodeSurface(
204 const scoped_refptr<VP8Picture>& pic); 212 const scoped_refptr<VP8Picture>& pic);
205 213
206 VaapiWrapper* vaapi_wrapper_; 214 VaapiWrapper* vaapi_wrapper_;
207 VaapiVideoDecodeAccelerator* vaapi_dec_; 215 VaapiVideoDecodeAccelerator* vaapi_dec_;
208 216
209 DISALLOW_COPY_AND_ASSIGN(VaapiVP8Accelerator); 217 DISALLOW_COPY_AND_ASSIGN(VaapiVP8Accelerator);
210 }; 218 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 252
245 // VP9Decoder::VP9Accelerator implementation. 253 // VP9Decoder::VP9Accelerator implementation.
246 scoped_refptr<VP9Picture> CreateVP9Picture() override; 254 scoped_refptr<VP9Picture> CreateVP9Picture() override;
247 255
248 bool SubmitDecode(const scoped_refptr<VP9Picture>& pic, 256 bool SubmitDecode(const scoped_refptr<VP9Picture>& pic,
249 const Vp9SegmentationParams& seg, 257 const Vp9SegmentationParams& seg,
250 const Vp9LoopFilterParams& lf, 258 const Vp9LoopFilterParams& lf,
251 const std::vector<scoped_refptr<VP9Picture>>& ref_pictures, 259 const std::vector<scoped_refptr<VP9Picture>>& ref_pictures,
252 const base::Closure& done_cb) override; 260 const base::Closure& done_cb) override;
253 261
254 bool OutputPicture(const scoped_refptr<VP9Picture>& pic) override; 262 bool OutputPicture(const scoped_refptr<VP9Picture>& pic,
263 const gfx::Rect& visible_rect) override;
255 264
256 bool IsFrameContextRequired() const override { return false; } 265 bool IsFrameContextRequired() const override { return false; }
257 266
258 bool GetFrameContext(const scoped_refptr<VP9Picture>& pic, 267 bool GetFrameContext(const scoped_refptr<VP9Picture>& pic,
259 Vp9FrameContext* frame_ctx) override; 268 Vp9FrameContext* frame_ctx) override;
260 269
261 private: 270 private:
262 scoped_refptr<VaapiDecodeSurface> VP9PictureToVaapiDecodeSurface( 271 scoped_refptr<VaapiDecodeSurface> VP9PictureToVaapiDecodeSurface(
263 const scoped_refptr<VP9Picture>& pic); 272 const scoped_refptr<VP9Picture>& pic);
264 273
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 decoder_thread_task_runner_ = decoder_thread_.task_runner(); 411 decoder_thread_task_runner_ = decoder_thread_.task_runner();
403 412
404 state_ = kIdle; 413 state_ = kIdle;
405 output_mode_ = config.output_mode; 414 output_mode_ = config.output_mode;
406 return true; 415 return true;
407 } 416 }
408 417
409 void VaapiVideoDecodeAccelerator::OutputPicture( 418 void VaapiVideoDecodeAccelerator::OutputPicture(
410 const scoped_refptr<VASurface>& va_surface, 419 const scoped_refptr<VASurface>& va_surface,
411 int32_t input_id, 420 int32_t input_id,
421 gfx::Rect visible_rect,
412 VaapiPicture* picture) { 422 VaapiPicture* picture) {
413 DCHECK(task_runner_->BelongsToCurrentThread()); 423 DCHECK(task_runner_->BelongsToCurrentThread());
414 424
415 int32_t output_id = picture->picture_buffer_id(); 425 int32_t output_id = picture->picture_buffer_id();
416 426
417 TRACE_EVENT2("Video Decoder", "VAVDA::OutputSurface", "input_id", input_id, 427 TRACE_EVENT2("Video Decoder", "VAVDA::OutputSurface", "input_id", input_id,
418 "output_id", output_id); 428 "output_id", output_id);
419 429
420 DVLOG(3) << "Outputting VASurface " << va_surface->id() 430 DVLOG(3) << "Outputting VASurface " << va_surface->id()
421 << " into pixmap bound to picture buffer id " << output_id; 431 << " into pixmap bound to picture buffer id " << output_id;
422 432
423 RETURN_AND_NOTIFY_ON_FAILURE(picture->DownloadFromSurface(va_surface), 433 RETURN_AND_NOTIFY_ON_FAILURE(picture->DownloadFromSurface(va_surface),
424 "Failed putting surface into pixmap", 434 "Failed putting surface into pixmap",
425 PLATFORM_FAILURE, ); 435 PLATFORM_FAILURE, );
426 436
427 // Notify the client a picture is ready to be displayed. 437 // Notify the client a picture is ready to be displayed.
428 ++num_frames_at_client_; 438 ++num_frames_at_client_;
429 TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_); 439 TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_);
430 DVLOG(4) << "Notifying output picture id " << output_id 440 DVLOG(4) << "Notifying output picture id " << output_id << " for input "
431 << " for input " << input_id << " is ready"; 441 << input_id
432 // TODO(posciak): Use visible size from decoder here instead 442 << " is ready. visible rect: " << visible_rect.ToString();
433 // (crbug.com/402760). Passing (0, 0) results in the client using the
434 // visible size extracted from the container instead.
435 // TODO(hubbe): Use the correct color space. http://crbug.com/647725 443 // TODO(hubbe): Use the correct color space. http://crbug.com/647725
436 if (client_) 444 if (client_)
437 client_->PictureReady(Picture(output_id, input_id, gfx::Rect(0, 0), 445 client_->PictureReady(Picture(output_id, input_id, visible_rect,
438 gfx::ColorSpace(), picture->AllowOverlay())); 446 gfx::ColorSpace(), picture->AllowOverlay()));
439 } 447 }
440 448
441 void VaapiVideoDecodeAccelerator::TryOutputSurface() { 449 void VaapiVideoDecodeAccelerator::TryOutputSurface() {
442 DCHECK(task_runner_->BelongsToCurrentThread()); 450 DCHECK(task_runner_->BelongsToCurrentThread());
443 451
444 // Handle Destroy() arriving while pictures are queued for output. 452 // Handle Destroy() arriving while pictures are queued for output.
445 if (!client_) 453 if (!client_)
446 return; 454 return;
447 455
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 1144
1137 { 1145 {
1138 base::AutoLock auto_lock(lock_); 1146 base::AutoLock auto_lock(lock_);
1139 // Drop any requests to output if we are resetting or being destroyed. 1147 // Drop any requests to output if we are resetting or being destroyed.
1140 if (state_ == kResetting || state_ == kDestroying) 1148 if (state_ == kResetting || state_ == kDestroying)
1141 return; 1149 return;
1142 } 1150 }
1143 1151
1144 pending_output_cbs_.push( 1152 pending_output_cbs_.push(
1145 base::Bind(&VaapiVideoDecodeAccelerator::OutputPicture, weak_this_, 1153 base::Bind(&VaapiVideoDecodeAccelerator::OutputPicture, weak_this_,
1146 dec_surface->va_surface(), dec_surface->bitstream_id())); 1154 dec_surface->va_surface(), dec_surface->bitstream_id(),
1155 dec_surface->visible_rect()));
1147 1156
1148 TryOutputSurface(); 1157 TryOutputSurface();
1149 } 1158 }
1150 1159
1151 scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> 1160 scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>
1152 VaapiVideoDecodeAccelerator::CreateSurface() { 1161 VaapiVideoDecodeAccelerator::CreateSurface() {
1153 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); 1162 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
1154 base::AutoLock auto_lock(lock_); 1163 base::AutoLock auto_lock(lock_);
1155 1164
1156 if (available_va_surfaces_.empty()) 1165 if (available_va_surfaces_.empty())
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitDecode( 1425 bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitDecode(
1417 const scoped_refptr<H264Picture>& pic) { 1426 const scoped_refptr<H264Picture>& pic) {
1418 DVLOG(4) << "Decoding POC " << pic->pic_order_cnt; 1427 DVLOG(4) << "Decoding POC " << pic->pic_order_cnt;
1419 scoped_refptr<VaapiDecodeSurface> dec_surface = 1428 scoped_refptr<VaapiDecodeSurface> dec_surface =
1420 H264PictureToVaapiDecodeSurface(pic); 1429 H264PictureToVaapiDecodeSurface(pic);
1421 1430
1422 return vaapi_dec_->DecodeSurface(dec_surface); 1431 return vaapi_dec_->DecodeSurface(dec_surface);
1423 } 1432 }
1424 1433
1425 bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::OutputPicture( 1434 bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::OutputPicture(
1426 const scoped_refptr<H264Picture>& pic) { 1435 const scoped_refptr<H264Picture>& pic,
1436 const gfx::Rect& visible_rect) {
1427 scoped_refptr<VaapiDecodeSurface> dec_surface = 1437 scoped_refptr<VaapiDecodeSurface> dec_surface =
1428 H264PictureToVaapiDecodeSurface(pic); 1438 H264PictureToVaapiDecodeSurface(pic);
1429 1439 dec_surface->SetVisibleRect(visible_rect);
1430 vaapi_dec_->SurfaceReady(dec_surface); 1440 vaapi_dec_->SurfaceReady(dec_surface);
1431 1441
1432 return true; 1442 return true;
1433 } 1443 }
1434 1444
1435 void VaapiVideoDecodeAccelerator::VaapiH264Accelerator::Reset() { 1445 void VaapiVideoDecodeAccelerator::VaapiH264Accelerator::Reset() {
1436 vaapi_wrapper_->DestroyPendingBuffers(); 1446 vaapi_wrapper_->DestroyPendingBuffers();
1437 } 1447 }
1438 1448
1439 scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> 1449 scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 frame_hdr->frame_size, non_const_ptr)) 1713 frame_hdr->frame_size, non_const_ptr))
1704 return false; 1714 return false;
1705 1715
1706 scoped_refptr<VaapiDecodeSurface> dec_surface = 1716 scoped_refptr<VaapiDecodeSurface> dec_surface =
1707 VP8PictureToVaapiDecodeSurface(pic); 1717 VP8PictureToVaapiDecodeSurface(pic);
1708 1718
1709 return vaapi_dec_->DecodeSurface(dec_surface); 1719 return vaapi_dec_->DecodeSurface(dec_surface);
1710 } 1720 }
1711 1721
1712 bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::OutputPicture( 1722 bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::OutputPicture(
1713 const scoped_refptr<VP8Picture>& pic) { 1723 const scoped_refptr<VP8Picture>& pic,
1724 const gfx::Rect& visible_rect) {
1714 scoped_refptr<VaapiDecodeSurface> dec_surface = 1725 scoped_refptr<VaapiDecodeSurface> dec_surface =
1715 VP8PictureToVaapiDecodeSurface(pic); 1726 VP8PictureToVaapiDecodeSurface(pic);
1716 1727 dec_surface->SetVisibleRect(visible_rect);
1717 vaapi_dec_->SurfaceReady(dec_surface); 1728 vaapi_dec_->SurfaceReady(dec_surface);
1718 return true; 1729 return true;
1719 } 1730 }
1720 1731
1721 scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> 1732 scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>
1722 VaapiVideoDecodeAccelerator::VaapiVP8Accelerator:: 1733 VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::
1723 VP8PictureToVaapiDecodeSurface(const scoped_refptr<VP8Picture>& pic) { 1734 VP8PictureToVaapiDecodeSurface(const scoped_refptr<VP8Picture>& pic) {
1724 VaapiVP8Picture* vaapi_pic = pic->AsVaapiVP8Picture(); 1735 VaapiVP8Picture* vaapi_pic = pic->AsVaapiVP8Picture();
1725 CHECK(vaapi_pic); 1736 CHECK(vaapi_pic);
1726 return vaapi_pic->dec_surface(); 1737 return vaapi_pic->dec_surface();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 frame_hdr->frame_size, non_const_ptr)) 1878 frame_hdr->frame_size, non_const_ptr))
1868 return false; 1879 return false;
1869 1880
1870 scoped_refptr<VaapiDecodeSurface> dec_surface = 1881 scoped_refptr<VaapiDecodeSurface> dec_surface =
1871 VP9PictureToVaapiDecodeSurface(pic); 1882 VP9PictureToVaapiDecodeSurface(pic);
1872 1883
1873 return vaapi_dec_->DecodeSurface(dec_surface); 1884 return vaapi_dec_->DecodeSurface(dec_surface);
1874 } 1885 }
1875 1886
1876 bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::OutputPicture( 1887 bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::OutputPicture(
1877 const scoped_refptr<VP9Picture>& pic) { 1888 const scoped_refptr<VP9Picture>& pic,
1889 const gfx::Rect& visible_rect) {
1878 scoped_refptr<VaapiDecodeSurface> dec_surface = 1890 scoped_refptr<VaapiDecodeSurface> dec_surface =
1879 VP9PictureToVaapiDecodeSurface(pic); 1891 VP9PictureToVaapiDecodeSurface(pic);
1880 1892 dec_surface->SetVisibleRect(visible_rect);
1881 vaapi_dec_->SurfaceReady(dec_surface); 1893 vaapi_dec_->SurfaceReady(dec_surface);
1882 return true; 1894 return true;
1883 } 1895 }
1884 1896
1885 bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::GetFrameContext( 1897 bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::GetFrameContext(
1886 const scoped_refptr<VP9Picture>& pic, 1898 const scoped_refptr<VP9Picture>& pic,
1887 Vp9FrameContext* frame_ctx) { 1899 Vp9FrameContext* frame_ctx) {
1888 NOTIMPLEMENTED() << "Frame context update not supported"; 1900 NOTIMPLEMENTED() << "Frame context update not supported";
1889 return false; 1901 return false;
1890 } 1902 }
1891 1903
1892 scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> 1904 scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>
1893 VaapiVideoDecodeAccelerator::VaapiVP9Accelerator:: 1905 VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::
1894 VP9PictureToVaapiDecodeSurface(const scoped_refptr<VP9Picture>& pic) { 1906 VP9PictureToVaapiDecodeSurface(const scoped_refptr<VP9Picture>& pic) {
1895 VaapiVP9Picture* vaapi_pic = pic->AsVaapiVP9Picture(); 1907 VaapiVP9Picture* vaapi_pic = pic->AsVaapiVP9Picture();
1896 CHECK(vaapi_pic); 1908 CHECK(vaapi_pic);
1897 return vaapi_pic->dec_surface(); 1909 return vaapi_pic->dec_surface();
1898 } 1910 }
1899 1911
1900 // static 1912 // static
1901 VideoDecodeAccelerator::SupportedProfiles 1913 VideoDecodeAccelerator::SupportedProfiles
1902 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1914 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1903 return VaapiWrapper::GetSupportedDecodeProfiles(); 1915 return VaapiWrapper::GetSupportedDecodeProfiles();
1904 } 1916 }
1905 1917
1906 } // namespace media 1918 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698