中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

彩票網(wǎng)站開發(fā)風險中美關系最新消息

彩票網(wǎng)站開發(fā)風險,中美關系最新消息,網(wǎng)站開發(fā)畢業(yè)論文指導教師意見,接做網(wǎng)站的項目try_decode_video_frame /*** 嘗試解碼視頻幀** param codec_ctx 解碼器上下文* param pkt 待解碼的視頻數(shù)據(jù)包* param decode 是否解碼標志,如果為1,則進行解碼,如果為0,則不解碼* return 返回0表示成功,否則表示出錯…

try_decode_video_frame

/*** 嘗試解碼視頻幀** @param codec_ctx 解碼器上下文* @param pkt 待解碼的視頻數(shù)據(jù)包* @param decode 是否解碼標志,如果為1,則進行解碼,如果為0,則不解碼* @return 返回0表示成功,否則表示出錯*/
static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket *pkt, int decode)
{int ret = 0;int got_frame = 0;AVFrame *frame = NULL;int skip_frame = codec_ctx->skip_frame;// 如果解碼器未打開,則打開解碼器if (!avcodec_is_open(codec_ctx)) {const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);ret = avcodec_open2(codec_ctx, codec, NULL);if (ret < 0) {av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");goto end;}}// 分配一個AVFrame結構體frame = av_frame_alloc();if (!frame) {av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");goto end;}// 如果不需要解碼,并且解碼器支持跳幀填充參數(shù),則將跳幀設置為AVDISCARD_ALLif (!decode && avpriv_codec_get_cap_skip_frame_fill_param(codec_ctx->codec)) {codec_ctx->skip_frame = AVDISCARD_ALL;}// 循環(huán)解碼視頻幀do {// 解碼視頻幀ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);av_assert0(decode || (!decode && !got_frame));if (ret < 0)break;pkt->data += ret;pkt->size -= ret;// 如果成功解碼到一幀視頻,則退出循環(huán)if (got_frame) {break;}} while (pkt->size > 0);end:// 恢復skip_frame的原始值codec_ctx->skip_frame = skip_frame;// 釋放AVFrame結構體av_frame_free(&frame);return ret;
}

find_video_stream_info

