海思h264解码库

海思h264解码库海思的dll,解码h264 解码后转出yuv12dll自己百度下载 hi_h264dec.dll  hi_h264dec_w.dll 调用方法:if(H264Dec.Hi264DecAU(_decHandle,pH264Data,frameLen,0,ref_decodeFrame,0)==0) pH264Data是h264帧的句柄,frameLen…

大家好,又见面了,我是你们的朋友全栈君。

海思的dll,解码h264  解码后转出yuv12
dll自己百度下载  hi_h264dec.dll   hi_h264dec_w.dll
 
调用方法:
if (H264Dec.Hi264DecAU(_decHandle, pH264Data, frameLen, 0, ref _decodeFrame, 0) == 0)
 
pH264Data是h264帧的句柄,frameLen是h264帧的长度,_decodeFrame是解码后的yuv帧
 
 
 
#region 解码器相关变量声明
        /// <summary>
        /// 数据的句柄
        /// </summary>
        /// <summary>
        /// 这是解码器属性信息
        /// </summary>
        public H264Dec.hiH264_DEC_ATTR_S decAttr;
        /// <summary>
        /// 这是解码器输出图像信息
        /// </summary>
        public H264Dec.hiH264_DEC_FRAME_S _decodeFrame = new H264Dec.hiH264_DEC_FRAME_S();
        /// <summary>
        /// 解码器句柄
        /// </summary>
        public IntPtr _decHandle;
        static double[,] YUV2RGB_CONVERT_MATRIX = new double[3, 3] { { 1, 0, 1.4022 }, { 1, -0.3456, -0.7145 }, { 1, 1.771, 0 } };
        #endregion
 
#region 解码器相关初始化,一般在窗口load中进行初始化
            decAttr = new H264Dec.hiH264_DEC_ATTR_S();
            decAttr.uPictureFormat = 0;
            decAttr.uStreamInType = 0;
            decAttr.uPicWidthInMB = (uint)width;
            decAttr.uPicHeightInMB = (uint)height;
            decAttr.uBufNum = 8;
            decAttr.uWorkMode = 16;
            //创建、初始化解码器句柄
            _decHandle = H264Dec.Hi264DecCreate(ref decAttr);
            #endregion
 
using System;
using System.Runtime.InteropServices;
 
namespace FVD.Common
{
    public class H264Dec
    {
        public const int HI_SUCCESS = 0;
 
        public const int HI_FAILURE = -1;
 
        public const int HI_LITTLE_ENDIAN = 1234;
 
        public const int HI_BIG_ENDIAN = 4321;
 
        public const int HI_DECODER_SLEEP_TIME = 60000;
 
        public const int HI_H264DEC_OK = 0;
 
        public const int HI_H264DEC_NEED_MORE_BITS = -1;
 
        public const int HI_H264DEC_NO_PICTURE = -2;
 
        public const int HI_H264DEC_ERR_HANDLE = -3;
 
 
 
        [DllImport("hi_h264dec_w.dll", EntryPoint = "Hi264DecImageEnhance",CallingConvention = CallingConvention.Cdecl)]
        public static extern int Hi264DecImageEnhance(IntPtr hDec, refhiH264_DEC_FRAME_S pDecFrame, uint uEnhanceCoeff);
 
        [DllImport("hi_h264dec_w.dll", EntryPoint = "Hi264DecCreate", CallingConvention =CallingConvention.Cdecl)]
        public static extern IntPtr Hi264DecCreate(ref hiH264_DEC_ATTR_S pDecAttr);
 
        [DllImport("hi_h264dec_w.dll", EntryPoint = "Hi264DecDestroy", CallingConvention =CallingConvention.Cdecl)]
        public static extern void Hi264DecDestroy(IntPtr hDec);
 
 
        [DllImport("hi_h264dec_w.dll", EntryPoint = "Hi264DecGetInfo", CallingConvention =CallingConvention.Cdecl)]
        public static extern int Hi264DecGetInfo(ref hiH264_LIBINFO_S pLibInfo);
 
        /// <summary>
        /// 对输入的一段码流进行解码并按帧输出图像
        /// </summary>
        /// <param name="hDec">解码器句柄</param>
        /// <param name="pStream">码流起始地址</param>
        /// <param name="iStreamLen">码流长度</param>
        /// <param name="ullPTS">时间戳信息</param>
        /// <param name="pDecFrame">图像信息</param>
        /// <param name="uFlags">解码模式 0:正常解码;1、解码完毕并要求解码器输出残留图像</param>
        /// <returns></returns>
        [DllImport("hi_h264dec_w.dll", EntryPoint = "Hi264DecFrame", CallingConvention = CallingConvention.Cdecl)]
        public static extern int Hi264DecFrame(IntPtr hDec, IntPtr pStream, uint iStreamLen, ulong ullPTS, ref hiH264_DEC_FRAME_S pDecFrame, uint uFlags);
 
