static av_cold int dvvideo_encode_init(AVCodecContext *avctx) { DVVideoContext *s = avctx->priv_data; FDCTDSPContext fdsp; MECmpContext mecc; PixblockDSPContext pdsp; int ret; s->sys = avpriv_dv_codec_profile(avctx); if (!s->sys) { av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. " "Valid DV profiles are:\n", avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt)); ff_dv_print_profiles(avctx, AV_LOG_ERROR); return AVERROR(EINVAL); } if (avctx->height > 576) { av_log(avctx, AV_LOG_ERROR, "DVCPRO HD encoding is not supported.\n"); return AVERROR_PATCHWELCOME; } ret = ff_dv_init_dynamic_tables(s, s->sys); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing work tables.\n"); return ret; } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); dv_vlc_map_tableinit(); memset(&fdsp,0, sizeof(fdsp)); memset(&mecc,0, sizeof(mecc)); memset(&pdsp,0, sizeof(pdsp)); ff_fdctdsp_init(&fdsp, avctx); ff_me_cmp_init(&mecc, avctx); ff_pixblockdsp_init(&pdsp, avctx); ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp); s->get_pixels = pdsp.get_pixels; s->ildct_cmp = mecc.ildct_cmp[5]; s->fdct[0] = fdsp.fdct; s->fdct[1] = fdsp.fdct248; return ff_dvvideo_init(avctx); }
int avcodec_dct_init(AVDCT *dsp) { AVCodecContext *avctx = avcodec_alloc_context3(NULL); if (!avctx) return AVERROR(ENOMEM); avctx->idct_algo = dsp->idct_algo; avctx->dct_algo = dsp->dct_algo; avctx->bits_per_raw_sample = dsp->bits_per_sample; #define COPY(src, name) memcpy(&dsp->name, &src.name, sizeof(dsp->name)) #if CONFIG_IDCTDSP { IDCTDSPContext idsp; ff_idctdsp_init(&idsp, avctx); COPY(idsp, idct); COPY(idsp, idct_permutation); } #endif #if CONFIG_FDCTDSP { FDCTDSPContext fdsp; ff_fdctdsp_init(&fdsp, avctx); COPY(fdsp, fdct); } #endif #if CONFIG_PIXBLOCKDSP { PixblockDSPContext pdsp; ff_pixblockdsp_init(&pdsp, avctx); COPY(pdsp, get_pixels); } #endif avcodec_close(avctx); av_free(avctx); return 0; }