FFmpegh.264解码
- (int)DecodeH264Frames: (unsigned char*)inputBuffer withLength:(int)aLength
{
int gotPicPtr=;
int result=; av_init_packet(&pAvPackage);
pAvPackage.data=(unsigned char*)inputBuffer;
pAvPackage.size=aLength;
//解码
result=avcodec_decode_video2(pCodecCtx, pVideoFrame, &gotPicPtr, &pAvPackage); //如果视频尺寸更改,我们丢掉这个frame
if((pictureWidth!=)&&(pictureWidth!=pCodecCtx->width)){
setRecordResolveState=;
pictureWidth=pCodecCtx->width;
return -;
} //YUV 420 Y U V -> RGB
if(gotPicPtr)
{ unsigned int lumaLength= (pCodecCtx->height)*(MIN(pVideoFrame->linesize[], pCodecCtx->width));// W * H
unsigned int chromBLength=((pCodecCtx->height)/)*(MIN(pVideoFrame->linesize[], (pCodecCtx->width)/));// w * h/4
unsigned int chromRLength=((pCodecCtx->height)/)*(MIN(pVideoFrame->linesize[], (pCodecCtx->width)/)); H264YUV_Frame yuvFrame;
memset(&yuvFrame, , sizeof(H264YUV_Frame)); yuvFrame.luma.length = lumaLength;
yuvFrame.chromaB.length = chromBLength;
yuvFrame.chromaR.length =chromRLength;
yuvFrame.luma.dataBuffer=(unsigned char*)malloc(lumaLength);
yuvFrame.chromaB.dataBuffer=(unsigned char*)malloc(chromBLength);
yuvFrame.chromaR.dataBuffer=(unsigned char*)malloc(chromRLength);
copyDecodedFrame(pVideoFrame->data[],yuvFrame.luma.dataBuffer,pVideoFrame->linesize[],
pCodecCtx->width,pCodecCtx->height);
copyDecodedFrame(pVideoFrame->data[], yuvFrame.chromaB.dataBuffer,pVideoFrame->linesize[],
pCodecCtx->width / ,pCodecCtx->height / );
copyDecodedFrame(pVideoFrame->data[], yuvFrame.chromaR.dataBuffer,pVideoFrame->linesize[],
pCodecCtx->width / ,pCodecCtx->height / ); yuvFrame.width=pCodecCtx->width;
yuvFrame.height=pCodecCtx->height; dispatch_sync(dispatch_get_main_queue(), ^{ [self updateYUVFrameOnMainThread:(H264YUV_Frame*)&yuvFrame];
}); free(yuvFrame.luma.dataBuffer);
free(yuvFrame.chromaB.dataBuffer);
free(yuvFrame.chromaR.dataBuffer); }
av_free_packet(&pAvPackage); return ;
}
FFmpegh.264解码的更多相关文章
- [ffmpeg] h.264解码所用的主要缓冲区介绍
在进行h264解码过程中,有两个最重要的结构体,分别为H264Picture.H264SliceContext. H264Picture H264Picture用于维护一帧图像以及与该图像相关的语法元 ...
- <开源项目分析>Cisco的开源视频加解码器THOR(H.264解码)
原创博客,转载请联系博主! 题外话:自学了快两个月的Perl语言,本来打算写两篇基础介绍的博文来科普一下一些小技巧,但是仔细想想还是没有必要了吧,毕竟现在无论是在用Perl5还是Perl6的人都是小众 ...
- h.264并行解码算法分析
并行算法类型可以分为两类 Function-level Decomposition,按照功能模块进行并行 Data-level Decomposition,按照数据划分进行并行 Function-le ...
- H.264视频在android手机端的解码与播放(转)
随着无线网络和智能手机的发展,智能手机与人们日常生活联系越来越紧密,娱乐.商务应用.金融应用.交通出行各种功能的软件大批涌现,使得人们的生活丰富多彩.快捷便利,也让它成为人们生活中不可取代的一部分.其 ...
- (转载)H.264码流的RTP封包说明
H.264的NALU,RTP封包说明(转自牛人) 2010-06-30 16:28 H.264 RTP payload 格式 H.264 视频 RTP 负载格式 1. 网络抽象层单元类型 (NALU) ...
- H.264码流结构解析
from:http://wenku.baidu.com/link?url=hYQHJcAWUIS-8C7nSBbf-8lGagYGXKb5msVwQKWyXFAcPLU5gR4BKOVLrFOw4bX ...
- FFmpeg源码结构图 - 解码
===================================================== FFmpeg的库函数源码分析文章列表: [架构图] FFmpeg源码结构图 - 解码 FFm ...
- FFmpeg源代码结构图 - 解码
===================================================== FFmpeg的库函数源代码分析文章列表: [架构图] FFmpeg源代码结构图 - 解码 F ...
- H.264开源解码器评测
转自:http://wmnmtm.blog.163.com/blog/static/38245714201142883032575/ 要播放HDTV,就首先要正确地解开封装,然后进行视频音频解码.所以 ...
随机推荐
- 最长回文子串 hihocode 1032 hdu 3068
最长回文 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- nodejs操作文件和数据流
前言 node中有一组流api,它们可以像处理网络流一样处理文件.流api用起来非常方便,本节学习介绍文件处理基础和流的概念. 目录 处理文件路径 fs核心模块简介 操作流 慢客户端问题 1. 处理文 ...
- vue.js中compted与model的区别
在p便签内写的{{reversemessage}}方法,若js里对应的函数为computed则不需要加上括号 若js里对应的函数为model则应该将{{reversemessage}}改为{{reve ...
- BZOJ2337: [HNOI2011]XOR和路径(高斯消元,期望)
解题思路: Xor的期望???怕你不是在逗我. 按为期望,新技能get 剩下的就是游走了. 代码: #include<cmath> #include<cstdio> #incl ...
- JS实现分页效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 使用virtualenv搭建python虚拟开发环境
在使用python做开发时,如果多人需要在同一台机器上工作,或者机器环境经常变化时, 添加或删除一些python包很可能会影响到你自己的开发环境. 因此,通过virtualenv工具可以创建一个完全属 ...
- You have ettempted to queue to many files.You may select one files.
<script type="text/javascript" src="/script/swfupload/swfupload.js"></s ...
- Unityclient通信測试问题处理(一)
Unityclient通信測试问题处理(一) 近期在測试程序的通信模块时.遇到了一个问题:Unity的API函数仅仅能在主线程中调用.而作为client程序,我单独启用了一个监听线程来接收服务端发送的 ...
- LintCode 二叉树的遍历 (非递归)
前序: class Solution { public: /** * @param root: The root of binary tree. * @return: Preorder in vect ...
- ActiveReports 9实战教程(2): 准备数据源(设计时、执行时)
在上讲中<ActiveReports 9实战教程(1): 手把手搭建好开发环境Visual Studio 2013 社区版>,我们已经结合Visual Studio 2013搭建好了Act ...