Skip to content

Commit 9efa6d6

Browse files
authored
Merge pull request #61 from mpeg5/dev-CheckCfgFunction2XeveAPI
Moved check_conf function from xeve_app implementation to xeve API
2 parents 8acf832 + 41ddc54 commit 9efa6d6

File tree

5 files changed

+163
-89
lines changed

5 files changed

+163
-89
lines changed

app/CMakeLists.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ if(("${SET_PROF}" STREQUAL "MAIN"))
1010
add_executable (${EXE_NAME} ${ENC_SRC} ${ENC_INC} )
1111
include_directories( ${EXE_NAME} PUBLIC . .. ../inc ../src_base ../src_main ${BASE_SRC_PATH})
1212

13-
# Comment the following line for dynamic linking
14-
target_link_libraries (${EXE_NAME} xeve)
15-
16-
# Uncommet the following line for dynamic linking
17-
# target_link_libraries (${EXE_NAME} xeve_dynamic)
13+
if(XEVE_APP_STATIC_BUILD)
14+
target_link_libraries (${EXE_NAME} xeve)
15+
else()
16+
target_link_libraries (${EXE_NAME} xeve_dynamic)
17+
endif()
1818

1919
set_property(TARGET ${EXE_NAME} PROPERTY FOLDER "app")
2020
set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -38,11 +38,11 @@ if(("${SET_PROF}" STREQUAL "BASE"))
3838
add_executable (${EXE_NAME_BASE} ${ENC_SRC} ${ENC_INC} )
3939
include_directories( ${EXE_NAME_BASE} PUBLIC . .. ../inc ../src_base ../src_main ${BASE_SRC_PATH})
4040

41-
# Comment the following line for dynamic linking
42-
target_link_libraries (${EXE_NAME_BASE} xeveb)
43-
44-
# Uncommet the following line for dynamic linking
45-
# target_link_libraries (${EXE_NAME_BASE} xeveb_dynamic)
41+
if(XEVE_APP_STATIC_BUILD)
42+
target_link_libraries (${EXE_NAME_BASE} xeveb)
43+
else()
44+
target_link_libraries (${EXE_NAME_BASE} xeveb_dynamic)
45+
endif()
4646

4747
set_property(TARGET ${EXE_NAME_BASE} PROPERTY FOLDER "app")
4848
set_target_properties(${EXE_NAME_BASE} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

app/xeve_app.c

+1-79
Original file line numberDiff line numberDiff line change
@@ -122,84 +122,6 @@ static void print_usage(const char **argv)
122122
if(args) args->release(args);
123123
}
124124

