[Ffmpeg-devel] [PATCH] get rid of AVFrac
Reimar Döffinger
Reimar.Doeffinger
Fri Oct 13 14:48:06 CEST 2006
Hello,
On Fri, Oct 13, 2006 at 01:18:10PM +0200, Michael Niedermayer wrote:
> On Fri, Oct 13, 2006 at 01:22:06AM +0200, Reimar D?ffinger wrote:
> > Hello,
> > since it is marked as deprecated...
> > Does the attached path look correct to you?
>
> /libavformat/libavformat.a(utils.o): In function `av_write_header':
> /home/michael/ffmpeg-svn/trunk/libavformat/utils.c:2193: undefined reference to `av_frac_init'
Fixed.
> > And would this need a version increment?
>
> did anyone use the av frac stuff? if yes then yes a version increment is
> needed
Well, that exactly is the question... I have no idea if someone might
have used it.
Attached patch would change the version number.
Of course such a version change just because of this seems a bit
"overkill" to me, but the alternative would be an ifdef mess like done on other
occasions. I don't like that much, but if that is preferred I could come up
with a patch for that way as well.
I also though about only removing the uses of AVFrac but not the
functions, but I think that would not help because it still would change the
AVFormatContext (or wouldn't this require a version increment?).
Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavformat/avformat.h
===================================================================
--- libavformat/avformat.h (revision 6681)
+++ libavformat/avformat.h (working copy)
@@ -25,8 +25,8 @@
extern "C" {
#endif
-#define LIBAVFORMAT_VERSION_INT ((50<<16)+(6<<8)+0)
-#define LIBAVFORMAT_VERSION 50.6.0
+#define LIBAVFORMAT_VERSION_INT ((51<<16)+(6<<8)+0)
+#define LIBAVFORMAT_VERSION 51.6.0
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
@@ -93,15 +93,6 @@
}
/*************************************************/
-/* fractional numbers for exact pts handling */
-
-/* the exact value of the fractional number is: 'val + num / den'. num
- is assumed to be such as 0 <= num < den */
-typedef struct AVFrac {
- int64_t val, num, den;
-} AVFrac attribute_deprecated;
-
-/*************************************************/
/* input/output formats */
struct AVFormatContext;
@@ -246,7 +237,7 @@
int64_t codec_info_duration;
int codec_info_nb_frames;
/* encoding: PTS generation when outputing stream */
- AVFrac pts;
+ int64_t pts;
/**
* this is the fundamental unit of time (in seconds) in terms
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c (revision 6681)
+++ libavformat/utils.c (working copy)
@@ -30,10 +30,6 @@
* Various utility functions for using ffmpeg library.
*/
-static void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den);
-static void av_frac_add(AVFrac *f, int64_t incr);
-static void av_frac_set(AVFrac *f, int64_t val);
-
/** head of registered input format linked list. */
AVInputFormat *first_iformat = NULL;
/** head of registered output format linked list. */
@@ -2193,7 +2189,6 @@
if (den != AV_NOPTS_VALUE) {
if (den <= 0)
return AVERROR_INVALIDDATA;
- av_frac_init(&st->pts, 0, 0, den);
}
}
return 0;
@@ -2221,7 +2216,7 @@
if((pkt->pts == 0 || pkt->pts == AV_NOPTS_VALUE) && pkt->dts == AV_NOPTS_VALUE && !delay){
pkt->dts=
// pkt->pts= st->cur_dts;
- pkt->pts= st->pts.val;
+ pkt->pts= st->pts;
}
//calculate dts from pts
@@ -2246,7 +2241,7 @@
// av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts2:%lld dts2:%lld\n", pkt->pts, pkt->dts);
st->cur_dts= pkt->dts;
- st->pts.val= pkt->dts;
+ st->pts= pkt->dts;
/* update pts */
switch (st->codec->codec_type) {
@@ -2255,12 +2250,12 @@
/* 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)) {
- av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size);
+ if (frame_size >= 0 && (pkt->size || st->pts)) {
+ st->pts += (int64_t)st->time_base.den * frame_size;
}
break;
case CODEC_TYPE_VIDEO:
- av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num);
+ st->pts += (int64_t)st->time_base.den * st->codec->time_base.num;
break;
default:
break;
@@ -3034,66 +3029,7 @@
s->time_base.den = pts_den;
}
-/* 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 av_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;
-}
-
-/**
- * Set f to (val + 0.5).
- */
-static void av_frac_set(AVFrac *f, int64_t val)
-{
- f->val = val;
- f->num = f->den >> 1;
-}
-
-/**
- * Fractionnal addition to f: f = f + (incr / f->den).
- *
- * @param f fractional number
- * @param incr increment, can be positive or negative
- */
-static void av_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;
-}
-
-/**
* register a new image format
* @param img_fmt Image format descriptor
*/
More information about the ffmpeg-devel
mailing list