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

Side by Side Diff: media/base/android/media_codec_util.cc

Issue 2572573007: Use passthrough decoder for (E)AC3 formats (Closed)
Patch Set: Sanity checks Created 3 years, 7 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/base/android/media_codec_util.h ('k') | media/base/audio_buffer.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/base/android/media_codec_util.h" 5 #include "media/base/android/media_codec_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 23 matching lines...) Expand all
34 34
35 namespace media { 35 namespace media {
36 36
37 namespace { 37 namespace {
38 const char kMp3MimeType[] = "audio/mpeg"; 38 const char kMp3MimeType[] = "audio/mpeg";
39 const char kAacMimeType[] = "audio/mp4a-latm"; 39 const char kAacMimeType[] = "audio/mp4a-latm";
40 const char kOpusMimeType[] = "audio/opus"; 40 const char kOpusMimeType[] = "audio/opus";
41 const char kVorbisMimeType[] = "audio/vorbis"; 41 const char kVorbisMimeType[] = "audio/vorbis";
42 const char kAc3MimeType[] = "audio/ac3"; 42 const char kAc3MimeType[] = "audio/ac3";
43 const char kEac3MimeType[] = "audio/eac3"; 43 const char kEac3MimeType[] = "audio/eac3";
44 const char kBitstreamAudioMimeType[] = "audio/raw";
44 const char kAvcMimeType[] = "video/avc"; 45 const char kAvcMimeType[] = "video/avc";
45 const char kHevcMimeType[] = "video/hevc"; 46 const char kHevcMimeType[] = "video/hevc";
46 const char kVp8MimeType[] = "video/x-vnd.on2.vp8"; 47 const char kVp8MimeType[] = "video/x-vnd.on2.vp8";
47 const char kVp9MimeType[] = "video/x-vnd.on2.vp9"; 48 const char kVp9MimeType[] = "video/x-vnd.on2.vp9";
48 } // namespace 49 } // namespace
49 50
50 static CodecProfileLevel MediaCodecProfileLevelToChromiumProfileLevel( 51 static CodecProfileLevel MediaCodecProfileLevelToChromiumProfileLevel(
51 JNIEnv* env, 52 JNIEnv* env,
52 const jobject& j_codec_profile_level) { 53 const jobject& j_codec_profile_level) {
53 VideoCodec codec = static_cast<VideoCodec>( 54 VideoCodec codec = static_cast<VideoCodec>(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) { 92 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) {
92 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); 93 DCHECK(MediaCodecUtil::IsMediaCodecAvailable());
93 JNIEnv* env = AttachCurrentThread(); 94 JNIEnv* env = AttachCurrentThread();
94 ScopedJavaLocalRef<jstring> j_mime = 95 ScopedJavaLocalRef<jstring> j_mime =
95 ConvertUTF8ToJavaString(env, android_mime_type); 96 ConvertUTF8ToJavaString(env, android_mime_type);
96 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime); 97 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime);
97 } 98 }
98 99
99 // static 100 // static
100 std::string MediaCodecUtil::CodecToAndroidMimeType(AudioCodec codec) { 101 std::string MediaCodecUtil::CodecToAndroidMimeType(AudioCodec codec) {
102 if (IsPassthroughAudioFormat(codec))
103 return kBitstreamAudioMimeType;
104
101 switch (codec) { 105 switch (codec) {
102 case kCodecMP3: 106 case kCodecMP3:
103 return kMp3MimeType; 107 return kMp3MimeType;
104 case kCodecVorbis: 108 case kCodecVorbis:
105 return kVorbisMimeType; 109 return kVorbisMimeType;
106 case kCodecOpus: 110 case kCodecOpus:
107 return kOpusMimeType; 111 return kOpusMimeType;
108 case kCodecAAC: 112 case kCodecAAC:
109 return kAacMimeType; 113 return kAacMimeType;
110 case kCodecAC3: 114 case kCodecAC3:
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return true; 357 return true;
354 } 358 }
355 359
356 // static 360 // static
357 bool MediaCodecUtil::IsSetOutputSurfaceSupported() { 361 bool MediaCodecUtil::IsSetOutputSurfaceSupported() {
358 JNIEnv* env = AttachCurrentThread(); 362 JNIEnv* env = AttachCurrentThread();
359 return Java_MediaCodecUtil_isSetOutputSurfaceSupported(env); 363 return Java_MediaCodecUtil_isSetOutputSurfaceSupported(env);
360 } 364 }
361 365
362 // static 366 // static
367 bool MediaCodecUtil::IsPassthroughAudioFormat(AudioCodec codec) {
368 return codec == kCodecAC3 || codec == kCodecEAC3;
369 }
370
371 // static
363 bool MediaCodecUtil::CodecNeedsFlushWorkaround(MediaCodecBridge* codec) { 372 bool MediaCodecUtil::CodecNeedsFlushWorkaround(MediaCodecBridge* codec) {
364 int sdk_int = base::android::BuildInfo::GetInstance()->sdk_int(); 373 int sdk_int = base::android::BuildInfo::GetInstance()->sdk_int();
365 std::string codec_name = codec->GetName(); 374 std::string codec_name = codec->GetName();
366 return sdk_int < 18 || 375 return sdk_int < 18 ||
367 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || 376 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name ||
368 "OMX.SEC.avc.dec.secure" == codec_name)) || 377 "OMX.SEC.avc.dec.secure" == codec_name)) ||
369 (sdk_int == 19 && 378 (sdk_int == 19 &&
370 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), 379 base::StartsWith(base::android::BuildInfo::GetInstance()->model(),
371 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && 380 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) &&
372 ("OMX.Exynos.avc.dec" == codec_name || 381 ("OMX.Exynos.avc.dec" == codec_name ||
373 "OMX.Exynos.avc.dec.secure" == codec_name)); 382 "OMX.Exynos.avc.dec.secure" == codec_name));
374 } 383 }
375 384
376 } // namespace media 385 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_util.h ('k') | media/base/audio_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698