# @name TI Encoder Tests
# @desc Test functionality of Texas Instruments' video encoders
# @requires tienc
# @setup_requires

TIDEC_S_FUNC_GST_ENCODE_PEDESTRIAN_1080P_NV12_H264 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 9de6518d4bfa677497d97a626c143786 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_VTC1NW_8BIT_352x288_NV12_H264 source 'ti_codecs.sh'; get_media encoder vtc1nw_8bit_352x288.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/vtc1nw_8bit_352x288.yuv blocksize=152064 ! video/x-raw, width=352, height=288, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep d4b13aa609c786e2644c520553bcf6d2 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_OLDTOWNCROSS_1280x720_NV12_H264 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv blocksize=1382400 ! video/x-raw, width=1280, height=720, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 644391bf14ef07d8e1cb17d893f3dbb7 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_CONCERT_640x480_NV12_H264 source 'ti_codecs.sh'; get_media encoder concert_640x480_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/concert_640x480_nv12.yuv blocksize=460800 ! video/x-raw, width=640, height=480, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 5de684e0de617dba0c7c488b831c4fa4 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_PEDESTRIAN_1080P_NV12_H265 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 1617b3832f18897a697470da3907ad0e || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_VTC1NW_8BIT_352x288_NV12_H265 source 'ti_codecs.sh'; get_media encoder vtc1nw_8bit_352x288.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/vtc1nw_8bit_352x288.yuv blocksize=152064 ! video/x-raw, width=352, height=288, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep d9410da089065a5a293e54ccc13c71c3 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_OLDTOWNCROSS_1280x720_NV12_H265 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv blocksize=1382400 ! video/x-raw, width=1280, height=720, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 77ae694038dab2753f33e0948952f2b3 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_CONCERT_640x480_NV12_H265 source 'ti_codecs.sh'; get_media encoder concert_640x480_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/concert_640x480_nv12.yuv blocksize=460800 ! video/x-raw, width=640, height=480, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep c19e9e2ab12e9767e2c0944addd5ade1 || die "decoded file does not match expected md5sum"; remove_media encoder

# Section defined for YUV422 packed formats

TIDEC_S_FUNC_GST_ENCODE_VIDEOTESTSRC_1080P_YUYV_H264 source 'ti_codecs.sh'; F=$(mktemp); gst-launch-1.0 videotestsrc is-live=true num-buffers=150 ! video/x-raw,format=YUY2,width=1920,height=1080,framerate=30/1 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep ad9e84ff6dd1223e68e4b43f561c85eb || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_VIDEOTESTSRC_1080P_YUYV_H265 source 'ti_codecs.sh'; F=$(mktemp); gst-launch-1.0 videotestsrc is-live=true num-buffers=150 ! video/x-raw,format=YUY2,width=1920,height=1080,framerate=30/1 ! v4l2h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep f8a751c1b113dccc0a55577a7d0aab06 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_VIDEOTESTSRC_1080P_YVYU_H264 source 'ti_codecs.sh'; F=$(mktemp); gst-launch-1.0 videotestsrc is-live=true num-buffers=150 ! video/x-raw,format=YVYU,width=1920,height=1080,framerate=30/1 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep ad9e84ff6dd1223e68e4b43f561c85eb || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_VIDEOTESTSRC_1080P_YVYU_H265 source 'ti_codecs.sh'; F=$(mktemp); gst-launch-1.0 videotestsrc is-live=true num-buffers=150 ! video/x-raw,format=YVYU,width=1920,height=1080,framerate=30/1 ! v4l2h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep f8a751c1b113dccc0a55577a7d0aab06 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_VIDEOTESTSRC_1080P_UYVY_H264 source 'ti_codecs.sh'; F=$(mktemp); gst-launch-1.0 videotestsrc is-live=true num-buffers=150 ! video/x-raw,format=UYVY,width=1920,height=1080,framerate=30/1 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep ad9e84ff6dd1223e68e4b43f561c85eb || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_VIDEOTESTSRC_1080P_UYVY_H265 source 'ti_codecs.sh'; F=$(mktemp); gst-launch-1.0 videotestsrc is-live=true num-buffers=150 ! video/x-raw,format=UYVY,width=1920,height=1080,framerate=30/1 ! v4l2h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep f8a751c1b113dccc0a55577a7d0aab06 || die "decoded file does not match expected md5sum"; remove_media encoder

