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

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

Issue 2106133003: [M52] Make AVDA fall back to software decoding if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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_bridge.h ('k') | media/base/android/ndk_media_codec_bridge.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 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 static bool IsSupportedAndroidMimeType(const std::string& mime_type) { 60 static bool IsSupportedAndroidMimeType(const std::string& mime_type) {
61 std::vector<std::string> supported{ 61 std::vector<std::string> supported{
62 kMp4aMimeType, kOpusMimeType, kVorbisMimeType, kAvcMimeType, 62 kMp4aMimeType, kOpusMimeType, kVorbisMimeType, kAvcMimeType,
63 kHevcMimeType, kVp8MimeType, kVp9MimeType}; 63 kHevcMimeType, kVp8MimeType, kVp9MimeType};
64 return std::find(supported.begin(), supported.end(), mime_type) != 64 return std::find(supported.begin(), supported.end(), mime_type) !=
65 supported.end(); 65 supported.end();
66 } 66 }
67 67
68 static std::string GetDefaultCodecName(const std::string& mime_type, 68 static std::string GetDefaultCodecName(const std::string& mime_type,
69 MediaCodecDirection direction) { 69 MediaCodecDirection direction,
70 bool require_software_codec) {
70 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); 71 DCHECK(MediaCodecUtil::IsMediaCodecAvailable());
71 JNIEnv* env = AttachCurrentThread(); 72 JNIEnv* env = AttachCurrentThread();
72 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type); 73 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type);
73 ScopedJavaLocalRef<jstring> j_codec_name = 74 ScopedJavaLocalRef<jstring> j_codec_name =
74 Java_MediaCodecUtil_getDefaultCodecName(env, j_mime.obj(), direction); 75 Java_MediaCodecUtil_getDefaultCodecName(env, j_mime.obj(), direction,
76 require_software_codec);
75 return ConvertJavaStringToUTF8(env, j_codec_name.obj()); 77 return ConvertJavaStringToUTF8(env, j_codec_name.obj());
76 } 78 }
77 79
78 static bool IsDecoderSupportedByDevice(const std::string& android_mime_type) { 80 static bool IsDecoderSupportedByDevice(const std::string& android_mime_type) {
79 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); 81 DCHECK(MediaCodecUtil::IsMediaCodecAvailable());
80 DCHECK(IsSupportedAndroidMimeType(android_mime_type)); 82 DCHECK(IsSupportedAndroidMimeType(android_mime_type));
81 JNIEnv* env = AttachCurrentThread(); 83 JNIEnv* env = AttachCurrentThread();
82 ScopedJavaLocalRef<jstring> j_mime = 84 ScopedJavaLocalRef<jstring> j_mime =
83 ConvertUTF8ToJavaString(env, android_mime_type); 85 ConvertUTF8ToJavaString(env, android_mime_type);
84 return Java_MediaCodecUtil_isDecoderSupportedForDevice(env, j_mime.obj()); 86 return Java_MediaCodecUtil_isDecoderSupportedForDevice(env, j_mime.obj());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return Java_MediaCodecUtil_canDecode(env, j_mime.obj(), is_secure); 140 return Java_MediaCodecUtil_canDecode(env, j_mime.obj(), is_secure);
139 } 141 }
140 142
141 // static 143 // static
142 bool MediaCodecUtil::IsKnownUnaccelerated(const std::string& android_mime_type, 144 bool MediaCodecUtil::IsKnownUnaccelerated(const std::string& android_mime_type,
143 MediaCodecDirection direction) { 145 MediaCodecDirection direction) {
144 DCHECK(IsSupportedAndroidMimeType(android_mime_type)); 146 DCHECK(IsSupportedAndroidMimeType(android_mime_type));
145 if (!IsMediaCodecAvailable()) 147 if (!IsMediaCodecAvailable())
146 return true; 148 return true;
147 149
148 std::string codec_name = GetDefaultCodecName(android_mime_type, direction); 150 std::string codec_name =
151 GetDefaultCodecName(android_mime_type, direction, false);
149 DVLOG(1) << __FUNCTION__ << "Default codec for " << android_mime_type << " : " 152 DVLOG(1) << __FUNCTION__ << "Default codec for " << android_mime_type << " : "
150 << codec_name << ", direction: " << direction; 153 << codec_name << ", direction: " << direction;
151 if (!codec_name.size()) 154 if (!codec_name.size())
152 return true; 155 return true;
153 156
154 // MediaTek hardware vp8 is known slower than the software implementation. 157 // MediaTek hardware vp8 is known slower than the software implementation.
155 // MediaTek hardware vp9 is known crashy, see http://crbug.com/446974 and 158 // MediaTek hardware vp9 is known crashy, see http://crbug.com/446974 and
156 // http://crbug.com/597836. 159 // http://crbug.com/597836.
157 if (base::StartsWith(codec_name, "OMX.MTK.", base::CompareCase::SENSITIVE)) { 160 if (base::StartsWith(codec_name, "OMX.MTK.", base::CompareCase::SENSITIVE)) {
158 if (android_mime_type == kVp8MimeType) 161 if (android_mime_type == kVp8MimeType)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (base::StartsWith(model, model_prefixes[i], 232 if (base::StartsWith(model, model_prefixes[i],
230 base::CompareCase::INSENSITIVE_ASCII)) { 233 base::CompareCase::INSENSITIVE_ASCII)) {
231 return false; 234 return false;
232 } 235 }
233 } 236 }
234 237
235 return true; 238 return true;
236 } 239 }
237 240
238 } // namespace media 241 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_bridge.h ('k') | media/base/android/ndk_media_codec_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698