]> git.sesse.net Git - x264/blobdiff - muxers.c
move os/compiler specific defines to their own header
[x264] / muxers.c
index dc825b6e2877cac905da590e751ed95bedd84313..46315367a2c757ee6b3d65368bb66b1f1e25f186 100644 (file)
--- a/muxers.c
+++ b/muxers.c
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define _LARGEFILE_SOURCE
-#define _FILE_OFFSET_BITS 64
-
-#include <stdio.h>
-#include <string.h>
 #include <sys/types.h>
 
 #include "common/common.h"
 #include <gpac/isomedia.h>
 #endif
 
+static int64_t gcd( int64_t a, int64_t b )
+{
+    while (1)
+    {
+        int64_t c = a % b;
+        if( !c )
+            return b;
+        a = b;
+        b = c;
+    }
+}
+
 typedef struct {
     FILE *fh;
     int width, height;
@@ -106,7 +113,9 @@ int close_file_yuv(hnd_t handle)
     yuv_input_t *h = handle;
     if( !h || !h->fh )
         return 0;
-    return fclose(h->fh);
+    fclose( h->fh );
+    free( h );
+    return 0;
 }
 
 /* YUV4MPEG2 raw 420 yuv file operation */
@@ -243,7 +252,7 @@ int get_frame_total_y4m( hnd_t handle )
 {
     y4m_input_t *h             = handle;
     int          i_frame_total = 0;
-    off_t        init_pos      = ftell(h->fh);
+    uint64_t     init_pos      = ftell(h->fh);
 
     if( !fseek( h->fh, 0, SEEK_END ) )
     {
@@ -307,7 +316,9 @@ int close_file_y4m(hnd_t handle)
     y4m_input_t *h = handle;
     if( !h || !h->fh )
         return 0;
-    return fclose(h->fh);
+    fclose( h->fh );
+    free( h );
+    return 0;
 }
 
 /* avs/avi input file support under cygwin */
@@ -318,20 +329,6 @@ typedef struct {
     int width, height;
 } avis_input_t;
 
-int gcd(int a, int b)
-{
-    int c;
-
-    while (1)
-    {
-        c = a % b;
-        if (!c)
-            return b;
-        a = b;
-        b = c;
-    }
-}
-
 int open_file_avis( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param )
 {
     avis_input_t *h = malloc(sizeof(avis_input_t));
@@ -895,19 +892,9 @@ int set_param_mkv( hnd_t handle, x264_param_t *p_param )
 
     if( dw > 0 && dh > 0 )
     {
-        int64_t a = dw, b = dh;
-
-        for (;;)
-        {
-            int64_t c = a % b;
-            if( c == 0 )
-              break;
-            a = b;
-            b = c;
-        }
-
-        dw /= b;
-        dh /= b;
+        int64_t x = gcd( dw, dh );
+        dw /= x;
+        dh /= x;
     }
 
     p_mkv->d_width = (int)dw;