diff options
Diffstat (limited to 'src/mov_encoder.cc')
-rw-r--r-- | src/mov_encoder.cc | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index 0e2b935..cbf7993 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -39,6 +39,9 @@ /* * $Log$ + * Revision 1.16 2005/05/09 19:54:15 deva + * *** empty log message *** + * * Revision 1.15 2005/05/09 16:40:20 deva * * Added optimize yuv conversion code @@ -70,6 +73,8 @@ #include "mov_encoder.h" +#include <errno.h> + #include "debug.h" //av_alloc_format_context //av_destruct_packet_nofree @@ -99,13 +104,19 @@ MovEncoder::MovEncoder(const char *filename) // Open output file f=fopen(filename, "wb"); - // FIXME: check f == NULL + if(!f) { + fprintf(stderr, "Failed to open output file [%s] due to teh following error: %s", filename, strerror(errno)); + return; + } // Open a new session of the fame library. - fame_context = fame_open(); - // FIXME: check fame_context == NULL // (If initialization was successful, it returns a non-null context which // can then be used for subsequent library calls.) + fame_context = fame_open(); + if(!fame_context) { + fprintf(stderr, "Unable to open FAME context, due to the following error: %s", strerror(errno)); + return; + } /* typedef struct _fame_parameters_ { @@ -166,14 +177,15 @@ MovEncoder::MovEncoder(const char *filename) fame_par.verbose = 0; fame_init(fame_context, &fame_par, fame_buffer, FAME_BUFFER_SIZE); - // FIXME: fame_init return a new context, or NULL if an error occurred. } MovEncoder::~MovEncoder() { - int written = fame_close(fame_context); - fwrite(fame_buffer, written, 1, f); - fclose(f); + 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; @@ -201,6 +213,8 @@ inline void rgb_to_yuv(unsigned char *rgb, unsigned char &y, unsigned char &u, u void MovEncoder::encode_video(Frame *dvframe) { + if(!f) return; // The file was not opened. + // Decode DV Frame to YUV int w = 720; int h = 576; |