Move producer/consumer frames out of video buffer
The video buffer held 3 frames: - the producer frame (for decoding) - the pending frame (to exchange between the producer and consumer) - the consumer frame (for rendering) It worked well, but it prevented video buffers to be chained, because the consumer frame of the first video buffer must be the same as the producer frame of the second video buffer. To solve this problem, make the decoder and the screen handle their own frames, and keep only the pending frame in the video_buffer. This paves the way to support asynchronous swscale.
This commit is contained in:
@@ -29,9 +29,7 @@ typedef struct AVFrame AVFrame;
|
||||
*/
|
||||
|
||||
struct video_buffer {
|
||||
AVFrame *producer_frame;
|
||||
AVFrame *pending_frame;
|
||||
AVFrame *consumer_frame;
|
||||
|
||||
sc_mutex mutex;
|
||||
bool wait_consumer; // never overwrite a pending frame if it is not consumed
|
||||
@@ -67,13 +65,14 @@ video_buffer_set_consumer_callbacks(struct video_buffer *vb,
|
||||
void *cbs_userdata);
|
||||
|
||||
// set the producer frame as ready for consuming
|
||||
// the produced frame is exchanged with an unused allocated frame
|
||||
void
|
||||
video_buffer_producer_offer_frame(struct video_buffer *vb);
|
||||
video_buffer_producer_offer_frame(struct video_buffer *vb, AVFrame **pframe);
|
||||
|
||||
// mark the consumer frame as consumed and return it
|
||||
// the frame is valid until the next call to this function
|
||||
const AVFrame *
|
||||
video_buffer_consumer_take_frame(struct video_buffer *vb);
|
||||
// mark the consumer frame as consumed and exchange it with an unused allocated
|
||||
// frame
|
||||
void
|
||||
video_buffer_consumer_take_frame(struct video_buffer *vb, AVFrame **pframe);
|
||||
|
||||
// wake up and avoid any blocking call
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user