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

Unified Diff: media/ffmpeg/ffmpeg_common.cc

Issue 11308310: Replace av_malloc with AlignedAlloc for memory allocation in VideoFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/ffmpeg/ffmpeg_common.cc
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index e487c4948ced3acc5a2c66f4f9a5d9f480cc9eed..c79e4807faf66c09006ba6508e66fc5c3bfa0822 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "media/base/decoder_buffer.h"
+#include "media/base/video_frame.h"
#include "media/base/video_util.h"
namespace media {
@@ -17,19 +18,32 @@ namespace media {
COMPILE_ASSERT(DecoderBuffer::kPaddingSize >= FF_INPUT_BUFFER_PADDING_SIZE,
decoder_buffer_padding_size_does_not_fit_ffmpeg_requirement);
-// Alignment requirement by FFmpeg for input buffers. This need to be updated
-// to match FFmpeg when it changes.
+// Alignment requirement by FFmpeg for input and output buffers. This need to
+// be updated to match FFmpeg when it changes.
#if defined(ARCH_CPU_ARM_FAMILY)
-static const int kFFmpegInputBufferAlignmentSize = 16;
+static const int kFFmpegBufferAddressAlignment = 16;
#else
-static const int kFFmpegInputBufferAlignmentSize = 32;
+static const int kFFmpegBufferAddressAlignment = 32;
#endif
+
// Check here to ensure FFmpeg only receives data aligned to its specifications.
COMPILE_ASSERT(
- DecoderBuffer::kAlignmentSize >= kFFmpegInputBufferAlignmentSize &&
- DecoderBuffer::kAlignmentSize % kFFmpegInputBufferAlignmentSize == 0,
+ DecoderBuffer::kAlignmentSize >= kFFmpegBufferAddressAlignment &&
+ DecoderBuffer::kAlignmentSize % kFFmpegBufferAddressAlignment == 0,
decoder_buffer_alignment_size_does_not_fit_ffmpeg_requirement);
+// Allows faster SIMD YUV convert. Also, FFmpeg overreads/-writes occasionally.
+// See video_get_buffer() in libavcodec/utils.c.
+static const int kFFmpegOutputBufferPaddingSize = 16;
+
+COMPILE_ASSERT(VideoFrame::kFrameSizePadding >= kFFmpegOutputBufferPaddingSize,
+ video_frame_padding_size_does_not_fit_ffmpeg_requirement);
+
+COMPILE_ASSERT(
+ VideoFrame::kFrameAddressAlignment >= kFFmpegBufferAddressAlignment &&
+ VideoFrame::kFrameAddressAlignment % kFFmpegBufferAddressAlignment == 0,
+ video_frame_address_alignment_does_not_fit_ffmpeg_requirement);
+
static const AVRational kMicrosBase = { 1, base::Time::kMicrosecondsPerSecond };
base::TimeDelta ConvertFromTimeBase(const AVRational& time_base,
« no previous file with comments | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698