summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-07-12 10:42:49 +0200
committerAnton Khirnov <anton@khirnov.net>2022-08-23 16:47:48 +0200
commit68413d4ee19d716205f950e3bd81ea511e2051cb (patch)
tree2c71a0e7d7cf131a5affd35bde2b25abb270eb14
parent2e14032bc97eb2e575da59378d09b8f9009c0425 (diff)
lavc/encode: combine setting no-delay pts for video/audio
-rw-r--r--libavcodec/encode.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index d0c3903258..da910b1b60 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -209,12 +209,8 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
* (due to the delay inherent in frame threaded encoding, it makes
* no sense to use the properties of the current frame anyway). */
ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
- else {
+ else
ret = codec->cb.encode(avctx, avpkt, frame, &got_packet);
- if (avctx->codec->type == AVMEDIA_TYPE_VIDEO && !ret && got_packet &&
- !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
- avpkt->pts = frame->pts;
- }
av_assert0(ret <= 0);
@@ -227,10 +223,14 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
goto end;
}
- if (frame && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
+ // set the timestamps for the simple no-delay case
+ // encoders with delay have to set the timestamps themselves
+ if (!(avctx->active_thread_type & FF_THREAD_FRAME) &&
+ !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
+ if (avpkt->pts == AV_NOPTS_VALUE)
+ avpkt->pts = frame->pts;
+
if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
- if (avpkt->pts == AV_NOPTS_VALUE)
- avpkt->pts = frame->pts;
if (!avpkt->duration)
avpkt->duration = ff_samples_to_time_base(avctx,
frame->nb_samples);