FFMPeg代码分析:AVPacket结构体和av_read_frame函数-程序员宅基地

技术标签: 图像与音视频  

转自:http://blog.csdn.net/shaqoneal/article/details/16960927

AVPacket结构用于保存压缩编码过的数据。在解码时,该结构的实例通常作为解复用器(demuxer)的输出并输入到解码器中;在编码时,通常是编码器的输出,并输入到复用器(muxer)中。该结构体的定义如下:

  1. typedef struct AVPacket {  
  2.     /** 
  3.      * A reference to the reference-counted buffer where the packet data is 
  4.      * stored. 
  5.      * May be NULL, then the packet data is not reference-counted. 
  6.      */  
  7.     AVBufferRef *buf;  
  8.     /** 
  9.      * Presentation timestamp in AVStream->time_base units; the time at which 
  10.      * the decompressed packet will be presented to the user. 
  11.      * Can be AV_NOPTS_VALUE if it is not stored in the file. 
  12.      * pts MUST be larger or equal to dts as presentation cannot happen before 
  13.      * decompression, unless one wants to view hex dumps. Some formats misuse 
  14.      * the terms dts and pts/cts to mean something different. Such timestamps 
  15.      * must be converted to true pts/dts before they are stored in AVPacket. 
  16.      */  
  17.     int64_t pts;//显示时间戳  
  18.     /** 
  19.      * Decompression timestamp in AVStream->time_base units; the time at which 
  20.      * the packet is decompressed. 
  21.      * Can be AV_NOPTS_VALUE if it is not stored in the file. 
  22.      */  
  23.     int64_t dts;//解码时间戳  
  24.     uint8_t *data;//实例所包含的压缩数据,直接获取该指针指向缓存的数据可以得到压缩过的码流;  
  25.     int   size;//原始压缩数据的大小  
  26.     int   stream_index;//标识当前AVPacket所从属的码流  
  27.     /** 
  28.      * A combination of AV_PKT_FLAG values 
  29.      */  
  30.     int   flags;  
  31.     /** 
  32.      * Additional packet data that can be provided by the container. 
  33.      * Packet can contain several types of side information. 
  34.      */  
  35.     struct {  
  36.         uint8_t *data;  
  37.         int      size;  
  38.         enum AVPacketSideDataType type;  
  39.     } *side_data;  
  40.     int side_data_elems;  
  41.   
  42.     /** 
  43.      * Duration of this packet in AVStream->time_base units, 0 if unknown. 
  44.      * Equals next_pts - this_pts in presentation order. 
  45.      */  
  46.     int   duration;  
  47. #if FF_API_DESTRUCT_PACKET  
  48.     attribute_deprecated  
  49.     void  (*destruct)(struct AVPacket *);  
  50.     attribute_deprecated  
  51.     void  *priv;  
  52. #endif  
  53.     int64_t pos;                            ///< byte position in stream, -1 if unknown  
  54.   
  55.     /** 
  56.      * Time difference in AVStream->time_base units from the pts of this 
  57.      * packet to the point at which the output from the decoder has converged 
  58.      * independent from the availability of previous frames. That is, the 
  59.      * frames are virtually identical no matter if decoding started from 
  60.      * the very first frame or from this keyframe. 
  61.      * Is AV_NOPTS_VALUE if unknown. 
  62.      * This field is not the display duration of the current packet. 
  63.      * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY 
  64.      * set. 
  65.      * 
  66.      * The purpose of this field is to allow seeking in streams that have no 
  67.      * keyframes in the conventional sense. It corresponds to the 
  68.      * recovery point SEI in H.264 and match_time_delta in NUT. It is also 
  69.      * essential for some types of subtitle streams to ensure that all 
  70.      * subtitles are correctly displayed after seeking. 
  71.      */  
  72.     int64_t convergence_duration;  
  73. } AVPacket;  
