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

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

Issue 2885643002: Have FFmpeg Decoders handle 0 byte buffers instead of FFmpeg (Closed)
Patch Set: FFmpegAudioDecoder Created 3 years, 7 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 | « media/filters/ffmpeg_audio_decoder.cc ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // Due to FFmpeg API changes we no longer have const read-only pointers. 342 // Due to FFmpeg API changes we no longer have const read-only pointers.
343 AVPacket packet; 343 AVPacket packet;
344 av_init_packet(&packet); 344 av_init_packet(&packet);
345 if (buffer->end_of_stream()) { 345 if (buffer->end_of_stream()) {
346 packet.data = NULL; 346 packet.data = NULL;
347 packet.size = 0; 347 packet.size = 0;
348 } else { 348 } else {
349 packet.data = const_cast<uint8_t*>(buffer->data()); 349 packet.data = const_cast<uint8_t*>(buffer->data());
350 packet.size = buffer->data_size(); 350 packet.size = buffer->data_size();
351 351
352 // Starting in M60, avcodec_decode_video2() generates an error if an
353 // empty buffer is provided. Since we're not at EOS and there is no data
354 // available in the current buffer, simply return and let the caller
355 // provide more data. crbug.com/663438 has more context on 0-byte buffers.
356 if (!packet.size)
357 return true;
358
352 // Let FFmpeg handle presentation timestamp reordering. 359 // Let FFmpeg handle presentation timestamp reordering.
353 codec_context_->reordered_opaque = buffer->timestamp().InMicroseconds(); 360 codec_context_->reordered_opaque = buffer->timestamp().InMicroseconds();
354 } 361 }
355 362
356 int frame_decoded = 0; 363 int frame_decoded = 0;
357 int result = avcodec_decode_video2(codec_context_.get(), 364 int result = avcodec_decode_video2(codec_context_.get(),
358 av_frame_.get(), 365 av_frame_.get(),
359 &frame_decoded, 366 &frame_decoded,
360 &packet); 367 &packet);
361 // Log the problem if we can't decode a video frame and exit early. 368 // Log the problem if we can't decode a video frame and exit early.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 440 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
434 ReleaseFFmpegResources(); 441 ReleaseFFmpegResources();
435 return false; 442 return false;
436 } 443 }
437 444
438 av_frame_.reset(av_frame_alloc()); 445 av_frame_.reset(av_frame_alloc());
439 return true; 446 return true;
440 } 447 }
441 448
442 } // namespace media 449 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.cc ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698