# Section dedicated to special controls added to Wave5 Encoder

TIDEC_S_FUNC_GST_ENCODE_VIDEOTESTSRC_1080P_BG_ALGO_H265 source 'ti_codecs.sh'; F=$(mktemp); gst-launch-1.0 videotestsrc is-live=true num-buffers=150 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! v4l2h265enc extra-controls="controls,frame_level_rate_control_enable=1,video_bitrate=500000000,hevc_minimum_qp_value=10,hevc_maximum_qp_value=30" ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep a7821780691bc0ac11b57f366651e14b || die "decoded file does not match expected md5sum"; remove_media encoder

# Section dedicated to AHP Specific Second Instance

TIDEC_S_AHP_FUNC_GST_ENCODE_PEDESTRIAN_1080P_NV12_H264 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2video3h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 9de6518d4bfa677497d97a626c143786 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_AHP_FUNC_GST_ENCODE_VTC1NW_8BIT_352x288_NV12_H264 source 'ti_codecs.sh'; get_media encoder vtc1nw_8bit_352x288.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/vtc1nw_8bit_352x288.yuv blocksize=152064 ! video/x-raw, width=352, height=288, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2video3h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep d4b13aa609c786e2644c520553bcf6d2 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_AHP_FUNC_GST_ENCODE_OLDTOWNCROSS_1280x720_NV12_H264 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv blocksize=1382400 ! video/x-raw, width=1280, height=720, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2video3h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 88ad55982ff08fab1d5229d51bcf5099 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_AHP_FUNC_GST_ENCODE_CONCERT_640x480_NV12_H264 source 'ti_codecs.sh'; get_media encoder concert_640x480_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/concert_640x480_nv12.yuv blocksize=460800 ! video/x-raw, width=640, height=480, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2video3h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 5de684e0de617dba0c7c488b831c4fa4 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_AHP_FUNC_GST_ENCODE_PEDESTRIAN_1080P_NV12_H265 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2video3h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 1617b3832f18897a697470da3907ad0e || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_AHP_FUNC_GST_ENCODE_VTC1NW_8BIT_352x288_NV12_H265 source 'ti_codecs.sh'; get_media encoder vtc1nw_8bit_352x288.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/vtc1nw_8bit_352x288.yuv blocksize=152064 ! video/x-raw, width=352, height=288, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2video3h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep d9410da089065a5a293e54ccc13c71c3 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_AHP_FUNC_GST_ENCODE_OLDTOWNCROSS_1280x720_NV12_H265 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv blocksize=1382400 ! video/x-raw, width=1280, height=720, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2video3h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 77ae694038dab2753f33e0948952f2b3 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_AHP_FUNC_GST_ENCODE_CONCERT_640x480_NV12_H265 source 'ti_codecs.sh'; get_media encoder concert_640x480_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/concert_640x480_nv12.yuv blocksize=460800 ! video/x-raw, width=640, height=480, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2video3h265enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep c19e9e2ab12e9767e2c0944addd5ade1 || die "decoded file does not match expected md5sum"; remove_media encoder

# Memory Consumption Cases

TIENC_S_FUNC_MEM_CONSUMPTION_ENCODE_VIDEOTESTSRC_H264 source 'ti_codecs.sh'; F=$(mktemp); get_pipe_mem_consumption "videotestsrc is-live=true num-buffers=600 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! v4l2h264enc ! fakesink" "$F" || die "Encoder operation not working correctly"; Mem=`(cat $F | grep -E '^[0-9]+$') && Mem=$((Mem)) && [ $Mem -lt 40000 ]` || die "Mem consumption is too high"; echo "Mem consumption is $Mem END"; remove_media encoder

