MCPcopy Create free account
hub / github.com/IENT/YUView / getNextFrameFromDecoder

Method getNextFrameFromDecoder

YUViewLib/src/decoder/decoderVVDec.cpp:357–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355}
356
357bool decoderVVDec::getNextFrameFromDecoder()
358{
359 if (this->currentFrame == nullptr)
360 {
361 DEBUG_vvdec("decoderVVDec::getNextFrameFromDecoder No frame decoded");
362 return false;
363 }
364
365 // Check the validity of the picture
366 const auto lumaSize = Size({this->currentFrame->width, this->currentFrame->height});
367 const auto nrPlanes = (this->currentFrame->colorFormat == VVDEC_CF_YUV400_PLANAR) ? 1u : 3u;
368
369 // Check the validity of the picture
370 if (!lumaSize.isValid())
371 DEBUG_vvdec("decoderVVDec::getNextFrameFromDecoder got invalid size");
372 auto subsampling = convertFromInternalSubsampling(this->currentFrame->colorFormat);
373 if (subsampling == Subsampling::UNKNOWN)
374 DEBUG_vvdec("decoderVVDec::getNextFrameFromDecoder got invalid chroma format");
375 auto bitDepth = this->currentFrame->bitDepth;
376 if (bitDepth < 8 || bitDepth > 16)
377 DEBUG_vvdec("decoderVVDec::getNextFrameFromDecoder got invalid bit depth");
378 if (nrPlanes != this->currentFrame->numPlanes)
379 DEBUG_vvdec("decoderVVDec::getNextFrameFromDecoder got non expected number of planes");
380
381 for (unsigned i = 1; i < this->currentFrame->numPlanes; i++)
382 {
383 const auto &plane = this->currentFrame->planes[i];
384 auto expectedSize = calculateChromaSize(lumaSize, this->currentFrame->colorFormat);
385 if (expectedSize.width != plane.width || expectedSize.height != plane.height)
386 DEBUG_vvdec("decoderVVDec::getNextFrameFromDecoder plane has different size then expected");
387 }
388
389 if (!this->frameSize.isValid() && !this->formatYUV.isValid())
390 {
391 // Set the values
392 this->frameSize = lumaSize;
393 this->formatYUV = video::yuv::PixelFormatYUV(subsampling, bitDepth);
394 }
395 else
396 {
397 // Check the values against the previously set values
398 if (this->frameSize != lumaSize)
399 return setErrorB("Received a frame of different size");
400 if (this->formatYUV.getSubsampling() != subsampling)
401 return setErrorB("Received a frame with different subsampling");
402 if (unsigned(this->formatYUV.getBitsPerSample()) != bitDepth)
403 return setErrorB("Received a frame with different bit depth");
404 }
405
406 DEBUG_vvdec("decoderVVDec::getNextFrameFromDecoder got a valid frame");
407 return true;
408}
409
410bool decoderVVDec::pushData(QByteArray &data)
411{
412 if (decoderState != DecoderState::NeedsMoreData)
413 {
414 DEBUG_vvdec("decoderVVDec::pushData: Wrong decoder state.");

Callers 2

decodeNextFrameMethod · 0.95
pushDataMethod · 0.95

Calls 6

SizeClass · 0.85
calculateChromaSizeFunction · 0.85
PixelFormatYUVClass · 0.85
isValidMethod · 0.45
getSubsamplingMethod · 0.45

Tested by

no test coverage detected