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

Side by Side Diff: media/ffmpeg/ffmpeg_common.cc

Issue 10949029: Replace av_malloc with AlignedAlloc for memory allocation in DecoderBuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve Dale's comments. Created 8 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/decoder_buffer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/ffmpeg/ffmpeg_common.h" 5 #include "media/ffmpeg/ffmpeg_common.h"
6 6
7 #include "base/basictypes.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/base/decoder_buffer.h"
8 #include "media/base/video_util.h" 10 #include "media/base/video_util.h"
9 11
10 namespace media { 12 namespace media {
11 13
14 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are
15 // padded. Check here to ensure FFmpeg only receives data padded to its
16 // specifications.
17 COMPILE_ASSERT(DecoderBuffer::kPaddingSize >= FF_INPUT_BUFFER_PADDING_SIZE,
18 decoder_buffer_padding_size_does_not_fit_ffmpeg_requirement);
19
20 // Alignment requirement by FFmpeg for input buffers. This need to be updated
21 // to match FFmpeg when it changes.
22 #if defined(ARCH_CPU_ARM_FAMILY)
23 static const int kFFmpegInputBufferAlignmentSize = 16;
24 #else
25 static const int kFFmpegInputBufferAlignmentSize = 32;
26 #endif
27 // Check here to ensure FFmpeg only receives data aligned to its specifications.
28 COMPILE_ASSERT(
29 DecoderBuffer::kAlignmentSize >= kFFmpegInputBufferAlignmentSize &&
30 DecoderBuffer::kAlignmentSize % kFFmpegInputBufferAlignmentSize == 0,
31 decoder_buffer_alignment_size_does_not_fit_ffmpeg_requirement);
32
12 static const AVRational kMicrosBase = { 1, base::Time::kMicrosecondsPerSecond }; 33 static const AVRational kMicrosBase = { 1, base::Time::kMicrosecondsPerSecond };
13 34
14 base::TimeDelta ConvertFromTimeBase(const AVRational& time_base, 35 base::TimeDelta ConvertFromTimeBase(const AVRational& time_base,
15 int64 timestamp) { 36 int64 timestamp) {
16 int64 microseconds = av_rescale_q(timestamp, time_base, kMicrosBase); 37 int64 microseconds = av_rescale_q(timestamp, time_base, kMicrosBase);
17 return base::TimeDelta::FromMicroseconds(microseconds); 38 return base::TimeDelta::FromMicroseconds(microseconds);
18 } 39 }
19 40
20 int64 ConvertToTimeBase(const AVRational& time_base, 41 int64 ConvertToTimeBase(const AVRational& time_base,
21 const base::TimeDelta& timestamp) { 42 const base::TimeDelta& timestamp) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 avcodec_close(stream->codec); 408 avcodec_close(stream->codec);
388 } 409 }
389 } 410 }
390 } 411 }
391 412
392 // Then finally cleanup the format context. 413 // Then finally cleanup the format context.
393 avformat_close_input(&format_context); 414 avformat_close_input(&format_context);
394 } 415 }
395 416
396 } // namespace media 417 } // namespace media
OLDNEW
« no previous file with comments | « media/base/decoder_buffer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698