MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / init

Method init

framework/utils/pixelBufferConvertor.cpp:342–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342int pixelBufferConvertor::init(const IAFFrame::videoInfo &src)
343{
344 // TODO: get the dst format
345 enum AVPixelFormat dstFormat;
346 IAFFrame::videoInfo dst = src;
347 switch (src.format) {
348 case AF_PIX_FMT_UYVY422:
349 case AF_PIX_FMT_NV12:
350 case AF_PIX_FMT_YUV420P:
351 // break;
352 default:
353 dst.format = AV_PIX_FMT_NV12;
354 }
355
356
357 if (mPixBufPool) {
358 CVPixelBufferPoolRelease(mPixBufPool);
359 }
360
361 mPixBufPool = cvpxpool_create(dst, 3);
362
363 if (mPixBufPool == nullptr) {
364 return -EINVAL;
365 }
366
367
368 if (sws_ctx) {
369 sws_freeContext(sws_ctx);
370 sws_ctx = nullptr;
371 }
372 av_frame_free(&mOutFrame);
373 dstFormat = static_cast<AVPixelFormat>(dst.format);
374
375 if (src != dst) {
376
377 sws_ctx = sws_getContext(src.width, src.height, static_cast<AVPixelFormat>(src.format), src.width, src.height, dstFormat,
378 SWS_BILINEAR, nullptr, nullptr, nullptr);
379 mOutFrame = alloc_picture(dstFormat, src.width, src.height);
380 }
381 return 0;
382}
383
384IAFFrame *pixelBufferConvertor::convert(IAFFrame *frame)
385{

Callers

nothing calls this directly

Calls 2

cvpxpool_createFunction · 0.85
alloc_pictureFunction · 0.85

Tested by

no test coverage detected