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

Unified 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: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/ffmpeg/ffmpeg_common.h ('k') | media/filters/decrypting_demuxer_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/ffmpeg/ffmpeg_common.cc
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index cb806c74812aba84ee66885a36f746f161ad0129..ba01afd0d60de6dc09f63289e7665f50bb88cbff 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -431,16 +431,20 @@ void AVStreamToVideoDecoderConfig(
format = VideoFrame::YV12A;
}
- config->Initialize(codec,
- profile,
- format,
- (stream->codec->colorspace == AVCOL_SPC_BT709)
- ? VideoFrame::COLOR_SPACE_HD_REC709
- : VideoFrame::COLOR_SPACE_UNSPECIFIED,
- coded_size, visible_rect, natural_size,
- stream->codec->extradata, stream->codec->extradata_size,
- is_encrypted,
- record_stats);
+ // Prefer the color space found by libavcodec if available.
+ VideoFrame::ColorSpace color_space =
+ AVColorSpaceToVideoFrameColorSpace(stream->codec->colorspace);
+ if (color_space == VideoFrame::COLOR_SPACE_UNSPECIFIED) {
+ // Otherwise, assume that SD video is usually Rec.601, and HD is usually
+ // Rec.709.
+ color_space = (natural_size.height() < 720)
+ ? VideoFrame::COLOR_SPACE_SD_REC601
+ : VideoFrame::COLOR_SPACE_HD_REC709;
+ }
+
+ config->Initialize(codec, profile, format, color_space, coded_size,
+ visible_rect, natural_size, stream->codec->extradata,
+ stream->codec->extradata_size, is_encrypted, record_stats);
}
void VideoDecoderConfigToAVCodecContext(
@@ -564,6 +568,22 @@ PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) {
return PIX_FMT_NONE;
}
+VideoFrame::ColorSpace AVColorSpaceToVideoFrameColorSpace(
+ AVColorSpace color_space) {
+ switch (color_space) {
+ case AVCOL_SPC_BT709:
+ return VideoFrame::COLOR_SPACE_HD_REC709;
+ case AVCOL_SPC_SMPTE170M:
+ case AVCOL_SPC_BT470BG:
+ return VideoFrame::COLOR_SPACE_SD_REC601;
+ case AVCOL_SPC_UNSPECIFIED:
+ break;
+ default:
+ DVLOG(1) << "Unknown AVColorSpace: " << color_space;
+ }
+ return VideoFrame::COLOR_SPACE_UNSPECIFIED;
+}
+
bool FFmpegUTCDateToTime(const char* date_utc, base::Time* out) {
DCHECK(date_utc);
DCHECK(out);
« no previous file with comments | « media/ffmpeg/ffmpeg_common.h ('k') | media/filters/decrypting_demuxer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698