s32 gf_media_hevc_read_pps(char *data, u32 size, HEVCState *hevc)
{
	GF_BitStream *bs;
	char *data_without_emulation_bytes = NULL;
	u32 data_without_emulation_bytes_size = 0;
	s32 pps_id = -1;

	/*still contains emulation bytes*/
	data_without_emulation_bytes_size = avc_emulation_bytes_remove_count(data, size);
	if (!data_without_emulation_bytes_size) {
		bs = gf_bs_new(data, size, GF_BITSTREAM_READ);
	} else {
		data_without_emulation_bytes = gf_malloc(size*sizeof(char));
		data_without_emulation_bytes_size = avc_remove_emulation_bytes(data, data_without_emulation_bytes, size);
		bs = gf_bs_new(data_without_emulation_bytes, data_without_emulation_bytes_size, GF_BITSTREAM_READ);
	}
	if (!bs) goto exit;

	if (! hevc_parse_nal_header(bs, NULL, NULL, NULL)) goto exit;

	pps_id = gf_media_hevc_read_pps_bs(bs, hevc);

exit:
	if (bs) gf_bs_del(bs);
	if (data_without_emulation_bytes) gf_free(data_without_emulation_bytes);
	return pps_id;
}
s32 gf_media_hevc_read_pps(char *data, u32 size, HEVCState *hevc)
{
	GF_BitStream *bs;
	char *data_without_emulation_bytes = NULL;
	u32 data_without_emulation_bytes_size = 0;
	s32 pps_id = -1;

	 
	data_without_emulation_bytes_size = avc_emulation_bytes_remove_count(data, size);
	if (!data_without_emulation_bytes_size) {
		bs = gf_bs_new(data, size, GF_BITSTREAM_READ);
	} else {
		data_without_emulation_bytes = gf_malloc(size*sizeof(char));
		data_without_emulation_bytes_size = avc_remove_emulation_bytes(data, data_without_emulation_bytes, size);
		bs = gf_bs_new(data_without_emulation_bytes, data_without_emulation_bytes_size, GF_BITSTREAM_READ);
	}
	if (!bs) goto exit;

	if (! hevc_parse_nal_header(bs, NULL, NULL, NULL)) goto exit;

	pps_id = gf_media_hevc_read_pps_bs(bs, hevc);

exit:
	if (bs) gf_bs_del(bs);
	if (data_without_emulation_bytes) gf_free(data_without_emulation_bytes);
	return pps_id;
}