【FFmpeg】avio_open2函数

【FFmpeg】avio_open2函数

  • 1.avio_open2
    • 1.1 创建URLContext(ffurl_open_whitelist)
      • 1.1.1 创建URLContext(ffurl_alloc)
        • 1.1.1.1 查找合适的protocol(url_find_protocol)
        • 1.1.1.2 为查找到的URLProtocol创建URLContext(url_alloc_for_protocol)
      • 1.1.2 打开URLContext(ffurl_connect)
    • 1.2 根据创建的URLContext初始化AVIOContext(ffio_fdopen)
      • 1.2.1 创建AVIOContext(avio_alloc_context)
  • 2.小结

参考:
FFmpeg源代码简单分析:avio_open2()

示例工程:
【FFmpeg】调用ffmpeg库实现264软编
【FFmpeg】调用ffmpeg库实现264软解
【FFmpeg】调用ffmpeg库进行RTMP推流和拉流
【FFmpeg】调用ffmpeg库进行SDL2解码后渲染

流程分析:
【FFmpeg】编码链路上主要函数的简单分析
【FFmpeg】解码链路上主要函数的简单分析

结构体分析:
【FFmpeg】AVCodec结构体
【FFmpeg】AVCodecContext结构体
【FFmpeg】AVStream结构体
【FFmpeg】AVFormatContext结构体
【FFmpeg】AVIOContext结构体
【FFmpeg】AVPacket结构体

函数分析:
【FFmpeg】avformat_open_input函数
【FFmpeg】avformat_find_stream_info函数
【FFmpeg】avformat_alloc_output_context2函数

avio_open2函数的内部调用关系为
在这里插入图片描述

1.avio_open2

avio_open2函数的定义位于libavformat\avio.c中,功能是打开URL,之后方便进行读写操作。这里的URL是广义的地址,对于文件而言,就是文件的路径,如"C:\xxx\test.flv",也可以是地址例如"rtmp://127.0.0.1:1935/live/stream",flag表示控制如何打开url所指示的资源的标志,如AVIO_FLAG_READ和AVIO_FLAG_WRITE

/**
 * Create and initialize a AVIOContext for accessing the
 * resource indicated by url.
 * @note When the resource indicated by url has been opened in
 * read+write mode, the AVIOContext can be used only for writing.
 *
 * @param s Used to return the pointer to the created AVIOContext.
 * In case of failure the pointed to value is set to NULL.
 * @param url resource to access
 * @param flags flags which control how the resource indicated by url
 * is to be opened
 * @param int_cb an interrupt callback to be used at the protocols level
 * @param options  A dictionary filled with protocol-private options. On return
 * this parameter will be destroyed and replaced with a dict containing options
 * that were not found. May be NULL.
 * @return >= 0 in case of success, a negative value corresponding to an
 * AVERROR code in case of failure
 */
// 创建并初始化一个AVIOContext,用于访问url指定的资源
// @note:当url所指示的资源以读+写方式打开时,AVIOContext只能用于写
int avio_open2(AVIOContext **s, const char *filename, int flags,
               const AVIOInterruptCB *int_cb, AVDictionary **options)
{
    return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL, NULL);
}

avio_open2调用ffio_open_whitelist进行AVIOContext的创建,而ffio_open_whitelist的实现方式如下,其中主要使用了两个函数:(1)ffurl_open_whitelist根据白名单创建URLContext;(2)ffio_fdopen根据创建的URLContext来初始化AVIOContext。其中,URLContext完成协议的读写操作。

int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags,
                        const AVIOInterruptCB *int_cb, AVDictionary **options,
                        const char *whitelist, const char *blacklist)
{
    URLContext *h;
    int err;

    *s = NULL;
	// 1.根据whitelist创建URLContext
    err = ffurl_open_whitelist(&h, filename, flags, int_cb, options, whitelist, blacklist, NULL);
    if (err < 0)
        return err;
    // 2.根据创建的URLContext初始化AVIOContext
    err = ffio_fdopen(s, h);
    if (err < 0) {
        ffurl_close(h);
        return err;
    }
    return 0;
}