TIENC_S_FUNC_MEM_CONSUMPTION_ENCODE_VIDEOTESTSRC_H265 source 'ti_codecs.sh'; F=$(mktemp); get_pipe_mem_consumption "videotestsrc is-live=true num-buffers=600 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! v4l2h265enc ! fakesink" "$F" || die "Encoder operation not working correctly"; Mem=`(cat $F | grep -E '^[0-9]+$') && Mem=$((Mem)) && [ $Mem -lt 40000 ]` || die "Mem consumption is too high"; echo "Mem consumption is $Mem END"; remove_media encoder

# CPU Utilization Cases

TIENC_S_FUNC_CPU_UTILIZATION_ENCODE source 'ti_codecs.sh'; F=$(mktemp); get_pipe_cpu_utilization "videotestsrc is-live=true num-buffers=600 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! v4l2h264enc ! fakesink sync=true" "$F"|| die "Encoder operation not working correctly"; CPU=`(cat $F | grep -E '^[0-9]+(\.[0-9]+)?$') && CPU=$((CPU)) && [ $CPU -lt 5 ]` || die "CPU utilization is too high"; echo "CPU utilization is $CPU END";  remove_media encoder

# Dynamic Parameter Cases

TIENC_S_FUNC_DYNAMIC_BITRATE_ENCODE_H264 source 'ti_codecs.sh'; F=$(mktemp); Log=$(mktemp); gst-validate-1.0  --set-scenario=/opt/ltp/runtest/ddt/bitrate.scenario videotestsrc is-live=true do-timestamp=true num-buffers=300 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h265enc extra-controls="enc,frame_level_rate_control=1,video_bitrate=100000" ! h265parse ! qtmux ! filesink location=$F > $Log || die "Encode operation did not complete successfully"; cat $Log | grep "Test PASSED" || die "Dynamic Bitrate Test Failed"; remove_media encoder

TIENC_S_FUNC_DYNAMIC_I_FRAME_ENCODE_H264 source 'ti_codecs.sh'; F=$(mktemp); Log=$(mktemp); gst-validate-1.0  --set-scenario=/opt/ltp/runtest/ddt/force_i_frame.scenario videotestsrc is-live=true do-timestamp=true num-buffers=300 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc extra-controls="enc,prepend_sps_and_pps_to_idr=1" ! h264parse ! qtmux ! filesink location=$F > $Log || die "Encode operation did not complete successfully"; cat $Log | grep "Test PASSED" || die "Dynamic I-frame did not set properly"; remove_media encoder

# DevFreq Cases

TIENC_S_FUNC_LOWER_FREQ_ENCODE_H264 source 'ti_codecs.sh'; echo 200000000 > /sys/class/devfreq/30210000.video-codec/userspace/set_freq; k3conf dump clock 204 | grep 200000000 || die "Devfreq not set properly"; gst-launch-1.0 videotestsrc num-buffers=200 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1,interlace-mode=progressive,colorimetry=bt601 ! v4l2h264enc ! fakesink || die "Encode operation did not complete successfully"; remove_media encoder

TIENC_S_FUNC_LOWER_MID_FREQ_ENCODE_H264 source 'ti_codecs.sh'; echo 400000000 > /sys/class/devfreq/30210000.video-codec/userspace/set_freq; k3conf dump clock 204 | grep 400000000 || die "Devfreq not set properly"; gst-launch-1.0 videotestsrc num-buffers=200 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1,interlace-mode=progressive,colorimetry=bt601 ! v4l2h264enc ! fakesink || die "Encode operation did not complete successfully"; remove_media encoder

#Multistream testcase

