History

avformat/mux: Don't allocate priv_pts separately

Andreas Rheinhardt committed 2 years ago

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

Showing the changes to libavformat (4 of 4 files). Show all

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
63 av_parser_close(sti->parser);63 av_parser_close(sti->parser);
64 avcodec_free_context(&sti->avctx);64 avcodec_free_context(&sti->avctx);
65 av_bsf_free(&sti->bsfc);65 av_bsf_free(&sti->bsfc);
66 av_freep(&sti->priv_pts);
67 av_freep(&sti->index_entries);66 av_freep(&sti->index_entries);
68 av_freep(&sti->probe_data.buf);67 av_freep(&sti->probe_data.buf);
69 68
libavformat/internal.h+1−1
@@ -245,7 +245,7 @@ typedef struct FFStream { · 244 unmodified lines
245 245
246 int is_intra_only;246 int is_intra_only;
247 247
248 FFFrac *priv_pts;248 FFFrac priv_pts;
249 249
250 /**250 /**
251 * Stream information used internally by avformat_find_stream_info()251 * 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
406 break;406 break;
407 }407 }
408 408
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
414 if (den != AV_NOPTS_VALUE) {409 if (den != AV_NOPTS_VALUE) {
415 if (den <= 0)410 if (den <= 0)
416 return AVERROR_INVALIDDATA;411 return AVERROR_INVALIDDATA;
417 412
418 frac_init(sti->priv_pts, 0, 0, den);413 frac_init(&sti->priv_pts, 0, 0, den);
419 }414 }
420 }415 }
421 416
@@ -550,7 +545,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * · 128 unmodified lines
550 }545 }
551 pkt->dts =546 pkt->dts =
552// pkt->pts= st->cur_dts;547// pkt->pts= st->cur_dts;
553 pkt->pts = sti->priv_pts->val;548 pkt->pts = sti->priv_pts.val;
554 }549 }
555 550
556 //calculate dts from pts551 //calculate dts from pts
@@ -587,7 +582,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * · 30 unmodified lines
587 av_ts2str(pkt->pts), av_ts2str(pkt->dts));582 av_ts2str(pkt->pts), av_ts2str(pkt->dts));
588 583
589 sti->cur_dts = pkt->dts;584 sti->cur_dts = pkt->dts;
590 sti->priv_pts->val = pkt->dts;585 sti->priv_pts.val = pkt->dts;
591 586
592 /* update pts */587 /* update pts */
593 switch (st->codecpar->codec_type) {588 switch (st->codecpar->codec_type) {
@@ -599,12 +594,12 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * · 5 unmodified lines
599 /* HACK/FIXME, we skip the initial 0 size packets as they are most594 /* HACK/FIXME, we skip the initial 0 size packets as they are most
600 * likely equal to the encoder delay, but it would be better if we595 * likely equal to the encoder delay, but it would be better if we
601 * had the real timestamps from the encoder */596 * 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)) {597 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);598 frac_add(&sti->priv_pts, (int64_t)st->time_base.den * frame_size);
604 }599 }
605 break;600 break;
606 case AVMEDIA_TYPE_VIDEO:601 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);
608 break;603 break;
609 }604 }
610 return 0;605 return 0;
libavformat/mux_utils.c+1−4
@@ -33,10 +33,7 @@ · 32 unmodified lines
33#if FF_API_GET_END_PTS33#if FF_API_GET_END_PTS
34int64_t av_stream_get_end_pts(const AVStream *st)34int64_t av_stream_get_end_pts(const AVStream *st)
35{35{
36 if (cffstream(st)->priv_pts) {36 return cffstream(st)->priv_pts.val;
37 return cffstream(st)->priv_pts->val;
38 } else
39 return AV_NOPTS_VALUE;
40}37}
41#endif38#endif
42 39

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