1.1 创建URLContext(ffurl_open_whitelist)

该函数的主要内容为两个部分:(1)ffurl_alloc:创建URLContext;(2)ffurl_connect:打开已创建的URLContext;

int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
                         const AVIOInterruptCB *int_cb, AVDictionary **options,
                         const char *whitelist, const char* blacklist,
                         URLContext *parent)
{
    AVDictionary *tmp_opts = NULL;
    AVDictionaryEntry *e;
    // 创建URLContext
    int ret = ffurl_alloc(puc, filename, flags, int_cb);
    if (ret < 0)
        return ret;
    if (parent) {
        ret = av_opt_copy(*puc, parent);
        if (ret < 0)
            goto fail;
    }
    if (options &&
        (ret = av_opt_set_dict(*puc, options)) < 0)
        goto fail;
    if (options && (*puc)->prot->priv_data_class &&
        (ret = av_opt_set_dict((*puc)->priv_data, options)) < 0)
        goto fail;

    if (!options)
        options = &tmp_opts;

    av_assert0(!whitelist ||
               !(e=av_dict_get(*options, "protocol_whitelist", NULL, 0)) ||
               !strcmp(whitelist, e->value));
    av_assert0(!blacklist ||
               !(e=av_dict_get(*options, "protocol_blacklist", NULL, 0)) ||
               !strcmp(blacklist, e->value));

    if ((ret = av_dict_set(options, "protocol_whitelist", whitelist, 0)) < 0)
        goto fail;

    if ((ret = av_dict_set(options, "protocol_blacklist", blacklist, 0)) < 0)
        goto fail;

    if ((ret = av_opt_set_dict(*puc, options)) < 0)
        goto fail;
	// 打开获得的URLProtocol
    ret = ffurl_connect(*puc, options);

    if (!ret)
        return 0;
fail:
    ffurl_closep(puc);
    return ret;
}

1.1.1 创建URLContext(ffurl_alloc)

int ffurl_alloc(URLContext **puc, const char *filename, int flags,
                const AVIOInterruptCB *int_cb)
{
    const URLProtocol *p = NULL;
	// 根据filename查找合适的protocol
    p = url_find_protocol(filename);
    if (p)
       // 为protocol分配URLContext
       return url_alloc_for_protocol(puc, p, filename, flags, int_cb);

    *puc = NULL;
    return AVERROR_PROTOCOL_NOT_FOUND;
}
1.1.1.1 查找合适的protocol(url_find_protocol)

函数主要工作是调用ffurl_get_protocols获取一个protocol

static const struct URLProtocol *url_find_protocol(const char *filename)
{
    const URLProtocol **protocols;
    char proto_str[128], proto_nested[128], *ptr;
    size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
    int i;

    if (filename[proto_len] != ':' &&
        (strncmp(filename, "subfile,", 8) || !strchr(filename + proto_len + 1, ':')) ||
        is_dos_path(filename))
        strcpy(proto_str, "file");
    else
        av_strlcpy(proto_str, filename,
                   FFMIN(proto_len + 1, sizeof(proto_str)));

    av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
    if ((ptr = strchr(proto_nested, '+')))
        *ptr = '\0';
	// 寻找一个protocols
    protocols = ffurl_get_protocols(NULL, NULL);
    if (!protocols)
        return NULL;
    for (i = 0; protocols[i]; i++) {
            const URLProtocol *up = protocols[i];
        if (!strcmp(proto_str, up->name)) {
            av_freep(&protocols);
            return up;
        }
        if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&
            !strcmp(proto_nested, up->name)) {
            av_freep(&protocols);
            return up;
        }
    }
    av_freep(&protocols);
    if (av_strstart(filename, "https:", NULL) || av_strstart(filename, "tls:", NULL))
        av_log(NULL, AV_LOG_WARNING, "https protocol not found, recompile FFmpeg with "
                                     "openssl, gnutls or securetransport enabled.\n");

    return NULL;
}

