avcodec/encode, frame_thread_encoder: Unify calling encode callback
The encode-callback (the callback used by the FF_CODEC_CB_TYPE_ENCODE encoders) is currently called in two places: encode_simple_internal() and by the worker threads of frame-threaded encoders. After the call, some packet properties are set based upon the corresponding AVFrame properties and the packet is made refcounted if it isn't already. So there is some code duplication. There was also non-duplicated code in encode_simple_internal() which is executed even when using frame-threading. This included an emms_c() (which is needed for frame-threading, too, if it is needed for the single-threaded case, because there are allocations (via av_packet_make_refcounted()) immediately after returning from the encode-callback). Furthermore, some further properties are only set in encode_simple_internal(): For audio, pts and duration are derived from the corresponding fields of the frame if the encoder does not have the AV_CODEC_CAP_DELAY set. Yet this is wrong for frame-threaded encoders, because frame-threading always introduces delay regardless of whether the underlying codec has said cap. This only worked because there are no frame-threaded audio encoders. This commit fixes the code duplication and the above issue by factoring this code out and reusing it in both places. It would work in case of audio codecs with frame-threading, because now the values are derived from the correct AVFrame. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
4dddcd08c4
commit
1e6307f46c
3 changed files with 50 additions and 54 deletions
|
|
@ -75,4 +75,7 @@ int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size);
|
|||
*/
|
||||
int ff_encode_preinit(AVCodecContext *avctx);
|
||||
|
||||
int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
const AVFrame *frame, int *got_packet);
|
||||
|
||||
#endif /* AVCODEC_ENCODE_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue