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

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

Issue 10824141: Remove VideoDecoder::natural_size() & added VideoFrame::natural_size(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (format == VideoFrame::INVALID) 74 if (format == VideoFrame::INVALID)
75 return AVERROR(EINVAL); 75 return AVERROR(EINVAL);
76 DCHECK(format == VideoFrame::YV12 || format == VideoFrame::YV16); 76 DCHECK(format == VideoFrame::YV12 || format == VideoFrame::YV16);
77 77
78 int width = codec_context->width; 78 int width = codec_context->width;
79 int height = codec_context->height; 79 int height = codec_context->height;
80 int ret; 80 int ret;
81 if ((ret = av_image_check_size(width, height, 0, NULL)) < 0) 81 if ((ret = av_image_check_size(width, height, 0, NULL)) < 0)
82 return ret; 82 return ret;
83 83
84 gfx::Size natural_size = natural_size_;
85 if (codec_context->sample_aspect_ratio.num > 0) {
86 natural_size = GetNaturalSize(gfx::Size(width, height),
87 codec_context->sample_aspect_ratio.num,
88 codec_context->sample_aspect_ratio.den);
89 }
84 scoped_refptr<VideoFrame> video_frame = 90 scoped_refptr<VideoFrame> video_frame =
85 VideoFrame::CreateFrame(format, width, height, kNoTimestamp()); 91 VideoFrame::CreateFrame(format, width, height, natural_size,
92 kNoTimestamp());
86 93
87 for (int i = 0; i < 3; i++) { 94 for (int i = 0; i < 3; i++) {
88 frame->base[i] = video_frame->data(i); 95 frame->base[i] = video_frame->data(i);
89 frame->data[i] = video_frame->data(i); 96 frame->data[i] = video_frame->data(i);
90 frame->linesize[i] = video_frame->stride(i); 97 frame->linesize[i] = video_frame->stride(i);
91 } 98 }
92 99
93 frame->opaque = video_frame.release(); 100 frame->opaque = video_frame.release();
94 frame->type = FF_BUFFER_TYPE_USER; 101 frame->type = FF_BUFFER_TYPE_USER;
95 frame->pkt_pts = codec_context->pkt ? codec_context->pkt->pts : 102 frame->pkt_pts = codec_context->pkt ? codec_context->pkt->pts :
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 243
237 DoStop(); 244 DoStop();
238 } 245 }
239 246
240 void FFmpegVideoDecoder::DoStop() { 247 void FFmpegVideoDecoder::DoStop() {
241 ReleaseFFmpegResources(); 248 ReleaseFFmpegResources();
242 state_ = kUninitialized; 249 state_ = kUninitialized;
243 base::ResetAndReturn(&stop_cb_).Run(); 250 base::ResetAndReturn(&stop_cb_).Run();
244 } 251 }
245 252
246 const gfx::Size& FFmpegVideoDecoder::natural_size() {
247 return natural_size_;
248 }
249
250 void FFmpegVideoDecoder::set_decryptor(Decryptor* decryptor) { 253 void FFmpegVideoDecoder::set_decryptor(Decryptor* decryptor) {
251 DCHECK_EQ(state_, kUninitialized); 254 DCHECK_EQ(state_, kUninitialized);
252 decryptor_ = decryptor; 255 decryptor_ = decryptor;
253 } 256 }
254 257
255 FFmpegVideoDecoder::~FFmpegVideoDecoder() { 258 FFmpegVideoDecoder::~FFmpegVideoDecoder() {
256 ReleaseFFmpegResources(); 259 ReleaseFFmpegResources();
257 } 260 }
258 261
259 void FFmpegVideoDecoder::DoRead(const ReadCB& read_cb) { 262 void FFmpegVideoDecoder::DoRead(const ReadCB& read_cb) {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 av_free(codec_context_); 516 av_free(codec_context_);
514 codec_context_ = NULL; 517 codec_context_ = NULL;
515 } 518 }
516 if (av_frame_) { 519 if (av_frame_) {
517 av_free(av_frame_); 520 av_free(av_frame_);
518 av_frame_ = NULL; 521 av_frame_ = NULL;
519 } 522 }
520 } 523 }
521 524
522 } // namespace media 525 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698