ffurl_get_protocol的定义如下,大致的流程是遍历可选的url_protocol,检查是否位于白名单中且不在黑名单中

const URLProtocol **ffurl_get_protocols(const char *whitelist,
                                        const char *blacklist)
{
    const URLProtocol **ret;
    int i, ret_idx = 0;

    ret = av_calloc(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
    if (!ret)
        return NULL;

    for (i = 0; url_protocols[i]; i++) {
        const URLProtocol *up = url_protocols[i];

        if (whitelist && *whitelist && !av_match_name(up->name, whitelist))
            continue;
        if (blacklist && *blacklist && av_match_name(up->name, blacklist))
            continue;

        ret[ret_idx++] = up;
    }

    return ret;
}
1.1.1.2 为查找到的URLProtocol创建URLContext(url_alloc_for_protocol)

在创建URLContext时,会先检查flag和函数对应的关系:(1)网络操作;(2)读取;(3)写入;如果有一个初始化失败,则返回错误

static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
                                  const char *filename, int flags,
                                  const AVIOInterruptCB *int_cb)
{
    URLContext *uc;
    int err;
	// flag中包含NETWORK,但是网络初始化模块失败,则返回错误
#if CONFIG_NETWORK
    if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())
        return AVERROR(EIO);
#endif
	// flag中包含AVIO_FLAG_READ,但是不包含url_read,则输出错误
    if ((flags & AVIO_FLAG_READ) && !up->url_read) {
        av_log(NULL, AV_LOG_ERROR,
               "Impossible to open the '%s' protocol for reading\n", up->name);
        return AVERROR(EIO);
    }
    // flag中包含AVIO_FALG_WRITE,但是不包含url_write,则输出错误
    if ((flags & AVIO_FLAG_WRITE) && !up->url_write) {
        av_log(NULL, AV_LOG_ERROR,
               "Impossible to open the '%s' protocol for writing\n", up->name);
        return AVERROR(EIO);
    }
   	// 前续检查结束,创建结构体,并且进行初始化赋值
    uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);
    if (!uc) {
        err = AVERROR(ENOMEM);
        goto fail;
    }
    uc->av_class = &url_context_class;
    uc->filename = (char *)&uc[1];
    strcpy(uc->filename, filename);
    uc->prot            = up;
    uc->flags           = flags;
    uc->is_streamed     = 0; /* default = not streamed */
    uc->max_packet_size = 0; /* default: stream file */
    if (up->priv_data_size) {
        uc->priv_data = av_mallocz(up->priv_data_size);
        if (!uc->priv_data) {
            err = AVERROR(ENOMEM);
            goto fail;
        }
        if (up->priv_data_class) {
            char *start;
            *(const AVClass **)uc->priv_data = up->priv_data_class;
            av_opt_set_defaults(uc->priv_data);
            if (av_strstart(uc->filename, up->name, (const char**)&start) && *start == ',') {
                int ret= 0;
                char *p= start;
                char sep= *++p;
                char *key, *val;
                p++;

                if (strcmp(up->name, "subfile"))
                    ret = AVERROR(EINVAL);

                while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){
                    *val= *key= 0;
                    ret = av_opt_set(uc->priv_data, p, key+1, 0);
                    if (ret == AVERROR_OPTION_NOT_FOUND)
                        av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", p);
                    *val= *key= sep;
                    p= val+1;
                }
                if(ret<0 || p!=key){
                    av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", start);
                    err = AVERROR(EINVAL);
                    goto fail;
                }
                memmove(start, key+1, strlen(key));
            }
        }
    }
    if (int_cb)
        uc->interrupt_callback = *int_cb;

    *puc = uc;
    return 0;
