OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cdm/ppapi/external_clear_key/ffmpeg_cdm_audio_decoder.h" | 5 #include "media/cdm/ppapi/external_clear_key/ffmpeg_cdm_audio_decoder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 static_cast<AVSampleFormat>(av_sample_format_)); | 264 static_cast<AVSampleFormat>(av_sample_format_)); |
265 DCHECK_NE(cdm_format, cdm::kUnknownAudioFormat); | 265 DCHECK_NE(cdm_format, cdm::kUnknownAudioFormat); |
266 decoded_frames->SetFormat(cdm_format); | 266 decoded_frames->SetFormat(cdm_format); |
267 | 267 |
268 // Each audio packet may contain several frames, so we must call the decoder | 268 // Each audio packet may contain several frames, so we must call the decoder |
269 // until we've exhausted the packet. Regardless of the packet size we always | 269 // until we've exhausted the packet. Regardless of the packet size we always |
270 // want to hand it to the decoder at least once, otherwise we would end up | 270 // want to hand it to the decoder at least once, otherwise we would end up |
271 // skipping end of stream packets since they have a size of zero. | 271 // skipping end of stream packets since they have a size of zero. |
272 do { | 272 do { |
273 // Reset frame to default values. | 273 // Reset frame to default values. |
274 avcodec_get_frame_defaults(av_frame_.get()); | 274 av_frame_unref(av_frame_.get()); |
wolenetz
2014/05/20 22:37:10
Unref prior to first decode looks wrong to me.
DaleCurtis
2014/05/20 23:00:45
I agree it looks weird, but that's the API as writ
| |
275 | 275 |
276 int frame_decoded = 0; | 276 int frame_decoded = 0; |
277 int result = avcodec_decode_audio4( | 277 int result = avcodec_decode_audio4( |
278 codec_context_.get(), av_frame_.get(), &frame_decoded, &packet); | 278 codec_context_.get(), av_frame_.get(), &frame_decoded, &packet); |
279 | 279 |
280 if (result < 0) { | 280 if (result < 0) { |
281 DCHECK(!is_end_of_stream) | 281 DCHECK(!is_end_of_stream) |
282 << "End of stream buffer produced an error! " | 282 << "End of stream buffer produced an error! " |
283 << "This is quite possibly a bug in the audio decoder not handling " | 283 << "This is quite possibly a bug in the audio decoder not handling " |
284 << "end of stream AVPackets correctly."; | 284 << "end of stream AVPackets correctly."; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 av_frame_.reset(); | 420 av_frame_.reset(); |
421 } | 421 } |
422 | 422 |
423 void FFmpegCdmAudioDecoder::SerializeInt64(int64 value) { | 423 void FFmpegCdmAudioDecoder::SerializeInt64(int64 value) { |
424 const size_t previous_size = serialized_audio_frames_.size(); | 424 const size_t previous_size = serialized_audio_frames_.size(); |
425 serialized_audio_frames_.resize(previous_size + sizeof(value)); | 425 serialized_audio_frames_.resize(previous_size + sizeof(value)); |
426 memcpy(&serialized_audio_frames_[0] + previous_size, &value, sizeof(value)); | 426 memcpy(&serialized_audio_frames_[0] + previous_size, &value, sizeof(value)); |
427 } | 427 } |
428 | 428 |
429 } // namespace media | 429 } // namespace media |
OLD | NEW |