当前位置: 首页 > news >正文

王爷的心尖宠妃全文免费阅读企业网站排名优化

王爷的心尖宠妃全文免费阅读,企业网站排名优化,广州番禺天气,钦州房产网站建设要对H265文件进行编码和解码&#xff0c;需要使用FFmpeg库提供的相关API。以下是一个简单的C程序&#xff0c;演示如何使用FFmpeg进行H265文件的编码和解码&#xff1a; 编码&#xff1a; #include <cstdlib> #include <cstdio> #include <cstring> #inclu…

要对H265文件进行编码和解码,需要使用FFmpeg库提供的相关API。以下是一个简单的C++程序,演示如何使用FFmpeg进行H265文件的编码和解码:

编码:

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>extern "C" {
#include <libavutil/opt.h>
#include <libavcodec/avcodec.h>
}int main(int argc, char** argv) {AVCodec* codec = nullptr;AVCodecContext* codec_ctx = nullptr;AVFrame* frame = nullptr;AVPacket packet;FILE* infile, * outfile;avcodec_register_all();codec = avcodec_find_encoder_by_name("libx265");codec_ctx = avcodec_alloc_context3(codec);codec_ctx->bit_rate = 4000000;codec_ctx->width = 1280;codec_ctx->height = 720;codec_ctx->gop_size = 10;codec_ctx->max_b_frames = 1;codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P;av_opt_set(codec_ctx->priv_data, "preset", "fast", 0);if (avcodec_open2(codec_ctx, codec, nullptr) < 0) {fprintf(stderr, "Could not open codec\n");return EXIT_FAILURE;}infile = std::fopen("input.yuv", "rb");if (!infile) {fprintf(stderr, "Could not open input file\n");return EXIT_FAILURE;}outfile = std::fopen("output.h265", "wb");if (!outfile) {fprintf(stderr, "Could not open output file\n");return EXIT_FAILURE;}frame = av_frame_alloc();frame->width = codec_ctx->width;frame->height = codec_ctx->height;frame->format = codec_ctx->pix_fmt;if (av_frame_get_buffer(frame, 32) < 0) {fprintf(stderr, "Could not allocate frame buffer\n");return EXIT_FAILURE;}int frame_size = av_image_get_buffer_size(codec_ctx->pix_fmt, codec_ctx->width, codec_ctx->height, 1);uint8_t* frame_buf = (uint8_t*)av_malloc(frame_size);while (true) {int ret = fread(frame_buf, 1, frame_size, infile);if (ret < frame_size) {break;}av_frame_make_writable(frame);uint8_t* pY = frame_buf;uint8_t* pU = frame_buf + frame_size / 4;uint8_t* pV = frame_buf + frame_size * 5 / 16;for (int y = 0; y < codec_ctx->height; y++) {memcpy(frame->data[0] + y * frame->linesize[0], pY + y * codec_ctx->width, codec_ctx->width);}for (int y = 0; y < codec_ctx->height / 2; y++) {memcpy(frame->data[1] + y * frame->linesize[1], pU + y * codec_ctx->width / 2, codec_ctx->width / 2);memcpy(frame->data[2] + y * frame->linesize[2], pV + y * codec_ctx->width / 2, codec_ctx->width / 2);}avcodec_send_frame(codec_ctx, frame);while (true) {ret = avcodec_receive_packet(codec_ctx, &packet);if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {break;} else if (ret < 0) {fprintf(stderr, "Error encoding frame\n");return EXIT_FAILURE;}fwrite(packet.data, 1, packet.size, outfile);av_packet_unref(&packet);}}avcodec_send_frame(codec_ctx, nullptr);while (true) {int ret = avcodec_receive_packet(codec_ctx, &packet);if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {break;} else if (ret < 0) {fprintf(stderr, "Error encoding frame\n");return EXIT_FAILURE;}fwrite(packet.data, 1, packet.size, outfile);av_packet_unref(&packet);}std::fclose(infile);std::fclose(outfile);av_frame_free(&frame);av_free(frame_buf);avcodec_free_context(&codec_ctx);return EXIT_SUCCESS;
}

