31 #define MAX_RLE_BULK 127
33 #define MAX_RLE_REPEAT 128
35 #define MAX_RLE_SKIP 254
144 unsigned int skipcount;
151 int total_repeat_cost;
154 int lowest_bulk_cost;
155 int lowest_bulk_cost_index;
156 int sec_lowest_bulk_cost;
157 int sec_lowest_bulk_cost_index;
159 uint8_t *this_line = p->
data[0] + line*p-> linesize[0] +
168 lowest_bulk_cost = INT_MAX / 2;
169 lowest_bulk_cost_index =
width;
170 sec_lowest_bulk_cost = INT_MAX / 2;
171 sec_lowest_bulk_cost_index =
width;
175 for (i = width - 1; i >= 0; i--) {
182 lowest_bulk_cost = sec_lowest_bulk_cost;
183 lowest_bulk_cost_index = sec_lowest_bulk_cost_index;
185 sec_lowest_bulk_cost = INT_MAX / 2;
186 sec_lowest_bulk_cost_index =
width;
193 sec_lowest_bulk_cost++;
198 prev_bulk_cost = s->
length_table[i + 1] + base_bulk_cost;
199 if (prev_bulk_cost <= sec_lowest_bulk_cost) {
202 if (prev_bulk_cost <= lowest_bulk_cost) {
207 sec_lowest_bulk_cost = INT_MAX / 2;
209 lowest_bulk_cost = prev_bulk_cost;
210 lowest_bulk_cost_index = i + 1;
213 sec_lowest_bulk_cost = prev_bulk_cost;
214 sec_lowest_bulk_cost_index = i + 1;
241 if (repeatcount > 1 && (skipcount == 0 || total_repeat_cost < total_skip_cost)) {
246 else if (skipcount > 0) {
277 bytestream_put_byte(buf, s->
skip_table[0] + 1);
280 else bytestream_put_byte(buf, 1);
285 bytestream_put_byte(buf, rlecode);
288 bytestream_put_byte(buf, s->
skip_table[i] + 1);
291 else if (rlecode > 0) {
299 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
311 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
318 bytestream_put_byte(buf, -1);
331 for (start_line = 0; start_line < s->
avctx->
height; start_line++)
337 for (end_line=s->
avctx->
height; end_line > start_line; end_line--)
344 bytestream_put_be32(&buf, 0);
347 bytestream_put_be16(&buf, 0);
349 bytestream_put_be16(&buf, 8);
350 bytestream_put_be16(&buf, start_line);
351 bytestream_put_be16(&buf, 0);
352 bytestream_put_be16(&buf, end_line - start_line);
353 bytestream_put_be16(&buf, 0);
355 for (i = start_line; i < end_line; i++)
358 bytestream_put_byte(&buf, 0);
359 AV_WB32(orig_buf, buf - orig_buf);
360 return buf - orig_buf;
364 const AVFrame *pict,
int *got_packet)