Browse Source

Merge commit '32c8359093d1ff4f45ed19518b449b3ac3769d27'

* commit '32c8359093d1ff4f45ed19518b449b3ac3769d27':
  lavc: export the timestamps when decoding in AVFrame.pts

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
tags/n3.2
Hendrik Leppkes 8 years ago
parent
commit
3f9137c57d
16 changed files with 102 additions and 12 deletions
  1. +7
    -0
      doc/APIchanges
  2. +5
    -0
      libavcodec/audiotoolboxdec.c
  3. +5
    -0
      libavcodec/crystalhd.c
  4. +4
    -0
      libavcodec/cuvid.c
  5. +4
    -0
      libavcodec/gifdec.c
  6. +4
    -0
      libavcodec/libopenh264dec.c
  7. +6
    -1
      libavcodec/libschroedingerdec.c
  8. +12
    -2
      libavcodec/mediacodecdec.c
  9. +6
    -1
      libavcodec/mmaldec.c
  10. +6
    -1
      libavcodec/qsvdec.c
  11. +20
    -4
      libavcodec/utils.c
  12. +2
    -2
      libavcodec/version.h
  13. +5
    -0
      libavcodec/vp9.c
  14. +9
    -1
      libavutil/frame.c
  15. +4
    -0
      libavutil/frame.h
  16. +3
    -0
      libavutil/version.h

+ 7
- 0
doc/APIchanges View File

@@ -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.


+ 5
- 0
libavcodec/audiotoolboxdec.c View File

@@ -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) {


+ 5
- 0
libavcodec/crystalhd.c View File

@@ -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;


+ 4
- 0
libavcodec/cuvid.c View File

@@ -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);


+ 4
- 0
libavcodec/gifdec.c View File

@@ -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);



+ 4
- 0
libavcodec/libopenh264dec.c View File

@@ -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;
}


+ 6
- 1
libavcodec/libschroedingerdec.c View File

@@ -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;


+ 12
- 2
libavcodec/mediacodecdec.c View File

@@ -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,


+ 6
- 1
libavcodec/mmaldec.c View File

@@ -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:


+ 6
- 1
libavcodec/qsvdec.c View File

@@ -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 :


+ 20
- 4
libavcodec/utils.c View File

@@ -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;


+ 2
- 2
libavcodec/version.h View File

@@ -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, \


+ 5
- 0
libavcodec/vp9.c View File

@@ -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])


+ 9
- 1
libavutil/frame.c View File

@@ -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;


+ 4
- 0
libavutil/frame.h View File

@@ -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)


+ 3
- 0
libavutil/version.h View File

@@ -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


/**


Loading…
Cancel
Save