        [DllImport("hi_h264dec_w.dll", EntryPoint = "Hi264DecAU", CallingConvention =CallingConvention.Cdecl)]
        public static extern int Hi264DecAU(IntPtr hDec, IntPtr pStream, uint iStreamLen,ulong ullPTS, ref hiH264_DEC_FRAME_S pDecFrame, uint uFlags);
        /// <summary>
        /// 解码器属性信息。
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public struct hiH264_DEC_ATTR_S
        {
            /// <summary>
            /// 解码器输出图像格式,目前解码库只支持YUV420图像格式
            /// </summary>
            public uint uPictureFormat;
            /// <summary>
            /// 输入码流格式 0x00: 目前解码库只支持以“00 00 01”为nalu分割符的流式H.264码流 
            /// </summary>
            public uint uStreamInType;
            /// <summary>
            /// 图像宽度
            /// </summary>
            public uint uPicWidthInMB;
            /// <summary>
            /// 图像高度
            /// </summary>
            public uint uPicHeightInMB;
            /// <summary>
            /// 参考帧数目
            /// </summary>
            public uint uBufNum;
            /// <summary>
            /// 解码器工作模式
            /// </summary>
            public uint uWorkMode;
            /// <summary>
            /// 用户私有数据
            /// </summary>
            public IntPtr pUserData;
            /// <summary>
            /// 保留字
            /// </summary>
            public uint uReserved;
 
        }
 
        /// <summary>
        /// 解码器输出图像信息数据结构
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public struct hiH264_DEC_FRAME_S
        {
            /// <summary>
            /// Y分量地址
            /// </summary>
            public IntPtr pY;
            /// <summary>
            /// U分量地址
            /// </summary>
            public IntPtr pU;
            /// <summary>
            /// V分量地址
            /// </summary>
            public IntPtr pV;
            /// <summary>
            /// 图像宽度(以像素为单位)
            /// </summary>
            public uint uWidth;
            /// <summary>
            /// 图像高度(以像素为单位)
            /// </summary>
            public uint uHeight;
            /// <summary>
            /// 输出Y分量的stride (以像素为单位)
            /// </summary>
            public uint uYStride;
            /// <summary>
            /// 输出UV分量的stride (以像素为单位)
            /// </summary>
            public uint uUVStride;
            /// <summary>
            /// 图像裁减信息:左边界裁减像素数
            /// </summary>
            public uint uCroppingLeftOffset;
            /// <summary>
            /// 图像裁减信息:右边界裁减像素数
            /// </summary>
            public uint uCroppingRightOffset;
            /// <summary>
            /// 图像裁减信息:上边界裁减像素数
            /// </summary>
            public uint uCroppingTopOffset;
            /// <summary>
            /// 图像裁减信息:下边界裁减像素数
            /// </summary>
            public uint uCroppingBottomOffset;
            /// <summary>
            /// 输出图像在dpb中的序号
            /// </summary>
            public uint uDpbIdx;
            /// <summary>
            /// 图像类型:0:帧; 1:顶场; 2:底场 */
            /// </summary>
            public uint uPicFlag;
            /// <summary>
            /// 图像类型:0:帧; 1:顶场; 2:底场 */
            /// </summary>
            public uint bError;
            /// <summary>
            /// 图像是否为IDR帧:0:非IDR帧;1:IDR帧
            /// </summary>
            public uint bIntra;
            /// <summary>
            /// 时间戳
            /// </summary>
            public ulong ullPTS;
            /// <summary>
            /// 图像信号
            /// </summary>
            public uint uPictureID;
            /// <summary>
            /// 保留字
            /// </summary>
            public uint uReserved;
            /// <summary>
            /// 指向用户私有数据
            /// </summary>
            public IntPtr pUserData;
 
        }
 
 
        /// <summary>
        /// 解码库版本、版权和能力集信息。
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public struct hiH264_LIBINFO_S
        {
            /// <summary>
            /// 主编号
            /// </summary>
            public uint uMajor;
            /// <summary>
            /// 次编号
            /// </summary>
            public uint uMinor;
            /// <summary>
            /// 发布编号
            /// </summary>
            public uint uRelease;
            /// <summary>
            /// 建构编号
            /// </summary>
            public uint uBuild;
            /// <summary>
            /// 版本信息
            /// </summary>
            [MarshalAs(UnmanagedType.LPStr)]
            public string sVersion;
            /// <summary>
            /// 版权信息
            /// </summary>
            [MarshalAs(UnmanagedType.LPStr)]
            public string sCopyRight;
            /// <summary>
            /// 解码库能力集
            /// </summary>
            public uint uFunctionSet;
            /// <summary>
            /// 支持的输出图像格式
            /// </summary>
            public uint uPictureFormat;
            /// <summary>
            /// 输入码流格式
            /// </summary>
            public uint uStreamInType;
            /// <summary>
            /// 最大图像宽度(以像素为单位)
            /// </summary>
            public uint uPicWidth;
            /// <summary>
            /// 最大图像高度(以像素为单位)
            /// </summary>
            public uint uPicHeight;
            /// <summary>
            /// 最大参考帧数目
            /// </summary>
            public uint uBufNum;
            /// <summary>
            /// 保留字
            /// </summary>
            public uint uReserved;
 
        }
 
