| 69 | |
| 70 | |
| 71 | static av_cold int dvvideo_encode_init(AVCodecContext *avctx) |
| 72 | { |
| 73 | DVEncContext *s = avctx->priv_data; |
| 74 | FDCTDSPContext fdsp; |
| 75 | int ret; |
| 76 | |
| 77 | s->avctx = avctx; |
| 78 | |
| 79 | if (avctx->chroma_sample_location != AVCHROMA_LOC_TOPLEFT) { |
| 80 | const char *name = av_chroma_location_name(avctx->chroma_sample_location); |
| 81 | av_log(avctx, AV_LOG_WARNING, "Only top-left chroma location is supported " |
| 82 | "in DV, input value is: %s\n", name ? name : "unknown"); |
| 83 | if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL) |
| 84 | return AVERROR(EINVAL); |
| 85 | } |
| 86 | |
| 87 | s->sys = av_dv_codec_profile2(avctx->width, avctx->height, avctx->pix_fmt, avctx->time_base); |
| 88 | if (!s->sys) { |
| 89 | av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. " |
| 90 | "Valid DV profiles are:\n", |
| 91 | avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt)); |
| 92 | ff_dv_print_profiles(avctx, AV_LOG_ERROR); |
| 93 | return AVERROR(EINVAL); |
| 94 | } |
| 95 | |
| 96 | ff_dv_init_dynamic_tables(s->work_chunks, s->sys); |
| 97 | |
| 98 | if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { |
| 99 | MECmpContext mecc; |
| 100 | me_cmp_func ildct_cmp[6]; |
| 101 | |
| 102 | ff_me_cmp_init(&mecc, avctx); |
| 103 | ret = ff_set_cmp(&mecc, ildct_cmp, avctx->ildct_cmp, 0); |
| 104 | if (ret < 0) |
| 105 | return ret; |
| 106 | if (!ildct_cmp[5]) |
| 107 | return AVERROR(EINVAL); |
| 108 | s->ildct_cmp = ildct_cmp[5]; |
| 109 | } |
| 110 | |
| 111 | memset(&fdsp,0, sizeof(fdsp)); |
| 112 | ff_fdctdsp_init(&fdsp, avctx); |
| 113 | s->fdct[0] = fdsp.fdct; |
| 114 | s->fdct[1] = fdsp.fdct248; |
| 115 | ff_pixblockdsp_init(&s->pdsp, 8); |
| 116 | |
| 117 | #if !CONFIG_HARDCODED_TABLES |
| 118 | { |
| 119 | static AVOnce init_static_once = AV_ONCE_INIT; |
| 120 | ff_thread_once(&init_static_once, dv_vlc_map_tableinit); |
| 121 | } |
| 122 | #endif |
| 123 | |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | /* bit budget for AC only in 5 MBs */ |
| 128 | static const int vs_total_ac_bits_hd = (68 * 6 + 52*2) * 5; |
nothing calls this directly
no test coverage detected