summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authoriive <iive@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-09-01 10:50:36 +0000
committeriive <iive@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-09-01 10:50:36 +0000
commite371194632d839fbafd5941941f5444584f227c0 (patch)
tree70062f7ad1a2f1b3cc1fbd8640e20e43d620fdab /libmpcodecs
parentce81a2156b247d7203f078884043134c93ebe58b (diff)
downloadmpv-e371194632d839fbafd5941941f5444584f227c0.tar.bz2
mpv-e371194632d839fbafd5941941f5444584f227c0.tar.xz
Remove imported rational calculation code and use the original one from avutil.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24315 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ve_xvid4.c94
1 files changed, 11 insertions, 83 deletions
diff --git a/libmpcodecs/ve_xvid4.c b/libmpcodecs/ve_xvid4.c
index 0533bbc8b7..5e52c93489 100644
--- a/libmpcodecs/ve_xvid4.c
+++ b/libmpcodecs/ve_xvid4.c
@@ -56,6 +56,12 @@
#include "m_option.h"
+#ifdef USE_LIBAVUTIL_SO
+#include <ffmpeg/avutil.h>
+#else
+#include "avutil.h"
+#endif
+
#define FINE (!0)
#define BAD (!FINE)
@@ -95,84 +101,6 @@ typedef struct
unsigned int flags; ///< flags for allowed options/dxn note the definitions for PROFILE_S and PROFILE_AS
} profile_t;
-// Code taken from Libavcodec and ve_lavc.c to handle Aspect Ratio calculation
-
-typedef struct xvid_rational_s{
- int num;
- int den;
-} XVIDRational;
-
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#define ABS(a) ((a) >= 0 ? (a) : (-(a)))
-
-
-static int64_t xvid_gcd(int64_t a, int64_t b){
- if(b) return xvid_gcd(b, a%b);
- else return a;
-}
-
-static int xvid_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
- int exact=1, sign=0;
- int64_t gcd;
-
- assert(den != 0);
-
- if(den < 0){
- den= -den;
- nom= -nom;
- }
-
- if(nom < 0){
- nom= -nom;
- sign= 1;
- }
-
- gcd = xvid_gcd(nom, den);
- nom /= gcd;
- den /= gcd;
-
- if(nom > max || den > max){
- XVIDRational a0={0,1}, a1={1,0};
- exact=0;
-
- for(;;){
- int64_t x= nom / den;
- int64_t a2n= x*a1.num + a0.num;
- int64_t a2d= x*a1.den + a0.den;
-
- if(a2n > max || a2d > max) break;
-
- nom %= den;
-
- a0= a1;
- a1= (XVIDRational){a2n, a2d};
- if(nom==0) break;
- x= nom; nom=den; den=x;
- }
- nom= a1.num;
- den= a1.den;
- }
-
- assert(xvid_gcd(nom, den) == 1);
-
- if(sign) nom= -nom;
-
- *dst_nom = nom;
- *dst_den = den;
-
- return exact;
-}
-
-
-static XVIDRational xvid_d2q(double d, int max){
- XVIDRational a;
- int exponent= MAX( (int)(log(ABS(d) + 1e-20)/log(2)), 0);
- int64_t den= 1LL << (61 - exponent);
- xvid_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);
-
- return a;
-}
-
// Code taken from XviD VfW source for profile support
/* default vbv_occupancy is (64/170)*vbv_buffer_size */
@@ -734,7 +662,7 @@ static int dispatch_settings(xvid_mplayer_module_t *mod)
xvid_enc_frame_t *frame = &mod->frame;
xvid_plugin_single_t *onepass = &mod->onepass;
xvid_plugin_2pass2_t *pass2 = &mod->pass2;
- XVIDRational ar;
+ AVRational ar;
const int motion_presets[7] =
{
@@ -977,9 +905,9 @@ static int dispatch_settings(xvid_mplayer_module_t *mod)
if( !(selected_profile->flags & PROFILE_DXN) )
{
if(xvidenc_dar_aspect > 0)
- ar = xvid_d2q(xvidenc_dar_aspect * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255);
+ ar = av_d2q(xvidenc_dar_aspect * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255);
else if(xvidenc_autoaspect)
- ar = xvid_d2q((float)mod->d_width / mod->d_height * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255);
+ ar = av_d2q((float)mod->d_width / mod->d_height * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255);
else ar.num = ar.den = 0;
if(ar.den != 0) {
@@ -1164,8 +1092,8 @@ static int set_create_struct(xvid_mplayer_module_t *mod)
/* Quantizer mode uses the same plugin, we have only to define
* a constant quantizer zone beginning at frame 0 */
if(pass == MODE_QUANT) {
- XVIDRational squant;
- squant = xvid_d2q(xvidenc_quantizer,128);
+ AVRational squant;
+ squant = av_d2q(xvidenc_quantizer,128);
create->zones[create->num_zones].mode = XVID_ZONE_QUANT;
create->zones[create->num_zones].frame = 0;