MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / dec_open

Function dec_open

fftools/ffmpeg_dec.c:1527–1663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1525}
1526
1527static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts,
1528 const DecoderOpts *o, AVFrame *param_out)
1529{
1530 const AVCodec *codec = o->codec;
1531 int ret;
1532
1533 dp->flags = o->flags;
1534 dp->log_parent = o->log_parent;
1535
1536 dp->dec.type = codec->type;
1537 dp->framerate_in = o->framerate;
1538
1539 dp->hwaccel_id = o->hwaccel_id;
1540 dp->hwaccel_device_type = o->hwaccel_device_type;
1541 dp->hwaccel_output_format = o->hwaccel_output_format;
1542
1543 snprintf(dp->log_name, sizeof(dp->log_name), "dec:%s", codec->name);
1544
1545 dp->parent_name = av_strdup(o->name ? o->name : "");
1546 if (!dp->parent_name)
1547 return AVERROR(ENOMEM);
1548
1549 if (codec->type == AVMEDIA_TYPE_SUBTITLE &&
1550 (dp->flags & DECODER_FLAG_FIX_SUB_DURATION)) {
1551 for (int i = 0; i < FF_ARRAY_ELEMS(dp->sub_prev); i++) {
1552 dp->sub_prev[i] = av_frame_alloc();
1553 if (!dp->sub_prev[i])
1554 return AVERROR(ENOMEM);
1555 }
1556 dp->sub_heartbeat = av_frame_alloc();
1557 if (!dp->sub_heartbeat)
1558 return AVERROR(ENOMEM);
1559 }
1560
1561 dp->sar_override = o->par->sample_aspect_ratio;
1562
1563 dp->dec_ctx = avcodec_alloc_context3(codec);
1564 if (!dp->dec_ctx)
1565 return AVERROR(ENOMEM);
1566
1567 ret = avcodec_parameters_to_context(dp->dec_ctx, o->par);
1568 if (ret < 0) {
1569 av_log(dp, AV_LOG_ERROR, "Error initializing the decoder context.\n");
1570 return ret;
1571 }
1572
1573 dp->dec_ctx->opaque = dp;
1574 dp->dec_ctx->get_format = get_format;
1575 dp->dec_ctx->get_buffer2 = get_buffer;
1576 dp->dec_ctx->pkt_timebase = o->time_base;
1577
1578 if (!av_dict_get(*dec_opts, "threads", NULL, 0))
1579 av_dict_set(dec_opts, "threads", "auto", 0);
1580
1581 ret = hw_device_setup_for_decode(dp, codec, o->hwaccel_device);
1582 if (ret < 0) {
1583 av_log(dp, AV_LOG_ERROR,
1584 "Hardware device setup failed for decoder: %s\n",

Callers 2

dec_standalone_openFunction · 0.85
dec_initFunction · 0.85

Calls 15

av_strdupFunction · 0.85
av_frame_allocFunction · 0.85
avcodec_alloc_context3Function · 0.85
av_logFunction · 0.85
av_dict_getFunction · 0.85
av_dict_setFunction · 0.85
av_opt_set_dict2Function · 0.85
check_avoptionsFunction · 0.85
avcodec_open2Function · 0.85
av_channel_layout_copyFunction · 0.85

Tested by

no test coverage detected