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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 2247403002: Assign color spaces to video frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use static_assert Created 4 years, 4 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.cc ('k') | media/filters/vpx_video_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_video_decoder.cc
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index b2915a0308a17e15451b409fea91194314e89928..0eca8e875c9a1a1cc299935ea5fc2a779bfa6d00 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -141,6 +141,18 @@ int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context,
video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE,
color_space);
+ if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED ||
+ codec_context->color_trc != AVCOL_TRC_UNSPECIFIED ||
+ codec_context->colorspace != AVCOL_SPC_UNSPECIFIED) {
+ video_frame->set_color_space(gfx::ColorSpace(
+ static_cast<gfx::ColorSpace::PrimaryID>(codec_context->color_primaries),
+ static_cast<gfx::ColorSpace::TransferID>(codec_context->color_trc),
+ static_cast<gfx::ColorSpace::MatrixID>(codec_context->colorspace),
+ codec_context->color_range != AVCOL_RANGE_MPEG
+ ? gfx::ColorSpace::RangeID::FULL
+ : gfx::ColorSpace::RangeID::LIMITED));
+ }
+
for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) {
frame->data[i] = video_frame->data(i);
frame->linesize[i] = video_frame->stride(i);
« no previous file with comments | « media/ffmpeg/ffmpeg_common.cc ('k') | media/filters/vpx_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698