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

Side by Side Diff: content/common/gpu/media/vaapi_h264_decoder_unittest.cc

Issue 490233002: VaapiVideoAccelerator: make Vaapi accelerator work with ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enable vaapi_h264_decoder_unittest on Ozone Created 6 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 6
7 // This has to be included first. 7 // This has to be included first.
8 // See http://code.google.com/p/googletest/issues/detail?id=371 8 // See http://code.google.com/p/googletest/issues/detail?id=371
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Give all surfaces in available_surfaces_ to the decoder. 74 // Give all surfaces in available_surfaces_ to the decoder.
75 void RefillSurfaces(); 75 void RefillSurfaces();
76 76
77 // Free the current set of surfaces and allocate a new set of 77 // Free the current set of surfaces and allocate a new set of
78 // surfaces. Returns true when successful. 78 // surfaces. Returns true when successful.
79 bool AllocateNewSurfaces(); 79 bool AllocateNewSurfaces();
80 80
81 // Use the data in the frame: write to file and update MD5 sum. 81 // Use the data in the frame: write to file and update MD5 sum.
82 bool ProcessVideoFrame(const scoped_refptr<media::VideoFrame>& frame); 82 bool ProcessVideoFrame(const scoped_refptr<media::VideoFrame>& frame);
83 83
84 scoped_ptr<VaapiWrapper> wrapper_; 84 scoped_refptr<VaapiWrapper> wrapper_;
85 scoped_ptr<VaapiH264Decoder> decoder_; 85 scoped_ptr<VaapiH264Decoder> decoder_;
86 std::string data_; // data read from input_file 86 std::string data_; // data read from input_file
87 base::FilePath output_file_; // output data is written to this file 87 base::FilePath output_file_; // output data is written to this file
88 std::vector<VASurfaceID> available_surfaces_; 88 std::vector<VASurfaceID> available_surfaces_;
89 89
90 // These members (x_display_, num_outputted_pictures_, num_surfaces_) 90 // These members (x_display_, num_outputted_pictures_, num_surfaces_)
Pawel Osciak 2014/11/03 01:36:51 No x_display_ anymore.
llandwerlin-old 2014/11/03 09:30:11 Acknowledged.
91 // need to be initialized and possibly freed manually. 91 // need to be initialized and possibly freed manually.
92 Display* x_display_;
93 int num_outputted_pictures_; // number of pictures already outputted 92 int num_outputted_pictures_; // number of pictures already outputted
94 size_t num_surfaces_; // number of surfaces in the current set of surfaces 93 size_t num_surfaces_; // number of surfaces in the current set of surfaces
95 base::MD5Context md5_context_; 94 base::MD5Context md5_context_;
96 }; 95 };
97 96
98 VaapiH264DecoderLoop::VaapiH264DecoderLoop() 97 VaapiH264DecoderLoop::VaapiH264DecoderLoop()
99 : x_display_(NULL), num_outputted_pictures_(0), num_surfaces_(0) { 98 : num_outputted_pictures_(0), num_surfaces_(0) {
100 base::MD5Init(&md5_context_); 99 base::MD5Init(&md5_context_);
101 } 100 }
102 101
103 VaapiH264DecoderLoop::~VaapiH264DecoderLoop() { 102 VaapiH264DecoderLoop::~VaapiH264DecoderLoop() {
104 // We need to destruct decoder and wrapper first because: 103 // We need to destruct decoder and wrapper first because:
105 // (1) The decoder has a reference to the wrapper. 104 // (1) The decoder has a reference to the wrapper.
106 // (2) The wrapper has a reference to x_display_. 105 // (2) The wrapper has a reference to x_display_.
Pawel Osciak 2014/11/03 01:36:51 No x_display_ anymore.
llandwerlin-old 2014/11/03 09:30:10 Acknowledged.
107 decoder_.reset(); 106 decoder_.reset();
108 wrapper_.reset(); 107 wrapper_ = NULL;
Pawel Osciak 2014/11/03 01:36:51 I don't think we actually need these now that you
llandwerlin-old 2014/11/03 09:30:11 Acknowledged.
109
110 if (x_display_) {
111 XCloseDisplay(x_display_);
112 }
113 } 108 }
114 109
115 void LogOnError(VaapiH264Decoder::VAVDAH264DecoderFailure error) { 110 void LogOnError(VaapiH264Decoder::VAVDAH264DecoderFailure error) {
116 LOG(FATAL) << "Oh noes! Decoder failed: " << error; 111 LOG(FATAL) << "Oh noes! Decoder failed: " << error;
117 } 112 }
118 113
119 bool VaapiH264DecoderLoop::Initialize(base::FilePath input_file, 114 bool VaapiH264DecoderLoop::Initialize(base::FilePath input_file,
120 base::FilePath output_file) { 115 base::FilePath output_file) {
121 x_display_ = XOpenDisplay(NULL);
122 if (!x_display_) {
123 LOG(ERROR) << "Can't open X display";
124 return false;
125 }
126
127 media::VideoCodecProfile profile = media::H264PROFILE_BASELINE; 116 media::VideoCodecProfile profile = media::H264PROFILE_BASELINE;
128 base::Closure report_error_cb = 117 base::Closure report_error_cb =
129 base::Bind(&LogOnError, VaapiH264Decoder::VAAPI_ERROR); 118 base::Bind(&LogOnError, VaapiH264Decoder::VAAPI_ERROR);
130 wrapper_ = VaapiWrapper::Create( 119 wrapper_ =
131 VaapiWrapper::kDecode, profile, x_display_, report_error_cb); 120 VaapiWrapper::Create(VaapiWrapper::kDecode, profile, report_error_cb);
132 if (!wrapper_.get()) { 121 if (!wrapper_.get()) {
133 LOG(ERROR) << "Can't create vaapi wrapper"; 122 LOG(ERROR) << "Can't create vaapi wrapper";
134 return false; 123 return false;
135 } 124 }
136 125
137 decoder_.reset(new VaapiH264Decoder( 126 decoder_.reset(new VaapiH264Decoder(
138 wrapper_.get(), 127 wrapper_.get(),
139 base::Bind(&VaapiH264DecoderLoop::OutputPicture, base::Unretained(this)), 128 base::Bind(&VaapiH264DecoderLoop::OutputPicture, base::Unretained(this)),
140 base::Bind(&LogOnError))); 129 base::Bind(&LogOnError)));
141 130
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 278 }
290 279
291 void VaapiH264DecoderLoop::RecycleSurface(VASurfaceID va_surface_id) { 280 void VaapiH264DecoderLoop::RecycleSurface(VASurfaceID va_surface_id) {
292 available_surfaces_.push_back(va_surface_id); 281 available_surfaces_.push_back(va_surface_id);
293 } 282 }
294 283
295 void VaapiH264DecoderLoop::RefillSurfaces() { 284 void VaapiH264DecoderLoop::RefillSurfaces() {
296 for (size_t i = 0; i < available_surfaces_.size(); i++) { 285 for (size_t i = 0; i < available_surfaces_.size(); i++) {
297 VASurface::ReleaseCB release_cb = base::Bind( 286 VASurface::ReleaseCB release_cb = base::Bind(
298 &VaapiH264DecoderLoop::RecycleSurface, base::Unretained(this)); 287 &VaapiH264DecoderLoop::RecycleSurface, base::Unretained(this));
299 scoped_refptr<VASurface> surface( 288 scoped_refptr<VASurface> surface(new VASurface(
300 new VASurface(available_surfaces_[i], release_cb)); 289 available_surfaces_[i], decoder_->GetPicSize(), release_cb));
301 decoder_->ReuseSurface(surface); 290 decoder_->ReuseSurface(surface);
302 } 291 }
303 available_surfaces_.clear(); 292 available_surfaces_.clear();
304 } 293 }
305 294
306 bool VaapiH264DecoderLoop::AllocateNewSurfaces() { 295 bool VaapiH264DecoderLoop::AllocateNewSurfaces() {
307 CHECK_EQ(num_surfaces_, available_surfaces_.size()) 296 CHECK_EQ(num_surfaces_, available_surfaces_.size())
308 << "not all surfaces are returned"; 297 << "not all surfaces are returned";
309 298
310 available_surfaces_.clear(); 299 available_surfaces_.clear();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 content::g_md5sum = it->second; 365 content::g_md5sum = it->second;
377 continue; 366 continue;
378 } 367 }
379 if (it->first == "v" || it->first == "vmodule") 368 if (it->first == "v" || it->first == "vmodule")
380 continue; 369 continue;
381 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 370 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
382 } 371 }
383 372
384 return RUN_ALL_TESTS(); 373 return RUN_ALL_TESTS();
385 } 374 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698