diff mbox series

[FFmpeg-devel,2/3] avcodec/libwebpenc_animencoder: set the correct packet pts

Message ID 20210411021238.29014-2-jamrial@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/3] avcodec/libwebpenc_animencoder: stop propagating bogus empty packets | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer April 11, 2021, 2:12 a.m. UTC
The only packet produced by this encoder contains the entire animated stream,
so its pts is 0.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/libwebpenc_animencoder.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Anton Khirnov April 11, 2021, 9:49 a.m. UTC | #1
Quoting James Almer (2021-04-11 04:12:37)
> The only packet produced by this encoder contains the entire animated stream,
> so its pts is 0.

Shouldn't it rather save the first frame's pts? It does not always have
to be 0.
diff mbox series

Patch

diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c
index 633af2e925..ff36b865f8 100644
--- a/libavcodec/libwebpenc_animencoder.c
+++ b/libavcodec/libwebpenc_animencoder.c
@@ -32,7 +32,6 @@ 
 typedef struct LibWebPAnimContext {
     LibWebPContextCommon cc;
     WebPAnimEncoder *enc;     // the main AnimEncoder object
-    int64_t prev_frame_pts;   // pts of the previously encoded frame.
     int done;                 // If true, we have assembled the bitstream already
 } LibWebPAnimContext;
 
@@ -48,7 +47,6 @@  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->done = 0;
     }
     return ret;
@@ -73,7 +71,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 = 0;
                 *got_packet = 1;
                 return 0;
             } else {
@@ -102,7 +100,6 @@  static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             goto end;
         }
 
-        s->prev_frame_pts = frame->pts;  // Save for next frame.
         ret = 0;
         *got_packet = 0;