        /// <summary>
        /// 用户私有数据信息。
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public struct hiH264_USERDATA_S
        {
            /// <summary>
            /// 用户数据类型
            /// </summary>
            public uint uUserDataType;
            /// <summary>
            /// 用户数据长度
            /// </summary>
            public uint uUserDataSize;
            /// <summary>
            /// 用户数据缓冲区
            /// </summary>
            public IntPtr pData;
            /// <summary>
            /// 指向下一段用户数据
            /// </summary>
            public IntPtr pNext;
        }
    }
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/148508.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • c++ ostringstream的用法(c语言的sprintf)

    c++ ostringstream的用法(c语言的sprintf)转载: https://blog.csdn.net/qq1987924/article/details/7671154ostringstream的用法【本文来自】http://www.builder.com.cn/2003/0304/83250.shtmlhttp://www.cppblog.com/alantop/archive/2007/07/10/27823.html使用stringstre…

    2022年6月23日
  • navicat15 激活码 3月最新注册码

    navicat15 激活码 3月最新注册码,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月15日
  • interview-db[通俗易懂]

    interview-db[通俗易懂]1.索引作用和优缺点索引就一种特殊的查询表,数据库的搜索可以利用它加速对数据的检索。它很类似与现实生活中书的目录,不需要查询整本书内容就可以找到想要的数据。索引可以是唯一的,创建索引允许指定单个列或者是多个列。缺点是它减慢了数据录入的速度,同时也增加了数据库的尺寸大小。2.什么字段适合建索引唯一性比较高,不为空,经常查询3.常见慢查询优化1.建索引2.减少表之间的关联3.优化sql,尽量让sq…

    2022年7月21日
  • Android入门基础教程(小白速成1)

    Android入门基础教程(小白速成1)Android入门基础教程(小白速成1)编译工具:AndroidStudio各种工具其实大同小异开发环境的搭建还有项目新建这里就不过多说明了,网上有很多教程。项目新建按照需求来就好,我这里选用空的界面(EmptyActivity)和Android4.0.3,大家一定要注意安卓版本匹配问题鸭,之前每次新建项目都报错,最后才发现是版本匹配问题。话不多说,进入正题吧!HelloWorld!新建好项目以后,我们首先认识几个主要用到的界面。MainActivity.java页面,这个页面相当

    2022年5月4日
  • Vue+Element UI 商城后台管理系统[通俗易懂]

    Vue+Element UI 商城后台管理系统[通俗易懂]Vue+ElementUI商城后台管理系统一、前言1.项目背景此项目来自B站Vue实战项目:电商管理系统(Element-UI)。此项目的功能与后端提供的接口并不完全相同,根据后端接口进行开发并添加了部分功能从而进行修改。在完成此项目并测试上线后,在这里记录一下项目的开发思路,以及遇到的一些问题。自我感觉这个项目是一个很不错的关于Vue+ElementUI的练手项目2.部分效果图展示先放一些效果图项目上线地址:https://aerowang.cn/vue_shop

    2022年11月1日
  • html5 sexteen,Teen Sex on the Rise in Guangzhou

    html5 sexteen,Teen Sex on the Rise in GuangzhouSexamongmiddleschoolstudentsmaybecontributingtogrowingsterilityproblemsamongyoungwomeninGuangzhou,thecapitalofsouthChina’sGuangdongProvince,saysaprominentlocaldoctor.Puppy…

    2022年5月10日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号