在demo中,调用了av_read_frame(pFormatCtx, &packet)函数从pFormatCtx所指向的环境的文件中读取压缩码流数据,保存到AVPacket实例packet中。av_read_frame()函数实现如下所示:
  1. int av_read_frame(AVFormatContext *s, AVPacket *pkt)  
  2. {  
  3.     const int genpts = s->flags & AVFMT_FLAG_GENPTS;  
  4.     int          eof = 0;  
  5.     int ret;  
  6.     AVStream *st;  
  7.   
  8.     if (!genpts) {  
  9.         ret = s->packet_buffer ?  
  10.             read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt) :  
  11.             read_frame_internal(s, pkt);  
  12.         if (ret < 0)  
  13.             return ret;  
  14.         goto return_packet;  
  15.     }  
  16.   
  17.     for (;;) {  
  18.         AVPacketList *pktl = s->packet_buffer;  
  19.   
  20.         if (pktl) {  
  21.             AVPacket *next_pkt = &pktl->pkt;  
  22.   
  23.             if (next_pkt->dts != AV_NOPTS_VALUE) {  
  24.                 int wrap_bits = s->streams[next_pkt->stream_index]->pts_wrap_bits;  
  25.                 // last dts seen for this stream. if any of packets following  
  26.                 // current one had no dts, we will set this to AV_NOPTS_VALUE.  
  27.                 int64_t last_dts = next_pkt->dts;  
  28.                 while (pktl && next_pkt->pts == AV_NOPTS_VALUE) {  
  29.                     if (pktl->pkt.stream_index == next_pkt->stream_index &&  
  30.                         (av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << (wrap_bits - 1)) < 0)) {  
  31.                         if (av_compare_mod(pktl->pkt.pts, pktl->pkt.dts, 2LL << (wrap_bits - 1))) { //not b frame  
  32.                             next_pkt->pts = pktl->pkt.dts;  
  33.                         }  
  34.                         if (last_dts != AV_NOPTS_VALUE) {  
  35.                             // Once last dts was set to AV_NOPTS_VALUE, we don't change it.  
  36.                             last_dts = pktl->pkt.dts;  
  37.                         }  
  38.                     }  
  39.                     pktl = pktl->next;  
  40.                 }  
  41.                 if (eof && next_pkt->pts == AV_NOPTS_VALUE && last_dts != AV_NOPTS_VALUE) {  
  42.                     // Fixing the last reference frame had none pts issue (For MXF etc).  
  43.                     // We only do this when  
  44.                     // 1. eof.  
  45.                     // 2. we are not able to resolve a pts value for current packet.  
  46.                     // 3. the packets for this stream at the end of the files had valid dts.  
  47.                     next_pkt->pts = last_dts + next_pkt->duration;  
  48.                 }  
  49.                 pktl = s->packet_buffer;  
  50.             }  
  51.   
  52.             /* read packet from packet buffer, if there is data */  
  53.             if (!(next_pkt->pts == AV_NOPTS_VALUE &&  
  54.                   next_pkt->dts != AV_NOPTS_VALUE && !eof)) {  
  55.                 ret = read_from_packet_buffer(&s->packet_buffer,  
  56.                                                &s->packet_buffer_end, pkt);  
  57.                 goto return_packet;  
  58.             }  
  59.         }  
  60.   
  61.         ret = read_frame_internal(s, pkt);  
  62.         if (ret < 0) {  
  63.             if (pktl && ret != AVERROR(EAGAIN)) {  
  64.                 eof = 1;  
  65.                 continue;  
  66.             } else  
  67.                 return ret;  
  68.         }  
  69.   
  70.         if (av_dup_packet(add_to_pktbuf(&s->packet_buffer, pkt,  
  71.                           &s->packet_buffer_end)) < 0)  
  72.             return AVERROR(ENOMEM);  
  73.     }  
  74.   
  75. return_packet:  
  76.   
  77.     st = s->streams[pkt->stream_index];  
  78.     if (st->skip_samples) {  
  79.         uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10);  
  80.         if (p) {  
  81.             AV_WL32(p, st->skip_samples);  
  82.             av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d\n", st->skip_samples);  
  83.         }  
  84.         st->skip_samples = 0;  
  85.     }  
  86.   
  87.     if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY) {  
  88.         ff_reduce_index(s, st->index);  
  89.         av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME);  
  90.     }  
  91.   
  92.     if (is_relative(pkt->dts))  
  93.         pkt->dts -= RELATIVE_TS_BASE;  
  94.     if (is_relative(pkt->pts))  
  95.         pkt->pts -= RELATIVE_TS_BASE;  
  96.   
  97.     return ret;  

