31 #define MAX_RLE_BULK 127
33 #define MAX_RLE_REPEAT 128
35 #define MAX_RLE_SKIP 254
126 unsigned int skipcount;
133 int total_repeat_cost;
136 int lowest_bulk_cost;
137 int lowest_bulk_cost_index;
138 int sec_lowest_bulk_cost;
139 int sec_lowest_bulk_cost_index;
141 uint8_t *this_line = p->
data[0] + line*p-> linesize[0] +
150 lowest_bulk_cost = INT_MAX / 2;
151 lowest_bulk_cost_index =
width;
152 sec_lowest_bulk_cost = INT_MAX / 2;
153 sec_lowest_bulk_cost_index =
width;
157 for (i = width - 1; i >= 0; i--) {
164 lowest_bulk_cost = sec_lowest_bulk_cost;
165 lowest_bulk_cost_index = sec_lowest_bulk_cost_index;
167 sec_lowest_bulk_cost = INT_MAX / 2;
168 sec_lowest_bulk_cost_index =
width;
175 sec_lowest_bulk_cost++;
180 prev_bulk_cost = s->
length_table[i + 1] + base_bulk_cost;
181 if (prev_bulk_cost <= sec_lowest_bulk_cost) {
184 if (prev_bulk_cost <= lowest_bulk_cost) {
189 sec_lowest_bulk_cost = INT_MAX / 2;
191 lowest_bulk_cost = prev_bulk_cost;
192 lowest_bulk_cost_index = i + 1;
195 sec_lowest_bulk_cost = prev_bulk_cost;
196 sec_lowest_bulk_cost_index = i + 1;
223 if (repeatcount > 1 && (skipcount == 0 || total_repeat_cost < total_skip_cost)) {
228 else if (skipcount > 0) {
259 bytestream_put_byte(buf, s->
skip_table[0] + 1);
262 else bytestream_put_byte(buf, 1);
267 bytestream_put_byte(buf, rlecode);
270 bytestream_put_byte(buf, s->
skip_table[i] + 1);
273 else if (rlecode > 0) {
281 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
293 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
300 bytestream_put_byte(buf, -1);
313 for (start_line = 0; start_line < s->
avctx->
height; start_line++)
319 for (end_line=s->
avctx->
height; end_line > start_line; end_line--)
326 bytestream_put_be32(&buf, 0);
329 bytestream_put_be16(&buf, 0);
331 bytestream_put_be16(&buf, 8);
332 bytestream_put_be16(&buf, start_line);
333 bytestream_put_be16(&buf, 0);
334 bytestream_put_be16(&buf, end_line - start_line);
335 bytestream_put_be16(&buf, 0);
337 for (i = start_line; i < end_line; i++)
340 bytestream_put_byte(&buf, 0);
341 AV_WB32(orig_buf, buf - orig_buf);
342 return buf - orig_buf;
346 const AVFrame *pict,
int *got_packet)