Commit 634869e4 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Handle odd width and height in the MediaSource renderer.

Chrome requires video streams to have even width and height, so
MediaSource renderer didn't work properly for streams with odd width or
height. Fixed it to round up dimensions and crop one column or one row
when screen size is odd, using Matroska's CropRight and CropBottom
attributes.

BUG=321825

Review URL: https://codereview.chromium.org/291193008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272430 0039d316-1c4b-4281-b951-d872f2087c98
parent 1090d2b8
...@@ -65,9 +65,25 @@ MediaSourceVideoRenderer::VideoWriter::VideoWriter( ...@@ -65,9 +65,25 @@ MediaSourceVideoRenderer::VideoWriter::VideoWriter(
.InMicroseconds() * .InMicroseconds() *
base::Time::kNanosecondsPerMicrosecond); base::Time::kNanosecondsPerMicrosecond);
segment_->AddVideoTrack(frame_size_.width(), frame_size_.height(), 1); uint64 crop_right = 0;
int width = frame_size_.width();
if (width % 2 == 1) {
++width;
crop_right = 1;
}
uint64 crop_bottom = 0;
int height = frame_size_.height();
if (height % 2 == 1) {
++height;
crop_bottom = 1;
}
segment_->AddVideoTrack(width, height, 1);
mkvmuxer::VideoTrack* video_track = mkvmuxer::VideoTrack* video_track =
reinterpret_cast<mkvmuxer::VideoTrack*>(segment_->GetTrackByNumber(1)); reinterpret_cast<mkvmuxer::VideoTrack*>(segment_->GetTrackByNumber(1));
video_track->set_crop_right(crop_right);
video_track->set_crop_bottom(crop_bottom);
video_track->set_frame_rate(base::Time::kNanosecondsPerSecond / video_track->set_frame_rate(base::Time::kNanosecondsPerSecond /
kFrameIntervalNs); kFrameIntervalNs);
video_track->set_default_duration(base::Time::kNanosecondsPerSecond); video_track->set_default_duration(base::Time::kNanosecondsPerSecond);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment