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

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

Issue 1254953004: Hacking ffvp9 decoder support for profiling. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Supress windows warning Created 4 years, 8 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
« no previous file with comments | « media/ffmpeg/ffmpeg_common.h ('k') | media/ffmpeg/ffmpeg_deleters.h » ('j') | 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/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/sha1.h" 9 #include "base/sha1.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 20 matching lines...) Expand all
31 31
32 } // namespace 32 } // namespace
33 33
34 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are 34 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are
35 // padded. Check here to ensure FFmpeg only receives data padded to its 35 // padded. Check here to ensure FFmpeg only receives data padded to its
36 // specifications. 36 // specifications.
37 static_assert(DecoderBuffer::kPaddingSize >= FF_INPUT_BUFFER_PADDING_SIZE, 37 static_assert(DecoderBuffer::kPaddingSize >= FF_INPUT_BUFFER_PADDING_SIZE,
38 "DecoderBuffer padding size does not fit ffmpeg requirement"); 38 "DecoderBuffer padding size does not fit ffmpeg requirement");
39 39
40 // Alignment requirement by FFmpeg for input and output buffers. This need to 40 // Alignment requirement by FFmpeg for input and output buffers. This need to
41 // be updated to match FFmpeg when it changes. 41 // be updated to match FFmpeg when it changes. See libavutil/mem.c.
42 #if defined(ARCH_CPU_ARM_FAMILY) 42 #if defined(ARCH_CPU_ARM_FAMILY)
43 static const int kFFmpegBufferAddressAlignment = 16; 43 static const int kFFmpegBufferAddressAlignment = 16;
44 #else 44 #else
45 static const int kFFmpegBufferAddressAlignment = 32; 45 static const int kFFmpegBufferAddressAlignment = 32;
46 #endif 46 #endif
47 47
48 // Check here to ensure FFmpeg only receives data aligned to its specifications. 48 // Check here to ensure FFmpeg only receives data aligned to its specifications.
49 static_assert( 49 static_assert(
50 DecoderBuffer::kAlignmentSize >= kFFmpegBufferAddressAlignment && 50 DecoderBuffer::kAlignmentSize >= kFFmpegBufferAddressAlignment &&
51 DecoderBuffer::kAlignmentSize % kFFmpegBufferAddressAlignment == 0, 51 DecoderBuffer::kAlignmentSize % kFFmpegBufferAddressAlignment == 0,
52 "DecoderBuffer alignment size does not fit ffmpeg requirement"); 52 "DecoderBuffer alignment size does not fit ffmpeg requirement");
53 53
54 // Allows faster SIMD YUV convert. Also, FFmpeg overreads/-writes occasionally.
55 // See video_get_buffer() in libavcodec/utils.c.
56 static const int kFFmpegOutputBufferPaddingSize = 16;
57
58 static_assert(VideoFrame::kFrameSizePadding >= kFFmpegOutputBufferPaddingSize,
59 "VideoFrame padding size does not fit ffmpeg requirement");
60
61 static_assert( 54 static_assert(
62 VideoFrame::kFrameAddressAlignment >= kFFmpegBufferAddressAlignment && 55 VideoFrame::kFrameAddressAlignment >= kFFmpegBufferAddressAlignment &&
63 VideoFrame::kFrameAddressAlignment % kFFmpegBufferAddressAlignment == 0, 56 VideoFrame::kFrameAddressAlignment % kFFmpegBufferAddressAlignment == 0,
64 "VideoFrame frame address alignment does not fit ffmpeg requirement"); 57 "VideoFrame frame address alignment does not fit ffmpeg requirement");
65 58
59 static_assert(VideoFrame::kFrameSizeAlignment >= STRIDE_ALIGN &&
60 VideoFrame::kFrameSizeAlignment % STRIDE_ALIGN == 0,
61 "VideoFrame size alignment does not fit ffmpeg requirement");
62
63 // Allows faster SIMD YUV convert. Also, FFmpeg overreads/-writes occasionally.
64 // See video_get_buffer() and update_frame_pool() in libavcodec/utils.c
65 static_assert(VideoFrame::kFrameSizePadding >= FRAME_PADDING,
66 "VideoFrame padding size does not fit ffmpeg requirement");
67
66 static const AVRational kMicrosBase = { 1, base::Time::kMicrosecondsPerSecond }; 68 static const AVRational kMicrosBase = { 1, base::Time::kMicrosecondsPerSecond };
67 69
68 base::TimeDelta ConvertFromTimeBase(const AVRational& time_base, 70 base::TimeDelta ConvertFromTimeBase(const AVRational& time_base,
69 int64_t timestamp) { 71 int64_t timestamp) {
70 int64_t microseconds = av_rescale_q(timestamp, time_base, kMicrosBase); 72 int64_t microseconds = av_rescale_q(timestamp, time_base, kMicrosBase);
71 return base::TimeDelta::FromMicroseconds(microseconds); 73 return base::TimeDelta::FromMicroseconds(microseconds);
72 } 74 }
73 75
74 int64_t ConvertToTimeBase(const AVRational& time_base, 76 int64_t ConvertToTimeBase(const AVRational& time_base,
75 const base::TimeDelta& timestamp) { 77 const base::TimeDelta& timestamp) {
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 } 762 }
761 763
762 int32_t HashCodecName(const char* codec_name) { 764 int32_t HashCodecName(const char* codec_name) {
763 // Use the first 32-bits from the SHA1 hash as the identifier. 765 // Use the first 32-bits from the SHA1 hash as the identifier.
764 int32_t hash; 766 int32_t hash;
765 memcpy(&hash, base::SHA1HashString(codec_name).substr(0, 4).c_str(), 4); 767 memcpy(&hash, base::SHA1HashString(codec_name).substr(0, 4).c_str(), 4);
766 return hash; 768 return hash;
767 } 769 }
768 770
769 } // namespace media 771 } // namespace media
OLDNEW
« no previous file with comments | « media/ffmpeg/ffmpeg_common.h ('k') | media/ffmpeg/ffmpeg_deleters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698