Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: media/filters/ffmpeg_video_decoder.cc

Issue 113748: New FFmpeg public API headers to match our source tarball in deps. (Closed)
Patch Set: Fixes Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | third_party/ffmpeg/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "media/base/video_frame_impl.h" 5 #include "media/base/video_frame_impl.h"
6 #include "media/filters/ffmpeg_common.h" 6 #include "media/filters/ffmpeg_common.h"
7 #include "media/filters/ffmpeg_demuxer.h" 7 #include "media/filters/ffmpeg_demuxer.h"
8 #include "media/filters/ffmpeg_video_decoder.h" 8 #include "media/filters/ffmpeg_video_decoder.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void FFmpegVideoDecoder::OnDecode(Buffer* buffer) { 74 void FFmpegVideoDecoder::OnDecode(Buffer* buffer) {
75 // Check for end of stream. 75 // Check for end of stream.
76 // TODO(scherkus): check for end of stream. 76 // TODO(scherkus): check for end of stream.
77 77
78 // Queue the incoming timestamp. 78 // Queue the incoming timestamp.
79 TimeTuple times; 79 TimeTuple times;
80 times.timestamp = buffer->GetTimestamp(); 80 times.timestamp = buffer->GetTimestamp();
81 times.duration = buffer->GetDuration(); 81 times.duration = buffer->GetDuration();
82 time_queue_.push(times); 82 time_queue_.push(times);
83 83
84 // Cast everything to FFmpeg types. 84 // Create a packet for input data.
85 const uint8_t* data_in = buffer->GetData(); 85 // Due to FFmpeg API changes we no longer have const read-only pointers.
86 const size_t size_in = buffer->GetDataSize(); 86 AVPacket packet;
87 av_init_packet(&packet);
88 packet.data = const_cast<uint8*>(buffer->GetData());
89 packet.size = buffer->GetDataSize();
87 90
88 // We don't allocate AVFrame on the stack since different versions of FFmpeg 91 // We don't allocate AVFrame on the stack since different versions of FFmpeg
89 // may change the size of AVFrame, causing stack corruption. The solution is 92 // may change the size of AVFrame, causing stack corruption. The solution is
90 // to let FFmpeg allocate the structure via avcodec_alloc_frame(). 93 // to let FFmpeg allocate the structure via avcodec_alloc_frame().
91 int decoded = 0; 94 int decoded = 0;
92 scoped_ptr_malloc<AVFrame, ScopedPtrAVFree> yuv_frame(avcodec_alloc_frame()); 95 scoped_ptr_malloc<AVFrame, ScopedPtrAVFree> yuv_frame(avcodec_alloc_frame());
93 int result = avcodec_decode_video(codec_context_, yuv_frame.get(), &decoded, 96 int result = avcodec_decode_video2(codec_context_, yuv_frame.get(), &decoded,
94 data_in, size_in); 97 &packet);
95 98
96 // Log the problem if we can't decode a video frame. 99 // Log the problem if we can't decode a video frame.
97 if (result < 0) { 100 if (result < 0) {
98 LOG(INFO) << "Error decoding a video frame with timestamp: " 101 LOG(INFO) << "Error decoding a video frame with timestamp: "
99 << buffer->GetTimestamp().InMicroseconds() << " us" 102 << buffer->GetTimestamp().InMicroseconds() << " us"
100 << " , duration: " 103 << " , duration: "
101 << buffer->GetDuration().InMicroseconds() << " us" 104 << buffer->GetDuration().InMicroseconds() << " us"
102 << " , packet size: " 105 << " , packet size: "
103 << buffer->GetDataSize() << " bytes"; 106 << buffer->GetDataSize() << " bytes";
104 } 107 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 185 }
183 DCHECK(bytes_per_line <= source_stride && bytes_per_line <= dest_stride); 186 DCHECK(bytes_per_line <= source_stride && bytes_per_line <= dest_stride);
184 for (size_t i = 0; i < copy_lines; ++i) { 187 for (size_t i = 0; i < copy_lines; ++i) {
185 memcpy(dest, source, bytes_per_line); 188 memcpy(dest, source, bytes_per_line);
186 source += source_stride; 189 source += source_stride;
187 dest += dest_stride; 190 dest += dest_stride;
188 } 191 }
189 } 192 }
190 193
191 } // namespace 194 } // namespace
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | third_party/ffmpeg/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698