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

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

Issue 339653003: No EOS frame in {Audio|Video}Decoder::OutputCB. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 CHECK_NE(state_, kUninitialized); 182 CHECK_NE(state_, kUninitialized);
183 183
184 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); 184 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb);
185 185
186 if (state_ == kError) { 186 if (state_ == kError) {
187 decode_cb_bound.Run(kDecodeError); 187 decode_cb_bound.Run(kDecodeError);
188 return; 188 return;
189 } 189 }
190 190
191 if (state_ == kDecodeFinished) { 191 if (state_ == kDecodeFinished) {
192 output_cb_.Run(VideoFrame::CreateEOSFrame());
193 decode_cb_bound.Run(kOk); 192 decode_cb_bound.Run(kOk);
194 return; 193 return;
195 } 194 }
196 195
197 DCHECK_EQ(state_, kNormal); 196 DCHECK_EQ(state_, kNormal);
198 197
199 // During decode, because reads are issued asynchronously, it is possible to 198 // During decode, because reads are issued asynchronously, it is possible to
200 // receive multiple end of stream buffers since each decode is acked. When the 199 // receive multiple end of stream buffers since each decode is acked. When the
201 // first end of stream buffer is read, FFmpeg may still have frames queued 200 // first end of stream buffer is read, FFmpeg may still have frames queued
202 // up in the decoder so we need to go through the decode loop until it stops 201 // up in the decoder so we need to go through the decode loop until it stops
(...skipping 18 matching lines...) Expand all
221 do { 220 do {
222 has_produced_frame = false; 221 has_produced_frame = false;
223 if (!FFmpegDecode(buffer, &has_produced_frame)) { 222 if (!FFmpegDecode(buffer, &has_produced_frame)) {
224 state_ = kError; 223 state_ = kError;
225 decode_cb_bound.Run(kDecodeError); 224 decode_cb_bound.Run(kDecodeError);
226 return; 225 return;
227 } 226 }
228 // Repeat to flush the decoder after receiving EOS buffer. 227 // Repeat to flush the decoder after receiving EOS buffer.
229 } while (buffer->end_of_stream() && has_produced_frame); 228 } while (buffer->end_of_stream() && has_produced_frame);
230 229
231 if (buffer->end_of_stream()) { 230 if (buffer->end_of_stream())
232 output_cb_.Run(VideoFrame::CreateEOSFrame());
233 state_ = kDecodeFinished; 231 state_ = kDecodeFinished;
234 }
235 232
236 decode_cb_bound.Run(kOk); 233 decode_cb_bound.Run(kOk);
237 } 234 }
238 235
239 void FFmpegVideoDecoder::Reset(const base::Closure& closure) { 236 void FFmpegVideoDecoder::Reset(const base::Closure& closure) {
240 DCHECK(task_runner_->BelongsToCurrentThread()); 237 DCHECK(task_runner_->BelongsToCurrentThread());
241 238
242 avcodec_flush_buffers(codec_context_.get()); 239 avcodec_flush_buffers(codec_context_.get());
243 state_ = kNormal; 240 state_ = kNormal;
244 task_runner_->PostTask(FROM_HERE, closure); 241 task_runner_->PostTask(FROM_HERE, closure);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 350 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
354 ReleaseFFmpegResources(); 351 ReleaseFFmpegResources();
355 return false; 352 return false;
356 } 353 }
357 354
358 av_frame_.reset(av_frame_alloc()); 355 av_frame_.reset(av_frame_alloc());
359 return true; 356 return true;
360 } 357 }
361 358
362 } // namespace media 359 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698