Skip to content

Commit

Permalink
tests: add MPEG2LG 576i tests with aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
philipnbbc committed Apr 22, 2024
1 parent 5e89ca5 commit 22c9c90
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 4 deletions.
22 changes: 19 additions & 3 deletions test/create_test_essence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ typedef enum
TYPE_RDD36_4444 = 56,
TYPE_16BIT_PCM_SAMPLES = 57,
TYPE_RDD36_422_ITU2020 = 58,
TYPE_END = 59,
TYPE_MPEG2LG_MP_ML_576I = 59,
TYPE_MPEG2LG_MP_ML_576I_4_3 = 60,
TYPE_END = 61,
} EssenceType;

typedef struct
Expand Down Expand Up @@ -430,13 +432,14 @@ static void write_d10(FILE *file, int type, unsigned int duration)
write_buffer(file, data, frame_size);
}

static void write_mpeg2lg(FILE *file, int type, unsigned int duration, bool low_delay, bool closed_gop)
static void write_mpeg2lg(FILE *file, int type, unsigned int duration, bool low_delay, bool closed_gop,
uint8_t aspect_ratio = MPEG_16_9_ASPECT_RATIO)
{
MPEGInfo mpeg_info;
memset(&mpeg_info, 0, sizeof(mpeg_info));
mpeg_info.is_progressive = false;
mpeg_info.low_delay = low_delay;
mpeg_info.aspect_ratio = MPEG_16_9_ASPECT_RATIO;
mpeg_info.aspect_ratio = aspect_ratio;

uint32_t i_frame_size, non_i_frame_size;
switch (type)
Expand Down Expand Up @@ -489,6 +492,15 @@ static void write_mpeg2lg(FILE *file, int type, unsigned int duration, bool low_
mpeg_info.v_size = 1080;
mpeg_info.bit_rate = (35 * 1000 * 1000) / 400;
break;
case TYPE_MPEG2LG_MP_ML_576I:
i_frame_size = 19500;
non_i_frame_size = 16500;
mpeg_info.profile_level = 0x72;
mpeg_info.chroma_format = 1;
mpeg_info.h_size = 720;
mpeg_info.v_size = 576;
mpeg_info.bit_rate = (10 * 1000 * 1000) / 400;
break;
case TYPE_MPEG2LG_MP_H14_1080I:
case TYPE_MPEG2LG_MP_H14_1080P:
default:
Expand Down Expand Up @@ -1129,11 +1141,15 @@ int main(int argc, const char **argv)
case TYPE_MPEG2LG_MP_HL_1080P_1440:
case TYPE_MPEG2LG_422P_HL_720P:
case TYPE_MPEG2LG_MP_HL_720P:
case TYPE_MPEG2LG_MP_ML_576I:
write_mpeg2lg(file, type, duration, true, false);
break;
case TYPE_AS10_MPEG2LG_422P_HL_1080I:
write_mpeg2lg(file, TYPE_MPEG2LG_422P_HL_1080I, duration, false, true);
break;
case TYPE_MPEG2LG_MP_ML_576I_4_3:
write_mpeg2lg(file, type, duration, true, false, MPEG_4_3_ASPECT_RATIO);
break;
case TYPE_UNC_SD:
case TYPE_UNC_HD_1080I:
case TYPE_UNC_HD_1080P:
Expand Down
1 change: 1 addition & 0 deletions test/mxf_op1a/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(tests
dv
indexfollows
mpeg2lg
mpeg2lg_576i
rdd36
soundonly
unc
Expand Down
1 change: 1 addition & 0 deletions test/mxf_op1a/mpeg2lg_mp_ml_576i_16by9.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9706391e131d72298ecc27da8984009a
1 change: 1 addition & 0 deletions test/mxf_op1a/mpeg2lg_mp_ml_576i_4by3.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fcfe27b756f6d6daed2aa0158c1f61a3
2 changes: 1 addition & 1 deletion test/mxf_op1a/test_mpeg2lg.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test creating an MXF OP1a file containing AVC video and 2 PCM tracks
# Test creating an MXF OP1a file containing MPEG2LG video and 2 PCM tracks

include("${TEST_SOURCE_DIR}/test_common.cmake")

Expand Down
84 changes: 84 additions & 0 deletions test/mxf_op1a/test_mpeg2lg_576i.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Test creating an MXF OP1a file containing MPEG2LG 576i video and 2 PCM tracks

include("${TEST_SOURCE_DIR}/../testing.cmake")


function(run_test test aspect_ratio duration)
if(TEST_MODE STREQUAL "check")
set(output_file test_${test}_${aspect_ratio}.mxf)
elseif(TEST_MODE STREQUAL "samples")
file(MAKE_DIRECTORY ${BMX_TEST_SAMPLES_DIR})

set(output_file ${BMX_TEST_SAMPLES_DIR}/test_${test}_${aspect_ratio}.mxf)
else()
set(output_file test_${test}${aspect_ratio}.mxf)
endif()

set(checksum_file ${test}_${aspect_ratio}.md5)

set(create_test_audio ${CREATE_TEST_ESSENCE}
-t 1
-d ${duration}
audio_${test}
)

set(create_command ${RAW2BMX}
--regtest
-t op1a
-y 10:11:12:13
--clip test
-o ${output_file}
--${test} video_${test}
-q 16 --locked true --pcm audio_${test}
-q 16 --locked true --pcm audio_${test}
)

run_test_a(
"${TEST_MODE}"
"${BMX_TEST_WITH_VALGRIND}"
"${create_test_video}"
"${create_test_audio}"
""
"${create_command}"
""
""
""
"${output_file}"
"${checksum_file}"
""
""
)
endfunction()

function(run_tests tests duration)
list(LENGTH tests len_tests)
math(EXPR max_index "(${len_tests} / 3) - 1")

foreach(index RANGE ${max_index})
math(EXPR test_index "${index} * 3")
list(GET tests ${test_index} test)

math(EXPR test_ess_type_index "${index} * 3 + 1")
list(GET tests ${test_ess_type_index} test_ess_type)

math(EXPR test_aspect_ratio_index "${index} * 3 + 2")
list(GET tests ${test_aspect_ratio_index} test_aspect_ratio)

set(create_test_video ${CREATE_TEST_ESSENCE}
-t ${test_ess_type}
-d ${duration}
video_${test}
)

run_test(${test} ${test_aspect_ratio} ${duration})
endforeach()
endfunction()


set(tests
mpeg2lg_mp_ml_576i 59 16by9
mpeg2lg_mp_ml_576i 60 4by3
)


run_tests("${tests}" 24)

0 comments on commit 22c9c90

Please sign in to comment.