shithub: libvpx

Download patch

ref: 24bc1a7189724e1b67703a6165ec7e170ce784d6
parent: c9071601a251d773e95eeb5f94aff919174de398
author: John Koleszar <jkoleszar@google.com>
date: Mon Jan 14 06:49:30 EST 2013

Use INT64_MAX instead of LLONG_MAX

These variables have the type int64_t, not long long. long long could
be a larger type than 64 bits. Emulate INT64_MAX for older versions of
MSVC, and remove the unreferenced vpx_ports/vpxtypes.h

Change-Id: Ideaca71838fcd3849d816d5ab17aa347c97d03b0

--- a/vp9/common/vp9_implicit_segmentation.c
+++ b/vp9/common/vp9_implicit_segmentation.c
@@ -33,8 +33,8 @@
   int min_y;
   int max_x;
   int max_y;
-  long long sum_x;
-  long long sum_y;
+  int64_t sum_x;
+  int64_t sum_y;
   int pixels;
   int seg_value;
   int label;
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -794,7 +794,7 @@
   return -(log(prob) / log(2.0));
 }
 
-static long long estimate_modemvcost(VP9_COMP *cpi,
+static int64_t estimate_modemvcost(VP9_COMP *cpi,
                                      FIRSTPASS_STATS *fpstats) {
 #if 0
   int mv_cost;
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -1727,10 +1727,7 @@
 
 #endif
 
-#ifndef LLONG_MAX
-#define LLONG_MAX  9223372036854775807LL
-#endif
-  cpi->first_time_stamp_ever = LLONG_MAX;
+  cpi->first_time_stamp_ever = INT64_MAX;
 
   cpi->frames_till_gf_update_due      = 0;
   cpi->key_frame_count              = 1;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1088,7 +1088,7 @@
                                      int *bestdistortion) {
   B_PREDICTION_MODE mode;
   MACROBLOCKD *xd = &x->e_mbd;
-  int64_t best_rd = LLONG_MAX;
+  int64_t best_rd = INT64_MAX;
   int rate = 0;
   int distortion;
 
@@ -1243,7 +1243,7 @@
   }
 
   if (total_rd >= best_rd)
-    return LLONG_MAX;
+    return INT64_MAX;
 
   *Rate = cost;
   *rate_y = tot_rate_y;
@@ -1263,7 +1263,7 @@
   MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
   int this_rate, this_rate_tokenonly;
   int this_distortion, s;
-  int64_t best_rd = LLONG_MAX, this_rd;
+  int64_t best_rd = INT64_MAX, this_rd;
 
   /* Y Search for 32x32 intra prediction mode */
   for (mode = DC_PRED; mode <= TM_PRED; mode++) {
@@ -1303,7 +1303,7 @@
   MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
   int this_rate, this_rate_tokenonly;
   int this_distortion, s;
-  int64_t best_rd = LLONG_MAX, this_rd;
+  int64_t best_rd = INT64_MAX, this_rd;
 
   /* Y Search for 32x32 intra prediction mode */
   for (mode = DC_PRED; mode <= TM_PRED; mode++) {
@@ -1346,12 +1346,12 @@
   MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
   int rate, ratey;
   int distortion, skip;
-  int64_t best_rd = LLONG_MAX;
+  int64_t best_rd = INT64_MAX;
   int64_t this_rd;
 
   int i;
   for (i = 0; i < NB_TXFM_MODES; i++)
-    txfm_cache[i] = LLONG_MAX;
+    txfm_cache[i] = INT64_MAX;
 
   // Y Search for 16x16 intra prediction mode
   for (mode = DC_PRED; mode <= TM_PRED; mode++) {
@@ -1403,7 +1403,7 @@
                                      int *bestdistortion) {
   MB_PREDICTION_MODE mode;
   MACROBLOCKD *xd = &x->e_mbd;
-  int64_t best_rd = LLONG_MAX;
+  int64_t best_rd = INT64_MAX;
   int distortion = 0, rate = 0;
   BLOCK  *be = x->block + ib;
   BLOCKD *b = xd->block + ib;
@@ -1528,7 +1528,7 @@
   int cost = mb->mbmode_cost [xd->frame_type] [I8X8_PRED];
   int distortion = 0;
   int tot_rate_y = 0;
-  long long total_rd = 0;
+  int64_t total_rd = 0;
   ENTROPY_CONTEXT_PLANES t_above, t_left;
   ENTROPY_CONTEXT *ta, *tl;
   int *i8x8mode_costs;
@@ -1769,7 +1769,7 @@
   MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
-  int64_t best_rd = LLONG_MAX;
+  int64_t best_rd = INT64_MAX;
   int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r);
   int rate_to, UNINITIALIZED_IS_SAFE(skip);
 
@@ -1821,7 +1821,7 @@
   MB_PREDICTION_MODE mode;
   MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
   MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
-  int64_t best_rd = LLONG_MAX;
+  int64_t best_rd = INT64_MAX;
   int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r);
   int rate_to, UNINITIALIZED_IS_SAFE(skip);
 
@@ -2010,7 +2010,7 @@
                                        int *skippable) {
   MB_PREDICTION_MODE mode;
   MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
-  int64_t best_rd = LLONG_MAX, this_rd;
+  int64_t best_rd = INT64_MAX, this_rd;
   int this_rate_tokenonly, this_rate;
   int this_distortion, s;
 
@@ -2047,7 +2047,7 @@
                                          int *skippable) {
   MB_PREDICTION_MODE mode;
   MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(mode_selected);
-  int64_t best_rd = LLONG_MAX, this_rd;
+  int64_t best_rd = INT64_MAX, this_rd;
   int this_rate_tokenonly, this_rate;
   int this_distortion, s;
 
@@ -2442,7 +2442,7 @@
   mbmi->txfm_size = tx_size;
   for (i = 0; i < label_count && this_segment_rd < bsi->segment_rd; i++) {
     int_mv mode_mv[B_MODE_COUNT], second_mode_mv[B_MODE_COUNT];
-    int64_t best_label_rd = LLONG_MAX, best_other_rd = LLONG_MAX;
+    int64_t best_label_rd = INT64_MAX, best_other_rd = INT64_MAX;
     B_PREDICTION_MODE mode_selected = ZERO4X4;
     int bestlabelyrate = 0;
 
@@ -2780,7 +2780,7 @@
 
   vpx_memset(&bsi, 0, sizeof(bsi));
   for (i = 0; i < NB_TXFM_MODES; i++)
-    txfm_cache[i] = LLONG_MAX;
+    txfm_cache[i] = INT64_MAX;
 
   bsi.segment_rd = best_rd;
   bsi.ref_mv = best_ref_mv;
@@ -3238,7 +3238,7 @@
       if (is_comp_pred) {
         if (frame_mv[NEWMV][refs[0]].as_int == INVALID_MV ||
             frame_mv[NEWMV][refs[1]].as_int == INVALID_MV)
-          return LLONG_MAX;
+          return INT64_MAX;
         *rate2 += vp9_mv_bit_cost(&frame_mv[NEWMV][refs[0]],
                                   &ref_mv[0],
                                   x->nmvjointcost, x->mvcost, 96,
@@ -3312,7 +3312,7 @@
       // near) is 0,0 as this should then be coded using the zeromv mode.
       for (i = 0; i < num_refs; ++i)
         if (frame_mv[this_mode][refs[i]].as_int == 0)
-          return LLONG_MAX;
+          return INT64_MAX;
     case ZEROMV:
     default:
       break;
@@ -3322,7 +3322,7 @@
     // Clip "next_nearest" so that it does not extend to far out of image
     clamp_mv2(&cur_mv[i], xd);
     if (mv_check_bounds(x, &cur_mv[i]))
-      return LLONG_MAX;
+      return INT64_MAX;
     mbmi->mv[i].as_int = cur_mv[i].as_int;
   }
 
@@ -3536,13 +3536,13 @@
   int64_t best_txfm_diff[NB_TXFM_MODES];
   int64_t best_pred_diff[NB_PREDICTION_TYPES];
   int64_t best_pred_rd[NB_PREDICTION_TYPES];
-  int64_t best_rd = LLONG_MAX, best_intra_rd = LLONG_MAX;
+  int64_t best_rd = INT64_MAX, best_intra_rd = INT64_MAX;
 #if CONFIG_COMP_INTERINTRA_PRED
   int is_best_interintra = 0;
-  int64_t best_intra16_rd = LLONG_MAX;
+  int64_t best_intra16_rd = INT64_MAX;
   int best_intra16_mode = DC_PRED, best_intra16_uv_mode = DC_PRED;
 #endif
-  int64_t best_overall_rd = LLONG_MAX;
+  int64_t best_overall_rd = INT64_MAX;
   INTERPOLATIONFILTERTYPE best_filter = SWITCHABLE;
   int uv_intra_rate, uv_intra_distortion, uv_intra_rate_tokenonly;
   int uv_intra_skippable = 0;
@@ -3550,7 +3550,7 @@
   int uv_intra_skippable_8x8 = 0;
   int rate_y, UNINITIALIZED_IS_SAFE(rate_uv);
   int distortion_uv = INT_MAX;
-  int64_t best_yrd = LLONG_MAX;
+  int64_t best_yrd = INT64_MAX;
   int switchable_filter_index = 0;
 
   MB_PREDICTION_MODE uv_intra_mode;
@@ -3579,9 +3579,9 @@
   for (i = 0; i < MAX_REF_FRAMES; i++)
     frame_mv[NEWMV][i].as_int = INVALID_MV;
   for (i = 0; i < NB_PREDICTION_TYPES; ++i)
-    best_pred_rd[i] = LLONG_MAX;
+    best_pred_rd[i] = INT64_MAX;
   for (i = 0; i < NB_TXFM_MODES; i++)
-    best_txfm_rd[i] = LLONG_MAX;
+    best_txfm_rd[i] = INT64_MAX;
 
   for (i = 0; i < NB_PARTITIONINGS; i++) {
     int j, k;
@@ -3612,7 +3612,7 @@
                        frame_mdcounts, y_buffer, u_buffer, v_buffer);
   }
 
-  *returnintra = LLONG_MAX;
+  *returnintra = INT64_MAX;
 
   mbmi->ref_frame = INTRA_FRAME;
 
@@ -3640,7 +3640,7 @@
 
   for (mode_index = 0; mode_index < MAX_MODES;
        mode_index += (!switchable_filter_index)) {
-    int64_t this_rd = LLONG_MAX;
+    int64_t this_rd = INT64_MAX;
     int disable_skip = 0, skippable = 0;
     int other_cost = 0;
     int compmode_cost = 0;
@@ -3810,7 +3810,7 @@
             distortion2 += uv_intra_distortion;
             distortion_uv = uv_intra_distortion;
           } else {
-            this_rd = LLONG_MAX;
+            this_rd = INT64_MAX;
             disable_skip = 1;
           }
         }
@@ -3887,7 +3887,7 @@
             distortion2 += uv_intra_distortion;
             distortion_uv = uv_intra_distortion;
           } else {
-            this_rd = LLONG_MAX;
+            this_rd = INT64_MAX;
             disable_skip = 1;
           }
         }
