OLD | NEW |
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 ColorSpace color_space = AVColorSpaceToColorSpace(codec_context->colorspace, | 180 ColorSpace color_space = AVColorSpaceToColorSpace(codec_context->colorspace, |
181 codec_context->color_range); | 181 codec_context->color_range); |
182 if (color_space == COLOR_SPACE_UNSPECIFIED) | 182 if (color_space == COLOR_SPACE_UNSPECIFIED) |
183 color_space = config_.color_space(); | 183 color_space = config_.color_space(); |
184 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, | 184 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, |
185 color_space); | 185 color_space); |
186 | 186 |
187 if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED || | 187 if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED || |
188 codec_context->color_trc != AVCOL_TRC_UNSPECIFIED || | 188 codec_context->color_trc != AVCOL_TRC_UNSPECIFIED || |
189 codec_context->colorspace != AVCOL_SPC_UNSPECIFIED) { | 189 codec_context->colorspace != AVCOL_SPC_UNSPECIFIED) { |
190 video_frame->set_color_space(gfx::ColorSpace::CreateVideo( | 190 media::VideoColorSpace video_color_space = media::VideoColorSpace( |
191 codec_context->color_primaries, codec_context->color_trc, | 191 codec_context->color_primaries, codec_context->color_trc, |
192 codec_context->colorspace, | 192 codec_context->colorspace, |
193 codec_context->color_range != AVCOL_RANGE_MPEG | 193 codec_context->color_range != AVCOL_RANGE_MPEG |
194 ? gfx::ColorSpace::RangeID::FULL | 194 ? gfx::ColorSpace::RangeID::FULL |
195 : gfx::ColorSpace::RangeID::LIMITED)); | 195 : gfx::ColorSpace::RangeID::LIMITED); |
| 196 video_frame->set_color_space(video_color_space.ToGfxColorSpace()); |
196 } | 197 } |
197 | 198 |
198 for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) { | 199 for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) { |
199 frame->data[i] = video_frame->data(i); | 200 frame->data[i] = video_frame->data(i); |
200 frame->linesize[i] = video_frame->stride(i); | 201 frame->linesize[i] = video_frame->stride(i); |
201 } | 202 } |
202 | 203 |
203 frame->width = coded_size.width(); | 204 frame->width = coded_size.width(); |
204 frame->height = coded_size.height(); | 205 frame->height = coded_size.height(); |
205 frame->format = codec_context->pix_fmt; | 206 frame->format = codec_context->pix_fmt; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 433 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
433 ReleaseFFmpegResources(); | 434 ReleaseFFmpegResources(); |
434 return false; | 435 return false; |
435 } | 436 } |
436 | 437 |
437 av_frame_.reset(av_frame_alloc()); | 438 av_frame_.reset(av_frame_alloc()); |
438 return true; | 439 return true; |
439 } | 440 } |
440 | 441 |
441 } // namespace media | 442 } // namespace media |
OLD | NEW |