| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 num_rendered_frames_(0), | 30 num_rendered_frames_(0), |
| 31 black_frame_(false) {} | 31 black_frame_(false) {} |
| 32 | 32 |
| 33 virtual void OnFrame(const VideoFrame& frame) { | 33 virtual void OnFrame(const VideoFrame& frame) { |
| 34 rtc::CritScope cs(&crit_); | 34 rtc::CritScope cs(&crit_); |
| 35 // TODO(zhurunz) Check with VP8 team to see if we can remove this | 35 // TODO(zhurunz) Check with VP8 team to see if we can remove this |
| 36 // tolerance on Y values. | 36 // tolerance on Y values. |
| 37 black_frame_ = CheckFrameColorYuv(6, 48, 128, 128, 128, 128, &frame); | 37 black_frame_ = CheckFrameColorYuv(6, 48, 128, 128, 128, 128, &frame); |
| 38 // Treat unexpected frame size as error. | 38 // Treat unexpected frame size as error. |
| 39 ++num_rendered_frames_; | 39 ++num_rendered_frames_; |
| 40 width_ = static_cast<int>(frame.GetWidth()); | 40 width_ = frame.width(); |
| 41 height_ = static_cast<int>(frame.GetHeight()); | 41 height_ = frame.height(); |
| 42 rotation_ = frame.GetVideoRotation(); | 42 rotation_ = frame.GetVideoRotation(); |
| 43 timestamp_ = frame.GetTimeStamp(); | 43 timestamp_ = frame.GetTimeStamp(); |
| 44 SignalRenderFrame(&frame); | 44 SignalRenderFrame(&frame); |
| 45 } | 45 } |
| 46 | 46 |
| 47 int errors() const { return errors_; } | 47 int errors() const { return errors_; } |
| 48 int width() const { | 48 int width() const { |
| 49 rtc::CritScope cs(&crit_); | 49 rtc::CritScope cs(&crit_); |
| 50 return width_; | 50 return width_; |
| 51 } | 51 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 uint8_t y_max, | 79 uint8_t y_max, |
| 80 uint8_t u_min, | 80 uint8_t u_min, |
| 81 uint8_t u_max, | 81 uint8_t u_max, |
| 82 uint8_t v_min, | 82 uint8_t v_min, |
| 83 uint8_t v_max, | 83 uint8_t v_max, |
| 84 const cricket::VideoFrame* frame) { | 84 const cricket::VideoFrame* frame) { |
| 85 if (!frame) { | 85 if (!frame) { |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 // Y | 88 // Y |
| 89 size_t y_width = frame->GetWidth(); | 89 int y_width = frame->width(); |
| 90 size_t y_height = frame->GetHeight(); | 90 int y_height = frame->height(); |
| 91 const uint8_t* y_plane = frame->GetYPlane(); | 91 const uint8_t* y_plane = frame->GetYPlane(); |
| 92 const uint8_t* y_pos = y_plane; | 92 const uint8_t* y_pos = y_plane; |
| 93 int32_t y_pitch = frame->GetYPitch(); | 93 int32_t y_pitch = frame->GetYPitch(); |
| 94 for (size_t i = 0; i < y_height; ++i) { | 94 for (int i = 0; i < y_height; ++i) { |
| 95 for (size_t j = 0; j < y_width; ++j) { | 95 for (int j = 0; j < y_width; ++j) { |
| 96 uint8_t y_value = *(y_pos + j); | 96 uint8_t y_value = *(y_pos + j); |
| 97 if (y_value < y_min || y_value > y_max) { | 97 if (y_value < y_min || y_value > y_max) { |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 y_pos += y_pitch; | 101 y_pos += y_pitch; |
| 102 } | 102 } |
| 103 // U and V | 103 // U and V |
| 104 size_t chroma_width = frame->GetChromaWidth(); | 104 int chroma_width = (frame->width() + 1)/2; |
| 105 size_t chroma_height = frame->GetChromaHeight(); | 105 int chroma_height = (frame->height() + 1)/2; |
| 106 const uint8_t* u_plane = frame->GetUPlane(); | 106 const uint8_t* u_plane = frame->GetUPlane(); |
| 107 const uint8_t* v_plane = frame->GetVPlane(); | 107 const uint8_t* v_plane = frame->GetVPlane(); |
| 108 const uint8_t* u_pos = u_plane; | 108 const uint8_t* u_pos = u_plane; |
| 109 const uint8_t* v_pos = v_plane; | 109 const uint8_t* v_pos = v_plane; |
| 110 int32_t u_pitch = frame->GetUPitch(); | 110 int32_t u_pitch = frame->GetUPitch(); |
| 111 int32_t v_pitch = frame->GetVPitch(); | 111 int32_t v_pitch = frame->GetVPitch(); |
| 112 for (size_t i = 0; i < chroma_height; ++i) { | 112 for (int i = 0; i < chroma_height; ++i) { |
| 113 for (size_t j = 0; j < chroma_width; ++j) { | 113 for (int j = 0; j < chroma_width; ++j) { |
| 114 uint8_t u_value = *(u_pos + j); | 114 uint8_t u_value = *(u_pos + j); |
| 115 if (u_value < u_min || u_value > u_max) { | 115 if (u_value < u_min || u_value > u_max) { |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 uint8_t v_value = *(v_pos + j); | 118 uint8_t v_value = *(v_pos + j); |
| 119 if (v_value < v_min || v_value > v_max) { | 119 if (v_value < v_min || v_value > v_max) { |
| 120 return false; | 120 return false; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 u_pos += u_pitch; | 123 u_pos += u_pitch; |
| 124 v_pos += v_pitch; | 124 v_pos += v_pitch; |
| 125 } | 125 } |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 int errors_; | 129 int errors_; |
| 130 int width_; | 130 int width_; |
| 131 int height_; | 131 int height_; |
| 132 webrtc::VideoRotation rotation_; | 132 webrtc::VideoRotation rotation_; |
| 133 int64_t timestamp_; | 133 int64_t timestamp_; |
| 134 int num_rendered_frames_; | 134 int num_rendered_frames_; |
| 135 bool black_frame_; | 135 bool black_frame_; |
| 136 rtc::CriticalSection crit_; | 136 rtc::CriticalSection crit_; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 } // namespace cricket | 139 } // namespace cricket |
| 140 | 140 |
| 141 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ | 141 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ |
| OLD | NEW |