I recenlythave tried to convert the preg_replace() line to preg_replace_callback, but with no success. I did try the methods on Stackoverflow, but they seem to be different.
Hope I could get some help with it.
function ame_process_bbcode(&$parser, &$param1, $param2 = '')
{
    if (class_exists('vB_BbCodeParser_Wysiwyg') AND is_a($parser, 'vB_BbCodeParser_Wysiwyg'))
    {
     return $text; 
    }
    else
    {
        global $vbulletin;
        ($hook = vBulletinHook::fetch_hook('automediaembed_parse_bbcode_start')) ? eval($hook) : false;
        $ameinfo = fetch_full_ameinfo();
        $text = preg_replace($ameinfo['find'], $ameinfo['replace'], ($param2 ? $param2 : $param1), 1);
        ($hook = vBulletinHook::fetch_hook('automediaembed_parse_bbcode_end')) ? eval($hook) : false;
        return $text;   
    }
}
Updates: Thanks to @Barmar, I know now that the issue is related to the fetch_full_ameinfo function.. I will add function below. Maybe it will help others in the long run. I will also include the fix whenever I am done. Thanks to @Barmar for the help.
function &fetch_full_ameinfo($findonly = false, $refresh = false)
{
    global $db, $vbulletin, $vbphrase, $stylevar;
    static $ameinfo = array();
    static $inied, $lastfind;
    if ($refresh)
    {
        $inied = false;
    }
    if ($lastfind && !$findonly)
    {
        $inied = false;
        $ameinfo = array();
    }
    if (!$inied)
    {
        if (!$refresh AND $vbulletin->options['automediaembed_cache'])
        {
            $path = $vbulletin->options['automediaembed_cache_path'];
            if (file_exists($path . "findonly.php"));
            {
                if ($findonly)
                {
                    include($path . "findonly.php");
                }
                else
                {
                    include($path . "ameinfo.php");
                }
                $inied = true;
                $lastfind = $findonly;
                return $ameinfo;
            }
        }
        if ($vbulletin->options['automediaembed_resolve'])
        {
            $embed = ",IF(extraction=1 AND embedregexp!= '', embedregexp, '') as embedregexp, IF(extraction=1 AND validation!= '', validation, '') as validation";
            $embedwhere = " AND ((extraction = 0 AND embedregexp = '') OR (extraction = 1)) ";
        }
        else
        {
            $embedwhere = " AND embedregexp = ''";
        }
        $sql = "SELECT findcode" . (!$findonly ? ", replacecode,title,container,ameid" : ",extraction$embed") . " FROM " . TABLE_PREFIX . "automediaembed WHERE status=1 $embedwhere
                        ORDER BY displayorder, title ASC";
        $results = $db->query_read_slave($sql);
        while ($result = $db->fetch_array($results))
        {
            if ($result['findcode'])
            {
                if (!$findonly)
                {
                    $ameinfo['find'][] = "~($result[findcode])~ie";
                    $ameinfo['replace'][] = 'ame_match_bbcode($param1, $param2, \'' . $result['ameid'] . '\', \'' . ame_slasher($result['title']) . '\', ' . $result['container'] . ', \'' . ame_slasher($result['replacecode']) . '\', \'\\1\', \'\\2\', \'\\3\', \'\\4\', \'\\5\', \'\\6\')';
                }
                else
                {
                    $ameinfo['find'][] = "~(\[url\]$result[findcode]\[/url\])~ie";
                    $ameinfo['find'][] = "~(\[url=\"?$result[findcode]\"?\](.*?)\[/url\])~ie";
                    $ameinfo['replace'][] = 'ame_match("\1", "", ' . intval($result['extraction']) .', "' . ($result['embedregexp'] ? "~" . ame_slasher($result['embedregexp']) . "~sim" : "") . '", "' . ($result['validation'] ? "~" . ame_slasher($result['validation']) . "~sim" : "") . '",$ameinfo)';
                    $ameinfo['replace'][] = 'ame_match("\1", "\2", ' . intval($result['extraction']) .', "' . ($result['embedregexp'] ? "~" . ame_slasher($result['embedregexp']) . "~sim" : "") . '", "' . ($result['validation'] ? "~" . ame_slasher($result['validation']) . "~sim" : "") . '", $ameinfo)';
                }
            }
        }
        $inied = true;
    }
    $lastfind = $findonly;
    return $ameinfo;
}
 
    