summaryrefslogtreecommitdiff
path: root/libavcodec/encode.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/encode.c')
-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);