/* basic testing of all RAW_FILEINFO_* calls for each call we test that it succeeds, and where possible test for consistency between the calls. */ static bool torture_raw_qfileinfo_internals(struct torture_context *torture, TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, int fnum, const char *fname, bool is_ipc) { int i; bool ret = true; int count; union smb_fileinfo *s1, *s2; NTTIME correct_time; uint64_t correct_size; uint32_t correct_attrib; const char *correct_name; bool skip_streams = false; /* scan all the fileinfo and pathinfo levels */ for (i=0; levels[i].name; i++) { if (!levels[i].only_paths) { levels[i].fnum_finfo.generic.level = levels[i].level; levels[i].fnum_finfo.generic.in.file.fnum = fnum; levels[i].fnum_status = smb_raw_fileinfo(tree, mem_ctx, &levels[i].fnum_finfo); } if (!levels[i].only_handles) { levels[i].fname_finfo.generic.level = levels[i].level; levels[i].fname_finfo.generic.in.file.path = talloc_strdup(mem_ctx, fname); levels[i].fname_status = smb_raw_pathinfo(tree, mem_ctx, &levels[i].fname_finfo); } } /* check for completely broken levels */ for (count=i=0; levels[i].name; i++) { uint32_t cap = tree->session->transport->negotiate.capabilities; /* see if this server claims to support this level */ if ((cap & levels[i].capability_mask) != levels[i].capability_mask) { continue; } if (is_ipc) { if (levels[i].expected_ipc_access_denied && NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, levels[i].fname_status)) { } else if (!levels[i].only_handles && NT_STATUS_EQUAL(levels[i].fname_status, NT_STATUS_NOT_SUPPORTED)) { torture_warning(torture, "fname level %s %s", levels[i].name, nt_errstr(levels[i].fname_status)); continue; } else if (!levels[i].only_handles && !NT_STATUS_EQUAL(NT_STATUS_INVALID_DEVICE_REQUEST, levels[i].fname_status)) { printf("ERROR: fname level %s failed, expected NT_STATUS_INVALID_DEVICE_REQUEST - %s\n", levels[i].name, nt_errstr(levels[i].fname_status)); count++; } if (!levels[i].only_paths && (NT_STATUS_EQUAL(levels[i].fnum_status, NT_STATUS_NOT_SUPPORTED) || NT_STATUS_EQUAL(levels[i].fnum_status, NT_STATUS_NOT_IMPLEMENTED))) { torture_warning(torture, "fnum level %s %s", levels[i].name, nt_errstr(levels[i].fnum_status)); continue; } if (!levels[i].only_paths && !NT_STATUS_EQUAL(levels[i].expected_ipc_fnum_status, levels[i].fnum_status)) { printf("ERROR: fnum level %s failed, expected %s - %s\n", levels[i].name, nt_errstr(levels[i].expected_ipc_fnum_status), nt_errstr(levels[i].fnum_status)); count++; } } else { if (!levels[i].only_paths && (NT_STATUS_EQUAL(levels[i].fnum_status, NT_STATUS_NOT_SUPPORTED) || NT_STATUS_EQUAL(levels[i].fnum_status, NT_STATUS_NOT_IMPLEMENTED))) { torture_warning(torture, "fnum level %s %s", levels[i].name, nt_errstr(levels[i].fnum_status)); continue; } if (!levels[i].only_handles && (NT_STATUS_EQUAL(levels[i].fname_status, NT_STATUS_NOT_SUPPORTED) || NT_STATUS_EQUAL(levels[i].fname_status, NT_STATUS_NOT_IMPLEMENTED))) { torture_warning(torture, "fname level %s %s", levels[i].name, nt_errstr(levels[i].fname_status)); continue; } if (!levels[i].only_paths && !NT_STATUS_IS_OK(levels[i].fnum_status)) { printf("ERROR: fnum level %s failed - %s\n", levels[i].name, nt_errstr(levels[i].fnum_status)); count++; } if (!levels[i].only_handles && !NT_STATUS_IS_OK(levels[i].fname_status)) { printf("ERROR: fname level %s failed - %s\n", levels[i].name, nt_errstr(levels[i].fname_status)); count++; } } } if (count != 0) { ret = false; printf("%d levels failed\n", count); if (count > 35) { torture_fail(torture, "too many level failures - giving up"); } } /* see if we can do streams */ s1 = fnum_find("STREAM_INFO"); if (!s1 || s1->stream_info.out.num_streams == 0) { if (!is_ipc) { printf("STREAM_INFO broken (%d) - skipping streams checks\n", s1 ? s1->stream_info.out.num_streams : -1); } skip_streams = true; } /* this code is incredibly repititive but doesn't lend itself to loops, so we use lots of macros to make it less painful */ /* first off we check the levels that are supposed to be aliases. It will be quite rare for this code to fail, but we need to check it for completeness */ #define ALIAS_CHECK(sname1, sname2) \ do { \ s1 = fnum_find(sname1); s2 = fnum_find(sname2); \ if (s1 && s2) { INFO_CHECK } \ s1 = fname_find(is_ipc, sname1); s2 = fname_find(is_ipc, sname2); \ if (s1 && s2) { INFO_CHECK } \ s1 = fnum_find(sname1); s2 = fname_find(is_ipc, sname2); \ if (s1 && s2) { INFO_CHECK } \ } while (0) #define INFO_CHECK \ STRUCT_EQUAL(basic_info, create_time, basic_info, create_time); \ STRUCT_EQUAL(basic_info, access_time, basic_info, access_time); \ STRUCT_EQUAL(basic_info, write_time, basic_info, write_time); \ STRUCT_EQUAL(basic_info, change_time, basic_info, change_time); \ VAL_EQUAL (basic_info, attrib, basic_info, attrib); ALIAS_CHECK("BASIC_INFO", "BASIC_INFORMATION"); #undef INFO_CHECK #define INFO_CHECK \ VAL_EQUAL(standard_info, alloc_size, standard_info, alloc_size); \ VAL_EQUAL(standard_info, size, standard_info, size); \ VAL_EQUAL(standard_info, nlink, standard_info, nlink); \ VAL_EQUAL(standard_info, delete_pending, standard_info, delete_pending); \ VAL_EQUAL(standard_info, directory, standard_info, directory); ALIAS_CHECK("STANDARD_INFO", "STANDARD_INFORMATION"); #undef INFO_CHECK #define INFO_CHECK \ VAL_EQUAL(ea_info, ea_size, ea_info, ea_size); ALIAS_CHECK("EA_INFO", "EA_INFORMATION"); #undef INFO_CHECK #define INFO_CHECK \ STR_EQUAL(name_info, fname, name_info, fname); ALIAS_CHECK("NAME_INFO", "NAME_INFORMATION"); #undef INFO_CHECK #define INFO_CHECK \ STRUCT_EQUAL(all_info, create_time, all_info, create_time); \ STRUCT_EQUAL(all_info, access_time, all_info, access_time); \ STRUCT_EQUAL(all_info, write_time, all_info, write_time); \ STRUCT_EQUAL(all_info, change_time, all_info, change_time); \ VAL_EQUAL(all_info, attrib, all_info, attrib); \ VAL_EQUAL(all_info, alloc_size, all_info, alloc_size); \ VAL_EQUAL(all_info, size, all_info, size); \ VAL_EQUAL(all_info, nlink, all_info, nlink); \ VAL_EQUAL(all_info, delete_pending, all_info, delete_pending); \ VAL_EQUAL(all_info, directory, all_info, directory); \ VAL_EQUAL(all_info, ea_size, all_info, ea_size); \ STR_EQUAL(all_info, fname, all_info, fname); ALIAS_CHECK("ALL_INFO", "ALL_INFORMATION"); #undef INFO_CHECK #define INFO_CHECK \ VAL_EQUAL(compression_info, compressed_size,compression_info, compressed_size); \ VAL_EQUAL(compression_info, format, compression_info, format); \ VAL_EQUAL(compression_info, unit_shift, compression_info, unit_shift); \ VAL_EQUAL(compression_info, chunk_shift, compression_info, chunk_shift); \ VAL_EQUAL(compression_info, cluster_shift, compression_info, cluster_shift); ALIAS_CHECK("COMPRESSION_INFO", "COMPRESSION_INFORMATION"); #undef INFO_CHECK #define INFO_CHECK \ STR_EQUAL(alt_name_info, fname, alt_name_info, fname); ALIAS_CHECK("ALT_NAME_INFO", "ALT_NAME_INFORMATION"); #define TIME_CHECK_NT(sname, stype, tfield) do { \ s1 = fnum_find(sname); \ if (s1 && memcmp(&s1->stype.out.tfield, &correct_time, sizeof(correct_time)) != 0) { \ printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ nt_time_string(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && memcmp(&s1->stype.out.tfield, &correct_time, sizeof(correct_time)) != 0) { \ printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ nt_time_string(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ ret = false; \ }} while (0) #define TIME_CHECK_DOS(sname, stype, tfield) do { \ s1 = fnum_find(sname); \ if (s1 && dos_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \ printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ timestring(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && dos_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \ printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ timestring(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ ret = false; \ }} while (0) #if 0 /* unused */ #define TIME_CHECK_UNX(sname, stype, tfield) do { \ s1 = fnum_find(sname); \ if (s1 && unx_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \ printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ timestring(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && unx_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \ printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ timestring(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ ret = false; \ }} while (0) #endif /* now check that all the times that are supposed to be equal are correct */ s1 = fnum_find("BASIC_INFO"); correct_time = s1->basic_info.out.create_time; torture_comment(torture, "create_time: %s\n", nt_time_string(mem_ctx, correct_time)); TIME_CHECK_NT ("BASIC_INFO", basic_info, create_time); TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, create_time); TIME_CHECK_DOS("GETATTRE", getattre, create_time); TIME_CHECK_DOS("STANDARD", standard, create_time); TIME_CHECK_DOS("EA_SIZE", ea_size, create_time); TIME_CHECK_NT ("ALL_INFO", all_info, create_time); TIME_CHECK_NT ("NETWORK_OPEN_INFORMATION", network_open_information, create_time); s1 = fnum_find("BASIC_INFO"); correct_time = s1->basic_info.out.access_time; torture_comment(torture, "access_time: %s\n", nt_time_string(mem_ctx, correct_time)); TIME_CHECK_NT ("BASIC_INFO", basic_info, access_time); TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, access_time); TIME_CHECK_DOS("GETATTRE", getattre, access_time); TIME_CHECK_DOS("STANDARD", standard, access_time); TIME_CHECK_DOS("EA_SIZE", ea_size, access_time); TIME_CHECK_NT ("ALL_INFO", all_info, access_time); TIME_CHECK_NT ("NETWORK_OPEN_INFORMATION", network_open_information, access_time); s1 = fnum_find("BASIC_INFO"); correct_time = s1->basic_info.out.write_time; torture_comment(torture, "write_time : %s\n", nt_time_string(mem_ctx, correct_time)); TIME_CHECK_NT ("BASIC_INFO", basic_info, write_time); TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, write_time); TIME_CHECK_DOS("GETATTR", getattr, write_time); TIME_CHECK_DOS("GETATTRE", getattre, write_time); TIME_CHECK_DOS("STANDARD", standard, write_time); TIME_CHECK_DOS("EA_SIZE", ea_size, write_time); TIME_CHECK_NT ("ALL_INFO", all_info, write_time); TIME_CHECK_NT ("NETWORK_OPEN_INFORMATION", network_open_information, write_time); s1 = fnum_find("BASIC_INFO"); correct_time = s1->basic_info.out.change_time; torture_comment(torture, "change_time: %s\n", nt_time_string(mem_ctx, correct_time)); TIME_CHECK_NT ("BASIC_INFO", basic_info, change_time); TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, change_time); TIME_CHECK_NT ("ALL_INFO", all_info, change_time); TIME_CHECK_NT ("NETWORK_OPEN_INFORMATION", network_open_information, change_time); #define SIZE_CHECK(sname, stype, tfield) do { \ s1 = fnum_find(sname); \ if (s1 && s1->stype.out.tfield != correct_size) { \ printf("(%d) handle %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield, \ (unsigned int)s1->stype.out.tfield, \ (unsigned int)correct_size); \ ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && s1->stype.out.tfield != correct_size) { \ printf("(%d) path %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield, \ (unsigned int)s1->stype.out.tfield, \ (unsigned int)correct_size); \ ret = false; \ }} while (0) s1 = fnum_find("STANDARD_INFO"); correct_size = s1->standard_info.out.size; torture_comment(torture, "size: %u\n", (unsigned int)correct_size); SIZE_CHECK("GETATTR", getattr, size); SIZE_CHECK("GETATTRE", getattre, size); SIZE_CHECK("STANDARD", standard, size); SIZE_CHECK("EA_SIZE", ea_size, size); SIZE_CHECK("STANDARD_INFO", standard_info, size); SIZE_CHECK("STANDARD_INFORMATION", standard_info, size); SIZE_CHECK("ALL_INFO", all_info, size); SIZE_CHECK("ALL_INFORMATION", all_info, size); SIZE_CHECK("COMPRESSION_INFO", compression_info, compressed_size); SIZE_CHECK("COMPRESSION_INFORMATION", compression_info, compressed_size); SIZE_CHECK("NETWORK_OPEN_INFORMATION", network_open_information, size); if (!skip_streams) { SIZE_CHECK("STREAM_INFO", stream_info, streams[0].size); SIZE_CHECK("STREAM_INFORMATION", stream_info, streams[0].size); } s1 = fnum_find("STANDARD_INFO"); correct_size = s1->standard_info.out.alloc_size; torture_comment(torture, "alloc_size: %u\n", (unsigned int)correct_size); SIZE_CHECK("GETATTRE", getattre, alloc_size); SIZE_CHECK("STANDARD", standard, alloc_size); SIZE_CHECK("EA_SIZE", ea_size, alloc_size); SIZE_CHECK("STANDARD_INFO", standard_info, alloc_size); SIZE_CHECK("STANDARD_INFORMATION", standard_info, alloc_size); SIZE_CHECK("ALL_INFO", all_info, alloc_size); SIZE_CHECK("ALL_INFORMATION", all_info, alloc_size); SIZE_CHECK("NETWORK_OPEN_INFORMATION", network_open_information, alloc_size); if (!skip_streams) { SIZE_CHECK("STREAM_INFO", stream_info, streams[0].alloc_size); SIZE_CHECK("STREAM_INFORMATION", stream_info, streams[0].alloc_size); } #define ATTRIB_CHECK(sname, stype, tfield) do { \ s1 = fnum_find(sname); \ if (s1 && s1->stype.out.tfield != correct_attrib) { \ printf("(%d) handle %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield, \ (unsigned int)s1->stype.out.tfield, \ (unsigned int)correct_attrib); \ ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && s1->stype.out.tfield != correct_attrib) { \ printf("(%d) path %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield, \ (unsigned int)s1->stype.out.tfield, \ (unsigned int)correct_attrib); \ ret = false; \ }} while (0) s1 = fnum_find("BASIC_INFO"); correct_attrib = s1->basic_info.out.attrib; torture_comment(torture, "attrib: 0x%x\n", (unsigned int)correct_attrib); ATTRIB_CHECK("GETATTR", getattr, attrib); if (!is_ipc) { ATTRIB_CHECK("GETATTRE", getattre, attrib); ATTRIB_CHECK("STANDARD", standard, attrib); ATTRIB_CHECK("EA_SIZE", ea_size, attrib); } ATTRIB_CHECK("BASIC_INFO", basic_info, attrib); ATTRIB_CHECK("BASIC_INFORMATION", basic_info, attrib); ATTRIB_CHECK("ALL_INFO", all_info, attrib); ATTRIB_CHECK("ALL_INFORMATION", all_info, attrib); ATTRIB_CHECK("NETWORK_OPEN_INFORMATION", network_open_information, attrib); ATTRIB_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, attrib); correct_name = fname; torture_comment(torture, "name: %s\n", correct_name); #define NAME_CHECK(sname, stype, tfield, flags) do { \ s1 = fnum_find(sname); \ if (s1 && (strcmp_safe(s1->stype.out.tfield.s, correct_name) != 0 || \ wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \ printf("(%d) handle %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \ s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \ ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && (strcmp_safe(s1->stype.out.tfield.s, correct_name) != 0 || \ wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \ printf("(%d) path %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \ s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \ ret = false; \ }} while (0) NAME_CHECK("NAME_INFO", name_info, fname, STR_UNICODE); NAME_CHECK("NAME_INFORMATION", name_info, fname, STR_UNICODE); /* the ALL_INFO file name is the full path on the filesystem */ s1 = fnum_find("ALL_INFO"); if (s1 && !s1->all_info.out.fname.s) { torture_fail(torture, "ALL_INFO didn't give a filename"); } if (s1 && s1->all_info.out.fname.s) { char *p = strrchr(s1->all_info.out.fname.s, '\\'); if (!p) { printf("Not a full path in all_info/fname? - '%s'\n", s1->all_info.out.fname.s); ret = false; } else { if (strcmp_safe(correct_name, p) != 0) { printf("incorrect basename in all_info/fname - '%s'\n", s1->all_info.out.fname.s); ret = false; } } if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE, tree->session->transport)) { printf("Should not null terminate all_info/fname\n"); ret = false; } } s1 = fnum_find("ALT_NAME_INFO"); if (s1) { correct_name = s1->alt_name_info.out.fname.s; } if (!correct_name) { torture_comment(torture, "no alternate name information\n"); } else { torture_comment(torture, "alt_name: %s\n", correct_name); NAME_CHECK("ALT_NAME_INFO", alt_name_info, fname, STR_UNICODE); NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE); /* and make sure we can open by alternate name */ smbcli_close(tree, fnum); fnum = smbcli_nt_create_full(tree, correct_name, 0, SEC_RIGHTS_FILE_ALL, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_DELETE| NTCREATEX_SHARE_ACCESS_READ| NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum == -1) { printf("Unable to open by alt_name - %s\n", smbcli_errstr(tree)); ret = false; } if (!skip_streams) { correct_name = "::$DATA"; torture_comment(torture, "stream_name: %s\n", correct_name); NAME_CHECK("STREAM_INFO", stream_info, streams[0].stream_name, STR_UNICODE); NAME_CHECK("STREAM_INFORMATION", stream_info, streams[0].stream_name, STR_UNICODE); } } /* make sure the EAs look right */ s1 = fnum_find("ALL_EAS"); s2 = fnum_find("ALL_INFO"); if (s1) { for (i=0;i<s1->all_eas.out.num_eas;i++) { printf(" flags=%d %s=%*.*s\n", s1->all_eas.out.eas[i].flags, s1->all_eas.out.eas[i].name.s, (int)s1->all_eas.out.eas[i].value.length, (int)s1->all_eas.out.eas[i].value.length, s1->all_eas.out.eas[i].value.data); } } if (s1 && s2) { if (s1->all_eas.out.num_eas == 0) { if (s2->all_info.out.ea_size != 0) { printf("ERROR: num_eas==0 but fnum all_info.out.ea_size == %d\n", s2->all_info.out.ea_size); } } else { if (s2->all_info.out.ea_size != ea_list_size(s1->all_eas.out.num_eas, s1->all_eas.out.eas)) { printf("ERROR: ea_list_size=%d != fnum all_info.out.ea_size=%d\n", (int)ea_list_size(s1->all_eas.out.num_eas, s1->all_eas.out.eas), (int)s2->all_info.out.ea_size); } } } s2 = fname_find(is_ipc, "ALL_EAS"); if (s2) { VAL_EQUAL(all_eas, num_eas, all_eas, num_eas); for (i=0;i<s1->all_eas.out.num_eas;i++) { VAL_EQUAL(all_eas, eas[i].flags, all_eas, eas[i].flags); STR_EQUAL(all_eas, eas[i].name, all_eas, eas[i].name); VAL_EQUAL(all_eas, eas[i].value.length, all_eas, eas[i].value.length); } } #define VAL_CHECK(sname1, stype1, tfield1, sname2, stype2, tfield2) do { \ s1 = fnum_find(sname1); s2 = fnum_find(sname2); \ if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \ printf("(%d) handle %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \ #stype1, #tfield1, #stype2, #tfield2, \ s1->stype1.out.tfield1, s2->stype2.out.tfield2); \ ret = false; \ } \ s1 = fname_find(is_ipc, sname1); s2 = fname_find(is_ipc, sname2); \ if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \ printf("(%d) path %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \ #stype1, #tfield1, #stype2, #tfield2, \ s1->stype1.out.tfield1, s2->stype2.out.tfield2); \ ret = false; \ } \ s1 = fnum_find(sname1); s2 = fname_find(is_ipc, sname2); \ if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \ printf("(%d) handle %s/%s != path %s/%s - 0x%x vs 0x%x\n", __LINE__, \ #stype1, #tfield1, #stype2, #tfield2, \ s1->stype1.out.tfield1, s2->stype2.out.tfield2); \ ret = false; \ } \ s1 = fname_find(is_ipc, sname1); s2 = fnum_find(sname2); \ if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \ printf("(%d) path %s/%s != handle %s/%s - 0x%x vs 0x%x\n", __LINE__, \ #stype1, #tfield1, #stype2, #tfield2, \ s1->stype1.out.tfield1, s2->stype2.out.tfield2); \ ret = false; \ }} while (0) VAL_CHECK("STANDARD_INFO", standard_info, delete_pending, "ALL_INFO", all_info, delete_pending); VAL_CHECK("STANDARD_INFO", standard_info, directory, "ALL_INFO", all_info, directory); VAL_CHECK("STANDARD_INFO", standard_info, nlink, "ALL_INFO", all_info, nlink); s1 = fnum_find("BASIC_INFO"); if (s1 && is_ipc) { if (s1->basic_info.out.attrib != FILE_ATTRIBUTE_NORMAL) { printf("(%d) attrib basic_info/nlink incorrect - %d should be %d\n", __LINE__, s1->basic_info.out.attrib, (int)FILE_ATTRIBUTE_NORMAL); ret = false; } } s1 = fnum_find("STANDARD_INFO"); if (s1 && is_ipc) { if (s1->standard_info.out.nlink != 1) { printf("(%d) nlinks standard_info/nlink incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.nlink); ret = false; } if (s1->standard_info.out.delete_pending != 1) { printf("(%d) nlinks standard_info/delete_pending incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.delete_pending); ret = false; } } VAL_CHECK("EA_INFO", ea_info, ea_size, "ALL_INFO", all_info, ea_size); if (!is_ipc) { VAL_CHECK("EA_SIZE", ea_size, ea_size, "ALL_INFO", all_info, ea_size); } #define NAME_PATH_CHECK(sname, stype, field) do { \ s1 = fname_find(is_ipc, sname); s2 = fnum_find(sname); \ if (s1 && s2) { \ VAL_EQUAL(stype, field, stype, field); \ } \ } while (0) s1 = fnum_find("INTERNAL_INFORMATION"); if (s1) { torture_comment(torture, "file_id=%.0f\n", (double)s1->internal_information.out.file_id); } NAME_PATH_CHECK("INTERNAL_INFORMATION", internal_information, file_id); NAME_PATH_CHECK("POSITION_INFORMATION", position_information, position); if (s1 && s2) { printf("fnum pos = %.0f, fname pos = %.0f\n", (double)s2->position_information.out.position, (double)s1->position_information.out.position ); } NAME_PATH_CHECK("MODE_INFORMATION", mode_information, mode); NAME_PATH_CHECK("ALIGNMENT_INFORMATION", alignment_information, alignment_requirement); NAME_PATH_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, attrib); NAME_PATH_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, reparse_tag); #if 0 /* these are expected to differ */ NAME_PATH_CHECK("ACCESS_INFORMATION", access_information, access_flags); #endif #if 0 /* unused */ #define UNKNOWN_CHECK(sname, stype, tfield) do { \ s1 = fnum_find(sname); \ if (s1 && s1->stype.out.tfield != 0) { \ printf("(%d) handle %s/%s unknown != 0 (0x%x)\n", __LINE__, \ #stype, #tfield, \ (unsigned int)s1->stype.out.tfield); \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && s1->stype.out.tfield != 0) { \ printf("(%d) path %s/%s unknown != 0 (0x%x)\n", __LINE__, \ #stype, #tfield, \ (unsigned int)s1->stype.out.tfield); \ }} while (0) #endif /* now get a bit fancier .... */ /* when we set the delete disposition then the link count should drop to 0 and delete_pending should be 1 */ return ret; }
mfxStatus ParseInputString(msdk_char* strInput[], mfxU8 nArgNum, sInputParams* pParams) { if (1 == nArgNum) { PrintHelp(strInput[0], NULL); return MFX_ERR_UNSUPPORTED; } MSDK_CHECK_POINTER(pParams, MFX_ERR_NULL_PTR); msdk_opt_read(MSDK_CPU_ROTATE_PLUGIN, pParams->strPluginDLLPath); // default implementation pParams->bUseHWLib = true; pParams->isV4L2InputEnabled = false; pParams->nNumFrames = 0; #if defined (ENABLE_V4L2_SUPPORT) pParams->MipiPort = -1; pParams->MipiMode = NONE; pParams->v4l2Format = NO_FORMAT; #endif // parse command line parameters for (mfxU8 i = 1; i < nArgNum; i++) { MSDK_CHECK_POINTER(strInput[i], MFX_ERR_NULL_PTR); if (MSDK_CHAR('-') != strInput[i][0]) { mfxStatus sts = StrFormatToCodecFormatFourCC(strInput[i], pParams->CodecId); if (sts != MFX_ERR_NONE) { PrintHelp(strInput[0], MSDK_STRING("Unknown codec")); return MFX_ERR_UNSUPPORTED; } if (!IsEncodeCodecSupported(pParams->CodecId)) { PrintHelp(strInput[0], MSDK_STRING("Unsupported codec")); return MFX_ERR_UNSUPPORTED; } if (pParams->CodecId == CODEC_MVC) { pParams->CodecId = MFX_CODEC_AVC; pParams->MVC_flags |= MVC_ENABLED; } continue; } // process multi-character options if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-dstw"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nDstWidth)) { PrintHelp(strInput[0], MSDK_STRING("Destination picture Width is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-dsth"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nDstHeight)) { PrintHelp(strInput[0], MSDK_STRING("Destination picture Height is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-sw"))) { pParams->bUseHWLib = false; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-hw"))) { pParams->bUseHWLib = true; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-yuy2"))) { #if defined (ENABLE_V4L2_SUPPORT) pParams->v4l2Format = YUY2; #endif pParams->ColorFormat = MFX_FOURCC_YUY2; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-nv12"))) { pParams->ColorFormat = MFX_FOURCC_NV12; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-tff"))) { pParams->nPicStruct = MFX_PICSTRUCT_FIELD_TFF; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-bff"))) { pParams->nPicStruct = MFX_PICSTRUCT_FIELD_BFF; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-bref"))) { pParams->nBRefType = MFX_B_REF_PYRAMID; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-nobref"))) { pParams->nBRefType = MFX_B_REF_OFF; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-idr_interval"))) { if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nIdrInterval)) { PrintHelp(strInput[0], MSDK_STRING("IdrInterval is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-angle"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nRotationAngle)) { PrintHelp(strInput[0], MSDK_STRING("Rotation Angle is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-opencl"))) { msdk_opt_read(MSDK_OCL_ROTATE_PLUGIN, pParams->strPluginDLLPath); pParams->nRotationAngle = 180; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-viewoutput"))) { if (!(MVC_ENABLED & pParams->MVC_flags)) { PrintHelp(strInput[0], MSDK_STRING("-viewoutput option is supported only when mvc codec specified")); return MFX_ERR_UNSUPPORTED; } pParams->MVC_flags |= MVC_VIEWOUTPUT; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-la"))) { pParams->nRateControlMethod = MFX_RATECONTROL_LA; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-lad"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); pParams->nRateControlMethod = MFX_RATECONTROL_LA; if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nLADepth)) { PrintHelp(strInput[0], MSDK_STRING("Look Ahead Depth is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-mss"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nMaxSliceSize)) { PrintHelp(strInput[0], MSDK_STRING("MaxSliceSize is invalid")); return MFX_ERR_UNSUPPORTED; } } #if D3D_SURFACES_SUPPORT else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-d3d"))) { pParams->memType = D3D9_MEMORY; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-d3d11"))) { pParams->memType = D3D11_MEMORY; } #endif #ifdef LIBVA_SUPPORT else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-vaapi"))) { pParams->memType = D3D9_MEMORY; } #endif else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-async"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nAsyncDepth)) { PrintHelp(strInput[0], MSDK_STRING("Async Depth is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-gpucopy::on"))) { pParams->gpuCopy = MFX_GPUCOPY_ON; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-gpucopy::off"))) { pParams->gpuCopy = MFX_GPUCOPY_OFF; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-cqp"))) { pParams->nRateControlMethod = MFX_RATECONTROL_CQP; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-qpi"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nQPI)) { PrintHelp(strInput[0], MSDK_STRING("Quantizer for I frames is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-qpp"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nQPP)) { PrintHelp(strInput[0], MSDK_STRING("Quantizer for P frames is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-qpb"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nQPB)) { PrintHelp(strInput[0], MSDK_STRING("Quantizer for B frames is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-qsv-ff"))) { pParams->enableQSVFF=true; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-num_slice"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->nNumSlice)) { PrintHelp(strInput[0], MSDK_STRING("Number of slices is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-path"))) { i++; #if defined(_WIN32) || defined(_WIN64) msdk_char wchar[MSDK_MAX_FILENAME_LEN]; msdk_opt_read(strInput[i], wchar); std::wstring wstr(wchar); std::string str(wstr.begin(), wstr.end()); strcpy_s(pParams->pluginParams.strPluginPath, str.c_str()); #else msdk_opt_read(strInput[i], pParams->pluginParams.strPluginPath); #endif pParams->pluginParams.type = MFX_PLUGINLOAD_TYPE_FILE; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-re"))) { pParams->UseRegionEncode = true; } MOD_ENC_PARSE_INPUT #if defined (ENABLE_V4L2_SUPPORT) else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-d"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->DeviceName)) { PrintHelp(strInput[0], MSDK_STRING("Device name is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-uyvy"))) { pParams->v4l2Format = UYVY; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-p"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->MipiPort)) { PrintHelp(strInput[0], MSDK_STRING("Mipi-port is invalid")); return MFX_ERR_UNSUPPORTED; } } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-m"))) { VAL_CHECK(i+1 >= nArgNum, i, strInput[i]); if (MFX_ERR_NONE != msdk_opt_read(strInput[++i], pParams->MipiModeName)) { PrintHelp(strInput[0], MSDK_STRING("Device name is invalid")); return MFX_ERR_UNSUPPORTED; } if(strcasecmp(pParams->MipiModeName,"STILL") == 0) pParams->MipiMode = STILL; else if(strcasecmp(pParams->MipiModeName,"VIDEO") == 0) pParams->MipiMode = VIDEO; else if(strcasecmp(pParams->MipiModeName,"PREVIEW") == 0) pParams->MipiMode = PREVIEW; else if(strcasecmp(pParams->MipiModeName,"CONTINUOUS") == 0) pParams->MipiMode = CONTINUOUS; else pParams->MipiMode = NONE; } else if (0 == msdk_strcmp(strInput[i], MSDK_STRING("-i::v4l2"))) { pParams->isV4L2InputEnabled = true; } #endif else // 1-character options { switch (strInput[i][1]) { case MSDK_CHAR('u'): if (++i < nArgNum) { pParams->nTargetUsage = StrToTargetUsage(strInput[i]); } else { msdk_printf(MSDK_STRING("error: option '-u' expects an argument\n")); } break; case MSDK_CHAR('w'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->nWidth)) { PrintHelp(strInput[0], MSDK_STRING("Width is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-w' expects an argument\n")); } break; case MSDK_CHAR('h'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->nHeight)) { PrintHelp(strInput[0], MSDK_STRING("Height is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-h' expects an argument\n")); } break; case MSDK_CHAR('f'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->dFrameRate)) { PrintHelp(strInput[0], MSDK_STRING("Frame Rate is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-f' expects an argument\n")); } break; case MSDK_CHAR('n'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->nNumFrames)) { PrintHelp(strInput[0], MSDK_STRING("Number of frames to process is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-n' expects an argument\n")); } break; case MSDK_CHAR('b'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->nBitRate)) { PrintHelp(strInput[0], MSDK_STRING("Bit Rate is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-b' expects an argument\n")); } break; case MSDK_CHAR('x'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->nNumRefFrame)) { PrintHelp(strInput[0], MSDK_STRING("Ref Num is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-x' expects an argument\n")); } break; case MSDK_CHAR('g'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->nGopPicSize)) { PrintHelp(strInput[0], MSDK_STRING("Gop Size is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-g' expects an argument\n")); } break; case MSDK_CHAR('r'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->nGopRefDist)) { PrintHelp(strInput[0], MSDK_STRING("Ref Dist is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-r' expects an argument\n")); } break; case MSDK_CHAR('i'): if (++i < nArgNum) { msdk_opt_read(strInput[i], pParams->strSrcFile); if (MVC_ENABLED & pParams->MVC_flags) { pParams->srcFileBuff.push_back(strInput[i]); } } else { msdk_printf(MSDK_STRING("error: option '-i' expects an argument\n")); } break; case MSDK_CHAR('o'): if (++i < nArgNum) { pParams->dstFileBuff.push_back(strInput[i]); } else { msdk_printf(MSDK_STRING("error: option '-o' expects an argument\n")); } break; case MSDK_CHAR('q'): if (++i < nArgNum) { if (MFX_ERR_NONE != msdk_opt_read(strInput[i], pParams->nQuality)) { PrintHelp(strInput[0], MSDK_STRING("Quality is invalid")); return MFX_ERR_UNSUPPORTED; } } else { msdk_printf(MSDK_STRING("error: option '-q' expects an argument\n")); } break; case MSDK_CHAR('p'): if (++i < nArgNum) { if (MFX_ERR_NONE == ConvertStringToGuid(strInput[i], pParams->pluginParams.pluginGuid)) { pParams->pluginParams.type = MFX_PLUGINLOAD_TYPE_GUID; } else { PrintHelp(strInput[0], MSDK_STRING("Unknown options")); } } else { msdk_printf(MSDK_STRING("error: option '-p' expects an argument\n")); } break; case MSDK_CHAR('?'): PrintHelp(strInput[0], NULL); return MFX_ERR_UNSUPPORTED; default: PrintHelp(strInput[0], MSDK_STRING("Unknown options")); } } } #if defined (ENABLE_V4L2_SUPPORT) if (pParams->isV4L2InputEnabled) { if (0 == msdk_strlen(pParams->DeviceName)) { PrintHelp(strInput[0], MSDK_STRING("Device Name not found")); return MFX_ERR_UNSUPPORTED; } if ((pParams->MipiPort > -1 && pParams->MipiMode == NONE) || (pParams->MipiPort < 0 && pParams->MipiMode != NONE)) { PrintHelp(strInput[0], MSDK_STRING("Invalid Mipi Configuration\n")); return MFX_ERR_UNSUPPORTED; } if (pParams->v4l2Format == NO_FORMAT) { PrintHelp(strInput[0], MSDK_STRING("NO input v4l2 format\n")); return MFX_ERR_UNSUPPORTED; } } #endif // check if all mandatory parameters were set if (0 == msdk_strlen(pParams->strSrcFile) && !pParams->isV4L2InputEnabled) { PrintHelp(strInput[0], MSDK_STRING("Source file name not found")); return MFX_ERR_UNSUPPORTED; }; if (pParams->dstFileBuff.empty()) { PrintHelp(strInput[0], MSDK_STRING("Destination file name not found")); return MFX_ERR_UNSUPPORTED; }; if (0 == pParams->nWidth || 0 == pParams->nHeight) { PrintHelp(strInput[0], MSDK_STRING("-w, -h must be specified")); return MFX_ERR_UNSUPPORTED; } if (MFX_CODEC_MPEG2 != pParams->CodecId && MFX_CODEC_AVC != pParams->CodecId && MFX_CODEC_JPEG != pParams->CodecId && MFX_CODEC_VP8 != pParams->CodecId && MFX_CODEC_HEVC != pParams->CodecId) { PrintHelp(strInput[0], MSDK_STRING("Unknown codec")); return MFX_ERR_UNSUPPORTED; } if (MFX_CODEC_JPEG != pParams->CodecId && pParams->ColorFormat == MFX_FOURCC_YUY2 && !pParams->isV4L2InputEnabled) { PrintHelp(strInput[0], MSDK_STRING("-yuy2 option is supported only for JPEG encoder")); return MFX_ERR_UNSUPPORTED; } // check parameters validity if (pParams->nRotationAngle != 0 && pParams->nRotationAngle != 180) { PrintHelp(strInput[0], MSDK_STRING("Angles other than 180 degrees are not supported.")); return MFX_ERR_UNSUPPORTED; // other than 180 are not supported } if (pParams->nQuality && (MFX_CODEC_JPEG != pParams->CodecId)) { PrintHelp(strInput[0], MSDK_STRING("-q option is supported only for JPEG encoder")); return MFX_ERR_UNSUPPORTED; } if ((pParams->nTargetUsage || pParams->nBitRate) && (MFX_CODEC_JPEG == pParams->CodecId)) { PrintHelp(strInput[0], MSDK_STRING("-u and -b options are supported only for H.264, MPEG2 and MVC encoders. For JPEG encoder use -q")); return MFX_ERR_UNSUPPORTED; } // set default values for optional parameters that were not set or were set incorrectly mfxU32 nviews = (mfxU32)pParams->srcFileBuff.size(); if ((nviews <= 1) || (nviews > 2)) { if (!(MVC_ENABLED & pParams->MVC_flags)) { pParams->numViews = 1; } else { PrintHelp(strInput[0], MSDK_STRING("Only 2 views are supported right now in this sample.")); return MFX_ERR_UNSUPPORTED; } } else { pParams->numViews = nviews; } if (MFX_TARGETUSAGE_BEST_QUALITY != pParams->nTargetUsage && MFX_TARGETUSAGE_BEST_SPEED != pParams->nTargetUsage) { pParams->nTargetUsage = MFX_TARGETUSAGE_BALANCED; } if (pParams->dFrameRate <= 0) { pParams->dFrameRate = 30; } // if no destination picture width or height wasn't specified set it to the source picture size if (pParams->nDstWidth == 0) { pParams->nDstWidth = pParams->nWidth; } if (pParams->nDstHeight == 0) { pParams->nDstHeight = pParams->nHeight; } // calculate default bitrate based on the resolution (a parameter for encoder, so Dst resolution is used) if (pParams->nBitRate == 0) { pParams->nBitRate = CalculateDefaultBitrate(pParams->CodecId, pParams->nTargetUsage, pParams->nDstWidth, pParams->nDstHeight, pParams->dFrameRate); } // if nv12 option wasn't specified we expect input YUV file in YUV420 color format if (!pParams->ColorFormat) { pParams->ColorFormat = MFX_FOURCC_YV12; } if (!pParams->nPicStruct) { pParams->nPicStruct = MFX_PICSTRUCT_PROGRESSIVE; } if ((pParams->nRateControlMethod == MFX_RATECONTROL_LA) && (!pParams->bUseHWLib)) { PrintHelp(strInput[0], MSDK_STRING("Look ahead BRC is supported only with -hw option!")); return MFX_ERR_UNSUPPORTED; } if ((pParams->nMaxSliceSize) && (!pParams->bUseHWLib)) { PrintHelp(strInput[0], MSDK_STRING("MaxSliceSize option is supported only with -hw option!")); return MFX_ERR_UNSUPPORTED; } if ((pParams->nMaxSliceSize) && (pParams->nNumSlice)) { PrintHelp(strInput[0], MSDK_STRING("-mss and -num_slice options are not compatible!")); return MFX_ERR_UNSUPPORTED; } if ((pParams->nRateControlMethod == MFX_RATECONTROL_LA) && (pParams->CodecId != MFX_CODEC_AVC)) { PrintHelp(strInput[0], MSDK_STRING("Look ahead BRC is supported only with H.264 encoder!")); return MFX_ERR_UNSUPPORTED; } if ((pParams->nMaxSliceSize) && (pParams->CodecId != MFX_CODEC_AVC)) { PrintHelp(strInput[0], MSDK_STRING("MaxSliceSize option is supported only with H.264 encoder!")); return MFX_ERR_UNSUPPORTED; } if (pParams->nLADepth && (pParams->nLADepth < 10 || pParams->nLADepth > 100)) { if ((pParams->nLADepth != 1) || (!pParams->nMaxSliceSize)) { PrintHelp(strInput[0], MSDK_STRING("Unsupported value of -lad parameter, must be in range [10, 100] or 1 in case of -mss option!")); return MFX_ERR_UNSUPPORTED; } } // not all options are supported if rotate plugin is enabled if (pParams->nRotationAngle == 180 && ( MFX_PICSTRUCT_PROGRESSIVE != pParams->nPicStruct || pParams->nDstWidth != pParams->nWidth || pParams->nDstHeight != pParams->nHeight || MVC_ENABLED & pParams->MVC_flags || pParams->nRateControlMethod == MFX_RATECONTROL_LA)) { PrintHelp(strInput[0], MSDK_STRING("Some of the command line options are not supported with rotation plugin!")); return MFX_ERR_UNSUPPORTED; } if (pParams->nAsyncDepth == 0) { pParams->nAsyncDepth = 4; //set by default; } // Ignoring user-defined Async Depth for LA if (pParams->nMaxSliceSize) { pParams->nAsyncDepth = 1; } if (pParams->nRateControlMethod == 0) { pParams->nRateControlMethod = MFX_RATECONTROL_CBR; } if(pParams->UseRegionEncode) { if(pParams->CodecId != MFX_CODEC_HEVC) { msdk_printf(MSDK_STRING("Region encode option is compatible with h265(HEVC) encoder only.\nRegion encoding is disabled\n")); pParams->UseRegionEncode=false; } if (pParams->nWidth != pParams->nDstWidth || pParams->nHeight != pParams->nDstHeight || pParams->nRotationAngle!=0) { msdk_printf(MSDK_STRING("Region encode option is not compatible with VPP processing.\nRegion encoding is disabled\n")); pParams->UseRegionEncode=false; } } return MFX_ERR_NONE; }