fail:
    *puc = NULL;
    if (uc)
        av_freep(&uc->priv_data);
    av_freep(&uc);
#if CONFIG_NETWORK
    if (up->flags & URL_PROTOCOL_FLAG_NETWORK)
        ff_network_close();
#endif
    return err;
}

1.1.2 打开URLContext(ffurl_connect)

函数的主要功能是打开前面创建的URLContext,首先检查前面创建的URLContext是否被正确初始化,然后调用url_open打开URL

int ffurl_connect(URLContext *uc, AVDictionary **options)
{
    int err;
    AVDictionary *tmp_opts = NULL;
    AVDictionaryEntry *e;

    if (!options)
        options = &tmp_opts;

    // Check that URLContext was initialized correctly and lists are matching if set
    // 检查URLContext被正确的初始化
    // 如果设置了黑白名单需要检查URLContext是否符合要求
    av_assert0(!(e=av_dict_get(*options, "protocol_whitelist", NULL, 0)) ||
               (uc->protocol_whitelist && !strcmp(uc->protocol_whitelist, e->value)));
    av_assert0(!(e=av_dict_get(*options, "protocol_blacklist", NULL, 0)) ||
               (uc->protocol_blacklist && !strcmp(uc->protocol_blacklist, e->value)));

    if (uc->protocol_whitelist && av_match_list(uc->prot->name, uc->protocol_whitelist, ',') <= 0) {
        av_log(uc, AV_LOG_ERROR, "Protocol '%s' not on whitelist '%s'!\n", uc->prot->name, uc->protocol_whitelist);
        return AVERROR(EINVAL);
    }

    if (uc->protocol_blacklist && av_match_list(uc->prot->name, uc->protocol_blacklist, ',') > 0) {
        av_log(uc, AV_LOG_ERROR, "Protocol '%s' on blacklist '%s'!\n", uc->prot->name, uc->protocol_blacklist);
        return AVERROR(EINVAL);
    }

    if (!uc->protocol_whitelist && uc->prot->default_whitelist) {
        av_log(uc, AV_LOG_DEBUG, "Setting default whitelist '%s'\n", uc->prot->default_whitelist);
        uc->protocol_whitelist = av_strdup(uc->prot->default_whitelist);
        if (!uc->protocol_whitelist) {
            return AVERROR(ENOMEM);
        }
    } else if (!uc->protocol_whitelist)
        av_log(uc, AV_LOG_DEBUG, "No default whitelist set\n"); // This should be an error once all declare a default whitelist

    if ((err = av_dict_set(options, "protocol_whitelist", uc->protocol_whitelist, 0)) < 0)
        return err;
    if ((err = av_dict_set(options, "protocol_blacklist", uc->protocol_blacklist, 0)) < 0)
        return err;
	// 使用url_open2或者url_open
	// 对于协议例如file,ftp,rtp,tcp,libRTMP等,使用的是url_open
	// 对于http协议,使用的是url_open2
	// 如果是file,url_open会链接到ftp_open()
	// 如果是libRTMP,url_open会链接到rtmp_open()
    err =
        uc->prot->url_open2 ? uc->prot->url_open2(uc,
                                                  uc->filename,
                                                  uc->flags,
                                                  options) :
        uc->prot->url_open(uc, uc->filename, uc->flags);

    av_dict_set(options, "protocol_whitelist", NULL, 0);
    av_dict_set(options, "protocol_blacklist", NULL, 0);

    if (err)
        return err;
    uc->is_connected = 1;
    /* We must be careful here as ffurl_seek() could be slow,
     * for example for http */
    if ((uc->flags & AVIO_FLAG_WRITE) || !strcmp(uc->prot->name, "file"))
        if (!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0)
            uc->is_streamed = 1;
    return 0;
}

例如协议的格式为ftp,会调用ftp_open,定义如下;会调用ftp_connect实现ftp连接的打开