TIDEC_S_FUNC_GST_ENCODE_MULTISTREAM_PEDESTRIAN_1080P_NV12_H264 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 num-buffers=30 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 num-buffers=30 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 num-buffers=30 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 num-buffers=30 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 num-buffers=30 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 num-buffers=30 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 num-buffers=30 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 9de6518d4bfa677497d97a626c143786 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_MULTISTREAM_OLDTOWNCROSS_1280x720_NV12_H264 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv blocksize=1382400 ! video/x-raw, width=1280, height=720, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F filesrc location=/usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv blocksize=1382400 ! video/x-raw, width=1280, height=720, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 9385bd1c404f65c9a8e0e3bc33291c13 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_MULTISTREAM_TWO_CHANNEL_PEDESTRIAN_1080P_NV12_H264 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep b70d6b68f3f442c1817447fce560080c || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_MULTISTREAM_JELLYFISH_1080P_NV12_H264 source 'ti_codecs.sh'; get_media encoder jellyfish_59frm_1920x1080_nv12.yuv; insert_video_modules; gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/jellyfish_59frm_1920x1080_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=jellyfish_59frm_1920x1080_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=jellyfish_59frm_1920x1080_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=jellyfish_59frm_1920x1080_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=jellyfish_59frm_1920x1080_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=jellyfish_59frm_1920x1080_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=jellyfish_59frm_1920x1080_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink filesrc location=jellyfish_59frm_1920x1080_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! fakesink || die "Decode operation did not complete successfully"; remove_media encoder

TIENC_S_FUNC_GST_ENCODE_MULTISTREAM_VIDEO_TEST_SRC_H264 source 'ti_codecs.sh'; gst-launch-1.0 videotestsrc is-live=true do-timestamp=true num-buffers=1000 ! video/x-raw, format=NV12, width=1920, height=1080 ! tee name=t t. ! queue ! v4l2h264enc capture-io-mode=2 extra-controls="controls,video_gop_size=30,video_bitrate=10000000,h264_profile=0;" ! filesink location=/tmp/test1.h264 t. ! queue ! v4l2h264enc capture-io-mode=2 extra-controls="controls,video_gop_size=30,video_bitrate=10000000,h264_profile=0;" ! filesink location=/tmp/test2.h264 || dies "Decode operation did not complete successfully"

TIENC_S_FUNC_GST_ENCODE_MULTISTREAM_VIDEO_TEST_SRC_4K_H264 source 'ti_codecs.sh'; gst-launch-1.0 videotestsrc is-live=true do-timestamp=true num-buffers=1000 ! video/x-raw, format=NV12, width=3840, height=2160 ! tee name=t t. ! queue ! v4l2h264enc ! fakesink t. ! queue ! v4l2h264enc ! fakesink || dies "Decode operation did not complete successfully"

# Placeholder for AEP/AHP Cases because of checksum mismatch between J7ES Platform

TIDEC_S_FUNC_GST_ENCODE_PEDESTRIAN_AEP_1080P_NV12_H264 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 9de6518d4bfa677497d97a626c143786 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_VTC1NW_8BIT_AEP_352x288_NV12_H264 source 'ti_codecs.sh'; get_media encoder vtc1nw_8bit_352x288.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/vtc1nw_8bit_352x288.yuv blocksize=152064 ! video/x-raw, width=352, height=288, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep d4b13aa609c786e2644c520553bcf6d2 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_OLDTOWNCROSS_AEP_1280x720_NV12_H264 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv blocksize=1382400 ! video/x-raw, width=1280, height=720, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 644391bf14ef07d8e1cb17d893f3dbb7 || die "decoded file does not match expected md5sum"; remove_media encoder

