summaryrefslogtreecommitdiff
path: root/src/mov_encoder.cc
diff options
context:
space:
mode:
authordeva <deva>2005-09-12 15:34:25 +0000
committerdeva <deva>2005-09-12 15:34:25 +0000
commit701608f39c59b530f6cede66ec24e9ddda8beae6 (patch)
treee974077734a45e0e6bb5b487b230922656834bed /src/mov_encoder.cc
parent84e9873f846478476487d5cd2587e5879a0be8ea (diff)
*** empty log message ***
Diffstat (limited to 'src/mov_encoder.cc')
-rw-r--r--src/mov_encoder.cc69
1 files changed, 36 insertions, 33 deletions
diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc
index 1073b35..a9a2ca2 100644
--- a/src/mov_encoder.cc
+++ b/src/mov_encoder.cc
@@ -44,8 +44,9 @@
#include "debug.h"
MovEncoder::MovEncoder(sem_t *r_sem,
- FrameVectorQueue *in, sem_t *in_sem, pthread_mutex_t *in_mutex,
- FramePriorityQueue *out, sem_t *out_sem, pthread_mutex_t *out_mutex,
+ 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,
Info *i)
{
info = i;
@@ -53,16 +54,21 @@ MovEncoder::MovEncoder(sem_t *r_sem,
running = true;
+ // Queues
inputqueue = in;
- outputqueue = out;
+ video_outputqueue = v_out;
+ audio_outputqueue = a_out;
+
+ // Queue mutexes
+ input_mutex = in_mutex;
+ video_output_mutex = v_out_mutex;
+ audio_output_mutex = a_out_mutex;
input_sem = in_sem;
- output_sem = out_sem;
+ video_output_sem = v_out_sem;
+ audio_output_sem = a_out_sem;
read_sem = r_sem;
-
- input_mutex = in_mutex;
- output_mutex = out_mutex;
}
MovEncoder::~MovEncoder()
@@ -71,14 +77,13 @@ MovEncoder::~MovEncoder()
}
-//#define COPY_DV 1
-
// this runs in a thread
void MovEncoder::thread_main()
{
info->info("MovEncoder thread is running.");
static volatile int test = 0;
- int outsize = 0;
+ int v_outsize = 0;
+ int a_outsize = 0;
int insize = 0;
// Run with slightly lower priority than MovEncoderWriter
@@ -113,49 +118,47 @@ void MovEncoder::thread_main()
for(unsigned int cnt = 0; cnt < item->size(); cnt++) {
in_frame = item->at(cnt);
-#ifdef COPY_DV
-
// Encode video
out_v_frame = new Frame(in_frame->data, in_frame->size);
out_v_frame->number = in_frame->number;
-
- // Encode audio
- out_a_frame = new Frame(in_frame->data, in_frame->size);
- out_a_frame->number = in_frame->number + 1;
-
-#else /*COPY_DV*/
-
- // Encode video
out_v_frame = fame.encode(in_frame);
out_v_frame->number = in_frame->number;
// Encode audio
+ out_a_frame = new Frame(in_frame->data, in_frame->size);
+ out_a_frame->number = in_frame->number;
out_a_frame = lame.encode(in_frame);
- out_a_frame->number = in_frame->number + 1;
+ out_a_frame->number = in_frame->number;
-#endif /*COPY_DV*/
delete in_frame;
// Lock output mutex
- pthread_mutex_lock(output_mutex);
-
- outputqueue->push(out_v_frame);
-
- outputqueue->push(out_a_frame);
+ 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
- outsize = outputqueue->size();
+ // Kick multiplexer (video)
+ sem_post(video_output_sem);
- pthread_mutex_unlock(output_mutex);
+ // Lock output mutex
+ pthread_mutex_lock(audio_output_mutex);
+ audio_outputqueue->push(out_a_frame);
+ a_outsize = audio_outputqueue->size();
+ pthread_mutex_unlock(audio_output_mutex);
// Unlock output mutex
+
+ // Kick multiplexer (audio)
+ sem_post(audio_output_sem);
}
delete item;
test++;
- if(test % (25 * 24) == 0) info->info("Input pool size: %d, output pool size: %d", insize, outsize);
-
- // Kick frame writer
- sem_post(output_sem);
+ if(test % (25 * 24) == 0)
+ info->info("Input pool size: %d, video output pool size: %d, audio output pool size: %d",
+ insize, v_outsize, a_outsize);
// Kick reader
sem_post(read_sem);