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

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller.cc

Issue 897483002: Refactored pixel format resize operations in media/video/capture into a function called VideoCaptu… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed function to a public member. Added tests. Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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 "content/browser/renderer_host/media/video_capture_controller.h" 5 #include "content/browser/renderer_host/media/video_capture_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 else if (rotation == 180) 420 else if (rotation == 180)
421 rotation_mode = libyuv::kRotate180; 421 rotation_mode = libyuv::kRotate180;
422 else if (rotation == 270) 422 else if (rotation == 270)
423 rotation_mode = libyuv::kRotate270; 423 rotation_mode = libyuv::kRotate270;
424 424
425 switch (frame_format.pixel_format) { 425 switch (frame_format.pixel_format) {
426 case media::PIXEL_FORMAT_UNKNOWN: // Color format not set. 426 case media::PIXEL_FORMAT_UNKNOWN: // Color format not set.
427 break; 427 break;
428 case media::PIXEL_FORMAT_I420: 428 case media::PIXEL_FORMAT_I420:
429 DCHECK(!chopped_width && !chopped_height); 429 DCHECK(!chopped_width && !chopped_height);
430 DCHECK_EQ(frame_format.ImageAllocationSize(),
mcasas 2015/02/03 20:48:46 Instead of reimplementing ImageAllocationSize() fo
431 (size_t) frame_format.frame_size.GetArea() * 3 / 2);
430 origin_colorspace = libyuv::FOURCC_I420; 432 origin_colorspace = libyuv::FOURCC_I420;
431 break; 433 break;
432 case media::PIXEL_FORMAT_YV12: 434 case media::PIXEL_FORMAT_YV12:
433 DCHECK(!chopped_width && !chopped_height); 435 DCHECK(!chopped_width && !chopped_height);
436 DCHECK_EQ(frame_format.ImageAllocationSize(),
437 (size_t) frame_format.frame_size.GetArea() * 3 / 2);
434 origin_colorspace = libyuv::FOURCC_YV12; 438 origin_colorspace = libyuv::FOURCC_YV12;
435 break; 439 break;
436 case media::PIXEL_FORMAT_NV12: 440 case media::PIXEL_FORMAT_NV12:
437 DCHECK(!chopped_width && !chopped_height); 441 DCHECK(!chopped_width && !chopped_height);
442 DCHECK_EQ(frame_format.ImageAllocationSize(),
443 (size_t) frame_format.frame_size.GetArea() * 3 / 2);
438 origin_colorspace = libyuv::FOURCC_NV12; 444 origin_colorspace = libyuv::FOURCC_NV12;
439 break; 445 break;
440 case media::PIXEL_FORMAT_NV21: 446 case media::PIXEL_FORMAT_NV21:
441 DCHECK(!chopped_width && !chopped_height); 447 DCHECK(!chopped_width && !chopped_height);
448 DCHECK_EQ(frame_format.ImageAllocationSize(),
449 (size_t) frame_format.frame_size.GetArea() * 3 / 2);
442 origin_colorspace = libyuv::FOURCC_NV21; 450 origin_colorspace = libyuv::FOURCC_NV21;
443 break; 451 break;
444 case media::PIXEL_FORMAT_YUY2: 452 case media::PIXEL_FORMAT_YUY2:
445 DCHECK(!chopped_width && !chopped_height); 453 DCHECK(!chopped_width && !chopped_height);
454 DCHECK_EQ(frame_format.ImageAllocationSize(),
455 (size_t) frame_format.frame_size.GetArea() * 2);
446 origin_colorspace = libyuv::FOURCC_YUY2; 456 origin_colorspace = libyuv::FOURCC_YUY2;
447 break; 457 break;
448 case media::PIXEL_FORMAT_UYVY: 458 case media::PIXEL_FORMAT_UYVY:
449 DCHECK(!chopped_width && !chopped_height); 459 DCHECK(!chopped_width && !chopped_height);
460 DCHECK_EQ(frame_format.ImageAllocationSize(),
461 (size_t) frame_format.frame_size.GetArea() * 2);
450 origin_colorspace = libyuv::FOURCC_UYVY; 462 origin_colorspace = libyuv::FOURCC_UYVY;
451 break; 463 break;
452 case media::PIXEL_FORMAT_RGB24: 464 case media::PIXEL_FORMAT_RGB24:
465 DCHECK_GE(frame_format.ImageAllocationSize(),
466 (size_t) frame_format.frame_size.GetArea() * 3);
453 origin_colorspace = libyuv::FOURCC_24BG; 467 origin_colorspace = libyuv::FOURCC_24BG;
454 #if defined(OS_WIN) 468 #if defined(OS_WIN)
455 // TODO(wjia): Currently, for RGB24 on WIN, capture device always 469 // TODO(wjia): Currently, for RGB24 on WIN, capture device always
456 // passes in positive src_width and src_height. Remove this hardcoded 470 // passes in positive src_width and src_height. Remove this hardcoded
457 // value when nagative src_height is supported. The negative src_height 471 // value when nagative src_height is supported. The negative src_height
458 // indicates that vertical flipping is needed. 472 // indicates that vertical flipping is needed.
459 flip = true; 473 flip = true;
460 #endif 474 #endif
461 break; 475 break;
462 case media::PIXEL_FORMAT_ARGB: 476 case media::PIXEL_FORMAT_ARGB:
463 origin_colorspace = libyuv::FOURCC_ARGB; 477 origin_colorspace = libyuv::FOURCC_ARGB;
464 break; 478 break;
465 case media::PIXEL_FORMAT_MJPEG: 479 case media::PIXEL_FORMAT_MJPEG:
480 DCHECK_LE(frame_format.ImageAllocationSize(),
481 (size_t) frame_format.frame_size.GetArea() * 3);
466 origin_colorspace = libyuv::FOURCC_MJPG; 482 origin_colorspace = libyuv::FOURCC_MJPG;
467 break; 483 break;
468 default: 484 default:
469 NOTREACHED(); 485 NOTREACHED();
470 } 486 }
471 487
472 libyuv::ConvertToI420(data, 488 libyuv::ConvertToI420(data,
473 length, 489 length,
474 yplane, 490 yplane,
475 yplane_stride, 491 yplane_stride,
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 DCHECK_CURRENTLY_ON(BrowserThread::IO); 739 DCHECK_CURRENTLY_ON(BrowserThread::IO);
724 int active_client_count = 0; 740 int active_client_count = 0;
725 for (ControllerClient* client : controller_clients_) { 741 for (ControllerClient* client : controller_clients_) {
726 if (!client->paused) 742 if (!client->paused)
727 ++active_client_count; 743 ++active_client_count;
728 } 744 }
729 return active_client_count; 745 return active_client_count;
730 } 746 }
731 747
732 } // namespace content 748 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/video/capture/file_video_capture_device.cc » ('j') | media/video/capture/file_video_capture_device.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698