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

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

Issue 1221903003: Change the video color space default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable the JPEG blackwhite test Created 5 years, 5 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 "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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0); 423 AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0);
424 if (key) 424 if (key)
425 is_encrypted = true; 425 is_encrypted = true;
426 426
427 AVDictionaryEntry* webm_alpha = 427 AVDictionaryEntry* webm_alpha =
428 av_dict_get(stream->metadata, "alpha_mode", NULL, 0); 428 av_dict_get(stream->metadata, "alpha_mode", NULL, 0);
429 if (webm_alpha && !strcmp(webm_alpha->value, "1")) { 429 if (webm_alpha && !strcmp(webm_alpha->value, "1")) {
430 format = VideoFrame::YV12A; 430 format = VideoFrame::YV12A;
431 } 431 }
432 432
433 config->Initialize(codec, 433 // Prefer the color space found by libavcodec if available.
434 profile, 434 VideoFrame::ColorSpace color_space =
435 format, 435 AVColorSpaceToVideoFrameColorSpace(stream->codec->colorspace);
436 (stream->codec->colorspace == AVCOL_SPC_BT709) 436 if (color_space == VideoFrame::COLOR_SPACE_UNSPECIFIED)
437 ? VideoFrame::COLOR_SPACE_HD_REC709 437 color_space = VideoDecoderConfig::DefaultSrcColorSpace(natural_size);
438 : VideoFrame::COLOR_SPACE_UNSPECIFIED, 438
439 coded_size, visible_rect, natural_size, 439 config->Initialize(codec, profile, format, color_space, coded_size,
440 stream->codec->extradata, stream->codec->extradata_size, 440 visible_rect, natural_size, stream->codec->extradata,
441 is_encrypted, 441 stream->codec->extradata_size, is_encrypted, record_stats);
442 record_stats);
443 } 442 }
444 443
445 void VideoDecoderConfigToAVCodecContext( 444 void VideoDecoderConfigToAVCodecContext(
446 const VideoDecoderConfig& config, 445 const VideoDecoderConfig& config,
447 AVCodecContext* codec_context) { 446 AVCodecContext* codec_context) {
448 codec_context->codec_type = AVMEDIA_TYPE_VIDEO; 447 codec_context->codec_type = AVMEDIA_TYPE_VIDEO;
449 codec_context->codec_id = VideoCodecToCodecID(config.codec()); 448 codec_context->codec_id = VideoCodecToCodecID(config.codec());
450 codec_context->profile = VideoCodecProfileToProfileID(config.profile()); 449 codec_context->profile = VideoCodecProfileToProfileID(config.profile());
451 codec_context->coded_width = config.coded_size().width(); 450 codec_context->coded_width = config.coded_size().width();
452 codec_context->coded_height = config.coded_size().height(); 451 codec_context->coded_height = config.coded_size().height();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 case VideoFrame::YV12A: 555 case VideoFrame::YV12A:
557 return PIX_FMT_YUVA420P; 556 return PIX_FMT_YUVA420P;
558 case VideoFrame::YV24: 557 case VideoFrame::YV24:
559 return PIX_FMT_YUV444P; 558 return PIX_FMT_YUV444P;
560 default: 559 default:
561 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; 560 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format;
562 } 561 }
563 return PIX_FMT_NONE; 562 return PIX_FMT_NONE;
564 } 563 }
565 564
565 VideoFrame::ColorSpace AVColorSpaceToVideoFrameColorSpace(
566 AVColorSpace color_space) {
567 switch (color_space) {
568 case AVCOL_SPC_BT709:
569 return VideoFrame::COLOR_SPACE_HD_REC709;
570 case AVCOL_SPC_SMPTE170M:
571 case AVCOL_SPC_BT470BG:
572 return VideoFrame::COLOR_SPACE_SD_REC601;
573 case AVCOL_SPC_UNSPECIFIED:
574 break;
575 default:
576 DVLOG(1) << "Unknown AVColorSpace: " << color_space;
577 }
578 return VideoFrame::COLOR_SPACE_UNSPECIFIED;
579 }
580
566 bool FFmpegUTCDateToTime(const char* date_utc, 581 bool FFmpegUTCDateToTime(const char* date_utc,
567 base::Time* out) { 582 base::Time* out) {
568 DCHECK(date_utc); 583 DCHECK(date_utc);
569 DCHECK(out); 584 DCHECK(out);
570 585
571 std::vector<std::string> fields; 586 std::vector<std::string> fields;
572 std::vector<std::string> date_fields; 587 std::vector<std::string> date_fields;
573 std::vector<std::string> time_fields; 588 std::vector<std::string> time_fields;
574 base::Time::Exploded exploded; 589 base::Time::Exploded exploded;
575 exploded.millisecond = 0; 590 exploded.millisecond = 0;
(...skipping 14 matching lines...) Expand all
590 return false; 605 return false;
591 606
592 *out = parsed_time; 607 *out = parsed_time;
593 return true; 608 return true;
594 } 609 }
595 610
596 return false; 611 return false;
597 } 612 }
598 613
599 } // namespace media 614 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698