TIDEC_S_FUNC_GST_ENCODE_CONCERT_AEP_640x480_NV12_H264 source 'ti_codecs.sh'; get_media encoder concert_640x480_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/concert_640x480_nv12.yuv blocksize=460800 ! video/x-raw, width=640, height=480, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Decode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 5de684e0de617dba0c7c488b831c4fa4 || die "decoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_GST_ENCODE_PEDESTRIAN_AEP_1080P_NV12_H264_GOP_30 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc extra-controls="controls, video_gop_size=30" ! filesink location=$F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep f25b67604ea5f569a5de8f6bcfa553ed || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_GST_ENCODE_PEDESTRIAN_AEP_1080P_NV12_H264_GOP_10 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc extra-controls="controls, video_gop_size=10" ! filesink location=$F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 1075907bc1e51bc9da86cf9fce04375f || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_GST_ENCODE_PEDESTRIAN_AEP_1080P_NV12_H264_CBR source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc extra-controls="controls, video_bitrate=100000, video_bitrate_mode=1, frame_level_rate_control_enable=1" ! filesink location=$F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 6d117aa2fccbd95dd1303936d3d96514 || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_GST_ENCODE_PEDESTRIAN_AEP_1080P_NV12_H264_VBR source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv blocksize=3110400 ! video/x-raw, width=1920, height=1080, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc extra-controls="controls, video_bitrate=100000, video_bitrate_mode=0, vbv_buffer_size=3000, frame_level_rate_control_enable=1" ! filesink location=$F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep e93d8015c48cf68f019f7b47eda5341d || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_GST_ENCODE_CONSTRAINED_BASELINE_PROFILE source 'ti_codecs.sh'; insert_video_modules; F=$(mktemp); gst-launch-1.0 videotestsrc is-live=true num-buffers=500 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! v4l2h264enc extra-controls="s,h264_profile=1,h264_level=11" ! 'video/x-h264,level=(string)4,profile=constrained-baseline' ! filesink location=$F || die "Encode operation did not complete successfully"; remove_media encoder

# IMG Cases

TIENC_S_FUNC_ENCODE_VTC1NW_8BIT_352x288_NV12_H264 source 'ti_codecs.sh'; get_media encoder vtc1nw_8bit_352x288.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/vtc1nw_8bit_352x288.yuv blocksize=152064 ! video/x-raw, width=352, height=288, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 19ca43e90e2ea69ac4a019f2fb95d1cb || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_ENCODE_OLDTOWNCROSS_1280x720_NV12_H264 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv blocksize=1382400 ! video/x-raw, width=1280, height=720, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep c20ad661b1e1e2a44432ef9aa9f90aa8 || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_ENCODE_CONCERT_640x480_NV12_H264 source 'ti_codecs.sh'; get_media encoder concert_640x480_nv12.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/concert_640x480_nv12.yuv blocksize=460800 ! video/x-raw, width=640, height=480, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 91a629894e992aab2192388f22ba956f || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_ENCODE_AIRSHOW_P176x144_NV12_QCIF_H264 source 'ti_codecs.sh'; get_media encoder airshow_p176x144_nv12_qcif.yuv; insert_video_modules; F=$(mktemp); gst-launch-1.0 filesrc location=/usr/share/ti/tienc-encode/airshow_p176x144_nv12_qcif.yuv blocksize=38016 ! video/x-raw, width=176, height=144, framerate=30/1, format=NV12, interlace-mode=progressive, colorimetry=bt601 ! v4l2h264enc ! filesink location=$F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep 973bc60dbdf5418218ca785cc6c33b19 || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_ENCODE_VIDEOTESTSRC_ERROR_CASE source 'ti_codecs.sh'; insert_video_modules; gst-launch-1.0 videotestsrc do-timestamp=true num-buffers=100 ! video/x-raw, format="xRGB", width=1920, height=1080, framerate=30/1 ! v4l2h264enc ! fakesink || die "Encode operation did not complete successfully";

# FFMPEG ENCODE CASES

