| 147 | } |
| 148 | |
| 149 | int av_bsf_init(AVBSFContext *ctx) |
| 150 | { |
| 151 | int ret, i; |
| 152 | |
| 153 | /* check that the codec is supported */ |
| 154 | if (ctx->filter->codec_ids) { |
| 155 | for (i = 0; ctx->filter->codec_ids[i] != AV_CODEC_ID_NONE; i++) |
| 156 | if (ctx->par_in->codec_id == ctx->filter->codec_ids[i]) |
| 157 | break; |
| 158 | if (ctx->filter->codec_ids[i] == AV_CODEC_ID_NONE) { |
| 159 | const AVCodecDescriptor *desc = avcodec_descriptor_get(ctx->par_in->codec_id); |
| 160 | av_log(ctx, AV_LOG_ERROR, "Codec '%s' (%d) is not supported by the " |
| 161 | "bitstream filter '%s'. Supported codecs are: ", |
| 162 | desc ? desc->name : "unknown", ctx->par_in->codec_id, ctx->filter->name); |
| 163 | for (i = 0; ctx->filter->codec_ids[i] != AV_CODEC_ID_NONE; i++) { |
| 164 | enum AVCodecID codec_id = ctx->filter->codec_ids[i]; |
| 165 | av_log(ctx, AV_LOG_ERROR, "%s (%d) ", |
| 166 | avcodec_get_name(codec_id), codec_id); |
| 167 | } |
| 168 | av_log(ctx, AV_LOG_ERROR, "\n"); |
| 169 | return AVERROR(EINVAL); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /* initialize output parameters to be the same as input |
| 174 | * init below might overwrite that */ |
| 175 | ret = avcodec_parameters_copy(ctx->par_out, ctx->par_in); |
| 176 | if (ret < 0) |
| 177 | return ret; |
| 178 | |
| 179 | ctx->time_base_out = ctx->time_base_in; |
| 180 | |
| 181 | if (ff_bsf(ctx->filter)->init) { |
| 182 | ret = ff_bsf(ctx->filter)->init(ctx); |
| 183 | if (ret < 0) |
| 184 | return ret; |
| 185 | } |
| 186 | |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | void av_bsf_flush(AVBSFContext *ctx) |
| 191 | { |
no test coverage detected