Example #1
0
def process_one_exe(exe_path, yuv_list, usage_type):
    TestPoint_dict = {}

    for one_yuv in yuv_list:
        for qp in [22, 27, 32, 37]:
            result = encode_one_yuv(exe_path, one_yuv, usage_type, qp)
            yuv_name = ((one_yuv.split(os.sep))[-1])
            if not TestPoint_dict.has_key(yuv_name):
                TestPoint_dict[yuv_name] = {}
            if not TestPoint_dict[yuv_name].has_key(qp):
                TestPoint_dict[yuv_name][qp] = {}
            TestPoint_dict[yuv_name][qp] = result

    write_testpoint_to_csv(exe_path, os.getcwd(), TestPoint_dict)

    return TestPoint_dict
Example #2
0
def process_one_exe(exe_path, yuv_list, usage_type):
    TestPoint_dict = {}

    for one_yuv in yuv_list:
        for qp in [22, ]:#27, 32, 37]:
            result = encode_one_yuv(exe_path, one_yuv, usage_type, qp)
            yuv_name = ((one_yuv.split(os.sep))[-1])
            if not TestPoint_dict.has_key(yuv_name):
                TestPoint_dict[yuv_name] = {}
            if not TestPoint_dict[yuv_name].has_key(qp):
                TestPoint_dict[yuv_name][qp] = {}
            TestPoint_dict[yuv_name][qp] = result


    write_testpoint_to_csv(exe_path, os.getcwd(), TestPoint_dict)

    return TestPoint_dict
Example #3
0
def process_compare_enc(yuv_list, downscale):
    TestPoint_dict = {}
    out_path = __init__.OUT_DATA_PATH

    BitRateTable = CodecUtil.cBitRateTable()

    for one_yuv in yuv_list:
        width, height, frame_rate = __init__.get_resolution_from_name(one_yuv)
        width_out = width / downscale
        height_out = height / downscale
        out_yuv_resolution = "%d" % width_out + "x" + "%d" % height_out

        jsvm_out = (
            out_path + os.sep + os.path.basename(one_yuv)[0:-4] + "_to_" + out_yuv_resolution + "_downConvert.yuv"
        )
        downsampler1_out = (
            out_path + os.sep + os.path.basename(one_yuv)[0:-4] + "_to_" + out_yuv_resolution + "_downsampler1.yuv"
        )
        downsampler2_out = (
            out_path + os.sep + os.path.basename(one_yuv)[0:-4] + "_to_" + out_yuv_resolution + "_downsampler2.yuv"
        )

        # encoder three yuv files
        qp = 36
        usage_type = 0
        result_path = os.path.abspath(__init__.OUT_DATA_PATH)
        jsvm_out = os.path.abspath(jsvm_out)
        downsampler1_out = os.path.abspath(downsampler1_out)
        downsampler2_out = os.path.abspath(downsampler2_out)

        current_path = os.getcwd()
        os.chdir(H264CODEC_PATH)
        for source in (jsvm_out, downsampler1_out, downsampler2_out):
            if RC_ON:
                bs_name, log_name, result_line = CodecUtil.openh264_encoder_rc(
                    source,
                    usage_type,
                    width_out,
                    height_out,
                    frame_rate,
                    BitRateTable.get_one_camera_point(width_out, height_out),
                    BitRateTable.get_one_camera_point(width_out, height_out) * 2,
                    0,
                    0,
                )
            else:
                bs_name, log_name, result_line = CodecUtil.openh264_encoder_qp(
                    source, usage_type, width_out, height_out, qp
                )

            bs_name = __init__.move_to_result_path(bs_name, result_path)
            log_name = __init__.move_to_result_path(log_name, result_path)

            rec_yuv = bs_name[0:-4] + "_dec.yuv"
            CodecUtil.decode(bs_name, rec_yuv)

            # encoder information
            frames, encode_time, fps = CodecUtil.openh264_encoder_log_all(log_name)

            # psnr ing
            frame_num, bitrate, psnr_y, psnr_u, psnr_v = CodecUtil.PSNRStaticd(
                width_out, height_out, source, rec_yuv, rec_yuv + ".log", bs_name, frame_rate
            )
            psnr2, ssim = 0, 0
            if VQMT_ON:
                psnr2, ssim = CodecUtil.Vqmt(width_out, height_out, source, rec_yuv, frame_num)

            file_size = os.path.getsize(bs_name)
            current_test_point = OneTestPoint(
                width_out,
                height_out,
                frame_rate,
                frames,
                qp,
                file_size,
                encode_time,
                fps,
                bitrate,
                psnr_y,
                psnr_u,
                psnr_v,
                psnr2,
                ssim,
            )

            if not TestPoint_dict.has_key(source):
                TestPoint_dict[source] = {}
            if not TestPoint_dict[source].has_key(qp):
                TestPoint_dict[source][qp] = {}
            TestPoint_dict[source][qp] = current_test_point
            os.remove(rec_yuv)

        for source in (downsampler1_out, downsampler2_out):
            bs_name, log_name, result_line = CodecUtil.openh264_encoder_qp(
                source, usage_type, width_out, height_out, qp
            )
            bs_name = __init__.move_to_result_path(bs_name, result_path)
            rec_yuv = bs_name[0:-4] + "_dec.yuv"
            CodecUtil.decode(bs_name, rec_yuv)
            frame_num, bitrate, psnr_y, psnr_u, psnr_v = CodecUtil.PSNRStaticd(width_out, height_out, jsvm_out, rec_yuv)
            psnr2, ssim = 0, 0
            if VQMT_ON:
                psnr2, ssim = CodecUtil.Vqmt(width_out, height_out, source, rec_yuv, frame_num)

            current_test_point = OneTestPoint(
                width_out, height_out, frame_rate, frame_num, qp, 0, 0, 0, bitrate, psnr_y, psnr_u, psnr_v, psnr2, ssim
            )

            current_name = str(os.path.basename(source) + "_comparejsvm")
            if not TestPoint_dict.has_key(current_name):
                TestPoint_dict[current_name] = {}
            if not TestPoint_dict[current_name].has_key(qp):
                TestPoint_dict[current_name][qp] = {}
            TestPoint_dict[current_name][qp] = current_test_point
            os.remove(rec_yuv)

        os.chdir(current_path)

    write_testpoint_to_csv(str("encCompare" + "_%d" % downscale), __init__.OUT_DATA_PATH, TestPoint_dict)