static int ftp_open(URLContext *h, const char *url, int flags)
{
    FTPContext *s = h->priv_data;
    int err;

    ff_dlog(h, "ftp protocol open\n");

    if ((err = ftp_connect(h, url)) < 0)
        goto fail;

    if (ftp_restart(s, 0) < 0) {
        h->is_streamed = 1;
    } else {
        ftp_file_size(s);
        if (s->write_seekable != 1 && flags & AVIO_FLAG_WRITE)
            h->is_streamed = 1;
    }

    return 0;

  fail:
    av_log(h, AV_LOG_ERROR, "FTP open failed\n");
    ftp_close(h);
    return err;
}

1.2 根据创建的URLContext初始化AVIOContext(ffio_fdopen)

/**
 * Create and initialize a AVIOContext for accessing the
 * resource referenced by the URLContext h.
 * @note When the URLContext h has been opened in read+write mode, the
 * AVIOContext can be used only for writing.
 *
 * @param s Used to return the pointer to the created AVIOContext.
 * In case of failure the pointed to value is set to NULL.
 * @return >= 0 in case of success, a negative value corresponding to an
 * AVERROR code in case of failure
 */
// 创建并初始化一个AVIOContext,用于访问URLContext引用的资源
// @note 如果URLContext已经以read + write模式打开,那么AVIOContext只能被用于writing
int ffio_fdopen(AVIOContext **sp, URLContext *h)
{
    AVIOContext *s;
    uint8_t *buffer = NULL;
    int buffer_size, max_packet_size;
	// 首先初始化AVIOContext当中的buffer,如果前面配置max_packet_size,则将其配置为buffer_size
	// 否则将buffer_size配置为IO_BUFFER_SIZE=32768
    max_packet_size = h->max_packet_size;
    if (max_packet_size) {
    	// buffer_size不必超过packet最大size,因为最多填充一个packet即可
        buffer_size = max_packet_size; /* no need to bufferize more than one packet */
    } else {
        buffer_size = IO_BUFFER_SIZE;
    }
    if (!(h->flags & AVIO_FLAG_WRITE) && h->is_streamed) {
        if (buffer_size > INT_MAX/2)
            return AVERROR(EINVAL);
        buffer_size *= 2;
    }
    buffer = av_malloc(buffer_size);
    if (!buffer)
        return AVERROR(ENOMEM);
	// 创建AVIOContext
    *sp = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,
                             ffurl_read2, ffurl_write2, ffurl_seek2);
    if (!*sp) {
        av_freep(&buffer);
        return AVERROR(ENOMEM);
    }
    s = *sp;
    if (h->protocol_whitelist) {
        s->protocol_whitelist = av_strdup(h->protocol_whitelist);
        if (!s->protocol_whitelist) {
            avio_closep(sp);
            return AVERROR(ENOMEM);
        }
    }
    if (h->protocol_blacklist) {
        s->protocol_blacklist = av_strdup(h->protocol_blacklist);
        if (!s->protocol_blacklist) {
            avio_closep(sp);
            return AVERROR(ENOMEM);
        }
    }
    s->direct = h->flags & AVIO_FLAG_DIRECT;

    s->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
    s->max_packet_size = max_packet_size;
    s->min_packet_size = h->min_packet_size;
    if(h->prot) {
        s->read_pause = h->prot->url_read_pause;
        s->read_seek  = h->prot->url_read_seek;

        if (h->prot->url_read_seek)
            s->seekable |= AVIO_SEEKABLE_TIME;
    }
    ((FFIOContext*)s)->short_seek_get = ffurl_get_short_seek;
    s->av_class = &ff_avio_class;
    return 0;
}

1.2.1 创建AVIOContext(avio_alloc_context)

该函数首先使用av_malloc创建FFIOContext,随后通过调用ffio_init_context来初始化,这里做了一个封装,先通过初始化FFIOContext,随后返回FFIOContext之中的AVIOContext

