| 340 | } |
| 341 | |
| 342 | int 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 | |
| 384 | IAFFrame *pixelBufferConvertor::convert(IAFFrame *frame) |
| 385 | { |
nothing calls this directly
no test coverage detected