上文中贴出了av_read_frame()函数的实现,现在更细致地分析一下其内部的实现流程。

av_read_frame()开始后,通常会调用read_frame_internal(s, pkt)函数:

  1. static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)  
  2. {  
  3.     int ret = 0, i, got_packet = 0;  
  4.   
  5.     av_init_packet(pkt);  
  6.   
  7.     while (!got_packet && !s->parse_queue) {  
  8.         AVStream *st;  
  9.         AVPacket cur_pkt;  
  10.   
  11.         /* read next packet */  
  12.         ret = ff_read_packet(s, &cur_pkt);  
  13.         if (ret < 0) {  
  14.             if (ret == AVERROR(EAGAIN))  
  15.                 return ret;  
  16.             /* flush the parsers */  
  17.             for(i = 0; i < s->nb_streams; i++) {  
  18.                 st = s->streams[i];  
  19.                 if (st->parser && st->need_parsing)  
  20.                     parse_packet(s, NULL, st->index);  
  21.             }  
  22.             /* all remaining packets are now in parse_queue => 
  23.              * really terminate parsing */  
  24.             break;  
  25.         }  
  26.         ret = 0;  
  27.         st  = s->streams[cur_pkt.stream_index];  
  28.   
  29.         if (cur_pkt.pts != AV_NOPTS_VALUE &&  
  30.             cur_pkt.dts != AV_NOPTS_VALUE &&  
  31.             cur_pkt.pts < cur_pkt.dts) {  
  32.             av_log(s, AV_LOG_WARNING, "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",  
  33.                    cur_pkt.stream_index,  
  34.                    av_ts2str(cur_pkt.pts),  
  35.                    av_ts2str(cur_pkt.dts),  
  36.                    cur_pkt.size);  
  37.         }  
  38.         if (s->debug & FF_FDEBUG_TS)  
  39.             av_log(s, AV_LOG_DEBUG, "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",  
  40.                    cur_pkt.stream_index,  
  41.                    av_ts2str(cur_pkt.pts),  
  42.                    av_ts2str(cur_pkt.dts),  
  43.                    cur_pkt.size,  
  44.                    cur_pkt.duration,  
  45.                    cur_pkt.flags);  
  46.   
  47.         if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {  
  48.             st->parser = av_parser_init(st->codec->codec_id);  
  49.             if (!st->parser) {  
  50.                 av_log(s, AV_LOG_VERBOSE, "parser not found for codec "  
  51.                        "%s, packets or times may be invalid.\n",  
  52.                        avcodec_get_name(st->codec->codec_id));  
  53.                 /* no parser available: just output the raw packets */  
  54.                 st->need_parsing = AVSTREAM_PARSE_NONE;  
  55.             } else if(st->need_parsing == AVSTREAM_PARSE_HEADERS) {  
  56.                 st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;  
  57.             } else if(st->need_parsing == AVSTREAM_PARSE_FULL_ONCE) {  
  58.                 st->parser->flags |= PARSER_FLAG_ONCE;  
  59.             } else if(st->need_parsing == AVSTREAM_PARSE_FULL_RAW) {  
  60.                 st->parser->flags |= PARSER_FLAG_USE_CODEC_TS;  
  61.             }  
  62.         }  
  63.   
  64.         if (!st->need_parsing || !st->parser) {  
  65.             /* no parsing needed: we just output the packet as is */  
  66.             *pkt = cur_pkt;  
  67.             compute_pkt_fields(s, st, NULL, pkt);  
  68.             if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&  
  69.                 (pkt->flags & AV_PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) {  
  70.                 ff_reduce_index(s, st->index);  
  71.                 av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME);  
  72.             }  
  73.             got_packet = 1;  
  74.         } else if (st->discard < AVDISCARD_ALL) {  
  75.             if ((ret = parse_packet(s, &cur_pkt, cur_pkt.stream_index)) < 0)  
  76.                 return ret;  
  77.         } else {  
  78.             /* free packet */  
  79.             av_free_packet(&cur_pkt);  
  80.         }  
  81.         if (pkt->flags & AV_PKT_FLAG_KEY)  
  82.             st->skip_to_keyframe = 0;  
  83.         if (st->skip_to_keyframe) {  
  84.             av_free_packet(&cur_pkt);  
  85.             if (got_packet) {  
  86.                 *pkt = cur_pkt;  
  87.             }  
  88.             got_packet = 0;  
  89.         }  
  90.     }  
  91.   
  92.     if (!got_packet && s->parse_queue)  
  93.         ret = read_from_packet_buffer(&s->parse_queue, &s->parse_queue_end, pkt);  
  94.   
  95.     if(s->debug & FF_FDEBUG_TS)  
  96.         av_log(s, AV_LOG_DEBUG, "read_frame_internal stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",  
  97.             pkt->stream_index,  
  98.             av_ts2str(pkt->pts),  
  99.             av_ts2str(pkt->dts),  
  100.             pkt->size,  
  101.             pkt->duration,  
  102.             pkt->flags);  
  103.   
  104.     return ret;  
  105. }  
