Beispiel #1
0
int rdpgfx_decode_h264(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd)
{
	int status;
	wStream* s;
	RDPGFX_H264_BITMAP_STREAM h264;
	RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;

	s = Stream_New(cmd->data, cmd->length);

	if (!s)
		return -1;

	status = rdpgfx_read_h264_metablock(gfx, s, &(h264.meta));

	if (status < 0)
	{
		if (h264.meta.regionRects)
			free(h264.meta.regionRects);
		if (h264.meta.quantQualityVals)
			free(h264.meta.quantQualityVals);
		return -1;
	}

	h264.data = Stream_Pointer(s);
	h264.length = (UINT32) Stream_GetRemainingLength(s);

	Stream_Free(s, FALSE);

	cmd->extra = (void*) &h264;

	if (context && context->SurfaceCommand)
	{
		context->SurfaceCommand(context, cmd);
	}

	free(h264.meta.regionRects);
	free(h264.meta.quantQualityVals);

	return 1;
}
Beispiel #2
0
/**
 * Function description
 *
 * @return 0 on success, otherwise a Win32 error code
 */
static UINT rdpgfx_decode_AVC420(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd)
{
	UINT error;
	wStream* s;
	RDPGFX_AVC420_BITMAP_STREAM h264;
	RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;

	s = Stream_New(cmd->data, cmd->length);

	if (!s)
	{
		WLog_ERR(TAG, "Stream_New failed!");
		return CHANNEL_RC_NO_MEMORY;
	}

	if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.meta))))
	{
		WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
		return error;
	}

	h264.data = Stream_Pointer(s);
	h264.length = (UINT32) Stream_GetRemainingLength(s);

	Stream_Free(s, FALSE);

	cmd->extra = (void*) &h264;

	if (context)
	{
		IFCALLRET(context->SurfaceCommand, error, context, cmd);
		if (error)
			WLog_ERR(TAG, "context->SurfaceCommand failed with error %"PRIu32"", error);
	}

	free(h264.meta.regionRects);
	free(h264.meta.quantQualityVals);

	return error;
}
Beispiel #3
0
/**
 * Function description
 *
 * @return 0 on success, otherwise a Win32 error code
 */
static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd)
{
	UINT error;
	UINT32 tmp;
	size_t pos1, pos2;
	wStream* s;
	RDPGFX_AVC444_BITMAP_STREAM h264;
	RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;

	s = Stream_New(cmd->data, cmd->length);

	if (!s)
	{
		WLog_ERR(TAG, "Stream_New failed!");
		return CHANNEL_RC_NO_MEMORY;
	}

	if (Stream_GetRemainingLength(s) < 4)
		return ERROR_INVALID_DATA;

	Stream_Read_UINT32(s, tmp);
	h264.cbAvc420EncodedBitstream1 = tmp & 0x3FFFFFFFUL;
	h264.LC = (tmp >> 30UL) & 0x03UL;

	if (h264.LC == 0x03)
		return ERROR_INVALID_DATA;

	pos1 = Stream_GetPosition(s);
	if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.bitstream[0].meta))))
	{
		WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
		return error;
	}
	pos2 = Stream_GetPosition(s);

	h264.bitstream[0].data = Stream_Pointer(s);

	if (h264.LC == 0)
	{
		tmp = h264.cbAvc420EncodedBitstream1 - pos2 + pos1;
		if (Stream_GetRemainingLength(s) < tmp)
			return ERROR_INVALID_DATA;

		h264.bitstream[0].length = tmp;
		Stream_Seek(s, tmp);

		if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.bitstream[1].meta))))
		{
			WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
			return error;
		}

		h264.bitstream[1].data = Stream_Pointer(s);
		h264.bitstream[1].length = Stream_GetRemainingLength(s);
	}
	else
	{
		h264.bitstream[0].length = Stream_GetRemainingLength(s);
		memset(&h264.bitstream[1], 0, sizeof(h264.bitstream[1]));
	}

	Stream_Free(s, FALSE);

	cmd->extra = (void*) &h264;

	if (context)
	{
		IFCALLRET(context->SurfaceCommand, error, context, cmd);
		if (error)
			WLog_ERR(TAG, "context->SurfaceCommand failed with error %"PRIu32"", error);
	}

	free(h264.bitstream[0].meta.regionRects);
	free(h264.bitstream[0].meta.quantQualityVals);
	free(h264.bitstream[1].meta.regionRects);
	free(h264.bitstream[1].meta.quantQualityVals);

	return error;
}