diff options
author | wm4 <wm4@nowhere> | 2018-04-29 19:42:18 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-05-03 01:08:44 +0300 |
commit | 0ab3184526e7b9b95c06a3ec7a6674283a5922d0 (patch) | |
tree | 4c05b192e65b51c68f3024b4b7946dcb79caf404 /common/encode_lavc.h | |
parent | 958053ff56109a38e9f8e0a0aa8786a5f47adb7c (diff) | |
download | mpv-0ab3184526e7b9b95c06a3ec7a6674283a5922d0.tar.bz2 mpv-0ab3184526e7b9b95c06a3ec7a6674283a5922d0.tar.xz |
encode: get rid of the output packet queue
Until recently, ao_lavc and vo_lavc started encoding whenever the core
happened to send them data. Since audio and video are not initialized at
the same time, and the muxer was not necessarily opened when the first
encoder started to produce data, the resulting packets were put into a
queue. As soon as the muxer was opened, the queue was flushed.
Change this to make the core wait with sending data until all encoders
are initialized. This has the advantage that we don't need to queue up
the packets.
Diffstat (limited to 'common/encode_lavc.h')
-rw-r--r-- | common/encode_lavc.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/common/encode_lavc.h b/common/encode_lavc.h index a689b1ea47..97c2cf01f1 100644 --- a/common/encode_lavc.h +++ b/common/encode_lavc.h @@ -101,7 +101,12 @@ struct encoder_context *encoder_context_alloc(struct encode_lavc_context *ctx, // After setting your codec parameters on p->encoder, you call this to "open" // the encoder. This also initializes p->mux_stream. Returns false on failure. -bool encoder_init_codec_and_muxer(struct encoder_context *p); +// on_ready is called as soon as the muxer has been initialized. Then you are +// allowed to write packets with encoder_encode(). +// Warning: the on_ready callback is called asynchronously, so you need to +// make sure to properly synchronize everything. +bool encoder_init_codec_and_muxer(struct encoder_context *p, + void (*on_ready)(void *ctx), void *ctx); // Encode the frame and write the packet. frame is ref'ed as need. bool encoder_encode(struct encoder_context *p, AVFrame *frame); |