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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 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 unified diff | Download patch
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"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
10 #include "base/sha1.h" 9 #include "base/sha1.h"
11 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
14 #include "media/base/decoder_buffer.h" 13 #include "media/base/decoder_buffer.h"
15 #include "media/base/video_decoder_config.h" 14 #include "media/base/video_decoder_config.h"
16 #include "media/base/video_util.h" 15 #include "media/base/video_util.h"
17 16
(...skipping 27 matching lines...) Expand all
45 "VideoFrame padding size does not fit ffmpeg requirement"); 44 "VideoFrame padding size does not fit ffmpeg requirement");
46 45
47 static_assert( 46 static_assert(
48 VideoFrame::kFrameAddressAlignment >= kFFmpegBufferAddressAlignment && 47 VideoFrame::kFrameAddressAlignment >= kFFmpegBufferAddressAlignment &&
49 VideoFrame::kFrameAddressAlignment % kFFmpegBufferAddressAlignment == 0, 48 VideoFrame::kFrameAddressAlignment % kFFmpegBufferAddressAlignment == 0,
50 "VideoFrame frame address alignment does not fit ffmpeg requirement"); 49 "VideoFrame frame address alignment does not fit ffmpeg requirement");
51 50
52 static const AVRational kMicrosBase = { 1, base::Time::kMicrosecondsPerSecond }; 51 static const AVRational kMicrosBase = { 1, base::Time::kMicrosecondsPerSecond };
53 52
54 base::TimeDelta ConvertFromTimeBase(const AVRational& time_base, 53 base::TimeDelta ConvertFromTimeBase(const AVRational& time_base,
55 int64 timestamp) { 54 int64_t timestamp) {
56 int64 microseconds = av_rescale_q(timestamp, time_base, kMicrosBase); 55 int64_t microseconds = av_rescale_q(timestamp, time_base, kMicrosBase);
57 return base::TimeDelta::FromMicroseconds(microseconds); 56 return base::TimeDelta::FromMicroseconds(microseconds);
58 } 57 }
59 58
60 int64 ConvertToTimeBase(const AVRational& time_base, 59 int64_t ConvertToTimeBase(const AVRational& time_base,
61 const base::TimeDelta& timestamp) { 60 const base::TimeDelta& timestamp) {
62 return av_rescale_q(timestamp.InMicroseconds(), kMicrosBase, time_base); 61 return av_rescale_q(timestamp.InMicroseconds(), kMicrosBase, time_base);
63 } 62 }
64 63
65 // Converts an FFmpeg audio codec ID into its corresponding supported codec id. 64 // Converts an FFmpeg audio codec ID into its corresponding supported codec id.
66 static AudioCodec CodecIDToAudioCodec(AVCodecID codec_id) { 65 static AudioCodec CodecIDToAudioCodec(AVCodecID codec_id) {
67 switch (codec_id) { 66 switch (codec_id) {
68 case AV_CODEC_ID_AAC: 67 case AV_CODEC_ID_AAC:
69 return kCodecAAC; 68 return kCodecAAC;
70 case AV_CODEC_ID_MP3: 69 case AV_CODEC_ID_MP3:
71 return kCodecMP3; 70 return kCodecMP3;
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 689 }
691 690
692 int32_t HashCodecName(const char* codec_name) { 691 int32_t HashCodecName(const char* codec_name) {
693 // Use the first 32-bits from the SHA1 hash as the identifier. 692 // Use the first 32-bits from the SHA1 hash as the identifier.
694 int32_t hash; 693 int32_t hash;
695 memcpy(&hash, base::SHA1HashString(codec_name).substr(0, 4).c_str(), 4); 694 memcpy(&hash, base::SHA1HashString(codec_name).substr(0, 4).c_str(), 4);
696 return hash; 695 return hash;
697 } 696 }
698 697
699 } // namespace media 698 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698