static int val_in_array(const int *arr, int len, int val)
{
    int i;
    for (i = 0; i < len; i++)
        if (arr[i] == val)
            return 1;
    return 0;
}
['static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,\n                                   uint8_t **data, int *size)\n{\n    static const int extradata_nal_types_hevc[] = {\n        HEVC_NAL_VPS, HEVC_NAL_SPS, HEVC_NAL_PPS,\n    };\n    static const int extradata_nal_types_h264[] = {\n        H264_NAL_SPS, H264_NAL_PPS,\n    };\n    ExtractExtradataContext *s = ctx->priv_data;\n    H2645Packet h2645_pkt = { 0 };\n    int extradata_size = 0;\n    const int *extradata_nal_types;\n    int nb_extradata_nal_types;\n    int i, has_sps = 0, has_vps = 0, ret = 0;\n    if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {\n        extradata_nal_types    = extradata_nal_types_hevc;\n        nb_extradata_nal_types = FF_ARRAY_ELEMS(extradata_nal_types_hevc);\n    } else {\n        extradata_nal_types    = extradata_nal_types_h264;\n        nb_extradata_nal_types = FF_ARRAY_ELEMS(extradata_nal_types_h264);\n    }\n    ret = ff_h2645_packet_split(&h2645_pkt, pkt->data, pkt->size,\n                                ctx, 0, 0, ctx->par_in->codec_id);\n    if (ret < 0)\n        return ret;\n    for (i = 0; i < h2645_pkt.nb_nals; i++) {\n        H2645NAL *nal = &h2645_pkt.nals[i];\n        if (val_in_array(extradata_nal_types, nb_extradata_nal_types, nal->type)) {\n            extradata_size += nal->raw_size + 3;\n            if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {\n                if (nal->type == HEVC_NAL_SPS) has_sps = 1;\n                if (nal->type == HEVC_NAL_VPS) has_vps = 1;\n            } else {\n                if (nal->type == H264_NAL_SPS) has_sps = 1;\n            }\n        }\n    }\n    if (extradata_size &&\n        ((ctx->par_in->codec_id == AV_CODEC_ID_HEVC && has_sps && has_vps) ||\n         (ctx->par_in->codec_id == AV_CODEC_ID_H264 && has_sps))) {\n        AVBufferRef *filtered_buf;\n        uint8_t *extradata, *filtered_data;\n        if (s->remove) {\n            filtered_buf = av_buffer_alloc(pkt->size + AV_INPUT_BUFFER_PADDING_SIZE);\n            if (!filtered_buf)\n                goto fail;\n            filtered_data = filtered_buf->data;\n        }\n        extradata = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);\n        if (!extradata) {\n            av_buffer_unref(&filtered_buf);\n            goto fail;\n        }\n        *data = extradata;\n        *size = extradata_size;\n        for (i = 0; i < h2645_pkt.nb_nals; i++) {\n            H2645NAL *nal = &h2645_pkt.nals[i];\n            if (val_in_array(extradata_nal_types, nb_extradata_nal_types,\n                             nal->type)) {\n                AV_WB24(extradata, 1);\n                memcpy(extradata + 3, nal->raw_data, nal->raw_size);\n                extradata += 3 + nal->raw_size;\n            } else if (s->remove) {\n                AV_WB24(filtered_data, 1);\n                memcpy(filtered_data + 3, nal->raw_data, nal->raw_size);\n                filtered_data += 3 + nal->raw_size;\n            }\n        }\n        if (s->remove) {\n            av_buffer_unref(&pkt->buf);\n            pkt->buf  = filtered_buf;\n            pkt->data = filtered_buf->data;\n            pkt->size = filtered_data - filtered_buf->data;\n        }\n    }\nfail:\n    ff_h2645_packet_uninit(&h2645_pkt);\n    return ret;\n}', 'static int val_in_array(const int *arr, int len, int val)\n{\n    int i;\n    for (i = 0; i < len; i++)\n        if (arr[i] == val)\n            return 1;\n    return 0;\n}']