History

avformat/mux: Don't allocate priv_pts separately

Andreas Rheinhardt committed 2 years ago

Commit 71e1da41 parent ad9f6444 files · +8 −17Browse files

Unified · Split

4 files
  1. libavformat/avformat.c +0 −1
  2. libavformat/internal.h +1 −1
  3. libavformat/mux.c +6 −11
  4. libavformat/mux_utils.c +1 −4
libavformat/avformat.c+0−1
@@ -63,7 +63,6 @@ FF_ENABLE_DEPRECATION_WARNINGS · 62 unmodified lines
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+1−1
@@ -245,7 +245,7 @@ typedef struct FFStream { · 244 unmodified lines
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+6−11
@@ -406,16 +406,11 @@ static int init_pts(AVFormatContext *s) · 405 unmodified lines
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 * · 128 unmodified lines
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 * · 30 unmodified lines
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 * · 5 unmodified lines
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+1−4
@@ -33,10 +33,7 @@ · 32 unmodified lines
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

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