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