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

Side by Side Diff: media/gpu/v4l2_slice_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/v4l2_slice_video_decode_accelerator.h" 5 #include "media/gpu/v4l2_slice_video_decode_accelerator.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/videodev2.h> 9 #include <linux/videodev2.h>
10 #include <poll.h> 10 #include <poll.h>
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 793 }
794 794
795 bool V4L2SliceVideoDecodeAccelerator::CreateOutputBuffers() { 795 bool V4L2SliceVideoDecodeAccelerator::CreateOutputBuffers() {
796 DVLOGF(3); 796 DVLOGF(3);
797 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); 797 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
798 DCHECK(!output_streamon_); 798 DCHECK(!output_streamon_);
799 DCHECK(output_buffer_map_.empty()); 799 DCHECK(output_buffer_map_.empty());
800 DCHECK(surfaces_at_display_.empty()); 800 DCHECK(surfaces_at_display_.empty());
801 DCHECK(surfaces_at_device_.empty()); 801 DCHECK(surfaces_at_device_.empty());
802 802
803 visible_size_ = decoder_->GetPicSize(); 803 gfx::Size pic_size = decoder_->GetPicSize();
804 visible_rect_ = decoder_->GetVisibleRect();
804 size_t num_pictures = decoder_->GetRequiredNumOfPictures(); 805 size_t num_pictures = decoder_->GetRequiredNumOfPictures();
805 806
806 DCHECK_GT(num_pictures, 0u); 807 DCHECK_GT(num_pictures, 0u);
807 DCHECK(!visible_size_.IsEmpty()); 808 DCHECK(!pic_size.IsEmpty());
809 DCHECK(!visible_rect_.IsEmpty());
Owen Lin 2017/06/07 06:10:59 As said in previous file, remove the check. Is it
johnylin1 2017/06/07 15:38:37 We may pass visible size from decoder to VDA along
808 810
809 struct v4l2_format format; 811 struct v4l2_format format;
810 memset(&format, 0, sizeof(format)); 812 memset(&format, 0, sizeof(format));
811 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 813 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
812 format.fmt.pix_mp.pixelformat = output_format_fourcc_; 814 format.fmt.pix_mp.pixelformat = output_format_fourcc_;
813 format.fmt.pix_mp.width = visible_size_.width(); 815 format.fmt.pix_mp.width = pic_size.width();
814 format.fmt.pix_mp.height = visible_size_.height(); 816 format.fmt.pix_mp.height = pic_size.height();
815 format.fmt.pix_mp.num_planes = input_planes_count_; 817 format.fmt.pix_mp.num_planes = input_planes_count_;
816 818
817 if (device_->Ioctl(VIDIOC_S_FMT, &format) != 0) { 819 if (device_->Ioctl(VIDIOC_S_FMT, &format) != 0) {
818 PLOGF(ERROR) << "Failed setting format to: " << output_format_fourcc_; 820 PLOGF(ERROR) << "Failed setting format to: " << output_format_fourcc_;
819 NOTIFY_ERROR(PLATFORM_FAILURE); 821 NOTIFY_ERROR(PLATFORM_FAILURE);
820 return false; 822 return false;
821 } 823 }
822 824
823 coded_size_.SetSize(base::checked_cast<int>(format.fmt.pix_mp.width), 825 coded_size_.SetSize(base::checked_cast<int>(format.fmt.pix_mp.width),
824 base::checked_cast<int>(format.fmt.pix_mp.height)); 826 base::checked_cast<int>(format.fmt.pix_mp.height));
825 DCHECK_EQ(coded_size_.width() % 16, 0); 827 DCHECK_EQ(coded_size_.width() % 16, 0);
826 DCHECK_EQ(coded_size_.height() % 16, 0); 828 DCHECK_EQ(coded_size_.height() % 16, 0);
827 829
828 if (!gfx::Rect(coded_size_).Contains(gfx::Rect(visible_size_))) { 830 if (!gfx::Rect(coded_size_).Contains(visible_rect_)) {
Owen Lin 2017/06/07 06:10:59 use pic_size.
johnylin1 2017/06/07 15:38:37 Done.
829 LOGF(ERROR) << "Got invalid adjusted coded size: " 831 LOGF(ERROR) << "Got invalid adjusted coded size: " << coded_size_.ToString()
830 << coded_size_.ToString(); 832 << ", visible rect:" << visible_rect_.ToString();
831 return false; 833 return false;
832 } 834 }
833 835
834 DVLOGF(3) << "buffer_count=" << num_pictures 836 DVLOGF(3) << "buffer_count=" << num_pictures
835 << ", visible size=" << visible_size_.ToString() 837 << ", visible rect=" << visible_rect_.ToString()
836 << ", coded size=" << coded_size_.ToString(); 838 << ", coded size=" << coded_size_.ToString();
837 839
838 // With ALLOCATE mode the client can sample it as RGB and doesn't need to 840 // With ALLOCATE mode the client can sample it as RGB and doesn't need to
839 // know the precise format. 841 // know the precise format.
840 VideoPixelFormat pixel_format = 842 VideoPixelFormat pixel_format =
841 (output_mode_ == Config::OutputMode::IMPORT) 843 (output_mode_ == Config::OutputMode::IMPORT)
842 ? V4L2Device::V4L2PixFmtToVideoPixelFormat(output_format_fourcc_) 844 ? V4L2Device::V4L2PixFmtToVideoPixelFormat(output_format_fourcc_)
843 : PIXEL_FORMAT_UNKNOWN; 845 : PIXEL_FORMAT_UNKNOWN;
844 846
845 child_task_runner_->PostTask( 847 child_task_runner_->PostTask(
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after
3180 surfaces_at_display_ 3182 surfaces_at_display_
3181 .insert(std::make_pair(output_record.picture_id, dec_surface)) 3183 .insert(std::make_pair(output_record.picture_id, dec_surface))
3182 .second; 3184 .second;
3183 DCHECK(inserted); 3185 DCHECK(inserted);
3184 3186
3185 DCHECK(!output_record.at_client); 3187 DCHECK(!output_record.at_client);
3186 DCHECK(!output_record.at_device); 3188 DCHECK(!output_record.at_device);
3187 DCHECK_NE(output_record.picture_id, -1); 3189 DCHECK_NE(output_record.picture_id, -1);
3188 output_record.at_client = true; 3190 output_record.at_client = true;
3189 3191
3190 // TODO(posciak): Use visible size from decoder here instead
3191 // (crbug.com/402760). Passing (0, 0) results in the client using the
3192 // visible size extracted from the container instead.
3193 // TODO(hubbe): Insert correct color space. http://crbug.com/647725 3192 // TODO(hubbe): Insert correct color space. http://crbug.com/647725
3194 Picture picture(output_record.picture_id, dec_surface->bitstream_id(), 3193 Picture picture(output_record.picture_id, dec_surface->bitstream_id(),
3195 gfx::Rect(0, 0), gfx::ColorSpace(), false); 3194 visible_rect_, gfx::ColorSpace(), false);
3196 DVLOGF(3) << dec_surface->ToString() 3195 DVLOGF(3) << dec_surface->ToString()
3197 << ", bitstream_id: " << picture.bitstream_buffer_id() 3196 << ", bitstream_id: " << picture.bitstream_buffer_id()
3198 << ", picture_id: " << picture.picture_buffer_id(); 3197 << ", picture_id: " << picture.picture_buffer_id()
3198 << ", visible_rect: " << visible_rect_.ToString();
3199 pending_picture_ready_.push(PictureRecord(output_record.cleared, picture)); 3199 pending_picture_ready_.push(PictureRecord(output_record.cleared, picture));
3200 SendPictureReady(); 3200 SendPictureReady();
3201 output_record.cleared = true; 3201 output_record.cleared = true;
3202 } 3202 }
3203 3203
3204 scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface> 3204 scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>
3205 V4L2SliceVideoDecodeAccelerator::CreateSurface() { 3205 V4L2SliceVideoDecodeAccelerator::CreateSurface() {
3206 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); 3206 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
3207 DCHECK_EQ(state_, kDecoding); 3207 DCHECK_EQ(state_, kDecoding);
3208 3208
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3295 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() { 3295 V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles() {
3296 scoped_refptr<V4L2Device> device = V4L2Device::Create(); 3296 scoped_refptr<V4L2Device> device = V4L2Device::Create();
3297 if (!device) 3297 if (!device)
3298 return SupportedProfiles(); 3298 return SupportedProfiles();
3299 3299
3300 return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_), 3300 return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_),
3301 supported_input_fourccs_); 3301 supported_input_fourccs_);
3302 } 3302 }
3303 3303
3304 } // namespace media 3304 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698