31 #define MAX_RLE_BULK 127
33 #define MAX_RLE_REPEAT 128
35 #define MAX_RLE_SKIP 254
89 if (avctx->
width % 4) {
148 unsigned int skipcount;
155 int total_repeat_cost;
158 int lowest_bulk_cost;
159 int lowest_bulk_cost_index;
160 int sec_lowest_bulk_cost;
161 int sec_lowest_bulk_cost_index;
163 uint8_t *this_line = p->
data[0] + line*p-> linesize[0] +
172 lowest_bulk_cost = INT_MAX / 2;
173 lowest_bulk_cost_index =
width;
174 sec_lowest_bulk_cost = INT_MAX / 2;
175 sec_lowest_bulk_cost_index =
width;
179 for (i = width - 1; i >= 0; i--) {
186 lowest_bulk_cost = sec_lowest_bulk_cost;
187 lowest_bulk_cost_index = sec_lowest_bulk_cost_index;
189 sec_lowest_bulk_cost = INT_MAX / 2;
190 sec_lowest_bulk_cost_index =
width;
197 sec_lowest_bulk_cost++;
202 prev_bulk_cost = s->
length_table[i + 1] + base_bulk_cost;
203 if (prev_bulk_cost <= sec_lowest_bulk_cost) {
206 if (prev_bulk_cost <= lowest_bulk_cost) {
211 sec_lowest_bulk_cost = INT_MAX / 2;
213 lowest_bulk_cost = prev_bulk_cost;
214 lowest_bulk_cost_index = i + 1;
217 sec_lowest_bulk_cost = prev_bulk_cost;
218 sec_lowest_bulk_cost_index = i + 1;
245 if (repeatcount > 1 && (skipcount == 0 || total_repeat_cost < total_skip_cost)) {
250 else if (skipcount > 0) {
281 bytestream_put_byte(buf, s->
skip_table[0] + 1);
284 else bytestream_put_byte(buf, 1);
289 bytestream_put_byte(buf, rlecode);
292 bytestream_put_byte(buf, s->
skip_table[i] + 1);
295 else if (rlecode > 0) {
303 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
315 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
322 bytestream_put_byte(buf, -1);
335 for (start_line = 0; start_line < s->
avctx->
height; start_line++)
341 for (end_line=s->
avctx->
height; end_line > start_line; end_line--)
348 bytestream_put_be32(&buf, 0);
351 bytestream_put_be16(&buf, 0);
353 bytestream_put_be16(&buf, 8);
354 bytestream_put_be16(&buf, start_line);
355 bytestream_put_be16(&buf, 0);
356 bytestream_put_be16(&buf, end_line - start_line);
357 bytestream_put_be16(&buf, 0);
359 for (i = start_line; i < end_line; i++)
362 bytestream_put_byte(&buf, 0);
363 AV_WB32(orig_buf, buf - orig_buf);
364 return buf - orig_buf;
368 const AVFrame *pict,
int *got_packet)