Lines 9-14
Link Here
|
9 |
|
9 |
|
10 |
#include <va/va.h> |
10 |
#include <va/va.h> |
11 |
|
11 |
|
|
|
12 |
#include <string> |
13 |
#include <fstream> |
14 |
#include <sstream> |
15 |
|
12 |
#include "base/bind.h" |
16 |
#include "base/bind.h" |
13 |
#include "base/callback_helpers.h" |
17 |
#include "base/callback_helpers.h" |
14 |
#include "base/logging.h" |
18 |
#include "base/logging.h" |
Lines 443-448
bool VaapiWrapper::AreAttribsSupported_L
Link Here
|
443 |
return true; |
447 |
return true; |
444 |
} |
448 |
} |
445 |
|
449 |
|
|
|
450 |
int VaapiWrapper::va_fb_res_width = VA_FB_RES_DEFAULT_WIDTH; |
451 |
int VaapiWrapper::va_fb_res_height = VA_FB_RES_DEFAULT_HEIGHT; |
452 |
|
453 |
void VaapiWrapper::SetFallbackResolution(int w, int h) |
454 |
{ |
455 |
va_fb_res_width = w; |
456 |
va_fb_res_height = h; |
457 |
} |
458 |
|
459 |
void VaapiWrapper::GetFallbackResolution(gfx::Size* resolution) |
460 |
{ |
461 |
resolution->SetSize(va_fb_res_width, va_fb_res_height); |
462 |
} |
463 |
|
446 |
bool VaapiWrapper::GetMaxResolution_Locked( |
464 |
bool VaapiWrapper::GetMaxResolution_Locked( |
447 |
VAProfile va_profile, |
465 |
VAProfile va_profile, |
448 |
VAEntrypoint entrypoint, |
466 |
VAEntrypoint entrypoint, |
Lines 461-467
bool VaapiWrapper::GetMaxResolution_Lock
Link Here
|
461 |
unsigned int num_attribs; |
479 |
unsigned int num_attribs; |
462 |
va_res = vaQuerySurfaceAttributes(va_display_, va_config_id, nullptr, |
480 |
va_res = vaQuerySurfaceAttributes(va_display_, va_config_id, nullptr, |
463 |
&num_attribs); |
481 |
&num_attribs); |
464 |
VA_SUCCESS_OR_RETURN(va_res, "vaQuerySurfaceAttributes failed", false); |
482 |
if (va_res != VA_STATUS_SUCCESS) { |
|
|
483 |
LOG_VA_ERROR_AND_REPORT(va_res, "vaQuerySurfaceAttributes failed, returning fallback resolution"); |
484 |
GetFallbackResolution(resolution); |
485 |
return true; |
486 |
} |
465 |
if (!num_attribs) |
487 |
if (!num_attribs) |
466 |
return false; |
488 |
return false; |
467 |
|
489 |
|
Lines 470-476
bool VaapiWrapper::GetMaxResolution_Lock
Link Here
|
470 |
|
492 |
|
471 |
va_res = vaQuerySurfaceAttributes(va_display_, va_config_id, &attrib_list[0], |
493 |
va_res = vaQuerySurfaceAttributes(va_display_, va_config_id, &attrib_list[0], |
472 |
&num_attribs); |
494 |
&num_attribs); |
473 |
VA_SUCCESS_OR_RETURN(va_res, "vaQuerySurfaceAttributes failed", false); |
495 |
if (va_res != VA_STATUS_SUCCESS) { |
|
|
496 |
LOG_VA_ERROR_AND_REPORT(va_res, "vaQuerySurfaceAttributes failed, returning fallback resolution"); |
497 |
GetFallbackResolution(resolution); |
498 |
return true; |
499 |
} |
474 |
|
500 |
|
475 |
resolution->SetSize(0, 0); |
501 |
resolution->SetSize(0, 0); |
476 |
for (const auto& attrib : attrib_list) { |
502 |
for (const auto& attrib : attrib_list) { |
Lines 480-488
bool VaapiWrapper::GetMaxResolution_Lock
Link Here
|
480 |
resolution->set_height(attrib.value.value.i); |
506 |
resolution->set_height(attrib.value.value.i); |
481 |
} |
507 |
} |
482 |
if (resolution->IsEmpty()) { |
508 |
if (resolution->IsEmpty()) { |
483 |
LOG(ERROR) << "Codec resolution " << resolution->ToString() |
509 |
GetFallbackResolution(resolution); |
484 |
<< " cannot be zero."; |
|
|
485 |
return false; |
486 |
} |
510 |
} |
487 |
return true; |
511 |
return true; |
488 |
} |
512 |
} |
Lines 1108-1113
void VaapiWrapper::DeinitializeVpp() {
Link Here
|
1108 |
|
1132 |
|
1109 |
// static |
1133 |
// static |
1110 |
void VaapiWrapper::PreSandboxInitialization() { |
1134 |
void VaapiWrapper::PreSandboxInitialization() { |
|
|
1135 |
int w=VA_FB_RES_DEFAULT_WIDTH, h=VA_FB_RES_DEFAULT_HEIGHT; |
1136 |
std::string line; |
1137 |
// Open fallback resolution file before sandbox initialization |
1138 |
std::ifstream va_fb_res_file(VA_FALLBACK_RESOLUTION_FILENAME); |
1139 |
// If the file exists, open and read the resolution |
1140 |
// If not successful, use default values |
1141 |
if(va_fb_res_file.is_open()){ |
1142 |
LOG(INFO) << "Opened fallback resolution file: " << VA_FALLBACK_RESOLUTION_FILENAME; |
1143 |
if(std::getline(va_fb_res_file,line)){ |
1144 |
std::istringstream iss(line); |
1145 |
if(!((iss >> w) && (iss >> h))){ |
1146 |
w=VA_FB_RES_DEFAULT_WIDTH; |
1147 |
h=VA_FB_RES_DEFAULT_HEIGHT; |
1148 |
LOG(ERROR) << "Could not read values. Please check that\ |
1149 |
the first line has two space separated integers indicating\ |
1150 |
the width and height in that order."; |
1151 |
} |
1152 |
else if( w<1 || h<1) |
1153 |
{ |
1154 |
w=VA_FB_RES_DEFAULT_WIDTH; |
1155 |
h=VA_FB_RES_DEFAULT_HEIGHT; |
1156 |
LOG(WARNING) << "Non-positive dimension(s) specified. \ |
1157 |
Using default values instead."; |
1158 |
} |
1159 |
} |
1160 |
else |
1161 |
LOG(ERROR) << "Failed to read resolution"; |
1162 |
} |
1163 |
else |
1164 |
LOG(ERROR) << "Failed to open fallback resolution file: " << VA_FALLBACK_RESOLUTION_FILENAME; |
1165 |
va_fb_res_file.close(); |
1166 |
LOG(INFO) << "Resolution used: " << w << " x " << h; |
1167 |
SetFallbackResolution(w,h); |
1111 |
#if defined(USE_OZONE) |
1168 |
#if defined(USE_OZONE) |
1112 |
const char kDriRenderNode0Path[] = "/dev/dri/renderD128"; |
1169 |
const char kDriRenderNode0Path[] = "/dev/dri/renderD128"; |
1113 |
base::File drm_file = base::File( |
1170 |
base::File drm_file = base::File( |