* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "../libopenjpeg/opj_includes.h"
+#include "opj_includes.h"
#include "mj2.h"
/* ----------------------- */
/* */
/* ----------------------- */
-int yuv_num_frames(mj2_tk_t * tk, char *infile)
+unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile)
{
- int numimages, frame_size, prec_size;
- long end_of_f;
+ unsigned int prec_size;
+ long end_of_f, frame_size;
FILE *f;
f = fopen(infile,"rb");
if (!f) {
fprintf(stderr, "failed to open %s for reading\n",infile);
- return -1;
+ return 0;
}
prec_size = (tk->depth + 7)/8;/* bytes of precision */
- frame_size = (int) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */
+ frame_size = (long) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */
frame_size *= prec_size;
fseek(f, 0, SEEK_END);
fprintf(stderr,
"YUV does not contains any frame of %d x %d size\n", tk->w,
tk->h);
- return -1;
+ return 0;
}
+ fclose(f);
- numimages = end_of_f / frame_size; /* Calculate number of images */
- fclose(f);
-
- return numimages;
+ return (unsigned int)(end_of_f / frame_size);
}
// -----------------------
// -----------------------
-bool imagetoyuv(opj_image_t * img, char *outfile)
+opj_bool imagetoyuv(opj_image_t * img, char *outfile)
{
FILE *f;
int *data;
|| img->comps[1].dx != img->comps[2].dx) {
fprintf(stderr,
"Error with the input image components size: cannot create yuv file)\n");
- return false;
+ return OPJ_FALSE;
}
} else if (!(img->numcomps == 1)) {
fprintf(stderr,
"Error with the number of image components(must be one or three)\n");
- return false;
+ return OPJ_FALSE;
}
f = fopen(outfile, "a+b");
if (!f) {
fprintf(stderr, "failed to open %s for writing\n", outfile);
- return false;
+ return OPJ_FALSE;
}
is_16 = (img->comps[0].prec > 8);
prec_bytes = (is_16?2:1);
}
}
fclose(f);
- return true;
+ return OPJ_TRUE;
}
// -----------------------