ffmpeg 解码内存块 错误(多谢各位支招 在线等)
#if 1 的流程是使用自定义avio的解码代码
struct buffer_data {
uint8_t *ptr;
size_t size; ///< size left in the buffer
};
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
{
struct buffer_data *bd = (struct buffer_data *)opaque;
buf_size = FFMIN(buf_size, bd->size);
printf("ptr:%p size:%zu\n", bd->ptr, bd->size);
/* copy internal buffer data to buf */
memcpy(buf, bd->ptr, buf_size);
bd->ptr += buf_size;
bd->size -= buf_size;
return buf_size;
}
void * decode_thread(void *para)
{
AVCodecContext* video_dec_ctx = NULL;
AVCodec* video_dec = NULL;
AVPacket *pkt = NULL;
unsigned int framecnt = 0;
unsigned int decodecnt = 0;
struct timeval tv_begin, tv_end;
int index = *(int *)para;
int i,j,a;
int videoindex = -1;
char *src_file=g_src_files[index];
int height = 0;
int width = 0;
unsigned char * ch_pgm = NULL;
unsigned int outputsize = 0;
struct buffer_data bd = { 0 };
unsigned char * buffer = NULL;
size_t buffer_size = 0;
ch_pgm = (unsigned char *)malloc(MAX_PGM_SIZE);
printf("create decode thread. index=%d\n", index);
AVFormatContext* pFormat = NULL;
#if 1
unsigned char *avio_ctx_buffer = NULL;
AVIOContext *avio_ctx = NULL;
AVInputFormat* piFmt = NULL;
if (!(pFormat = avformat_alloc_context()))
{
printf("avformat_alloc_context failed\n");
return (void *)NULL;
}
avio_ctx_buffer = (unsigned char *)malloc(CTX_BUFFER_SIZE);
if(NULL ==avio_ctx_buffer)
{
printf("malloc avio_ctx_buffer failed\n");
return (void *)NULL;
}
memset(avio_ctx_buffer, 0, CTX_BUFFER_SIZE);
/* slurp file content into buffer */
if (av_file_map(src_file, &buffer, &buffer_size, 0, NULL) < 0)
{
printf("av_file_map failed\n");
return (void *)NULL;
}
/* fill opaque structure used by the AVIOContext read callback */
bd.ptr = buffer;
bd.size = buffer_size;
avio_ctx = avio_alloc_context(avio_ctx_buffer, CTX_BUFFER_SIZE,
0, &bd, &read_packet, NULL, NULL);
if (!avio_ctx)
{
printf("avio_alloc_context failed\n");
return (void *)NULL;
}
pFormat->pb = avio_ctx;
//if (av_probe_input_buffer(avio_ctx, &piFmt, "", NULL, 0, 0) < 0)
//{
// printf("probe format failed\n");
// return (void *)NULL;
//}
// else{
// printf("format:%s[%s]\n", piFmt->name, piFmt->long_name);
//}
//pFormat->probesize = 1024;
//pFormat->max_analyze_duration = 1
printf("flsg=0x%x \n"
, pFormat->flags);
//pFormat->flags |= AVFMT_FLAG_NONBLOCK;
if (avformat_open_input(&pFormat, , NULL, NULL) < 0)
{
printf("avformat_open_input failed\n");
return (void *)NULL;
}
printf("max_analyze_duration=%ld probesize=%ld\n"
, pFormat->max_analyze_duration
, pFormat->probesize);
#else
if (avformat_open_input(&pFormat, src_file, NULL, NULL) < 0)
{
printf("%s is not exit\n", src_file);
return (void *)NULL;
}
#endif
if (avformat_find_stream_info(pFormat, NULL) < 0)
{
printf("avformat_find_stream_info failed\n");
return (void *)NULL;
}
av_dump_format(pFormat,0,src_file,0);
gettimeofday(&tv_begin, NULL);
for (i=0; i < pFormat->nb_streams; i++)
{
if (pFormat->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
videoindex = i;
break;
}
}
if (videoindex == -1) {
printf("Don't find a video stream !\n");
return (void *)NULL;
}
video_dec_ctx = pFormat->streams[videoindex]->codec;
video_dec = avcodec_find_decoder(video_dec_ctx->codec_id);
if (avcodec_open2(video_dec_ctx, video_dec, NULL) < 0)
{
printf("avcodec_open2 failed\n");
return (void *)NULL;
}
height = video_dec_ctx->height;
width = video_dec_ctx->width;
pkt = av_packet_alloc();
av_init_packet(pkt);
outputsize = 0;
while (1)
{
int got_picture = 0,ret = 0;
if (av_read_frame(pFormat, pkt) < 0)
{
//printf("av_read_frame()<0 framecnt=%u decodecnt=%u\n", framecnt, decodecnt);
break;
}
framecnt++;
if (pkt->stream_index == videoindex)
{
//AVFrame *pFrame = avcodec_alloc_frame();// 2.8.6
AVFrame *pFrame = av_frame_alloc();// 3.0.0
decodecnt++;
ret = avcodec_decode_video2(video_dec_ctx, pFrame, &got_picture, pkt);
if (ret < 0)
{
printf("avcodec_decode_video2 failed\n");
//avcodec_free_frame(&pFrame);// 2.8.6
av_frame_free(&pFrame);// 3.0.0
break;
}
if(got_picture)
{
}
}
av_frame_free(&pFrame);// 3.0.0
}
输出:
flsg=0x200
ptr:0x7fb675889000 size:41381359
ptr:0x7fb675989000 size:40332783
ptr:0x7fb675a89000 size:39284207
ptr:0x7fb675b89000 size:38235631
ptr:0x7fb675c89000 size:37187055
ptr:0x7fb675d89000 size:36138479
ptr:0x7fb675e89000 size:35089903
ptr:0x7fb675f89000 size:34041327
ptr:0x7fb676089000 size:32992751
ptr:0x7fb676189000 size:31944175
ptr:0x7fb676289000 size:30895599
ptr:0x7fb676389000 size:29847023
ptr:0x7fb676489000 size:28798447
ptr:0x7fb676589000 size:27749871
ptr:0x7fb676689000 size:26701295
ptr:0x7fb676789000 size:25652719
ptr:0x7fb676889000 size:24604143
ptr:0x7fb676989000 size:23555567
ptr:0x7fb676a89000 size:22506991
ptr:0x7fb676b89000 size:21458415
ptr:0x7fb676c89000 size:20409839
ptr:0x7fb676d89000 size:19361263
ptr:0x7fb676e89000 size:18312687
ptr:0x7fb676f89000 size:17264111
ptr:0x7fb677089000 size:16215535
ptr:0x7fb677189000 size:15166959
ptr:0x7fb677289000 size:14118383
ptr:0x7fb677389000 size:13069807
ptr:0x7fb677489000 size:12021231
ptr:0x7fb677589000 size:10972655
ptr:0x7fb677689000 size:9924079
ptr:0x7fb677789000 size:8875503
ptr:0x7fb677889000 size:7826927
ptr:0x7fb677989000 size:6778351
ptr:0x7fb677a89000 size:5729775
ptr:0x7fb677b89000 size:4681199
ptr:0x7fb677c89000 size:3632623
ptr:0x7fb677d89000 size:2584047
ptr:0x7fb677e89000 size:1535471
ptr:0x7fb677f89000 size:486895
max_analyze_duration=0 probesize=5000000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb678400900] stream 0, offset 0x3e29: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb678400900] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1920x1080, 7254 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'hello.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: isommp423gp5
creation_time : 2011-08-04 01:51:12
title : big_buck_bunny_1080p_surround.avi_006.AVI.MP4
artist : created with SUPER(C).v2011.bld.49
encoder : eRightSoft
comment : 09:51:32
Duration: 00:00:45.00, bitrate: N/A
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), none, 1920x1080, 7254 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Metadata:
creation_time : 2011-08-05 01:50:11
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
creation_time : 2011-08-04 01:51:16
handler_name : GPAC ISO Audio Handler
Stream #0:2(und): Data: none (mp4s / 0x7334706D), 0 kb/s (default)
Metadata:
creation_time : 2011-08-04 01:51:21
handler_name : GPAC MPEG-4 OD Handler
Stream #0:3(und): Data: none (mp4s / 0x7334706D), 0 kb/s (default)
Metadata:
creation_time : 2011-08-04 01:51:21
handler_name : GPAC MPEG-4 BIFS Handler
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb678400900] stream 0, offset 0x3e29: partial file
现象:
程序会在avformat_open_input(&pFormat, , NULL, NULL)中遍历完整个文件流,最终并不报打开文件错误。
相关推荐
【高速互连技术】基于线性均衡的PCIe链路扩展方案:重驱动器在高损耗通道中的信号完整性优化
内容概要:本文介绍了如何利用线性均衡技术扩展PCI Express(PCIe)链路的传输距离,重点探讨了重驱动器(Re-Driver)在补偿PCB和电缆信道损耗中的作用。文章回顾了Re-Driver的发展历程,分析其性能特点,解释其在不同信道环境下的应用条件,并强调线性操作对保持信号完整性及满足PCIe规范的重要性。通过眼图分析、频率响应和Tx预设波形等手段,展示了R
谐波去噪基于随机奇异值分解和软阈值的大型数据集中的强大高效谐波去噪研究(Matlab代码实现)
内容概要:本文研究了一种基于随机奇异值分解(Randomized SVD)和软阈值(Soft Thresholding)的高效谐波去噪方法,旨在解决大型数据集中谐波干扰的抑制问题。该方法通过引入随机化技术加速传统奇异值分解过程,在保障信号主要特征完整性的同时,显著提升了高维数据处理的计算效率与实时性,适用于电力系统、通信等领域的复杂信号处理场景。文中系统阐述了算法的数学理论基础、实现步骤及在Matlab环境下的具体代码实现,并通过仿真实验验证了其在不同噪声水平下对谐波成分的有效识别与去除能力,展现出优异的鲁棒性与工程实用价值。; 适合人群:具备一定信号处理理论基础和Matlab编程能力,从事电力系统分析、通信工程、自动化控制或相关领域研究的研发人员及硕士、博士研究生。; 使用场景及目标:①应用于大规模实测信号中谐波成分的快速提取与抑制;②用于提升电能质量监测、设备故障诊断、精密仪器测量等应用中的信号信噪比;③为高维时序数据的高效去噪提供可复现、易部署的算法模板与技术参考。; 阅读建议:建议读者结合提供的Matlab代码逐模块理解算法实现细节,重点掌握随机SVD与软阈值去噪的协同机制,并尝试在实际采集数据上进行参数调优与性能测试,以深入理解其适用边界与优化潜力。
binutils-2.19.92.tar.bz2
binutils-2.19.92.tar.bz2
Agent Skills 实战速查包(Claude Code 技能体系/格式全表/加载位置/触发传参/上下文成本/打包分发/安全治理/排错)
Agent Skills 是 2025 年底以来 AI 编码工具领域事实上的新开放标准(Anthropic 开源、agentskills.io 承载规范),Claude Code、claude.ai、Claude API 及各兼容 agent 都在用;但规范页、Claude Code 文档、示例仓库三处全英文且互相引用,行为细节(比如哪些 frontmatter 字段出了 Claude Code 上传就会失败)散落各段。本包按「看懂格式 → 放对位置 → 控制触发 → 算清 token → 打包分发 → 审安全 → 排错」一条线整理:技能三层渐进加载与 CLAUDE.md/命令/MCP 的边界、7 种加载位置与同名优先级、SKILL.md 开放标准 6 字段 + Claude Code 扩展 17 字段逐条约束与跨产品红线、$ARGUMENTS/$1/命名参数两种传参、描述列表 1% 压缩预算与 skillOverrides 四状态、context:fork 子代理与动态注入的完整行为矩阵(位置规则/失败语义/权限检查)、官方写法最佳实践与对照基线的 eval 闭环、Git/插件市场/企业托管三条分发路与 marketplace.json 结构、自放行与第三方技能进场审查、YAML 解析失败静默降级与非零退出中止整个技能调用等 16 类症状反查。附 SKILL.template、marketplace.template、settings.template 三份可直接改占位的骨架与一个零依赖校验脚本(合法 exit 0、错误 exit 1 逐条打印)。本包不含任何程序本体,只整理规则与配置骨架;示例一律 YOUR_*/your-* 占位。
mongodb-org-mongos_8.0.13_arm64.deb
mongodb-org-mongos_8.0.13_arm64


多媒体/流媒体开发
