| 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 // ffmpeg_unittests verify that the parts of the FFmpeg API that Chromium uses | 5 // ffmpeg_unittests verify that the parts of the FFmpeg API that Chromium uses |
| 6 // function as advertised for each media format that Chromium supports. This | 6 // function as advertised for each media format that Chromium supports. This |
| 7 // mostly includes stuff like reporting proper timestamps, seeking to | 7 // mostly includes stuff like reporting proper timestamps, seeking to |
| 8 // keyframes, and supporting certain features like reordered_opaque. | 8 // keyframes, and supporting certain features like reordered_opaque. |
| 9 // | 9 // |
| 10 | 10 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 bool end_of_stream = false; | 226 bool end_of_stream = false; |
| 227 | 227 |
| 228 AVPacket packet; | 228 AVPacket packet; |
| 229 if (audio_packets_.empty()) { | 229 if (audio_packets_.empty()) { |
| 230 av_init_packet(&packet); | 230 av_init_packet(&packet); |
| 231 end_of_stream = true; | 231 end_of_stream = true; |
| 232 } else { | 232 } else { |
| 233 memcpy(&packet, audio_packets_.peek(), sizeof(packet)); | 233 memcpy(&packet, audio_packets_.peek(), sizeof(packet)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 avcodec_get_frame_defaults(audio_buffer_.get()); | 236 av_frame_unref(audio_buffer_.get()); |
| 237 result = avcodec_decode_audio4(av_audio_context(), audio_buffer_.get(), | 237 result = avcodec_decode_audio4(av_audio_context(), audio_buffer_.get(), |
| 238 &got_audio, &packet); | 238 &got_audio, &packet); |
| 239 if (!audio_packets_.empty()) { | 239 if (!audio_packets_.empty()) { |
| 240 audio_packets_.pop(); | 240 audio_packets_.pop(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 EXPECT_GE(result, 0) << "Audio decode error."; | 243 EXPECT_GE(result, 0) << "Audio decode error."; |
| 244 if (result < 0 || (got_audio == 0 && end_of_stream)) { | 244 if (result < 0 || (got_audio == 0 && end_of_stream)) { |
| 245 return false; | 245 return false; |
| 246 } | 246 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 bool end_of_stream = false; | 280 bool end_of_stream = false; |
| 281 | 281 |
| 282 AVPacket packet; | 282 AVPacket packet; |
| 283 if (video_packets_.empty()) { | 283 if (video_packets_.empty()) { |
| 284 av_init_packet(&packet); | 284 av_init_packet(&packet); |
| 285 end_of_stream = true; | 285 end_of_stream = true; |
| 286 } else { | 286 } else { |
| 287 memcpy(&packet, video_packets_.peek(), sizeof(packet)); | 287 memcpy(&packet, video_packets_.peek(), sizeof(packet)); |
| 288 } | 288 } |
| 289 | 289 |
| 290 avcodec_get_frame_defaults(video_buffer_.get()); | 290 av_frame_unref(video_buffer_.get()); |
| 291 av_video_context()->reordered_opaque = packet.pts; | 291 av_video_context()->reordered_opaque = packet.pts; |
| 292 result = avcodec_decode_video2(av_video_context(), video_buffer_.get(), | 292 result = avcodec_decode_video2(av_video_context(), video_buffer_.get(), |
| 293 &got_picture, &packet); | 293 &got_picture, &packet); |
| 294 if (!video_packets_.empty()) { | 294 if (!video_packets_.empty()) { |
| 295 video_packets_.pop(); | 295 video_packets_.pop(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 EXPECT_GE(result, 0) << "Video decode error."; | 298 EXPECT_GE(result, 0) << "Video decode error."; |
| 299 if (result < 0 || (got_picture == 0 && end_of_stream)) { | 299 if (result < 0 || (got_picture == 0 && end_of_stream)) { |
| 300 return false; | 300 return false; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 EXPECT_TRUE(StepDecodeVideo()); | 580 EXPECT_TRUE(StepDecodeVideo()); |
| 581 VLOG(1) << decoded_video_time(); | 581 VLOG(1) << decoded_video_time(); |
| 582 | 582 |
| 583 SeekTo(0.4); | 583 SeekTo(0.4); |
| 584 ReadRemainingFile(); | 584 ReadRemainingFile(); |
| 585 EXPECT_TRUE(StepDecodeVideo()); | 585 EXPECT_TRUE(StepDecodeVideo()); |
| 586 VLOG(1) << decoded_video_time(); | 586 VLOG(1) << decoded_video_time(); |
| 587 } | 587 } |
| 588 | 588 |
| 589 } // namespace media | 589 } // namespace media |
| OLD | NEW |