[trunk] Make sure to handle ret value, and properly initialize output file
This commit is contained in:
parent
f42c26adbd
commit
c91044a4a7
|
@ -40,7 +40,7 @@ void info_callback(const char *msg, void *v);
|
||||||
void error_callback(const char *msg, void *v) {
|
void error_callback(const char *msg, void *v) {
|
||||||
(void)msg;
|
(void)msg;
|
||||||
(void)v;
|
(void)v;
|
||||||
assert(0);
|
puts(msg);
|
||||||
}
|
}
|
||||||
void warning_callback(const char *msg, void *v) {
|
void warning_callback(const char *msg, void *v) {
|
||||||
(void)msg;
|
(void)msg;
|
||||||
|
@ -87,6 +87,7 @@ int main(int argc, char *argv[])
|
||||||
cmptparm.dy = subsampling_dy;
|
cmptparm.dy = subsampling_dy;
|
||||||
cmptparm.w = image_width;
|
cmptparm.w = image_width;
|
||||||
cmptparm.h = image_height;
|
cmptparm.h = image_height;
|
||||||
|
strncpy(parameters.outfile, outputfile, sizeof(parameters.outfile)-1);
|
||||||
|
|
||||||
image = opj_image_create(numcomps, &cmptparm, color_space);
|
image = opj_image_create(numcomps, &cmptparm, color_space);
|
||||||
assert( image );
|
assert( image );
|
||||||
|
@ -113,8 +114,23 @@ int main(int argc, char *argv[])
|
||||||
opj_setup_encoder(l_codec, ¶meters, image);
|
opj_setup_encoder(l_codec, ¶meters, image);
|
||||||
|
|
||||||
l_stream = opj_stream_create_default_file_stream_v3(parameters.outfile,OPJ_FALSE);
|
l_stream = opj_stream_create_default_file_stream_v3(parameters.outfile,OPJ_FALSE);
|
||||||
|
if( !l_stream )
|
||||||
|
{
|
||||||
|
fprintf( stderr, "Something went wrong during creation of stream\n" );
|
||||||
|
opj_destroy_codec(l_codec);
|
||||||
|
opj_image_destroy(image);
|
||||||
|
opj_stream_destroy_v3(l_stream);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
assert(l_stream);
|
assert(l_stream);
|
||||||
bSuccess = opj_start_compress(l_codec,image,l_stream);
|
bSuccess = opj_start_compress(l_codec,image,l_stream);
|
||||||
|
if( !bSuccess )
|
||||||
|
{
|
||||||
|
opj_stream_destroy_v3(l_stream);
|
||||||
|
opj_destroy_codec(l_codec);
|
||||||
|
opj_image_destroy(image);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
assert( bSuccess );
|
assert( bSuccess );
|
||||||
bSuccess = opj_encode(l_codec, l_stream);
|
bSuccess = opj_encode(l_codec, l_stream);
|
||||||
|
|
Loading…
Reference in New Issue