[FFmpeg-cvslog] r9169 - in trunk/libavcodec: ac3enc.c adpcm.c dsicinav.c gif.c gifdec.c interplayvideo.c kmvc.c lcl.c libtheoraenc.c mjpegenc.c mp3_header_decompress_bsf.c mp3lameaudio.c mpegaudio_parser.c mpegaudiodec.c oggvorbis.c png.c pnmenc.c rangecoder.c smacker.c sp5xdec.c tiertexseqv.c ulti.c vp56.h wmadec.c wmaenc.c xan.c zmbv.c zmbvenc.c

ramiro subversion
Sat Jun 2 03:41:07 CEST 2007


Author: ramiro
Date: Sat Jun  2 03:41:07 2007
New Revision: 9169

Log:
Use AV_xx throughout libavcodec

Modified:
   trunk/libavcodec/ac3enc.c
   trunk/libavcodec/adpcm.c
   trunk/libavcodec/dsicinav.c
   trunk/libavcodec/gif.c
   trunk/libavcodec/gifdec.c
   trunk/libavcodec/interplayvideo.c
   trunk/libavcodec/kmvc.c
   trunk/libavcodec/lcl.c
   trunk/libavcodec/libtheoraenc.c
   trunk/libavcodec/mjpegenc.c
   trunk/libavcodec/mp3_header_decompress_bsf.c
   trunk/libavcodec/mp3lameaudio.c
   trunk/libavcodec/mpegaudio_parser.c
   trunk/libavcodec/mpegaudiodec.c
   trunk/libavcodec/oggvorbis.c
   trunk/libavcodec/png.c
   trunk/libavcodec/pnmenc.c
   trunk/libavcodec/rangecoder.c
   trunk/libavcodec/smacker.c
   trunk/libavcodec/sp5xdec.c
   trunk/libavcodec/tiertexseqv.c
   trunk/libavcodec/ulti.c
   trunk/libavcodec/vp56.h
   trunk/libavcodec/wmadec.c
   trunk/libavcodec/wmaenc.c
   trunk/libavcodec/xan.c
   trunk/libavcodec/zmbv.c
   trunk/libavcodec/zmbvenc.c