AVIOContext *avio_alloc_context(
                  unsigned char *buffer,
                  int buffer_size,
                  int write_flag,
                  void *opaque,
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
                  int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size),
                  int64_t (*seek)(void *opaque, int64_t offset, int whence))
{
    FFIOContext *s = av_malloc(sizeof(*s));
    if (!s)
        return NULL;
    ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
                  read_packet, write_packet, seek);
    return &s->pub;
}

ffio_init_context的初始化操作为

void ffio_init_context(FFIOContext *ctx,
                  unsigned char *buffer,
                  int buffer_size,
                  int write_flag,
                  void *opaque,
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
                  int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size),
                  int64_t (*seek)(void *opaque, int64_t offset, int whence))
{
    AVIOContext *const s = &ctx->pub;

    memset(ctx, 0, sizeof(*ctx));

    s->buffer      = buffer;
    ctx->orig_buffer_size =
    s->buffer_size = buffer_size;
    s->buf_ptr     = buffer;
    s->buf_ptr_max = buffer;
    s->opaque      = opaque;
    s->direct      = 0;

    url_resetbuf(s, write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ);

    s->write_packet    = write_packet;
    s->read_packet     = read_packet;
    s->seek            = seek;
    s->pos             = 0;
    s->eof_reached     = 0;
    s->error           = 0;
    s->seekable        = seek ? AVIO_SEEKABLE_NORMAL : 0;
    s->min_packet_size = 0;
    s->max_packet_size = 0;
    s->update_checksum = NULL;
    ctx->short_seek_threshold = SHORT_SEEK_THRESHOLD;

    if (!read_packet && !write_flag) {
        s->pos     = buffer_size;
        s->buf_end = s->buffer + buffer_size;
    }
    s->read_pause = NULL;
    s->read_seek  = NULL;

    s->write_data_type       = NULL;
    s->ignore_boundary_point = 0;
    ctx->current_type        = AVIO_DATA_MARKER_UNKNOWN;
    ctx->last_time           = AV_NOPTS_VALUE;
    ctx->short_seek_get      = NULL;
}

2.小结

avio_open2函数用于为指定的URL创建一个URLContext,并且打开它,随后基于这个URLContext创建一个AVIOContext,从而实现对数据源的控制。在AVIOContext中,可以使用read_packet和write_packet进行packet读写操作,在URLProtocol中,可以使用url_read和url_write从protocol中读写数据。

因为还不是很理解协议层procotol的内容,下面是从别的地方看来的对于read_packet和url_read的理解
url_read和read_packet都是用于读取数据的函数,但实现方式和应用场景有所不同:
(1)url_read
主要用于从网络URL中读取数据。在实际应用中,可能会涉及到更复杂的网络协议,如http和rtmp。例如librtmp库中的RTMP packet结构就复杂处理发送和接收过程中的协议解析、分包、合包等复杂逻辑
(2)read_packet
主要用于从数据流当中读取特定格式的数据包。在FFmpeg中,av_read_frame()函数就是用来读取AVPacket的。这种情况下,数据处理可能会涉及更加复杂的数据流处理,如解码、过滤等

CSDN : https://blog.csdn.net/weixin_42877471
Github : https://github.com/DoFulangChen

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/750623.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【工程实践】MQ中rebalance机制

问题起因&#xff0c;有些分区积压严重&#xff0c;有些分区又是空闲。之前了解过rebalance机制&#xff0c;想知道在这种情况下rebalance机制为什么不触发&#xff0c;从而将积压的数据匀给空闲的分区。 问了gpt&#xff0c;“mq的rebalance功能能否保证每个分区在同一时间段…

AL8807是一款降压型DC/DC转换器,旨在以恒定电流驱动LED,可串联驱动多达9个LED,从6V至36V的电压源