首先调用av_init_packet(pkt)对pkt进行初始化:
  1. void av_init_packet(AVPacket *pkt)  
  2. {  
  3.     pkt->pts                  = AV_NOPTS_VALUE;  
  4.     pkt->dts                  = AV_NOPTS_VALUE;  
  5.     pkt->pos                  = -1;  
  6.     pkt->duration             = 0;  
  7.     pkt->convergence_duration = 0;  
  8.     pkt->flags                = 0;  
  9.     pkt->stream_index         = 0;  
  10. #if FF_API_DESTRUCT_PACKET  
  11. FF_DISABLE_DEPRECATION_WARNINGS  
  12.     pkt->destruct             = NULL;  
  13. FF_ENABLE_DEPRECATION_WARNINGS  
  14. #endif  
  15.     pkt->buf                  = NULL;  
  16.     pkt->side_data            = NULL;  
  17.     pkt->side_data_elems      = 0;  
  18. }  
该函数将pts、dts设为AV_NOPTS_VALUE,将pos初始化为-1,将其他参数设为0或空值;随后在一个while循环中,调用ff_read_packet函数读取数据:
  1. int ff_read_packet(AVFormatContext *s, AVPacket *pkt)  
  2. {  
  3.     int ret, i, err;  
  4.     AVStream *st;  
  5.   
  6.     for(;;){  
  7.         AVPacketList *pktl = s->raw_packet_buffer;  
  8.   
  9.         if (pktl) {  
  10.             *pkt = pktl->pkt;  
  11.             st = s->streams[pkt->stream_index];  
  12.             if (s->raw_packet_buffer_remaining_size <= 0) {  
  13.                 if ((err = probe_codec(s, st, NULL)) < 0)  
  14.                     return err;  
  15.             }  
  16.             if(st->request_probe <= 0){  
  17.                 s->raw_packet_buffer = pktl->next;  
  18.                 s->raw_packet_buffer_remaining_size += pkt->size;  
  19.                 av_free(pktl);  
  20.                 return 0;  
  21.             }  
  22.         }  
  23.   
  24.         pkt->data = NULL;  
  25.         pkt->size = 0;  
  26.         av_init_packet(pkt);  
  27.         ret= s->iformat->read_packet(s, pkt);  
  28.         if (ret < 0) {  
  29.             if (!pktl || ret == AVERROR(EAGAIN))  
  30.                 return ret;  
  31.             for (i = 0; i < s->nb_streams; i++) {  
  32.                 st = s->streams[i];  
  33.                 if (st->probe_packets) {  
  34.                     if ((err = probe_codec(s, st, NULL)) < 0)  
  35.                         return err;  
  36.                 }  
  37.                 av_assert0(st->request_probe <= 0);  
  38.             }  
  39.             continue;  
  40.         }  
  41.   
  42.         if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) &&  
  43.             (pkt->flags & AV_PKT_FLAG_CORRUPT)) {  
  44.             av_log(s, AV_LOG_WARNING,  
  45.                    "Dropped corrupted packet (stream = %d)\n",  
  46.                    pkt->stream_index);  
  47.             av_free_packet(pkt);  
  48.             continue;  
  49.         }  
  50.   
  51.         if(!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA))  
  52.             av_packet_merge_side_data(pkt);  
  53.   
  54.         if(pkt->stream_index >= (unsigned)s->nb_streams){  
  55.             av_log(s, AV_LOG_ERROR, "Invalid stream index %d\n", pkt->stream_index);  
  56.             continue;  
  57.         }  
  58.   
  59.         st= s->streams[pkt->stream_index];  
  60.         pkt->dts = wrap_timestamp(st, pkt->dts);  
  61.         pkt->pts = wrap_timestamp(st, pkt->pts);  
  62.   
  63.         force_codec_ids(s, st);  
  64.   
  65.         /* TODO: audio: time filter; video: frame reordering (pts != dts) */  
  66.         if (s->use_wallclock_as_timestamps)  
  67.             pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base);  
  68.   
  69.         if(!pktl && st->request_probe <= 0)  
  70.             return ret;  
  71.   
  72.         add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end);  
  73.         s->raw_packet_buffer_remaining_size -= pkt->size;  
  74.   
  75.         if ((err = probe_codec(s, st, pkt)) < 0)  
  76.             return err;  
  77.     }  
  78. }  
