Chromium Code Reviews| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | |
| 353 // empty buffer provided. If that is the case signal that more data | |
|
xhwang
2017/05/15 23:35:17
"If that is the case" seems to be confusing since
jrummell
2017/05/16 21:54:03
Done.
| |
| 354 // is required to produce more frames. | |
|
xhwang
2017/05/15 23:35:17
Could you please refer to crbug.com/663438 for con
jrummell
2017/05/16 21:54:03
Done.
| |
| 355 if (!packet.size) | |
| 356 return true; | |
| 357 | |
| 352 // Let FFmpeg handle presentation timestamp reordering. | 358 // Let FFmpeg handle presentation timestamp reordering. |
| 353 codec_context_->reordered_opaque = buffer->timestamp().InMicroseconds(); | 359 codec_context_->reordered_opaque = buffer->timestamp().InMicroseconds(); |
| 354 } | 360 } |
| 355 | 361 |
| 356 int frame_decoded = 0; | 362 int frame_decoded = 0; |
| 357 int result = avcodec_decode_video2(codec_context_.get(), | 363 int result = avcodec_decode_video2(codec_context_.get(), |
| 358 av_frame_.get(), | 364 av_frame_.get(), |
| 359 &frame_decoded, | 365 &frame_decoded, |
| 360 &packet); | 366 &packet); |
| 361 // Log the problem if we can't decode a video frame and exit early. | 367 // 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 Loading... | |
| 433 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 439 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 434 ReleaseFFmpegResources(); | 440 ReleaseFFmpegResources(); |
| 435 return false; | 441 return false; |
| 436 } | 442 } |
| 437 | 443 |
| 438 av_frame_.reset(av_frame_alloc()); | 444 av_frame_.reset(av_frame_alloc()); |
| 439 return true; | 445 return true; |
| 440 } | 446 } |
| 441 | 447 |
| 442 } // namespace media | 448 } // namespace media |
| OLD | NEW |