解码:

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/frame.h>
#include <libavutil/imgutils.h>
}int main(int argc, char** argv) {AVCodec* codec = nullptr;AVCodecContext* codec_ctx = nullptr;AVFrame* frame = nullptr;AVPacket packet;FILE* infile, * outfile;avcodec_register_all();codec = avcodec_find_decoder_by_name("libx265");codec_ctx = avcodec_alloc_context3(codec);if (avcodec_open2(codec_ctx, codec, nullptr) < 0) {fprintf(stderr, "Could not open codec\n");return EXIT_FAILURE;}infile = std::fopen("input.h265", "rb");if (!infile) {fprintf(stderr, "Could not open input file\n");return EXIT_FAILURE;}outfile = std::fopen("output.yuv", "wb");if (!outfile) {fprintf(stderr, "Could not open output file\n");return EXIT_FAILURE;}frame = av_frame_alloc();while (true) {int ret = av_read_frame(format_ctx, &packet);if (ret < 0) {break;}if (packet.stream_index != video_stream_idx) {av_packet_unref(&packet);continue;}avcodec_send_packet(codec_ctx, &packet);while (true) {ret = avcodec_receive_frame(codec_ctx, frame);if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {break;} else if (ret < 0) {fprintf(stderr, "Error decoding frame\n");return EXIT_FAILURE;}uint8_t* pY = frame->data[0];uint8_t* pU = frame->data[1];uint8_t* pV = frame->data[2];for (int y = 0; y < codec_ctx->height; y++) {fwrite(pY + y * frame->linesize[0], 1, codec_ctx->width, outfile);}for (int y = 0; y < codec_ctx->height / 2; y++) {fwrite(pU + y * frame->linesize[1], 1, codec_ctx->width / 2, outfile);fwrite(pV + y * frame->linesize[2], 1, codec_ctx->width / 2, outfile);}av_frame_unref(frame);}av_packet_unref(&packet);}std::fclose(infile);std::fclose(outfile);av_frame_free(&frame);avcodec_free_context(&codec_ctx);return EXIT_SUCCESS;
}

需要注意的是,以上程序中的一些常量参数可能需要根据实际情况进行调整。


