Rewrite FFmpeg decoder to use pull model
This allows us to keep asynchronous decoders like MMAL and V4L2M2M fed while we're waiting for output frames. Behavior for synchronous decoders should be identical. Continuing to feed new data while waiting for output frames is crucial for acceptable performance on 1080p video on the Raspberry Pi using V4L2M2M, since it allows the decode and copy operations to be pipelined.
This commit is contained in:
parent
8a27fa7bb5
commit
d6cfbdb273
4 changed files with 165 additions and 119 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <QQueue>
|
||||
|
||||
#include "decoder.h"
|
||||
#include "ffmpeg-renderers/renderer.h"
|
||||
|
|
@ -54,6 +55,10 @@ private:
|
|||
enum AVPixelFormat ffGetFormat(AVCodecContext* context,
|
||||
const enum AVPixelFormat* pixFmts);
|
||||
|
||||
void decoderThreadProc();
|
||||
|
||||
static int decoderThreadProcThunk(void* context);
|
||||
|
||||
AVPacket* m_Pkt;
|
||||
AVCodecContext* m_VideoDecoderCtx;
|
||||
QByteArray m_DecodeBuffer;
|
||||
|
|
@ -74,11 +79,14 @@ private:
|
|||
int m_VideoFormat;
|
||||
bool m_NeedsSpsFixup;
|
||||
bool m_TestOnly;
|
||||
enum {
|
||||
RRF_UNKNOWN,
|
||||
RRF_YES,
|
||||
RRF_NO
|
||||
} m_CanRetryReceiveFrame;
|
||||
SDL_Thread* m_DecoderThread;
|
||||
SDL_atomic_t m_DecoderThreadShouldQuit;
|
||||
|
||||
typedef struct {
|
||||
uint64_t enqueueTimeMs;
|
||||
uint32_t presentationTimeMs;
|
||||
} FrameInfoTuple;
|
||||
QQueue<FrameInfoTuple> m_FrameInfoQueue;
|
||||
|
||||
static const uint8_t k_H264TestFrame[];
|
||||
static const uint8_t k_HEVCMainTestFrame[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue