changeset 31614:b40d593a463f

Use AV_RL* macros instead of typecasts where appropriate.
author reimar
date Sat, 10 Jul 2010 22:24:31 +0000
parents 55abf5e08172
children 29f48c6e3056
files libmpcodecs/ad_dk3adpcm.c libmpcodecs/ad_imaadpcm.c libmpcodecs/vd_mtga.c libmpcodecs/vd_realvid.c libmpcodecs/vd_sgi.c
diffstat 5 files changed, 19 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/ad_dk3adpcm.c	Sat Jul 10 22:12:38 2010 +0000
+++ b/libmpcodecs/ad_dk3adpcm.c	Sat Jul 10 22:24:31 2010 +0000
@@ -33,7 +33,7 @@
 #include <unistd.h>
 
 #include "config.h"
-#include "mpbswap.h"
+#include "libavutil/intreadwrite.h"
 #include "ad_internal.h"
 
 static const ad_info_t info =
@@ -49,9 +49,6 @@
 
 #define DK3_ADPCM_PREAMBLE_SIZE 16
 
-#define LE_16(x) (le2me_16(*(unsigned short *)(x)))
-#define LE_32(x) (le2me_32(*(unsigned int *)(x)))
-
 // useful macros
 // clamp a number between 0 and 88
 #define CLAMP_0_TO_88(x)  if (x < 0) x = 0; else if (x > 88) x = 88;
@@ -154,8 +151,8 @@
   int step;
   int diff;
 
-  sum_pred = LE_16(&input[10]);
-  diff_pred = LE_16(&input[12]);
+  sum_pred = AV_RL16(&input[10]);
+  diff_pred = AV_RL16(&input[12]);
   SE_16BIT(sum_pred);
   SE_16BIT(diff_pred);
   diff_channel = diff_pred;
--- a/libmpcodecs/ad_imaadpcm.c	Sat Jul 10 22:12:38 2010 +0000
+++ b/libmpcodecs/ad_imaadpcm.c	Sat Jul 10 22:24:31 2010 +0000
@@ -39,7 +39,7 @@
 #include <inttypes.h>
 
 #include "config.h"
-#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
 #include "mpbswap.h"
 #include "ad_internal.h"
 
@@ -49,9 +49,6 @@
 #define QT_IMA_ADPCM_BLOCK_SIZE 0x22
 #define QT_IMA_ADPCM_SAMPLES_PER_BLOCK 64
 
-#define BE_16(x) (be2me_16(*(unsigned short *)(x)))
-#define LE_16(x) (le2me_16(*(unsigned short *)(x)))
-
 // pertinent tables for IMA ADPCM
 static const int16_t adpcm_step[89] =
 {
@@ -189,7 +186,7 @@
     return -1;
 
   for (i = 0; i < channels; i++) {
-    initial_index[i] = initial_predictor[i] = (int16_t)BE_16(&input[i * QT_IMA_ADPCM_BLOCK_SIZE]);
+    initial_index[i] = initial_predictor[i] = (int16_t)AV_RB16(&input[i * QT_IMA_ADPCM_BLOCK_SIZE]);
 
     // mask, sign-extend, and clamp the predictor portion
     initial_predictor[i] &= ~0x7F;
@@ -239,7 +236,7 @@
     return -1;
 
   for (i = 0; i < channels; i++) {
-    predictor[i] = (int16_t)LE_16(&input[i * 4]);
+    predictor[i] = (int16_t)AV_RL16(&input[i * 4]);
     index[i] = input[i * 4 + 2];
   }
 
@@ -303,7 +300,7 @@
 
   for (i = 0; i < channels; i++) {
     // the first predictor value goes straight to the output
-    predictor[i] = output[i] = (int16_t)LE_16(&input[i * 4]);
+    predictor[i] = output[i] = (int16_t)AV_RL16(&input[i * 4]);
     index[i] = input[i * 4 + 2];
   }
 
--- a/libmpcodecs/vd_mtga.c	Sat Jul 10 22:12:38 2010 +0000
+++ b/libmpcodecs/vd_mtga.c	Sat Jul 10 22:24:31 2010 +0000
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "mp_msg.h"
 
-#include "mpbswap.h"
+#include "libavutil/intreadwrite.h"
 #include "libvo/fastmemcpy.h"
 
 #include "vd_internal.h"
@@ -176,8 +176,8 @@
     info->img_type = buf[2];
 
     /* targa data is always stored in little endian byte order */
-    info->width = le2me_16(*(unsigned short *) &buf[12]);
-    info->height = le2me_16(*(unsigned short *) &buf[14]);
+    info->width  = AV_RL16(&buf[12]);
+    info->height = AV_RL16(&buf[14]);
 
     info->bpp = buf[16];
 
--- a/libmpcodecs/vd_realvid.c	Sat Jul 10 22:12:38 2010 +0000
+++ b/libmpcodecs/vd_realvid.c	Sat Jul 10 22:24:31 2010 +0000
@@ -270,9 +270,9 @@
 	    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"realvideo: extradata too small (%u)\n", sh->bih->biSize - sizeof(BITMAPINFOHEADER));
 	    return 0;
 	}
-	init_data = (struct rv_init_t){11, sh->disp_w, sh->disp_h, 0, 0, be2me_32(((unsigned int*)extrahdr)[0]), 1, be2me_32(((unsigned int*)extrahdr)[1])}; // rv30
+	init_data = (struct rv_init_t){11, sh->disp_w, sh->disp_h, 0, 0, AV_RB32(extrahdr), 1, AV_RB32(extrahdr + 4)}; // rv30
 
-	mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X  sub-id: 0x%08X\n",be2me_32(((unsigned int*)extrahdr)[1]),be2me_32(((unsigned int*)extrahdr)[0]));
+	mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X  sub-id: 0x%08X\n",init_data.format,init_data.sub_format);
 
 	path = malloc(strlen(codec_path) + strlen(sh->codec->dll) + 2);
 	if (!path) return 0;
--- a/libmpcodecs/vd_sgi.c	Sat Jul 10 22:12:38 2010 +0000
+++ b/libmpcodecs/vd_sgi.c	Sat Jul 10 22:24:31 2010 +0000
@@ -23,7 +23,7 @@
 
 #include "config.h"
 #include "mp_msg.h"
-#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
 #include "mpbswap.h"
 #include "vd_internal.h"
 
@@ -194,7 +194,7 @@
        dest_row = mpi->planes[0] + mpi->stride[0] * (ysize - 1 - y);
 
       /* set start of next run (offsets are from start of header) */
-      start_offset = be2me_32(*(uint32_t*) &starttab[y + z * ysize]);
+      start_offset = AV_RB32(&starttab[y + z * ysize]);
 
       rle_data = &data[start_offset];
 
@@ -261,13 +261,13 @@
 read_sgi_header(unsigned char *buf, SGIInfo *info)
 {
   /* sgi data is always stored in big endian byte order */
-  info->magic = be2me_16(*(unsigned short *) &buf[0]);
+  info->magic = AV_RB16(&buf[0]);
   info->rle = buf[2];
   info->bytes_per_channel = buf[3];
-  info->dimension = be2me_16(*(unsigned short *) &buf[4]);
-  info->xsize = be2me_16(*(unsigned short *) &buf[6]);
-  info->ysize = be2me_16(*(unsigned short *) &buf[8]);
-  info->zsize = be2me_16(*(unsigned short *) &buf[10]);
+  info->dimension = AV_RB16(&buf[4]);
+  info->xsize = AV_RB16(&buf[6]);
+  info->ysize = AV_RB16(&buf[8]);
+  info->zsize = AV_RB16(&buf[10]);
 }