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

Unified Diff: media/ffmpeg/ffmpeg_common.cc

Issue 1230593005: Reland: Change the video color space default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: big 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 1630c0d6e85941a5c3768441509cf40667a0f7fa..e2e9892f50fa238595218ae1e190ad49933bdd62 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -432,12 +432,18 @@ void AVStreamToVideoDecoderConfig(
format = PIXEL_FORMAT_YV12A;
}
- config->Initialize(
- codec, profile, format,
- (stream->codec->colorspace == AVCOL_SPC_BT709) ? COLOR_SPACE_HD_REC709
- : 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.
+ ColorSpace color_space = AVColorSpaceToColorSpace(stream->codec->colorspace);
+ if (color_space == COLOR_SPACE_UNSPECIFIED) {
+ // Otherwise, assume that SD video is usually Rec.601, and HD is usually
+ // Rec.709.
+ color_space = (natural_size.height() < 720) ? COLOR_SPACE_SD_REC601
+ : 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(
@@ -561,6 +567,22 @@ PixelFormat VideoPixelFormatToPixelFormat(VideoPixelFormat video_format) {
return PIX_FMT_NONE;
}
+ColorSpace AVColorSpaceToColorSpace(
+ AVColorSpace color_space) {
+ switch (color_space) {
+ case AVCOL_SPC_UNSPECIFIED:
+ break;
+ case AVCOL_SPC_BT709:
+ return COLOR_SPACE_HD_REC709;
+ case AVCOL_SPC_SMPTE170M:
+ case AVCOL_SPC_BT470BG:
+ return COLOR_SPACE_SD_REC601;
+ default:
+ DVLOG(1) << "Unknown AVColorSpace: " << color_space;
+ }
+ return 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