Skip to content

Commit 71e1da4

Browse files
committed
avformat/mux: Don't allocate priv_pts separately
Signed-off-by: Andreas Rheinhardt <[email protected]>
1 parent ad9f644 commit 71e1da4

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

libavformat/avformat.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
6363
av_parser_close(sti->parser);
6464
avcodec_free_context(&sti->avctx);
6565
av_bsf_free(&sti->bsfc);
66-
av_freep(&sti->priv_pts);
6766
av_freep(&sti->index_entries);
6867
av_freep(&sti->probe_data.buf);
6968

libavformat/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ typedef struct FFStream {
245245

246246
int is_intra_only;
247247

248-
FFFrac *priv_pts;
248+
FFFrac priv_pts;
249249

250250
/**
251251
* Stream information used internally by avformat_find_stream_info()

libavformat/mux.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,11 @@ static int init_pts(AVFormatContext *s)
406406
break;
407407
}
408408

409-
if (!sti->priv_pts)
410-
sti->priv_pts = av_mallocz(sizeof(*sti->priv_pts));
411-
if (!sti->priv_pts)
412-
return AVERROR(ENOMEM);
413-
414409
if (den != AV_NOPTS_VALUE) {
415410
if (den <= 0)
416411
return AVERROR_INVALIDDATA;
417412

418-
frac_init(sti->priv_pts, 0, 0, den);
413+
frac_init(&sti->priv_pts, 0, 0, den);
419414
}
420415
}
421416

@@ -550,7 +545,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
550545
}
551546
pkt->dts =
552547
// pkt->pts= st->cur_dts;
553-
pkt->pts = sti->priv_pts->val;
548+
pkt->pts = sti->priv_pts.val;
554549
}
555550

556551
//calculate dts from pts
@@ -587,7 +582,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
587582
av_ts2str(pkt->pts), av_ts2str(pkt->dts));
588583

589584
sti->cur_dts = pkt->dts;
590-
sti->priv_pts->val = pkt->dts;
585+
sti->priv_pts.val = pkt->dts;
591586

592587
/* update pts */
593588
switch (st->codecpar->codec_type) {
@@ -599,12 +594,12 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
599594
/* HACK/FIXME, we skip the initial 0 size packets as they are most
600595
* likely equal to the encoder delay, but it would be better if we
601596
* had the real timestamps from the encoder */
602-
if (frame_size >= 0 && (pkt->size || sti->priv_pts->num != sti->priv_pts->den >> 1 || sti->priv_pts->val)) {
603-
frac_add(sti->priv_pts, (int64_t)st->time_base.den * frame_size);
597+
if (frame_size >= 0 && (pkt->size || sti->priv_pts.num != sti->priv_pts.den >> 1 || sti->priv_pts.val)) {
598+
frac_add(&sti->priv_pts, (int64_t)st->time_base.den * frame_size);
604599
}
605600
break;
606601
case AVMEDIA_TYPE_VIDEO:
607-
frac_add(sti->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
602+
frac_add(&sti->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
608603
break;
609604
}
610605
return 0;

libavformat/mux_utils.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@
3333
#if FF_API_GET_END_PTS
3434
int64_t av_stream_get_end_pts(const AVStream *st)
3535
{
36-
if (cffstream(st)->priv_pts) {
37-
return cffstream(st)->priv_pts->val;
38-
} else
39-
return AV_NOPTS_VALUE;
36+
return cffstream(st)->priv_pts.val;
4037
}
4138
#endif
4239

0 commit comments

Comments
 (0)