diff --git a/doc/APIchanges b/doc/APIchanges index 786962973a..130638b7bc 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,13 @@ libavutil: 2015-08-28 API changes, most recent first: +2016-xx-xx - xxxxxxx - lavc 57.61.100 / lavc 57.24.0 - avcodec.h + Decoders now export the frame timestamp as AVFrame.pts. It was + previously exported as AVFrame.pkt_pts, which is now deprecated. + + Note: When decoding, AVFrame.pts uses the stream/packet timebase, + and not the codec timebase. + 2016-09-xx - xxxxxxx - lavu 55.32.100 / 55.16.0 - hwcontext.h hwcontext_qsv.h Add AV_HWDEVICE_TYPE_QSV and a new installed header with QSV-specific hwcontext definitions. diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c index 1097668437..3066d47b11 100644 --- a/libavcodec/audiotoolboxdec.c +++ b/libavcodec/audiotoolboxdec.c @@ -554,7 +554,12 @@ static int ffat_decode(AVCodecContext *avctx, void *data, ffat_copy_samples(avctx, frame); *got_frame_ptr = 1; if (at->last_pts != AV_NOPTS_VALUE) { + frame->pts = at->last_pts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS frame->pkt_pts = at->last_pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif at->last_pts = avpkt->pts; } } else if (ret && ret != 1) { diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 59b14b9c29..0f5101a01f 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -707,7 +707,12 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, if (interlaced) priv->pic->top_field_first = !bottom_first; + priv->pic->pts = pkt_pts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS priv->pic->pkt_pts = pkt_pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (!priv->need_second_field) { *got_frame = 1; diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c index 56f349cdd2..27a4c30b00 100644 --- a/libavcodec/cuvid.c +++ b/libavcodec/cuvid.c @@ -469,7 +469,11 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame) /* CUVIDs opaque reordering breaks the internal pkt logic. * So set pkt_pts and clear all the other pkt_ fields. */ +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS frame->pkt_pts = frame->pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_frame_set_pkt_pos(frame, -1); av_frame_set_pkt_duration(frame, 0); av_frame_set_pkt_size(frame, -1); diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index 20ae903a33..48345db545 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -462,7 +462,11 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, A bytestream2_init(&s->gb, avpkt->data, avpkt->size); s->frame->pts = avpkt->pts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS s->frame->pkt_pts = avpkt->pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->frame->pkt_dts = avpkt->dts; av_frame_set_pkt_duration(s->frame, avpkt->duration); diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c index 6af60af434..ab0a84c698 100644 --- a/libavcodec/libopenh264dec.c +++ b/libavcodec/libopenh264dec.c @@ -221,7 +221,11 @@ static int svc_decode_frame(AVCodecContext *avctx, void *data, avframe->pts = s->pkt_filtered.pts; avframe->pkt_dts = s->pkt_filtered.dts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS avframe->pkt_pts = s->pkt_filtered.pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif *got_frame = 1; } diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index 152cbe7d47..c9930c717c 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -326,7 +326,12 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, framewithpts->frame->components[2].length); /* Fill frame with current buffer data from Schroedinger. */ - avframe->pkt_pts = framewithpts->pts; + avframe->pts = framewithpts->pts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS + avframe->pkt_pts = avframe->pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif avframe->linesize[0] = framewithpts->frame->components[0].stride; avframe->linesize[1] = framewithpts->frame->components[1].stride; avframe->linesize[2] = framewithpts->frame->components[2].stride; diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 223942b3bd..6683de7751 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -202,12 +202,17 @@ static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx, frame->format = avctx->pix_fmt; if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) { - frame->pkt_pts = av_rescale_q(info->presentationTimeUs, + frame->pts = av_rescale_q(info->presentationTimeUs, av_make_q(1, 1000000), avctx->pkt_timebase); } else { - frame->pkt_pts = info->presentationTimeUs; + frame->pts = info->presentationTimeUs; } +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS + frame->pkt_pts = frame->pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif frame->pkt_dts = AV_NOPTS_VALUE; buffer = av_mallocz(sizeof(AVMediaCodecBuffer)); @@ -278,7 +283,12 @@ static int mediacodec_wrap_sw_buffer(AVCodecContext *avctx, * on the last avpacket received which is not in sync with the frame: * * N avpackets can be pushed before 1 frame is actually returned * * 0-sized avpackets are pushed to flush remaining frames at EOS */ + frame->pts = info->presentationTimeUs; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS frame->pkt_pts = info->presentationTimeUs; +FF_ENABLE_DEPRECATION_WARNINGS +#endif frame->pkt_dts = AV_NOPTS_VALUE; av_log(avctx, AV_LOG_DEBUG, diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index 56ad948a13..3f92bf5ec9 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -654,7 +654,12 @@ static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame, avctx->pix_fmt, avctx->width, avctx->height); } - frame->pkt_pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : buffer->pts; + frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : buffer->pts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS + frame->pkt_pts = frame->pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif frame->pkt_dts = AV_NOPTS_VALUE; done: diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index b685e0e3f0..6409312d31 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -443,7 +443,12 @@ static int do_qsv_decode(AVCodecContext *avctx, QSVContext *q, outsurf = out_frame->surface; - frame->pkt_pts = frame->pts = outsurf->Data.TimeStamp; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS + frame->pkt_pts = outsurf->Data.TimeStamp; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + frame->pts = outsurf->Data.TimeStamp; frame->repeat_pict = outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_TRIPLING ? 4 : diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1239d490d6..be1686e678 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -768,7 +768,12 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) }; if (pkt) { + frame->pts = pkt->pts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS frame->pkt_pts = pkt->pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_frame_set_pkt_pos (frame, pkt->pos); av_frame_set_pkt_duration(frame, pkt->duration); av_frame_set_pkt_size (frame, pkt->size); @@ -794,7 +799,12 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD); } } else { + frame->pts = AV_NOPTS_VALUE; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS frame->pkt_pts = AV_NOPTS_VALUE; +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_frame_set_pkt_pos (frame, -1); av_frame_set_pkt_duration(frame, 0); av_frame_set_pkt_size (frame, -1); @@ -2043,7 +2053,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, * which case the output will as well. * * @param pts the pts field of the decoded AVPacket, as passed through - * AVFrame.pkt_pts + * AVFrame.pts * @param dts the dts field of the decoded AVPacket * @return one of the input values, may be AV_NOPTS_VALUE */ @@ -2281,7 +2291,7 @@ fail: avctx->frame_number++; av_frame_set_best_effort_timestamp(picture, guess_correct_pts(avctx, - picture->pkt_pts, + picture->pts, picture->pkt_dts)); } else av_frame_unref(picture); @@ -2354,7 +2364,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, avctx->frame_number++; av_frame_set_best_effort_timestamp(frame, guess_correct_pts(avctx, - frame->pkt_pts, + frame->pts, frame->pkt_dts)); if (frame->format == AV_SAMPLE_FMT_NONE) frame->format = avctx->sample_fmt; @@ -2396,8 +2406,14 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, int64_t diff_ts = av_rescale_q(avctx->internal->skip_samples, (AVRational){1, avctx->sample_rate}, avctx->pkt_timebase); + if(frame->pts!=AV_NOPTS_VALUE) + frame->pts += diff_ts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS if(frame->pkt_pts!=AV_NOPTS_VALUE) frame->pkt_pts += diff_ts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if(frame->pkt_dts!=AV_NOPTS_VALUE) frame->pkt_dts += diff_ts; if (av_frame_get_pkt_duration(frame) >= diff_ts) @@ -2874,7 +2890,7 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr if (ret >= 0) { if (av_frame_get_best_effort_timestamp(frame) == AV_NOPTS_VALUE) { av_frame_set_best_effort_timestamp(frame, - guess_correct_pts(avctx, frame->pkt_pts, frame->pkt_dts)); + guess_correct_pts(avctx, frame->pts, frame->pkt_dts)); } } return ret; diff --git a/libavcodec/version.h b/libavcodec/version.h index de7280f132..9c03364e9b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 60 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MINOR 61 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index cb2a4a2921..779f2d50f3 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -3992,7 +3992,12 @@ static int vp9_decode_frame(AVCodecContext *ctx, void *frame, } if ((res = av_frame_ref(frame, s->s.refs[ref].f)) < 0) return res; + ((AVFrame *)frame)->pts = pkt->pts; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS ((AVFrame *)frame)->pkt_pts = pkt->pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif ((AVFrame *)frame)->pkt_dts = pkt->dts; for (i = 0; i < 8; i++) { if (s->next_refs[i].f->buf[0]) diff --git a/libavutil/frame.c b/libavutil/frame.c index 3c74931dca..53e6174223 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -99,8 +99,12 @@ static void get_frame_defaults(AVFrame *frame) memset(frame, 0, sizeof(*frame)); frame->pts = - frame->pkt_dts = + frame->pkt_dts = AV_NOPTS_VALUE; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS frame->pkt_pts = AV_NOPTS_VALUE; +FF_ENABLE_DEPRECATION_WARNINGS +#endif frame->best_effort_timestamp = AV_NOPTS_VALUE; frame->pkt_duration = 0; frame->pkt_pos = -1; @@ -295,7 +299,11 @@ static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy) dst->palette_has_changed = src->palette_has_changed; dst->sample_rate = src->sample_rate; dst->opaque = src->opaque; +#if FF_API_PKT_PTS +FF_DISABLE_DEPRECATION_WARNINGS dst->pkt_pts = src->pkt_pts; +FF_ENABLE_DEPRECATION_WARNINGS +#endif dst->pkt_dts = src->pkt_dts; dst->pkt_pos = src->pkt_pos; dst->pkt_size = src->pkt_size; diff --git a/libavutil/frame.h b/libavutil/frame.h index 1e2691e663..a19da2f489 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -267,10 +267,14 @@ typedef struct AVFrame { */ int64_t pts; +#if FF_API_PKT_PTS /** * PTS copied from the AVPacket that was decoded to produce this frame. + * @deprecated use the pts field instead */ + attribute_deprecated int64_t pkt_pts; +#endif /** * DTS copied from the AVPacket that triggered returning this frame. (if frame threading isn't used) diff --git a/libavutil/version.h b/libavutil/version.h index 787ba58ac6..8a41ef6fbc 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -132,6 +132,9 @@ #ifndef FF_API_CRC_BIG_TABLE #define FF_API_CRC_BIG_TABLE (LIBAVUTIL_VERSION_MAJOR < 56) #endif +#ifndef FF_API_PKT_PTS +#define FF_API_PKT_PTS (LIBAVUTIL_VERSION_MAJOR < 56) +#endif /**