These fields are documented to be non-public and are only used in decode.c
Unified · Split
| @@ -1860,16 +1860,6 @@ typedef struct AVCodecContext { · 1859 unmodified lines | |||
| 1860 | */ | 1860 | */ |
| 1861 | const struct AVCodecDescriptor *codec_descriptor; | 1861 | const struct AVCodecDescriptor *codec_descriptor; |
| 1862 | 1862 | ||
| 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 | |||
| 1873 | /** | 1863 | /** |
| 1874 | * Character encoding of the input subtitles file. | 1864 | * Character encoding of the input subtitles file. |
| 1875 | * - decoding: set by user | 1865 | * - decoding: set by user |
| @@ -60,6 +60,11 @@ typedef struct DecodeContext { · 59 unmodified lines | |||
| 60 | * The caller has submitted a NULL packet on input. | 60 | * The caller has submitted a NULL packet on input. |
| 61 | */ | 61 | */ |
| 62 | int draining_started; | 62 | 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 | ||
| 63 | } DecodeContext; | 68 | } DecodeContext; |
| 64 | 69 | ||
| 65 | static DecodeContext *decode_ctx(AVCodecInternal *avci) | 70 | static DecodeContext *decode_ctx(AVCodecInternal *avci) |
| @@ -240,24 +245,24 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt) · 174 unmodified lines | |||
| 240 | * @param dts the dts field of the decoded AVPacket | 245 | * @param dts the dts field of the decoded AVPacket |
| 241 | * @return one of the input values, may be AV_NOPTS_VALUE | 246 | * @return one of the input values, may be AV_NOPTS_VALUE |
| 242 | */ | 247 | */ |
| 243 | static int64_t guess_correct_pts(AVCodecContext *ctx, | 248 | static int64_t guess_correct_pts(DecodeContext *dc, |
| 244 | int64_t reordered_pts, int64_t dts) | 249 | int64_t reordered_pts, int64_t dts) |
| 245 | { | 250 | { |
| 246 | int64_t pts = AV_NOPTS_VALUE; | 251 | int64_t pts = AV_NOPTS_VALUE; |
| 247 | 252 | ||
| 248 | if (dts != AV_NOPTS_VALUE) { | 253 | if (dts != AV_NOPTS_VALUE) { |
| 249 | ctx->pts_correction_num_faulty_dts += dts <= ctx->pts_correction_last_dts; | 254 | dc->pts_correction_num_faulty_dts += dts <= dc->pts_correction_last_dts; |
| 250 | ctx->pts_correction_last_dts = dts; | 255 | dc->pts_correction_last_dts = dts; |
| 251 | } else if (reordered_pts != AV_NOPTS_VALUE) | 256 | } else if (reordered_pts != AV_NOPTS_VALUE) |
| 252 | ctx->pts_correction_last_dts = reordered_pts; | 257 | dc->pts_correction_last_dts = reordered_pts; |
| 253 | 258 | ||
| 254 | if (reordered_pts != AV_NOPTS_VALUE) { | 259 | if (reordered_pts != AV_NOPTS_VALUE) { |
| 255 | ctx->pts_correction_num_faulty_pts += reordered_pts <= ctx->pts_correction_last_pts; | 260 | dc->pts_correction_num_faulty_pts += reordered_pts <= dc->pts_correction_last_pts; |
| 256 | ctx->pts_correction_last_pts = reordered_pts; | 261 | dc->pts_correction_last_pts = reordered_pts; |
| 257 | } else if(dts != AV_NOPTS_VALUE) | 262 | } else if(dts != AV_NOPTS_VALUE) |
| 258 | ctx->pts_correction_last_pts = dts; | 263 | dc->pts_correction_last_pts = dts; |
| 259 | 264 | ||
| 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) |
| 261 | && reordered_pts != AV_NOPTS_VALUE) | 266 | && reordered_pts != AV_NOPTS_VALUE) |
| 262 | pts = reordered_pts; | 267 | pts = reordered_pts; |
| 263 | else | 268 | else |
| @@ -575,6 +580,7 @@ static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame) · 311 unmodified lines | |||
| 575 | static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) | 580 | static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) |
| 576 | { | 581 | { |
| 577 | AVCodecInternal *avci = avctx->internal; | 582 | AVCodecInternal *avci = avctx->internal; |
| 583 | DecodeContext *dc = decode_ctx(avci); | ||
| 578 | const FFCodec *const codec = ffcodec(avctx->codec); | 584 | const FFCodec *const codec = ffcodec(avctx->codec); |
| 579 | int ret, ok; | 585 | int ret, ok; |
| 580 | 586 | ||
| @@ -630,7 +636,7 @@ FF_DISABLE_DEPRECATION_WARNINGS · 49 unmodified lines | |||
| 630 | frame->top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST); | 636 | frame->top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST); |
| 631 | FF_ENABLE_DEPRECATION_WARNINGS | 637 | FF_ENABLE_DEPRECATION_WARNINGS |
| 632 | #endif | 638 | #endif |
| 633 | frame->best_effort_timestamp = guess_correct_pts(avctx, | 639 | frame->best_effort_timestamp = guess_correct_pts(dc, |
| 634 | frame->pts, | 640 | frame->pts, |
| 635 | frame->pkt_dts); | 641 | frame->pkt_dts); |
| 636 | 642 | ||
| @@ -1672,6 +1678,7 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) · 1035 unmodified lines | |||
| 1672 | int ff_decode_preinit(AVCodecContext *avctx) | 1678 | int ff_decode_preinit(AVCodecContext *avctx) |
| 1673 | { | 1679 | { |
| 1674 | AVCodecInternal *avci = avctx->internal; | 1680 | AVCodecInternal *avci = avctx->internal; |
| 1681 | DecodeContext *dc = decode_ctx(avci); | ||
| 1675 | int ret = 0; | 1682 | int ret = 0; |
| 1676 | 1683 | ||
| 1677 | /* if the decoder init function was already called previously, | 1684 | /* if the decoder init function was already called previously, |
| @@ -1719,10 +1726,10 @@ int ff_decode_preinit(AVCodecContext *avctx) · 41 unmodified lines | |||
| 1719 | } | 1726 | } |
| 1720 | } | 1727 | } |
| 1721 | 1728 | ||
| 1722 | avctx->pts_correction_num_faulty_pts = | 1729 | dc->pts_correction_num_faulty_pts = |
| 1723 | avctx->pts_correction_num_faulty_dts = 0; | 1730 | dc->pts_correction_num_faulty_dts = 0; |
| 1724 | avctx->pts_correction_last_pts = | 1731 | dc->pts_correction_last_pts = |
| 1725 | avctx->pts_correction_last_dts = INT64_MIN; | 1732 | dc->pts_correction_last_dts = INT64_MIN; |
| 1726 | 1733 | ||
| 1727 | if ( !CONFIG_GRAY && avctx->flags & AV_CODEC_FLAG_GRAY | 1734 | if ( !CONFIG_GRAY && avctx->flags & AV_CODEC_FLAG_GRAY |
| 1728 | && avctx->codec_descriptor->type == AVMEDIA_TYPE_VIDEO) | 1735 | && avctx->codec_descriptor->type == AVMEDIA_TYPE_VIDEO) |
| @@ -1801,8 +1808,8 @@ void ff_decode_flush_buffers(AVCodecContext *avctx) · 72 unmodified lines | |||
| 1801 | av_packet_unref(avci->last_pkt_props); | 1808 | av_packet_unref(avci->last_pkt_props); |
| 1802 | av_packet_unref(avci->in_pkt); | 1809 | av_packet_unref(avci->in_pkt); |
| 1803 | 1810 | ||
| 1804 | avctx->pts_correction_last_pts = | 1811 | dc->pts_correction_last_pts = |
| 1805 | avctx->pts_correction_last_dts = INT64_MIN; | 1812 | dc->pts_correction_last_dts = INT64_MIN; |
| 1806 | 1813 | ||
| 1807 | av_bsf_flush(avci->bsf); | 1814 | av_bsf_flush(avci->bsf); |
| 1808 | 1815 | ||