Commit caee7df2 authored by rbultje@chromium.org's avatar rbultje@chromium.org

Reintroduce kFramePadBytes in frame allocation.

Some FFmpeg SIMD functions overread/write slightly to have
more efficient buffer access code. Not adding padding thus
can lead to overreads/bytes (and crashes) when the buffer
pointer points near the end of the frame boundaries.

BUG=136231

Review URL: https://chromiumcodereview.appspot.com/10765015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145900 0039d316-1c4b-4281-b951-d872f2087c98
parent ff79fa2e
...@@ -99,6 +99,8 @@ static inline size_t RoundUp(size_t value, size_t alignment) { ...@@ -99,6 +99,8 @@ static inline size_t RoundUp(size_t value, size_t alignment) {
} }
static const int kFrameSizeAlignment = 16; static const int kFrameSizeAlignment = 16;
// Allows faster SIMD YUV convert. Also, FFmpeg overreads/-writes occasionally.
static const int kFramePadBytes = 15;
void VideoFrame::AllocateRGB(size_t bytes_per_pixel) { void VideoFrame::AllocateRGB(size_t bytes_per_pixel) {
// Round up to align at least at a 16-byte boundary for each row. // Round up to align at least at a 16-byte boundary for each row.
...@@ -110,7 +112,7 @@ void VideoFrame::AllocateRGB(size_t bytes_per_pixel) { ...@@ -110,7 +112,7 @@ void VideoFrame::AllocateRGB(size_t bytes_per_pixel) {
// TODO(dalecurtis): use DataAligned or so, so this #ifdef hackery // TODO(dalecurtis): use DataAligned or so, so this #ifdef hackery
// doesn't need to be repeated in every single user of aligned data. // doesn't need to be repeated in every single user of aligned data.
data_[VideoFrame::kRGBPlane] = reinterpret_cast<uint8*>( data_[VideoFrame::kRGBPlane] = reinterpret_cast<uint8*>(
av_malloc(bytes_per_row * aligned_height)); av_malloc(bytes_per_row * aligned_height + kFramePadBytes));
#else #else
data_[VideoFrame::kRGBPlane] = new uint8_t[bytes_per_row * aligned_height]; data_[VideoFrame::kRGBPlane] = new uint8_t[bytes_per_row * aligned_height];
#endif #endif
...@@ -142,7 +144,7 @@ void VideoFrame::AllocateYUV() { ...@@ -142,7 +144,7 @@ void VideoFrame::AllocateYUV() {
// TODO(dalecurtis): use DataAligned or so, so this #ifdef hackery // TODO(dalecurtis): use DataAligned or so, so this #ifdef hackery
// doesn't need to be repeated in every single user of aligned data. // doesn't need to be repeated in every single user of aligned data.
uint8* data = reinterpret_cast<uint8*>( uint8* data = reinterpret_cast<uint8*>(
av_malloc(y_bytes + (uv_bytes * 2))); av_malloc(y_bytes + (uv_bytes * 2) + kFramePadBytes));
#else #else
uint8* data = new uint8_t[y_bytes + (uv_bytes * 2)]; uint8* data = new uint8_t[y_bytes + (uv_bytes * 2)];
#endif #endif
......
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