History

lavf: deprecate now unused AVStream.pts

Anton Khirnov committed 12 years ago

Commit a312f711 parent ed7922f4 files · +17 −107Browse files

Unified · Split

4 files
  1. doc/APIchanges +5 −0
  2. libavformat/avformat.h +6 −1
  3. libavformat/mux.c +2 −105
  4. libavformat/version.h +4 −1
doc/APIchanges+5−0
@@ -13,6 +13,11 @@ libavutil: 2013-12-xx · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2014-05-xx - xxxxxxx - lavf 55.17.1 - avformat.h
17+ Deprecate AVStream.pts and the AVFrac struct, which was its only use case.
18+ Those fields were poorly defined and not meant to be public, so there is
19+ no replacement for them.
20+
1621 2014-05-18 - fd05602 - lavc 55.52.0 - avcodec.h
1722 Add avcodec_free_context(). From now on it should be used for freeing
1823 AVCodecContext.
libavformat/avformat.h+6−1
@@ -366,6 +366,7 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size); · 365 unmodified lines
366366 */
367367 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
368368
369+#if FF_API_LAVF_FRAC
369370 /*************************************************/
370371 /* fractional numbers for exact pts handling */
371372
@@ -376,6 +377,7 @@ int av_append_packet(AVIOContext *s, AVPacket *pkt, int size); · 4 unmodified lines
376377 typedef struct AVFrac {
377378 int64_t val, num, den;
378379 } AVFrac;
380+#endif
379381
380382 /*************************************************/
381383 /* input/output formats */
@@ -695,10 +697,13 @@ typedef struct AVStream { · 313 unmodified lines
695697 AVCodecContext *codec;
696698 void *priv_data;
697699
700+#if FF_API_LAVF_FRAC
698701 /**
699− * encoding: pts generation when outputting stream
702+ * @deprecated this field is unused
700703 */
704+ attribute_deprecated
701705 struct AVFrac pts;
706+#endif
702707
703708 /**
704709 * This is the fundamental unit of time (in seconds) in terms
libavformat/mux.c+2−105
@@ -51,56 +51,6 @@ · 50 unmodified lines
5151 * muxing functions for use within Libav
5252 */
5353
54−/* fraction handling */
55−
56−/**
57− * f = val + (num / den) + 0.5.
58− *
59− * 'num' is normalized so that it is such as 0 <= num < den.
60− *
61− * @param f fractional number
62− * @param val integer value
63− * @param num must be >= 0
64− * @param den must be >= 1
65− */
66−static void frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den)
67−{
68− num += (den >> 1);
69− if (num >= den) {
70− val += num / den;
71− num = num % den;
72− }
73− f->val = val;
74− f->num = num;
75− f->den = den;
76−}
77−
78−/**
79− * Fractional addition to f: f = f + (incr / f->den).
80− *
81− * @param f fractional number
82− * @param incr increment, can be positive or negative
83− */
84−static void frac_add(AVFrac *f, int64_t incr)
85−{
86− int64_t num, den;
87−
88− num = f->num + incr;
89− den = f->den;
90− if (num < 0) {
91− f->val += num / den;
92− num = num % den;
93− if (num < 0) {
94− num += den;
95− f->val--;
96− }
97− } else if (num >= den) {
98− f->val += num / den;
99− num = num % den;
100− }
101− f->num = num;
102−}
103−
10454 static int validate_codec_tag(AVFormatContext *s, AVStream *st)
10555 {
10656 const AVCodecTag *avctag;
@@ -273,37 +223,6 @@ fail: · 166 unmodified lines
273223 return ret;
274224 }
275225
276−static int init_pts(AVFormatContext *s)
277−{
278− int i;
279− AVStream *st;
280−
281− /* init PTS generation */
282− for (i = 0; i < s->nb_streams; i++) {
283− int64_t den = AV_NOPTS_VALUE;
284− st = s->streams[i];
285−
286− switch (st->codec->codec_type) {
287− case AVMEDIA_TYPE_AUDIO:
288− den = (int64_t)st->time_base.num * st->codec->sample_rate;
289− break;
290− case AVMEDIA_TYPE_VIDEO:
291− den = (int64_t)st->time_base.num * st->codec->time_base.den;
292− break;
293− default:
294− break;
295− }
296− if (den != AV_NOPTS_VALUE) {
297− if (den <= 0)
298− return AVERROR_INVALIDDATA;
299−
300− frac_init(&st->pts, 0, 0, den);
301− }
302− }
303−
304− return 0;
305−}
306−
307226 int avformat_write_header(AVFormatContext *s, AVDictionary **options)
308227 {
309228 int ret = 0;
@@ -317,9 +236,6 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) · 7 unmodified lines
317236 return ret;
318237 }
319238
320− if ((ret = init_pts(s)) < 0)
321− return ret;
322−
323239 return 0;
324240 }
325241
@@ -327,7 +243,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) · 1 unmodified line
327243 static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
328244 {
329245 int delay = FFMAX(st->codec->has_b_frames, !!st->codec->max_b_frames);
330− int num, den, frame_size, i;
246+ int num, den, i;
331247
332248 av_dlog(s, "compute_pkt_fields2: pts:%" PRId64 " dts:%" PRId64 " cur_dts:%" PRId64 " b:%d size:%d st:%d\n",
333249 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) · 39 unmodified lines
373289 av_dlog(s, "av_write_frame: pts2:%"PRId64" dts2:%"PRId64"\n",
374290 pkt->pts, pkt->dts);
375291 st->cur_dts = pkt->dts;
376− st->pts.val = pkt->dts;
377−
378− /* update pts */
379− switch (st->codec->codec_type) {
380− case AVMEDIA_TYPE_AUDIO:
381− frame_size = ff_get_audio_frame_size(st->codec, pkt->size, 1);
382−
383− /* HACK/FIXME, we skip the initial 0 size packets as they are most
384− * likely equal to the encoder delay, but it would be better if we
385− * had the real timestamps from the encoder */
386− if (frame_size >= 0 && (pkt->size || st->pts.num != st->pts.den >> 1 || st->pts.val)) {
387− frac_add(&st->pts, (int64_t)st->time_base.den * frame_size);
388− }
389− break;
390− case AVMEDIA_TYPE_VIDEO:
391− frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num);
392− break;
393− default:
394− break;
395− }
292+
396293 return 0;
397294 }
398295
libavformat/version.h+4−1
@@ -31,7 +31,7 @@ · 30 unmodified lines
3131
3232 #define LIBAVFORMAT_VERSION_MAJOR 55
3333 #define LIBAVFORMAT_VERSION_MINOR 17
34−#define LIBAVFORMAT_VERSION_MICRO 0
34+#define LIBAVFORMAT_VERSION_MICRO 1
3535
3636 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3737 LIBAVFORMAT_VERSION_MINOR, \
@@ -54,5 +54,8 @@ · 16 unmodified lines
5454 #ifndef FF_API_LAVF_BITEXACT
5555 #define FF_API_LAVF_BITEXACT (LIBAVFORMAT_VERSION_MAJOR < 56)
5656 #endif
57+#ifndef FF_API_LAVF_FRAC
58+#define FF_API_LAVF_FRAC (LIBAVFORMAT_VERSION_MAJOR < 57)
59+#endif
5760
5861 #endif /* AVFORMAT_VERSION_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t