一般描述 AL8807是一款降压型DC/DC转换器&#xff0c;旨在以恒定电流驱动LED。根据LED的正向电压&#xff0c;该设备可串联驱动多达9个LED&#xff0c;从6V至36V的电压源。LED的串联连接提供相同的LED电流&#xff0c;从而实现均匀的亮度&#xff0c;并消除了对镇流电阻…

国产CPU兆芯发展分析

国产信创CPU-兆芯CPU CPU&#xff1a;信创根基&#xff0c;国之重器 国产CPU已形成自主架构、x86、ARM三大阵营。自主架构以龙芯、申威的LoongArch、SW-64为代表&#xff1b;ARM阵营由鲲鹏、飞腾领军&#xff0c;依托ARM授权开发处理器&#xff1b;x86阵营则以海光、兆芯等品牌…

3d合并模型一直加载有哪些原因---模大狮模型网

当在3D软件中合并3d模型时&#xff0c;可能会遇到加载时间过长或持续加载的情况。这可能是由以下原因之一引起的&#xff1a; 一&#xff1a;模型复杂度 合并的模型可能非常复杂&#xff0c;包含大量的面片、顶点或纹理等。这会增加加载和处理的时间。解决方法是优化模型&…

数据结构与算法笔记:高级篇 - 最短路径:地图软件是如何计算出最优出行路径的?

概述 基础篇的时候&#xff0c;我们学习了图的两种搜索算法&#xff0c;深度优先搜索和广度优先搜索。这两种算法主要是针对无权图的搜索算法。针对有权图&#xff0c;也就是图中的每一条变都有一个权重&#xff0c;我们该如何计算两点之间的最短路径&#xff08;经过的边的权…

微软发布Phi-3系列语言模型:手机端的强大AI助手

大模型&#xff08;LLMs&#xff09;在处理复杂任务时展现出的巨大潜力&#xff0c;但却需要庞大的计算资源和存储空间&#xff0c;限制了它们在移动设备等资源受限环境中的应用。微软公司最新发布的Phi-3系列语言模型&#xff0c;以其卓越的性能和小巧的体积&#xff0c;打破了…

使用 privacyIDEA 实现 Windows RDP 多因素认证 (MFA)

前言 在等保 2.0 标准中有要求: d&#xff09;应采用口令、密码技术、生物技术等两种或两种以上组合的鉴别技术对用户进行身份鉴别&#xff0c;且其中一种鉴别技术至少应使用密码技术来实现。 可以借助开源的 privacyIDEA 配合 AD 域环境实现 RDP MFA 认证登录以满足上面的要…

Ubuntu 之Glade图形化设计器

演示环境说明&#xff1a;本机使用Windows 11 家庭版本搭载 Ubuntu 22.04.4 LTS 子系统&#xff0c;同时并安装Ubuntu桌面虚拟化软件XLaunch。 如果没有搭建好上述问题&#xff0c;请参考&#xff1a;windows11子系统Ubuntu 22.04.4子安装图形化界面 Glade是什么&#xff1f;…

【MySQL备份】lvm-snapshot篇

目录 1.简介 1.1.如何工作 1.2.应用场景 1.3.注意事项 1.4.优缺点 2.为什么选择lvm快照备份&#xff1f; 3.创建LVM 3.1.操作流程 3.2.正常安装MySQL后进行备份 3.3.MySQL运行一段时间后进行备份 3.3.1.准备lvm及文件系统//先添加一块磁盘 3.3.2.将数据迁移到LVM …

jmeter之接口数据与数据库数据检验!

前言 本文讲解使用jmeter测试接口&#xff0c;然后与数据库里面的数据进行校验对比。本节使用一个新增数据的接口&#xff0c;新增一条数据&#xff0c;然后在数据库里面进行查询&#xff0c;是否能够查询到此条数据。 一、接口环境搭建 1.1 新建一个http请求&#xff0c;写…

ARM32开发-fat_fs文件系统