该函数从AVFormatContext指针格式的媒体文件句柄中读取待解码数据,并储存于AVPacket实例中。当读取成功时返回0,读取失败则返回AVERROR值。
该函数调用av_init_packet对参数pkg初始化,并调用iformat的方法read_packet读取数据。在本demo中,AVFormatContext实例中iformat成员为ff_mov_demuxer,如下所示:
  1. AVInputFormat ff_mov_demuxer = {  
  2.     .name           = "mov,mp4,m4a,3gp,3g2,mj2",  
  3.     .long_name      = NULL_IF_CONFIG_SMALL("QuickTime / MOV"),  
  4.     .priv_data_size = sizeof(MOVContext),  
  5.     .read_probe     = mov_probe,  
  6.     .read_header    = mov_read_header,  
  7.     .read_packet    = mov_read_packet,  
  8.     .read_close     = mov_read_close,  
  9.     .read_seek      = mov_read_seek,  
  10.     .priv_class     = &mov_class,  
  11.     .flags          = AVFMT_NO_BYTE_SEEK,  
  12. };  
其read_packet指针指向mov_read_packet函数,这个函数的内容也比较长,暂时就不贴了,有时间慢慢分析。
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/hjwang1/article/details/17956953

智能推荐

攻防世界_难度8_happy_puzzle_攻防世界困难模式攻略图文-程序员宅基地

文章浏览阅读645次。这个肯定是末尾的IDAT了,因为IDAT必须要满了才会开始一下个IDAT,这个明显就是末尾的IDAT了。,对应下面的create_head()代码。,对应下面的create_tail()代码。不要考虑爆破,我已经试了一下,太多情况了。题目来源:UNCTF。_攻防世界困难模式攻略图文

达梦数据库的导出(备份)、导入_达梦数据库导入导出-程序员宅基地

文章浏览阅读2.9k次,点赞3次,收藏10次。偶尔会用到,记录、分享。1. 数据库导出1.1 切换到dmdba用户su - dmdba1.2 进入达梦数据库安装路径的bin目录,执行导库操作  导出语句:./dexp cwy_init/[email protected]:5236 file=cwy_init.dmp log=cwy_init_exp.log 注释:   cwy_init/init_123..._达梦数据库导入导出

js引入kindeditor富文本编辑器的使用_kindeditor.js-程序员宅基地

文章浏览阅读1.9k次。1. 在官网上下载KindEditor文件,可以删掉不需要要到的jsp,asp,asp.net和php文件夹。接着把文件夹放到项目文件目录下。2. 修改html文件,在页面引入js文件:<script type="text/javascript" src="./kindeditor/kindeditor-all.js"></script><script type="text/javascript" src="./kindeditor/lang/zh-CN.js"_kindeditor.js

STM32学习过程记录11——基于STM32G431CBU6硬件SPI+DMA的高效WS2812B控制方法-程序员宅基地

文章浏览阅读2.3k次,点赞6次,收藏14次。SPI的详情简介不必赘述。假设我们通过SPI发送0xAA,我们的数据线就会变为10101010,通过修改不同的内容,即可修改SPI中0和1的持续时间。比如0xF0即为前半周期为高电平,后半周期为低电平的状态。在SPI的通信模式中,CPHA配置会影响该实验,下图展示了不同采样位置的SPI时序图[1]。CPOL = 0,CPHA = 1:CLK空闲状态 = 低电平,数据在下降沿采样,并在上升沿移出CPOL = 0,CPHA = 0:CLK空闲状态 = 低电平,数据在上升沿采样,并在下降沿移出。_stm32g431cbu6

