From: Anton Khirnov Date: Sun, 18 May 2014 10:36:00 +0000 (+0200) Subject: lavf: deprecate now unused AVStream.pts X-Git-Tag: v11_alpha1~469 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a312f71090ee620ee252f2034aef6b13e2dafe9c;p=platform%2Fupstream%2Flibav.git lavf: deprecate now unused AVStream.pts --- diff --git a/doc/APIchanges b/doc/APIchanges index 49a35d5..309bd46 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,11 @@ libavutil: 2013-12-xx 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 Add avcodec_free_context(). From now on it should be used for freeing AVCodecContext. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 55f24e6..5ed50f4 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -366,6 +366,7 @@ int av_get_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 */ @@ -376,6 +377,7 @@ int av_append_packet(AVIOContext *s, AVPacket *pkt, int size); typedef struct AVFrac { int64_t val, num, den; } AVFrac; +#endif /*************************************************/ /* input/output formats */ @@ -695,10 +697,13 @@ typedef struct AVStream { AVCodecContext *codec; void *priv_data; +#if FF_API_LAVF_FRAC /** - * encoding: pts generation when outputting stream + * @deprecated this field is unused */ + attribute_deprecated struct AVFrac pts; +#endif /** * This is the fundamental unit of time (in seconds) in terms diff --git a/libavformat/mux.c b/libavformat/mux.c index 4d984cb..e024a7e 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -51,56 +51,6 @@ * 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) { const AVCodecTag *avctag; @@ -273,37 +223,6 @@ fail: 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 ret = 0; @@ -317,9 +236,6 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) return ret; } - if ((ret = init_pts(s)) < 0) - return ret; - 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) { 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", 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", pkt->pts, 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; } diff --git a/libavformat/version.h b/libavformat/version.h index 248ecdf..dd945ac 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 55 #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, \ LIBAVFORMAT_VERSION_MINOR, \ @@ -54,5 +54,8 @@ #ifndef FF_API_LAVF_BITEXACT #define FF_API_LAVF_BITEXACT (LIBAVFORMAT_VERSION_MAJOR < 56) #endif +#ifndef FF_API_LAVF_FRAC +#define FF_API_LAVF_FRAC (LIBAVFORMAT_VERSION_MAJOR < 57) +#endif #endif /* AVFORMAT_VERSION_H */