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

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

Issue 1208693002: media: Respect color space regardless of pixel format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | no next file » | 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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 RoundUp(std::max(size.width(), codec_context->coded_width), 2), 120 RoundUp(std::max(size.width(), codec_context->coded_width), 2),
121 RoundUp(std::max(size.height(), codec_context->coded_height), 2)); 121 RoundUp(std::max(size.height(), codec_context->coded_height), 2));
122 122
123 if (!VideoFrame::IsValidConfig(format, VideoFrame::STORAGE_UNKNOWN, 123 if (!VideoFrame::IsValidConfig(format, VideoFrame::STORAGE_UNKNOWN,
124 coded_size, gfx::Rect(size), natural_size)) { 124 coded_size, gfx::Rect(size), natural_size)) {
125 return AVERROR(EINVAL); 125 return AVERROR(EINVAL);
126 } 126 }
127 127
128 scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame( 128 scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame(
129 format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp()); 129 format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp());
130 if (format == VideoFrame::YV12 && 130 if (codec_context->colorspace == AVCOL_SPC_BT709) {
131 codec_context->colorspace == AVCOL_SPC_BT709) {
132 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, 131 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE,
133 VideoFrame::COLOR_SPACE_HD_REC709); 132 VideoFrame::COLOR_SPACE_HD_REC709);
134 } 133 }
135 134
136 for (int i = 0; i < 3; i++) { 135 for (int i = 0; i < 3; i++) {
137 frame->data[i] = video_frame->data(i); 136 frame->data[i] = video_frame->data(i);
138 frame->linesize[i] = video_frame->stride(i); 137 frame->linesize[i] = video_frame->stride(i);
139 } 138 }
140 139
141 frame->width = coded_size.width(); 140 frame->width = coded_size.width();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 353 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
355 ReleaseFFmpegResources(); 354 ReleaseFFmpegResources();
356 return false; 355 return false;
357 } 356 }
358 357
359 av_frame_.reset(av_frame_alloc()); 358 av_frame_.reset(av_frame_alloc());
360 return true; 359 return true;
361 } 360 }
362 361
363 } // namespace media 362 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698