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

Method pushAVPacket

YUViewLib/src/decoder/decoderFFmpeg.cpp:322–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322bool decoderFFmpeg::pushAVPacket(FFmpeg::AVPacketWrapper &pkt)
323{
324 if (this->decoderState != DecoderState::NeedsMoreData)
325 {
326 DEBUG_FFMPEG("decoderFFmpeg::pushAVPacket: Wrong decoder state.");
327 return false;
328 }
329 if (!pkt)
330 {
331 DEBUG_FFMPEG("decoderFFmpeg::pushAVPacket: Received empty packet. Swithing to flushing.");
332 this->flushing = true;
333 this->decoderState = DecoderState::RetrieveFrames;
334 return false;
335 }
336 if (this->flushing)
337 {
338 DEBUG_FFMPEG(
339 "decoderFFmpeg::pushAVPacket: Error no new packets should be pushed in flushing mode.");
340 return false;
341 }
342
343 // Push the packet to the decoder
344 int retPush = this->ff.pushPacketToDecoder(decCtx, pkt);
345
346 if (retPush < 0 && retPush != AVERROR(EAGAIN))
347 {
348#if DECODERFFMPEG_DEBUG_OUTPUT
349 {
350 QString meaning =
351 QString("decoderFFmpeg::pushAVPacket: Error sending packet - err %1").arg(retPush);
352 if (retPush == -1094995529)
353 meaning += " INDA";
354 // Log the first bytes
355 meaning += " B(";
356 int nrBytes = std::min(pkt.getDataSize(), 5);
357 uint8_t *data = pkt.getData();
358 for (int i = 0; i < nrBytes; i++)
359 {
360 uint8_t b = data[i];
361 meaning += QString(" %1").arg(b, 2, 16);
362 }
363 meaning += ")";
364 qDebug() << meaning;
365 }
366#endif
367 this->setError(QStringLiteral("Error sending packet (avcodec_send_packet)"));
368 return false;
369 }
370 else
371 DEBUG_FFMPEG("decoderFFmpeg::pushAVPacket: Send packet PTS " << pkt.getPTS() << " duration "
372 << pkt.getDuration() << " flags "
373 << pkt.getFlags());
374
375 if (retPush == AVERROR(EAGAIN))
376 {
377 // Enough data pushed. Decode and retrieve frames now.
378 DEBUG_FFMPEG(
379 "decoderFFmpeg::pushAVPacket: Enough data pushed. Decode and retrieve frames now.");

Callers 2

pushDataMethod · 0.95
loadRawDataMethod · 0.80

Calls 7

pushPacketToDecoderMethod · 0.80
getDataSizeMethod · 0.80
getFlagsMethod · 0.80
getDataMethod · 0.45
setErrorMethod · 0.45
getPTSMethod · 0.45
getDurationMethod · 0.45

Tested by

no test coverage detected