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

Method pushData

YUViewLib/src/decoder/decoderDav1d.cpp:381–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381bool decoderDav1d::pushData(QByteArray &data)
382{
383 if (decoderState != DecoderState::NeedsMoreData)
384 {
385 DEBUG_DAV1D("decoderDav1d::pushData: Wrong decoder state.");
386 return false;
387 }
388 if (flushing)
389 {
390 DEBUG_DAV1D("decoderDav1d::pushData: Do not push data when flushing!");
391 return false;
392 }
393
394 if (!sequenceHeaderPushed)
395 {
396 // The first packet which is pushed to the decoder should be a sequence header.
397 // Otherwise, the decoder can not decode the data.
398 if (data.size() == 0)
399 {
400 DEBUG_DAV1D(
401 "decoderDav1d::pushData Error: Sequence header not pushed yet and the data is empty");
402 return setErrorB("Error: Sequence header not pushed yet and the data is empty.");
403 }
404
405 Dav1dSequenceHeader seq;
406 int err =
407 this->lib.dav1d_parse_sequence_header(&seq, (const uint8_t *)data.data(), data.size());
408 if (err == 0)
409 {
410 sequenceHeaderPushed = true;
411
412 auto s = Size(seq.max_width, seq.max_height);
413 if (!s.isValid())
414 DEBUG_DAV1D("decoderDav1d::pushData got invalid frame size");
415 auto subsampling = convertFromInternalSubsampling(seq.layout);
416 if (subsampling == Subsampling::UNKNOWN)
417 DEBUG_DAV1D("decoderDav1d::pushData got invalid subsampling");
418 int bitDepth = (seq.hbd == 0 ? 8 : (seq.hbd == 1 ? 10 : (seq.hbd == 2 ? 12 : -1)));
419 if (bitDepth < 8 || bitDepth > 16)
420 DEBUG_DAV1D("decoderDav1d::pushData got invalid bit depth");
421 subBlockSize = (seq.sb128 >= 1) ? 128 : 64;
422
423 this->frameSize = s;
424 this->formatYUV = video::yuv::PixelFormatYUV(subsampling, bitDepth);
425 }
426 else
427 {
428 DEBUG_DAV1D("decoderDav1d::pushData Error: No sequence header revieved yet and parsing of "
429 "this packet as slice header failed. Ignoring packet.");
430 return true;
431 }
432 }
433
434 if (data.size() == 0)
435 {
436 // The input file is at the end. Switch to flushing mode.
437 DEBUG_DAV1D("decoderDav1d::pushData input ended - flushing");
438 flushing = true;

Callers

nothing calls this directly

Calls 6

SizeClass · 0.85
PixelFormatYUVClass · 0.85
sizeMethod · 0.45
dataMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected