MCPcopy Create free account
hub / github.com/Nevcairiel/LAVFilters / InitDecoder

Method InitDecoder

decoder/LAVVideo/decoders/quicksync.cpp:462–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462STDMETHODIMP CDecQuickSync::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)
463{
464 HRESULT hr = S_OK;
465 DbgLog((LOG_TRACE, 10, L"CDecQuickSync::InitDecoder(): Initializing QuickSync decoder"));
466
467 DestroyDecoder(false);
468
469 FOURCC fourCC = (FOURCC)0;
470 for (int i = 0; i < countof(quicksync_codecs); i++)
471 {
472 if (quicksync_codecs[i].ffcodec == codec)
473 {
474 fourCC = quicksync_codecs[i].fourCC;
475 break;
476 }
477 }
478
479 if (fourCC == 0)
480 {
481 DbgLog((LOG_TRACE, 10, L"-> Codec id %d does not map to a QuickSync FourCC codec", codec));
482 return E_FAIL;
483 }
484
485 m_pDecoder = qs.create();
486 if (!m_pDecoder || !m_pDecoder->getOK())
487 {
488 DbgLog((LOG_TRACE, 10, L"-> Decoder creation failed"));
489 return E_FAIL;
490 }
491 m_pDecoder->SetDeliverSurfaceCallback(this, &QS_DeliverSurfaceCallback);
492
493 m_nAVCNalSize = 0;
494 if (pmt->subtype == MEDIASUBTYPE_AVC1 || pmt->subtype == MEDIASUBTYPE_avc1 || pmt->subtype == MEDIASUBTYPE_CCV1)
495 {
496 if (pmt->formattype == FORMAT_MPEG2Video)
497 {
498 MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)pmt->pbFormat;
499 fourCC = FourCC_AVC1;
500 m_bAVC1 = TRUE;
501 m_nAVCNalSize = mp2vi->dwFlags;
502 }
503 else
504 {
505 DbgLog((LOG_TRACE, 10, L"-> AVC1 without MPEG2VIDEOINFO not supported"));
506 return E_FAIL;
507 }
508 }
509
510 BYTE *extradata = nullptr;
511 size_t extralen = 0;
512 getExtraData(*pmt, nullptr, &extralen);
513 if (extralen > 0)
514 {
515 extradata = (BYTE *)av_malloc(extralen + AV_INPUT_BUFFER_PADDING_SIZE);
516 if (extradata == nullptr)
517 return E_OUTOFMEMORY;
518 getExtraData(*pmt, extradata, nullptr);
519 }

Callers

nothing calls this directly

Calls 11

getExtraDataFunction · 0.85
videoFormatTypeHandlerFunction · 0.85
GetHWAccelDeintModeMethod · 0.80
GetHWAccelDeintOutputMethod · 0.80
GetDeinterlacingModeMethod · 0.80
GetDeintFieldOrderMethod · 0.80
SetTypeMethod · 0.80
FormatTypeMethod · 0.80
FormatMethod · 0.80
SetSubtypeMethod · 0.80

Tested by

no test coverage detected