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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 gfx::Size natural_size; | 83 gfx::Size natural_size; |
84 if (codec_context->sample_aspect_ratio.num > 0) { | 84 if (codec_context->sample_aspect_ratio.num > 0) { |
85 natural_size = GetNaturalSize(size, | 85 natural_size = GetNaturalSize(size, |
86 codec_context->sample_aspect_ratio.num, | 86 codec_context->sample_aspect_ratio.num, |
87 codec_context->sample_aspect_ratio.den); | 87 codec_context->sample_aspect_ratio.den); |
88 } else { | 88 } else { |
89 natural_size = demuxer_stream_->video_decoder_config().natural_size(); | 89 natural_size = demuxer_stream_->video_decoder_config().natural_size(); |
90 } | 90 } |
91 | 91 |
| 92 if (!VideoFrame::IsValidConfig(format, size, natural_size)) |
| 93 return AVERROR(EINVAL); |
| 94 |
92 scoped_refptr<VideoFrame> video_frame = | 95 scoped_refptr<VideoFrame> video_frame = |
93 VideoFrame::CreateFrame(format, size, natural_size, kNoTimestamp()); | 96 VideoFrame::CreateFrame(format, size, natural_size, kNoTimestamp()); |
94 | 97 |
95 for (int i = 0; i < 3; i++) { | 98 for (int i = 0; i < 3; i++) { |
96 frame->base[i] = video_frame->data(i); | 99 frame->base[i] = video_frame->data(i); |
97 frame->data[i] = video_frame->data(i); | 100 frame->data[i] = video_frame->data(i); |
98 frame->linesize[i] = video_frame->stride(i); | 101 frame->linesize[i] = video_frame->stride(i); |
99 } | 102 } |
100 | 103 |
101 frame->opaque = video_frame.release(); | 104 frame->opaque = video_frame.release(); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 av_free(codec_context_); | 523 av_free(codec_context_); |
521 codec_context_ = NULL; | 524 codec_context_ = NULL; |
522 } | 525 } |
523 if (av_frame_) { | 526 if (av_frame_) { |
524 av_free(av_frame_); | 527 av_free(av_frame_); |
525 av_frame_ = NULL; | 528 av_frame_ = NULL; |
526 } | 529 } |
527 } | 530 } |
528 | 531 |
529 } // namespace media | 532 } // namespace media |
OLD | NEW |