From 5298cdacd41efbf2ffd0282b14e401734b31d90a Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 19 Sep 2005 09:23:50 +0000 Subject: *** empty log message *** --- ChangeLog | 2 +- TODO | 7 +- pixmaps/Makefile.am | 4 +- pixmaps/dummy.dv | Bin 0 -> 3600000 bytes pixmaps/maage.dv | Bin 3600000 -> 0 bytes src/dvfile.h | 2 +- src/mov_encoder.cc | 21 ++-- src/mov_encoder_thread.cc | 2 +- src/mov_encoder_writer.cc | 267 ---------------------------------------------- src/multiplexer.cc | 14 +-- 10 files changed, 29 insertions(+), 290 deletions(-) create mode 100644 pixmaps/dummy.dv delete mode 100644 pixmaps/maage.dv diff --git a/ChangeLog b/ChangeLog index 9ba686a..a569f16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ Changelog for MIaV ======================================= -XXXX XX 2005 - MIaV version 0.2.7 +Sep 18 2005 - MIaV version 0.2.7 --------------------------------------- New Features: - Config file parser now reports line numbers when errors occure. diff --git a/TODO b/TODO index 2bd2003..43b228e 100644 --- a/TODO +++ b/TODO @@ -109,10 +109,11 @@ MovEncoder: (Best quality less than 22mb/s realtime encoded) [x] - Multithread encoding, for multi cpu support. [ ] - libFame frames have no timecodes!!! - [ ] - Fix audio sync problem. - [ ] - Make audio quality configurable + [x] - Fix audio sync problem. + [x] - Make audio quality configurable [x] - Files turning too big (>2gb) must automatically close and - continue in another file. + continue in another file + [ ] - Add ISO11172 multiplexing Main: [ ] - Save movie signal handling. diff --git a/pixmaps/Makefile.am b/pixmaps/Makefile.am index f6e4775..ff276cc 100644 --- a/pixmaps/Makefile.am +++ b/pixmaps/Makefile.am @@ -1,5 +1,5 @@ EXTRA_DIST = \ - maage.dv\ + dummy.dv\ about.png \ clear.png \ cpr.png \ @@ -19,7 +19,7 @@ EXTRA_DIST = \ pixmapdir = $(datadir)/pixmaps pixmap_DATA = \ - maage.dv\ + dummy.dv\ about.png \ clear.png \ cpr.png \ diff --git a/pixmaps/dummy.dv b/pixmaps/dummy.dv new file mode 100644 index 0000000..ced68b6 Binary files /dev/null and b/pixmaps/dummy.dv differ diff --git a/pixmaps/maage.dv b/pixmaps/maage.dv deleted file mode 100644 index ced68b6..0000000 Binary files a/pixmaps/maage.dv and /dev/null differ diff --git a/src/dvfile.h b/src/dvfile.h index cf78d1a..dc91a14 100644 --- a/src/dvfile.h +++ b/src/dvfile.h @@ -34,7 +34,7 @@ #include "info.h" -#define TEST_MOVIE PIXMAPS"/maage.dv" +#define TEST_MOVIE PIXMAPS"/dummy.dv" class dvfile : public frame_stream { public: diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index 09e6fa3..3d30bbb 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -80,8 +80,8 @@ MovEncoder::~MovEncoder() // this runs in a thread void MovEncoder::thread_main() { - info->info("MovEncoder thread is running."); - static volatile int test = 0; + info->info("MovEncoder::run"); + // static volatile int test = 0; int v_outsize = 0; int a_outsize = 0; int insize = 0; @@ -115,8 +115,13 @@ void MovEncoder::thread_main() // Check for end of stream if(in_frame->endOfFrameStream == true) { info->info("endOfFrameStream in MovEncoder"); - // Stop running + + // 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); } // Encode video out_v_frame = fame.encode(in_frame); @@ -149,20 +154,20 @@ void MovEncoder::thread_main() delete item; item = NULL; - + /* test++; 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); } } - + /* info->info("Input pool size: %d, video output pool size: %d, audio output pool size: %d", insize, v_outsize, a_outsize); - + */ // Kick audio encoder sem_post(audio_output_sem); @@ -170,5 +175,5 @@ void MovEncoder::thread_main() // Kick multiplexer (video) sem_post(video_output_sem); - info->info("MovEncoder thread has stopped."); + info->info("MovEncoder::stop"); } diff --git a/src/mov_encoder_thread.cc b/src/mov_encoder_thread.cc index 1e8263b..59e3c84 100644 --- a/src/mov_encoder_thread.cc +++ b/src/mov_encoder_thread.cc @@ -76,7 +76,7 @@ MovEncoderThread::MovEncoderThread(const char *cpr, Info *i) movenc->run(); encs.push_back(movenc); } - + // Create the audio encoder audioenc = new AudioEncoder(audio_inputqueue, &audio_input_mutex, &audio_in_sem, audio_outputqueue, &audio_output_mutex, &audio_out_sem, diff --git a/src/mov_encoder_writer.cc b/src/mov_encoder_writer.cc index 83530ac..717998a 100644 --- a/src/mov_encoder_writer.cc +++ b/src/mov_encoder_writer.cc @@ -111,273 +111,6 @@ void MovEncoderWriter::thread_main() audio_queue, audio_mutex, audio_sem); multiplexer.multiplex(); -#if 0 - int wrote = 0; - while(running ) { - sem_wait(audio_sem); - - // Lock output mutex - pthread_mutex_lock(audio_mutex); - audio_frame = audio_queue->top(); - if(audio_frame && audio_frame->number == audio_frame_number) audio_queue->pop(); - pthread_mutex_unlock(audio_mutex); - // Unlock output mutex - - while(audio_frame && (audio_frame->number == audio_frame_number)) { - if(file->Write(audio_frame->data, audio_frame->size) == -1) { - info->error("File write returned -1."); - return; - } - - delete audio_frame; - audio_frame = NULL; - - wrote ++; - audio_frame_number++; - - // Lock output mutex - pthread_mutex_lock(audio_mutex); - audio_frame = audio_queue->top(); - if(audio_frame && audio_frame->number == audio_frame_number) audio_queue->pop(); - pthread_mutex_unlock(audio_mutex); - // Unlock output mutex - } - } -#endif/*0*/ - - // info->info("Wrote %d mpeg packets.", wrote); info->info("MovEncoderWriter::stop"); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#if 0 -void MovEncoderWriter::write_system_header(unsigned int audio_size, unsigned int video_size) -{ - /* - Sys_header_struc sys_header; - - unsigned int mux_rate = (audio_size + video_size) * 25; - - create_sys_header(&sys_header, - mux_rate, //unsigned int rate_bound, - 1, //unsigned char audio_bound, - 1, //unsigned char fixed, - 1, //unsigned char CSPS, - 1, //unsigned char audio_lock, - 1, //unsigned char video_lock, - 1, //unsigned char video_bound, - - AUDIO_STR_0, //unsigned char stream1, - 0, //unsigned char buffer1_scale, - audio_size, //unsigned int buffer1_size, - // audio_size/128, //unsigned int buffer1_size, - - VIDEO_STR_0, //unsigned char stream2, - 1, //unsigned char buffer2_scale, - // video_size/1024, //unsigned int buffer2_size, - video_size, //unsigned int buffer2_size, - - // We both have audio *and* video - STREAMS_BOTH);//unsigned int which_streams - -// create_sys_header (sys_header, mux_rate, 1, 1, 1, 1, 1, 1, -// AUDIO_STR_0, 0, audio_size/128, -// VIDEO_STR_0, 1, video_size/1024, STREAMS_BOTH ); - - file->Write(sys_header.buf, sizeof(sys_header.buf)); -*/ - /** - * My shot at a valid system header - */ - /* - // PACK - char pack_start_code[] = { - 0x00, 0x00, 0x01, 0xBA, - }; - - file->Write(pack_start_code, sizeof(pack_start_code)); - - char pack_data[] = { - 0x21, // SCR-32 thru 30, marker bit - 0x00, 0x01, // SCR-29 thru 15, marker bit - 0x80, 0xF5, // SCR-14 thru 0, marker bit - 0x80, 0x1B, 0x83 // Marker bit, mux_rate, marker_bit - }; - - file->Write(pack_data, sizeof(pack_data)); - */ - /* - // SYSTEM - char system_header_start_code[] = { - 0x00, 0x00, 0x01, 0xBB, - }; - - file->Write(system_header_start_code, sizeof(system_header_start_code)); - - char system_data[] = { - 0x00, 0x0C, // Header length - 0x80, 0x1B, 0x83, // Marker bit, rate_bound,marker_bit - 0x07, // Audio bound, fixed_flag, CSPS_flag - 0xA1, // system_audio_lock_flag, system_video_lock_flag - 0xFF, // Reserved byte - 0xC0, // Stream id (audio) - // 0xC0, 0x20, // '11', STD_buffer_bound_scale, STD_buffer_size_bound - 0xFF, 0xFF, // '11', STD_buffer_bound_scale, STD_buffer_size_bound - 0xE0, // Stream id (video) - // 0xE0, 0x2E // '11', STD_buffer_bound_scale, STD_buffer_size_bound - 0xFF, 0xFF // '11', STD_buffer_bound_scale, STD_buffer_size_bound - }; - - file->Write(system_data, sizeof(system_data)); - - char padding_header_start_code[] = { - 0x00, 0x00, 0x01, 0xBE - }; - - file->Write(padding_header_start_code, sizeof(padding_header_start_code)); - - char padding_data[] = { - 0x00, 0x04, // Padding length - 0x0F, 0xFF, 0xFF, 0xFF // Padding - }; - - file->Write(padding_data, sizeof(padding_data)); - */ -} - -void MovEncoderWriter::write_packet_header(unsigned int audio_size, unsigned int video_size) -{ - /* - Pack_struc pack; - timestamp += 1.0; - make_timecode(timestamp, &SCR); - // Timecode_struc SCR; - unsigned int mux_rate = (audio_size + video_size) * 25; - // SCR. - - create_pack(&pack, mux_rate, &SCR); - - file->Write(pack.buf, sizeof(pack.buf)); - - unsigned char timestampbuf[32]; - unsigned char *i = timestampbuf; - buffer_timecode (&SCR, MARKER_JUST_PTS, &i); - - file->Write(timestampbuf, (int)i - (int)timestampbuf); - */ -} - -void MovEncoderWriter::write_video_header(unsigned short int psize) -{ - // PES Header startcode - char startcode[] = { - 0x00, 0x00, 0x01 - }; - - // Video stream, index = 0 - char streamID[] = { - 0xE0 - }; - - char packetsize[] = { 0x00, 0x00 }; - - char stuffing_bytes[] = { - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x0F - }; - - file->Write(startcode, sizeof(startcode)); - - file->Write(streamID, sizeof(streamID)); - - psize += - sizeof(stuffing_bytes); - packetsize[0] = ((char*)&psize)[1]; - packetsize[1] = ((char*)&psize)[0]; - file->Write(packetsize, sizeof(packetsize)); - - file->Write(stuffing_bytes, sizeof(stuffing_bytes)); -} - -void MovEncoderWriter::write_audio_header(unsigned short int psize) -{ - // PES Header startcode - char startcode[] = { - 0x00, 0x00, 0x01 - }; - - // Audio stream, index = 0 - char streamID[] = { - 0xC0 - }; - - char packetsize[] = { 0x00, 0x00 }; - - char stuffing_bytes[] = { - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF - }; - - char std_buffer[] = { - 0x40, // STD_buffer_scale - 0x20 // STD_buffer_size - }; - - char PTS[] = { - 0x21, // SCR-32 thru 30, marker bit - 0x00, 0x01, // SCR-29 thru 15, marker bit - 0xCE, 0x37 // SCR-14 thru 0, marker bit - }; - - file->Write(startcode, sizeof(startcode)); - - file->Write(streamID, sizeof(streamID)); - - psize += sizeof(stuffing_bytes) + sizeof(std_buffer) + sizeof(PTS); - packetsize[0] = ((char*)&psize)[1]; - packetsize[1] = ((char*)&psize)[0]; - file->Write(packetsize, sizeof(packetsize)); - - file->Write(stuffing_bytes, sizeof(stuffing_bytes)); - - file->Write(std_buffer, sizeof(std_buffer)); - - file->Write(PTS, sizeof(PTS)); - -} - -#endif /*0*/ diff --git a/src/multiplexer.cc b/src/multiplexer.cc index 12e9768..7f80345 100644 --- a/src/multiplexer.cc +++ b/src/multiplexer.cc @@ -174,7 +174,7 @@ bool Multiplexer::packet(StreamType type) char buf[PACKET_SIZE]; // Write data - info->info("\t\t[%sPacket]", type==TYPE_AUDIO?"Audio\0":"Video\0"); + // info->info("\t\t[%sPacket]", type==TYPE_AUDIO?"Audio\0":"Video\0"); unsigned short int framesize = read_stream(buf, PACKET_SIZE, type); @@ -246,7 +246,7 @@ bool Multiplexer::packet() */ void Multiplexer::system_header() { - info->info("\t\t[System Header]"); + // info->info("\t\t[System Header]"); // system_header_start_code (32 bits) file->Write((void*)ISO11172_1::system_header_start_code, SIZEOF(ISO11172_1::system_header_start_code)); @@ -364,7 +364,7 @@ void Multiplexer::system_header() */ bool Multiplexer::pack() { - info->info("\t[Pack"); + // info->info("\t[Pack"); file->Write((void*)ISO11172_1::pack_start_code, SIZEOF(ISO11172_1::pack_start_code)); @@ -432,7 +432,7 @@ bool Multiplexer::pack() for(int cnt = 0; cnt < PACKETS_PER_PACK; cnt++) if(!packet()) return false; - info->info("\t]"); + // info->info("\t]"); return true; } @@ -442,12 +442,12 @@ bool Multiplexer::pack() */ void Multiplexer::iso11172_stream() { - info->info("[iso11172_stream"); + // info->info("[iso11172_stream"); while(pack()); - info->info("]"); - info->info("[iso11172_end_code]"); + // info->info("]"); + // info->info("[iso11172_end_code]"); file->Write((void*)ISO11172_1::end_code, SIZEOF(ISO11172_1::end_code)); /* -- cgit v1.2.3