| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 355 } |
| 356 | 356 |
| 357 int frame_decoded = 0; | 357 int frame_decoded = 0; |
| 358 int result = avcodec_decode_video2(codec_context_.get(), | 358 int result = avcodec_decode_video2(codec_context_.get(), |
| 359 av_frame_.get(), | 359 av_frame_.get(), |
| 360 &frame_decoded, | 360 &frame_decoded, |
| 361 &packet); | 361 &packet); |
| 362 // Log the problem if we can't decode a video frame and exit early. | 362 // Log the problem if we can't decode a video frame and exit early. |
| 363 if (result < 0) { | 363 if (result < 0) { |
| 364 MEDIA_LOG(DEBUG, media_log_) | 364 MEDIA_LOG(DEBUG, media_log_) |
| 365 << "avcodec_decode_video2(): " << AVErrorToString(result) << ", at " | 365 << GetDisplayName() |
| 366 << ": avcodec_decode_video2(): " << AVErrorToString(result) << ", at " |
| 366 << buffer->AsHumanReadableString(); | 367 << buffer->AsHumanReadableString(); |
| 367 return false; | 368 return false; |
| 368 } | 369 } |
| 369 | 370 |
| 370 // FFmpeg says some codecs might have multiple frames per packet. Previous | 371 // FFmpeg says some codecs might have multiple frames per packet. Previous |
| 371 // discussions with rbultje@ indicate this shouldn't be true for the codecs | 372 // discussions with rbultje@ indicate this shouldn't be true for the codecs |
| 372 // we use. | 373 // we use. |
| 373 DCHECK_EQ(result, packet.size); | 374 DCHECK_EQ(result, packet.size); |
| 374 | 375 |
| 375 // If no frame was produced then signal that more data is required to | 376 // If no frame was produced then signal that more data is required to |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 434 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 434 ReleaseFFmpegResources(); | 435 ReleaseFFmpegResources(); |
| 435 return false; | 436 return false; |
| 436 } | 437 } |
| 437 | 438 |
| 438 av_frame_.reset(av_frame_alloc()); | 439 av_frame_.reset(av_frame_alloc()); |
| 439 return true; | 440 return true; |
| 440 } | 441 } |
| 441 | 442 |
| 442 } // namespace media | 443 } // namespace media |
| OLD | NEW |