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

Side by Side Diff: media/filters/ffmpeg_video_decoder.cc

Issue 2697863003: color: Clarify default behaviors (Closed)
Patch Set: color: Remove redundant PrimaryID/TransferID/MatrixID values Created 3 years, 10 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/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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 ColorSpace color_space = AVColorSpaceToColorSpace(codec_context->colorspace, 178 ColorSpace color_space = AVColorSpaceToColorSpace(codec_context->colorspace,
179 codec_context->color_range); 179 codec_context->color_range);
180 if (color_space == COLOR_SPACE_UNSPECIFIED) 180 if (color_space == COLOR_SPACE_UNSPECIFIED)
181 color_space = config_.color_space(); 181 color_space = config_.color_space();
182 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, 182 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE,
183 color_space); 183 color_space);
184 184
185 if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED || 185 if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED ||
186 codec_context->color_trc != AVCOL_TRC_UNSPECIFIED || 186 codec_context->color_trc != AVCOL_TRC_UNSPECIFIED ||
187 codec_context->colorspace != AVCOL_SPC_UNSPECIFIED) { 187 codec_context->colorspace != AVCOL_SPC_UNSPECIFIED) {
188 video_frame->set_color_space( 188 video_frame->set_color_space(gfx::ColorSpace(
189 gfx::ColorSpace(codec_context->color_primaries, 189 gfx::ColorSpace::PrimaryIDFromH264(codec_context->color_primaries),
190 codec_context->color_trc, codec_context->colorspace, 190 gfx::ColorSpace::TransferIDFromH264(codec_context->color_trc),
191 codec_context->color_range != AVCOL_RANGE_MPEG 191 gfx::ColorSpace::MatrixIDFromH264(codec_context->colorspace),
192 ? gfx::ColorSpace::RangeID::FULL 192 codec_context->color_range != AVCOL_RANGE_MPEG
193 : gfx::ColorSpace::RangeID::LIMITED)); 193 ? gfx::ColorSpace::RangeID::FULL
194 : gfx::ColorSpace::RangeID::LIMITED));
194 } 195 }
195 196
196 for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) { 197 for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) {
197 frame->data[i] = video_frame->data(i); 198 frame->data[i] = video_frame->data(i);
198 frame->linesize[i] = video_frame->stride(i); 199 frame->linesize[i] = video_frame->stride(i);
199 } 200 }
200 201
201 frame->width = coded_size.width(); 202 frame->width = coded_size.width();
202 frame->height = coded_size.height(); 203 frame->height = coded_size.height();
203 frame->format = codec_context->pix_fmt; 204 frame->format = codec_context->pix_fmt;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 428 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
428 ReleaseFFmpegResources(); 429 ReleaseFFmpegResources();
429 return false; 430 return false;
430 } 431 }
431 432
432 av_frame_.reset(av_frame_alloc()); 433 av_frame_.reset(av_frame_alloc());
433 return true; 434 return true;
434 } 435 }
435 436
436 } // namespace media 437 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698