| 298 | } |
| 299 | |
| 300 | bool decoderDav1d::decodeFrame() |
| 301 | { |
| 302 | if (decoder == nullptr) |
| 303 | return false; |
| 304 | |
| 305 | curPicture.clear(); |
| 306 | |
| 307 | int res = this->lib.dav1d_get_picture(decoder, curPicture.getPicture()); |
| 308 | if (res >= 0) |
| 309 | { |
| 310 | // We did get a picture |
| 311 | // Get the resolution / yuv format from the frame |
| 312 | auto s = curPicture.getFrameSize(); |
| 313 | if (!s.isValid()) |
| 314 | DEBUG_DAV1D("decoderDav1d::decodeFrame got invalid frame size"); |
| 315 | auto subsampling = curPicture.getSubsampling(); |
| 316 | if (subsampling == Subsampling::UNKNOWN) |
| 317 | DEBUG_DAV1D("decoderDav1d::decodeFrame got invalid subsampling"); |
| 318 | auto bitDepth = functions::clipToUnsigned(curPicture.getBitDepth()); |
| 319 | if (bitDepth < 8 || bitDepth > 16) |
| 320 | DEBUG_DAV1D("decoderDav1d::decodeFrame got invalid bit depth"); |
| 321 | |
| 322 | if (!frameSize.isValid() && !formatYUV.isValid()) |
| 323 | { |
| 324 | // Set the values |
| 325 | frameSize = s; |
| 326 | formatYUV = video::yuv::PixelFormatYUV(subsampling, bitDepth); |
| 327 | } |
| 328 | else |
| 329 | { |
| 330 | // Check the values against the previously set values |
| 331 | if (frameSize != s) |
| 332 | return setErrorB("Received a frame of different size"); |
| 333 | if (formatYUV.getSubsampling() != subsampling) |
| 334 | return setErrorB("Received a frame with different subsampling"); |
| 335 | if (formatYUV.getBitsPerSample() != bitDepth) |
| 336 | return setErrorB("Received a frame with different bit depth"); |
| 337 | } |
| 338 | DEBUG_DAV1D("decoderDav1d::decodeFrame Picture decoded - switching to retrieve frame mode"); |
| 339 | |
| 340 | decoderState = DecoderState::RetrieveFrames; |
| 341 | currentOutputBuffer.clear(); |
| 342 | return true; |
| 343 | } |
| 344 | else if (res != -EAGAIN) |
| 345 | return setErrorB("Error retrieving frame from decoder."); |
| 346 | |
| 347 | if (decoderState != DecoderState::NeedsMoreData) |
| 348 | DEBUG_DAV1D("decoderDav1d::decodeFrame No frame available - switching back to data push mode"); |
| 349 | decoderState = DecoderState::NeedsMoreData; |
| 350 | return false; |
| 351 | } |
| 352 | |
| 353 | QByteArray decoderDav1d::getRawFrameData() |
| 354 | { |
nothing calls this directly
no test coverage detected