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

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

Issue 2338213009: Always use valid enum values in gfx::ColorSpace (Closed)
Patch Set: merge Created 4 years, 3 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 | « no previous file | ui/gfx/color_space.h » ('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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 || 144 if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED ||
145 codec_context->color_trc != AVCOL_TRC_UNSPECIFIED || 145 codec_context->color_trc != AVCOL_TRC_UNSPECIFIED ||
146 codec_context->colorspace != AVCOL_SPC_UNSPECIFIED) { 146 codec_context->colorspace != AVCOL_SPC_UNSPECIFIED) {
147 video_frame->set_color_space(gfx::ColorSpace( 147 video_frame->set_color_space(
148 static_cast<gfx::ColorSpace::PrimaryID>(codec_context->color_primaries), 148 gfx::ColorSpace(codec_context->color_primaries,
149 static_cast<gfx::ColorSpace::TransferID>(codec_context->color_trc), 149 codec_context->color_trc, codec_context->colorspace,
150 static_cast<gfx::ColorSpace::MatrixID>(codec_context->colorspace), 150 codec_context->color_range != AVCOL_RANGE_MPEG
151 codec_context->color_range != AVCOL_RANGE_MPEG 151 ? gfx::ColorSpace::RangeID::FULL
152 ? gfx::ColorSpace::RangeID::FULL 152 : gfx::ColorSpace::RangeID::LIMITED));
153 : gfx::ColorSpace::RangeID::LIMITED));
154 } 153 }
155 154
156 for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) { 155 for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) {
157 frame->data[i] = video_frame->data(i); 156 frame->data[i] = video_frame->data(i);
158 frame->linesize[i] = video_frame->stride(i); 157 frame->linesize[i] = video_frame->stride(i);
159 } 158 }
160 159
161 frame->width = coded_size.width(); 160 frame->width = coded_size.width();
162 frame->height = coded_size.height(); 161 frame->height = coded_size.height();
163 frame->format = codec_context->pix_fmt; 162 frame->format = codec_context->pix_fmt;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 385 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
387 ReleaseFFmpegResources(); 386 ReleaseFFmpegResources();
388 return false; 387 return false;
389 } 388 }
390 389
391 av_frame_.reset(av_frame_alloc()); 390 av_frame_.reset(av_frame_alloc());
392 return true; 391 return true;
393 } 392 }
394 393
395 } // namespace media 394 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/color_space.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698