+ case 'Z': { /* IMF profile*/
+ int mainlevel = 0;
+ int sublevel = 0;
+ int profile = 0;
+ int framerate = 0;
+ const char* msg =
+ "Wrong value for -IMF. Should be "
+ "<PROFILE>[,mainlevel=X][,sublevel=Y][,framerate=FPS] where <PROFILE> is one "
+ "of 2K/4K/8K/2K_R/4K_R/8K_R.\n";
+ char* comma;
+
+ comma = strstr(opj_optarg, ",mainlevel=");
+ if (comma && sscanf(comma + 1, "mainlevel=%d", &mainlevel) != 1) {
+ fprintf(stderr, "%s", msg);
+ return 1;
+ }
+
+ comma = strstr(opj_optarg, ",sublevel=");
+ if (comma && sscanf(comma + 1, "sublevel=%d", &sublevel) != 1) {
+ fprintf(stderr, "%s", msg);
+ return 1;
+ }
+
+ comma = strstr(opj_optarg, ",framerate=");
+ if (comma && sscanf(comma + 1, "framerate=%d", &framerate) != 1) {
+ fprintf(stderr, "%s", msg);
+ return 1;
+ }
+
+ comma = strchr(opj_optarg, ',');
+ if (comma != NULL) {
+ *comma = 0;
+ }
+
+ if (strcmp(opj_optarg, "2K") == 0) {
+ profile = OPJ_PROFILE_IMF_2K;
+ } else if (strcmp(opj_optarg, "4K") == 0) {
+ profile = OPJ_PROFILE_IMF_4K;
+ } else if (strcmp(opj_optarg, "8K") == 0) {
+ profile = OPJ_PROFILE_IMF_8K;
+ } else if (strcmp(opj_optarg, "2K_R") == 0) {
+ profile = OPJ_PROFILE_IMF_2K_R;
+ } else if (strcmp(opj_optarg, "4K_R") == 0) {
+ profile = OPJ_PROFILE_IMF_4K_R;
+ } else if (strcmp(opj_optarg, "8K_R") == 0) {
+ profile = OPJ_PROFILE_IMF_8K_R;
+ } else {
+ fprintf(stderr, "%s", msg);
+ return 1;
+ }
+
+ if (!(mainlevel >= 0 && mainlevel <= 15)) {
+ /* Voluntarily rough validation. More fine grained done in library */
+ fprintf(stderr, "Invalid mainlevel value.\n");
+ return 1;
+ }
+ if (!(sublevel >= 0 && sublevel <= 15)) {
+ /* Voluntarily rough validation. More fine grained done in library */
+ fprintf(stderr, "Invalid sublevel value.\n");
+ return 1;
+ }
+ parameters->rsiz = (OPJ_UINT16)(profile | (sublevel << 4) | mainlevel);
+
+ fprintf(stdout, "IMF profile activated\n"
+ "Other options specified could be overridden\n");
+
+ if (pOutFramerate) {
+ *pOutFramerate = framerate;
+ }
+ if (framerate > 0 && sublevel > 0 && sublevel <= 9) {
+ const int limitMBitsSec[] = {
+ 0,
+ OPJ_IMF_SUBLEVEL_1_MBITSSEC,
+ OPJ_IMF_SUBLEVEL_2_MBITSSEC,
+ OPJ_IMF_SUBLEVEL_3_MBITSSEC,
+ OPJ_IMF_SUBLEVEL_4_MBITSSEC,
+ OPJ_IMF_SUBLEVEL_5_MBITSSEC,
+ OPJ_IMF_SUBLEVEL_6_MBITSSEC,
+ OPJ_IMF_SUBLEVEL_7_MBITSSEC,
+ OPJ_IMF_SUBLEVEL_8_MBITSSEC,
+ OPJ_IMF_SUBLEVEL_9_MBITSSEC
+ };
+ parameters->max_cs_size = limitMBitsSec[sublevel] * (1000 * 1000 / 8) /
+ framerate;
+ fprintf(stdout, "Setting max codestream size to %d bytes.\n",
+ parameters->max_cs_size);
+ }
+ }
+ break;
+
+ /* ------------------------------------------------------ */
+