18#include <freerdp/codec/hevc.h>
19#include <freerdp/primitives.h>
20#include <freerdp/log.h>
21#include <freerdp/codec/region.h>
22#include <freerdp/codec/h264.h>
24#define TAG FREERDP_TAG("codec.hevc")
26struct S_FREERDP_HEVC_CONTEXT
30 H264_CONTEXT* decoder;
34static H264_CONTEXT_OPTION hevc2h264option(FREERDP_HEVC_CONTEXT_OPTION option)
38 case FREERDP_HEVC_CONTEXT_OPTION_PROFILE:
39 return H264_CONTEXT_OPTION_QP;
40 case FREERDP_HEVC_CONTEXT_OPTION_RATECONTROL:
41 return H264_CONTEXT_OPTION_RATECONTROL;
42 case FREERDP_HEVC_CONTEXT_OPTION_BITRATE:
43 return H264_CONTEXT_OPTION_BITRATE;
44 case FREERDP_HEVC_CONTEXT_OPTION_USAGETYPE:
45 return H264_CONTEXT_OPTION_USAGETYPE;
46 case FREERDP_HEVC_CONTEXT_OPTION_HW_ACCEL:
47 return H264_CONTEXT_OPTION_HW_ACCEL;
52BOOL freerdp_hevc_context_set_option(WINPR_ATTR_UNUSED FREERDP_HEVC_CONTEXT* hevc,
53 WINPR_ATTR_UNUSED FREERDP_HEVC_CONTEXT_OPTION option,
54 WINPR_ATTR_UNUSED UINT32 value)
57 if (!hevc->Compressor)
58 return h264_context_set_option(hevc->decoder, hevc2h264option(option), value);
62UINT32 freerdp_hevc_context_get_option(WINPR_ATTR_UNUSED FREERDP_HEVC_CONTEXT* hevc,
63 WINPR_ATTR_UNUSED FREERDP_HEVC_CONTEXT_OPTION option)
66 if (!hevc->Compressor)
67 return h264_context_get_option(hevc->decoder, hevc2h264option(option));
71INT32 freerdp_hevc_compress(WINPR_ATTR_UNUSED FREERDP_HEVC_CONTEXT* hevc,
72 WINPR_ATTR_UNUSED
const BYTE* pSrcData,
73 WINPR_ATTR_UNUSED DWORD SrcFormat, WINPR_ATTR_UNUSED UINT32 nSrcStep,
74 WINPR_ATTR_UNUSED UINT32 nSrcWidth, WINPR_ATTR_UNUSED UINT32 nSrcHeight,
76 WINPR_ATTR_UNUSED BYTE** ppDstData, WINPR_ATTR_UNUSED UINT32* pDstSize,
80 WLog_Print(hevc->log, WLOG_ERROR,
81 "This build does not support HEVC codec. Recompile with '-DWITH_AVM=ON' or "
82 "'-DWITH_DHEVCD=ON'");
86INT32 freerdp_hevc_decompress(WINPR_ATTR_UNUSED FREERDP_HEVC_CONTEXT* hevc,
87 WINPR_ATTR_UNUSED
const BYTE* pSrcData,
88 WINPR_ATTR_UNUSED UINT32 SrcSize, WINPR_ATTR_UNUSED BYTE* pDstData,
89 WINPR_ATTR_UNUSED DWORD DstFormat, WINPR_ATTR_UNUSED UINT32 nDstStep,
90 WINPR_ATTR_UNUSED UINT32 nDstWidth,
91 WINPR_ATTR_UNUSED UINT32 nDstHeight,
93 WINPR_ATTR_UNUSED UINT32 numRegionRect)
96 return avc420_decompress(hevc->decoder, pSrcData, SrcSize, pDstData, DstFormat, nDstStep,
97 nDstWidth, nDstHeight, regionRects, numRegionRect);
100BOOL freerdp_hevc_context_reset(WINPR_ATTR_UNUSED FREERDP_HEVC_CONTEXT* hevc,
101 WINPR_ATTR_UNUSED UINT32 width, WINPR_ATTR_UNUSED UINT32 height)
104 if (!hevc->Compressor)
105 return h264_context_reset(hevc->decoder, width, height);
107 WLog_Print(hevc->log, WLOG_WARN,
108 "This build does not support HEVC codec. Recompile with '-DWITH_AVM=ON' or "
109 "'-DWITH_DHEVCD=ON'");
113void freerdp_hevc_context_free(WINPR_ATTR_UNUSED FREERDP_HEVC_CONTEXT* hevc)
118 h264_context_free(hevc->decoder);
122FREERDP_HEVC_CONTEXT* freerdp_hevc_context_new(BOOL Compressor)
124 FREERDP_HEVC_CONTEXT* ctx = calloc(1,
sizeof(FREERDP_HEVC_CONTEXT));
127 ctx->Compressor = Compressor;
128 ctx->log = WLog_Get(TAG);