Browse Source

Merge commit '6327c10702922eabcb1c6170abd3f03d23ce4c51'

* commit '6327c10702922eabcb1c6170abd3f03d23ce4c51':
  atomic: fix CAS with armcc.
  png: use av_mallocz_array() for the zlib zalloc function
  libmp3lame: use the correct remaining buffer size when flushing

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Michael Niedermayer 12 years ago
parent
commit
0d0f76ea56
3 changed files with 10 additions and 4 deletions
  1. 1 1
      libavcodec/libmp3lame.c
  2. 1 3
      libavcodec/png.c
  3. 8 0
      libavutil/atomic_gcc.h

+ 1 - 1
libavcodec/libmp3lame.c

@@ -218,7 +218,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
         }
         }
     } else {
     } else {
         lame_result = lame_encode_flush(s->gfp, s->buffer + s->buffer_index,
         lame_result = lame_encode_flush(s->gfp, s->buffer + s->buffer_index,
-                                        BUFFER_SIZE - s->buffer_index);
+                                        s->buffer_size - s->buffer_index);
     }
     }
     if (lame_result < 0) {
     if (lame_result < 0) {
         if (lame_result == -1) {
         if (lame_result == -1) {

+ 1 - 3
libavcodec/png.c

@@ -38,9 +38,7 @@ static const uint8_t ff_png_pass_xshift[NB_PASSES] = {
 
 
 void *ff_png_zalloc(void *opaque, unsigned int items, unsigned int size)
 void *ff_png_zalloc(void *opaque, unsigned int items, unsigned int size)
 {
 {
-    if(items >= UINT_MAX / size)
-        return NULL;
-    return av_malloc(items * size);
+    return av_mallocz_array(items, size);
 }
 }
 
 
 void ff_png_zfree(void *opaque, void *ptr)
 void ff_png_zfree(void *opaque, void *ptr)

+ 8 - 0
libavutil/atomic_gcc.h

@@ -21,6 +21,8 @@
 #ifndef AVUTIL_ATOMIC_GCC_H
 #ifndef AVUTIL_ATOMIC_GCC_H
 #define AVUTIL_ATOMIC_GCC_H
 #define AVUTIL_ATOMIC_GCC_H
 
 
+#include <stdint.h>
+
 #include "atomic.h"
 #include "atomic.h"
 
 
 #define avpriv_atomic_int_get atomic_int_get_gcc
 #define avpriv_atomic_int_get atomic_int_get_gcc
@@ -47,7 +49,13 @@ static inline int atomic_int_add_and_fetch_gcc(volatile int *ptr, int inc)
 static inline void *atomic_ptr_cas_gcc(void * volatile *ptr,
 static inline void *atomic_ptr_cas_gcc(void * volatile *ptr,
                                        void *oldval, void *newval)
                                        void *oldval, void *newval)
 {
 {
+#ifdef __ARMCC_VERSION
+    // armcc will throw an error if ptr is not an integer type
+    volatile uintptr_t *tmp = (volatile uintptr_t*)ptr;
+    return (void*)__sync_val_compare_and_swap(tmp, oldval, newval);
+#else
     return __sync_val_compare_and_swap(ptr, oldval, newval);
     return __sync_val_compare_and_swap(ptr, oldval, newval);
+#endif
 }
 }
 
 
 #endif /* AVUTIL_ATOMIC_GCC_H */
 #endif /* AVUTIL_ATOMIC_GCC_H */