diff options
author | James Almer <jamrial@gmail.com> | 2021-04-10 23:06:36 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-04-16 11:08:24 -0300 |
commit | 2e17b169f74bf8136385c554d36bbf4cabc6537d (patch) | |
tree | f7d9ca5410e7570343594e848a7a60545ce1a07b | |
parent | ab7a0a4cc23e3ff222714a58ce24fc6287a68585 (diff) | |
download | ffmpeg-2e17b169f74bf8136385c554d36bbf4cabc6537d.tar.gz |
avcodec/libwebpenc_animencoder: set the correct packet pts
The only packet produced by this encoder contains the entire animated stream,
so set its pts to the first frame encoded.
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libavcodec/libwebpenc_animencoder.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c index 633af2e925..835891d890 100644 --- a/libavcodec/libwebpenc_animencoder.c +++ b/libavcodec/libwebpenc_animencoder.c @@ -32,7 +32,7 @@ typedef struct LibWebPAnimContext { LibWebPContextCommon cc; WebPAnimEncoder *enc; // the main AnimEncoder object - int64_t prev_frame_pts; // pts of the previously encoded frame. + int64_t first_frame_pts; // pts of the first encoded frame. int done; // If true, we have assembled the bitstream already } LibWebPAnimContext; @@ -48,7 +48,7 @@ static av_cold int libwebp_anim_encode_init(AVCodecContext *avctx) s->enc = WebPAnimEncoderNew(avctx->width, avctx->height, &enc_options); if (!s->enc) return AVERROR(EINVAL); - s->prev_frame_pts = -1; + s->first_frame_pts = AV_NOPTS_VALUE; s->done = 0; } return ret; @@ -73,7 +73,7 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt, memcpy(pkt->data, assembled_data.bytes, assembled_data.size); s->done = 1; pkt->flags |= AV_PKT_FLAG_KEY; - pkt->pts = pkt->dts = s->prev_frame_pts + 1; + pkt->pts = pkt->dts = s->first_frame_pts; *got_packet = 1; return 0; } else { @@ -102,7 +102,8 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt, goto end; } - s->prev_frame_pts = frame->pts; // Save for next frame. + if (!avctx->frame_number) + s->first_frame_pts = frame->pts; ret = 0; *got_packet = 0; |