Modified: trunk/libavcodec/ac3enc.c
==============================================================================
--- trunk/libavcodec/ac3enc.c	(original)
+++ trunk/libavcodec/ac3enc.c	Sat Jun  2 03:41:07 2007
@@ -1136,12 +1136,10 @@ static int output_frame_end(AC3EncodeCon
     /* XXX: could precompute crc_inv */
     crc_inv = pow_poly((CRC16_POLY >> 1), (16 * frame_size_58) - 16, CRC16_POLY);
     crc1 = mul_poly(crc_inv, crc1, CRC16_POLY);
-    frame[2] = crc1 >> 8;
-    frame[3] = crc1;
+    AV_WB16(frame+2,crc1);
 
     crc2 = bswap_16(av_crc(av_crc8005, 0, frame + 2 * frame_size_58, (frame_size - frame_size_58) * 2 - 2));
-    frame[2*frame_size - 2] = crc2 >> 8;
-    frame[2*frame_size - 1] = crc2;
+    AV_WB16(frame+2*frame_size-2,crc2);
 
     //    printf("n=%d frame_size=%d\n", n, frame_size);
     return frame_size * 2;

Modified: trunk/libavcodec/adpcm.c
==============================================================================
--- trunk/libavcodec/adpcm.c	(original)
+++ trunk/libavcodec/adpcm.c	Sat Jun  2 03:41:07 2007
@@ -451,16 +451,14 @@ static int adpcm_encode_frame(AVCodecCon
         n = avctx->frame_size / 8;
             c->status[0].prev_sample = (signed short)samples[0]; /* XXX */
 /*            c->status[0].step_index = 0; *//* XXX: not sure how to init the state machine */
-            *dst++ = (c->status[0].prev_sample) & 0xFF; /* little endian */
-            *dst++ = (c->status[0].prev_sample >> 8) & 0xFF;
+            bytestream_put_le16(&dst, c->status[0].prev_sample);
             *dst++ = (unsigned char)c->status[0].step_index;
             *dst++ = 0; /* unknown */
             samples++;
             if (avctx->channels == 2) {
                 c->status[1].prev_sample = (signed short)samples[1];
 /*                c->status[1].step_index = 0; */
-                *dst++ = (c->status[1].prev_sample) & 0xFF;
-                *dst++ = (c->status[1].prev_sample >> 8) & 0xFF;
+                bytestream_put_le16(&dst, c->status[1].prev_sample);
                 *dst++ = (unsigned char)c->status[1].step_index;
                 *dst++ = 0;
                 samples++;
@@ -553,20 +551,17 @@ static int adpcm_encode_frame(AVCodecCon
             if (c->status[i].idelta < 16)
                 c->status[i].idelta = 16;
 
-            *dst++ = c->status[i].idelta & 0xFF;
-            *dst++ = c->status[i].idelta >> 8;
+            bytestream_put_le16(&dst, c->status[i].idelta);
         }
         for(i=0; i<avctx->channels; i++){
             c->status[i].sample1= *samples++;
 
-            *dst++ = c->status[i].sample1 & 0xFF;
-            *dst++ = c->status[i].sample1 >> 8;
+            bytestream_put_le16(&dst, c->status[i].sample1);
         }
         for(i=0; i<avctx->channels; i++){
             c->status[i].sample2= *samples++;
 
-            *dst++ = c->status[i].sample2 & 0xFF;
-            *dst++ = c->status[i].sample2 >> 8;
+            bytestream_put_le16(&dst, c->status[i].sample2);
         }
 
         if(avctx->trellis > 0) {

Modified: trunk/libavcodec/dsicinav.c
==============================================================================
--- trunk/libavcodec/dsicinav.c	(original)
+++ trunk/libavcodec/dsicinav.c	Sat Jun  2 03:41:07 2007
@@ -25,6 +25,7 @@
  */
 
 #include "avcodec.h"
+#include "bytestream.h"
 
 
 typedef enum CinVideoBitmapIndex {
@@ -206,7 +207,7 @@ static int cinvideo_decode_frame(AVCodec
     }
 
     palette_type = buf[0];
-    palette_colors_count = buf[1] | (buf[2] << 8);
+    palette_colors_count = AV_RL16(buf+1);
     bitmap_frame_type = buf[3];
     buf += 4;
 
@@ -215,13 +216,12 @@ static int cinvideo_decode_frame(AVCodec
     /* handle palette */
     if (palette_type == 0) {
         for (i = 0; i < palette_colors_count; ++i) {
-            cin->palette[i] = (buf[2] << 16) | (buf[1] << 8) | buf[0];
-            buf += 3;
+            cin->palette[i] = bytestream_get_le24(&buf);
             bitmap_frame_size -= 3;
         }
     } else {
         for (i = 0; i < palette_colors_count; ++i) {
-            cin->palette[buf[0]] = (buf[3] << 16) | (buf[2] << 8) | buf[1];
+            cin->palette[buf[0]] = AV_RL24(buf+1);
             buf += 4;
             bitmap_frame_size -= 4;
         }

Modified: trunk/libavcodec/gif.c
==============================================================================
--- trunk/libavcodec/gif.c	(original)
+++ trunk/libavcodec/gif.c	Sat Jun  2 03:41:07 2007
@@ -132,13 +132,9 @@ static void gif_put_bits_rev(PutBitConte
     } else {
         bit_buf |= value << (bit_cnt);
 
-        *s->buf_ptr = bit_buf & 0xff;
-        s->buf_ptr[1] = (bit_buf >> 8) & 0xff;
-        s->buf_ptr[2] = (bit_buf >> 16) & 0xff;
-        s->buf_ptr[3] = (bit_buf >> 24) & 0xff;
+        bytestream_put_le32(&s->buf_ptr, bit_buf);
 
         //printf("bitbuf = %08x\n", bit_buf);
-        s->buf_ptr+=4;
         if (s->buf_ptr >= s->buf_end)
             puts("bit buffer overflow !!"); // should never happen ! who got rid of the callback ???
 //            flush_buffer_rev(s);
@@ -195,9 +191,7 @@ static int gif_image_write_header(uint8_
     } else {
         for(i=0;i<256;i++) {
             v = palette[i];
-            bytestream_put_byte(bytestream, (v >> 16) & 0xff);
-            bytestream_put_byte(bytestream, (v >> 8) & 0xff);
-            bytestream_put_byte(bytestream, (v) & 0xff);
+            bytestream_put_be24(bytestream, v);
         }
     }
 

Modified: trunk/libavcodec/gifdec.c
==============================================================================
--- trunk/libavcodec/gifdec.c	(original)
+++ trunk/libavcodec/gifdec.c	Sat Jun  2 03:41:07 2007
@@ -96,8 +96,7 @@ static int gif_read_image(GifState *s)
     n = (1 << bits_per_pixel);
     spal = palette;
     for(i = 0; i < n; i++) {
-        s->image_palette[i] = (0xff << 24) |
-            (spal[0] << 16) | (spal[1] << 8) | (spal[2]);
+        s->image_palette[i] = (0xff << 24) | AV_RB24(spal);
         spal += 3;
     }
     for(; i < 256; i++)

Modified: trunk/libavcodec/interplayvideo.c
==============================================================================
--- trunk/libavcodec/interplayvideo.c	(original)
+++ trunk/libavcodec/interplayvideo.c	Sat Jun  2 03:41:07 2007
@@ -41,6 +41,7 @@
 #include <unistd.h>
 
 #include "avcodec.h"
+#include "bytestream.h"
 #include "dsputil.h"
 
 #define PALETTE_COUNT 256
@@ -297,10 +298,8 @@ static int ipvideo_decode_block_opcode_0
 
         /* need 2 more bytes from the stream */
         CHECK_STREAM_PTR(2);
-        B[0] = *s->stream_ptr++;
-        B[1] = *s->stream_ptr++;
 
-        flags = (B[1] << 8) | B[0];
+        flags = bytestream_get_le16(&s->stream_ptr);
         bitmask = 0x0001;
         for (y = 0; y < 8; y += 2) {
             for (x = 0; x < 8; x += 2, bitmask <<= 1) {
@@ -478,7 +477,6 @@ static int ipvideo_decode_block_opcode_0
 {
     int x, y;
     unsigned char P[4];
-    unsigned char B[4];
     unsigned int flags = 0;
     int shifter = 0;
     unsigned char pix;
@@ -496,8 +494,7 @@ static int ipvideo_decode_block_opcode_0
 
         for (y = 0; y < 8; y++) {
             /* get the next set of 8 2-bit flags */
-            flags = (s->stream_ptr[1] << 8) | s->stream_ptr[0];
-            s->stream_ptr += 2;
+            flags = bytestream_get_le16(&s->stream_ptr);
             for (x = 0, shifter = 0; x < 8; x++, shifter += 2) {
                 *s->pixel_ptr++ = P[(flags >> shifter) & 0x03];
             }
@@ -509,11 +506,7 @@ static int ipvideo_decode_block_opcode_0
         /* 1 of 4 colors for each 2x2 block, need 4 more bytes */
         CHECK_STREAM_PTR(4);
 
-        B[0] = *s->stream_ptr++;
-        B[1] = *s->stream_ptr++;
-        B[2] = *s->stream_ptr++;
-        B[3] = *s->stream_ptr++;
-        flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+        flags = bytestream_get_le32(&s->stream_ptr);
         shifter = 0;
 
         for (y = 0; y < 8; y += 2) {
@@ -535,11 +528,7 @@ static int ipvideo_decode_block_opcode_0
         for (y = 0; y < 8; y++) {
             /* time to reload flags? */
             if ((y == 0) || (y == 4)) {
-                B[0] = *s->stream_ptr++;
-                B[1] = *s->stream_ptr++;
-                B[2] = *s->stream_ptr++;
-                B[3] = *s->stream_ptr++;
-                flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+                flags = bytestream_get_le32(&s->stream_ptr);
                 shifter = 0;
             }
             for (x = 0; x < 8; x += 2, shifter += 2) {
@@ -558,11 +547,7 @@ static int ipvideo_decode_block_opcode_0
         for (y = 0; y < 8; y += 2) {
             /* time to reload flags? */
             if ((y == 0) || (y == 4)) {
-                B[0] = *s->stream_ptr++;
-                B[1] = *s->stream_ptr++;
-                B[2] = *s->stream_ptr++;
-                B[3] = *s->stream_ptr++;
-                flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+                flags = bytestream_get_le32(&s->stream_ptr);
                 shifter = 0;
             }
             for (x = 0; x < 8; x++, shifter += 2) {

Modified: trunk/libavcodec/kmvc.c
==============================================================================
--- trunk/libavcodec/kmvc.c	(original)
+++ trunk/libavcodec/kmvc.c	Sat Jun  2 03:41:07 2007
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 
 #include "avcodec.h"
+#include "bytestream.h"
 
 #define KMVC_KEYFRAME 0x80
 #define KMVC_PALETTE  0x40
@@ -249,7 +250,7 @@ static int decode_frame(AVCodecContext *
     if (buf[0] == 127) {
         buf += 3;
         for (i = 0; i < 127; i++) {
-            ctx->pal[i + (header & 0x81)] = (buf[0] << 16) | (buf[1] << 8) | buf[2];
+            ctx->pal[i + (header & 0x81)] = AV_RB24(buf);
             buf += 4;
         }
         buf -= 127 * 4 + 3;
@@ -274,8 +275,7 @@ static int decode_frame(AVCodecContext *
         ctx->pic.palette_has_changed = 1;
         // palette starts from index 1 and has 127 entries
         for (i = 1; i <= ctx->palsize; i++) {
-            ctx->pal[i] = (buf[0] << 16) | (buf[1] << 8) | buf[2];
-            buf += 3;
+            ctx->pal[i] = bytestream_get_be24(&buf);
         }
     }
 

Modified: trunk/libavcodec/lcl.c
==============================================================================
--- trunk/libavcodec/lcl.c	(original)
+++ trunk/libavcodec/lcl.c	Sat Jun  2 03:41:07 2007
@@ -358,13 +358,12 @@ static int decode_frame(AVCodecContext *
                 for (row = 0; row < height; row++) {
                     pixel_ptr = row * width * 3;
                     yq = encoded[pixel_ptr++];
-                    uqvq = encoded[pixel_ptr++];
-                    uqvq+=(encoded[pixel_ptr++] << 8);
+                    uqvq = AV_RL16(encoded+pixel_ptr);
+                    pixel_ptr += 2;
                     for (col = 1; col < width; col++) {
                         encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
-                        uqvq -= (encoded[pixel_ptr+1] | (encoded[pixel_ptr+2]<<8));
-                        encoded[pixel_ptr+1] = (uqvq) & 0xff;
-                        encoded[pixel_ptr+2] = ((uqvq)>>8) & 0xff;
+                        uqvq -= AV_RL16(encoded+pixel_ptr+1);
+                        AV_WL16(encoded+pixel_ptr+1, uqvq);
                         pixel_ptr += 3;
                     }
                 }

Modified: trunk/libavcodec/libtheoraenc.c
==============================================================================
--- trunk/libavcodec/libtheoraenc.c	(original)
+++ trunk/libavcodec/libtheoraenc.c	Sat Jun  2 03:41:07 2007
@@ -69,8 +69,8 @@ static int concatenate_packet(unsigned i
 
     avc_context->extradata = newdata;
     avc_context->extradata_size = newsize;
-    avc_context->extradata[ (*offset)++ ] = packet->bytes >> 8;
-    avc_context->extradata[ (*offset)++ ] = packet->bytes & 0xff;
+    AV_WB16(avc_context->extradata + (*offset), packet->bytes);
+    *offset += 2;
     memcpy( avc_context->extradata + (*offset), packet->packet, packet->bytes );
     (*offset) += packet->bytes;
     return 0;

Modified: trunk/libavcodec/mjpegenc.c
==============================================================================
--- trunk/libavcodec/mjpegenc.c	(original)
+++ trunk/libavcodec/mjpegenc.c	Sat Jun  2 03:41:07 2007
@@ -147,8 +147,7 @@ static void jpeg_table_header(MpegEncCon
                               ff_mjpeg_val_ac_luminance);
     size += put_huffman_table(s, 1, 1, ff_mjpeg_bits_ac_chrominance,
                               ff_mjpeg_val_ac_chrominance);
-    ptr[0] = size >> 8;
-    ptr[1] = size;
+    AV_WB16(ptr, size);
 }
 
 static void jpeg_put_comments(MpegEncContext *s)
@@ -179,8 +178,7 @@ static void jpeg_put_comments(MpegEncCon
         put_bits(p, 16, 0); /* patched later */
         ff_put_string(p, LIBAVCODEC_IDENT, 1);
         size = strlen(LIBAVCODEC_IDENT)+3;
-        ptr[0] = size >> 8;
-        ptr[1] = size;
+        AV_WB16(ptr, size);
     }
 
     if(  s->avctx->pix_fmt == PIX_FMT_YUV420P
@@ -192,8 +190,7 @@ static void jpeg_put_comments(MpegEncCon
         put_bits(p, 16, 0); /* patched later */
         ff_put_string(p, "CS=ITU601", 1);
         size = strlen("CS=ITU601")+3;
-        ptr[0] = size >> 8;
-        ptr[1] = size;
+        AV_WB16(ptr, size);
     }
 }
 

Modified: trunk/libavcodec/mp3_header_decompress_bsf.c
==============================================================================
--- trunk/libavcodec/mp3_header_decompress_bsf.c	(original)
+++ trunk/libavcodec/mp3_header_decompress_bsf.c	Sat Jun  2 03:41:07 2007
@@ -84,10 +84,7 @@ static int mp3_header_decompress(AVBitSt
         }
     }
 
-    (*poutbuf)[0]= header>>24;
-    (*poutbuf)[1]= header>>16;
-    (*poutbuf)[2]= header>> 8;
-    (*poutbuf)[3]= header    ;
+    AV_WB32(*poutbuf, header);
 
     return 1;
 }

Modified: trunk/libavcodec/mp3lameaudio.c
==============================================================================
--- trunk/libavcodec/mp3lameaudio.c	(original)
+++ trunk/libavcodec/mp3lameaudio.c	Sat Jun  2 03:41:07 2007
@@ -106,8 +106,7 @@ static const int sBitsPerSlot[3] = {
 
 static int mp3len(void *data, int *samplesPerFrame, int *sampleRate)
 {
-    uint8_t *dataTmp = (uint8_t *)data;
-    uint32_t header = ( (uint32_t)dataTmp[0] << 24 ) | ( (uint32_t)dataTmp[1] << 16 ) | ( (uint32_t)dataTmp[2] << 8 ) | (uint32_t)dataTmp[3];
+    uint32_t header = AV_RB32(data);
     int layerID = 3 - ((header >> 17) & 0x03);
     int bitRateID = ((header >> 12) & 0x0f);
     int sampleRateID = ((header >> 10) & 0x03);

Modified: trunk/libavcodec/mpegaudio_parser.c
==============================================================================
--- trunk/libavcodec/mpegaudio_parser.c	(original)
+++ trunk/libavcodec/mpegaudio_parser.c	Sat Jun  2 03:41:07 2007
@@ -105,10 +105,7 @@ static int mpegaudio_parse(AVCodecParser
             /* special case for next header for first frame in free
                format case (XXX: find a simpler method) */
             if (s->free_format_next_header != 0) {
-                s->inbuf[0] = s->free_format_next_header >> 24;
-                s->inbuf[1] = s->free_format_next_header >> 16;
-                s->inbuf[2] = s->free_format_next_header >> 8;
-                s->inbuf[3] = s->free_format_next_header;
+                AV_WB32(s->inbuf, s->free_format_next_header);
                 s->inbuf_ptr = s->inbuf + 4;
                 s->free_format_next_header = 0;
                 goto got_header;
@@ -124,8 +121,7 @@ static int mpegaudio_parse(AVCodecParser
             }
             if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
             got_header:
-                header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
-                    (s->inbuf[2] << 8) | s->inbuf[3];
+                header = AV_RB32(s->inbuf);
 
                 ret = ff_mpa_decode_header(avctx, header, &sr);
                 if (ret < 0) {
@@ -176,10 +172,8 @@ static int mpegaudio_parse(AVCodecParser
                 p = s->inbuf_ptr - 3;
                 pend = s->inbuf_ptr + len - 4;
                 while (p <= pend) {
-                    header = (p[0] << 24) | (p[1] << 16) |
-                        (p[2] << 8) | p[3];
-                    header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
-                        (s->inbuf[2] << 8) | s->inbuf[3];
+                    header = AV_RB32(p);
+                    header1 = AV_RB32(s->inbuf);
                     /* check with high probability that we have a
                        valid header */
                     if ((header & SAME_HEADER_MASK) ==

Modified: trunk/libavcodec/mpegaudiodec.c
==============================================================================
--- trunk/libavcodec/mpegaudiodec.c	(original)
+++ trunk/libavcodec/mpegaudiodec.c	Sat Jun  2 03:41:07 2007
@@ -2380,7 +2380,7 @@ retry:
     if(buf_size < HEADER_SIZE)
         return -1;
 
-    header = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
+    header = AV_RB32(buf);
     if(ff_mpa_check_header(header) < 0){
         buf++;
 //        buf_size--;
@@ -2459,7 +2459,7 @@ static int decode_frame_adu(AVCodecConte
         len = MPA_MAX_CODED_FRAME_SIZE;
 
     // Get header and restore sync word
-    header = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3] | 0xffe00000;
+    header = AV_RB32(buf) | 0xffe00000;
 
     if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame
         *data_size = 0;
@@ -2604,7 +2604,7 @@ static int decode_frame_mp3on4(AVCodecCo
         assert (m != NULL);
 
         // Get header
-        header = (start[0] << 24) | (start[1] << 16) | (start[2] << 8) | start[3] | 0xfff00000;
+        header = AV_RB32(start) | 0xfff00000;
 
         if (ff_mpa_check_header(header) < 0) { // Bad header, discard block
             *data_size = 0;

Modified: trunk/libavcodec/oggvorbis.c
==============================================================================
--- trunk/libavcodec/oggvorbis.c	(original)
+++ trunk/libavcodec/oggvorbis.c	Sat Jun  2 03:41:07 2007
@@ -27,6 +27,7 @@
 #include <vorbis/vorbisenc.h>
 
 #include "avcodec.h"
+#include "bytestream.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -234,8 +235,7 @@ static int oggvorbis_decode_init(AVCodec
 
     if(p[0] == 0 && p[1] == 30) {
         for(i = 0; i < 3; i++){
-            hsizes[i] = *p++ << 8;
-            hsizes[i] += *p++;
+            hsizes[i] = bytestream_get_be16(&p);
             headers[i] = p;
             p += hsizes[i];
         }

Modified: trunk/libavcodec/png.c
==============================================================================
--- trunk/libavcodec/png.c	(original)
+++ trunk/libavcodec/png.c	Sat Jun  2 03:41:07 2007
@@ -693,10 +693,7 @@ static void png_write_chunk(uint8_t **f,
 
     bytestream_put_be32(f, length);
     crc = crc32(0, Z_NULL, 0);
-    tagbuf[0] = tag;
-    tagbuf[1] = tag >> 8;
-    tagbuf[2] = tag >> 16;
-    tagbuf[3] = tag >> 24;
+    AV_WL32(tagbuf, tag);
     crc = crc32(crc, tagbuf, 4);
     bytestream_put_be32(f, bswap_32(tag));
     if (length > 0) {
@@ -833,10 +830,7 @@ static int encode_frame(AVCodecContext *
             if (alpha && alpha != 0xff)
                 has_alpha = 1;
             *alpha_ptr++ = alpha;
-            ptr[0] = v >> 16;
-            ptr[1] = v >> 8;
-            ptr[2] = v;
-            ptr += 3;
+            bytestream_put_be24(&ptr, v);
         }
         png_write_chunk(&s->bytestream, MKTAG('P', 'L', 'T', 'E'), s->buf, 256 * 3);
         if (has_alpha) {

Modified: trunk/libavcodec/pnmenc.c
==============================================================================
--- trunk/libavcodec/pnmenc.c	(original)
+++ trunk/libavcodec/pnmenc.c	Sat Jun  2 03:41:07 2007
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avcodec.h"
+#include "bytestream.h"
 #include "pnm.h"
 
 
@@ -303,9 +304,7 @@ static int pam_encode_frame(AVCodecConte
         for(i=0;i<h;i++) {
             for(j=0;j<w;j++) {
                 v = ((uint32_t *)ptr)[j];
-                *s->bytestream++ = v >> 16;
-                *s->bytestream++ = v >> 8;
-                *s->bytestream++ = v;
+                bytestream_put_be24(&s->bytestream, v);
                 *s->bytestream++ = v >> 24;
             }
             ptr += linesize;

Modified: trunk/libavcodec/rangecoder.c
==============================================================================
--- trunk/libavcodec/rangecoder.c	(original)
+++ trunk/libavcodec/rangecoder.c	Sat Jun  2 03:41:07 2007
@@ -36,6 +36,7 @@
 
 #include "avcodec.h"
 #include "rangecoder.h"
+#include "bytestream.h"
 
 
 void ff_init_range_encoder(RangeCoder *c, uint8_t *buf, int buf_size){
@@ -53,8 +54,7 @@ void ff_init_range_decoder(RangeCoder *c
     /* cast to avoid compiler warning */
     ff_init_range_encoder(c, (uint8_t *) buf, buf_size);
 
-    c->low =(*c->bytestream++)<<8;
-    c->low+= *c->bytestream++;
+    c->low = bytestream_get_be16(&c->bytestream);
 }
 
 void ff_build_rac_states(RangeCoder *c, int factor, int max_p){

Modified: trunk/libavcodec/smacker.c
==============================================================================
--- trunk/libavcodec/smacker.c	(original)
+++ trunk/libavcodec/smacker.c	Sat Jun  2 03:41:07 2007
@@ -436,11 +436,9 @@ static int decode_frame(AVCodecContext *
                 case 0:
                     for(i = 0; i < 4; i++) {
                         pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
-                        out[2] = pix & 0xFF;
-                        out[3] = pix >> 8;
+                        AV_WL16(out+2,pix);
                         pix = smk_get_code(&gb, smk->full_tbl, smk->full_last);
-                        out[0] = pix & 0xFF;
-                        out[1] = pix >> 8;
+                        AV_WL16(out,pix);
                         out += stride;
                     }
                     break;
@@ -465,11 +463,11 @@ static int decode_frame(AVCodecContext *
                         uint16_t pix1, pix2;
                         pix1 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
                         pix2 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
-                        out[0] = pix1 & 0xFF; out[1] = pix1 >> 8;
-                        out[2] = pix2 & 0xFF; out[3] = pix2 >> 8;
+                        AV_WL16(out,pix1);
+                        AV_WL16(out+2,pix2);
                         out += stride;
-                        out[0] = pix1 & 0xFF; out[1] = pix1 >> 8;
-                        out[2] = pix2 & 0xFF; out[3] = pix2 >> 8;
+                        AV_WL16(out,pix1);
+                        AV_WL16(out+2,pix2);
                         out += stride;
                     }
                     break;

Modified: trunk/libavcodec/sp5xdec.c
==============================================================================
--- trunk/libavcodec/sp5xdec.c	(original)
+++ trunk/libavcodec/sp5xdec.c	Sat Jun  2 03:41:07 2007
@@ -65,10 +65,8 @@ static int sp5x_decode_frame(AVCodecCont
     j += sizeof(sp5x_data_dht);
 
     memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
-    recoded[j+5] = (avctx->coded_height >> 8) & 0xFF;
-    recoded[j+6] = avctx->coded_height & 0xFF;
-    recoded[j+7] = (avctx->coded_width >> 8) & 0xFF;
-    recoded[j+8] = avctx->coded_width & 0xFF;
+    AV_WB16(recoded+j+5, avctx->coded_height);
+    AV_WB16(recoded+j+7, avctx->coded_width);
     j += sizeof(sp5x_data_sof);
 
     memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos));

Modified: trunk/libavcodec/tiertexseqv.c
==============================================================================
--- trunk/libavcodec/tiertexseqv.c	(original)
+++ trunk/libavcodec/tiertexseqv.c	Sat Jun  2 03:41:07 2007
@@ -146,7 +146,7 @@ static void seqvideo_decode(SeqVideoCont
         for (i = 0; i < 256; i++) {
             for (j = 0; j < 3; j++, data++)
                 c[j] = (*data << 2) | (*data >> 4);
-            seq->palette[i] = (c[0] << 16) | (c[1] << 8) | c[2];
+            seq->palette[i] = AV_RB24(c);
         }
         memcpy(seq->frame.data[1], seq->palette, sizeof(seq->palette));
         seq->frame.palette_has_changed = 1;

Modified: trunk/libavcodec/ulti.c
==============================================================================
--- trunk/libavcodec/ulti.c	(original)
+++ trunk/libavcodec/ulti.c	Sat Jun  2 03:41:07 2007
@@ -31,6 +31,7 @@
 #include <unistd.h>
 
 #include "avcodec.h"
+#include "bytestream.h"
 
 #include "ulti_cb.h"
 
@@ -305,9 +306,7 @@ static int ulti_decode_frame(AVCodecCont
 
                 case 2:
                     if (modifier) { // unpack four luma samples
-                        tmp = (*buf++) << 16;
-                        tmp += (*buf++) << 8;
-                        tmp += *buf++;
+                        tmp = bytestream_get_be24(&buf);
 
                         Y[0] = (tmp >> 18) & 0x3F;
                         Y[1] = (tmp >> 12) & 0x3F;
@@ -315,8 +314,7 @@ static int ulti_decode_frame(AVCodecCont
                         Y[3] = tmp & 0x3F;
                         angle = 16;
                     } else { // retrieve luma samples from codebook
-                        tmp = (*buf++) << 8;
-                        tmp += (*buf++);
+                        tmp = bytestream_get_be16(&buf);
 
                         angle = (tmp >> 12) & 0xF;
                         tmp &= 0xFFF;
@@ -332,33 +330,25 @@ static int ulti_decode_frame(AVCodecCont
                     if (modifier) { // all 16 luma samples
                         uint8_t Luma[16];
 
-                        tmp = (*buf++) << 16;
-                        tmp += (*buf++) << 8;
-                        tmp += *buf++;
+                        tmp = bytestream_get_be24(&buf);
                         Luma[0] = (tmp >> 18) & 0x3F;
                         Luma[1] = (tmp >> 12) & 0x3F;
                         Luma[2] = (tmp >> 6) & 0x3F;
                         Luma[3] = tmp & 0x3F;
 
-                        tmp = (*buf++) << 16;
-                        tmp += (*buf++) << 8;
-                        tmp += *buf++;
+                        tmp = bytestream_get_be24(&buf);
                         Luma[4] = (tmp >> 18) & 0x3F;
                         Luma[5] = (tmp >> 12) & 0x3F;
                         Luma[6] = (tmp >> 6) & 0x3F;
                         Luma[7] = tmp & 0x3F;
 
-                        tmp = (*buf++) << 16;
-                        tmp += (*buf++) << 8;
-                        tmp += *buf++;
+                        tmp = bytestream_get_be24(&buf);
                         Luma[8] = (tmp >> 18) & 0x3F;
                         Luma[9] = (tmp >> 12) & 0x3F;
                         Luma[10] = (tmp >> 6) & 0x3F;
                         Luma[11] = tmp & 0x3F;
 
-                        tmp = (*buf++) << 16;
-                        tmp += (*buf++) << 8;
-                        tmp += *buf++;
+                        tmp = bytestream_get_be24(&buf);
                         Luma[12] = (tmp >> 18) & 0x3F;
                         Luma[13] = (tmp >> 12) & 0x3F;
                         Luma[14] = (tmp >> 6) & 0x3F;

Modified: trunk/libavcodec/vp56.h
==============================================================================
--- trunk/libavcodec/vp56.h	(original)
+++ trunk/libavcodec/vp56.h	Sat Jun  2 03:41:07 2007
@@ -27,6 +27,7 @@
 #include "vp56data.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
+#include "bytestream.h"
 
 
 typedef struct vp56_context vp56_context_t;
@@ -169,8 +170,7 @@ static inline void vp56_init_range_decod
     c->high = 255;
     c->bits = 8;
     c->buffer = buf;
-    c->code_word = *c->buffer++ << 8;
-    c->code_word |= *c->buffer++;
+    c->code_word = bytestream_get_be16(&c->buffer);
 }
 
 static inline int vp56_rac_get_prob(vp56_range_coder_t *c, uint8_t prob)

Modified: trunk/libavcodec/wmadec.c
==============================================================================
--- trunk/libavcodec/wmadec.c	(original)
+++ trunk/libavcodec/wmadec.c	Sat Jun  2 03:41:07 2007
@@ -92,12 +92,11 @@ static int wma_decode_init(AVCodecContex
     flags2 = 0;
     extradata = avctx->extradata;
     if (avctx->codec->id == CODEC_ID_WMAV1 && avctx->extradata_size >= 4) {
-        flags1 = extradata[0] | (extradata[1] << 8);
-        flags2 = extradata[2] | (extradata[3] << 8);
+        flags1 = AV_RL16(extradata);
+        flags2 = AV_RL16(extradata+2);
     } else if (avctx->codec->id == CODEC_ID_WMAV2 && avctx->extradata_size >= 6) {
-        flags1 = extradata[0] | (extradata[1] << 8) |
-            (extradata[2] << 16) | (extradata[3] << 24);
-        flags2 = extradata[4] | (extradata[5] << 8);
+        flags1 = AV_RL32(extradata);
+        flags2 = AV_RL16(extradata+4);
     }
 // for(i=0; i<avctx->extradata_size; i++)
 //     av_log(NULL, AV_LOG_ERROR, "%02X ", extradata[i]);

Modified: trunk/libavcodec/wmaenc.c
==============================================================================
--- trunk/libavcodec/wmaenc.c	(original)
+++ trunk/libavcodec/wmaenc.c	Sat Jun  2 03:41:07 2007
@@ -45,19 +45,13 @@ static int encode_init(AVCodecContext * 
     if (avctx->codec->id == CODEC_ID_WMAV1) {
         extradata= av_malloc(4);
         avctx->extradata_size= 4;
-        extradata[0] = flags1;
-        extradata[1] = flags1>>8;
-        extradata[2] = flags2;
-        extradata[3] = flags2>>8;
+        AV_WL16(extradata, flags1);
+        AV_WL16(extradata+2, flags2);
     } else if (avctx->codec->id == CODEC_ID_WMAV2) {
         extradata= av_mallocz(10);
         avctx->extradata_size= 10;
-        extradata[0] = flags1;
-        extradata[1] = flags1>>8;
-        extradata[2] = flags1>>16;
-        extradata[3] = flags1>>24;
-        extradata[4] = flags2;
-        extradata[5] = flags2>>8;
+        AV_WL32(extradata, flags1);
+        AV_WL16(extradata+4, flags2);
     }else
         assert(0);
     avctx->extradata= extradata;

Modified: trunk/libavcodec/xan.c
==============================================================================
--- trunk/libavcodec/xan.c	(original)
+++ trunk/libavcodec/xan.c	Sat Jun  2 03:41:07 2007
@@ -354,8 +354,7 @@ static void xan_wc3_decode_frame(XanCont
 
         case 11:
         case 21:
-            size = (size_segment[0] << 16) | (size_segment[1] << 8) |
-                size_segment[2];
+            size = AV_RB24(size_segment);
             size_segment += 3;
             break;
         }

Modified: trunk/libavcodec/zmbv.c
==============================================================================
--- trunk/libavcodec/zmbv.c	(original)
+++ trunk/libavcodec/zmbv.c	Sat Jun  2 03:41:07 2007
@@ -579,9 +579,7 @@ static int decode_frame(AVCodecContext *
                 for(i = 0; i < c->width; i++) {
                     uint32_t tmp = AV_RL32(src);
                     src += 4;
-                    out[i * 3 + 0] = tmp >> 16;
-                    out[i * 3 + 1] = tmp >> 8;
-                    out[i * 3 + 2] = tmp >> 0;
+                    AV_WB24(out+(i*3), tmp);
                 }
                 out += c->pic.linesize[0];
             }

Modified: trunk/libavcodec/zmbvenc.c
==============================================================================
--- trunk/libavcodec/zmbvenc.c	(original)
+++ trunk/libavcodec/zmbvenc.c	Sat Jun  2 03:41:07 2007
@@ -144,9 +144,7 @@ static int encode_frame(AVCodecContext *
     if(chpal){
         uint8_t tpal[3];
         for(i = 0; i < 256; i++){
-            tpal[0] = palptr[i] >> 16;
-            tpal[1] = palptr[i] >>  8;
-            tpal[2] = palptr[i];
+            AV_WB24(tpal, palptr[i]);
             c->work_buf[work_size++] = tpal[0] ^ c->pal[i * 3 + 0];
             c->work_buf[work_size++] = tpal[1] ^ c->pal[i * 3 + 1];
             c->work_buf[work_size++] = tpal[2] ^ c->pal[i * 3 + 2];
@@ -158,9 +156,7 @@ static int encode_frame(AVCodecContext *
     }
     if(keyframe){
         for(i = 0; i < 256; i++){
-            c->pal[i*3 + 0] = palptr[i] >> 16;
-            c->pal[i*3 + 1] = palptr[i] >>  8;
-            c->pal[i*3 + 2] = palptr[i];
+            AV_WB24(c->pal+(i*3), palptr[i]);
         }
         memcpy(c->work_buf, c->pal, 768);
         memcpy(c->pal2, p->data[1], 1024);




More information about the ffmpeg-cvslog mailing list