FAT_FS 文件系统 FAT (File Allocation Table) 文件系统是一种广泛使用的基于磁盘的文件系统,尤其适用于小型嵌入式系统和存储卡。FAT_FS 就是一个专门针对 FAT 文件系统的开源实现。 FAT_FS 的主要特点 轻量级和高度可移植: FAT_FS 是一个非常轻量级的文件系统实现,占用资源少…

html5 video去除边框

video的属性&#xff1a; autoplay 视频在就绪后自动播放。 controls 显示控件&#xff0c;比如播放按钮。 height 设置视频播放器的高度。 width 设置视频播放器的宽度。 loop 循环播放 muted 视频的音频输出静音。 poster 视频加载时显示的图像&#xff0c;或者在用户点击播…

虚拟机的NAT模式连不上互联网

标题 虚拟机的NAT模式连不上互联网相关设备情况。我遇到了啥问题解决办法最后说一句 虚拟机的NAT模式连不上互联网 今天遇到了一个网络连接问题&#xff0c;是关于虚拟机的NAT模式上网的。 相关设备情况。 虚拟机上用到操作系统是centos7。宿主机的操作系统是windows10。虚拟…

mac14.1.2 M1芯片终端使用brew命令提示“zsh- command not found- brew ”解决方案

mac14.1.2 M1芯片终端使用brew命令提示“zsh- command not found- brew ” 原因&#xff1a;brew默认安装目录在/opt/homebrew/bin&#xff0c;zshrc文件中找不到对应的PATH路径导致。&#xff08;可通过右键finder的图标选择「前往文件”-输入/opt/homebrew/bin」来查看brew是…

防火墙双双机热备

设备直路部署&#xff0c;上下行连接交换机 如 图所示&#xff0c;DeviceA和DeviceB的业务接口都工作在三层&#xff0c;上下行分别连接二层交换机。上行交换机连接运营商的接入点&#xff0c;运营商为企业分配的IP地址为1.1.1.3和1.1.1.4。现在希望DeviceA和DeviceB以负载分担…

nodejs安装(2024最最最最新版)

node官网 Index of /dist/https://nodejs.org/dist/ 选择版本 我比较喜欢16.20.1或者是14.16.1,这两个版本简直天下无敌了 下一步 选择这个,下载下来一个文件 一直点击下一步,就安装成功了 可能遇见的问题 1.安装了node,为什么不生效还是以前自己电脑安装的版本? 答: 可…

vue2中的组件自定义事件

1.绑定事件: <组件 :自定义名称"方法" /> 2.调用 this.$emit(方法,参数) 3.关闭 this.$off(方法) 案例: 1.提前准备好组件 Student组件 <template><div class"student"><h1>学校名称:{{ st…

Golang 百题(实战快速掌握语法)_2

返回集合中满足指定条件的最后一个元素 本实验将实现判断给定集合中的元素是否符合&#xff0c;并返回符合的最后一个元素。 知识点 forfmt.Error 适合人群 本课程属于基础课程。需要用户掌握 Go 语言编程基础知识、计算机基础知识和 Linux 环境的基本用法。 许可证 内容…

windows安装nvm

文章目录 前言一、NVM下载方式一&#xff1a;官网下载方式二&#xff1a;GitHub 下载 二、NVM安装三、Node安装四、配置 NVM 和 NodeJS4.1. 环境变量配置4.2 配置node_global和node_cache 前言 NVM&#xff08;Node Version Manager&#xff09;是一个命令行工具&#xff0c;用…

Redis队列自研组件

背景 年初的时候设计实践过一个课题&#xff1a;SpringBootRedis实现不重复消费的队列&#xff0c;并用它开发了一个年夜饭下单和制作的服务。不知道大家还有没有印象。完成这个课题后&#xff0c;我兴致勃勃的把它运用到了项目里面&#xff0c;可谁曾想&#xff0c;运行不久后…