125-
int check_conf(XEVE_CDSC* cdsc)
126-
{
127-
XEVE_PARAM * param;
128-
int ret = 0;
129-
int min_block_size = 4;
130-
param = &cdsc->param;
131-
132-
if(param->profile == 0)
133-
{
134-
if (param->tool_amvr == 1) { logerr("AMVR cannot be on in base profile\n"); ret = -1; }
135-
if (param->tool_mmvd == 1) { logerr("MMVD cannot be on in base profile\n"); ret = -1; }
136-
if (param->tool_affine == 1) { logerr("Affine cannot be on in base profile\n"); ret = -1; }
137-
if (param->tool_dmvr == 1) { logerr("DMVR cannot be on in base profile\n"); ret = -1; }
138-
if (param->tool_admvp == 1) { logerr("ADMVP cannot be on in base profile\n"); ret = -1; }
139-
if (param->tool_hmvp == 1) { logerr("HMVP cannot be on in base profile\n"); ret = -1; }
140-
if (param->tool_addb == 1) { logerr("ADDB cannot be on in base profile\n"); ret = -1; }
141-
if (param->tool_alf == 1) { logerr("ALF cannot be on in base profile\n"); ret = -1; }
142-
if (param->tool_htdf == 1) { logerr("HTDF cannot be on in base profile\n"); ret = -1; }
143-
if (param->btt == 1) { logerr("BTT cannot be on in base profile\n"); ret = -1; }
144-
if (param->suco == 1) { logerr("SUCO cannot be on in base profile\n"); ret = -1; }
145-
if (param->tool_eipd == 1) { logerr("EIPD cannot be on in base profile\n"); ret = -1; }
146-
if (param->tool_iqt == 1) { logerr("IQT cannot be on in base profile\n"); ret = -1; }
147-
if (param->tool_cm_init == 1) { logerr("CM_INIT cannot be on in base profile\n"); ret = -1; }
148-
if (param->tool_adcc == 1) { logerr("ADCC cannot be on in base profile\n"); ret = -1; }
149-
if (param->tool_ats == 1) { logerr("ATS_INTRA cannot be on in base profile\n"); ret = -1; }
150-
if (param->ibc_flag == 1) { logerr("IBC cannot be on in base profile\n"); ret = -1; }
151-
if (param->tool_rpl == 1) { logerr("RPL cannot be on in base profile\n"); ret = -1; }
152-
if (param->tool_pocs == 1) { logerr("POCS cannot be on in base profile\n"); ret = -1; }
153-
}
154-
else
155-
{
156-
if (param->tool_admvp == 0 && param->tool_affine == 1) { logerr("AFFINE cannot be on when ADMVP is off\n"); ret = -1; }
157-
if (param->tool_admvp == 0 && param->tool_amvr == 1) { logerr("AMVR cannot be on when ADMVP is off\n"); ret = -1; }
158-
if (param->tool_admvp == 0 && param->tool_dmvr == 1) { logerr("DMVR cannot be on when ADMVP is off\n"); ret = -1; }
159-
if (param->tool_admvp == 0 && param->tool_mmvd == 1) { logerr("MMVD cannot be on when ADMVP is off\n"); ret = -1; }
160-
if (param->tool_eipd == 0 && param->ibc_flag == 1) { logerr("IBC cannot be on when EIPD is off\n"); ret = -1; }
161-
if (param->tool_iqt == 0 && param->tool_ats == 1) { logerr("ATS cannot be on when IQT is off\n"); ret = -1; }
162-
if (param->tool_cm_init == 0 && param->tool_adcc == 1) { logerr("ADCC cannot be on when CM_INIT is off\n"); ret = -1; }
163-
}
164-
165-
if (param->btt == 1)
166-
{
167-
if (param->framework_cb_max && param->framework_cb_max < 5) { logerr("Maximun Coding Block size cannot be smaller than 5\n"); ret = -1; }
168-
if (param->framework_cb_max > 7) { logerr("Maximun Coding Block size cannot be greater than 7\n"); ret = -1; }
169-
if (param->framework_cb_min && param->framework_cb_min < 2) { logerr("Minimum Coding Block size cannot be smaller than 2\n"); ret = -1; }
170-
if ((param->framework_cb_max || param->framework_cb_min) &&
171-
param->framework_cb_min > param->framework_cb_max) { logerr("Minimum Coding Block size cannot be greater than Maximum coding Block size\n"); ret = -1; }
172-
if (param->framework_cu14_max > 6) { logerr("Maximun 1:4 Coding Block size cannot be greater than 6\n"); ret = -1; }
173-
if ((param->framework_cb_max || param->framework_cu14_max) &&
174-
param->framework_cu14_max > param->framework_cb_max) { logerr("Maximun 1:4 Coding Block size cannot be greater than Maximum coding Block size\n"); ret = -1; }
175-
if (param->framework_tris_max > 6) { logerr("Maximun Tri-split Block size be greater than 6\n"); ret = -1; }
176-
if ((param->framework_tris_max || param->framework_cb_max) &&
177-
param->framework_tris_max > param->framework_cb_max) { logerr("Maximun Tri-split Block size cannot be greater than Maximum coding Block size\n"); ret = -1; }
178-
if ((param->framework_tris_min || param->framework_cb_min) &&
179-
param->framework_tris_min < param->framework_cb_min + 2) { logerr("Maximun Tri-split Block size cannot be smaller than Minimum Coding Block size plus two\n"); ret = -1; }
180-
if(param->framework_cb_min) min_block_size = 1 << param->framework_cb_min;
181-
else min_block_size = 8;
182-
}
183-
184-
if (param->suco == 1)
185-
{
186-
if (param->framework_suco_max > 6) { logerr("Maximun SUCO size cannot be greater than 6\n"); ret = -1; }
187-
if (param->framework_cb_max && param->framework_suco_max > param->framework_cb_max) { logerr("Maximun SUCO size cannot be greater than Maximum coding Block size\n"); ret = -1; }
188-
if (param->framework_suco_min < 4) { logerr("Minimun SUCO size cannot be smaller than 4\n"); ret = -1; }
189-
if (param->framework_cb_min && param->framework_suco_min < param->framework_cb_min) { logerr("Minimun SUCO size cannot be smaller than Minimum coding Block size\n"); ret = -1; }
190-
if (param->framework_suco_min > param->framework_suco_max) { logerr("Minimum SUCO size cannot be greater than Maximum SUCO size\n"); ret = -1; }
191-
}
192-
193-
if (XEVE_CS_GET_FORMAT(param->cs) != XEVE_CF_YCBCR400)
194-
{
195-
int pic_m = 2;
196-
if ((param->w & (pic_m - 1)) != 0) { logerr("Current encoder does not support odd picture width\n"); ret = -1; }
197-
if ((param->h & (pic_m - 1)) != 0) { logerr("Current encoder does not support odd picture height\n"); ret = -1; }
198-
}
199-
200-
return ret;
201-
}
202-
203125
static int set_extra_config(XEVE id, ARGS_PARSER * args, XEVE_PARAM * param)
204126
{
205127
int ret, size, value;
@@ -1150,7 +1072,7 @@ int main(int argc, const char **argv)
11501072

11511073
cdsc.max_bs_buf_size = MAX_BS_BUF; /* maximum bitstream buffer size */
11521074

1153-
if (check_conf(&cdsc))
1075+
if (xeve_param_check(param))
11541076
{
11551077
logerr("invalid configuration\n");
11561078
ret = -1; goto ERR;

inc/xeve.h

+1
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ int XEVE_EXPORT xeve_encode(XEVE id, XEVE_BITB * bitb, XEVE_STAT * stat);
592592
int XEVE_EXPORT xeve_config(XEVE id, int cfg, void * buf, int * size);
593593
int XEVE_EXPORT xeve_param_default(XEVE_PARAM* param);
594594
int XEVE_EXPORT xeve_param_ppt(XEVE_PARAM* param, int profile, int preset, int tune);
595+
int XEVE_EXPORT xeve_param_check(const XEVE_PARAM* param);
595596

596597
#ifdef __cplusplus
597598
} /* extern "C" */

src_base/xeve.c

+76
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,79 @@ int xeve_param_ppt(XEVE_PARAM* param, int profile, int preset, int tune)
323323
}
324324
return xeve_param_apply_ppt_baseline(param, profile, preset, tune);
325325
}
326+
327+
int xeve_param_check(const XEVE_PARAM* param)
328+
{
329+
int ret = 0;
330+
int min_block_size = 4;
331+
332+
if(param->profile == 0)
333+
{
334+
if (param->tool_amvr == 1) { xeve_trace("AMVR cannot be on in base profile\n"); ret = -1; }
335+
if (param->tool_mmvd == 1) { xeve_trace("MMVD cannot be on in base profile\n"); ret = -1; }
336+
if (param->tool_affine == 1) { xeve_trace("Affine cannot be on in base profile\n"); ret = -1; }
337+
if (param->tool_dmvr == 1) { xeve_trace("DMVR cannot be on in base profile\n"); ret = -1; }
338+
if (param->tool_admvp == 1) { xeve_trace("ADMVP cannot be on in base profile\n"); ret = -1; }
339+
if (param->tool_hmvp == 1) { xeve_trace("HMVP cannot be on in base profile\n"); ret = -1; }
340+
if (param->tool_addb == 1) { xeve_trace("ADDB cannot be on in base profile\n"); ret = -1; }
341+
if (param->tool_alf == 1) { xeve_trace("ALF cannot be on in base profile\n"); ret = -1; }
342+
if (param->tool_htdf == 1) { xeve_trace("HTDF cannot be on in base profile\n"); ret = -1; }
343+
if (param->btt == 1) { xeve_trace("BTT cannot be on in base profile\n"); ret = -1; }
344+
if (param->suco == 1) { xeve_trace("SUCO cannot be on in base profile\n"); ret = -1; }
345+
if (param->tool_eipd == 1) { xeve_trace("EIPD cannot be on in base profile\n"); ret = -1; }
346+
if (param->tool_iqt == 1) { xeve_trace("IQT cannot be on in base profile\n"); ret = -1; }
347+
if (param->tool_cm_init == 1) { xeve_trace("CM_INIT cannot be on in base profile\n"); ret = -1; }
348+
if (param->tool_adcc == 1) { xeve_trace("ADCC cannot be on in base profile\n"); ret = -1; }
349+
if (param->tool_ats == 1) { xeve_trace("ATS_INTRA cannot be on in base profile\n"); ret = -1; }
350+
if (param->ibc_flag == 1) { xeve_trace("IBC cannot be on in base profile\n"); ret = -1; }
351+
if (param->tool_rpl == 1) { xeve_trace("RPL cannot be on in base profile\n"); ret = -1; }
352+
if (param->tool_pocs == 1) { xeve_trace("POCS cannot be on in base profile\n"); ret = -1; }
353+
}
354+
else
355+
{
356+
if (param->tool_admvp == 0 && param->tool_affine == 1) { xeve_trace("AFFINE cannot be on when ADMVP is off\n"); ret = -1; }
357+
if (param->tool_admvp == 0 && param->tool_amvr == 1) { xeve_trace("AMVR cannot be on when ADMVP is off\n"); ret = -1; }
358+
if (param->tool_admvp == 0 && param->tool_dmvr == 1) { xeve_trace("DMVR cannot be on when ADMVP is off\n"); ret = -1; }
359+
if (param->tool_admvp == 0 && param->tool_mmvd == 1) { xeve_trace("MMVD cannot be on when ADMVP is off\n"); ret = -1; }
360+
if (param->tool_eipd == 0 && param->ibc_flag == 1) { xeve_trace("IBC cannot be on when EIPD is off\n"); ret = -1; }
361+
if (param->tool_iqt == 0 && param->tool_ats == 1) { xeve_trace("ATS cannot be on when IQT is off\n"); ret = -1; }
362+
if (param->tool_cm_init == 0 && param->tool_adcc == 1) { xeve_trace("ADCC cannot be on when CM_INIT is off\n"); ret = -1; }
363+
}
364+
365+
if (param->btt == 1)
366+
{
367+
if (param->framework_cb_max && param->framework_cb_max < 5) { xeve_trace("Maximun Coding Block size cannot be smaller than 5\n"); ret = -1; }
368+
if (param->framework_cb_max > 7) { xeve_trace("Maximun Coding Block size cannot be greater than 7\n"); ret = -1; }
369+
if (param->framework_cb_min && param->framework_cb_min < 2) { xeve_trace("Minimum Coding Block size cannot be smaller than 2\n"); ret = -1; }
370+
if ((param->framework_cb_max || param->framework_cb_min) &&
371+
param->framework_cb_min > param->framework_cb_max) { xeve_trace("Minimum Coding Block size cannot be greater than Maximum coding Block size\n"); ret = -1; }
372+
if (param->framework_cu14_max > 6) { xeve_trace("Maximun 1:4 Coding Block size cannot be greater than 6\n"); ret = -1; }
373+
if ((param->framework_cb_max || param->framework_cu14_max) &&
374+
param->framework_cu14_max > param->framework_cb_max) { xeve_trace("Maximun 1:4 Coding Block size cannot be greater than Maximum coding Block size\n"); ret = -1; }
375+
if (param->framework_tris_max > 6) { xeve_trace("Maximun Tri-split Block size be greater than 6\n"); ret = -1; }
376+
if ((param->framework_tris_max || param->framework_cb_max) &&
377+
param->framework_tris_max > param->framework_cb_max) { xeve_trace("Maximun Tri-split Block size cannot be greater than Maximum coding Block size\n"); ret = -1; }
378+
if ((param->framework_tris_min || param->framework_cb_min) &&
379+
param->framework_tris_min < param->framework_cb_min + 2) { xeve_trace("Maximun Tri-split Block size cannot be smaller than Minimum Coding Block size plus two\n"); ret = -1; }
380+
if(param->framework_cb_min) min_block_size = 1 << param->framework_cb_min;
381+
else min_block_size = 8;
382+
}
383+
384+
if (param->suco == 1)
385+
{
386+
if (param->framework_suco_max > 6) { xeve_trace("Maximun SUCO size cannot be greater than 6\n"); ret = -1; }
387+
if (param->framework_cb_max && param->framework_suco_max > param->framework_cb_max) { xeve_trace("Maximun SUCO size cannot be greater than Maximum coding Block size\n"); ret = -1; }
388+
if (param->framework_suco_min < 4) { xeve_trace("Minimun SUCO size cannot be smaller than 4\n"); ret = -1; }
389+
if (param->framework_cb_min && param->framework_suco_min < param->framework_cb_min) { xeve_trace("Minimun SUCO size cannot be smaller than Minimum coding Block size\n"); ret = -1; }
390+
if (param->framework_suco_min > param->framework_suco_max) { xeve_trace("Minimum SUCO size cannot be greater than Maximum SUCO size\n"); ret = -1; }
391+
}
392+
393+
if (XEVE_CS_GET_FORMAT(param->cs) != XEVE_CF_YCBCR400)
394+
{
395+
int pic_m = 2;
396+
if ((param->w & (pic_m - 1)) != 0) { xeve_trace("Current encoder does not support odd picture width\n"); ret = -1; }
397+
if ((param->h & (pic_m - 1)) != 0) { xeve_trace("Current encoder does not support odd picture height\n"); ret = -1; }
398+
}
399+
400+
return ret;
401+
}

0 commit comments

Comments
 (0)