* 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;
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 */
{
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 ) )
{
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 */
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));
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;