| 102 | } |
| 103 | |
| 104 | int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx) |
| 105 | { |
| 106 | AVBSFContext *ctx; |
| 107 | FFBSFContext *bsfi; |
| 108 | int ret; |
| 109 | |
| 110 | bsfi = av_mallocz(sizeof(*bsfi)); |
| 111 | if (!bsfi) |
| 112 | return AVERROR(ENOMEM); |
| 113 | ctx = &bsfi->pub; |
| 114 | |
| 115 | ctx->av_class = &bsf_class; |
| 116 | ctx->filter = filter; |
| 117 | |
| 118 | ctx->par_in = avcodec_parameters_alloc(); |
| 119 | ctx->par_out = avcodec_parameters_alloc(); |
| 120 | if (!ctx->par_in || !ctx->par_out) { |
| 121 | ret = AVERROR(ENOMEM); |
| 122 | goto fail; |
| 123 | } |
| 124 | /* allocate priv data and init private options */ |
| 125 | if (ff_bsf(filter)->priv_data_size) { |
| 126 | ctx->priv_data = av_mallocz(ff_bsf(filter)->priv_data_size); |
| 127 | if (!ctx->priv_data) { |
| 128 | ret = AVERROR(ENOMEM); |
| 129 | goto fail; |
| 130 | } |
| 131 | if (filter->priv_class) { |
| 132 | *(const AVClass **)ctx->priv_data = filter->priv_class; |
| 133 | av_opt_set_defaults(ctx->priv_data); |
| 134 | } |
| 135 | } |
| 136 | bsfi->buffer_pkt = av_packet_alloc(); |
| 137 | if (!bsfi->buffer_pkt) { |
| 138 | ret = AVERROR(ENOMEM); |
| 139 | goto fail; |
| 140 | } |
| 141 | |
| 142 | *pctx = ctx; |
| 143 | return 0; |
| 144 | fail: |
| 145 | av_bsf_free(&ctx); |
| 146 | return ret; |
| 147 | } |
| 148 | |
| 149 | int av_bsf_init(AVBSFContext *ctx) |
| 150 | { |
no test coverage detected