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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return decode_threads; | 54 return decode_threads; |
55 } | 55 } |
56 | 56 |
57 static int GetVideoBufferImpl(struct AVCodecContext* s, | 57 static int GetVideoBufferImpl(struct AVCodecContext* s, |
58 AVFrame* frame, | 58 AVFrame* frame, |
59 int flags) { | 59 int flags) { |
60 FFmpegVideoDecoder* decoder = static_cast<FFmpegVideoDecoder*>(s->opaque); | 60 FFmpegVideoDecoder* decoder = static_cast<FFmpegVideoDecoder*>(s->opaque); |
61 return decoder->GetVideoBuffer(s, frame, flags); | 61 return decoder->GetVideoBuffer(s, frame, flags); |
62 } | 62 } |
63 | 63 |
64 static void ReleaseVideoBufferImpl(void* opaque, uint8* data) { | 64 static void ReleaseVideoBufferImpl(void* opaque, uint8_t* data) { |
65 scoped_refptr<VideoFrame> video_frame; | 65 scoped_refptr<VideoFrame> video_frame; |
66 video_frame.swap(reinterpret_cast<VideoFrame**>(&opaque)); | 66 video_frame.swap(reinterpret_cast<VideoFrame**>(&opaque)); |
67 } | 67 } |
68 | 68 |
69 // static | 69 // static |
70 bool FFmpegVideoDecoder::IsCodecSupported(VideoCodec codec) { | 70 bool FFmpegVideoDecoder::IsCodecSupported(VideoCodec codec) { |
71 FFmpegGlue::InitializeFFmpeg(); | 71 FFmpegGlue::InitializeFFmpeg(); |
72 return avcodec_find_decoder(VideoCodecToCodecID(codec)) != nullptr; | 72 return avcodec_find_decoder(VideoCodecToCodecID(codec)) != nullptr; |
73 } | 73 } |
74 | 74 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 DCHECK(!*has_produced_frame); | 279 DCHECK(!*has_produced_frame); |
280 | 280 |
281 // Create a packet for input data. | 281 // Create a packet for input data. |
282 // Due to FFmpeg API changes we no longer have const read-only pointers. | 282 // Due to FFmpeg API changes we no longer have const read-only pointers. |
283 AVPacket packet; | 283 AVPacket packet; |
284 av_init_packet(&packet); | 284 av_init_packet(&packet); |
285 if (buffer->end_of_stream()) { | 285 if (buffer->end_of_stream()) { |
286 packet.data = NULL; | 286 packet.data = NULL; |
287 packet.size = 0; | 287 packet.size = 0; |
288 } else { | 288 } else { |
289 packet.data = const_cast<uint8*>(buffer->data()); | 289 packet.data = const_cast<uint8_t*>(buffer->data()); |
290 packet.size = buffer->data_size(); | 290 packet.size = buffer->data_size(); |
291 | 291 |
292 // Let FFmpeg handle presentation timestamp reordering. | 292 // Let FFmpeg handle presentation timestamp reordering. |
293 codec_context_->reordered_opaque = buffer->timestamp().InMicroseconds(); | 293 codec_context_->reordered_opaque = buffer->timestamp().InMicroseconds(); |
294 } | 294 } |
295 | 295 |
296 int frame_decoded = 0; | 296 int frame_decoded = 0; |
297 int result = avcodec_decode_video2(codec_context_.get(), | 297 int result = avcodec_decode_video2(codec_context_.get(), |
298 av_frame_.get(), | 298 av_frame_.get(), |
299 &frame_decoded, | 299 &frame_decoded, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 369 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
370 ReleaseFFmpegResources(); | 370 ReleaseFFmpegResources(); |
371 return false; | 371 return false; |
372 } | 372 } |
373 | 373 |
374 av_frame_.reset(av_frame_alloc()); | 374 av_frame_.reset(av_frame_alloc()); |
375 return true; | 375 return true; |
376 } | 376 } |
377 | 377 |
378 } // namespace media | 378 } // namespace media |
OLD | NEW |