OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_decode_engine.h" | 5 #include "media/filters/ffmpeg_video_decode_engine.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
10 #include "media/base/callback.h" | 10 #include "media/base/callback.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Create a packet for input data. | 125 // Create a packet for input data. |
126 // Due to FFmpeg API changes we no longer have const read-only pointers. | 126 // Due to FFmpeg API changes we no longer have const read-only pointers. |
127 AVPacket packet; | 127 AVPacket packet; |
128 av_init_packet(&packet); | 128 av_init_packet(&packet); |
129 packet.data = const_cast<uint8*>(buffer->GetData()); | 129 packet.data = const_cast<uint8*>(buffer->GetData()); |
130 packet.size = buffer->GetDataSize(); | 130 packet.size = buffer->GetDataSize(); |
131 | 131 |
132 // Let FFmpeg handle presentation timestamp reordering. | 132 // Let FFmpeg handle presentation timestamp reordering. |
133 codec_context_->reordered_opaque = buffer->GetTimestamp().InMicroseconds(); | 133 codec_context_->reordered_opaque = buffer->GetTimestamp().InMicroseconds(); |
134 | 134 |
| 135 // This is for codecs not using get_buffer to initialize |
| 136 // |av_frame_->reordered_opaque| |
| 137 av_frame_->reordered_opaque = codec_context_->reordered_opaque; |
| 138 |
135 int frame_decoded = 0; | 139 int frame_decoded = 0; |
136 int result = avcodec_decode_video2(codec_context_, | 140 int result = avcodec_decode_video2(codec_context_, |
137 av_frame_.get(), | 141 av_frame_.get(), |
138 &frame_decoded, | 142 &frame_decoded, |
139 &packet); | 143 &packet); |
140 | 144 |
141 // Log the problem if we can't decode a video frame and exit early. | 145 // Log the problem if we can't decode a video frame and exit early. |
142 if (result < 0) { | 146 if (result < 0) { |
143 LOG(INFO) << "Error decoding a video frame with timestamp: " | 147 LOG(INFO) << "Error decoding a video frame with timestamp: " |
144 << buffer->GetTimestamp().InMicroseconds() << " us" | 148 << buffer->GetTimestamp().InMicroseconds() << " us" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 case PIX_FMT_YUVJ422P: | 246 case PIX_FMT_YUVJ422P: |
243 return VideoFrame::YV16; | 247 return VideoFrame::YV16; |
244 break; | 248 break; |
245 default: | 249 default: |
246 // TODO(scherkus): More formats here? | 250 // TODO(scherkus): More formats here? |
247 return VideoFrame::INVALID; | 251 return VideoFrame::INVALID; |
248 } | 252 } |
249 } | 253 } |
250 | 254 |
251 } // namespace media | 255 } // namespace media |
OLD | NEW |