mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-05-17 23:17:41 +08:00
avformat/mux: Don't allocate priv_pts separately
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -63,7 +63,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
av_parser_close(sti->parser);
|
av_parser_close(sti->parser);
|
||||||
avcodec_free_context(&sti->avctx);
|
avcodec_free_context(&sti->avctx);
|
||||||
av_bsf_free(&sti->bsfc);
|
av_bsf_free(&sti->bsfc);
|
||||||
av_freep(&sti->priv_pts);
|
|
||||||
av_freep(&sti->index_entries);
|
av_freep(&sti->index_entries);
|
||||||
av_freep(&sti->probe_data.buf);
|
av_freep(&sti->probe_data.buf);
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ typedef struct FFStream {
|
|||||||
|
|
||||||
int is_intra_only;
|
int is_intra_only;
|
||||||
|
|
||||||
FFFrac *priv_pts;
|
FFFrac priv_pts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stream information used internally by avformat_find_stream_info()
|
* Stream information used internally by avformat_find_stream_info()
|
||||||
|
@ -406,16 +406,11 @@ static int init_pts(AVFormatContext *s)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sti->priv_pts)
|
|
||||||
sti->priv_pts = av_mallocz(sizeof(*sti->priv_pts));
|
|
||||||
if (!sti->priv_pts)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
if (den != AV_NOPTS_VALUE) {
|
if (den != AV_NOPTS_VALUE) {
|
||||||
if (den <= 0)
|
if (den <= 0)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
frac_init(sti->priv_pts, 0, 0, den);
|
frac_init(&sti->priv_pts, 0, 0, den);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +545,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
|
|||||||
}
|
}
|
||||||
pkt->dts =
|
pkt->dts =
|
||||||
// pkt->pts= st->cur_dts;
|
// pkt->pts= st->cur_dts;
|
||||||
pkt->pts = sti->priv_pts->val;
|
pkt->pts = sti->priv_pts.val;
|
||||||
}
|
}
|
||||||
|
|
||||||
//calculate dts from pts
|
//calculate dts from pts
|
||||||
@ -587,7 +582,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
|
|||||||
av_ts2str(pkt->pts), av_ts2str(pkt->dts));
|
av_ts2str(pkt->pts), av_ts2str(pkt->dts));
|
||||||
|
|
||||||
sti->cur_dts = pkt->dts;
|
sti->cur_dts = pkt->dts;
|
||||||
sti->priv_pts->val = pkt->dts;
|
sti->priv_pts.val = pkt->dts;
|
||||||
|
|
||||||
/* update pts */
|
/* update pts */
|
||||||
switch (st->codecpar->codec_type) {
|
switch (st->codecpar->codec_type) {
|
||||||
@ -599,12 +594,12 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
|
|||||||
/* HACK/FIXME, we skip the initial 0 size packets as they are most
|
/* HACK/FIXME, we skip the initial 0 size packets as they are most
|
||||||
* likely equal to the encoder delay, but it would be better if we
|
* likely equal to the encoder delay, but it would be better if we
|
||||||
* had the real timestamps from the encoder */
|
* had the real timestamps from the encoder */
|
||||||
if (frame_size >= 0 && (pkt->size || sti->priv_pts->num != sti->priv_pts->den >> 1 || sti->priv_pts->val)) {
|
if (frame_size >= 0 && (pkt->size || sti->priv_pts.num != sti->priv_pts.den >> 1 || sti->priv_pts.val)) {
|
||||||
frac_add(sti->priv_pts, (int64_t)st->time_base.den * frame_size);
|
frac_add(&sti->priv_pts, (int64_t)st->time_base.den * frame_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
frac_add(sti->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
|
frac_add(&sti->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -33,10 +33,7 @@
|
|||||||
#if FF_API_GET_END_PTS
|
#if FF_API_GET_END_PTS
|
||||||
int64_t av_stream_get_end_pts(const AVStream *st)
|
int64_t av_stream_get_end_pts(const AVStream *st)
|
||||||
{
|
{
|
||||||
if (cffstream(st)->priv_pts) {
|
return cffstream(st)->priv_pts.val;
|
||||||
return cffstream(st)->priv_pts->val;
|
|
||||||
} else
|
|
||||||
return AV_NOPTS_VALUE;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user