@@ -3933,7 +3933,7 @@
         distortion2 += distortion_uv;
         skippable = skippable && uv_skippable;
       } else {
-        this_rd = LLONG_MAX;
+        this_rd = INT64_MAX;
         disable_skip = 1;
       }
 
@@ -3971,7 +3971,7 @@
                                   &rate_uv, &distortion_uv,
                                   &mode_excluded, &disable_skip, recon_yoffset,
                                   mode_index, frame_mv);
-      if (this_rd == LLONG_MAX)
+      if (this_rd == INT64_MAX)
         continue;
     }
 
@@ -4158,7 +4158,7 @@
     }
 
     /* keep record of best txfm size */
-    if (!mode_excluded && this_rd != LLONG_MAX) {
+    if (!mode_excluded && this_rd != INT64_MAX) {
       for (i = 0; i < NB_TXFM_MODES; i++) {
         int64_t adj_rd;
         if (this_mode != B_PRED) {
@@ -4256,7 +4256,7 @@
   }
 
   for (i = 0; i < NB_PREDICTION_TYPES; ++i) {
-    if (best_pred_rd[i] == LLONG_MAX)
+    if (best_pred_rd[i] == INT64_MAX)
       best_pred_diff[i] = INT_MIN;
     else
       best_pred_diff[i] = best_rd - best_pred_rd[i];
@@ -4264,7 +4264,7 @@
 
   if (!x->skip) {
     for (i = 0; i < NB_TXFM_MODES; i++) {
-      if (best_txfm_rd[i] == LLONG_MAX)
+      if (best_txfm_rd[i] == INT64_MAX)
         best_txfm_diff[i] = INT_MIN;
       else
         best_txfm_diff[i] = best_rd - best_txfm_rd[i];
@@ -4481,7 +4481,7 @@
   int mdcounts[4];
   int near_sadidx[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
   int saddone = 0;
-  int64_t best_rd = LLONG_MAX;
+  int64_t best_rd = INT64_MAX;
   int64_t best_txfm_rd[NB_TXFM_MODES];
   int64_t best_txfm_diff[NB_TXFM_MODES];
   int64_t best_pred_diff[NB_PREDICTION_TYPES];
@@ -4491,10 +4491,10 @@
   unsigned int ref_costs[MAX_REF_FRAMES];
 #if CONFIG_COMP_INTERINTRA_PRED
   int is_best_interintra = 0;
-  int64_t best_intra16_rd = LLONG_MAX;
+  int64_t best_intra16_rd = INT64_MAX;
   int best_intra16_mode = DC_PRED, best_intra16_uv_mode = DC_PRED;
 #endif
-  int64_t best_overall_rd = LLONG_MAX;
+  int64_t best_overall_rd = INT64_MAX;
   INTERPOLATIONFILTERTYPE best_filter = SWITCHABLE;
   int rate_uv_4x4 = 0, rate_uv_8x8 = 0, rate_uv_tokenonly_4x4 = 0,
       rate_uv_tokenonly_8x8 = 0;
@@ -4511,9 +4511,9 @@
   vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
 
   for (i = 0; i < NB_PREDICTION_TYPES; ++i)
-    best_pred_rd[i] = LLONG_MAX;
+    best_pred_rd[i] = INT64_MAX;
   for (i = 0; i < NB_TXFM_MODES; i++)
-    best_txfm_rd[i] = LLONG_MAX;
+    best_txfm_rd[i] = INT64_MAX;
 
   for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
     if (cpi->ref_frame_flags & flag_list[ref_frame]) {
@@ -4573,7 +4573,7 @@
   for (mode_index = 0; mode_index < MAX_MODES;
        mode_index += (!switchable_filter_index)) {
     int mode_excluded = 0;
-    int64_t this_rd = LLONG_MAX;
+    int64_t this_rd = INT64_MAX;
     int disable_skip = 0;
     int other_cost = 0;
     int compmode_cost = 0;
@@ -4744,7 +4744,7 @@
                                   &rate_uv, &distortion_uv,
                                   &mode_excluded, &disable_skip, recon_yoffset,
                                   mode_index, frame_mv);
-      if (this_rd == LLONG_MAX)
+      if (this_rd == INT64_MAX)
         continue;
     }
 
@@ -4908,7 +4908,7 @@
     }
 
     /* keep record of best txfm size */
-    if (!mode_excluded && this_rd != LLONG_MAX) {
+    if (!mode_excluded && this_rd != INT64_MAX) {
       for (i = 0; i < NB_TXFM_MODES; i++) {
         int64_t adj_rd;
         if (this_mode != B_PRED) {
@@ -4982,7 +4982,7 @@
   vpx_memcpy(mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
 
   for (i = 0; i < NB_PREDICTION_TYPES; ++i) {
-    if (best_pred_rd[i] == LLONG_MAX)
+    if (best_pred_rd[i] == INT64_MAX)
       best_pred_diff[i] = INT_MIN;
     else
       best_pred_diff[i] = best_rd - best_pred_rd[i];
@@ -4990,7 +4990,7 @@
 
   if (!x->skip) {
     for (i = 0; i < NB_TXFM_MODES; i++) {
-      if (best_txfm_rd[i] == LLONG_MAX)
+      if (best_txfm_rd[i] == INT64_MAX)
         best_txfm_diff[i] = INT_MIN;
       else
         best_txfm_diff[i] = best_rd - best_txfm_rd[i];
--- a/vpx/vpx_integer.h
+++ b/vpx/vpx_integer.h
@@ -27,6 +27,7 @@
 #if (defined(_MSC_VER) && (_MSC_VER < 1600))
 typedef signed __int64   int64_t;
 typedef unsigned __int64 uint64_t;
+#define INT64_MAX _I64_MAX
 #endif
 
 #ifndef _UINTPTR_T_DEFINED
--- a/vpx_ports/vpxtypes.h
+++ /dev/null
@@ -1,166 +1,0 @@
-/*
- *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-
-#ifndef __VPXTYPES_H__
-#define __VPXTYPES_H__
-
-#include "vpx_config.h"
-
-// #include <sys/types.h>
-#ifdef _MSC_VER
-# include <basetsd.h>
-typedef SSIZE_T ssize_t;
-#endif
-
-#if defined(HAVE_STDINT_H) && HAVE_STDINT_H
-/* C99 types are preferred to vpx integer types */
-# include <stdint.h>
-#endif
-
-/*!\defgroup basetypes Base Types
-  @{*/
-#if !defined(HAVE_STDINT_H) && !defined(INT_T_DEFINED)
-# ifdef STRICTTYPES
-typedef signed char  int8_t;
-typedef signed short int16_t;
-typedef signed int   int32_t;
-# else
-typedef char         int8_t;
-typedef short        int16_t;
-typedef int          int32_t;
-# endif
-typedef unsigned char  uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int   uint32_t;
-#endif
-
-typedef int8_t     vpxs8;
-typedef uint8_t    vpxu8;
-typedef int16_t    vpxs16;
-typedef uint16_t   vpxu16;
-typedef int32_t    vpxs32;
-typedef uint32_t   vpxu32;
-typedef int32_t    vpxbool;
-
-enum {vpxfalse, vpxtrue};
-
-/*!\def OTC
-   \brief a macro suitable for declaring a constant #vpxtc*/
-/*!\def VPXTC
-   \brief printf format string suitable for printing an #vpxtc*/
-#ifdef UNICODE
-# ifdef NO_WCHAR
-#  error "no non-wchar support added yet"
-# else
-#  include <wchar.h>
-typedef wchar_t vpxtc;
-#  define OTC(str) L ## str
-#  define VPXTC "ls"
-# endif /*NO_WCHAR*/
-#else
-typedef char vpxtc;
-# define OTC(str) (vpxtc*)str
-# define VPXTC "s"
-#endif /*UNICODE*/
-/*@} end - base types*/
-
-/*!\addtogroup basetypes
-  @{*/
-/*!\def VPX64
-   \brief printf format string suitable for printing an #vpxs64*/
-#if defined(HAVE_STDINT_H)
-# define VPX64 PRId64
-typedef int64_t vpxs64;
-#elif defined(HASLONGLONG)
-# undef  PRId64
-# define PRId64 "lld"
-# define VPX64 PRId64
-typedef long long vpxs64;
-#elif defined(WIN32) || defined(_WIN32_WCE)
-# undef  PRId64
-# define PRId64 "I64d"
-# define VPX64 PRId64
-typedef __int64 vpxs64;
-typedef unsigned __int64 vpxu64;
-#elif defined(__uClinux__) && defined(CHIP_DM642)
-# include <lddk.h>
-# undef  PRId64
-# define PRId64 "lld"
-# define VPX64 PRId64
-typedef long vpxs64;
-#else
-# error "64 bit integer type undefined for this platform!"
-#endif
-#if !defined(HAVE_STDINT_H) && !defined(INT_T_DEFINED)
-typedef vpxs64 int64_t;
-typedef vpxu64 uint64_t;
-#endif
-/*!@} end - base types*/
-
-/*!\ingroup basetypes
-   \brief Common return type*/
-typedef enum {
-  VPX_NOT_FOUND        = -404,
-  VPX_BUFFER_EMPTY     = -202,
-  VPX_BUFFER_FULL      = -201,
-
-  VPX_CONNREFUSED      = -102,
-  VPX_TIMEDOUT         = -101,
-  VPX_WOULDBLOCK       = -100,
-
-  VPX_NET_ERROR        = -9,
-  VPX_INVALID_VERSION  = -8,
-  VPX_INPROGRESS       = -7,
-  VPX_NOT_SUPP         = -6,
-  VPX_NO_MEM           = -3,
-  VPX_INVALID_PARAMS   = -2,
-  VPX_ERROR            = -1,
-  VPX_OK               = 0,
-  VPX_DONE             = 1
-} vpxsc;
-
-#if defined(WIN32) || defined(_WIN32_WCE)
-# define DLLIMPORT __declspec(dllimport)
-# define DLLEXPORT __declspec(dllexport)
-# define DLLLOCAL
-#elif defined(LINUX)
-# define DLLIMPORT
-/*visibility attribute support is available in 3.4 and later.
-  see: http:// gcc.gnu.org/wiki/Visibility for more info*/
-# if defined(__GNUC__) && ((__GNUC__<<16|(__GNUC_MINOR__&0xff)) >= (3<<16|4))
-#  define GCC_HASCLASSVISIBILITY
-# endif /*defined(__GNUC__) && __GNUC_PREREQ(3,4)*/
-# ifdef GCC_HASCLASSVISIBILITY
-#  define DLLEXPORT   __attribute__ ((visibility("default")))
-#  define DLLLOCAL __attribute__ ((visibility("hidden")))
-# else
-#  define DLLEXPORT
-#  define DLLLOCAL
-# endif /*GCC_HASCLASSVISIBILITY*/
-#endif /*platform ifdefs*/
-
-#endif /*__VPXTYPES_H__*/
-
-#undef VPXAPI
-/*!\def VPXAPI
-   \brief library calling convention/storage class attributes.
-
-   Specifies whether the function is imported through a dll
-   or is from a static library.*/
-#ifdef VPXDLL
-# ifdef VPXDLLEXPORT
-#  define VPXAPI DLLEXPORT
-# else
-#  define VPXAPI DLLIMPORT
-# endif /*VPXDLLEXPORT*/
-#else
-# define VPXAPI
-#endif /*VPXDLL*/
--