Lines Matching defs:avctx

272     if (!FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_l,   ctx->m.avctx->qmax + 1) ||
273 !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_c, ctx->m.avctx->qmax + 1) ||
274 !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_l16, ctx->m.avctx->qmax + 1) ||
275 !FF_ALLOCZ_TYPED_ARRAY(ctx->qmatrix_c16, ctx->m.avctx->qmax + 1))
285 ctx->m.avctx->qmax, 1);
292 ctx->m.avctx->qmax, 1);
294 for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) {
306 for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) {
339 if (!FF_ALLOCZ_TYPED_ARRAY(ctx->mb_rc, (ctx->m.avctx->qmax + 1) * ctx->m.mb_num))
342 if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD) {
354 static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
356 DNXHDEncContext *ctx = avctx->priv_data;
359 switch (avctx->pix_fmt) {
370 if ((ctx->profile == FF_PROFILE_DNXHR_444 && (avctx->pix_fmt != AV_PIX_FMT_YUV444P10 &&
371 avctx->pix_fmt != AV_PIX_FMT_GBRP10)) ||
372 (ctx->profile != FF_PROFILE_DNXHR_444 && (avctx->pix_fmt == AV_PIX_FMT_YUV444P10 ||
373 avctx->pix_fmt == AV_PIX_FMT_GBRP10))) {
374 av_log(avctx, AV_LOG_ERROR,
379 if (ctx->profile == FF_PROFILE_DNXHR_HQX && avctx->pix_fmt != AV_PIX_FMT_YUV422P10) {
380 av_log(avctx, AV_LOG_ERROR,
387 ctx->profile == FF_PROFILE_DNXHR_HQ) && avctx->pix_fmt != AV_PIX_FMT_YUV422P) {
388 av_log(avctx, AV_LOG_ERROR,
394 avctx->profile = ctx->profile;
395 ctx->cid = ff_dnxhd_find_cid(avctx, ctx->bit_depth);
397 av_log(avctx, AV_LOG_ERROR,
399 ff_dnxhd_print_profiles(avctx, AV_LOG_ERROR);
402 av_log(avctx, AV_LOG_DEBUG, "cid %d\n", ctx->cid);
405 avctx->codec_tag = MKTAG('A','V','d','h');
407 if (avctx->width < 256 || avctx->height < 120) {
408 av_log(avctx, AV_LOG_ERROR,
416 ctx->m.avctx = avctx;
420 avctx->bits_per_raw_sample = ctx->bit_depth;
422 ff_blockdsp_init(&ctx->bdsp, avctx);
423 ff_fdctdsp_init(&ctx->m.fdsp, avctx);
425 ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx);
426 ff_pixblockdsp_init(&ctx->m.pdsp, avctx);
452 ctx->m.mb_height = (avctx->height + 15) / 16;
453 ctx->m.mb_width = (avctx->width + 15) / 16;
455 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
461 av_log(avctx, AV_LOG_ERROR,
470 avctx->width, avctx->height);
503 if (avctx->active_thread_type == FF_THREAD_SLICE) {
504 if (avctx->thread_count > MAX_THREADS) {
505 av_log(avctx, AV_LOG_ERROR, "too many threads\n");
510 if (avctx->qmax <= 1) {
511 av_log(avctx, AV_LOG_ERROR, "qmax must be at least 2\n");
516 if (avctx->active_thread_type == FF_THREAD_SLICE) {
517 for (i = 1; i < avctx->thread_count; i++) {
527 static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf)
529 DNXHDEncContext *ctx = avctx->priv_data;
543 AV_WB16(buf + 0x18, avctx->height >> ctx->interlaced); // ALPF
544 AV_WB16(buf + 0x1a, avctx->width); // SPL
545 AV_WB16(buf + 0x1d, avctx->height >> ctx->interlaced); // NAL
550 buf[0x2c] = (!ctx->interlaced << 7) | (ctx->is_444 << 6) | (avctx->pix_fmt == AV_PIX_FMT_YUV444P10);
698 if (ctx->bit_depth != 10 && vdsp->emulated_edge_mc && ((mb_x << 4) + 16 > ctx->m.avctx->width ||
699 (mb_y << 4) + 16 > ctx->m.avctx->height)) {
700 int y_w = ctx->m.avctx->width - (mb_x << 4);
701 int y_h = ctx->m.avctx->height - (mb_y << 4);
725 } else if (ctx->bit_depth == 10 && vdsp->emulated_edge_mc && ((mb_x << 4) + 16 > ctx->m.avctx->width ||
726 (mb_y << 4) + 16 > ctx->m.avctx->height)) {
727 int y_w = ctx->m.avctx->width - (mb_x << 4);
728 int y_h = ctx->m.avctx->height - (mb_y << 4);
760 if (mb_y + 1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) {
822 static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg,
825 DNXHDEncContext *ctx = avctx->priv_data;
866 if (avctx->mb_decision == FF_MB_DECISION_RD || !RC_VARIANCE) {
879 static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg,
882 DNXHDEncContext *ctx = avctx->priv_data;
897 put_bits(&ctx->m.pb, 1, avctx->pix_fmt == AV_PIX_FMT_YUV444P10);
937 static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
940 DNXHDEncContext *ctx = avctx->priv_data;
943 ((avctx->height >> ctx->interlaced) & 0xF);
953 if (!partial_last_row && mb_x * 16 <= avctx->width - 16 && (avctx->width % 16) == 0) {
957 int bw = FFMIN(avctx->width - 16 * mb_x, 16);
958 int bh = FFMIN((avctx->height >> ctx->interlaced) - 16 * mb_y, 16);
981 int bw = FFMIN(avctx->width - 16 * mb_x, 16);
982 int bh = FFMIN((avctx->height >> ctx->interlaced) - 16 * mb_y, 16);
1005 static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
1011 for (q = 1; q < avctx->qmax; q++) {
1013 avctx->execute2(avctx, dnxhd_calc_bits_thread,
1032 for (q = 1; q < avctx->qmax; q++) {
1097 ctx->m.avctx->execute2(ctx->m.avctx, dnxhd_calc_bits_thread,
1130 if (qscale >= ctx->m.avctx->qmax)
1194 static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx)
1223 avctx->execute2(avctx, dnxhd_mb_var_thread,
1247 for (i = 0; i < ctx->m.avctx->thread_count; i++) {
1257 static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
1260 DNXHDEncContext *ctx = avctx->priv_data;
1265 if ((ret = ff_get_encode_buffer(avctx, pkt, ctx->frame_size, 0)) < 0)
1278 dnxhd_write_header(avctx, buf);
1280 if (avctx->mb_decision == FF_MB_DECISION_RD)
1281 ret = dnxhd_encode_rdo(avctx, ctx);
1283 ret = dnxhd_encode_fast(avctx, ctx);
1285 av_log(avctx, AV_LOG_ERROR,
1299 avctx->execute2(avctx, dnxhd_encode_thread, buf, NULL, ctx->m.mb_height);
1320 static av_cold int dnxhd_encode_end(AVCodecContext *avctx)
1322 DNXHDEncContext *ctx = avctx->priv_data;
1344 for (i = 1; i < avctx->thread_count; i++)