diff options
author | Ramiro Polla <ramiro.polla@gmail.com> | 2007-06-02 01:41:07 +0000 |
---|---|---|
committer | Ramiro Polla <ramiro.polla@gmail.com> | 2007-06-02 01:41:07 +0000 |
commit | 2c124cb65c24cc7d0538260726045d68442eef25 (patch) | |
tree | 3752a8d02aa478d977264e8ce0438f49c92a4aca | |
parent | 29b29011e5631c4e867baf42258a00886d142841 (diff) | |
download | ffmpeg-2c124cb65c24cc7d0538260726045d68442eef25.tar.gz |
Use AV_xx throughout libavcodec
Originally committed as revision 9169 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/ac3enc.c | 6 | ||||
-rw-r--r-- | libavcodec/adpcm.c | 15 | ||||
-rw-r--r-- | libavcodec/dsicinav.c | 8 | ||||
-rw-r--r-- | libavcodec/gif.c | 10 | ||||
-rw-r--r-- | libavcodec/gifdec.c | 3 | ||||
-rw-r--r-- | libavcodec/interplayvideo.c | 27 | ||||
-rw-r--r-- | libavcodec/kmvc.c | 6 | ||||
-rw-r--r-- | libavcodec/lcl.c | 9 | ||||
-rw-r--r-- | libavcodec/libtheoraenc.c | 4 | ||||
-rw-r--r-- | libavcodec/mjpegenc.c | 9 | ||||
-rw-r--r-- | libavcodec/mp3_header_decompress_bsf.c | 5 | ||||
-rw-r--r-- | libavcodec/mp3lameaudio.c | 3 | ||||
-rw-r--r-- | libavcodec/mpegaudio_parser.c | 14 | ||||
-rw-r--r-- | libavcodec/mpegaudiodec.c | 6 | ||||
-rw-r--r-- | libavcodec/oggvorbis.c | 4 | ||||
-rw-r--r-- | libavcodec/png.c | 10 | ||||
-rw-r--r-- | libavcodec/pnmenc.c | 5 | ||||
-rw-r--r-- | libavcodec/rangecoder.c | 4 | ||||
-rw-r--r-- | libavcodec/smacker.c | 14 | ||||
-rw-r--r-- | libavcodec/sp5xdec.c | 6 | ||||
-rw-r--r-- | libavcodec/tiertexseqv.c | 2 | ||||
-rw-r--r-- | libavcodec/ulti.c | 24 | ||||
-rw-r--r-- | libavcodec/vp56.h | 4 | ||||
-rw-r--r-- | libavcodec/wmadec.c | 9 | ||||
-rw-r--r-- | libavcodec/wmaenc.c | 14 | ||||
-rw-r--r-- | libavcodec/xan.c | 3 | ||||
-rw-r--r-- | libavcodec/zmbv.c | 4 | ||||
-rw-r--r-- | libavcodec/zmbvenc.c | 8 |
28 files changed, 79 insertions, 157 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 5161b61e4f..43154378f8 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1136,12 +1136,10 @@ static int output_frame_end(AC3EncodeContext *s) /* 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; diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 05cca3f43a..030b0edd50 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -451,16 +451,14 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 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(AVCodecContext *avctx, 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) { diff --git a/libavcodec/dsicinav.c b/libavcodec/dsicinav.c index 7b4349b703..78cdbe93a9 100644 --- a/libavcodec/dsicinav.c +++ b/libavcodec/dsicinav.c @@ -25,6 +25,7 @@ */ #include "avcodec.h" +#include "bytestream.h" typedef enum CinVideoBitmapIndex { @@ -206,7 +207,7 @@ static int cinvideo_decode_frame(AVCodecContext *avctx, } 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(AVCodecContext *avctx, /* 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; } diff --git a/libavcodec/gif.c b/libavcodec/gif.c index f67ab52c22..c22a41823f 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -132,13 +132,9 @@ static void gif_put_bits_rev(PutBitContext *s, int n, unsigned int value) } 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_t **bytestream, } 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); } } diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index de5cab952e..c08dc9a702 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -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++) diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 32406f76d7..bce3a9a430 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -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_0x7(IpvideoContext *s) /* 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_0x9(IpvideoContext *s) { 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_0x9(IpvideoContext *s) 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_0x9(IpvideoContext *s) /* 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_0x9(IpvideoContext *s) 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_0x9(IpvideoContext *s) 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) { diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index 573f10c80d..c56b62ca2f 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -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 * avctx, void *data, int *data_size, uint 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 * avctx, void *data, int *data_size, uint 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); } } diff --git a/libavcodec/lcl.c b/libavcodec/lcl.c index 6f187f8734..0a60489414 100644 --- a/libavcodec/lcl.c +++ b/libavcodec/lcl.c @@ -358,13 +358,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8 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; } } diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index 7f531dbee5..ced0b8d280 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -69,8 +69,8 @@ static int concatenate_packet(unsigned int* offset, AVCodecContext* avc_context, 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; diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 03f081703d..bf780436f1 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -147,8 +147,7 @@ static void jpeg_table_header(MpegEncContext *s) 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(MpegEncContext *s) 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(MpegEncContext *s) 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); } } diff --git a/libavcodec/mp3_header_decompress_bsf.c b/libavcodec/mp3_header_decompress_bsf.c index bec3858634..952aa8a1c2 100644 --- a/libavcodec/mp3_header_decompress_bsf.c +++ b/libavcodec/mp3_header_decompress_bsf.c @@ -84,10 +84,7 @@ static int mp3_header_decompress(AVBitStreamFilterContext *bsfc, AVCodecContext } } - (*poutbuf)[0]= header>>24; - (*poutbuf)[1]= header>>16; - (*poutbuf)[2]= header>> 8; - (*poutbuf)[3]= header ; + AV_WB32(*poutbuf, header); return 1; } diff --git a/libavcodec/mp3lameaudio.c b/libavcodec/mp3lameaudio.c index d133502657..9a5177af30 100644 --- a/libavcodec/mp3lameaudio.c +++ b/libavcodec/mp3lameaudio.c @@ -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); diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 1c0364d81f..b41fcf4842 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -105,10 +105,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1, /* 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(AVCodecParserContext *s1, } 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(AVCodecParserContext *s1, 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) == diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 0cb6476a2e..9e8472f561 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -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(AVCodecContext * avctx, 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(AVCodecContext * avctx, 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; diff --git a/libavcodec/oggvorbis.c b/libavcodec/oggvorbis.c index 3073b1456d..b11e3d8af2 100644 --- a/libavcodec/oggvorbis.c +++ b/libavcodec/oggvorbis.c @@ -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(AVCodecContext *avccontext) { 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]; } diff --git a/libavcodec/png.c b/libavcodec/png.c index 72c0e81f0b..5e30f42ad1 100644 --- a/libavcodec/png.c +++ b/libavcodec/png.c @@ -693,10 +693,7 @@ static void png_write_chunk(uint8_t **f, uint32_t tag, 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 *avctx, unsigned char *buf, int buf_size, 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) { diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index 46f7e6e98a..a7e70eb2f3 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -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(AVCodecContext *avctx, unsigned char *outbuf, int bu 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; diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c index 4e15ce3096..0842dd9ce7 100644 --- a/libavcodec/rangecoder.c +++ b/libavcodec/rangecoder.c @@ -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, const uint8_t *buf, int buf_size){ /* 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){ diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 78ee923001..3bdb5f25fd 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -436,11 +436,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8 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 *avctx, void *data, int *data_size, uint8 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; diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 9553943bbd..2234afa697 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -65,10 +65,8 @@ static int sp5x_decode_frame(AVCodecContext *avctx, 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)); diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index 85d585ea8f..56c817a518 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -146,7 +146,7 @@ static void seqvideo_decode(SeqVideoContext *seq, unsigned char *data, int data_ 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; diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c index 5c6ba00114..c2439c4d16 100644 --- a/libavcodec/ulti.c +++ b/libavcodec/ulti.c @@ -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(AVCodecContext *avctx, 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(AVCodecContext *avctx, 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(AVCodecContext *avctx, 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; diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index fb8bbba6fc..023f3b9c23 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -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_decoder(vp56_range_coder_t *c, 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) diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index da02f69824..4724d51ac3 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -92,12 +92,11 @@ static int wma_decode_init(AVCodecContext * avctx) 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]); diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index e902a6aff4..e35f363b63 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -45,19 +45,13 @@ static int encode_init(AVCodecContext * avctx){ 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; diff --git a/libavcodec/xan.c b/libavcodec/xan.c index b9e28cb3a2..32402a7114 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -354,8 +354,7 @@ static void xan_wc3_decode_frame(XanContext *s) { 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; } diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index 6f7597380d..bdcf0b72c5 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -579,9 +579,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8 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]; } diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index c4c934e2fa..86ea1cb768 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -144,9 +144,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void 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 *avctx, uint8_t *buf, int buf_size, void } 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); |