| 1690 | } |
| 1691 | |
| 1692 | int dec_create(const OptionsContext *o, const char *arg, Scheduler *sch) |
| 1693 | { |
| 1694 | DecoderPriv *dp; |
| 1695 | |
| 1696 | OutputFile *of; |
| 1697 | OutputStream *ost; |
| 1698 | int of_index, ost_index; |
| 1699 | char *p; |
| 1700 | |
| 1701 | unsigned enc_idx; |
| 1702 | int ret; |
| 1703 | |
| 1704 | ret = dec_alloc(&dp, sch, 0); |
| 1705 | if (ret < 0) |
| 1706 | return ret; |
| 1707 | |
| 1708 | dp->index = nb_decoders; |
| 1709 | |
| 1710 | ret = GROW_ARRAY(decoders, nb_decoders); |
| 1711 | if (ret < 0) { |
| 1712 | dec_free((Decoder **)&dp); |
| 1713 | return ret; |
| 1714 | } |
| 1715 | |
| 1716 | decoders[nb_decoders - 1] = (Decoder *)dp; |
| 1717 | |
| 1718 | of_index = strtol(arg, &p, 0); |
| 1719 | if (of_index < 0 || of_index >= nb_output_files) { |
| 1720 | av_log(dp, AV_LOG_ERROR, "Invalid output file index '%d' in %s\n", of_index, arg); |
| 1721 | return AVERROR(EINVAL); |
| 1722 | } |
| 1723 | of = output_files[of_index]; |
| 1724 | |
| 1725 | ost_index = strtol(p + 1, NULL, 0); |
| 1726 | if (ost_index < 0 || ost_index >= of->nb_streams) { |
| 1727 | av_log(dp, AV_LOG_ERROR, "Invalid output stream index '%d' in %s\n", ost_index, arg); |
| 1728 | return AVERROR(EINVAL); |
| 1729 | } |
| 1730 | ost = of->streams[ost_index]; |
| 1731 | |
| 1732 | if (!ost->enc) { |
| 1733 | av_log(dp, AV_LOG_ERROR, "Output stream %s has no encoder\n", arg); |
| 1734 | return AVERROR(EINVAL); |
| 1735 | } |
| 1736 | |
| 1737 | dp->dec.type = ost->type; |
| 1738 | |
| 1739 | ret = enc_loopback(ost->enc); |
| 1740 | if (ret < 0) |
| 1741 | return ret; |
| 1742 | enc_idx = ret; |
| 1743 | |
| 1744 | ret = sch_connect(sch, SCH_ENC(enc_idx), SCH_DEC_IN(dp->sch_idx)); |
| 1745 | if (ret < 0) |
| 1746 | return ret; |
| 1747 | |
| 1748 | ret = av_dict_copy(&dp->standalone_init.opts, o->g->codec_opts, 0); |
| 1749 | if (ret < 0) |
nothing calls this directly
no test coverage detected