[Ffmpeg-devel] [PATCH] get rid of AVFrac

Reimar Döffinger Reimar.Doeffinger
Fri Oct 13 01:22:06 CEST 2006


Hello,
since it is marked as deprecated...
Does the attached path look correct to you?
And would this need a version increment?

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavformat/avformat.h
===================================================================
--- libavformat/avformat.h	(revision 6679)
+++ libavformat/avformat.h	(working copy)
@@ -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 6679)
+++ 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. */
@@ -2221,7 +2217,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 +2242,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 +2251,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 +3030,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