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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/filters/ffmpeg_video_decoder.h" 5 #include "media/filters/ffmpeg_video_decoder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 // Prefer the color space from the codec context. If it's not specified (or is 135 // Prefer the color space from the codec context. If it's not specified (or is
136 // set to an unsupported value), fall back on the value from the config. 136 // set to an unsupported value), fall back on the value from the config.
137 ColorSpace color_space = AVColorSpaceToColorSpace(codec_context->colorspace, 137 ColorSpace color_space = AVColorSpaceToColorSpace(codec_context->colorspace,
138 codec_context->color_range); 138 codec_context->color_range);
139 if (color_space == COLOR_SPACE_UNSPECIFIED) 139 if (color_space == COLOR_SPACE_UNSPECIFIED)
140 color_space = config_.color_space(); 140 color_space = config_.color_space();
141 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, 141 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE,
142 color_space); 142 color_space);
143 143
144 if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED ||
145 codec_context->color_trc != AVCOL_TRC_UNSPECIFIED ||
146 codec_context->colorspace != AVCOL_SPC_UNSPECIFIED) {
147 video_frame->set_color_space(gfx::ColorSpace(
148 static_cast<gfx::ColorSpace::PrimaryID>(codec_context->color_primaries),
149 static_cast<gfx::ColorSpace::TransferID>(codec_context->color_trc),
150 static_cast<gfx::ColorSpace::MatrixID>(codec_context->colorspace),
151 codec_context->color_range != AVCOL_RANGE_MPEG
152 ? gfx::ColorSpace::RangeID::FULL
153 : gfx::ColorSpace::RangeID::LIMITED));
154 }
155
144 for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) { 156 for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) {
145 frame->data[i] = video_frame->data(i); 157 frame->data[i] = video_frame->data(i);
146 frame->linesize[i] = video_frame->stride(i); 158 frame->linesize[i] = video_frame->stride(i);
147 } 159 }
148 160
149 frame->width = coded_size.width(); 161 frame->width = coded_size.width();
150 frame->height = coded_size.height(); 162 frame->height = coded_size.height();
151 frame->format = codec_context->pix_fmt; 163 frame->format = codec_context->pix_fmt;
152 frame->reordered_opaque = codec_context->reordered_opaque; 164 frame->reordered_opaque = codec_context->reordered_opaque;
153 165
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 386 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
375 ReleaseFFmpegResources(); 387 ReleaseFFmpegResources();
376 return false; 388 return false;
377 } 389 }
378 390
379 av_frame_.reset(av_frame_alloc()); 391 av_frame_.reset(av_frame_alloc());
380 return true; 392 return true;
381 } 393 }
382 394
383 } // namespace media 395 } // namespace media
OLDNEW
« 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