28 #include <sys/types.h>
33 4, 7, 9, 11, 13, 14, 15, 63,
34 7, 7, 11, 12, 14, 15, 63, 63,
35 9, 11, 13, 14, 15, 63, 63, 63,
36 11, 11, 13, 14, 63, 63, 63, 63,
37 11, 13, 14, 63, 63, 63, 63, 63,
38 13, 14, 63, 63, 63, 63, 63, 63,
39 13, 63, 63, 63, 63, 63, 63, 63,
40 63, 63, 63, 63, 63, 63, 63, 63,
43 4, 7, 9, 11, 13, 14, 63, 63,
44 7, 7, 11, 12, 14, 63, 63, 63,
45 9, 11, 13, 14, 63, 63, 63, 63,
46 11, 11, 13, 14, 63, 63, 63, 63,
47 11, 13, 14, 63, 63, 63, 63, 63,
48 13, 14, 63, 63, 63, 63, 63, 63,
49 13, 63, 63, 63, 63, 63, 63, 63,
50 63, 63, 63, 63, 63, 63, 63, 63
53 4, 5, 6, 7, 9, 11, 13, 15,
54 5, 5, 7, 8, 11, 13, 15, 17,
55 6, 7, 9, 11, 13, 15, 15, 17,
56 7, 7, 9, 11, 13, 15, 17, 19,
57 7, 9, 11, 13, 14, 16, 19, 23,
58 9, 11, 13, 14, 16, 19, 23, 29,
59 9, 11, 13, 15, 17, 21, 28, 35,
60 11, 13, 16, 17, 21, 28, 35, 41,
63 4, 4, 5, 5, 6, 7, 7, 9,
64 4, 4, 5, 6, 7, 7, 9, 9,
65 5, 5, 6, 7, 7, 9, 9, 10,
66 5, 5, 6, 7, 7, 9, 9, 10,
67 5, 6, 7, 7, 8, 9, 10, 12,
68 6, 7, 7, 8, 9, 10, 12, 15,
69 6, 7, 7, 9, 10, 11, 14, 17,
70 7, 7, 9, 10, 11, 14, 17, 21,
73 4, 4, 4, 4, 4, 4, 4, 4,
74 4, 4, 4, 4, 4, 4, 4, 4,
75 4, 4, 4, 4, 4, 4, 4, 4,
76 4, 4, 4, 4, 4, 4, 4, 5,
77 4, 4, 4, 4, 4, 4, 5, 5,
78 4, 4, 4, 4, 4, 5, 5, 6,
79 4, 4, 4, 4, 5, 5, 6, 7,
80 4, 4, 4, 4, 5, 6, 7, 7,
83 2, 2, 2, 2, 2, 2, 2, 2,
84 2, 2, 2, 2, 2, 2, 2, 2,
85 2, 2, 2, 2, 2, 2, 2, 2,
86 2, 2, 2, 2, 2, 2, 2, 3,
87 2, 2, 2, 2, 2, 2, 3, 3,
88 2, 2, 2, 2, 2, 3, 3, 3,
89 2, 2, 2, 2, 3, 3, 3, 4,
90 2, 2, 2, 2, 3, 3, 4, 4,
93 4, 4, 4, 4, 4, 4, 4, 4,
94 4, 4, 4, 4, 4, 4, 4, 4,
95 4, 4, 4, 4, 4, 4, 4, 4,
96 4, 4, 4, 4, 4, 4, 4, 4,
97 4, 4, 4, 4, 4, 4, 4, 4,
98 4, 4, 4, 4, 4, 4, 4, 4,
99 4, 4, 4, 4, 4, 4, 4, 4,
100 4, 4, 4, 4, 4, 4, 4, 4,
114 .tag =
MKTAG(
'a',
'p',
'c',
'o'),
117 .br_tab = { 300, 242, 220, 194 },
123 .tag =
MKTAG(
'a',
'p',
'c',
's'),
126 .br_tab = { 720, 560, 490, 440 },
131 .full_name =
"standard",
132 .tag =
MKTAG(
'a',
'p',
'c',
'n'),
135 .br_tab = { 1050, 808, 710, 632 },
140 .full_name =
"high quality",
141 .tag =
MKTAG(
'a',
'p',
'c',
'h'),
144 .br_tab = { 1566, 1216, 1070, 950 },
150 .tag =
MKTAG(
'a',
'p',
'4',
'h'),
153 .br_tab = { 2350, 1828, 1600, 1425 },
158 .full_name =
"4444XQ",
159 .tag =
MKTAG(
'a',
'p',
'4',
'x'),
162 .br_tab = { 3525, 2742, 2400, 2137 },
171 int mps,
i, j, min_quant;
179 mps =
ctx->mbs_per_slice;
180 if (mps & (mps - 1)) {
182 "there should be an integer power of two MBs per slice\n");
188 !(
desc->log2_chroma_w +
desc->log2_chroma_h))
192 ?
"4:4:4:4 profile because of the used input colorspace"
193 :
"HQ profile to keep best quality");
200 "encode alpha. Override with -profile if needed.\n");
203 if (
ctx->alpha_bits & 7) {
216 ctx->num_planes = 3 + !!
ctx->alpha_bits;
225 ctx->slices_width =
ctx->mb_width / mps;
227 ctx->slices_per_picture =
ctx->mb_height *
ctx->slices_width;
230 if (
ctx->quant_sel == -1) {
238 if (strlen(
ctx->vendor) != 4) {
244 if (!
ctx->force_quant) {
245 if (!
ctx->bits_per_mb) {
248 ctx->pictures_per_frame)
250 ctx->bits_per_mb =
ctx->profile_info->br_tab[
i];
252 ctx->bits_per_mb *= 20;
253 }
else if (
ctx->bits_per_mb < 128) {
258 min_quant =
ctx->profile_info->min_quant;
260 for (j = 0; j < 64; j++) {
261 ctx->quants[
i][j] =
ctx->quant_mat[j] *
i;
262 ctx->quants_chroma[
i][j] =
ctx->quant_chroma_mat[j] *
i;
269 if (
ctx->force_quant > 64) {
274 for (j = 0; j < 64; j++) {
275 ctx->quants[0][j] =
ctx->quant_mat[j] *
ctx->force_quant;
276 ctx->quants_chroma[0][j] =
ctx->quant_chroma_mat[j] *
ctx->force_quant;
277 ls +=
av_log2((1 << 11) /
ctx->quants[0][j]) * 2 + 1;
278 ls_chroma +=
av_log2((1 << 11) /
ctx->quants_chroma[0][j]) * 2 + 1;
281 ctx->bits_per_mb = ls * 4 + ls_chroma * 4;
283 ctx->bits_per_mb += ls_chroma * 4;
286 ctx->frame_size_upper_bound = (
ctx->pictures_per_frame *
287 ctx->slices_per_picture + 1) *
288 (2 + 2 *
ctx->num_planes +
289 (mps *
ctx->bits_per_mb) / 8)
292 if (
ctx->alpha_bits) {
294 ctx->frame_size_upper_bound += (
ctx->pictures_per_frame *
295 ctx->slices_per_picture + 1) *
296 (
ctx->mbs_per_slice * 256 *
297 (1 +
ctx->alpha_bits + 1) + 7 >> 3);
304 "profile %d, %d slices, interlacing: %s, %d bits per MB\n",
305 ctx->profile,
ctx->slices_per_picture *
ctx->pictures_per_frame,
308 ctx->frame_size_upper_bound);
314 uint8_t **orig_buf,
int flags,
324 bytestream_put_be32 (orig_buf,
FRAME_ID);
330 bytestream_put_be16 (&buf,
ctx->chroma_factor !=
CFACTOR_Y422 ||
ctx->alpha_bits ? 1 : 0);
332 bytestream_put_be16 (&buf, avctx->
width);
333 bytestream_put_be16 (&buf, avctx->
height);
335 frame_flags =
ctx->chroma_factor << 6;
338 bytestream_put_byte (&buf, frame_flags);
340 bytestream_put_byte (&buf, 0);
342 bytestream_put_byte (&buf, color_trc);
343 bytestream_put_byte (&buf, colorspace);
344 bytestream_put_byte (&buf,
ctx->alpha_bits >> 3);
345 bytestream_put_byte (&buf, 0);
347 bytestream_put_byte (&buf, 0x03);
351 bytestream_put_byte (&buf, 0x00);
353 bytestream_put_be16 (&
tmp, buf - *orig_buf);
359 bytestream_put_byte (&buf, 0x40);
361 bytestream_put_be16 (&buf,
ctx->slices_per_picture);
362 bytestream_put_byte (&buf,
av_log2(
ctx->mbs_per_slice) << 4);