summaryrefslogtreecommitdiff
path: root/src/mov_encoder.cc
diff options
context:
space:
mode:
authordeva <deva>2005-10-04 21:39:53 +0000
committerdeva <deva>2005-10-04 21:39:53 +0000
commit111b16802de661228ef414eb6ec7484e2fa186ed (patch)
treed6d1ce9e8b857371414f33ff460266258c462275 /src/mov_encoder.cc
parent9640339f2e9dc126406f6b6f8a091b924898b4f5 (diff)
*** empty log message ***
Diffstat (limited to 'src/mov_encoder.cc')
-rw-r--r--src/mov_encoder.cc161
1 files changed, 140 insertions, 21 deletions
diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc
index cf45ae0..a455f42 100644
--- a/src/mov_encoder.cc
+++ b/src/mov_encoder.cc
@@ -42,11 +42,12 @@
#include "miav_config.h"
#include "debug.h"
+#include "libfame_wrapper.h"
MovEncoder::MovEncoder(volatile bool *r, sem_t *r_sem,
- FrameVectorQueue *in, sem_t *in_sem, pthread_mutex_t *in_mutex,
- FramePriorityQueue *v_out, pthread_mutex_t *v_out_mutex, sem_t *v_out_sem,
- FramePriorityQueue *a_out, pthread_mutex_t *a_out_mutex, sem_t *a_out_sem,
+ ThreadSafeQueueFIFO<FrameVector*> *in,
+ ThreadSafeQueuePriority *video_out,
+ ThreadSafeQueuePriority *audio_out,
Info *i)
{
info = i;
@@ -56,18 +57,9 @@ MovEncoder::MovEncoder(volatile bool *r, sem_t *r_sem,
// Queues
inputqueue = in;
- video_outputqueue = v_out;
- audio_outputqueue = a_out;
+ video_output_queue = video_out;
+ audio_output_queue = audio_out;
- // Queue mutexes
- input_mutex = in_mutex;
- video_output_mutex = v_out_mutex;
- audio_output_mutex = a_out_mutex;
-
- input_sem = in_sem;
- video_output_sem = v_out_sem;
- audio_output_sem = a_out_sem;
-
read_sem = r_sem;
}
@@ -82,12 +74,131 @@ void MovEncoder::thread_main()
{
info->info("MovEncoder::run");
// static volatile int test = 0;
+ // int insize = 0;
+
+ // Run with slightly lower priority than MovEncoderWriter AND AudioEncoder
+ // nice(3);
+
+ FrameVector *item;
+ Frame *in_frame;
+ Frame *out_v_frame;
+ Frame *out_a_frame;
+
+ LibFAMEWrapper fame(info);
+
+ // Process until running == false and the queue is empty
+ while(*running) {
+
+ item = inputqueue->pop();
+
+ if(item) {
+ for(unsigned int cnt = 0; cnt < item->size(); cnt++) {
+ in_frame = item->at(cnt);
+
+ // Check for end of stream
+ if(in_frame->endOfFrameStream == true) {
+ info->info("endOfFrameStream in MovEncoder");
+
+ // Signal to stop running
+ *running = false;
+
+ // Kick them sleepy ones so they get the message.
+ int threads = config->readInt("encoding_threads");
+ for(int cnt = 0; cnt < threads; cnt++) {/*sem_post(input_sem);*/} // FIXME: Kick the other encoders
+ }
+
+ // Encode video
+ out_v_frame = fame.encode(in_frame);
+ out_v_frame->number = in_frame->number;
+ out_v_frame->endOfFrameStream = in_frame->endOfFrameStream;
+
+ // Create audio frame
+ out_a_frame = in_frame;
+
+ video_output_queue->push(out_v_frame);
+ audio_output_queue->push(out_a_frame);
+ }
+
+ delete item;
+
+ item = NULL;
+
+ // Kick reader
+ sem_post(read_sem);
+ }
+ }
+
+ info->info("MovEncoder::stop");
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+
+// this runs in a thread
+void MovEncoder::thread_main()
+{
+ info->info("MovEncoder::run");
+ // static volatile int test = 0;
+#ifndef NEW_QUEUE
int v_outsize = 0;
int a_outsize = 0;
+#endif
int insize = 0;
// Run with slightly lower priority than MovEncoderWriter AND AudioEncoder
- //nice(3);
+ nice(3);
FrameVector *item;
Frame *in_frame;
@@ -131,16 +242,20 @@ void MovEncoder::thread_main()
// Create audio frame
out_a_frame = in_frame;
+#ifdef NEW_QUEUE
+ video_output_queue->push(out_v_frame);
+ audio_output_queue->push(out_a_frame);
+#else
// Lock output mutex
pthread_mutex_lock(video_output_mutex);
video_outputqueue->push(out_v_frame);
v_outsize = video_outputqueue->size();
pthread_mutex_unlock(video_output_mutex);
// Unlock output mutex
-
+
// Kick multiplexer (video)
sem_post(video_output_sem);
-
+
// Lock output mutex
pthread_mutex_lock(audio_output_mutex);
audio_outputqueue->push(out_a_frame);
@@ -150,6 +265,7 @@ void MovEncoder::thread_main()
// Kick audio encoder
sem_post(audio_output_sem);
+#endif
}
delete item;
@@ -159,16 +275,19 @@ void MovEncoder::thread_main()
sem_post(read_sem);
}
}
- /*
- info->info("Input pool size: %d, video output pool size: %d, audio output pool size: %d",
- insize, v_outsize, a_outsize);
- */
+
+ //info->info("Input pool size: %d, video output pool size: %d, audio output pool size: %d",
+ // insize, v_outsize, a_outsize);
+
+#ifndef NEW_QUEUE
// Kick audio encoder
sem_post(audio_output_sem);
// Kick multiplexer (video)
sem_post(video_output_sem);
+#endif
info->info("MovEncoder::stop");
}
+*/