TIENC_S_FUNC_FFMPEG_ENCODE_PEDESTRIAN_NV12_H264 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; F=$(mktemp); ffmpeg -f rawvideo -pix_fmt yuv420p -s 1920x1080 -r 30 -i /usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv -vf "pad=width=1920:height=1088:x=0:y=0:color=black" -c:v h264_v4l2m2m -f h264 $F -y -nostdin || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}); echo $MD5 | grep 213dc7cc61ea65fffd16becdeb838d03 || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_FFMPEG_ENCODE_PEDESTRIAN_NV12_H265 source 'ti_codecs.sh'; get_media encoder pedestrain_1080p_nv12.yuv; F=$(mktemp); ffmpeg -f rawvideo -pix_fmt yuv420p -s 1920x1080 -r 30 -i /usr/share/ti/tienc-encode/pedestrain_1080p_nv12.yuv -vf "pad=width=1920:height=1088:x=0:y=0:color=black" -c:v hevc_v4l2m2m -f hevc $F -y -nostdin || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}); echo $MD5 | grep b45ec5630c8ef9739c098ad5959d73e6 || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_FFMPEG_ENCODE_OLDTOWN_CROSS_H264 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; F=$(mktemp); ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1280x720 -r 30 -i  /usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv -c:v h264_v4l2m2m -f h264 $F -y -nostdin || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}); echo $MD5 | grep e9ce27fcc5890145a88a54cdfd65cfee || die "encoded file does not match expected md5sum"; remove_media encoder

TIENC_S_FUNC_FFMPEG_ENCODE_OLDTOWN_CROSS_H265 source 'ti_codecs.sh'; get_media encoder oldtowncross_1280x720_nv12.yuv; F=$(mktemp); ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1280x720 -r 30 -i  /usr/share/ti/tienc-encode/oldtowncross_1280x720_nv12.yuv -c:v hevc_v4l2m2m -f hevc $F -y -nostdin || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}); echo $MD5 | grep  f1d6963a2cde990cf089a26d5234addd || die "encoded file does not match expected md5sum"; remove_media encoder

#Place holders for rgba format
#TIENC_S_FUNC_ENCODE_AIRSHOW_P176x144_RGBA_QCIF_H264 source 'ti_codecs.sh'; get_media encoder; F=$(mktemp); run_tienc_encode -i /usr/share/ti/tienc-encode/airshow_p176x144_rgba_qcif.rgb -w 176 -h 144 -f RGBA -c H264 -o $F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep xxxx || die "encoded file does not match expected md5sum"

#TIENC_S_FUNC_ENCODE_AUD_MW_QCIF_RGBA_H264 source 'ti_codecs.sh'; get_media encoder; F=$(mktemp); run_tienc_encode -i /usr/share/ti/tienc-encode/aud_mw_qcif_rgba.rgb -w 176 -h 144 -f RGBA -c H264 -o $F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep xxxx || die "encoded file does not match expected md5sum"

#TIENC_S_FUNC_ENCODE_CONCERT_640x480_RGBA_H264 source 'ti_codecs.sh'; get_media encoder; F=$(mktemp); run_tienc_encode -i /usr/share/ti/tienc-encode/concert_640x480_rgba.rgb -w 640 -h 480 -f RGBA -c H264 -o $F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep xxxx || die "encoded file does not match expected md5sum"

#TIENC_S_FUNC_ENCODE_OLDTOWNCROSS_1280x720_RGBA_H264 source 'ti_codecs.sh'; get_media encoder; F=$(mktemp); run_tienc_encode -i /usr/share/ti/tienc-encode/oldtowncross_1280x720_rgba.rgb -w 1280 -h 720 -f RGBA -c H264 -o $F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep xxxx || die "encoded file does not match expected md5sum"

#TIENC_S_FUNC_ENCODE_PEDESTRIAN_1080P_RGBA_H264 source 'ti_codecs.sh'; get_media encoder; F=$(mktemp); run_tienc_encode -i /usr/share/ti/tienc-encode/pedestrain_1080p_rgba.rgb -w 1920 -h 1080 -f RGBA -c H264 -o $F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep xxxx || die "encoded file does not match expected md5sum"

#TIENC_S_FUNC_ENCODE_VTC1NW_8BIT_352x288_RGBA_H264 source 'ti_codecs.sh'; get_media encoder; F=$(mktemp); run_tienc_encode -i /usr/share/ti/tienc-encode/vtc1nw_8bit_352x288.rgb -w 352 -h 288 -f RGBA -c H264 -o $F || die "Encode operation did not complete successfully"; MD5=$(md5sum ${F}) ; echo $MD5 | grep xxxx || die "encoded file does not match expected md5sum"
