History

lavc: move AVCodecContext.pts_correction* to DecodeContext

These fields are documented to be non-public and are only used in decode.c

Anton Khirnov committed 2 years ago

Commit 07576691 parent c8db1002 files · +22 −25Browse files

Unified · Split

2 files
  1. libavcodec/avcodec.h +0 −10
  2. libavcodec/decode.c +22 −15
libavcodec/avcodec.h+0−10
@@ -1860,16 +1860,6 @@ typedef struct AVCodecContext { · 1859 unmodified lines
18601860 */
18611861 const struct AVCodecDescriptor *codec_descriptor;
18621862
1863− /*
1864− * Current statistics for PTS correction.
1865− * - decoding: maintained and used by libavcodec, not intended to be used by user apps
1866− * - encoding: unused
1867− */
1868− int64_t pts_correction_num_faulty_pts; ///< Number of incorrect PTS values so far
1869− int64_t pts_correction_num_faulty_dts; ///< Number of incorrect DTS values so far
1870− int64_t pts_correction_last_pts; ///< PTS of the last frame
1871− int64_t pts_correction_last_dts; ///< DTS of the last frame
1872−
18731863 /**
18741864 * Character encoding of the input subtitles file.
18751865 * - decoding: set by user
libavcodec/decode.c+22−15
@@ -60,6 +60,11 @@ typedef struct DecodeContext { · 59 unmodified lines
6060 * The caller has submitted a NULL packet on input.
6161 */
6262 int draining_started;
63+
64+ int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
65+ int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
66+ int64_t pts_correction_last_pts; /// PTS of the last frame
67+ int64_t pts_correction_last_dts; /// DTS of the last frame
6368 } DecodeContext;
6469
6570 static DecodeContext *decode_ctx(AVCodecInternal *avci)
@@ -240,24 +245,24 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt) · 174 unmodified lines
240245 * @param dts the dts field of the decoded AVPacket
241246 * @return one of the input values, may be AV_NOPTS_VALUE
242247 */
243−static int64_t guess_correct_pts(AVCodecContext *ctx,
248+static int64_t guess_correct_pts(DecodeContext *dc,
244249 int64_t reordered_pts, int64_t dts)
245250 {
246251 int64_t pts = AV_NOPTS_VALUE;
247252
248253 if (dts != AV_NOPTS_VALUE) {
249− ctx->pts_correction_num_faulty_dts += dts <= ctx->pts_correction_last_dts;
250− ctx->pts_correction_last_dts = dts;
254+ dc->pts_correction_num_faulty_dts += dts <= dc->pts_correction_last_dts;
255+ dc->pts_correction_last_dts = dts;
251256 } else if (reordered_pts != AV_NOPTS_VALUE)
252− ctx->pts_correction_last_dts = reordered_pts;
257+ dc->pts_correction_last_dts = reordered_pts;
253258
254259 if (reordered_pts != AV_NOPTS_VALUE) {
255− ctx->pts_correction_num_faulty_pts += reordered_pts <= ctx->pts_correction_last_pts;
256− ctx->pts_correction_last_pts = reordered_pts;
260+ dc->pts_correction_num_faulty_pts += reordered_pts <= dc->pts_correction_last_pts;
261+ dc->pts_correction_last_pts = reordered_pts;
257262 } else if(dts != AV_NOPTS_VALUE)
258− ctx->pts_correction_last_pts = dts;
263+ dc->pts_correction_last_pts = dts;
259264
260− if ((ctx->pts_correction_num_faulty_pts<=ctx->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE)
265+ if ((dc->pts_correction_num_faulty_pts<=dc->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE)
261266 && reordered_pts != AV_NOPTS_VALUE)
262267 pts = reordered_pts;
263268 else
@@ -575,6 +580,7 @@ static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame) · 311 unmodified lines
575580 static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
576581 {
577582 AVCodecInternal *avci = avctx->internal;
583+ DecodeContext *dc = decode_ctx(avci);
578584 const FFCodec *const codec = ffcodec(avctx->codec);
579585 int ret, ok;
580586
@@ -630,7 +636,7 @@ FF_DISABLE_DEPRECATION_WARNINGS · 49 unmodified lines
630636 frame->top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
631637 FF_ENABLE_DEPRECATION_WARNINGS
632638 #endif
633− frame->best_effort_timestamp = guess_correct_pts(avctx,
639+ frame->best_effort_timestamp = guess_correct_pts(dc,
634640 frame->pts,
635641 frame->pkt_dts);
636642
@@ -1672,6 +1678,7 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) · 1035 unmodified lines
16721678 int ff_decode_preinit(AVCodecContext *avctx)
16731679 {
16741680 AVCodecInternal *avci = avctx->internal;
1681+ DecodeContext *dc = decode_ctx(avci);
16751682 int ret = 0;
16761683
16771684 /* if the decoder init function was already called previously,
@@ -1719,10 +1726,10 @@ int ff_decode_preinit(AVCodecContext *avctx) · 41 unmodified lines
17191726 }
17201727 }
17211728
1722− avctx->pts_correction_num_faulty_pts =
1723− avctx->pts_correction_num_faulty_dts = 0;
1724− avctx->pts_correction_last_pts =
1725− avctx->pts_correction_last_dts = INT64_MIN;
1729+ dc->pts_correction_num_faulty_pts =
1730+ dc->pts_correction_num_faulty_dts = 0;
1731+ dc->pts_correction_last_pts =
1732+ dc->pts_correction_last_dts = INT64_MIN;
17261733
17271734 if ( !CONFIG_GRAY && avctx->flags & AV_CODEC_FLAG_GRAY
17281735 && avctx->codec_descriptor->type == AVMEDIA_TYPE_VIDEO)
@@ -1801,8 +1808,8 @@ void ff_decode_flush_buffers(AVCodecContext *avctx) · 72 unmodified lines
18011808 av_packet_unref(avci->last_pkt_props);
18021809 av_packet_unref(avci->in_pkt);
18031810
1804− avctx->pts_correction_last_pts =
1805− avctx->pts_correction_last_dts = INT64_MIN;
1811+ dc->pts_correction_last_pts =
1812+ dc->pts_correction_last_dts = INT64_MIN;
18061813
18071814 av_bsf_flush(avci->bsf);
18081815

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