44 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
45 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
46 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
47 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
48 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
49 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
50 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
51 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
52 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
53 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
54 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
55 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
56 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1,
57 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
58 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
59 -1, -1, -1, -1, -1, -1, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0,
63 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
64 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
65 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
66 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
67 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
68 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
69 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
70 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
71 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
72 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
73 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
74 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
75 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
76 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
77 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
78 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1,
82 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
83 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
84 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
85 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
86 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
87 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
88 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
89 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
90 -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
91 -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
92 -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
93 -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
94 -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -3, -3, -3, -3, -3, -3,
95 -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
96 -3, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
97 -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -0, -0, -0, -0,
101 0, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
102 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
103 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
104 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
105 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
106 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
107 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
108 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
109 -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
110 -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
111 -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
112 -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
113 -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
114 -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -4, -4,
115 -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
116 -4, -4, -4, -4, -4, -3, -3, -3, -3, -3, -3, -3, -2, -2, -2, -1,
120 0, 10, 10, 10, 10, 16, 16, 16, 28, 16, 16, 29, 42, 49, 20, 49,
121 59, 25, 26, 26, 27, 31, 33, 33, 33, 34, 34, 37, 67, 38, 39, 39,
122 40, 40, 41, 79, 43, 44, 45, 45, 48, 48, 64, 50, 51, 52, 88, 52,
123 53, 74, 55, 57, 58, 58, 74, 60, 101, 61, 62, 84, 66, 66, 68, 69,
124 87, 82, 71, 97, 73, 73, 82, 75, 111, 77, 94, 78, 87, 81, 83, 97,
125 85, 83, 94, 86, 99, 89, 90, 99, 111, 92, 93, 134, 95, 98, 105, 98,
126 105, 110, 102, 108, 102, 118, 103, 106, 106, 113, 109, 112, 114, 112, 116, 125,
127 115, 116, 117, 117, 126, 119, 125, 121, 121, 123, 145, 124, 126, 131, 127, 129,
128 165, 130, 132, 138, 133, 135, 145, 136, 137, 139, 146, 141, 143, 142, 144, 148,
129 147, 155, 151, 149, 151, 150, 152, 157, 153, 154, 156, 168, 158, 162, 161, 160,
130 172, 163, 169, 164, 166, 184, 167, 170, 177, 174, 171, 173, 182, 176, 180, 178,
131 175, 189, 179, 181, 186, 183, 192, 185, 200, 187, 191, 188, 190, 197, 193, 196,
132 197, 194, 195, 196, 198, 202, 199, 201, 210, 203, 207, 204, 205, 206, 208, 214,
133 209, 211, 221, 212, 213, 215, 224, 216, 217, 218, 219, 220, 222, 228, 223, 225,
134 226, 224, 227, 229, 240, 230, 231, 232, 233, 234, 235, 236, 238, 239, 237, 242,
135 241, 243, 242, 244, 245, 246, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255,
139 const uint8_t one_state[256])
144 for (
i = 1;
i < 256;
i++)
145 l2tab[
i] = -
log2(
i / 256.0) * ((1
U << 31) / 8);
147 for (
i = 0;
i < 256;
i++) {
148 uint64_t best_len[256];
150 for (j = 0; j < 256; j++)
151 best_len[j] = UINT64_MAX;
153 for (j =
FFMAX(
i - 10, 1); j <
FFMIN(
i + 11, 256); j++) {
154 uint32_t occ[256] = { 0 };
161 for (k = 0; k < 256; k++) {
162 uint32_t newocc[256] = { 0 };
163 for (m = 1; m < 256; m++)
165 len += (occ[m]*((
i *(uint64_t)l2tab[ m]
166 + (256-
i)*(uint64_t)l2tab[256-m])>>8)) >> 8;
168 if (
len < best_len[k]) {
170 best_state[
i][k] = j;
172 for (m = 1; m < 256; m++)
174 newocc[ one_state[ m]] += occ[m] * (uint64_t)
i >> 8;
175 newocc[256 - one_state[256 - m]] += occ[m] * (uint64_t)(256 -
i) >> 8;
177 memcpy(occ, newocc,
sizeof(occ));
184 uint8_t *
state,
int v,
186 uint64_t rc_stat[256][2],
187 uint64_t rc_stat2[32][2])
191 #define put_rac(C, S, B) \
194 rc_stat[*(S)][B]++; \
195 rc_stat2[(S) - state][B]++; \
205 for (
i = 0;
i < e;
i++)
209 for (
i = e - 1;
i >= 0;
i--)
215 for (
i = 0;
i < e;
i++)
219 for (
i = e - 1;
i >= 0;
i--)
232 int v,
int is_signed)
246 while (i < state->error_sum) {
255 ff_dlog(
NULL,
"v:%d/%d bias:%d error:%d drift:%d count:%d k:%d\n", v,
code,
263 #define RENAME(name) name
269 #define RENAME(name) name ## 32
273 const uint8_t *
src,
int w,
int h,
274 int stride,
int plane_index,
int pixel_stride,
int ac)
278 const int ring_size =
f->context_model ? 3 : 2;
284 for (y = 0; y <
h; y++) {
290 if (
f->bits_per_raw_sample <= 8) {
291 for (x = 0; x <
w; x++)
296 if (
f->packed_at_lsb) {
297 for (x = 0; x <
w; x++) {
301 for (x = 0; x <
w; x++) {
302 sample[0][x] = ((uint16_t*)(
src +
stride*y))[x] >> (16 -
f->bits_per_raw_sample);
331 for (
i = 0;
i < 5;
i++)
340 for (
int i = 0;
i < nb_contexts;
i++)
342 if (initial_state[
i][j] != 128)
355 if (
f->version < 2) {
359 for (
i = 1;
i < 256;
i++)
361 f->state_transition[
i] -
c->one_state[
i], 1);
372 }
else if (
f->version < 3) {
374 for (
i = 0;
i <
f->slice_count;
i++) {
377 (
fs->slice_x + 1) *
f->num_h_slices /
f->width, 0);
379 (
fs->slice_y + 1) *
f->num_v_slices /
f->height, 0);
381 (
fs->slice_width + 1) *
f->num_h_slices /
f->width - 1,
384 (
fs->slice_height + 1) *
f->num_v_slices /
f->height - 1,
386 for (j = 0; j <
f->plane_count; j++) {
388 av_assert0(
fs->plane[j].quant_table_index ==
f->context_model);
402 memset(state2, 128,
sizeof(state2));
405 f->avctx->extradata_size = 10000 + 4 +
406 (11 * 11 * 5 * 5 * 5 + 11 * 11 * 11) * 32;
408 if (!
f->avctx->extradata)
414 if (
f->version > 2) {
415 if (
f->version == 3) {
416 f->micro_version = 4;
417 }
else if (
f->version == 4)
418 f->micro_version = 3;
424 for (
i = 1;
i < 256;
i++)
437 for (
i = 0;
i <
f->quant_table_count;
i++)
440 for (
i = 0;
i <
f->quant_table_count;
i++) {
443 for (j = 0; j <
f->context_count[
i]; j++)
445 int pred = j ?
f->initial_states[
i][j - 1][k] : 128;
447 (int8_t)(
f->initial_states[
i][j][k] -
pred), 1);
454 if (
f->version > 2) {
461 AV_WL32(
f->avctx->extradata +
f->avctx->extradata_size, v);
462 f->avctx->extradata_size += 4;
469 int i, i2, changed,
print = 0;
473 for (
i = 12;
i < 244;
i++) {
474 for (i2 =
i + 1; i2 < 245 && i2 <
i + 4; i2++) {
476 #define COST(old, new) \
477 s->rc_stat[old][0] * -log2((256 - (new)) / 256.0) + \
478 s->rc_stat[old][1] * -log2((new) / 256.0)
480 #define COST2(old, new) \
481 COST(old, new) + COST(256 - (old), 256 - (new))
485 if (size0 - sizeX > size0*(1e-14) &&
i != 128 && i2 != 128) {
488 FFSWAP(
int,
s->rc_stat[
i][0],
s->rc_stat[i2][0]);
489 FFSWAP(
int,
s->rc_stat[
i][1],
s->rc_stat[i2][1]);
491 FFSWAP(
int, stt[256 -
i], stt[256 - i2]);
492 FFSWAP(
int,
s->rc_stat[256 -
i][0],
s->rc_stat[256 - i2][0]);
493 FFSWAP(
int,
s->rc_stat[256 -
i][1],
s->rc_stat[256 - i2][1]);
495 for (j = 1; j < 256; j++) {
498 else if (stt[j] == i2)
501 if (stt[256 - j] == 256 -
i)
502 stt[256 - j] = 256 - i2;
503 else if (stt[256 - j] == 256 - i2)
504 stt[256 - j] = 256 -
i;
528 s->version =
FFMAX(
s->version, 2);
537 s->version =
FFMAX(
s->version, 2);
539 if (avctx->
level <= 0 &&
s->version == 2) {
543 if (avctx->
level <
s->version) {
544 av_log(avctx,
AV_LOG_ERROR,
"Version %d needed for requested features but %d requested\n",
s->version, avctx->
level);
547 s->version = avctx->
level;
551 if (
s->version >= 4) {
553 s->crcref = 0x7a8c4079;
554 }
else if (
s->version >= 3) {
562 s->version =
FFMAX(
s->version, 3);
564 s->version =
FFMAX(
s->version, 4);
567 av_log(avctx,
AV_LOG_ERROR,
"Version 2 or 4 needed for requested features but version 2 or 4 is experimental and not enabled\n");
586 s->bits_per_raw_sample = 9;
596 s->bits_per_raw_sample = 10;
605 s->bits_per_raw_sample = 12;
611 s->bits_per_raw_sample = 14;
612 s->packed_at_lsb = 1;
621 s->bits_per_raw_sample = 16;
622 }
else if (!
s->bits_per_raw_sample) {
625 if (
s->bits_per_raw_sample <= 8) {
629 s->version =
FFMAX(
s->version, 1);
641 s->chroma_planes =
desc->nb_components < 3 ? 0 : 1;
645 s->bits_per_raw_sample = 8;
646 else if (!
s->bits_per_raw_sample)
647 s->bits_per_raw_sample = 8;
652 s->chroma_planes = 1;
653 s->bits_per_raw_sample = 8;
658 s->chroma_planes = 1;
659 s->bits_per_raw_sample = 16;
661 s->version =
FFMAX(
s->version, 1);
665 s->chroma_planes = 1;
666 s->bits_per_raw_sample = 16;
668 s->version =
FFMAX(
s->version, 1);
672 s->chroma_planes = 1;
673 s->bits_per_raw_sample = 8;
677 s->bits_per_raw_sample = 9;
681 s->bits_per_raw_sample = 10;
685 s->bits_per_raw_sample = 12;
689 s->bits_per_raw_sample = 14;
693 s->bits_per_raw_sample = 16;
694 else if (!
s->bits_per_raw_sample)
698 s->chroma_planes = 1;
699 if (
s->bits_per_raw_sample >= 16) {
702 s->version =
FFMAX(
s->version, 1);
710 if (
s->bits_per_raw_sample > (
s->version > 3 ? 16 : 8)) {
713 "high bits_per_raw_sample, forcing range coder\n");
719 for (
i = 1;
i < 256;
i++)
724 for (
i = 1;
i < 256;
i++)
725 s->state_transition[
i] =
c.one_state[
i];
729 s->quant_table_count = 2;
730 if ((
s->qtable == -1 &&
s->bits_per_raw_sample <= 8) ||
s->qtable == 1) {
736 s->quant_tables[1][2][
i]= 11*11*
quant5 [
i];
737 s->quant_tables[1][3][
i]= 5*11*11*
quant5 [
i];
738 s->quant_tables[1][4][
i]= 5*5*11*11*
quant5 [
i];
739 s->context_count[0] = (11 * 11 * 11 + 1) / 2;
740 s->context_count[1] = (11 * 11 * 5 * 5 * 5 + 1) / 2;
750 s->context_count[0] = (9 * 9 * 9 + 1) / 2;
751 s->context_count[1] = (9 * 9 * 5 * 5 * 5 + 1) / 2;
758 if (!
s->transparency)
760 if (!
s->chroma_planes &&
s->version > 3)
767 s->picture_number = 0;
770 for (
i = 0;
i <
s->quant_table_count;
i++) {
772 sizeof(*
s->rc_stat2[
i]));
788 for (j = 0; j < 256; j++)
789 for (
i = 0;
i < 2;
i++) {
790 s->rc_stat[j][
i] = strtol(p, &next, 0);
793 "2Pass file invalid at %d %d [%s]\n", j,
i, p);
799 for (
i = 0;
i <
s->quant_table_count;
i++)
800 for (j = 0; j <
s->context_count[
i]; j++) {
801 for (k = 0; k < 32; k++)
802 for (m = 0; m < 2; m++) {
803 s->rc_stat2[
i][j][k][m] = strtol(p, &next, 0);
806 "2Pass file invalid at %d %d %d %d [%s]\n",
814 gob_count = strtol(p, &next, 0);
815 if (next == p || gob_count <= 0) {
821 while (*p ==
'\n' || *p ==
' ')
831 for (
i = 0;
i <
s->quant_table_count;
i++) {
832 for (k = 0; k < 32; k++) {
835 for (j = 0; j <
s->context_count[
i]; j++) {
837 if (
s->rc_stat2[
i][j][k][0] +
s->rc_stat2[
i][j][k][1] > 200 && j ||
a+
b > 200) {
839 p = 256.0 *
b / (
a +
b);
840 s->initial_states[
i][jp][k] =
842 for(jp++; jp<j; jp++)
843 s->initial_states[
i][jp][k] =
s->initial_states[
i][jp-1][k];
846 a +=
s->rc_stat2[
i][j][k][0];
847 b +=
s->rc_stat2[
i][j][k][1];
849 p = 256.0 *
b / (
a +
b);
851 s->initial_states[
i][j][k] =
859 if (
s->version > 1) {
860 int plane_count = 1 + 2*
s->chroma_planes +
s->transparency;
863 s->num_v_slices = (avctx->
width > 352 || avctx->
height > 288 || !avctx->
slices) ? 2 : 1;
865 s->num_v_slices =
FFMIN(
s->num_v_slices, max_v_slices);
867 for (;
s->num_v_slices < 32;
s->num_v_slices++) {
868 for (
s->num_h_slices =
s->num_v_slices;
s->num_h_slices < 2*
s->num_v_slices;
s->num_h_slices++) {
869 int maxw = (avctx->
width +
s->num_h_slices - 1) /
s->num_h_slices;
870 int maxh = (avctx->
height +
s->num_v_slices - 1) /
s->num_v_slices;
871 if (
s->num_h_slices > max_h_slices ||
s->num_v_slices > max_v_slices)
873 if (maxw * maxh * (
int64_t)(
s->bits_per_raw_sample+1) * plane_count > 8<<24)
884 "Unsupported number %d of slices requested, please specify a "
885 "supported number with -slices (ex:4,6,9,12,16, ...)\n",
895 s->slice_count =
s->max_slice_count;
897 for (
int j = 0; j <
s->slice_count; j++) {
898 for (
int i = 0;
i <
s->plane_count;
i++) {
911 #define STATS_OUT_SIZE 1024 * 1024 * 6
916 for (
i = 0;
i <
s->quant_table_count;
i++)
917 for (j = 0; j <
s->max_slice_count; j++) {
941 for (j=0; j<
f->plane_count; j++) {
951 if (
f->version > 3) {
964 const uint8_t *
src[3],
const int stride[3],
int w,
int h)
966 #define NB_Y_COEFF 15
967 static const int rct_y_coeff[15][2] = {
987 int x, y,
i, p, best;
989 int lbd =
f->bits_per_raw_sample <= 8;
990 int packed = !
src[1];
991 int transparency =
f->transparency;
992 int packed_size = (3 + transparency)*2;
994 for (y = 0; y <
h; y++) {
995 int lastr=0, lastg=0, lastb=0;
996 for (p = 0; p < 3; p++)
999 for (x = 0; x <
w; x++) {
1003 unsigned v = *((
const uint32_t*)(
src[0] + x*4 +
stride[0]*y));
1005 g = (v >> 8) & 0xFF;
1006 r = (v >> 16) & 0xFF;
1007 }
else if (packed) {
1008 const uint16_t *p = ((
const uint16_t*)(
src[0] + x*packed_size +
stride[0]*y));
1013 b = *((
const uint16_t*)(
src[0] + x*2 +
stride[0]*y));
1014 g = *((
const uint16_t*)(
src[1] + x*2 +
stride[1]*y));
1015 r = *((
const uint16_t*)(
src[2] + x*2 +
stride[2]*y));
1022 int bg = ag -
sample[0][x];
1023 int bb = ab -
sample[1][x];
1024 int br = ar -
sample[2][x];
1030 stat[
i] +=
FFABS(bg + ((br*rct_y_coeff[
i][0] + bb*rct_y_coeff[
i][1])>>2));
1046 if (stat[
i] < stat[best])
1062 const AVFrame *
const p =
f->cur_enc_frame;
1073 if (
f->version > 3 &&
f->colorspace == 1) {
1083 if (
f->version > 2) {
1096 const int cx = x >>
f->chroma_h_shift;
1097 const int cy = y >>
f->chroma_v_shift;
1101 if (
f->chroma_planes) {
1105 if (
f->transparency)
1110 }
else if (
f->use32bit) {
1125 if (
f->version < 4) {
1140 const AVFrame *pict,
int *got_packet)
1144 uint8_t keystate = 128;
1155 memset(
f->rc_stat, 0,
sizeof(
f->rc_stat));
1156 for (
i = 0;
i <
f->quant_table_count;
i++)
1157 memset(
f->rc_stat2[
i], 0,
f->context_count[
i] *
sizeof(*
f->rc_stat2[
i]));
1160 for (j = 0; j <
f->slice_count; j++) {
1162 for (
i = 0;
i < 256;
i++) {
1166 for (
i = 0;
i <
f->quant_table_count;
i++) {
1167 for (k = 0; k <
f->context_count[
i]; k++)
1168 for (m = 0; m < 32; m++) {
1169 f->rc_stat2[
i][k][m][0] += sc->
rc_stat2[
i][k][m][0];
1170 f->rc_stat2[
i][k][m][1] += sc->
rc_stat2[
i][k][m][1];
1175 for (j = 0; j < 256; j++) {
1176 snprintf(p, end - p,
"%" PRIu64
" %" PRIu64
" ",
1177 f->rc_stat[j][0],
f->rc_stat[j][1]);
1182 for (
i = 0;
i <
f->quant_table_count;
i++) {
1183 for (j = 0; j <
f->context_count[
i]; j++)
1184 for (m = 0; m < 32; m++) {
1185 snprintf(p, end - p,
"%" PRIu64
" %" PRIu64
" ",
1186 f->rc_stat2[
i][j][m][0],
f->rc_stat2[
i][j][m][1]);
1190 snprintf(p, end - p,
"%d\n",
f->gob_count);
1195 maxsize = avctx->
width*avctx->
height * (1 +
f->transparency);
1196 if (
f->chroma_planes)
1198 maxsize +=
f->slice_count * 800;
1199 if (
f->version > 3) {
1200 maxsize *=
f->bits_per_raw_sample + 1;
1202 maxsize +=
f->slice_count * 2 * (avctx->
width + avctx->
height);
1203 maxsize *= 8*(2*
f->bits_per_raw_sample + 5);
1209 av_log(avctx,
AV_LOG_WARNING,
"Cannot allocate worst case packet size, the encoding could fail\n");
1219 f->cur_enc_frame = pict;
1233 for (
i = 1;
i < 256;
i++) {
1234 c->one_state[
i] =
f->state_transition[
i];
1235 c->zero_state[256 -
i] = 256 -
c->one_state[
i];
1239 for (
i = 0;
i <
f->slice_count;
i++) {
1252 f->slice_count,
sizeof(*
f->slices));
1255 for (
i = 0;
i <
f->slice_count;
i++) {
1258 if (
i > 0 ||
f->version > 2) {
1262 AV_WB24(buf_p + bytes, bytes);
1278 f->picture_number++;
1286 #define OFFSET(x) offsetof(FFV1Context, x)
1287 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1291 { .i64 = 0 }, -2, 2,
VE, .unit =
"coder" },
1298 {
"ac",
"Range with custom table (the ac option exists for compatibility and is deprecated)", 0,
AV_OPT_TYPE_CONST,
1299 { .i64 = 1 }, INT_MIN, INT_MAX,
VE, .unit =
"coder" },
1301 { .i64 = 0 }, 0, 1,
VE },
1303 { .i64 = -1 }, -1, 2,
VE },