Index: content/common/gpu/media/android_video_encode_accelerator.cc |
diff --git a/content/common/gpu/media/android_video_encode_accelerator.cc b/content/common/gpu/media/android_video_encode_accelerator.cc |
index 2507ea41c1f9b3c6782adc3681186827433da991..df376ccb684d8d0c4b266beb8a0fcb2dbaa4d64e 100644 |
--- a/content/common/gpu/media/android_video_encode_accelerator.cc |
+++ b/content/common/gpu/media/android_video_encode_accelerator.cc |
@@ -4,6 +4,9 @@ |
#include "content/common/gpu/media/android_video_encode_accelerator.h" |
+#include <algorithm> |
+#include <vector> |
+ |
#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/logging.h" |
@@ -26,8 +29,9 @@ using media::VideoFrame; |
namespace content { |
-enum { |
+enum ColorFormat { |
mcasas
2014/10/10 08:16:16
Please consider calling this PixelFormat.
changbin
2014/10/10 08:55:51
Done.
|
// Subset of MediaCodecInfo.CodecCapabilities. |
+ COLOR_FORMAT_YUV420_PLANAR = 19, |
COLOR_FORMAT_YUV420_SEMIPLANAR = 21, |
}; |
@@ -67,6 +71,17 @@ static inline const base::TimeDelta NoWaitTimeOut() { |
return base::TimeDelta::FromMicroseconds(0); |
} |
+ColorFormat GetSupportedColorFormatForMime(const std::string& mime) { |
mcasas
2014/10/10 08:16:16
static
changbin
2014/10/10 08:55:51
Done.
|
+ std::vector<int> formats = MediaCodecBridge::GetEncoderColorFormats(mime); |
+ for (std::vector<int>::iterator it = formats.begin(); it != formats.end(); |
mcasas
2014/10/10 08:16:16
Please use range-based for loop and const auto [1]
changbin
2014/10/10 08:55:51
Thanks for suggestion. Looks the loop can be remov
|
+ ++it) |
+ if (std::find(formats.begin(), formats.end(), COLOR_FORMAT_YUV420_PLANAR) != |
+ formats.end()) |
+ return COLOR_FORMAT_YUV420_PLANAR; |
+ |
mcasas
2014/10/10 08:16:16
nit: remove empty line.
changbin
2014/10/10 08:55:51
Done.
|
+ return COLOR_FORMAT_YUV420_SEMIPLANAR; |
+} |
+ |
AndroidVideoEncodeAccelerator::AndroidVideoEncodeAccelerator() |
: num_buffers_at_codec_(0), |
num_output_buffers_(-1), |
@@ -142,17 +157,14 @@ bool AndroidVideoEncodeAccelerator::Initialize( |
return false; |
} |
- // TODO(fischman): when there is more HW out there with different color-space |
- // support, this should turn into a negotiation with the codec for supported |
- // formats. For now we use the only format supported by the only available |
- // HW. |
- media_codec_.reset( |
- media::VideoCodecBridge::CreateEncoder(media::kCodecVP8, |
- input_visible_size, |
- initial_bitrate, |
- INITIAL_FRAMERATE, |
- IFRAME_INTERVAL, |
- COLOR_FORMAT_YUV420_SEMIPLANAR)); |
+ std::string mime = "video/x-vnd.on2.vp8"; |
+ media_codec_.reset(media::VideoCodecBridge::CreateEncoder( |
+ media::kCodecVP8, |
+ input_visible_size, |
+ initial_bitrate, |
+ INITIAL_FRAMERATE, |
+ IFRAME_INTERVAL, |
+ GetSupportedColorFormatForMime(mime))); |
if (!media_codec_) { |
DLOG(ERROR) << "Failed to create/start the codec: " |