Fix -Wc++11-narrowing: media/
Bug: 1216696 Change-Id: If65eab84a66d5994c30eee2060923f87413b2f97 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2975071 Commit-Queue: Peter Kasting <pkasting@chromium.org> Auto-Submit: Peter Kasting <pkasting@chromium.org> Reviewed-by: Will Cassella <cassew@google.com> Cr-Commit-Position: refs/heads/master@{#894533}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d95568cd6f
commit
952cf37c8c
media
base
capture
cdm
formats
fuchsia
cdm
service
gpu
renderers
video
@ -57,8 +57,8 @@ static CodecProfileLevel MediaCodecProfileLevelToChromiumProfileLevel(
|
||||
Java_CodecProfileLevelAdapter_getCodec(env, j_codec_profile_level));
|
||||
VideoCodecProfile profile = static_cast<VideoCodecProfile>(
|
||||
Java_CodecProfileLevelAdapter_getProfile(env, j_codec_profile_level));
|
||||
int level =
|
||||
Java_CodecProfileLevelAdapter_getLevel(env, j_codec_profile_level);
|
||||
auto level = static_cast<VideoCodecLevel>(
|
||||
Java_CodecProfileLevelAdapter_getLevel(env, j_codec_profile_level));
|
||||
return {codec, profile, level};
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace media {
|
||||
|
||||
VideoAspectRatio::VideoAspectRatio(Type type, int width, int height) {
|
||||
type_ = type;
|
||||
aspect_ratio_ = height ? double{width} / height : 0.0;
|
||||
aspect_ratio_ = height ? static_cast<double>(width) / height : 0.0;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -29,8 +29,8 @@ VideoAspectRatio::VideoAspectRatio(const gfx::Rect& visible_rect,
|
||||
// The size of a pixel is:
|
||||
// (natural_width / visible_width) by (natural_height / visible_height).
|
||||
// Both are multiplied by (visible_width * visible_height) to avoid division.
|
||||
double w = double{visible_rect.height()} * natural_size.width();
|
||||
double h = double{visible_rect.width()} * natural_size.height();
|
||||
double w = visible_rect.height() * natural_size.width();
|
||||
double h = visible_rect.width() * natural_size.height();
|
||||
|
||||
type_ = Type::kPixel;
|
||||
aspect_ratio_ = h != 0.0 ? w / h : 0.0;
|
||||
|
@ -424,7 +424,7 @@ int FakeV4L2Impl::ioctl(int fd, int request, void* argp) {
|
||||
return EBADF;
|
||||
auto* opened_device = device_iter->second.get();
|
||||
|
||||
switch (request) {
|
||||
switch (static_cast<uint32_t>(request)) {
|
||||
case VIDIOC_ENUM_FMT:
|
||||
return opened_device->enum_fmt(reinterpret_cast<v4l2_fmtdesc*>(argp));
|
||||
case VIDIOC_QUERYCAP:
|
||||
|
@ -163,8 +163,9 @@ base::scoped_nsobject<NSDictionary> GetDeviceNames() {
|
||||
} // namespace
|
||||
|
||||
std::string MacFourCCToString(OSType fourcc) {
|
||||
char arr[] = {fourcc >> 24, (fourcc >> 16) & 255, (fourcc >> 8) & 255,
|
||||
fourcc & 255, 0};
|
||||
char arr[] = {static_cast<char>(fourcc >> 24),
|
||||
static_cast<char>(fourcc >> 16), static_cast<char>(fourcc >> 8),
|
||||
static_cast<char>(fourcc), 0};
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// only set |subsamples| if |clear_bytes| <= |size|. If |subsamples| is
|
||||
// empty, the complete buffer is treated as encrypted.
|
||||
std::vector<media::SubsampleEntry> subsamples;
|
||||
if (clear_bytes <= size)
|
||||
subsamples.push_back({clear_bytes, size - clear_bytes});
|
||||
if (clear_bytes <= size) {
|
||||
subsamples.push_back(
|
||||
{clear_bytes, static_cast<uint32_t>(size - clear_bytes)});
|
||||
}
|
||||
|
||||
// |encryption_pattern| is used to determine the encryption pattern. Since
|
||||
// |crypt_byte_block| must be > 0, use 1 for it. |skip_byte_block| can be 0.
|
||||
|
@ -53,8 +53,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// only set |subsamples| if |clear_bytes| <= |size|. If |subsamples| is
|
||||
// empty, the complete buffer is treated as encrypted.
|
||||
std::vector<media::SubsampleEntry> subsamples;
|
||||
if (clear_bytes <= size)
|
||||
subsamples.push_back({clear_bytes, size - clear_bytes});
|
||||
if (clear_bytes <= size) {
|
||||
subsamples.push_back(
|
||||
{clear_bytes, static_cast<uint32_t>(size - clear_bytes)});
|
||||
}
|
||||
|
||||
auto encrypted_buffer = media::DecoderBuffer::CopyFrom(data, size);
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ TEST_F(WebMClusterParserTest, PreferOpusDurationsOverBlockDurations) {
|
||||
std::string(), std::string(), kCodecOpus));
|
||||
|
||||
// Setting BlockDuration != Opus duration to see which one the parser uses.
|
||||
int block_duration_ms = packet_ptr->duration_ms() + 10;
|
||||
double block_duration_ms = packet_ptr->duration_ms() + 10;
|
||||
if (packet_ptr->duration_ms() > 120) {
|
||||
EXPECT_MEDIA_LOG(OpusPacketDurationTooHigh(packet_ptr->duration_ms()));
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ struct CdmDirectoryInfo {
|
||||
// addition of most-recently-modified calculation, and inclusion of directory
|
||||
// node sizes toward the total.
|
||||
CdmDirectoryInfo GetCdmDirectoryInfo(const base::FilePath& path) {
|
||||
int64_t directory_size = 0;
|
||||
uint64_t directory_size = 0;
|
||||
base::Time last_used;
|
||||
base::FileEnumerator enumerator(
|
||||
path, true /* recursive */,
|
||||
|
@ -343,7 +343,7 @@ TEST_F(H265DecoderTest, SetEncryptedStream) {
|
||||
const std::vector<SubsampleEntry> subsamples = {
|
||||
// No encrypted bytes. This test only checks whether the data is passed
|
||||
// thru to the acclerator so making this completely clear.
|
||||
{bitstream.size(), 0},
|
||||
{static_cast<uint32_t>(bitstream.size()), 0},
|
||||
};
|
||||
|
||||
std::unique_ptr<DecryptConfig> decrypt_config =
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@ -249,8 +250,9 @@ bool CreateVideoToolboxSession(
|
||||
// output size for a 1:1 ratio. (Note though that VideoToolbox does not handle
|
||||
// top or left crops correctly.) We expect the visible rect to be integral.
|
||||
CGRect visible_rect = CMVideoFormatDescriptionGetCleanAperture(format, true);
|
||||
CMVideoDimensions visible_dimensions = {visible_rect.size.width,
|
||||
visible_rect.size.height};
|
||||
CMVideoDimensions visible_dimensions = {
|
||||
base::ClampFloor(visible_rect.size.width),
|
||||
base::ClampFloor(visible_rect.size.height)};
|
||||
base::ScopedCFTypeRef<CFMutableDictionaryRef> image_config(
|
||||
BuildImageConfig(visible_dimensions, is_hbd));
|
||||
if (!image_config) {
|
||||
|
@ -68,7 +68,7 @@ uint32_t GetDefaultTargetBitrate(const gfx::Size& resolution,
|
||||
gfx::Size resolution;
|
||||
uint32_t bitrate;
|
||||
} kDefaultTargetBitrates[] = {
|
||||
{gfx::Size(640, 360), 1 * Mbps}, {gfx::Size(854, 480), 2.5 * Mbps},
|
||||
{gfx::Size(640, 360), 1 * Mbps}, {gfx::Size(854, 480), 5 * Mbps / 2},
|
||||
{gfx::Size(1280, 720), 5 * Mbps}, {gfx::Size(1920, 1080), 8 * Mbps},
|
||||
{gfx::Size(3840, 2160), 18 * Mbps},
|
||||
};
|
||||
|
@ -334,15 +334,16 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
|
||||
.WillOnce(RunClosure(run_loop.QuitClosure()));
|
||||
|
||||
const auto tex_target = mock_vaapi_picture_factory_->GetGLTextureTarget();
|
||||
int irrelevant_id = 2;
|
||||
int32_t irrelevant_id = 2;
|
||||
std::vector<PictureBuffer> picture_buffers;
|
||||
for (size_t picture = 0; picture < num_pictures; ++picture) {
|
||||
// The picture buffer id, client id and service texture ids are
|
||||
// arbitrarily chosen.
|
||||
picture_buffers.push_back({irrelevant_id++, picture_size,
|
||||
PictureBuffer::TextureIds{irrelevant_id++},
|
||||
PictureBuffer::TextureIds{irrelevant_id++},
|
||||
tex_target, PIXEL_FORMAT_XRGB});
|
||||
picture_buffers.push_back(
|
||||
{irrelevant_id++, picture_size,
|
||||
PictureBuffer::TextureIds{static_cast<uint32_t>(irrelevant_id++)},
|
||||
PictureBuffer::TextureIds{static_cast<uint32_t>(irrelevant_id++)},
|
||||
tex_target, PIXEL_FORMAT_XRGB});
|
||||
}
|
||||
|
||||
AssignPictureBuffers(picture_buffers);
|
||||
|
@ -516,7 +516,9 @@ bool EGLStreamPictureBuffer::BindSampleToTexture(
|
||||
dxgi_buffer->GetSubresourceIndex(&subresource);
|
||||
|
||||
EGLAttrib frame_attributes[] = {
|
||||
EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, subresource, EGL_NONE,
|
||||
EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE,
|
||||
static_cast<EGLAttrib>(subresource),
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
EGLBoolean result = eglStreamPostD3DTextureANGLE(
|
||||
|
@ -929,7 +929,7 @@ HRESULT MediaFoundationVideoEncodeAccelerator::PopulateInputSampleBuffer(
|
||||
frame->row_bytes(VideoFrame::kYPlane) * frame->rows(VideoFrame::kYPlane);
|
||||
uint8_t* end = dst_uv + frame->row_bytes(VideoFrame::kUVPlane) *
|
||||
frame->rows(VideoFrame::kUVPlane);
|
||||
DCHECK_GE(std::ptrdiff_t{scoped_buffer.max_length()},
|
||||
DCHECK_GE(static_cast<ptrdiff_t>(scoped_buffer.max_length()),
|
||||
end - scoped_buffer.get());
|
||||
|
||||
if (frame->format() == PIXEL_FORMAT_NV12) {
|
||||
|
@ -170,7 +170,7 @@ HRESULT GetAacAudioType(const AudioDecoderConfig decoder_config,
|
||||
aac_wave_format->wfx.nBlockAlign = 1;
|
||||
|
||||
size_t extra_size = wave_format_size - sizeof(WAVEFORMATEX);
|
||||
aac_wave_format->wfx.cbSize = WORD{extra_size};
|
||||
aac_wave_format->wfx.cbSize = static_cast<WORD>(extra_size);
|
||||
aac_wave_format->wPayloadType = 0; // RAW AAC
|
||||
aac_wave_format->wAudioProfileLevelIndication =
|
||||
0xFE; // no audio profile specified
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <limits>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/system/sys_info.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
@ -38,8 +39,7 @@ Status SetUpOpenH264Params(const VideoEncoder::Options& options,
|
||||
|
||||
if (options.bitrate.has_value()) {
|
||||
params->iRCMode = RC_BITRATE_MODE;
|
||||
params->iTargetBitrate = int{std::min(
|
||||
options.bitrate.value(), uint64_t{std::numeric_limits<int>::max()})};
|
||||
params->iTargetBitrate = base::saturated_cast<int>(options.bitrate.value());
|
||||
} else {
|
||||
params->iRCMode = RC_OFF_MODE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user