FreeRDP
Loading...
Searching...
No Matches
h264_openh264.c
1
21#include <freerdp/config.h>
22
23#include <winpr/winpr.h>
24#include <winpr/library.h>
25#include <winpr/assert.h>
26#include <winpr/cast.h>
27
28#include <freerdp/log.h>
29#include <freerdp/codec/h264.h>
30
31#include <wels/codec_def.h>
32#include <wels/codec_api.h>
33#include <wels/codec_ver.h>
34
35#include "h264.h"
36
37typedef void (*pWelsGetCodecVersionEx)(OpenH264Version* pVersion);
38
39typedef long (*pWelsCreateDecoder)(ISVCDecoder** ppDecoder);
40typedef void (*pWelsDestroyDecoder)(ISVCDecoder* pDecoder);
41
42typedef int (*pWelsCreateSVCEncoder)(ISVCEncoder** ppEncoder);
43typedef void (*pWelsDestroySVCEncoder)(ISVCEncoder* pEncoder);
44
45typedef struct
46{
47#if defined(WITH_OPENH264_LOADING)
48 HMODULE lib;
49 OpenH264Version version;
50#endif
51 pWelsGetCodecVersionEx WelsGetCodecVersionEx;
52 pWelsCreateDecoder WelsCreateDecoder;
53 pWelsDestroyDecoder WelsDestroyDecoder;
54 pWelsCreateSVCEncoder WelsCreateSVCEncoder;
55 pWelsDestroySVCEncoder WelsDestroySVCEncoder;
56 ISVCDecoder* pDecoder;
57 ISVCEncoder* pEncoder;
58 SEncParamExt EncParamExt;
59} H264_CONTEXT_OPENH264;
60
61#if defined(WITH_OPENH264_LOADING)
62static const char* openh264_library_names[] = {
63#if defined(_WIN32)
64 "openh264.dll"
65#elif defined(__APPLE__)
66 "libopenh264.dylib"
67#else
68 "libopenh264.so.7", "libopenh264.so.2.5.0", "libopenh264.so.2.4.1", "libopenh264.so.2.4.0",
69 "libopenh264.so.2.3.1", "libopenh264.so.2.3.0", "libopenh264.so",
70
71#endif
72};
73#endif
74
75static void openh264_trace_callback(void* ctx, int level, const char* message)
76{
77 H264_CONTEXT* h264 = ctx;
78 if (h264)
79 WLog_Print(h264->log, WLOG_TRACE, "%d - %s", level, message);
80}
81
82static int openh264_decompress(H264_CONTEXT* WINPR_RESTRICT h264,
83 const BYTE* WINPR_RESTRICT pSrcData, UINT32 SrcSize)
84{
85 DECODING_STATE state = dsInvalidArgument;
86 SBufferInfo sBufferInfo = { 0 };
87 SSysMEMBuffer* pSystemBuffer = NULL;
88 H264_CONTEXT_OPENH264* sys = NULL;
89 UINT32* iStride = NULL;
90 BYTE** pYUVData = NULL;
91
92 WINPR_ASSERT(h264);
93 WINPR_ASSERT(pSrcData || (SrcSize == 0));
94
95 sys = (H264_CONTEXT_OPENH264*)h264->pSystemData;
96 WINPR_ASSERT(sys);
97
98 iStride = h264->iStride;
99 WINPR_ASSERT(iStride);
100
101 pYUVData = h264->pYUVData;
102 WINPR_ASSERT(pYUVData);
103
104 if (!sys->pDecoder)
105 return -2001;
106
107 /*
108 * Decompress the image. The RDP host only seems to send I420 format.
109 */
110 pYUVData[0] = NULL;
111 pYUVData[1] = NULL;
112 pYUVData[2] = NULL;
113
114 WINPR_ASSERT(sys->pDecoder);
115 state = (*sys->pDecoder)
116 ->DecodeFrame2(sys->pDecoder, pSrcData, WINPR_ASSERTING_INT_CAST(int, SrcSize),
117 pYUVData, &sBufferInfo);
118
119 if (sBufferInfo.iBufferStatus != 1)
120 {
121 if (state == dsNoParamSets)
122 {
123 /* this happens on the first frame due to missing parameter sets */
124 state = (*sys->pDecoder)->DecodeFrame2(sys->pDecoder, NULL, 0, pYUVData, &sBufferInfo);
125 }
126 else if (state == dsErrorFree)
127 {
128 /* call DecodeFrame2 again to decode without delay */
129 state = (*sys->pDecoder)->DecodeFrame2(sys->pDecoder, NULL, 0, pYUVData, &sBufferInfo);
130 }
131 else
132 {
133 WLog_Print(h264->log, WLOG_WARN, "DecodeFrame2 state: 0x%04X iBufferStatus: %d", state,
134 sBufferInfo.iBufferStatus);
135 return -2002;
136 }
137 }
138
139 if (state != dsErrorFree)
140 {
141 WLog_Print(h264->log, WLOG_WARN, "DecodeFrame2 state: 0x%02X", state);
142 return -2003;
143 }
144
145#if OPENH264_MAJOR >= 2
146 state = (*sys->pDecoder)->FlushFrame(sys->pDecoder, pYUVData, &sBufferInfo);
147 if (state != dsErrorFree)
148 {
149 WLog_Print(h264->log, WLOG_WARN, "FlushFrame state: 0x%02X", state);
150 return -2003;
151 }
152#endif
153
154 pSystemBuffer = &sBufferInfo.UsrData.sSystemBuffer;
155 iStride[0] = WINPR_ASSERTING_INT_CAST(uint32_t, pSystemBuffer->iStride[0]);
156 iStride[1] = WINPR_ASSERTING_INT_CAST(uint32_t, pSystemBuffer->iStride[1]);
157 iStride[2] = WINPR_ASSERTING_INT_CAST(uint32_t, pSystemBuffer->iStride[1]);
158
159 if (sBufferInfo.iBufferStatus != 1)
160 {
161 WLog_Print(h264->log, WLOG_WARN, "DecodeFrame2 iBufferStatus: %d",
162 sBufferInfo.iBufferStatus);
163 return 0;
164 }
165
166 if (state != dsErrorFree)
167 {
168 WLog_Print(h264->log, WLOG_WARN, "DecodeFrame2 state: 0x%02X", state);
169 return -2003;
170 }
171
172 if (pSystemBuffer->iFormat != videoFormatI420)
173 return -2004;
174
175 if (!pYUVData[0] || !pYUVData[1] || !pYUVData[2])
176 return -2005;
177
178 return 1;
179}
180
181static int openh264_compress(H264_CONTEXT* WINPR_RESTRICT h264,
182 const BYTE** WINPR_RESTRICT pYUVData,
183 const UINT32* WINPR_RESTRICT iStride, BYTE** WINPR_RESTRICT ppDstData,
184 UINT32* WINPR_RESTRICT pDstSize)
185{
186 int status = 0;
187 SFrameBSInfo info = { 0 };
188 SSourcePicture pic = { 0 };
189
190 H264_CONTEXT_OPENH264* sys = NULL;
191
192 WINPR_ASSERT(h264);
193 WINPR_ASSERT(pYUVData);
194 WINPR_ASSERT(iStride);
195 WINPR_ASSERT(ppDstData);
196 WINPR_ASSERT(pDstSize);
197
198 sys = &((H264_CONTEXT_OPENH264*)h264->pSystemData)[0];
199 WINPR_ASSERT(sys);
200
201 if (!sys->pEncoder)
202 return -1;
203
204 if (!pYUVData[0] || !pYUVData[1] || !pYUVData[2])
205 return -1;
206
207 if ((h264->width > INT_MAX) || (h264->height > INT_MAX))
208 return -1;
209
210 if ((h264->FrameRate > INT_MAX) || (h264->NumberOfThreads > INT_MAX) ||
211 (h264->BitRate > INT_MAX) || (h264->QP > INT_MAX))
212 return -1;
213
214 WINPR_ASSERT(sys->pEncoder);
215 if ((sys->EncParamExt.iPicWidth != (int)h264->width) ||
216 (sys->EncParamExt.iPicHeight != (int)h264->height))
217 {
218 WINPR_ASSERT((*sys->pEncoder)->GetDefaultParams);
219 status = (*sys->pEncoder)->GetDefaultParams(sys->pEncoder, &sys->EncParamExt);
220
221 if (status < 0)
222 {
223 WLog_Print(h264->log, WLOG_ERROR,
224 "Failed to get OpenH264 default parameters (status=%d)", status);
225 return status;
226 }
227
228 EUsageType usageType = SCREEN_CONTENT_REAL_TIME;
229
230 switch (h264->UsageType)
231 {
232 case H264_CAMERA_VIDEO_NON_REAL_TIME:
233 usageType = CAMERA_VIDEO_NON_REAL_TIME;
234 break;
235 case H264_CAMERA_VIDEO_REAL_TIME:
236 usageType = CAMERA_VIDEO_REAL_TIME;
237 break;
238 case H264_SCREEN_CONTENT_NON_REAL_TIME:
239 usageType = SCREEN_CONTENT_NON_REAL_TIME;
240 break;
241 case H264_SCREEN_CONTENT_REAL_TIME:
242 default:
243 break;
244 }
245
246 sys->EncParamExt.iUsageType = usageType;
247 sys->EncParamExt.iPicWidth = WINPR_ASSERTING_INT_CAST(int, h264->width);
248 sys->EncParamExt.iPicHeight = WINPR_ASSERTING_INT_CAST(int, h264->height);
249 sys->EncParamExt.fMaxFrameRate = WINPR_ASSERTING_INT_CAST(short, h264->FrameRate);
250 sys->EncParamExt.iMaxBitrate = UNSPECIFIED_BIT_RATE;
251 sys->EncParamExt.bEnableDenoise = 0;
252 sys->EncParamExt.bEnableLongTermReference = 0;
253 sys->EncParamExt.iSpatialLayerNum = 1;
254 sys->EncParamExt.iMultipleThreadIdc =
255 WINPR_ASSERTING_INT_CAST(unsigned short, h264->NumberOfThreads);
256 sys->EncParamExt.sSpatialLayers[0].fFrameRate =
257 WINPR_ASSERTING_INT_CAST(short, h264->FrameRate);
258 sys->EncParamExt.sSpatialLayers[0].iVideoWidth = sys->EncParamExt.iPicWidth;
259 sys->EncParamExt.sSpatialLayers[0].iVideoHeight = sys->EncParamExt.iPicHeight;
260 sys->EncParamExt.sSpatialLayers[0].iMaxSpatialBitrate = sys->EncParamExt.iMaxBitrate;
261
262 switch (h264->RateControlMode)
263 {
264 case H264_RATECONTROL_VBR:
265 sys->EncParamExt.iRCMode = RC_BITRATE_MODE;
266 sys->EncParamExt.iTargetBitrate = (int)h264->BitRate;
267 sys->EncParamExt.sSpatialLayers[0].iSpatialBitrate =
268 sys->EncParamExt.iTargetBitrate;
269 sys->EncParamExt.bEnableFrameSkip = 1;
270 break;
271
272 case H264_RATECONTROL_CQP:
273 sys->EncParamExt.iRCMode = RC_OFF_MODE;
274 sys->EncParamExt.sSpatialLayers[0].iDLayerQp = (int)h264->QP;
275 sys->EncParamExt.bEnableFrameSkip = 0;
276 break;
277 default:
278 break;
279 }
280
281 if (sys->EncParamExt.iMultipleThreadIdc > 1)
282 {
283#if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <= 5)
284 sys->EncParamExt.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_AUTO_SLICE;
285#else
286 sys->EncParamExt.sSpatialLayers[0].sSliceArgument.uiSliceMode = SM_FIXEDSLCNUM_SLICE;
287#endif
288 }
289
290 WINPR_ASSERT((*sys->pEncoder)->InitializeExt);
291 status = (*sys->pEncoder)->InitializeExt(sys->pEncoder, &sys->EncParamExt);
292
293 if (status < 0)
294 {
295 WLog_Print(h264->log, WLOG_ERROR, "Failed to initialize OpenH264 encoder (status=%d)",
296 status);
297 return status;
298 }
299
300 WINPR_ASSERT((*sys->pEncoder)->GetOption);
301 status =
302 (*sys->pEncoder)
303 ->GetOption(sys->pEncoder, ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sys->EncParamExt);
304
305 if (status < 0)
306 {
307 WLog_Print(h264->log, WLOG_ERROR,
308 "Failed to get initial OpenH264 encoder parameters (status=%d)", status);
309 return status;
310 }
311 }
312 else
313 {
314 switch (h264->RateControlMode)
315 {
316 case H264_RATECONTROL_VBR:
317 if (sys->EncParamExt.iTargetBitrate != (int)h264->BitRate)
318 {
319 SBitrateInfo bitrate = { 0 };
320
321 sys->EncParamExt.iTargetBitrate = (int)h264->BitRate;
322 bitrate.iLayer = SPATIAL_LAYER_ALL;
323 bitrate.iBitrate = (int)h264->BitRate;
324
325 WINPR_ASSERT((*sys->pEncoder)->SetOption);
326 status = (*sys->pEncoder)
327 ->SetOption(sys->pEncoder, ENCODER_OPTION_BITRATE, &bitrate);
328
329 if (status < 0)
330 {
331 WLog_Print(h264->log, WLOG_ERROR,
332 "Failed to set encoder bitrate (status=%d)", status);
333 return status;
334 }
335 }
336
337 if ((uint32_t)sys->EncParamExt.fMaxFrameRate != h264->FrameRate)
338 {
339 sys->EncParamExt.fMaxFrameRate = WINPR_ASSERTING_INT_CAST(int, h264->FrameRate);
340
341 WINPR_ASSERT((*sys->pEncoder)->SetOption);
342 status = (*sys->pEncoder)
343 ->SetOption(sys->pEncoder, ENCODER_OPTION_FRAME_RATE,
344 &sys->EncParamExt.fMaxFrameRate);
345
346 if (status < 0)
347 {
348 WLog_Print(h264->log, WLOG_ERROR,
349 "Failed to set encoder framerate (status=%d)", status);
350 return status;
351 }
352 }
353
354 break;
355
356 case H264_RATECONTROL_CQP:
357 if (sys->EncParamExt.sSpatialLayers[0].iDLayerQp != (int)h264->QP)
358 {
359 sys->EncParamExt.sSpatialLayers[0].iDLayerQp = (int)h264->QP;
360
361 WINPR_ASSERT((*sys->pEncoder)->SetOption);
362 status = (*sys->pEncoder)
363 ->SetOption(sys->pEncoder, ENCODER_OPTION_SVC_ENCODE_PARAM_EXT,
364 &sys->EncParamExt);
365
366 if (status < 0)
367 {
368 WLog_Print(h264->log, WLOG_ERROR,
369 "Failed to set encoder parameters (status=%d)", status);
370 return status;
371 }
372 }
373
374 break;
375 default:
376 break;
377 }
378 }
379
380 pic.iPicWidth = (int)h264->width;
381 pic.iPicHeight = (int)h264->height;
382 pic.iColorFormat = videoFormatI420;
383 pic.iStride[0] = (int)iStride[0];
384 pic.iStride[1] = (int)iStride[1];
385 pic.iStride[2] = (int)iStride[2];
386 pic.pData[0] = WINPR_CAST_CONST_PTR_AWAY(pYUVData[0], BYTE*);
387 pic.pData[1] = WINPR_CAST_CONST_PTR_AWAY(pYUVData[1], BYTE*);
388 pic.pData[2] = WINPR_CAST_CONST_PTR_AWAY(pYUVData[2], BYTE*);
389
390 WINPR_ASSERT((*sys->pEncoder)->EncodeFrame);
391 status = (*sys->pEncoder)->EncodeFrame(sys->pEncoder, &pic, &info);
392
393 if (status < 0)
394 {
395 WLog_Print(h264->log, WLOG_ERROR, "Failed to encode frame (status=%d)", status);
396 return status;
397 }
398
399 *ppDstData = info.sLayerInfo[0].pBsBuf;
400 *pDstSize = 0;
401
402 for (int i = 0; i < info.iLayerNum; i++)
403 {
404 for (int j = 0; j < info.sLayerInfo[i].iNalCount; j++)
405 {
406 const int val = info.sLayerInfo[i].pNalLengthInByte[j];
407 *pDstSize += WINPR_ASSERTING_INT_CAST(uint32_t, val);
408 }
409 }
410
411 return 1;
412}
413
414static void openh264_uninit(H264_CONTEXT* h264)
415{
416 H264_CONTEXT_OPENH264* sysContexts = NULL;
417
418 WINPR_ASSERT(h264);
419
420 sysContexts = (H264_CONTEXT_OPENH264*)h264->pSystemData;
421
422 if (sysContexts)
423 {
424 for (UINT32 x = 0; x < h264->numSystemData; x++)
425 {
426 H264_CONTEXT_OPENH264* sys = &sysContexts[x];
427
428 if (sys->pDecoder)
429 {
430 (*sys->pDecoder)->Uninitialize(sys->pDecoder);
431 sysContexts->WelsDestroyDecoder(sys->pDecoder);
432 sys->pDecoder = NULL;
433 }
434
435 if (sys->pEncoder)
436 {
437 (*sys->pEncoder)->Uninitialize(sys->pEncoder);
438 sysContexts->WelsDestroySVCEncoder(sys->pEncoder);
439 sys->pEncoder = NULL;
440 }
441 }
442
443#if defined(WITH_OPENH264_LOADING)
444 if (sysContexts->lib)
445 FreeLibrary(sysContexts->lib);
446#endif
447 free(h264->pSystemData);
448 h264->pSystemData = NULL;
449 }
450}
451
452#if defined(WITH_OPENH264_LOADING)
453static BOOL openh264_load_functionpointers(H264_CONTEXT* h264, const char* name)
454{
455 H264_CONTEXT_OPENH264* sysContexts;
456
457 WINPR_ASSERT(name);
458
459 if (!h264)
460 return FALSE;
461
462 sysContexts = h264->pSystemData;
463
464 if (!sysContexts)
465 return FALSE;
466
467 sysContexts->lib = LoadLibraryA(name);
468
469 if (!sysContexts->lib)
470 return FALSE;
471
472 sysContexts->WelsGetCodecVersionEx =
473 GetProcAddressAs(sysContexts->lib, "WelsGetCodecVersionEx", pWelsGetCodecVersionEx);
474 sysContexts->WelsCreateDecoder =
475 GetProcAddressAs(sysContexts->lib, "WelsCreateDecoder", pWelsCreateDecoder);
476 sysContexts->WelsDestroyDecoder =
477 GetProcAddressAs(sysContexts->lib, "WelsDestroyDecoder", pWelsDestroyDecoder);
478 sysContexts->WelsCreateSVCEncoder =
479 GetProcAddressAs(sysContexts->lib, "WelsCreateSVCEncoder", pWelsCreateSVCEncoder);
480 sysContexts->WelsDestroySVCEncoder =
481 GetProcAddressAs(sysContexts->lib, "WelsDestroySVCEncoder", pWelsDestroySVCEncoder);
482
483 if (!sysContexts->WelsCreateDecoder || !sysContexts->WelsDestroyDecoder ||
484 !sysContexts->WelsCreateSVCEncoder || !sysContexts->WelsDestroySVCEncoder ||
485 !sysContexts->WelsGetCodecVersionEx)
486 {
487 FreeLibrary(sysContexts->lib);
488 sysContexts->lib = NULL;
489 return FALSE;
490 }
491
492 sysContexts->WelsGetCodecVersionEx(&sysContexts->version);
493 WLog_Print(h264->log, WLOG_INFO, "loaded %s %d.%d.%d", name, sysContexts->version.uMajor,
494 sysContexts->version.uMinor, sysContexts->version.uRevision);
495
496 if ((sysContexts->version.uMajor < 1) ||
497 ((sysContexts->version.uMajor == 1) && (sysContexts->version.uMinor < 6)))
498 {
499 WLog_Print(
500 h264->log, WLOG_ERROR,
501 "OpenH264 %s %d.%d.%d is too old, need at least version 1.6.0 for dynamic loading",
502 name, sysContexts->version.uMajor, sysContexts->version.uMinor,
503 sysContexts->version.uRevision);
504 FreeLibrary(sysContexts->lib);
505 sysContexts->lib = NULL;
506 return FALSE;
507 }
508
509 return TRUE;
510}
511#endif
512
513static BOOL openh264_init(H264_CONTEXT* h264)
514{
515#if defined(WITH_OPENH264_LOADING)
516 BOOL success = FALSE;
517#endif
518 long status = 0;
519 H264_CONTEXT_OPENH264* sysContexts = NULL;
520 static int traceLevel = WELS_LOG_DEBUG;
521#if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <= 5)
522 static EVideoFormatType videoFormat = videoFormatI420;
523#endif
524 static WelsTraceCallback traceCallback = openh264_trace_callback;
525
526 WINPR_ASSERT(h264);
527
528 h264->numSystemData = 1;
529 sysContexts =
530 (H264_CONTEXT_OPENH264*)calloc(h264->numSystemData, sizeof(H264_CONTEXT_OPENH264));
531
532 if (!sysContexts)
533 goto EXCEPTION;
534
535 h264->pSystemData = (void*)sysContexts;
536#if defined(WITH_OPENH264_LOADING)
537
538 for (size_t i = 0; i < ARRAYSIZE(openh264_library_names); i++)
539 {
540 const char* current = openh264_library_names[i];
541 success = openh264_load_functionpointers(h264, current);
542
543 if (success)
544 break;
545 }
546
547 if (!success)
548 goto EXCEPTION;
549
550#else
551 sysContexts->WelsGetCodecVersionEx = WelsGetCodecVersionEx;
552 sysContexts->WelsCreateDecoder = WelsCreateDecoder;
553 sysContexts->WelsDestroyDecoder = WelsDestroyDecoder;
554 sysContexts->WelsCreateSVCEncoder = WelsCreateSVCEncoder;
555 sysContexts->WelsDestroySVCEncoder = WelsDestroySVCEncoder;
556#endif
557
558 for (UINT32 x = 0; x < h264->numSystemData; x++)
559 {
560 SDecodingParam sDecParam = { 0 };
561 H264_CONTEXT_OPENH264* sys = &sysContexts[x];
562
563 if (h264->Compressor)
564 {
565 sysContexts->WelsCreateSVCEncoder(&sys->pEncoder);
566
567 if (!sys->pEncoder)
568 {
569 WLog_Print(h264->log, WLOG_ERROR, "Failed to create OpenH264 encoder");
570 goto EXCEPTION;
571 }
572 }
573 else
574 {
575 sysContexts->WelsCreateDecoder(&sys->pDecoder);
576
577 if (!sys->pDecoder)
578 {
579 WLog_Print(h264->log, WLOG_ERROR, "Failed to create OpenH264 decoder");
580 goto EXCEPTION;
581 }
582
583#if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <= 5)
584 sDecParam.eOutputColorFormat = videoFormatI420;
585#endif
586 sDecParam.eEcActiveIdc = ERROR_CON_FRAME_COPY;
587 sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
588 status = (*sys->pDecoder)->Initialize(sys->pDecoder, &sDecParam);
589
590 if (status != 0)
591 {
592 WLog_Print(h264->log, WLOG_ERROR,
593 "Failed to initialize OpenH264 decoder (status=%ld)", status);
594 goto EXCEPTION;
595 }
596
597#if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <= 5)
598 status =
599 (*sys->pDecoder)->SetOption(sys->pDecoder, DECODER_OPTION_DATAFORMAT, &videoFormat);
600#endif
601
602 if (status != 0)
603 {
604 WLog_Print(h264->log, WLOG_ERROR,
605 "Failed to set data format option on OpenH264 decoder (status=%ld)",
606 status);
607 goto EXCEPTION;
608 }
609
610 if (WLog_GetLogLevel(h264->log) == WLOG_TRACE)
611 {
612 status = (*sys->pDecoder)
613 ->SetOption(sys->pDecoder, DECODER_OPTION_TRACE_LEVEL, &traceLevel);
614
615 if (status != 0)
616 {
617 WLog_Print(h264->log, WLOG_ERROR,
618 "Failed to set trace level option on OpenH264 decoder (status=%ld)",
619 status);
620 goto EXCEPTION;
621 }
622
623 status = (*sys->pDecoder)
624 ->SetOption(sys->pDecoder, DECODER_OPTION_TRACE_CALLBACK_CONTEXT,
625 (void*)&h264);
626
627 if (status != 0)
628 {
629 WLog_Print(h264->log, WLOG_ERROR,
630 "Failed to set trace callback context option on OpenH264 decoder "
631 "(status=%ld)",
632 status);
633 goto EXCEPTION;
634 }
635
636 status = (*sys->pDecoder)
637 ->SetOption(sys->pDecoder, DECODER_OPTION_TRACE_CALLBACK,
638 (void*)&traceCallback);
639
640 if (status != 0)
641 {
642 WLog_Print(
643 h264->log, WLOG_ERROR,
644 "Failed to set trace callback option on OpenH264 decoder (status=%ld)",
645 status);
646 goto EXCEPTION;
647 }
648 }
649 }
650 }
651
652 h264->hwAccel = FALSE; /* not supported */
653 return TRUE;
654EXCEPTION:
655 openh264_uninit(h264);
656 return FALSE;
657}
658
659const H264_CONTEXT_SUBSYSTEM g_Subsystem_OpenH264 = { "OpenH264", openh264_init, openh264_uninit,
660 openh264_decompress, openh264_compress };