@@ -118,16 +118,6 @@ typedef struct MPVContext {
Picture **input_picture; ///< next pictures on display order for encoding
Picture **reordered_input_picture; ///< pointer to the next pictures in coded order for encoding
- int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_send_frame()
- /**
- * pts difference between the first and second input frame, used for
- * calculating dts of the first frame when there's a delay */
- int64_t dts_delta;
- /**
- * reordered pts to be used as dts for the next output frame when there's
- * a delay */
- int64_t reordered_pts;
-
/** bit output */
PutBitContext pb;
@@ -391,7 +391,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "intra dc precision too large\n");
return AVERROR(EINVAL);
}
- s->user_specified_pts = AV_NOPTS_VALUE;
+ m->user_specified_pts = AV_NOPTS_VALUE;
if (m->gop_size <= 1) {
s->intra_only = 1;
@@ -1023,8 +1023,8 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg)
display_picture_number = s->input_picture_number++;
if (pts != AV_NOPTS_VALUE) {
- if (s->user_specified_pts != AV_NOPTS_VALUE) {
- int64_t last = s->user_specified_pts;
+ if (m->user_specified_pts != AV_NOPTS_VALUE) {
+ int64_t last = m->user_specified_pts;
if (pts <= last) {
av_log(s->avctx, AV_LOG_ERROR,
@@ -1034,13 +1034,13 @@ static int load_input_picture(MPVMainEncContext *m, const AVFrame *pic_arg)
}
if (!s->low_delay && display_picture_number == 1)
- s->dts_delta = pts - last;
+ m->dts_delta = pts - last;
}
- s->user_specified_pts = pts;
+ m->user_specified_pts = pts;
} else {
- if (s->user_specified_pts != AV_NOPTS_VALUE) {
- s->user_specified_pts =
- pts = s->user_specified_pts + 1;
+ if (m->user_specified_pts != AV_NOPTS_VALUE) {
+ m->user_specified_pts =
+ pts = m->user_specified_pts + 1;
av_log(s->avctx, AV_LOG_INFO,
"Warning: AVFrame.pts=? trying to guess (%"PRId64")\n",
pts);
@@ -1889,10 +1889,10 @@ vbv_retry:
pkt->pts = s->current_picture.f->pts;
if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {
if (!s->current_picture.f->coded_picture_number)
- pkt->dts = pkt->pts - s->dts_delta;
+ pkt->dts = pkt->pts - m->dts_delta;
else
- pkt->dts = s->reordered_pts;
- s->reordered_pts = pkt->pts;
+ pkt->dts = m->reordered_pts;
+ m->reordered_pts = pkt->pts;
} else
pkt->dts = pkt->pts;
if (s->current_picture.f->key_frame)
@@ -45,6 +45,17 @@ typedef struct MPVMainEncContext {
int gop_size;
int picture_in_gop_number; ///< 0-> first pic in gop, ...
+ /** last non-zero pts from AVFrame which was passed into avcodec_send_frame() */
+ int64_t user_specified_pts;
+ /**
+ * pts difference between the first and second input frame, used for
+ * calculating dts of the first frame when there's a delay */
+ int64_t dts_delta;
+ /**
+ * reordered pts to be used as dts for the next output frame when there's
+ * a delay */
+ int64_t reordered_pts;
+
/* bit rate control */
int64_t total_bits;
int frame_bits; ///< bits used for the current frame
user_specified_pts, dts_delta and reordered_pts are only used by the main thread. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mpegvideo.h | 10 ---------- libavcodec/mpegvideo_enc.c | 22 +++++++++++----------- libavcodec/mpegvideoenc.h | 11 +++++++++++ 3 files changed, 22 insertions(+), 21 deletions(-)