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

Side by Side Diff: media/ffmpeg/ffmpeg_common.cc

Issue 591313008: Add support for Rec709 color space videos in software YUV convert path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up some bad rebasing... Created 6 years 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 "media/ffmpeg/ffmpeg_common.h" 5 #include "media/ffmpeg/ffmpeg_common.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // Note the PRESUBMIT_IGNORE_UMA_MAX below, this silences the PRESUBMIT.py 395 // Note the PRESUBMIT_IGNORE_UMA_MAX below, this silences the PRESUBMIT.py
396 // check for uma enum max usage, since we're abusing 396 // check for uma enum max usage, since we're abusing
397 // UMA_HISTOGRAM_ENUMERATION to report a discrete value. 397 // UMA_HISTOGRAM_ENUMERATION to report a discrete value.
398 UMA_HISTOGRAM_ENUMERATION("Media.VideoColorRange", 398 UMA_HISTOGRAM_ENUMERATION("Media.VideoColorRange",
399 stream->codec->color_range, 399 stream->codec->color_range,
400 AVCOL_RANGE_NB); // PRESUBMIT_IGNORE_UMA_MAX 400 AVCOL_RANGE_NB); // PRESUBMIT_IGNORE_UMA_MAX
401 } 401 }
402 402
403 VideoFrame::Format format = PixelFormatToVideoFormat(stream->codec->pix_fmt); 403 VideoFrame::Format format = PixelFormatToVideoFormat(stream->codec->pix_fmt);
404 if (codec == kCodecVP9) { 404 if (codec == kCodecVP9) {
405 // TODO(tomfinegan): libavcodec doesn't know about VP9. 405 // TODO(tomfinegan): libavcodec doesn't know about VP9.
DaleCurtis 2014/12/15 18:47:34 Can you check with fgalligan@ to see if VP9 needs
rileya (GONE FROM CHROMIUM) 2014/12/16 22:05:59 Will do.
406 format = VideoFrame::YV12; 406 format = VideoFrame::YV12;
407 coded_size = visible_rect.size(); 407 coded_size = visible_rect.size();
408 } 408 }
409 409
410 // YV12 frames may be in HD color space.
411 if (format == VideoFrame::YV12 &&
412 stream->codec->colorspace == AVCOL_SPC_BT709) {
413 format = VideoFrame::YV12HD;
414 }
415
410 // Pad out |coded_size| for subsampled YUV formats. 416 // Pad out |coded_size| for subsampled YUV formats.
411 if (format != VideoFrame::YV24) { 417 if (format != VideoFrame::YV24) {
412 coded_size.set_width((coded_size.width() + 1) / 2 * 2); 418 coded_size.set_width((coded_size.width() + 1) / 2 * 2);
413 if (format != VideoFrame::YV16) 419 if (format != VideoFrame::YV16)
414 coded_size.set_height((coded_size.height() + 1) / 2 * 2); 420 coded_size.set_height((coded_size.height() + 1) / 2 * 2);
415 } 421 }
416 422
417 bool is_encrypted = false; 423 bool is_encrypted = false;
418 AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0); 424 AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0);
419 if (key) 425 if (key)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format; 545 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format;
540 } 546 }
541 return VideoFrame::UNKNOWN; 547 return VideoFrame::UNKNOWN;
542 } 548 }
543 549
544 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { 550 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) {
545 switch (video_format) { 551 switch (video_format) {
546 case VideoFrame::YV16: 552 case VideoFrame::YV16:
547 return PIX_FMT_YUV422P; 553 return PIX_FMT_YUV422P;
548 case VideoFrame::YV12: 554 case VideoFrame::YV12:
555 case VideoFrame::YV12HD:
549 return PIX_FMT_YUV420P; 556 return PIX_FMT_YUV420P;
550 case VideoFrame::YV12J: 557 case VideoFrame::YV12J:
551 return PIX_FMT_YUVJ420P; 558 return PIX_FMT_YUVJ420P;
552 case VideoFrame::YV12A: 559 case VideoFrame::YV12A:
553 return PIX_FMT_YUVA420P; 560 return PIX_FMT_YUVA420P;
554 case VideoFrame::YV24: 561 case VideoFrame::YV24:
555 return PIX_FMT_YUV444P; 562 return PIX_FMT_YUV444P;
556 default: 563 default:
557 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; 564 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format;
558 } 565 }
(...skipping 27 matching lines...) Expand all
586 return false; 593 return false;
587 594
588 *out = parsed_time; 595 *out = parsed_time;
589 return true; 596 return true;
590 } 597 }
591 598
592 return false; 599 return false;
593 } 600 }
594 601
595 } // namespace media 602 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698