Esempio n. 1
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)
Esempio n. 2
0
    if args.camera_seq_path is not None:
        CAMERA_SEQ_PATH = args.camera_seq_path

    if args.screen_seq_path is not None:
        SCREEN_SEQ_PATH = args.screen_seq_path

    if args.rc_mode:
        RC_MODE_LIST = [args.rc_mode, ]

    if args.max_range and args.max_range>1:
        MAX_BR_RATIO = args.max_range

    if args.time_window_camera and args.time_window_camera>1000:
        TIME_WINDOW = args.time_window_camera

    BitRateTable = CodecUtil.cBitRateTable(args.multi_layer_encoding is None)
    if args.multi_layer_encoding is None:
        camera_bit_rate_list = { 3600: [900, 1200, 1400, 1600], #1280x720
                          1800: [400, 600, 800, 1000], #960x540
                          900: [350, 450, 550, 650], #640x480~640x512
                          500: [300, 330, 360, 390],
                          225: [160,],#[160, 200, 250, 360],  #320x180~320x192~320x240
                          80: [80, 100, 140, 160],   #160x90~160x128
                        }

        batch_encoder_test(args.enc, 0, BitRateTable.get_camera_br_list(), 30)
        #batch_encoder_test(args.enc, 1, camera_bit_rate_list, 10, args.rc_mode)
    else:


        batch_encoder_test(args.enc, 0, BitRateTable.get_camera_br_list(), 30, True)