| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/mac/video_frame_mac.h" | 5 #include "media/base/mac/video_frame_mac.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "media/base/mac/corevideo_glue.h" | 9 #include "media/base/mac/corevideo_glue.h" |
| 10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 if (frame.cv_pixel_buffer()) { | 36 if (frame.cv_pixel_buffer()) { |
| 37 pixel_buffer.reset(frame.cv_pixel_buffer(), base::scoped_policy::RETAIN); | 37 pixel_buffer.reset(frame.cv_pixel_buffer(), base::scoped_policy::RETAIN); |
| 38 return pixel_buffer; | 38 return pixel_buffer; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // VideoFrame only supports YUV formats and most of them are 'YVU' ordered, | 41 // VideoFrame only supports YUV formats and most of them are 'YVU' ordered, |
| 42 // which CVPixelBuffer does not support. This means we effectively can only | 42 // which CVPixelBuffer does not support. This means we effectively can only |
| 43 // represent I420 and NV12 frames. In addition, VideoFrame does not carry | 43 // represent I420 and NV12 frames. In addition, VideoFrame does not carry |
| 44 // colorimetric information, so this function assumes standard video range | 44 // colorimetric information, so this function assumes standard video range |
| 45 // and ITU Rec 709 primaries. | 45 // and ITU Rec 709 primaries. |
| 46 VideoFrame::Format video_frame_format = frame.format(); | 46 const VideoFrame::Format video_frame_format = frame.format(); |
| 47 OSType cv_format; | 47 OSType cv_format; |
| 48 if (video_frame_format == VideoFrame::Format::I420) { | 48 if (video_frame_format == VideoFrame::Format::I420) { |
| 49 cv_format = kCVPixelFormatType_420YpCbCr8Planar; | 49 cv_format = kCVPixelFormatType_420YpCbCr8Planar; |
| 50 } else if (video_frame_format == VideoFrame::Format::NV12) { | 50 } else if (video_frame_format == VideoFrame::Format::NV12) { |
| 51 cv_format = CoreVideoGlue::kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; | 51 cv_format = CoreVideoGlue::kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; |
| 52 } else { | 52 } else { |
| 53 DLOG(ERROR) << " unsupported frame format: " << video_frame_format; | 53 DLOG(ERROR) << " unsupported frame format: " << video_frame_format; |
| 54 return pixel_buffer; | 54 return pixel_buffer; |
| 55 } | 55 } |
| 56 | 56 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 kCVImageBufferTransferFunction_ITU_R_709_2, | 113 kCVImageBufferTransferFunction_ITU_R_709_2, |
| 114 kCVAttachmentMode_ShouldPropagate); | 114 kCVAttachmentMode_ShouldPropagate); |
| 115 CVBufferSetAttachment(pixel_buffer, kCVImageBufferYCbCrMatrixKey, | 115 CVBufferSetAttachment(pixel_buffer, kCVImageBufferYCbCrMatrixKey, |
| 116 kCVImageBufferYCbCrMatrix_ITU_R_709_2, | 116 kCVImageBufferYCbCrMatrix_ITU_R_709_2, |
| 117 kCVAttachmentMode_ShouldPropagate); | 117 kCVAttachmentMode_ShouldPropagate); |
| 118 | 118 |
| 119 return pixel_buffer; | 119 return pixel_buffer; |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace media | 122 } // namespace media |
| OLD | NEW |