/*** 查找視頻流信息并嘗試解碼視頻幀** @param fmt_ctx AVFormatContext 結構體,表示輸入文件的格式上下文* @param decode 是否解碼標志,如果為 1,則進行解碼,如果為 0,則不解碼* @return 返回 0 表示成功,否則表示出錯*/
static int find_video_stream_info(AVFormatContext *fmt_ctx, int decode)
{int ret = 0;int i, done = 0;AVPacket pkt;// 初始化 AVPacket 結構體av_init_packet(&pkt);// 循環(huán)讀取視頻幀數(shù)據(jù),直到所有視頻流都有數(shù)據(jù)包while (!done) {AVCodecContext *codec_ctx = NULL;AVStream *st;// 從輸入文件中讀取視頻幀數(shù)據(jù)包if ((ret = av_read_frame(fmt_ctx, &pkt)) < 0) {av_log(fmt_ctx, AV_LOG_ERROR, "Failed to read frame\n");goto end;}// 獲取視頻流的解碼器上下文st = fmt_ctx->streams[pkt.stream_index];codec_ctx = st->codec;// 不是視頻流或已經(jīng)解碼過一幀視頻則跳過if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO ||st->codec_info_nb_frames++ > 0) {av_packet_unref(&pkt);continue;}// 嘗試解碼視頻幀ret = try_decode_video_frame(codec_ctx, &pkt, decode);if (ret < 0) {av_log(fmt_ctx, AV_LOG_ERROR, "Failed to decode video frame\n");goto end;}// 釋放 AVPacket 結構體av_packet_unref(&pkt);// 檢查是否所有視頻流都已經(jīng)解碼完畢done = 1;for (i = 0; i < fmt_ctx->nb_streams; i++) {st = fmt_ctx->streams[i];codec_ctx = st->codec;if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO)continue;done &= st->codec_info_nb_frames > 0;/*在 FFmpeg 的 AVCodecContext 結構體中,codec_info_nb_frames 是一個用于存儲編解碼器相關幀數(shù)量信息的成員變量。這個變量通常用于在編解碼過程中跟蹤已經(jīng)處理的幀數(shù)。在 FFmpeg 中,幀是視頻編碼的基本單位,而 codec_info_nb_frames 則是與當前編解碼器相關聯(lián)的幀的數(shù)量。
在代碼中,codec_info_nb_frames 被用作檢查視頻流是否已經(jīng)解碼完成的標志。通過檢查 codec_info_nb_frames 是否大于 0,可以判斷當前視頻流是否已經(jīng)解碼了至少一幀。這在處理視頻流時非常有用,因為它可以幫助確定是否還有待處理的幀數(shù)據(jù),或者是否已經(jīng)處理完所有的幀數(shù)據(jù)。
總之,codec_info_nb_frames 是一個用于存儲編解碼器相關幀數(shù)量信息的成員變量,它在 FFmpeg 中用于跟蹤已經(jīng)處理的幀數(shù),并在視頻編解碼過程中起到重要的作用。*/}}end:// 釋放 AVPacket 結構體av_packet_unref(&pkt);// 關閉所有在 try_decode_video_frame 中打開的解碼器for (i = 0; i < fmt_ctx->nb_streams; i++) {AVStream *st = fmt_ctx->streams[i];avcodec_close(st->codec);}// 返回解碼結果return ret < 0;
}
/*** 打印視頻流信息** @param fmt_ctx AVFormatContext 結構體,表示輸入文件的格式上下文* @param decode 是否解碼標志,如果為 1,則進行解碼,如果為 0,則不解碼*/
static void dump_video_streams(const AVFormatContext *fmt_ctx, int decode)
{int i;// 遍歷所有視頻流for (i = 0; i < fmt_ctx->nb_streams; i++) {const AVOption *opt = NULL;const AVStream *st = fmt_ctx->streams[i];AVCodecContext *codec_ctx = st->codec;// 打印視頻流的序號和解碼標志printf("stream=%d, decode=%d\n", i, decode);// 遍歷視頻流的所有選項while (opt = av_opt_next(codec_ctx, opt)) {uint8_t *str;// 跳過常量選項if (opt->type == AV_OPT_TYPE_CONST)continue;// 跳過幀數(shù)選項if (!strcmp(opt->name, "frame_number"))continue;// 獲取選項的值并打印if (av_opt_get(codec_ctx, opt->name, 0, &str) >= 0) {printf("    %s=%s\n", opt->name, str);av_free(str);}}}
}
/*** 打開輸入文件并嘗試解碼視頻流信息** @param fmt_ctx AVFormatContext 結構體指針的指針,用于存儲打開的輸入文件的格式上下文* @param filename 輸入文件名* @param decode 是否解碼標志,如果為 1,則進行解碼,如果為 0,則不解碼* @return 返回 0 表示成功,否則表示出錯*/
static int open_and_probe_video_streams(AVFormatContext **fmt_ctx, const char *filename, int decode)
{int ret = 0;// 打開輸入文件并讀取格式ret = avformat_open_input(fmt_ctx, filename, NULL, NULL);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "Failed to open input '%s'", filename);goto end;}// 獲取視頻流信息并嘗試解碼ret = find_video_stream_info(*fmt_ctx, decode);if (ret < 0) {goto end;}// 打印視頻流信息dump_video_streams(*fmt_ctx, decode);end:return ret;
}
/*** 檢查兩個格式上下文中的視頻流是否相同** @param fmt_ctx1 第一個輸入文件的格式上下文* @param fmt_ctx2 第二個輸入文件的格式上下文* @return 返回 0 表示視頻流相同,否則表示不同*/
static int check_video_streams(const AVFormatContext *fmt_ctx1, const AVFormatContext *fmt_ctx2)
{int i;int ret = 0;// 斷言兩個格式上下文中的視頻流數(shù)量相同av_assert0(fmt_ctx1->nb_streams == fmt_ctx2->nb_streams);// 遍歷每個視頻流for (i = 0; i < fmt_ctx1->nb_streams; i++) {const AVOption *opt = NULL;const AVStream *st1 = fmt_ctx1->streams[i];const AVStream *st2 = fmt_ctx2->streams[i];AVCodecContext *codec_ctx1 = st1->codec;AVCodecContext *codec_ctx2 = st2->codec;// 如果當前流不是視頻流,則跳過if (codec_ctx1->codec_type != AVMEDIA_TYPE_VIDEO)continue;// 遍歷視頻流的所有選項while (opt = av_opt_next(codec_ctx1, opt)) {uint8_t *str1 = NULL, *str2 = NULL;// 跳過常量選項if (opt->type == AV_OPT_TYPE_CONST)continue;// 跳過幀數(shù)選項if (!strcmp(opt->name, "frame_number"))continue;// 獲取第一個格式上下文中選項的值av_assert0(av_opt_get(codec_ctx1, opt->name, 0, &str1) >= 0);// 獲取第二個格式上下文中選項的值av_assert0(av_opt_get(codec_ctx2, opt->name, 0, &str2) >= 0);// 比較兩個值是否相同,如果不同則打印錯誤信息if (strcmp(str1, str2)) {av_log(NULL, AV_LOG_ERROR, "Field %s differs: %s %s", opt->name, str1, str2);ret = AVERROR(EINVAL);  // 設置返回值表示不同}// 釋放內(nèi)存av_free(str1);av_free(str2);}}// 返回比較結果return ret;
}
http://www.risenshineclean.com/news/8391.html

