Exemplo n.º 1
0
int add_vui(void *srcPtr, size_t srcSize, void *dstPtr, size_t dstSize, int color)
{
	sps_t sps;
	bs_t b;
	memset(&b, 0, sizeof(bs_t));

	bs_init(&b, srcPtr, srcSize);
	read_seq_parameter_set_rbsp(&sps, &b);

	sps.vui_parameters_present_flag = 1;

	{
		sps.vui.video_signal_type_present_flag = 1;
		{
			sps.vui.video_format = 5;
			sps.vui.video_full_range_flag = 1;
		}
		sps.vui.colour_description_present_flag = 1;
		{
			sps.vui.colour_primaries = 1;
		}
		sps.vui.transfer_characteristics = 1;
		sps.vui.matrix_coefficients = 1;
	}

	switch (color)
	{
	case BT601_LIMITED:
		sps.vui.colour_primaries = 5;
		sps.vui.video_full_range_flag = 0;
		sps.vui.transfer_characteristics = 6;
		sps.vui.matrix_coefficients = 5;
		break;
	case BT601_FULL:
		sps.vui.colour_primaries = 5;
		sps.vui.transfer_characteristics = 6;
		sps.vui.matrix_coefficients = 5;
		break;
	case BT601_FULL_YCbCr:
		sps.vui.colour_primaries = 5;
		sps.vui.transfer_characteristics = 8;
		sps.vui.matrix_coefficients = 5;
		break;
	case BT709_LIMITED:
		sps.vui.video_full_range_flag = 0;
		break;
	case BT709_FULL:
		break;
	case BT709_ALT1_LIMITED:
		sps.vui.video_full_range_flag = 0;
		break;
	default:
		sps.vui_parameters_present_flag = 0;
		break;
	}

	bs_init(&b, dstPtr, dstSize);
	write_seq_parameter_set_rbsp(&sps, &b);
	return bs_pos_byte(&b);
}
Exemplo n.º 2
0
uint8_t get_width_height(byte *nal_sps, uint32_t *size_nal_sps, i2ctx_video **ctxVideo) {
    uint32_t width, height;
    sps_t* sps = (sps_t*)malloc(sizeof(sps_t));
    uint8_t* rbsp_buf = (uint8_t*)malloc(*size_nal_sps);

    if (nal_to_rbsp(nal_sps, (int*)size_nal_sps, rbsp_buf, (int*)size_nal_sps) < 0){
        free(rbsp_buf);
        free(sps);
        return I2ERROR_SPS_PPS;
    }
    bs_t* b = bs_new(rbsp_buf, *size_nal_sps);

    if(read_seq_parameter_set_rbsp(sps,b) < 0){
        bs_free(b);
        free(rbsp_buf);
        free(sps);
        return I2ERROR_SPS_PPS;
    }

    width = (sps->pic_width_in_mbs_minus1 + 1) * 16;
    height = (2 - sps->frame_mbs_only_flag) * (sps->pic_height_in_map_units_minus1 + 1) * 16;

    if (sps->frame_cropping_flag){
        width -= (sps->frame_crop_left_offset*2 + sps->frame_crop_right_offset*2);
        height -= (sps->frame_crop_top_offset*2 + sps->frame_crop_bottom_offset*2);
    }

    (*ctxVideo)->width = width;
    (*ctxVideo)->height = height;
    bs_free(b);
    free(rbsp_buf);
    free(sps);

    return 0;
}