lavf: deprecate now unused AVStream.pts
This commit is contained in:
parent
ed7922faac
commit
a312f71090
@ -13,6 +13,11 @@ libavutil: 2013-12-xx
|
|||||||
|
|
||||||
API changes, most recent first:
|
API changes, most recent first:
|
||||||
|
|
||||||
|
2014-05-xx - xxxxxxx - lavf 55.17.1 - avformat.h
|
||||||
|
Deprecate AVStream.pts and the AVFrac struct, which was its only use case.
|
||||||
|
Those fields were poorly defined and not meant to be public, so there is
|
||||||
|
no replacement for them.
|
||||||
|
|
||||||
2014-05-18 - fd05602 - lavc 55.52.0 - avcodec.h
|
2014-05-18 - fd05602 - lavc 55.52.0 - avcodec.h
|
||||||
Add avcodec_free_context(). From now on it should be used for freeing
|
Add avcodec_free_context(). From now on it should be used for freeing
|
||||||
AVCodecContext.
|
AVCodecContext.
|
||||||
|
@ -366,6 +366,7 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
|
|||||||
*/
|
*/
|
||||||
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
|
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
|
||||||
|
|
||||||
|
#if FF_API_LAVF_FRAC
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
/* fractional numbers for exact pts handling */
|
/* fractional numbers for exact pts handling */
|
||||||
|
|
||||||
@ -376,6 +377,7 @@ int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
|
|||||||
typedef struct AVFrac {
|
typedef struct AVFrac {
|
||||||
int64_t val, num, den;
|
int64_t val, num, den;
|
||||||
} AVFrac;
|
} AVFrac;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
/* input/output formats */
|
/* input/output formats */
|
||||||
@ -695,10 +697,13 @@ typedef struct AVStream {
|
|||||||
AVCodecContext *codec;
|
AVCodecContext *codec;
|
||||||
void *priv_data;
|
void *priv_data;
|
||||||
|
|
||||||
|
#if FF_API_LAVF_FRAC
|
||||||
/**
|
/**
|
||||||
* encoding: pts generation when outputting stream
|
* @deprecated this field is unused
|
||||||
*/
|
*/
|
||||||
|
attribute_deprecated
|
||||||
struct AVFrac pts;
|
struct AVFrac pts;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the fundamental unit of time (in seconds) in terms
|
* This is the fundamental unit of time (in seconds) in terms
|
||||||
|
@ -51,56 +51,6 @@
|
|||||||
* muxing functions for use within Libav
|
* muxing functions for use within Libav
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* fraction handling */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* f = val + (num / den) + 0.5.
|
|
||||||
*
|
|
||||||
* 'num' is normalized so that it is such as 0 <= num < den.
|
|
||||||
*
|
|
||||||
* @param f fractional number
|
|
||||||
* @param val integer value
|
|
||||||
* @param num must be >= 0
|
|
||||||
* @param den must be >= 1
|
|
||||||
*/
|
|
||||||
static void frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den)
|
|
||||||
{
|
|
||||||
num += (den >> 1);
|
|
||||||
if (num >= den) {
|
|
||||||
val += num / den;
|
|
||||||
num = num % den;
|
|
||||||
}
|
|
||||||
f->val = val;
|
|
||||||
f->num = num;
|
|
||||||
f->den = den;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fractional addition to f: f = f + (incr / f->den).
|
|
||||||
*
|
|
||||||
* @param f fractional number
|
|
||||||
* @param incr increment, can be positive or negative
|
|
||||||
*/
|
|
||||||
static void frac_add(AVFrac *f, int64_t incr)
|
|
||||||
{
|
|
||||||
int64_t num, den;
|
|
||||||
|
|
||||||
num = f->num + incr;
|
|
||||||
den = f->den;
|
|
||||||
if (num < 0) {
|
|
||||||
f->val += num / den;
|
|
||||||
num = num % den;
|
|
||||||
if (num < 0) {
|
|
||||||
num += den;
|
|
||||||
f->val--;
|
|
||||||
}
|
|
||||||
} else if (num >= den) {
|
|
||||||
f->val += num / den;
|
|
||||||
num = num % den;
|
|
||||||
}
|
|
||||||
f->num = num;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int validate_codec_tag(AVFormatContext *s, AVStream *st)
|
static int validate_codec_tag(AVFormatContext *s, AVStream *st)
|
||||||
{
|
{
|
||||||
const AVCodecTag *avctag;
|
const AVCodecTag *avctag;
|
||||||
@ -273,37 +223,6 @@ fail:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_pts(AVFormatContext *s)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
AVStream *st;
|
|
||||||
|
|
||||||
/* init PTS generation */
|
|
||||||
for (i = 0; i < s->nb_streams; i++) {
|
|
||||||
int64_t den = AV_NOPTS_VALUE;
|
|
||||||
st = s->streams[i];
|
|
||||||
|
|
||||||
switch (st->codec->codec_type) {
|
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
|
||||||
den = (int64_t)st->time_base.num * st->codec->sample_rate;
|
|
||||||
break;
|
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
|
||||||
den = (int64_t)st->time_base.num * st->codec->time_base.den;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (den != AV_NOPTS_VALUE) {
|
|
||||||
if (den <= 0)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
|
|
||||||
frac_init(&st->pts, 0, 0, den);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
|
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -317,9 +236,6 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = init_pts(s)) < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +243,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
|
|||||||
static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
|
static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
int delay = FFMAX(st->codec->has_b_frames, !!st->codec->max_b_frames);
|
int delay = FFMAX(st->codec->has_b_frames, !!st->codec->max_b_frames);
|
||||||
int num, den, frame_size, i;
|
int num, den, i;
|
||||||
|
|
||||||
av_dlog(s, "compute_pkt_fields2: pts:%" PRId64 " dts:%" PRId64 " cur_dts:%" PRId64 " b:%d size:%d st:%d\n",
|
av_dlog(s, "compute_pkt_fields2: pts:%" PRId64 " dts:%" PRId64 " cur_dts:%" PRId64 " b:%d size:%d st:%d\n",
|
||||||
pkt->pts, pkt->dts, st->cur_dts, delay, pkt->size, pkt->stream_index);
|
pkt->pts, pkt->dts, st->cur_dts, delay, pkt->size, pkt->stream_index);
|
||||||
@ -373,26 +289,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
|
|||||||
av_dlog(s, "av_write_frame: pts2:%"PRId64" dts2:%"PRId64"\n",
|
av_dlog(s, "av_write_frame: pts2:%"PRId64" dts2:%"PRId64"\n",
|
||||||
pkt->pts, pkt->dts);
|
pkt->pts, pkt->dts);
|
||||||
st->cur_dts = pkt->dts;
|
st->cur_dts = pkt->dts;
|
||||||
st->pts.val = pkt->dts;
|
|
||||||
|
|
||||||
/* update pts */
|
|
||||||
switch (st->codec->codec_type) {
|
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
|
||||||
frame_size = ff_get_audio_frame_size(st->codec, pkt->size, 1);
|
|
||||||
|
|
||||||
/* HACK/FIXME, we skip the initial 0 size packets as they are most
|
|
||||||
* likely equal to the encoder delay, but it would be better if we
|
|
||||||
* had the real timestamps from the encoder */
|
|
||||||
if (frame_size >= 0 && (pkt->size || st->pts.num != st->pts.den >> 1 || st->pts.val)) {
|
|
||||||
frac_add(&st->pts, (int64_t)st->time_base.den * frame_size);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
|
||||||
frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_MAJOR 55
|
#define LIBAVFORMAT_VERSION_MAJOR 55
|
||||||
#define LIBAVFORMAT_VERSION_MINOR 17
|
#define LIBAVFORMAT_VERSION_MINOR 17
|
||||||
#define LIBAVFORMAT_VERSION_MICRO 0
|
#define LIBAVFORMAT_VERSION_MICRO 1
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||||
LIBAVFORMAT_VERSION_MINOR, \
|
LIBAVFORMAT_VERSION_MINOR, \
|
||||||
@ -54,5 +54,8 @@
|
|||||||
#ifndef FF_API_LAVF_BITEXACT
|
#ifndef FF_API_LAVF_BITEXACT
|
||||||
#define FF_API_LAVF_BITEXACT (LIBAVFORMAT_VERSION_MAJOR < 56)
|
#define FF_API_LAVF_BITEXACT (LIBAVFORMAT_VERSION_MAJOR < 56)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef FF_API_LAVF_FRAC
|
||||||
|
#define FF_API_LAVF_FRAC (LIBAVFORMAT_VERSION_MAJOR < 57)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* AVFORMAT_VERSION_H */
|
#endif /* AVFORMAT_VERSION_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user