From eea7b0c0765f6666bfec25740d3b93cc3a511f5d Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Mon, 2 Jul 2012 17:25:07 -0500 Subject: [PATCH] Protected audio decoding in a omp_critical, and removed some debug code --- src/FFmpegReader.cpp | 48 +++----------------------------------------- src/Frame.cpp | 2 -- src/Main.cpp | 4 ++-- 3 files changed, 5 insertions(+), 49 deletions(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 8806c354..e9b08cbc 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -574,53 +574,11 @@ void FFmpegReader::ProcessAudioPacket(int requested_frame, int target_frame, int // re-initialize buffer size (it gets changed in the avcodec_decode_audio2 method call) int buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE; - // decode audio packet into samples (put samples in the audio_buf array) - #pragma omp critical (debug) - { - cout << "FRAME: " << target_frame << ", Starting Sample: " << starting_sample << ", Thread #: " << omp_get_thread_num() << endl; - cout << "&audio_buf: " << &audio_buf << endl; - cout << "audio_buf[0]: " << audio_buf[0] << endl; - cout << "audio_buf[1]: " << audio_buf[1] << endl; - cout << "audio_buf[2]: " << audio_buf[2] << endl; - cout << "audio_buf[3]: " << audio_buf[3] << endl; - cout << "audio_buf[4]: " << audio_buf[4] << endl; - cout << "audio_buf[5]: " << audio_buf[5] << endl; - cout << "my_packet.pts: " << my_packet->pts << endl; - cout << "&my_packet: " << &my_packet << endl; - } - - if (target_frame > 282) - sleep(1); - - #pragma omp critical (debug) - { - cout << "FRAME: " << target_frame << ", Starting Sample: " << starting_sample << ", Thread #: " << omp_get_thread_num() << endl; - cout << "&audio_buf: " << &audio_buf << endl; - cout << "audio_buf[0]: " << audio_buf[0] << endl; - cout << "audio_buf[1]: " << audio_buf[1] << endl; - cout << "audio_buf[2]: " << audio_buf[2] << endl; - cout << "audio_buf[3]: " << audio_buf[3] << endl; - cout << "audio_buf[4]: " << audio_buf[4] << endl; - cout << "audio_buf[5]: " << audio_buf[5] << endl; - cout << "my_packet.pts: " << my_packet->pts << endl; - cout << "&my_packet: " << &my_packet << endl; - } - - int used = avcodec_decode_audio3(aCodecCtx, audio_buf, &buf_size, my_packet); + int used = -1; + #pragma omp critical (audio_codec) + used = avcodec_decode_audio3(aCodecCtx, audio_buf, &buf_size, my_packet); if (used < 0) { - #pragma omp critical (debug) - { - cout << "FRAME: " << target_frame << ", Starting Sample: " << starting_sample << ", Thread #: " << omp_get_thread_num() << endl; - cout << "used: " << used << endl; - cout << "buf_size: " << buf_size << endl; - cout << "my_packet->size: " << my_packet->size << endl; - cout << "&audio_buf: " << &audio_buf << endl; - cout << "aCodecCtx: " << aCodecCtx << endl; - cout << "my_packet.pts: " << my_packet->pts << endl; - cout << "&my_packet: " << &my_packet << endl; - } - // Throw exception throw ErrorDecodingAudio("Error decoding audio samples", target_frame); my_packet->size = 0; diff --git a/src/Frame.cpp b/src/Frame.cpp index 7c88eca7..c0e1bb07 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -358,13 +358,11 @@ bool Frame::IsAudioReady(bool has_audio) if (channels_complete.size() == channels) { // yes, all audio is loaded - cout << "IsAudioReady: True, count: " << channels_complete.size() << endl; return true; } else { // still waiting on some channel to be loaded - cout << "IsAudioReady: False, count: " << channels_complete.size() << endl; return false; } } diff --git a/src/Main.cpp b/src/Main.cpp index 592c17eb..838af86e 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -17,9 +17,9 @@ int main() // openshot::FFmpegReader r("/home/jonathan/Apps/libopenshot/src/examples/test.mp4"); // openshot::FFmpegReader r("/home/jonathan/Apps/libopenshot/src/examples/test1.mp4"); // openshot::FFmpegReader r("/home/jonathan/Apps/libopenshot/src/examples/piano.wav"); - openshot::FFmpegReader r("/home/jonathan/Videos/sintel-1024-stereo.mp4"); + // openshot::FFmpegReader r("/home/jonathan/Videos/sintel-1024-stereo.mp4"); // openshot::FFmpegReader r("/home/jonathan/Videos/00001.mts"); - // openshot::FFmpegReader r("/home/jonathan/Videos/sintel_trailer-720p.mp4"); + openshot::FFmpegReader r("/home/jonathan/Videos/sintel_trailer-720p.mp4"); // openshot::FFmpegReader r("/home/jonathan/Aptana Studio Workspace/OpenShotLibrary/src/examples/piano.wav"); // openshot::FFmpegReader r("/home/jonathan/Music/Army of Lovers/Crucified/Army of Lovers - Crucified [Single Version].mp3"); // openshot::FFmpegReader r("/home/jonathan/Documents/OpenShot Art/test.jpeg");