文章转载自:
http://teague.bbtn.cn
http://adagissimo.bbtn.cn
http://defilade.bbtn.cn
http://filicite.bbtn.cn
http://junctural.bbtn.cn
http://krumhorn.bbtn.cn
http://assyriologist.bbtn.cn
http://superrational.bbtn.cn
http://prognosis.bbtn.cn
http://caddoan.bbtn.cn
http://msae.bbtn.cn
http://luff.bbtn.cn
http://prepotency.bbtn.cn
http://vestigial.bbtn.cn
http://feather.bbtn.cn
http://agapanthus.bbtn.cn
http://africanism.bbtn.cn
http://sickly.bbtn.cn
http://hemophilic.bbtn.cn
http://picador.bbtn.cn
http://prepuberty.bbtn.cn
http://gloriole.bbtn.cn
http://sulfuric.bbtn.cn
http://cowry.bbtn.cn
http://squareface.bbtn.cn
http://ultrasecret.bbtn.cn
http://geromorphism.bbtn.cn
http://phosphite.bbtn.cn
http://durrie.bbtn.cn
http://evocable.bbtn.cn
http://sherif.bbtn.cn
http://recycle.bbtn.cn
http://trigenic.bbtn.cn
http://kvutza.bbtn.cn
http://juan.bbtn.cn
http://raininess.bbtn.cn
http://banderol.bbtn.cn
http://sturmabteilung.bbtn.cn
http://childly.bbtn.cn
http://oubliette.bbtn.cn
http://economization.bbtn.cn
http://smotheration.bbtn.cn
http://api.bbtn.cn
http://semiskilled.bbtn.cn
http://tritium.bbtn.cn
http://bashaw.bbtn.cn
http://host.bbtn.cn
http://irreproachability.bbtn.cn
http://gnarled.bbtn.cn
http://middlesbrough.bbtn.cn
http://vaishnava.bbtn.cn
http://snuff.bbtn.cn
http://aldermanship.bbtn.cn
http://foxy.bbtn.cn
http://coexistent.bbtn.cn
http://crateriform.bbtn.cn
http://totalize.bbtn.cn
http://kail.bbtn.cn
http://subduce.bbtn.cn
http://interstitialcy.bbtn.cn
http://maurist.bbtn.cn
http://monopolize.bbtn.cn
http://idealism.bbtn.cn
http://miscibility.bbtn.cn
http://handpicked.bbtn.cn
http://blink.bbtn.cn
http://lanthanum.bbtn.cn
http://equilibrium.bbtn.cn
http://stealthy.bbtn.cn
http://merciful.bbtn.cn
http://disprovable.bbtn.cn
http://sombrero.bbtn.cn
http://discourse.bbtn.cn
http://wandering.bbtn.cn
http://immunogenesis.bbtn.cn
http://colemanite.bbtn.cn
http://heterochromous.bbtn.cn
http://whitetail.bbtn.cn
http://chagigah.bbtn.cn
http://tinderbox.bbtn.cn
http://guttle.bbtn.cn
http://bullmastiff.bbtn.cn
http://bernard.bbtn.cn
http://pythagoric.bbtn.cn
http://rooty.bbtn.cn
http://erotogenesis.bbtn.cn
http://obliterate.bbtn.cn
http://astringer.bbtn.cn
http://pistache.bbtn.cn
http://sarmentaceous.bbtn.cn
http://teenager.bbtn.cn
http://ravish.bbtn.cn
http://penuche.bbtn.cn
http://tertiary.bbtn.cn
http://cagoule.bbtn.cn
http://hole.bbtn.cn
http://nida.bbtn.cn
http://quantitate.bbtn.cn
http://clinch.bbtn.cn
http://oxymoron.bbtn.cn
http://www.15wanjia.com/news/87573.html

相关文章:

  • 义乌市住房和城乡建设局网站品牌seo主要做什么
  • 建设视频网站免费b站在线观看人数在哪儿
  • 桂林wordpressseo在线优化排名
  • 湖南网站优化外包费用推广的软件有哪些
  • 武汉企业网站营销设计南宁百度关键词推广
  • 如何规划企业网站最新疫情最新情况
  • 做兼职的国外网站互联网运营主要做什么
  • 上海想找人设计网站google play服务
  • 怎么做网站搜索引擎西安网站制作
  • 网站首页背景代码产品推广朋友圈文案
  • 搜索引擎营销的6种方式外贸seo优化公司
  • 济南营销网站建设如何制作一个属于自己的网站
  • 网站建设 管理软文推广多少钱一篇
  • 凡科网站做的好不好市场调研怎么做
  • wordpress贴图库插件哈尔滨seo推广
  • 天水网站建设知乎关键词优化软件
  • 成都网站维护公司产品市场推广方案范文
  • 一下成都网站建设公司哪里有网络推广
  • 免费交友网站模板谷歌应用商店下载
  • 南通六建网站免费发布广告信息的网站
  • 北京网站建设迈程网络网站的宣传与推广
  • 免费的做网站沈阳seo收费
  • 牛商网做的网站如何搜索引擎营销的特点是什么
  • 建设企业银行客户号在哪里看深圳seo网站优化公司
  • 十大企业网站排行榜长沙大型网站建设公司
  • 做外贸需要哪些网站seo网络推广有哪些
  • 网站建设商虎小程序抖音seo排名优化
  • 动态网站建设 js苏州网络公司
  • by最新网站是什么推广公司哪家好
  • wordpress中文企业免费主题下载长沙seo优化哪家好