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

Unified Diff: content/renderer/media/webrtc/video_destination_handler.cc

Issue 675513002: PepperVideoSourceHost: Change endianness of color format of frames sent to the plugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: content/renderer/media/webrtc/video_destination_handler.cc
diff --git a/content/renderer/media/webrtc/video_destination_handler.cc b/content/renderer/media/webrtc/video_destination_handler.cc
index 0e3734665f816f5ce40239f41a0cf78a92dfe8c8..6e254699f83cd00831445b9a11514302ce97a584 100644
--- a/content/renderer/media/webrtc/video_destination_handler.cc
+++ b/content/renderer/media/webrtc/video_destination_handler.cc
@@ -73,7 +73,7 @@ void PpFrameWriter::FrameWriterDelegate::DeliverFrameOnIO(
new_frame_callback_.Run(frame, format, base::TimeTicks());
}
-PpFrameWriter::PpFrameWriter() : endian_(UNKNOWN) {
+PpFrameWriter::PpFrameWriter() {
DVLOG(3) << "PpFrameWriter ctor";
}
@@ -157,46 +157,16 @@ void PpFrameWriter::PutFrame(PPB_ImageData_Impl* image_data,
MediaStreamVideoSource::kUnknownFrameRate,
media::PIXEL_FORMAT_YV12);
- // TODO(magjed): Remove this and always use libyuv::ARGBToI420 when
- // crbug/426020 is fixed.
- // Due to a change in endianness, we try to determine it from the data.
- // The alpha channel is always 255. It is unlikely for other color channels to
- // be 255, so we will most likely break on the first few pixels in the first
- // frame.
- const uint8* row_ptr = src_data;
- // Note that we only do this if endian_ is still UNKNOWN.
- for (int y = 0; y < height && endian_ == UNKNOWN; ++y) {
- for (int x = 0; x < width; ++x) {
- if (row_ptr[x * 4 + 0] != 255) { // First byte is not Alpha => XXXA.
- endian_ = XXXA;
- break;
- }
- if (row_ptr[x * 4 + 3] != 255) { // Fourth byte is not Alpha => AXXX.
- endian_ = AXXX;
- break;
- }
- }
- row_ptr += src_stride;
- }
- if (endian_ == UNKNOWN) {
- LOG(WARNING) << "PpFrameWriter::FrameWriterDelegate::DeliverFrameOnIO - "
- << "Could not determine endianness.";
- }
- // libyuv specifies fourcc/channel ordering the same as webrtc. That is why
- // the naming is reversed compared to PixelEndian and PP_ImageDataFormat which
- // describes the memory layout from the lowest address to the highest.
- auto xxxxToI420 =
- (endian_ == AXXX) ? &libyuv::BGRAToI420 : &libyuv::ARGBToI420;
- xxxxToI420(src_data,
- src_stride,
- new_frame->data(media::VideoFrame::kYPlane),
- new_frame->stride(media::VideoFrame::kYPlane),
- new_frame->data(media::VideoFrame::kUPlane),
- new_frame->stride(media::VideoFrame::kUPlane),
- new_frame->data(media::VideoFrame::kVPlane),
- new_frame->stride(media::VideoFrame::kVPlane),
- width,
- height);
+ libyuv::ARGBToI420(src_data,
+ src_stride,
+ new_frame->data(media::VideoFrame::kYPlane),
+ new_frame->stride(media::VideoFrame::kYPlane),
+ new_frame->data(media::VideoFrame::kUPlane),
+ new_frame->stride(media::VideoFrame::kUPlane),
+ new_frame->data(media::VideoFrame::kVPlane),
+ new_frame->stride(media::VideoFrame::kVPlane),
+ width,
+ height);
delegate_->DeliverFrame(new_frame, format);
}
« no previous file with comments | « content/renderer/media/webrtc/video_destination_handler.h ('k') | content/renderer/pepper/pepper_video_source_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698