计算机网络-数据链路层_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输-程序员宅基地

文章浏览阅读1.2k次,点赞2次,收藏8次。数据链路层习题自测问题1.数据链路(即逻辑链路)与链路(即物理链路)有何区别?“电路接通了”与”数据链路接通了”的区别何在?2.数据链路层中的链路控制包括哪些功能?试讨论数据链路层做成可靠的链路层有哪些优点和缺点。3.网络适配器的作用是什么?网络适配器工作在哪一层?4.数据链路层的三个基本问题(帧定界、透明传输和差错检测)为什么都必须加以解决?5.如果在数据链路层不进行帧定界,会发生什么问题?6.PPP协议的主要特点是什么?为什么PPP不使用帧的编号?PPP适用于什么情况?为什么PPP协议不_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输

软件测试工程师移民加拿大_无证移民,未受过软件工程师的教育(第1部分)-程序员宅基地

文章浏览阅读587次。软件测试工程师移民加拿大 无证移民,未受过软件工程师的教育(第1部分) (Undocumented Immigrant With No Education to Software Engineer(Part 1))Before I start, I want you to please bear with me on the way I write, I have very little gen...

随便推点

Thinkpad X250 secure boot failed 启动失败问题解决_安装完系统提示secureboot failure-程序员宅基地

文章浏览阅读304次。Thinkpad X250笔记本电脑,装的是FreeBSD,进入BIOS修改虚拟化配置(其后可能是误设置了安全开机),保存退出后系统无法启动,显示:secure boot failed ,把自己惊出一身冷汗,因为这台笔记本刚好还没开始做备份.....根据错误提示,到bios里面去找相关配置,在Security里面找到了Secure Boot选项,发现果然被设置为Enabled,将其修改为Disabled ,再开机,终于正常启动了。_安装完系统提示secureboot failure

C++如何做字符串分割(5种方法)_c++ 字符串分割-程序员宅基地

文章浏览阅读10w+次,点赞93次,收藏352次。1、用strtok函数进行字符串分割原型: char *strtok(char *str, const char *delim);功能:分解字符串为一组字符串。参数说明:str为要分解的字符串,delim为分隔符字符串。返回值:从str开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。其它:strtok函数线程不安全,可以使用strtok_r替代。示例://借助strtok实现split#include <string.h>#include <stdio.h&_c++ 字符串分割

2013第四届蓝桥杯 C/C++本科A组 真题答案解析_2013年第四届c a组蓝桥杯省赛真题解答-程序员宅基地

文章浏览阅读2.3k次。1 .高斯日记 大数学家高斯有个好习惯:无论如何都要记日记。他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢?高斯出生于:1777年4月30日。在高斯发现的一个重要定理的日记_2013年第四届c a组蓝桥杯省赛真题解答

基于供需算法优化的核极限学习机(KELM)分类算法-程序员宅基地

文章浏览阅读851次,点赞17次,收藏22次。摘要:本文利用供需算法对核极限学习机(KELM)进行优化,并用于分类。

metasploitable2渗透测试_metasploitable2怎么进入-程序员宅基地

文章浏览阅读1.1k次。一、系统弱密码登录1、在kali上执行命令行telnet 192.168.26.1292、Login和password都输入msfadmin3、登录成功,进入系统4、测试如下:二、MySQL弱密码登录:1、在kali上执行mysql –h 192.168.26.129 –u root2、登录成功,进入MySQL系统3、测试效果:三、PostgreSQL弱密码登录1、在Kali上执行psql -h 192.168.26.129 –U post..._metasploitable2怎么进入

Python学习之路:从入门到精通的指南_python人工智能开发从入门到精通pdf-程序员宅基地

文章浏览阅读257次。本文将为初学者提供Python学习的详细指南,从Python的历史、基础语法和数据类型到面向对象编程、模块和库的使用。通过本文,您将能够掌握Python编程的核心概念,为今后的编程学习和实践打下坚实基础。_python人工智能开发从入门到精通pdf

推荐文章

热门文章

相关标签