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

Unified Diff: content/common/gpu/media/android_video_encode_accelerator.cc

Issue 648613003: Add support for color formats negotiation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/base/android/java/src/org/chromium/media/MediaCodecBridge.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e648eb6e36bc93e913a7ef028d89f58f8afe7735 100644
--- a/content/common/gpu/media/android_video_encode_accelerator.cc
+++ b/content/common/gpu/media/android_video_encode_accelerator.cc
@@ -4,6 +4,8 @@
#include "content/common/gpu/media/android_video_encode_accelerator.h"
+#include <set>
+
#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
@@ -26,9 +28,11 @@ using media::VideoFrame;
namespace content {
-enum {
+enum PixelFormat {
// Subset of MediaCodecInfo.CodecCapabilities.
+ COLOR_FORMAT_YUV420_PLANAR = 19,
COLOR_FORMAT_YUV420_SEMIPLANAR = 21,
+ COLOR_FORMAT_UNKNOWN,
xhwang 2014/10/15 04:15:45 This is confusing because value "22" is a valid on
changbin 2014/10/15 07:00:37 Done.
};
// Helper macros for dealing with failure. If |result| evaluates false, emit
@@ -67,6 +71,15 @@ static inline const base::TimeDelta NoWaitTimeOut() {
return base::TimeDelta::FromMicroseconds(0);
}
+static PixelFormat GetSupportedColorFormatForMime(const std::string& mime) {
+ std::set<int> formats = MediaCodecBridge::GetEncoderColorFormats(mime);
+ if (formats.find(COLOR_FORMAT_YUV420_SEMIPLANAR) != formats.end())
+ return COLOR_FORMAT_YUV420_SEMIPLANAR;
+ if (formats.find(COLOR_FORMAT_YUV420_PLANAR) != formats.end())
+ return COLOR_FORMAT_YUV420_PLANAR;
+ return COLOR_FORMAT_UNKNOWN;
+}
+
AndroidVideoEncodeAccelerator::AndroidVideoEncodeAccelerator()
: num_buffers_at_codec_(0),
num_output_buffers_(-1),
@@ -142,17 +155,16 @@ 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));
+ PixelFormat pixel_format =
+ GetSupportedColorFormatForMime("video/x-vnd.on2.vp8");
+ if (pixel_format == COLOR_FORMAT_UNKNOWN)
+ return false;
+ media_codec_.reset(media::VideoCodecBridge::CreateEncoder(media::kCodecVP8,
+ input_visible_size,
+ initial_bitrate,
+ INITIAL_FRAMERATE,
+ IFRAME_INTERVAL,
+ pixel_format));
if (!media_codec_) {
DLOG(ERROR) << "Failed to create/start the codec: "
« no previous file with comments | « no previous file | media/base/android/java/src/org/chromium/media/MediaCodecBridge.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698