[MPlayer-cvslog] r24917 - in trunk/libaf: af.c af.h af_resample.c

uau subversion at mplayerhq.hu
Thu Nov 1 07:52:06 CET 2007


Author: uau
Date: Thu Nov  1 07:52:06 2007
New Revision: 24917

Log:
libaf: Remove rational number implementation

Remove the mul/cancel/gcd functions and some related code. Use ff_gcd
instead of the removed af_gcd in af_resample.c.


Modified:
   trunk/libaf/af.c
   trunk/libaf/af.h
   trunk/libaf/af_resample.c

Modified: trunk/libaf/af.c
==============================================================================
--- trunk/libaf/af.c	(original)
+++ trunk/libaf/af.c	Thu Nov  1 07:52:06 2007
@@ -604,53 +604,6 @@ af_instance_t *af_control_any_rev (af_st
   return NULL;
 }
 
-/**
- * \brief calculate greatest common divisior of a and b.
- * \ingroup af_filter
- *
- *   If both are 0 the result is 1.
- */
-int af_gcd(register int a, register int b) {
-  while (b != 0) {
-    a %= b;
-    if (a == 0)
-      break;
-    b %= a;
-  }
-  // the result is either in a or b. As the other one is 0 just add them.
-  a += b;
-  if (!a)
-    return 1;
-  return a;
-}
-
-/**
- * \brief cancel down a fraction f
- * \param f fraction to cancel down
- * \ingroup af_filter
- */
-void af_frac_cancel(frac_t *f) {
-  int gcd = af_gcd(f->n, f->d);
-  f->n /= gcd;
-  f->d /= gcd;
-}
-
-/**
- * \brief multiply out by in and store result in out.
- * \param out [inout] fraction to multiply by in
- * \param in [in] fraction to multiply out by
- * \ingroup af_filter
- *
- *        the resulting fraction will be cancelled down
- *        if in and out were.
- */
-void af_frac_mul(frac_t *out, const frac_t *in) {
-  int gcd1 = af_gcd(out->n, in->d);
-  int gcd2 = af_gcd(in->n, out->d);
-  out->n = (out->n / gcd1) * (in->n / gcd2);
-  out->d = (out->d / gcd2) * (in->d / gcd1);
-}
-
 void af_help (void) {
   int i = 0;
   af_msg(AF_MSG_INFO, "Available audio filters:\n");

Modified: trunk/libaf/af.h
==============================================================================
--- trunk/libaf/af.h	(original)
+++ trunk/libaf/af.h	Thu Nov  1 07:52:06 2007
@@ -26,16 +26,6 @@ typedef struct af_data_s
   int bps; 	// bytes per sample
 } af_data_t;
 
-// Fraction, used to calculate buffer lengths
-typedef struct frac_s
-{
-  int n; // Numerator
-  int d; // Denominator
-} frac_t;
-
-int af_gcd(register int a, register int b);
-void af_frac_cancel(frac_t *f);
-void af_frac_mul(frac_t *out, const frac_t *in);
 
 // Flags used for defining the behavior of an audio filter
 #define AF_FLAGS_REENTRANT 	0x00000000

Modified: trunk/libaf/af_resample.c
==============================================================================
--- trunk/libaf/af_resample.c	(original)
+++ trunk/libaf/af_resample.c	Thu Nov  1 07:52:06 2007
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 #include <inttypes.h>
 
+#include "libavutil/common.h"
 #include "af.h"
 #include "dsp.h"
 
@@ -189,7 +190,7 @@ static int control(struct af_instance_s*
     }
 
     // Calculate up and down sampling factors
-    d=af_gcd(af->data->rate,n->rate);
+    d=ff_gcd(af->data->rate,n->rate);
 
     // If sloppy resampling is enabled limit the upsampling factor
     if(((s->setup & FREQ_MASK) == FREQ_SLOPPY) && (af->data->rate/d > 5000)){
@@ -197,7 +198,7 @@ static int control(struct af_instance_s*
       int dn=n->rate/2;
       int m=2;
       while(af->data->rate/(d*m) > 5000){
-	d=af_gcd(up,dn); 
+	d=ff_gcd(up,dn);
 	up/=2; dn/=2; m*=2;
       }
       d*=m;



More information about the MPlayer-cvslog mailing list