summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2005-05-19 10:55:49 +0000
committerdeva <deva>2005-05-19 10:55:49 +0000
commita597454b7ce1b931e3e4117e6fed509cc22517ff (patch)
tree6fc7757fa514240ae0c815786af165801abbe9dc
parent511b49048fb62a56f7049045e0e3d85c5b3e8745 (diff)
Test for block encoding of length strlen("IPIPP").
-rw-r--r--src/mov_encoder_thread.cc26
-rw-r--r--src/mov_encoder_thread.h9
2 files changed, 30 insertions, 5 deletions
diff --git a/src/mov_encoder_thread.cc b/src/mov_encoder_thread.cc
index da83744..be86377 100644
--- a/src/mov_encoder_thread.cc
+++ b/src/mov_encoder_thread.cc
@@ -31,8 +31,10 @@
/*
* $Log$
- * Revision 1.4 2005/05/17 19:16:26 deva
+ * Revision 1.5 2005/05/19 10:55:49 deva
+ * Test for block encoding of length strlen("IPIPP").
*
+ * Revision 1.4 2005/05/17 19:16:26 deva
* Made new mpeg writer work, with proper file permissions.
*
* Revision 1.3 2005/05/17 15:13:15 deva
@@ -43,12 +45,12 @@
*
* Revision 1.1 2005/05/17 14:30:56 deva
* Added code, preparing threaded encoding.
- *
*/
#include <config.h>
#include "mov_encoder_thread.h"
#include <errno.h>
+#include "miav_config.h"
MovEncoderThread::MovEncoderThread(const char *filename)
{
@@ -56,7 +58,7 @@ MovEncoderThread::MovEncoderThread(const char *filename)
O_CREAT | O_WRONLY, //| O_LARGEFILE
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if(file == -1) {
- fprintf(stderr, "File not opened %s\n", strerror(errno));
+ fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));
return;
}
threads = 4;
@@ -64,6 +66,12 @@ MovEncoderThread::MovEncoderThread(const char *filename)
for(int cnt = 0; cnt < threads; cnt++) {
encs.push_back(new MovEncoder());
}
+
+ int current_encoder = 0;
+ int current_frame = 0;
+
+ int num_frames_in_block = config->readString("frame_sequence")->length();
+ fprintf(stderr, "Frame sequence length [%d]\n", num_frames_in_block); fflush(stderr);
}
MovEncoderThread::~MovEncoderThread()
@@ -78,10 +86,18 @@ void MovEncoderThread::encode(Frame* frame)
{
if(file == -1) return;
- Frame *enc_frame = encs[0]->encode(frame);
+ Frame *enc_frame = encs[current_encoder]->encode(frame);
// fprintf(stderr, "[%d]", enc_frame->size); fflush(stderr);
int i = write(file, enc_frame->data, enc_frame->size);
if(i == -1) perror("Write failed");
delete enc_frame;
-
+
+ // Switch frame
+ current_frame++;
+ if(current_frame >= num_frames_in_block) {
+ // Switch encoder
+ current_frame = 0;
+ current_encoder++;
+ if(current_encoder >= threads) current_encoder = 0;
+ }
}
diff --git a/src/mov_encoder_thread.h b/src/mov_encoder_thread.h
index 8b7cd72..1e91b58 100644
--- a/src/mov_encoder_thread.h
+++ b/src/mov_encoder_thread.h
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.3 2005/05/19 10:55:49 deva
+ * Test for block encoding of length strlen("IPIPP").
+ *
* Revision 1.2 2005/05/17 15:12:51 deva
* Fixed file rights (All read on files and directories, and all execute on directories).
*
@@ -64,6 +67,12 @@ public:
void encode(Frame* frame);
private:
+ // Used for encoder switching
+ int current_encoder;
+ int current_frame;
+
+ int num_frames_in_block;
+
int threads;
int file;
vector<MovEncoder*> encs;