相關文章:

  • wordpress彈移動端seo關鍵詞優(yōu)化
  • app軟件系統(tǒng)定制開發(fā)網(wǎng)站內(nèi)部鏈接優(yōu)化方法
  • 南京核酸最新通知重慶網(wǎng)站seo公司
  • 做張家界旅游網(wǎng)站多少錢全網(wǎng)營銷有哪些平臺
  • 深圳app開發(fā)公司大概價格seo關鍵詞分析表
  • 游戲源代碼網(wǎng)站百度推廣電話號碼
  • 手機網(wǎng)站開發(fā)公司百度搜索引擎api
  • 自助網(wǎng)站模板平臺北大青鳥
  • asp網(wǎng)站banner修改市場營銷計劃方案
  • 建設 大型電子商務網(wǎng)站杭州seo靠譜
  • 商城網(wǎng)站建設外貿(mào)平臺排名
  • 湛江市政工程建設公司網(wǎng)站美食軟文300范例
  • b2c電子商務網(wǎng)站的特點及類型2020年關鍵詞排名
  • 阿里云做網(wǎng)站可以嗎寧波seo資源
  • 做網(wǎng)站的榮譽證書網(wǎng)絡營銷這個專業(yè)怎么樣
  • 幼兒園網(wǎng)站建設情況統(tǒng)計表西安優(yōu)化seo托管
  • 宿遷哪里做網(wǎng)站內(nèi)蒙古網(wǎng)站seo
  • 最權威的做網(wǎng)站設計公司價格搜索引擎營銷ppt
  • 鄭州網(wǎng)站seo分析湖南seo推廣系統(tǒng)
  • dede 汽車網(wǎng)站谷歌競價排名推廣公司
  • 東湖網(wǎng)站建設啥是網(wǎng)絡推廣
  • WordPress前端上傳大文件搜索引擎優(yōu)化seo名詞解釋
  • 做設計網(wǎng)站的工作百度快照優(yōu)化培訓班
  • 手機在線做ppt的網(wǎng)站有哪些最新的網(wǎng)絡營銷的案例
  • 做企業(yè)網(wǎng)站選百度云還是阿里云b2b網(wǎng)站推廣優(yōu)化
  • 成都營銷類網(wǎng)站設計如何優(yōu)化關鍵詞排名快速首頁
  • 免費自己生成網(wǎng)站泰安網(wǎng)絡推廣培訓
  • 網(wǎng)站網(wǎng)頁設計模板下載視頻seo優(yōu)化教程
  • 網(wǎng)站鏈接seo云優(yōu)化是什么意思
  • 如何在網(wǎng)上建立自己的網(wǎng)站torrentkitty搜索引擎