1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "common_video/libyuv/include/webrtc_libyuv.h"
12
13 #include <cstdint>
14
15 #include "api/video/i420_buffer.h"
16 #include "common_video/include/video_frame_buffer.h"
17 #include "rtc_base/bind.h"
18 #include "rtc_base/checks.h"
19 #include "third_party/libyuv/include/libyuv.h"
20
21 namespace webrtc {
22
CalcBufferSize(VideoType type,int width,int height)23 size_t CalcBufferSize(VideoType type, int width, int height) {
24 RTC_DCHECK_GE(width, 0);
25 RTC_DCHECK_GE(height, 0);
26 size_t buffer_size = 0;
27 switch (type) {
28 case VideoType::kI420:
29 case VideoType::kNV12:
30 case VideoType::kNV21:
31 case VideoType::kIYUV:
32 case VideoType::kYV12: {
33 int half_width = (width + 1) >> 1;
34 int half_height = (height + 1) >> 1;
35 buffer_size = width * height + half_width * half_height * 2;
36 break;
37 }
38 case VideoType::kARGB4444:
39 case VideoType::kRGB565:
40 case VideoType::kARGB1555:
41 case VideoType::kYUY2:
42 case VideoType::kUYVY:
43 buffer_size = width * height * 2;
44 break;
45 case VideoType::kRGB24:
46 buffer_size = width * height * 3;
47 break;
48 case VideoType::kBGRA:
49 case VideoType::kARGB:
50 buffer_size = width * height * 4;
51 break;
52 default:
53 RTC_NOTREACHED();
54 break;
55 }
56 return buffer_size;
57 }
58
PrintPlane(const uint8_t * buf,int width,int height,int stride,FILE * file)59 static int PrintPlane(const uint8_t* buf,
60 int width,
61 int height,
62 int stride,
63 FILE* file) {
64 for (int i = 0; i < height; i++, buf += stride) {
65 if (fwrite(buf, 1, width, file) != static_cast<unsigned int>(width))
66 return -1;
67 }
68 return 0;
69 }
70
71 // TODO(nisse): Belongs with the test code?
PrintVideoFrame(const I420BufferInterface & frame,FILE * file)72 int PrintVideoFrame(const I420BufferInterface& frame, FILE* file) {
73 int width = frame.width();
74 int height = frame.height();
75 int chroma_width = frame.ChromaWidth();
76 int chroma_height = frame.ChromaHeight();
77
78 if (PrintPlane(frame.DataY(), width, height, frame.StrideY(), file) < 0) {
79 return -1;
80 }
81 if (PrintPlane(frame.DataU(), chroma_width, chroma_height, frame.StrideU(),
82 file) < 0) {
83 return -1;
84 }
85 if (PrintPlane(frame.DataV(), chroma_width, chroma_height, frame.StrideV(),
86 file) < 0) {
87 return -1;
88 }
89 return 0;
90 }
91
PrintVideoFrame(const VideoFrame & frame,FILE * file)92 int PrintVideoFrame(const VideoFrame& frame, FILE* file) {
93 return PrintVideoFrame(*frame.video_frame_buffer()->ToI420(), file);
94 }
95
ExtractBuffer(const rtc::scoped_refptr<I420BufferInterface> & input_frame,size_t size,uint8_t * buffer)96 int ExtractBuffer(const rtc::scoped_refptr<I420BufferInterface>& input_frame,
97 size_t size,
98 uint8_t* buffer) {
99 RTC_DCHECK(buffer);
100 if (!input_frame)
101 return -1;
102 int width = input_frame->width();
103 int height = input_frame->height();
104 size_t length = CalcBufferSize(VideoType::kI420, width, height);
105 if (size < length) {
106 return -1;
107 }
108
109 int chroma_width = input_frame->ChromaWidth();
110 int chroma_height = input_frame->ChromaHeight();
111
112 libyuv::I420Copy(input_frame->DataY(), input_frame->StrideY(),
113 input_frame->DataU(), input_frame->StrideU(),
114 input_frame->DataV(), input_frame->StrideV(), buffer, width,
115 buffer + width * height, chroma_width,
116 buffer + width * height + chroma_width * chroma_height,
117 chroma_width, width, height);
118
119 return static_cast<int>(length);
120 }
121
ExtractBuffer(const VideoFrame & input_frame,size_t size,uint8_t * buffer)122 int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer) {
123 return ExtractBuffer(input_frame.video_frame_buffer()->ToI420(), size,
124 buffer);
125 }
126
ConvertVideoType(VideoType video_type)127 int ConvertVideoType(VideoType video_type) {
128 switch (video_type) {
129 case VideoType::kUnknown:
130 return libyuv::FOURCC_ANY;
131 case VideoType::kI420:
132 return libyuv::FOURCC_I420;
133 case VideoType::kIYUV: // same as VideoType::kYV12
134 case VideoType::kYV12:
135 return libyuv::FOURCC_YV12;
136 case VideoType::kRGB24:
137 return libyuv::FOURCC_24BG;
138 case VideoType::kABGR:
139 return libyuv::FOURCC_ABGR;
140 case VideoType::kRGB565:
141 return libyuv::FOURCC_RGBP;
142 case VideoType::kYUY2:
143 return libyuv::FOURCC_YUY2;
144 case VideoType::kUYVY:
145 return libyuv::FOURCC_UYVY;
146 case VideoType::kMJPEG:
147 return libyuv::FOURCC_MJPG;
148 case VideoType::kNV21:
149 return libyuv::FOURCC_NV21;
150 case VideoType::kNV12:
151 return libyuv::FOURCC_NV12;
152 case VideoType::kARGB:
153 return libyuv::FOURCC_ARGB;
154 case VideoType::kBGRA:
155 return libyuv::FOURCC_BGRA;
156 case VideoType::kARGB4444:
157 return libyuv::FOURCC_R444;
158 case VideoType::kARGB1555:
159 return libyuv::FOURCC_RGBO;
160 }
161 RTC_NOTREACHED();
162 return libyuv::FOURCC_ANY;
163 }
164
ConvertFromI420(const VideoFrame & src_frame,VideoType dst_video_type,int dst_sample_size,uint8_t * dst_frame)165 int ConvertFromI420(const VideoFrame& src_frame,
166 VideoType dst_video_type,
167 int dst_sample_size,
168 uint8_t* dst_frame) {
169 rtc::scoped_refptr<I420BufferInterface> i420_buffer =
170 src_frame.video_frame_buffer()->ToI420();
171 return libyuv::ConvertFromI420(
172 i420_buffer->DataY(), i420_buffer->StrideY(), i420_buffer->DataU(),
173 i420_buffer->StrideU(), i420_buffer->DataV(), i420_buffer->StrideV(),
174 dst_frame, dst_sample_size, src_frame.width(), src_frame.height(),
175 ConvertVideoType(dst_video_type));
176 }
177
178 // Helper functions for keeping references alive.
KeepBufferRefs(rtc::scoped_refptr<webrtc::VideoFrameBuffer>,rtc::scoped_refptr<webrtc::VideoFrameBuffer>)179 void KeepBufferRefs(rtc::scoped_refptr<webrtc::VideoFrameBuffer>,
180 rtc::scoped_refptr<webrtc::VideoFrameBuffer>) {}
181
ScaleI420ABuffer(const I420ABufferInterface & buffer,int target_width,int target_height)182 rtc::scoped_refptr<I420ABufferInterface> ScaleI420ABuffer(
183 const I420ABufferInterface& buffer,
184 int target_width,
185 int target_height) {
186 rtc::scoped_refptr<I420Buffer> yuv_buffer =
187 I420Buffer::Create(target_width, target_height);
188 yuv_buffer->ScaleFrom(buffer);
189 rtc::scoped_refptr<I420Buffer> axx_buffer =
190 I420Buffer::Create(target_width, target_height);
191 libyuv::ScalePlane(buffer.DataA(), buffer.StrideA(), buffer.width(),
192 buffer.height(), axx_buffer->MutableDataY(),
193 axx_buffer->StrideY(), target_width, target_height,
194 libyuv::kFilterBox);
195 rtc::scoped_refptr<I420ABufferInterface> merged_buffer = WrapI420ABuffer(
196 yuv_buffer->width(), yuv_buffer->height(), yuv_buffer->DataY(),
197 yuv_buffer->StrideY(), yuv_buffer->DataU(), yuv_buffer->StrideU(),
198 yuv_buffer->DataV(), yuv_buffer->StrideV(), axx_buffer->DataY(),
199 axx_buffer->StrideY(),
200 rtc::Bind(&KeepBufferRefs, yuv_buffer, axx_buffer));
201 return merged_buffer;
202 }
203
ScaleVideoFrameBuffer(const I420BufferInterface & source,int dst_width,int dst_height)204 rtc::scoped_refptr<I420BufferInterface> ScaleVideoFrameBuffer(
205 const I420BufferInterface& source,
206 int dst_width,
207 int dst_height) {
208 rtc::scoped_refptr<I420Buffer> scaled_buffer =
209 I420Buffer::Create(dst_width, dst_height);
210 scaled_buffer->ScaleFrom(source);
211 return scaled_buffer;
212 }
213
I420SSE(const I420BufferInterface & ref_buffer,const I420BufferInterface & test_buffer)214 double I420SSE(const I420BufferInterface& ref_buffer,
215 const I420BufferInterface& test_buffer) {
216 RTC_DCHECK_EQ(ref_buffer.width(), test_buffer.width());
217 RTC_DCHECK_EQ(ref_buffer.height(), test_buffer.height());
218 const uint64_t width = test_buffer.width();
219 const uint64_t height = test_buffer.height();
220 const uint64_t sse_y = libyuv::ComputeSumSquareErrorPlane(
221 ref_buffer.DataY(), ref_buffer.StrideY(), test_buffer.DataY(),
222 test_buffer.StrideY(), width, height);
223 const int width_uv = (width + 1) >> 1;
224 const int height_uv = (height + 1) >> 1;
225 const uint64_t sse_u = libyuv::ComputeSumSquareErrorPlane(
226 ref_buffer.DataU(), ref_buffer.StrideU(), test_buffer.DataU(),
227 test_buffer.StrideU(), width_uv, height_uv);
228 const uint64_t sse_v = libyuv::ComputeSumSquareErrorPlane(
229 ref_buffer.DataV(), ref_buffer.StrideV(), test_buffer.DataV(),
230 test_buffer.StrideV(), width_uv, height_uv);
231 const double samples = width * height + 2 * (width_uv * height_uv);
232 const double sse = sse_y + sse_u + sse_v;
233 return sse / (samples * 255.0 * 255.0);
234 }
235
236 // Compute PSNR for an I420A frame (all planes). Can upscale test frame.
I420APSNR(const I420ABufferInterface & ref_buffer,const I420ABufferInterface & test_buffer)237 double I420APSNR(const I420ABufferInterface& ref_buffer,
238 const I420ABufferInterface& test_buffer) {
239 RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
240 RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
241 if ((ref_buffer.width() != test_buffer.width()) ||
242 (ref_buffer.height() != test_buffer.height())) {
243 rtc::scoped_refptr<I420ABufferInterface> scaled_buffer =
244 ScaleI420ABuffer(test_buffer, ref_buffer.width(), ref_buffer.height());
245 return I420APSNR(ref_buffer, *scaled_buffer);
246 }
247 const int width = test_buffer.width();
248 const int height = test_buffer.height();
249 const uint64_t sse_y = libyuv::ComputeSumSquareErrorPlane(
250 ref_buffer.DataY(), ref_buffer.StrideY(), test_buffer.DataY(),
251 test_buffer.StrideY(), width, height);
252 const int width_uv = (width + 1) >> 1;
253 const int height_uv = (height + 1) >> 1;
254 const uint64_t sse_u = libyuv::ComputeSumSquareErrorPlane(
255 ref_buffer.DataU(), ref_buffer.StrideU(), test_buffer.DataU(),
256 test_buffer.StrideU(), width_uv, height_uv);
257 const uint64_t sse_v = libyuv::ComputeSumSquareErrorPlane(
258 ref_buffer.DataV(), ref_buffer.StrideV(), test_buffer.DataV(),
259 test_buffer.StrideV(), width_uv, height_uv);
260 const uint64_t sse_a = libyuv::ComputeSumSquareErrorPlane(
261 ref_buffer.DataA(), ref_buffer.StrideA(), test_buffer.DataA(),
262 test_buffer.StrideA(), width, height);
263 const uint64_t samples = 2 * (uint64_t)width * (uint64_t)height +
264 2 * ((uint64_t)width_uv * (uint64_t)height_uv);
265 const uint64_t sse = sse_y + sse_u + sse_v + sse_a;
266 const double psnr = libyuv::SumSquareErrorToPsnr(sse, samples);
267 return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr;
268 }
269
270 // Compute PSNR for an I420A frame (all planes)
I420APSNR(const VideoFrame * ref_frame,const VideoFrame * test_frame)271 double I420APSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
272 if (!ref_frame || !test_frame)
273 return -1;
274 RTC_DCHECK(ref_frame->video_frame_buffer()->type() ==
275 VideoFrameBuffer::Type::kI420A);
276 RTC_DCHECK(test_frame->video_frame_buffer()->type() ==
277 VideoFrameBuffer::Type::kI420A);
278 return I420APSNR(*ref_frame->video_frame_buffer()->GetI420A(),
279 *test_frame->video_frame_buffer()->GetI420A());
280 }
281
282 // Compute PSNR for an I420 frame (all planes). Can upscale test frame.
I420PSNR(const I420BufferInterface & ref_buffer,const I420BufferInterface & test_buffer)283 double I420PSNR(const I420BufferInterface& ref_buffer,
284 const I420BufferInterface& test_buffer) {
285 RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
286 RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
287 if ((ref_buffer.width() != test_buffer.width()) ||
288 (ref_buffer.height() != test_buffer.height())) {
289 rtc::scoped_refptr<I420Buffer> scaled_buffer =
290 I420Buffer::Create(ref_buffer.width(), ref_buffer.height());
291 scaled_buffer->ScaleFrom(test_buffer);
292 return I420PSNR(ref_buffer, *scaled_buffer);
293 }
294 double psnr = libyuv::I420Psnr(
295 ref_buffer.DataY(), ref_buffer.StrideY(), ref_buffer.DataU(),
296 ref_buffer.StrideU(), ref_buffer.DataV(), ref_buffer.StrideV(),
297 test_buffer.DataY(), test_buffer.StrideY(), test_buffer.DataU(),
298 test_buffer.StrideU(), test_buffer.DataV(), test_buffer.StrideV(),
299 test_buffer.width(), test_buffer.height());
300 // LibYuv sets the max psnr value to 128, we restrict it here.
301 // In case of 0 mse in one frame, 128 can skew the results significantly.
302 return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr;
303 }
304
305 // Compute PSNR for an I420 frame (all planes)
I420PSNR(const VideoFrame * ref_frame,const VideoFrame * test_frame)306 double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
307 if (!ref_frame || !test_frame)
308 return -1;
309 return I420PSNR(*ref_frame->video_frame_buffer()->ToI420(),
310 *test_frame->video_frame_buffer()->ToI420());
311 }
312
313 // Compute SSIM for an I420A frame (all planes). Can upscale test frame.
I420ASSIM(const I420ABufferInterface & ref_buffer,const I420ABufferInterface & test_buffer)314 double I420ASSIM(const I420ABufferInterface& ref_buffer,
315 const I420ABufferInterface& test_buffer) {
316 RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
317 RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
318 if ((ref_buffer.width() != test_buffer.width()) ||
319 (ref_buffer.height() != test_buffer.height())) {
320 rtc::scoped_refptr<I420ABufferInterface> scaled_buffer =
321 ScaleI420ABuffer(test_buffer, ref_buffer.width(), ref_buffer.height());
322 return I420ASSIM(ref_buffer, *scaled_buffer);
323 }
324 const double yuv_ssim = libyuv::I420Ssim(
325 ref_buffer.DataY(), ref_buffer.StrideY(), ref_buffer.DataU(),
326 ref_buffer.StrideU(), ref_buffer.DataV(), ref_buffer.StrideV(),
327 test_buffer.DataY(), test_buffer.StrideY(), test_buffer.DataU(),
328 test_buffer.StrideU(), test_buffer.DataV(), test_buffer.StrideV(),
329 test_buffer.width(), test_buffer.height());
330 const double a_ssim = libyuv::CalcFrameSsim(
331 ref_buffer.DataA(), ref_buffer.StrideA(), test_buffer.DataA(),
332 test_buffer.StrideA(), test_buffer.width(), test_buffer.height());
333 return (yuv_ssim + (a_ssim * 0.8)) / 1.8;
334 }
335
336 // Compute SSIM for an I420A frame (all planes)
I420ASSIM(const VideoFrame * ref_frame,const VideoFrame * test_frame)337 double I420ASSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
338 if (!ref_frame || !test_frame)
339 return -1;
340 RTC_DCHECK(ref_frame->video_frame_buffer()->type() ==
341 VideoFrameBuffer::Type::kI420A);
342 RTC_DCHECK(test_frame->video_frame_buffer()->type() ==
343 VideoFrameBuffer::Type::kI420A);
344 return I420ASSIM(*ref_frame->video_frame_buffer()->GetI420A(),
345 *test_frame->video_frame_buffer()->GetI420A());
346 }
347
348 // Compute SSIM for an I420 frame (all planes). Can upscale test_buffer.
I420SSIM(const I420BufferInterface & ref_buffer,const I420BufferInterface & test_buffer)349 double I420SSIM(const I420BufferInterface& ref_buffer,
350 const I420BufferInterface& test_buffer) {
351 RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width());
352 RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height());
353 if ((ref_buffer.width() != test_buffer.width()) ||
354 (ref_buffer.height() != test_buffer.height())) {
355 rtc::scoped_refptr<I420Buffer> scaled_buffer =
356 I420Buffer::Create(ref_buffer.width(), ref_buffer.height());
357 scaled_buffer->ScaleFrom(test_buffer);
358 return I420SSIM(ref_buffer, *scaled_buffer);
359 }
360 return libyuv::I420Ssim(
361 ref_buffer.DataY(), ref_buffer.StrideY(), ref_buffer.DataU(),
362 ref_buffer.StrideU(), ref_buffer.DataV(), ref_buffer.StrideV(),
363 test_buffer.DataY(), test_buffer.StrideY(), test_buffer.DataU(),
364 test_buffer.StrideU(), test_buffer.DataV(), test_buffer.StrideV(),
365 test_buffer.width(), test_buffer.height());
366 }
367
I420SSIM(const VideoFrame * ref_frame,const VideoFrame * test_frame)368 double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
369 if (!ref_frame || !test_frame)
370 return -1;
371 return I420SSIM(*ref_frame->video_frame_buffer()->ToI420(),
372 *test_frame->video_frame_buffer()->ToI420());
373 }
374
NV12Scale(uint8_t * tmp_buffer,const uint8_t * src_y,int src_stride_y,const uint8_t * src_uv,int src_stride_uv,int src_width,int src_height,uint8_t * dst_y,int dst_stride_y,uint8_t * dst_uv,int dst_stride_uv,int dst_width,int dst_height)375 void NV12Scale(uint8_t* tmp_buffer,
376 const uint8_t* src_y,
377 int src_stride_y,
378 const uint8_t* src_uv,
379 int src_stride_uv,
380 int src_width,
381 int src_height,
382 uint8_t* dst_y,
383 int dst_stride_y,
384 uint8_t* dst_uv,
385 int dst_stride_uv,
386 int dst_width,
387 int dst_height) {
388 const int src_chroma_width = (src_width + 1) / 2;
389 const int src_chroma_height = (src_height + 1) / 2;
390
391 if (src_width == dst_width && src_height == dst_height) {
392 // No scaling.
393 libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, src_width,
394 src_height);
395 libyuv::CopyPlane(src_uv, src_stride_uv, dst_uv, dst_stride_uv,
396 src_chroma_width * 2, src_chroma_height);
397 return;
398 }
399
400 // Scaling.
401 // Allocate temporary memory for spitting UV planes and scaling them.
402 const int dst_chroma_width = (dst_width + 1) / 2;
403 const int dst_chroma_height = (dst_height + 1) / 2;
404
405 uint8_t* const src_u = tmp_buffer;
406 uint8_t* const src_v = src_u + src_chroma_width * src_chroma_height;
407 uint8_t* const dst_u = src_v + src_chroma_width * src_chroma_height;
408 uint8_t* const dst_v = dst_u + dst_chroma_width * dst_chroma_height;
409
410 // Split source UV plane into separate U and V plane using the temporary data.
411 libyuv::SplitUVPlane(src_uv, src_stride_uv, src_u, src_chroma_width, src_v,
412 src_chroma_width, src_chroma_width, src_chroma_height);
413
414 // Scale the planes.
415 libyuv::I420Scale(
416 src_y, src_stride_y, src_u, src_chroma_width, src_v, src_chroma_width,
417 src_width, src_height, dst_y, dst_stride_y, dst_u, dst_chroma_width,
418 dst_v, dst_chroma_width, dst_width, dst_height, libyuv::kFilterBox);
419
420 // Merge the UV planes into the destination.
421 libyuv::MergeUVPlane(dst_u, dst_chroma_width, dst_v, dst_chroma_width, dst_uv,
422 dst_stride_uv, dst_chroma_width, dst_chroma_height);
423 }
424
425 NV12ToI420Scaler::NV12ToI420Scaler() = default;
426 NV12ToI420Scaler::~NV12ToI420Scaler() = default;
427
NV12ToI420Scale(const uint8_t * src_y,int src_stride_y,const uint8_t * src_uv,int src_stride_uv,int src_width,int src_height,uint8_t * dst_y,int dst_stride_y,uint8_t * dst_u,int dst_stride_u,uint8_t * dst_v,int dst_stride_v,int dst_width,int dst_height)428 void NV12ToI420Scaler::NV12ToI420Scale(const uint8_t* src_y,
429 int src_stride_y,
430 const uint8_t* src_uv,
431 int src_stride_uv,
432 int src_width,
433 int src_height,
434 uint8_t* dst_y,
435 int dst_stride_y,
436 uint8_t* dst_u,
437 int dst_stride_u,
438 uint8_t* dst_v,
439 int dst_stride_v,
440 int dst_width,
441 int dst_height) {
442 if (src_width == dst_width && src_height == dst_height) {
443 // No scaling.
444 tmp_uv_planes_.clear();
445 tmp_uv_planes_.shrink_to_fit();
446 libyuv::NV12ToI420(src_y, src_stride_y, src_uv, src_stride_uv, dst_y,
447 dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v,
448 src_width, src_height);
449 return;
450 }
451
452 // Scaling.
453 // Allocate temporary memory for spitting UV planes.
454 const int src_uv_width = (src_width + 1) / 2;
455 const int src_uv_height = (src_height + 1) / 2;
456 tmp_uv_planes_.resize(src_uv_width * src_uv_height * 2);
457 tmp_uv_planes_.shrink_to_fit();
458
459 // Split source UV plane into separate U and V plane using the temporary data.
460 uint8_t* const src_u = tmp_uv_planes_.data();
461 uint8_t* const src_v = tmp_uv_planes_.data() + src_uv_width * src_uv_height;
462 libyuv::SplitUVPlane(src_uv, src_stride_uv, src_u, src_uv_width, src_v,
463 src_uv_width, src_uv_width, src_uv_height);
464
465 // Scale the planes into the destination.
466 libyuv::I420Scale(src_y, src_stride_y, src_u, src_uv_width, src_v,
467 src_uv_width, src_width, src_height, dst_y, dst_stride_y,
468 dst_u, dst_stride_u, dst_v, dst_stride_v, dst_width,
469 dst_height, libyuv::kFilterBox);
470 }
471
472 } // namespace webrtc
473