[FFmpeg-devel] Fwd: [PATCH] Change all uses of restrict to use av_restrict instead.

Ronald S. Bultje rsbultje at gmail.com
Sat Jun 16 23:57:56 CEST 2012


Hi,

interested in the below patch? It's part of a port to MSVC which I
have working locally.

Ronald

---------- Forwarded message ----------
From: Ronald S. Bultje <rsbultje at gmail.com>
Date: Fri, Jun 15, 2012 at 6:52 PM
Subject: [PATCH] Change all uses of restrict to use av_restrict instead.
To: libav-devel at libav.org
Cc: "Ronald S. Bultje" <rsbultje at gmail.com>


From: "Ronald S. Bultje" <rsbultje at gmail.com>

Defining restrict results - for some compilers - in changing other
uses of the restrict keyword also, e.g. __declspec(restrict) gets
changed to __declspec(__restrict) on MSVC. This causes compilation
failures. Therefore, using a private namespace macro instead is
more reliable and robust.
---
 configure                 |    2 +-
 libavcodec/dsputil.c      |    2 +-
 libavcodec/dsputil.h      |    2 +-
 libavcodec/ituh263dec.c   |    2 +-
 libavcodec/mpegvideo.c    |    4 ++--
 libavformat/rtpenc.h      |    4 ++--
 libavformat/rtpenc_h263.c |    4 ++--
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 4bb2030..a24bd52 100755
--- a/configure
+++ b/configure
@@ -3348,7 +3348,7 @@ cat > $TMPH <<EOF
 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
 #define CC_TYPE "$cc_type"
 #define CC_VERSION $cc_version
-#define restrict $_restrict
+#define av_restrict $_restrict
 #define EXTERN_PREFIX "${extern_prefix}"
 #define EXTERN_ASM ${extern_prefix}
 #define SLIBSUF "$SLIBSUF"
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index a146101..d006242 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -2409,7 +2409,7 @@ static void vector_fmac_scalar_c(float *dst,
const float *src, float mul,
        dst[i] += src[i] * mul;
 }

-static void butterflies_float_c(float *restrict v1, float *restrict v2,
+static void butterflies_float_c(float *av_restrict v1, float *av_restrict v2,
                                int len)
 {
    int i;
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index ec3d7ee..4525cf4 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -440,7 +440,7 @@ typedef struct DSPContext {
     * @param v2  second input vector, difference output, 16-byte aligned
     * @param len length of vectors, multiple of 4
     */
-    void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
+    void (*butterflies_float)(float *av_restrict v1, float
*av_restrict v2, int len);

    /**
     * Calculate the sum and difference of two vectors of floats and interleave
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 73e8bf5..9dfe0b1 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -208,7 +208,7 @@ static int h263_decode_gob_header(MpegEncContext *s)
 * @param end pointer to the end of the buffer
 * @return pointer to the next resync_marker, or end if none was found
 */
-const uint8_t *ff_h263_find_resync_marker(const uint8_t *restrict p,
const uint8_t * restrict end)
+const uint8_t *ff_h263_find_resync_marker(const uint8_t *av_restrict
p, const uint8_t *av_restrict end)
 {
    assert(p < end);

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index d1c4233..708199a 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -140,9 +140,9 @@ const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = {
    PIX_FMT_NONE
 };

-const uint8_t *avpriv_mpv_find_start_code(const uint8_t *restrict p,
+const uint8_t *avpriv_mpv_find_start_code(const uint8_t *av_restrict p,
                                          const uint8_t *end,
-                                          uint32_t * restrict state)
+                                          uint32_t *av_restrict state)
 {
    int i;

diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h
index b8a3fd1..a377bd6 100644
--- a/libavformat/rtpenc.h
+++ b/libavformat/rtpenc.h
@@ -86,7 +86,7 @@ void ff_rtp_send_mpegvideo(AVFormatContext *s1,
const uint8_t *buf1, int size);
 void ff_rtp_send_xiph(AVFormatContext *s1, const uint8_t *buff, int size);
 void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buff, int size);

-const uint8_t *ff_h263_find_resync_marker_reverse(const uint8_t
*restrict start,
-                                                  const uint8_t *restrict end);
+const uint8_t *ff_h263_find_resync_marker_reverse(const uint8_t
*av_restrict start,
+                                                  const uint8_t
*av_restrict end);

 #endif /* AVFORMAT_RTPENC_H */
diff --git a/libavformat/rtpenc_h263.c b/libavformat/rtpenc_h263.c
index 87f0bd7..c6bcf61 100644
--- a/libavformat/rtpenc_h263.c
+++ b/libavformat/rtpenc_h263.c
@@ -23,8 +23,8 @@
 #include "avformat.h"
 #include "rtpenc.h"

-const uint8_t *ff_h263_find_resync_marker_reverse(const uint8_t
*restrict start,
-                                                  const uint8_t *restrict end)
+const uint8_t *ff_h263_find_resync_marker_reverse(const uint8_t
*av_restrict start,
+                                                  const uint8_t
*av_restrict end)
 {
    const uint8_t *p = end - 1;
    start += 1; /* Make sure we never return the original start. */
--
1.7.9.2


More information about the ffmpeg-devel mailing list