diff options
author | deva <deva> | 2005-05-17 14:30:56 +0000 |
---|---|---|
committer | deva <deva> | 2005-05-17 14:30:56 +0000 |
commit | e3710646f6557a1592fbffa910ebed674cd9edf0 (patch) | |
tree | 6c1fe6ebdc9dad236685ec7cf09ce19ea976222a /src/mov_encoder.cc | |
parent | a7f843c9ac8bd1e4bbb017bcbfb73d7c5b110792 (diff) |
Added code, preparing threaded encoding.
Diffstat (limited to 'src/mov_encoder.cc')
-rw-r--r-- | src/mov_encoder.cc | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index fed2c40..bb24c5a 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -39,6 +39,9 @@ /* * $Log$ + * Revision 1.21 2005/05/17 14:30:56 deva + * Added code, preparing threaded encoding. + * * Revision 1.20 2005/05/16 16:00:57 deva * * Lots of stuff! @@ -94,7 +97,7 @@ //av_alloc_format_context //av_destruct_packet_nofree -MovEncoder::MovEncoder(const char *filename) +MovEncoder::MovEncoder() { // FIXME: Hmmm... should this be detected somewhere?! static int w = 720; @@ -116,14 +119,14 @@ MovEncoder::MovEncoder(const char *filename) // Allocate the output buffer. fame_buffer = new unsigned char [FAME_BUFFER_SIZE]; - + /* // Open output file f=fopen(filename, "wb"); if(!f) { - fprintf(stderr, "Failed to open output file [%s] due to teh following error: %s", filename, strerror(errno)); + fprintf(stderr, "Failed to open output file [%s] due to the following error: %s", filename, strerror(errno)); return; } - + */ // Open a new session of the fame library. // (If initialization was successful, it returns a non-null context which // can then be used for subsequent library calls.) @@ -204,27 +207,29 @@ MovEncoder::MovEncoder(const char *filename) MovEncoder::~MovEncoder() { + /* if(f) { // The file was opened. int written = fame_close(fame_context); fwrite(fame_buffer, written, 1, f); fclose(f); } + */ delete [] fame_buffer; delete [] yuv.y; delete [] yuv.u; delete [] yuv.v; } -void MovEncoder::encode(Frame *dvframe) +Frame *MovEncoder::encode(Frame *dvframe) { - encode_video(dvframe); - encode_audio(dvframe); + return encode_video(dvframe); + // encode_audio(dvframe); } -void MovEncoder::encode_video(Frame *dvframe) +Frame *MovEncoder::encode_video(Frame *dvframe) { - if(!f) return; // The file was not opened. - + // if(!f) return; // The file was not opened. + // Decode DV Frame to YUV422 int w = 720; int h = 576; @@ -281,13 +286,21 @@ void MovEncoder::encode_video(Frame *dvframe) } } + // Allocate a new frame for the output + Frame *output = new Frame(NULL, FAME_BUFFER_SIZE); + unsigned int pt = (unsigned int)output->data; + // Encode YUV frame and write it to disk. fame_start_frame(fame_context, &yuv, 0); int written; while((written = fame_encode_slice(fame_context))) { - fwrite(fame_buffer, written, 1, f); + // fwrite(fame_buffer, written, 1, f); + memcpy((void *)pt, fame_buffer, written); + pt += written; } fame_end_frame(fame_context,0); + + return output; } void MovEncoder::encode_audio(Frame *dvframe) |