| 371 | } |
| 372 | |
| 373 | static av_cold int encode_init(AVCodecContext *avctx) |
| 374 | { |
| 375 | ASVEncContext *const a = avctx->priv_data; |
| 376 | int i; |
| 377 | const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2; |
| 378 | int inv_qscale; |
| 379 | |
| 380 | ff_asv_common_init(avctx); |
| 381 | ff_fdctdsp_init(&a->fdsp, avctx); |
| 382 | ff_pixblockdsp_init(&a->pdsp, 8); |
| 383 | |
| 384 | if (avctx->global_quality <= 0) |
| 385 | avctx->global_quality = 4 * FF_QUALITY_SCALE; |
| 386 | |
| 387 | inv_qscale = (32 * scale * FF_QUALITY_SCALE + |
| 388 | avctx->global_quality / 2) / avctx->global_quality; |
| 389 | |
| 390 | avctx->extradata = av_mallocz(8); |
| 391 | if (!avctx->extradata) |
| 392 | return AVERROR(ENOMEM); |
| 393 | avctx->extradata_size = 8; |
| 394 | AV_WL32A(avctx->extradata, inv_qscale); |
| 395 | AV_WL32A(avctx->extradata + 4, MKTAG('A', 'S', 'U', 'S')); |
| 396 | |
| 397 | for (i = 0; i < 64; i++) { |
| 398 | if (a->fdsp.fdct == ff_fdct_ifast) { |
| 399 | int q = 32LL * scale * ff_mpeg1_default_intra_matrix[i] * ff_aanscales[i]; |
| 400 | a->q_intra_matrix[i] = (((int64_t)inv_qscale << 30) + q / 2) / q; |
| 401 | } else { |
| 402 | int q = 32 * scale * ff_mpeg1_default_intra_matrix[i]; |
| 403 | a->q_intra_matrix[i] = ((inv_qscale << 16) + q / 2) / q; |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | return 0; |
| 408 | } |
| 409 | |
| 410 | #if CONFIG_ASV1_ENCODER |
| 411 | const FFCodec ff_asv1_encoder = { |
nothing calls this directly
no test coverage detected