History

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.

James Almer committed 5 years ago

Commit 2e17b161 parent ab7a0a41 file · +5 −4Browse files

Unified · Split

libavcodec/libwebpenc_animencoder.c+5−4
@@ -32,7 +32,7 @@ · 31 unmodified lines
32typedef struct LibWebPAnimContext {32typedef struct LibWebPAnimContext {
33 LibWebPContextCommon cc;33 LibWebPContextCommon cc;
34 WebPAnimEncoder *enc; // the main AnimEncoder object34 WebPAnimEncoder *enc; // the main AnimEncoder object
35 int64_t prev_frame_pts; // pts of the previously encoded frame.35 int64_t first_frame_pts; // pts of the first encoded frame.
36 int done; // If true, we have assembled the bitstream already36 int done; // If true, we have assembled the bitstream already
37} LibWebPAnimContext;37} LibWebPAnimContext;
38 38
@@ -48,7 +48,7 @@ static av_cold int libwebp_anim_encode_init(AVCodecContext *avctx) · 9 unmodified lines
48 s->enc = WebPAnimEncoderNew(avctx->width, avctx->height, &enc_options);48 s->enc = WebPAnimEncoderNew(avctx->width, avctx->height, &enc_options);
49 if (!s->enc)49 if (!s->enc)
50 return AVERROR(EINVAL);50 return AVERROR(EINVAL);
51 s->prev_frame_pts = -1;51 s->first_frame_pts = AV_NOPTS_VALUE;
52 s->done = 0;52 s->done = 0;
53 }53 }
54 return ret;54 return ret;
@@ -73,7 +73,7 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 18 unmodified lines
73 memcpy(pkt->data, assembled_data.bytes, assembled_data.size);73 memcpy(pkt->data, assembled_data.bytes, assembled_data.size);
74 s->done = 1;74 s->done = 1;
75 pkt->flags |= AV_PKT_FLAG_KEY;75 pkt->flags |= AV_PKT_FLAG_KEY;
76 pkt->pts = pkt->dts = s->prev_frame_pts + 1;76 pkt->pts = pkt->dts = s->first_frame_pts;
77 *got_packet = 1;77 *got_packet = 1;
78 return 0;78 return 0;
79 } else {79 } else {
@@ -102,7 +102,8 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 22 unmodified lines
102 goto end;102 goto end;
103 }103 }
104 104
105 s->prev_frame_pts = frame->pts; // Save for next frame.105 if (!avctx->frame_number)
106 s->first_frame_pts = frame->pts;
106 ret = 0;107 ret = 0;
107 *got_packet = 0;108 *got_packet = 0;
108 109

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t