21#include <freerdp/config.h>
24#include <winpr/print.h>
25#include <winpr/library.h>
26#include <winpr/bitstream.h>
27#include <winpr/synch.h>
29#include <freerdp/primitives.h>
30#include <freerdp/codec/h264.h>
31#include <freerdp/codec/yuv.h>
32#include <freerdp/log.h>
33#include <freerdp/codec/region.h>
37#define TAG FREERDP_TAG("codec")
40static BOOL avc444_ensure_buffer(H264_CONTEXT* h264, DWORD nDstHeight);
43static BOOL yuv_ensure_buffer(H264_CONTEXT* h264, UINT32 stride, UINT32 width, UINT32 height)
46 UINT32 pheight = height;
53 const UINT32 pad = width % 16;
60 stride += 32 - stride % 16;
61 pheight += 32 - pheight % 16;
63 const size_t nPlanes = h264->hwAccel ? 2 : 3;
65 for (
size_t x = 0; x < nPlanes; x++)
67 if (!h264->pYUVData[x] || !h264->pOldYUVData[x])
76 if (isNull || (width != h264->width) || (height != h264->height) ||
77 (stride != h264->iStride[0]))
79 UINT32 iStride[3] = WINPR_C_ARRAY_INIT;
89 iStride[1] = (stride + 1) / 2;
90 iStride[2] = (stride + 1) / 2;
93 for (
size_t x = 0; x < nPlanes; x++)
95 BYTE* tmp1 = winpr_aligned_recalloc(h264->pYUVData[x], iStride[x], pheight, 16);
96 BYTE* tmp2 = winpr_aligned_recalloc(h264->pOldYUVData[x], iStride[x], pheight, 16);
98 h264->pYUVData[x] = tmp1;
100 h264->pOldYUVData[x] = tmp2;
105 memcpy(h264->iStride, iStride,
sizeof(h264->iStride));
107 h264->height = height;
113BOOL avc420_ensure_buffer(H264_CONTEXT* h264, UINT32 stride, UINT32 width, UINT32 height)
115 return yuv_ensure_buffer(h264, stride, width, height);
119static BOOL isRectValid(wLog* log,
size_t pos, UINT32 width, UINT32 height,
123 if ((rect->left > width) || (rect->right > width) || (rect->left >= rect->right) ||
124 (rect->top > height) || (rect->bottom > height) || (rect->top >= rect->bottom))
126 char buffer[64] = WINPR_C_ARRAY_INIT;
127 WLog_Print(log, WLOG_WARN,
128 "Rectangle %" PRIuz
" %s outside of bounding frame %" PRIu32
"x%" PRIu32, pos,
129 rectangle_to_string(rect, buffer,
sizeof(buffer)), width, height);
137static BOOL areRectsValid(wLog* log, UINT32 width, UINT32 height,
const RECTANGLE_16* rects,
140 WINPR_ASSERT(rects || (count == 0));
141 for (
size_t x = 0; x < count; x++)
144 if (!isRectValid(log, x, width, height, rect))
151static int log_decompress(H264_CONTEXT* h264,
const BYTE* pSrcData, UINT32 SrcSize,
155 WINPR_ASSERT(h264->subsystem);
156 WINPR_ASSERT(h264->subsystem->Decompress);
158 const int status = h264->subsystem->Decompress(h264, pSrcData, SrcSize);
161 WLog_Print(h264->log, WLOG_WARN,
"H264 decompress failed with %d", status);
171 if (!areRectsValid(h264->log, h264->YUVWidth, h264->YUVHeight, rects, nrRects))
173 if (!areRectsValid(h264->log, h264->width, h264->height, rects, nrRects))
178INT32 avc420_decompress(H264_CONTEXT* h264,
const BYTE* pSrcData, UINT32 SrcSize, BYTE* pDstData,
179 DWORD DstFormat, UINT32 nDstStep, WINPR_ATTR_UNUSED UINT32 nDstWidth,
180 WINPR_ATTR_UNUSED UINT32 nDstHeight,
const RECTANGLE_16* regionRects,
181 UINT32 numRegionRects)
184 const BYTE* pYUVData[3];
186 if (!h264 || h264->Compressor)
189 if (!areRectsValid(h264->log, nDstWidth, nDstHeight, regionRects, numRegionRects))
192 status = log_decompress(h264, pSrcData, SrcSize, regionRects, numRegionRects);
200 pYUVData[0] = h264->pYUVData[0];
201 pYUVData[1] = h264->pYUVData[1];
202 pYUVData[2] = h264->pYUVData[2];
203 if (!yuv420_context_decode(h264->yuv, pYUVData, h264->iStride, h264->YUVHeight, DstFormat,
204 pDstData, nDstStep, regionRects, numRegionRects))
211static BOOL allocate_h264_metablock(UINT32 QP,
RECTANGLE_16* rectangles,
215 if (!meta || (QP > UINT8_MAX))
221 meta->regionRects = rectangles;
225 if (count > UINT32_MAX)
230 if (!meta->quantQualityVals || !meta->regionRects)
232 meta->numRegionRects = (UINT32)count;
233 for (
size_t x = 0; x < count; x++)
240 cur->qualityVal = 100 - (QP & 0x3F);
246static inline BOOL diff_tile(
const RECTANGLE_16* regionRect, BYTE* pYUVData[3],
247 BYTE* pOldYUVData[3], UINT32
const iStride[3])
251 if (!regionRect || !pYUVData || !pOldYUVData || !iStride)
253 size = regionRect->right - regionRect->left;
254 if (regionRect->right > iStride[0])
256 if (regionRect->right / 2u > iStride[1])
258 if (regionRect->right / 2u > iStride[2])
261 for (
size_t y = regionRect->top; y < regionRect->bottom; y++)
263 const BYTE* cur0 = &pYUVData[0][y * iStride[0]];
264 const BYTE* cur1 = &pYUVData[1][y * iStride[1]];
265 const BYTE* cur2 = &pYUVData[2][y * iStride[2]];
266 const BYTE* old0 = &pOldYUVData[0][y * iStride[0]];
267 const BYTE* old1 = &pOldYUVData[1][y * iStride[1]];
268 const BYTE* old2 = &pOldYUVData[2][y * iStride[2]];
270 if (memcmp(&cur0[regionRect->left], &old0[regionRect->left], size) != 0)
272 if (memcmp(&cur1[regionRect->left / 2], &old1[regionRect->left / 2], size / 2) != 0)
274 if (memcmp(&cur2[regionRect->left / 2], &old2[regionRect->left / 2], size / 2) != 0)
281static BOOL detect_changes(BOOL firstFrameDone,
const UINT32 QP,
const RECTANGLE_16* regionRect,
282 BYTE* pYUVData[3], BYTE* pOldYUVData[3], UINT32
const iStride[3],
290 if (!regionRect || !pYUVData || !pOldYUVData || !iStride || !meta)
293 wc = (regionRect->right - regionRect->left) / 64 + 1;
294 hc = (regionRect->bottom - regionRect->top) / 64 + 1;
300 rectangles[0] = *regionRect;
305 for (
size_t y = 0; y < regionRect->bottom - regionRect->top; y += 64)
307 for (
size_t x = 0; x < regionRect->right - regionRect->left; x += 64)
310 rect.left = (UINT16)MIN(UINT16_MAX, regionRect->left + x);
311 rect.top = (UINT16)MIN(UINT16_MAX, regionRect->top + y);
313 (UINT16)MIN(UINT16_MAX, MIN(regionRect->left + x + 64, regionRect->right));
315 (UINT16)MIN(UINT16_MAX, MIN(regionRect->top + y + 64, regionRect->bottom));
316 if (diff_tile(&rect, pYUVData, pOldYUVData, iStride))
317 rectangles[count++] = rect;
321 if (!allocate_h264_metablock(QP, rectangles, meta, count))
326INT32 h264_get_yuv_buffer(H264_CONTEXT* h264, UINT32 nSrcStride, UINT32 nSrcWidth,
327 UINT32 nSrcHeight, BYTE* YUVData[3], UINT32 stride[3])
329 if (!h264 || !h264->Compressor || !h264->subsystem || !h264->subsystem->Compress)
332 if (!yuv_ensure_buffer(h264, nSrcStride, nSrcWidth, nSrcHeight))
335 for (
size_t x = 0; x < 3; x++)
337 YUVData[x] = h264->pYUVData[x];
338 stride[x] = h264->iStride[x];
344INT32 h264_compress(H264_CONTEXT* h264, BYTE** ppDstData, UINT32* pDstSize)
346 if (!h264 || !h264->Compressor || !h264->subsystem || !h264->subsystem->Compress)
349 const BYTE* pcYUVData[3] = { h264->pYUVData[0], h264->pYUVData[1], h264->pYUVData[2] };
351 return h264->subsystem->Compress(h264, pcYUVData, h264->iStride, ppDstData, pDstSize);
354INT32 avc420_compress(H264_CONTEXT* h264,
const BYTE* pSrcData, DWORD SrcFormat, UINT32 nSrcStep,
355 UINT32 nSrcWidth, UINT32 nSrcHeight,
const RECTANGLE_16* regionRect,
359 BYTE* pYUVData[3] = WINPR_C_ARRAY_INIT;
360 const BYTE* pcYUVData[3] = WINPR_C_ARRAY_INIT;
361 BYTE* pOldYUVData[3] = WINPR_C_ARRAY_INIT;
363 if (!h264 || !regionRect || !meta || !h264->Compressor)
366 if (!h264->subsystem->Compress)
369 if (!avc420_ensure_buffer(h264, nSrcStep, nSrcWidth, nSrcHeight))
372 if (h264->encodingBuffer)
374 for (
size_t x = 0; x < 3; x++)
376 pYUVData[x] = h264->pYUVData[x];
377 pOldYUVData[x] = h264->pOldYUVData[x];
382 for (
size_t x = 0; x < 3; x++)
384 pYUVData[x] = h264->pOldYUVData[x];
385 pOldYUVData[x] = h264->pYUVData[x];
388 h264->encodingBuffer = !h264->encodingBuffer;
390 if (!yuv420_context_encode(h264->yuv, pSrcData, nSrcStep, SrcFormat, h264->iStride, pYUVData,
394 if (!detect_changes(h264->firstLumaFrameDone, h264->QP, regionRect, pYUVData, pOldYUVData,
395 h264->iStride, meta))
398 if (meta->numRegionRects == 0)
404 for (
size_t x = 0; x < 3; x++)
405 pcYUVData[x] = pYUVData[x];
407 rc = h264->subsystem->Compress(h264, pcYUVData, h264->iStride, ppDstData, pDstSize);
409 h264->firstLumaFrameDone = TRUE;
413 free_h264_metablock(meta);
417INT32 avc444_compress(H264_CONTEXT* h264,
const BYTE* pSrcData, DWORD SrcFormat, UINT32 nSrcStep,
418 UINT32 nSrcWidth, UINT32 nSrcHeight, BYTE version,
const RECTANGLE_16* region,
419 BYTE* op, BYTE** ppDstData, UINT32* pDstSize, BYTE** ppAuxDstData,
424 BYTE* coded =
nullptr;
425 UINT32 codedSize = 0;
426 BYTE** pYUV444Data =
nullptr;
427 BYTE** pOldYUV444Data =
nullptr;
428 BYTE** pYUVData =
nullptr;
429 BYTE** pOldYUVData =
nullptr;
431 if (!h264 || !h264->Compressor)
434 if (!h264->subsystem->Compress)
437 if (!avc420_ensure_buffer(h264, nSrcStep, nSrcWidth, nSrcHeight))
440 if (!avc444_ensure_buffer(h264, nSrcHeight))
443 if (h264->encodingBuffer)
445 pYUV444Data = h264->pOldYUV444Data;
446 pOldYUV444Data = h264->pYUV444Data;
447 pYUVData = h264->pOldYUVData;
448 pOldYUVData = h264->pYUVData;
452 pYUV444Data = h264->pYUV444Data;
453 pOldYUV444Data = h264->pOldYUV444Data;
454 pYUVData = h264->pYUVData;
455 pOldYUVData = h264->pOldYUVData;
457 h264->encodingBuffer = !h264->encodingBuffer;
459 if (!yuv444_context_encode(h264->yuv, version, pSrcData, nSrcStep, SrcFormat, h264->iStride,
460 pYUV444Data, pYUVData, region, 1))
463 if (!detect_changes(h264->firstLumaFrameDone, h264->QP, region, pYUV444Data, pOldYUV444Data,
464 h264->iStride, meta))
466 if (!detect_changes(h264->firstChromaFrameDone, h264->QP, region, pYUVData, pOldYUVData,
467 h264->iStride, auxMeta))
476 if ((meta->numRegionRects > 0) && (auxMeta->numRegionRects > 0))
478 else if (meta->numRegionRects > 0)
480 else if (auxMeta->numRegionRects > 0)
484 WLog_Print(h264->log, WLOG_TRACE,
"no changes detected for luma or chroma frame");
489 if ((*op == 0) || (*op == 1))
491 const BYTE* pcYUV444Data[3] = { pYUV444Data[0], pYUV444Data[1], pYUV444Data[2] };
493 if (h264->subsystem->Compress(h264, pcYUV444Data, h264->iStride, &coded, &codedSize) < 0)
495 h264->firstLumaFrameDone = TRUE;
496 memcpy(h264->lumaData, coded, codedSize);
497 *ppDstData = h264->lumaData;
498 *pDstSize = codedSize;
501 if ((*op == 0) || (*op == 2))
503 const BYTE* pcYUVData[3] = { pYUVData[0], pYUVData[1], pYUVData[2] };
505 if (h264->subsystem->Compress(h264, pcYUVData, h264->iStride, &coded, &codedSize) < 0)
507 h264->firstChromaFrameDone = TRUE;
508 *ppAuxDstData = coded;
509 *pAuxDstSize = codedSize;
516 free_h264_metablock(meta);
517 free_h264_metablock(auxMeta);
522BOOL avc444_ensure_buffer(H264_CONTEXT* h264, DWORD nDstHeight)
526 const UINT32* piMainStride = h264->iStride;
527 UINT32* piDstSize = h264->iYUV444Size;
528 UINT32* piDstStride = h264->iYUV444Stride;
529 BYTE** ppYUVDstData = h264->pYUV444Data;
530 BYTE** ppOldYUVDstData = h264->pOldYUV444Data;
532 nDstHeight = MAX(h264->height, nDstHeight);
533 const UINT32 pad = nDstHeight % 16;
534 UINT32 padDstHeight = nDstHeight;
537 padDstHeight += 16 - pad;
542 if ((piMainStride[0] == 0) || (padDstHeight == 0))
545 const uint64_t dstsize = 1ull * piMainStride[0] * padDstHeight;
546 if (dstsize > UINT32_MAX)
549 if ((piMainStride[0] != piDstStride[0]) || (piDstSize[0] != dstsize))
551 const UINT32 size = WINPR_ASSERTING_INT_CAST(UINT32, dstsize);
553 for (UINT32 x = 0; x < 3; x++)
555 BYTE* tmp1 = winpr_aligned_recalloc(ppYUVDstData[x], size, 1, 16);
558 ppYUVDstData[x] = tmp1;
559 BYTE* tmp2 = winpr_aligned_recalloc(ppOldYUVDstData[x], size, 1, 16);
562 ppOldYUVDstData[x] = tmp2;
566 BYTE* tmp = winpr_aligned_recalloc(h264->lumaData, size, 4, 16);
569 h264->lumaData = tmp;
574 for (UINT32 x = 0; x < 3; x++)
576 piDstStride[x] = piMainStride[0];
581 for (UINT32 x = 0; x < 3; x++)
583 if (!ppOldYUVDstData[x] || !ppYUVDstData[x] || (piDstSize[x] == 0) || (piDstStride[x] == 0))
585 WLog_Print(h264->log, WLOG_ERROR,
586 "YUV buffer not initialized! check your decoder settings");
600static BOOL avc444_process_rects(H264_CONTEXT* h264,
const BYTE* pSrcData, UINT32 SrcSize,
601 BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
602 WINPR_ATTR_UNUSED UINT32 nDstWidth, UINT32 nDstHeight,
603 const RECTANGLE_16* rects, UINT32 nrRects, avc444_frame_type type)
605 const BYTE* pYUVData[3] = WINPR_C_ARRAY_INIT;
606 BYTE* pYUVDstData[3] = WINPR_C_ARRAY_INIT;
607 UINT32* piDstStride = h264->iYUV444Stride;
608 BYTE** ppYUVDstData = h264->pYUV444Data;
609 const UINT32* piStride = h264->iStride;
611 const int status = log_decompress(h264, pSrcData, SrcSize, rects, nrRects);
617 pYUVData[0] = h264->pYUVData[0];
618 pYUVData[1] = h264->pYUVData[1];
619 pYUVData[2] = h264->pYUVData[2];
620 if (!avc444_ensure_buffer(h264, nDstHeight))
623 pYUVDstData[0] = ppYUVDstData[0];
624 pYUVDstData[1] = ppYUVDstData[1];
625 pYUVDstData[2] = ppYUVDstData[2];
626 return (yuv444_context_decode(h264->yuv, (BYTE)type, pYUVData, piStride, h264->YUVHeight,
627 pYUVDstData, piDstStride, DstFormat, pDstData, nDstStep, rects,
631#if defined(AVC444_FRAME_STAT)
632static UINT64 op1 = 0;
633static double op1sum = 0;
634static UINT64 op2 = 0;
635static double op2sum = 0;
636static UINT64 op3 = 0;
637static double op3sum = 0;
638static double avg(UINT64* count,
double old,
double size)
640 double tmp = size + *count * old;
647INT32 avc444_decompress(H264_CONTEXT* h264, BYTE op,
const RECTANGLE_16* regionRects,
648 UINT32 numRegionRects,
const BYTE* pSrcData, UINT32 SrcSize,
649 const RECTANGLE_16* auxRegionRects, UINT32 numAuxRegionRect,
650 const BYTE* pAuxSrcData, UINT32 AuxSrcSize, BYTE* pDstData, DWORD DstFormat,
651 UINT32 nDstStep, UINT32 nDstWidth, UINT32 nDstHeight, UINT32 codecId)
654 avc444_frame_type chroma =
655 (codecId == RDPGFX_CODECID_AVC444) ? AVC444_CHROMAv1 : AVC444_CHROMAv2;
657 if (!h264 || !regionRects || !pSrcData || !pDstData || h264->Compressor)
660 if (!areRectsValid(h264->log, nDstWidth, nDstHeight, regionRects, numRegionRects))
662 if (!areRectsValid(h264->log, nDstWidth, nDstHeight, auxRegionRects, numAuxRegionRect))
669 if (!avc444_process_rects(h264, pSrcData, SrcSize, pDstData, DstFormat, nDstStep,
670 nDstWidth, nDstHeight, regionRects, numRegionRects,
673 else if (!avc444_process_rects(h264, pAuxSrcData, AuxSrcSize, pDstData, DstFormat,
674 nDstStep, nDstWidth, nDstHeight, auxRegionRects,
675 numAuxRegionRect, chroma))
683 if (!avc444_process_rects(h264, pSrcData, SrcSize, pDstData, DstFormat, nDstStep,
684 nDstWidth, nDstHeight, regionRects, numRegionRects, chroma))
692 if (!avc444_process_rects(h264, pSrcData, SrcSize, pDstData, DstFormat, nDstStep,
693 nDstWidth, nDstHeight, regionRects, numRegionRects,
705#if defined(AVC444_FRAME_STAT)
710 op1sum = avg(&op1, op1sum, SrcSize + AuxSrcSize);
714 op2sum = avg(&op2, op2sum, SrcSize);
718 op3sum = avg(&op3, op3sum, SrcSize);
725 WLog_Print(h264->log, WLOG_INFO,
726 "luma=%" PRIu64
" [avg=%lf] chroma=%" PRIu64
" [avg=%lf] combined=%" PRIu64
728 op1, op1sum, op2, op2sum, op3, op3sum);
733#define MAX_SUBSYSTEMS 10
734static INIT_ONCE subsystems_once = INIT_ONCE_STATIC_INIT;
735static const H264_CONTEXT_SUBSYSTEM* subSystems[MAX_SUBSYSTEMS] = WINPR_C_ARRAY_INIT;
738static BOOL CALLBACK h264_register_subsystems(WINPR_ATTR_UNUSED
PINIT_ONCE once,
739 WINPR_ATTR_UNUSED PVOID param,
740 WINPR_ATTR_UNUSED PVOID* context)
744#ifdef WITH_MEDIACODEC
746 subSystems[i] = &g_Subsystem_mediacodec;
750#if defined(_WIN32) && defined(WITH_MEDIA_FOUNDATION)
752 subSystems[i] = &g_Subsystem_MF;
756#ifdef WITH_APPLE_VIDEOTOOLBOX
758 subSystems[i] = &g_Subsystem_VideoToolbox;
764 subSystems[i] = &g_Subsystem_OpenH264;
768#ifdef WITH_VIDEO_FFMPEG
770 subSystems[i] = &g_Subsystem_libavcodec;
774#ifdef WITH_H264_WEBCODECS
776 subSystems[i] = &g_Subsystem_WebCodecs;
784static BOOL h264_context_init(H264_CONTEXT* h264)
789 h264->subsystem =
nullptr;
790 if (!InitOnceExecuteOnce(&subsystems_once, h264_register_subsystems,
nullptr,
nullptr))
793 for (
size_t i = 0; i < MAX_SUBSYSTEMS; i++)
795 const H264_CONTEXT_SUBSYSTEM* subsystem = subSystems[i];
797 if (!subsystem || !subsystem->Init)
800 if (subsystem->Init(h264))
802 h264->subsystem = subsystem;
810static void h264_buffers_free(H264_CONTEXT* h264)
813 for (
size_t x = 0; x < 3; x++)
815 if (h264->Compressor)
817 winpr_aligned_free(h264->pYUVData[x]);
818 winpr_aligned_free(h264->pOldYUVData[x]);
820 winpr_aligned_free(h264->pYUV444Data[x]);
821 winpr_aligned_free(h264->pOldYUV444Data[x]);
823 h264->pYUVData[x] =
nullptr;
824 h264->pOldYUVData[x] =
nullptr;
825 h264->pYUV444Data[x] =
nullptr;
826 h264->pOldYUV444Data[x] =
nullptr;
828 winpr_aligned_free(h264->lumaData);
829 h264->lumaData =
nullptr;
832BOOL h264_context_reset(H264_CONTEXT* h264, UINT32 width, UINT32 height)
837 if (width > UINT16_MAX)
839 WLog_Print(h264->log, WLOG_ERROR,
"h264::width %" PRIu32
" > %d, aborting", width,
843 if (height > UINT16_MAX)
845 WLog_Print(h264->log, WLOG_ERROR,
"h264::height %" PRIu32
" > %d, aborting", height,
850 if (h264->subsystem && h264->subsystem->Uninit)
851 h264->subsystem->Uninit(h264);
853 h264_buffers_free(h264);
855 h264->height = height;
857 if (!h264_context_init(h264))
860 return yuv_context_reset(h264->yuv, width, height);
863H264_CONTEXT* h264_context_new(BOOL Compressor)
865 H264_CONTEXT* h264 = (H264_CONTEXT*)calloc(1,
sizeof(H264_CONTEXT));
869 h264->log = WLog_Get(TAG);
874 h264->Compressor = Compressor;
878 h264->BitRate = 1000000;
879 h264->FrameRate = 30;
882 if (!h264_context_init(h264))
885 h264->yuv = yuv_context_new(Compressor, 0);
892 WINPR_PRAGMA_DIAG_PUSH
893 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
894 h264_context_free(h264);
895 WINPR_PRAGMA_DIAG_POP
899void h264_context_free(H264_CONTEXT* h264)
906 WINPR_ASSERT(h264->subsystem->Uninit);
907 h264->subsystem->Uninit(h264);
910 h264_buffers_free(h264);
912 yuv_context_free(h264->yuv);
921 free(meta->quantQualityVals);
922 free(meta->regionRects);
926BOOL h264_context_set_option(H264_CONTEXT* h264, H264_CONTEXT_OPTION option, UINT32 value)
931 case H264_CONTEXT_OPTION_BITRATE:
932 h264->BitRate = value;
934 case H264_CONTEXT_OPTION_FRAMERATE:
935 h264->FrameRate = value;
937 case H264_CONTEXT_OPTION_RATECONTROL:
941 case H264_RATECONTROL_VBR:
942 h264->RateControlMode = H264_RATECONTROL_VBR;
944 case H264_RATECONTROL_CQP:
945 h264->RateControlMode = H264_RATECONTROL_CQP;
948 WLog_Print(h264->log, WLOG_WARN,
949 "Unknown H264_CONTEXT_OPTION_RATECONTROL value [0x%08" PRIx32
"]",
955 case H264_CONTEXT_OPTION_QP:
958 case H264_CONTEXT_OPTION_USAGETYPE:
959 h264->UsageType = value;
961 case H264_CONTEXT_OPTION_HW_ACCEL:
962#ifdef WITH_APPLE_VIDEOTOOLBOX
965 if (h264->subsystem == &g_Subsystem_VideoToolbox)
968 if (h264->hwAccel == value)
970 h264->hwAccel = (value);
971 IFCALL(h264->subsystem->Uninit, h264);
972 return IFCALLRESULT(TRUE, h264->subsystem->Init, h264);
974 WLog_Print(h264->log, WLOG_WARN,
"Unknown H264_CONTEXT_OPTION[0x%08" PRIx32
"]",
980UINT32 h264_context_get_option(H264_CONTEXT* h264, H264_CONTEXT_OPTION option)
985 case H264_CONTEXT_OPTION_BITRATE:
986 return h264->BitRate;
987 case H264_CONTEXT_OPTION_FRAMERATE:
988 return h264->FrameRate;
989 case H264_CONTEXT_OPTION_RATECONTROL:
990 return h264->RateControlMode;
991 case H264_CONTEXT_OPTION_QP:
993 case H264_CONTEXT_OPTION_USAGETYPE:
994 return h264->UsageType;
995 case H264_CONTEXT_OPTION_HW_ACCEL:
996 return h264->hwAccel;
998 WLog_Print(h264->log, WLOG_WARN,
"Unknown H264_CONTEXT_OPTION[0x%08" PRIx32
"]",