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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162014-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
162014-05-18 - fd05602 - lavc 55.52.0 - avcodec.h212014-05-18 - fd05602 - lavc 55.52.0 - avcodec.h
17 Add avcodec_free_context(). From now on it should be used for freeing22 Add avcodec_free_context(). From now on it should be used for freeing
18 AVCodecContext.23 AVCodecContext.
libavformat/avformat.h+6−1
@@ -366,6 +366,7 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size); · 365 unmodified lines
366 */366 */
367int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);367int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
368 368
369#if FF_API_LAVF_FRAC
369/*************************************************/370/*************************************************/
370/* fractional numbers for exact pts handling */371/* fractional numbers for exact pts handling */
371 372
@@ -376,6 +377,7 @@ int av_append_packet(AVIOContext *s, AVPacket *pkt, int size); · 4 unmodified lines
376typedef struct AVFrac {377typedef struct AVFrac {
377 int64_t val, num, den;378 int64_t val, num, den;
378} AVFrac;379} AVFrac;
380#endif
379 381
380/*************************************************/382/*************************************************/
381/* input/output formats */383/* input/output formats */
@@ -695,10 +697,13 @@ typedef struct AVStream { · 313 unmodified lines
695 AVCodecContext *codec;697 AVCodecContext *codec;
696 void *priv_data;698 void *priv_data;
697 699
700#if FF_API_LAVF_FRAC
698 /**701 /**
699 * encoding: pts generation when outputting stream702 * @deprecated this field is unused
700 */703 */
704 attribute_deprecated
701 struct AVFrac pts;705 struct AVFrac pts;
706#endif
702 707
703 /**708 /**
704 * This is the fundamental unit of time (in seconds) in terms709 * This is the fundamental unit of time (in seconds) in terms
libavformat/mux.c+2−105
@@ -51,56 +51,6 @@ · 50 unmodified lines
51 * muxing functions for use within Libav51 * muxing functions for use within Libav
52 */52 */
53 53
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 */
66static 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 */
84static 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
104static int validate_codec_tag(AVFormatContext *s, AVStream *st)54static int validate_codec_tag(AVFormatContext *s, AVStream *st)
105{55{
106 const AVCodecTag *avctag;56 const AVCodecTag *avctag;
@@ -273,37 +223,6 @@ fail: · 166 unmodified lines
273 return ret;223 return ret;
274}224}
275 225
276static 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
307int avformat_write_header(AVFormatContext *s, AVDictionary **options)226int avformat_write_header(AVFormatContext *s, AVDictionary **options)
308{227{
309 int ret = 0;228 int ret = 0;
@@ -317,9 +236,6 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) · 7 unmodified lines
317 return ret;236 return ret;
318 }237 }
319 238
320 if ((ret = init_pts(s)) < 0)
321 return ret;
322
323 return 0;239 return 0;
324}240}
325 241
@@ -327,7 +243,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options) · 1 unmodified line
327static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)243static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
328{244{
329 int delay = FFMAX(st->codec->has_b_frames, !!st->codec->max_b_frames);245 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;
331 247
332 av_dlog(s, "compute_pkt_fields2: pts:%" PRId64 " dts:%" PRId64 " cur_dts:%" PRId64 " b:%d size:%d st:%d\n",248 av_dlog(s, "compute_pkt_fields2: pts:%" PRId64 " dts:%" PRId64 " cur_dts:%" PRId64 " b:%d size:%d st:%d\n",
333 pkt->pts, pkt->dts, st->cur_dts, delay, pkt->size, pkt->stream_index);249 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
373 av_dlog(s, "av_write_frame: pts2:%"PRId64" dts2:%"PRId64"\n",289 av_dlog(s, "av_write_frame: pts2:%"PRId64" dts2:%"PRId64"\n",
374 pkt->pts, pkt->dts);290 pkt->pts, pkt->dts);
375 st->cur_dts = pkt->dts;291 st->cur_dts = pkt->dts;
376 st->pts.val = pkt->dts;292
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 }
396 return 0;293 return 0;
397}294}
398 295
libavformat/version.h+4−1
@@ -31,7 +31,7 @@ · 30 unmodified lines
31 31
32#define LIBAVFORMAT_VERSION_MAJOR 5532#define LIBAVFORMAT_VERSION_MAJOR 55
33#define LIBAVFORMAT_VERSION_MINOR 1733#define LIBAVFORMAT_VERSION_MINOR 17
34#define LIBAVFORMAT_VERSION_MICRO 034#define LIBAVFORMAT_VERSION_MICRO 1
35 35
36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
37 LIBAVFORMAT_VERSION_MINOR, \37 LIBAVFORMAT_VERSION_MINOR, \
@@ -54,5 +54,8 @@ · 16 unmodified lines
54#ifndef FF_API_LAVF_BITEXACT54#ifndef FF_API_LAVF_BITEXACT
55#define FF_API_LAVF_BITEXACT (LIBAVFORMAT_VERSION_MAJOR < 56)55#define FF_API_LAVF_BITEXACT (LIBAVFORMAT_VERSION_MAJOR < 56)
56#endif56#endif
57#ifndef FF_API_LAVF_FRAC
58#define FF_API_LAVF_FRAC (LIBAVFORMAT_VERSION_MAJOR < 57)
59#endif
57 60
58#endif /* AVFORMAT_VERSION_H */61#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