| 483 | } |
| 484 | |
| 485 | void decoderVVDec::copyImgToByteArray(QByteArray &dst) |
| 486 | { |
| 487 | auto fmt = this->currentFrame->colorFormat; |
| 488 | if (fmt == VVDEC_CF_INVALID) |
| 489 | { |
| 490 | DEBUG_vvdec("decoderVVDec::copyImgToByteArray picture format is unknown"); |
| 491 | return; |
| 492 | } |
| 493 | const auto nrPlanes = this->currentFrame->numPlanes; |
| 494 | const auto bytesPerSample = this->currentFrame->bitDepth > 8 ? 2 : 1; |
| 495 | const auto lumaSize = Size({this->currentFrame->width, this->currentFrame->height}); |
| 496 | const auto chromaSize = calculateChromaSize(lumaSize, fmt); |
| 497 | |
| 498 | auto outSizeLumaBytes = lumaSize.width * lumaSize.height * bytesPerSample; |
| 499 | auto outSizeChromaBytes = chromaSize.width * chromaSize.height * bytesPerSample; |
| 500 | // How many bytes do we need in the output buffer? |
| 501 | auto nrBytesOutput = (outSizeLumaBytes + outSizeChromaBytes * 2); |
| 502 | DEBUG_vvdec("decoderVVDec::copyImgToByteArray nrBytesOutput %d", nrBytesOutput); |
| 503 | |
| 504 | // Is the output big enough? |
| 505 | if (dst.capacity() < int(nrBytesOutput)) |
| 506 | dst.resize(int(nrBytesOutput)); |
| 507 | |
| 508 | for (unsigned c = 0; c < nrPlanes; c++) |
| 509 | { |
| 510 | auto &component = this->currentFrame->planes[c]; |
| 511 | |
| 512 | auto widthBytes = component.width * bytesPerSample; |
| 513 | auto plane = component.ptr; |
| 514 | |
| 515 | if (component.ptr == nullptr) |
| 516 | { |
| 517 | DEBUG_vvdec("decoderVVDec::copyImgToByteArray unable to get plane for component %d", c); |
| 518 | return; |
| 519 | } |
| 520 | |
| 521 | unsigned char *restrict d = (unsigned char *)dst.data(); |
| 522 | if (c > 0) |
| 523 | d += outSizeLumaBytes; |
| 524 | if (c == 2) |
| 525 | d += outSizeChromaBytes; |
| 526 | |
| 527 | for (unsigned y = 0; y < component.height; y++) |
| 528 | { |
| 529 | std::memcpy(d, plane, widthBytes); |
| 530 | plane += component.stride; |
| 531 | d += widthBytes; |
| 532 | } |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | QString decoderVVDec::getDecoderName() const |
| 537 | { |
nothing calls this directly
no test coverage detected