comparison sgidec.c @ 6218:dfdff1ca78a7 libavcodec

consts I have underestimated this a little, and these are just some ...
author michael
date Fri, 01 Feb 2008 03:26:31 +0000
parents 2b825cb391f2
children 48759bfbd073
comparison
equal deleted inserted replaced
6217:f838213ca91b 6218:dfdff1ca78a7
38 * @param out_buf Points to one line after the output buffer. 38 * @param out_buf Points to one line after the output buffer.
39 * @param out_end end of line in output buffer 39 * @param out_end end of line in output buffer
40 * @param pixelstride pixel stride of input buffer 40 * @param pixelstride pixel stride of input buffer
41 * @return size of output in bytes, -1 if buffer overflows 41 * @return size of output in bytes, -1 if buffer overflows
42 */ 42 */
43 static int expand_rle_row(uint8_t *in_buf, uint8_t* in_end, 43 static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end,
44 unsigned char *out_buf, uint8_t* out_end, int pixelstride) 44 unsigned char *out_buf, uint8_t* out_end, int pixelstride)
45 { 45 {
46 unsigned char pixel, count; 46 unsigned char pixel, count;
47 unsigned char *orig = out_buf; 47 unsigned char *orig = out_buf;
48 48
78 * @param in_buf input buffer 78 * @param in_buf input buffer
79 * @param in_end end of input buffer 79 * @param in_end end of input buffer
80 * @param s the current image state 80 * @param s the current image state
81 * @return 0 if no error, else return error number. 81 * @return 0 if no error, else return error number.
82 */ 82 */
83 static int read_rle_sgi(unsigned char* out_buf, uint8_t *in_buf, 83 static int read_rle_sgi(unsigned char* out_buf, const uint8_t *in_buf,
84 uint8_t *in_end, SgiState* s) 84 const uint8_t *in_end, SgiState* s)
85 { 85 {
86 uint8_t *dest_row; 86 uint8_t *dest_row;
87 unsigned int len = s->height * s->depth * 4; 87 unsigned int len = s->height * s->depth * 4;
88 uint8_t *start_table = in_buf; 88 const uint8_t *start_table = in_buf;
89 unsigned int y, z; 89 unsigned int y, z;
90 unsigned int start_offset; 90 unsigned int start_offset;
91 91
92 /* size of RLE offset and length tables */ 92 /* size of RLE offset and length tables */
93 if(len * 2 > in_end - in_buf) { 93 if(len * 2 > in_end - in_buf) {
119 * @param in_end end of input buffer 119 * @param in_end end of input buffer
120 * @param s the current image state 120 * @param s the current image state
121 * @return 0 if read success, otherwise return -1. 121 * @return 0 if read success, otherwise return -1.
122 */ 122 */
123 static int read_uncompressed_sgi(unsigned char* out_buf, uint8_t* out_end, 123 static int read_uncompressed_sgi(unsigned char* out_buf, uint8_t* out_end,
124 uint8_t *in_buf, uint8_t *in_end, SgiState* s) 124 const uint8_t *in_buf, const uint8_t *in_end, SgiState* s)
125 { 125 {
126 int x, y, z; 126 int x, y, z;
127 uint8_t *ptr; 127 const uint8_t *ptr;
128 unsigned int offset = s->height * s->width; 128 unsigned int offset = s->height * s->width;
129 129
130 /* Test buffer size. */ 130 /* Test buffer size. */
131 if (offset * s->depth > in_end - in_buf) { 131 if (offset * s->depth > in_end - in_buf) {
132 return -1; 132 return -1;
145 return 0; 145 return 0;
146 } 146 }
147 147
148 static int decode_frame(AVCodecContext *avctx, 148 static int decode_frame(AVCodecContext *avctx,
149 void *data, int *data_size, 149 void *data, int *data_size,
150 uint8_t *in_buf, int buf_size) 150 const uint8_t *in_buf, int buf_size)
151 { 151 {
152 SgiState *s = avctx->priv_data; 152 SgiState *s = avctx->priv_data;
153 AVFrame *picture = data; 153 AVFrame *picture = data;
154 AVFrame *p = &s->picture; 154 AVFrame *p = &s->picture;
155 uint8_t *in_end = in_buf + buf_size; 155 const uint8_t *in_end = in_buf + buf_size;
156 unsigned int dimension, bytes_per_channel, rle; 156 unsigned int dimension, bytes_per_channel, rle;
157 int ret = 0; 157 int ret = 0;
158 uint8_t *out_buf, *out_end; 158 uint8_t *out_buf, *out_end;
159 159
160 if (buf_size < SGI_HEADER_SIZE){ 160 if (buf_size < SGI_HEADER_SIZE){