Files
luban-lite-t3e-pro/doc/topics/sdk/mpp/mpp-decode.html
2025-01-23 16:37:00 +08:00

628 lines
83 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.0">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="description" content="MPP Decoder 由三个主要模块组成: 解码模块H264、JPEG、PNG 等):负责将码流数据解码成视频图像 输入码流数据管理模块( Packet manager ):负责视频、图片码流数据和 buffer 的管理 显示帧管理模块( Frame manager ):负责解码图像 buffer 的管理 Packet 管理机制 Packet manager 负责管理码流数据和 ..."/><meta name="DC.rights.owner" content="(C) 版权 2025"/><meta name="copyright" content="(C) 版权 2025"/><meta name="generator" content="DITA-OT"/><meta name="DC.type" content="concept"/><meta name="DC.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-12-05"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="mpp_decode"/><title>MPP Decoder 设计及接口说明</title><!-- Build number 2023110923. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content=""/><meta name="wh-source-relpath" content="topics/sdk/mpp/mpp-decode.dita"/><meta name="wh-out-relpath" content="topics/sdk/mpp/mpp-decode.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2023110923"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2023110923"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250121171154"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2023110923"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250121171154"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2023110923"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2023110923"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2023110923"/></head>
<body id="mpp_decode" class="wh_topic_page frmBody">
<a href="#wh_topic_body" class="sr-only sr-only-focusable">
跳转到主要内容
</a>
<header class="navbar navbar-default wh_header">
<div class="container-fluid">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.png" alt="RTOS SDK 使用指南SDK 指南文件"/></a>
<div class=" wh_publication_title "><a href="../../../index.html"><span class="booktitle"><span class="ph mainbooktitle">RTOS SDK 使用指南</span><span class="ph booktitlealt">SDK 指南文件</span></span></a></div>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<div class=" wh_search_input navbar-form wh_topic_page_search search " role="form">
<form id="searchForm" method="get" role="search" action="../../../search.html"><div><input type="search" placeholder="搜索 " class="wh_search_textfield" id="textToSearch" name="searchQuery" aria-label="搜索查询" required="required"/><button type="submit" class="wh_search_button" aria-label="搜索"><span class="search_input_text">搜索</span></button></div></form>
</div>
<div class="container-fluid" id="wh_topic_container">
<div class="row">
<nav class="wh_tools d-print-none navbar-expand-md" aria-label="Tools">
<div data-tooltip-position="bottom" class=" wh_breadcrumb "></div>
<div class="wh_right_tools">
<button class="wh_hide_highlight" aria-label="切换搜索突出显示" title="切换搜索突出显示"></button>
<button class="webhelp_expand_collapse_sections" data-next-state="collapsed" aria-label="折叠截面" title="折叠截面"></button>
<div class=" wh_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12" id="wh_topic_body">
<button id="wh_close_topic_toc_button" class="close-toc-button d-none" aria-label="Toggle topic table of content" aria-controls="wh_topic_toc" aria-expanded="true">
<span class="close-toc-icon-container">
<span class="close-toc-icon"></span>
</span>
</button>
<div class=" wh_topic_content body "><main role="main"><article class="- topic/topic concept/concept topic concept" role="article" aria-labelledby="ariaid-title1"><span class="edit-link" style="font-size:12px; opacity:0.6; text-align:right; vertical-align:middle"><a target="_blank" href="http://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/mpp/mpp-decode.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">MPP Decoder 设计及接口说明</h1><div class="date inPage">5 Dec 2024</div><div style="color: gray;">
Read time: 10 minute(s)
</div><div class="- topic/body concept/conbody body conbody"><div class="- topic/p p" data-ofbid="d41009e22__20250121171516">MPP Decoder 由三个主要模块组成:<ul class="- topic/ul ul simple" id="mpp_decode__ul_ntn_2nt_2dc" data-ofbid="mpp_decode__ul_ntn_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e25__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e27__20250121171516">解码模块H264、JPEG、PNG 等):负责将码流数据解码成视频图像</p>
</li><li class="- topic/li li" data-ofbid="d41009e30__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e32__20250121171516">输入码流数据管理模块(<a class="- topic/xref xref" href="mpp-decode.html#mpp_decode__packet">Packet
manager</a>):负责视频、图片码流数据和 buffer 的管理</p>
</li><li class="- topic/li li" data-ofbid="d41009e39__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e41__20250121171516">显示帧管理模块(<a class="- topic/xref xref" href="mpp-decode.html#mpp_decode__packet">Frame manager</a>):负责解码图像 buffer
的管理</p>
</li></ul></div><section class="- topic/section section" id="mpp_decode__packet" data-ofbid="mpp_decode__packet"><h2 class="- topic/title title sectiontitle">Packet 管理机制</h2>
<p class="- topic/p p" data-ofbid="d41009e53__20250121171516">Packet manager 负责管理码流数据和 buffer。初始化时该模块申请一块物理连续的内存buffer
大小可由外部配置),用于存放视频/图片码流数据。</p>
<p class="- topic/p p" data-ofbid="d41009e56__20250121171516">Packet manager 管理的数据单元为 packetpacket 表示一笔码流数据,它可以是完整的一帧数据,也支持不是完整的一帧数据。 每个 packet
与物理内存中的码流数据一一对应,它记录了每一笔码流的物理内存基地址、物理内存结束地址、物理内存偏移、虚拟内存地址、码流数据长度等信息。</p>
<figure class="- topic/fig fig fignone" id="mpp_decode__id13" data-ofbid="mpp_decode__id13"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="mpp_decode__image_otn_2nt_2dc" src="../../../images/mpp/packet_manager.png" width="576" alt="packet_manager"/></div><br/><figcaption data-caption-side="bottom" class="- topic/title title figcapcenter"><span class="figtitleprefix fig--title-label"><span class="fig--title-label-number"> 1</span><span class="fig--title-label-punctuation">. </span></span><span class="fig--title">packet 管理</span></figcaption></figure>
<p class="- topic/p p" data-ofbid="d41009e66__20250121171516">packet 通过 empty list 和 ready list 两个链表进行管理。 其中empty list 用于存放空闲的 packetready list
用于存放待解码的 packet。</p>
<p class="- topic/p p" data-ofbid="d41009e70__20250121171516">送码流数据时,从 empty list 获取一个空闲 packet填充数据后再把 packet 放入 ready list</p>
<p class="- topic/p p" data-ofbid="d41009e73__20250121171516">解码前,解码器从 ready list 获取一个填充数据的 packet使用完后再把该 packet 放入 empty list。</p>
<figure class="- topic/fig fig fignone" id="mpp_decode__id14" data-ofbid="mpp_decode__id14"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="mpp_decode__image_ptn_2nt_2dc" src="../../../images/mpp/pm_flow.png" width="576" alt="pm_flow"/></div><br/><figcaption data-caption-side="bottom" class="- topic/title title figcapcenter"><span class="figtitleprefix fig--title-label"><span class="fig--title-label-number"> 2</span><span class="fig--title-label-punctuation">. </span></span><span class="fig--title">packet manager 调用流程</span></figcaption></figure>
</section><section class="- topic/section section" id="mpp_decode__frame" data-ofbid="mpp_decode__frame"><h2 class="- topic/title title sectiontitle">Frame 管理机制</h2>
<p class="- topic/p p" data-ofbid="d41009e88__20250121171516">Frame manager 负责管理图像 buffer。Frame manager 内部通过两个链表来管理图像 bufferempty list 和 render
list。 其中empty list 存放可以给解码输出使用的图像 bufferrender list 存放解码完成但还未显示的图像 buffer。
在运行过程中,正在显示的图像 buffer 和用于参考的图像 buffer 可能不在这两个 list 中。</p>
<ol class="- topic/ol ol arabic simple" id="mpp_decode__ol_qtn_2nt_2dc" data-ofbid="mpp_decode__ol_qtn_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e92__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e94__20250121171516">frame 状态迁移</p>
<div class="- topic/p p" data-ofbid="d41009e97__20250121171516">初始化时,该模块申请指定个数的图像 buffer个数可由外部配置每个图像 buffer 的信息存放在内部数组中。 每个图像 buffer 有 4
种状态:<ul class="- topic/ul ul simple" id="mpp_decode__ul_rtn_2nt_2dc" data-ofbid="mpp_decode__ul_rtn_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e100__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e102__20250121171516">Decoding: 该帧正在被解码器使用(用于解码输出或作为参考帧)</p>
</li><li class="- topic/li li" data-ofbid="d41009e105__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e107__20250121171516">wait_render: 该帧在 render list 中,等待显示</p>
</li><li class="- topic/li li" data-ofbid="d41009e110__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e112__20250121171516">Rendering: 该帧正在被显示占用</p>
</li><li class="- topic/li li" data-ofbid="d41009e115__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e117__20250121171516">IDLE: 该帧处于空闲状态(既没有被显示占用,也没有被解码器用作参考帧)</p>
</li></ul></div>
<div class="- topic/p p" data-ofbid="d41009e121__20250121171516">其状态转移如下图所示:<ul class="- topic/ul ul simple" id="mpp_decode__ul_stn_2nt_2dc" data-ofbid="mpp_decode__ul_stn_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e124__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e126__20250121171516">初始化时,所有图像 buffer 都在 empty list 中,此时处于 IDLE 状态;</p>
</li><li class="- topic/li li" data-ofbid="d41009e129__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e131__20250121171516">解码模块从 empty list 链表头部获取一个空图像 buffer此时 buffer 被解码模块占用,从 IDLE 状态变为
Decoding 状态;</p>
</li><li class="- topic/li li" data-ofbid="d41009e134__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e136__20250121171516">解码完成后,解码模块还图像数据。此时分两种情况:</p>
<ul class="- topic/ul ul" id="mpp_decode__ul_ttn_2nt_2dc" data-ofbid="mpp_decode__ul_ttn_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e140__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e142__20250121171516">如果当前帧还未被显示,该帧加入 render list 链表尾部,从 Decoding 状态变为 wait
render 状态;</p>
</li><li class="- topic/li li" data-ofbid="d41009e145__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e147__20250121171516">该帧不再用做参考帧且已显示完成,此时该帧加入 empty list 链表尾部,由 Decoding 状态进入
IDLE 状态;</p>
</li></ul>
</li><li class="- topic/li li" data-ofbid="d41009e151__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e153__20250121171516">显示模块从 render list 链表头部取一帧图像,此时当前帧由 wait render 状态进入 Rendering
状态;</p>
</li><li class="- topic/li li" data-ofbid="d41009e156__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e158__20250121171516">显示模块还图像 buffer分两种情况</p>
<ul class="- topic/ul ul" id="mpp_decode__ul_utn_2nt_2dc" data-ofbid="mpp_decode__ul_utn_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e162__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e164__20250121171516">如果当前帧不用于参考,此时由 Rendering 状态回到 IDLE 状态,该帧加入 empty list
链表尾部;</p>
</li><li class="- topic/li li" data-ofbid="d41009e167__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e169__20250121171516">如果当前帧用于参考,此时由 Rendering 状态进入 Decoding 状态,该图像 buffer
不进入任何队列,等待解码器还参考帧;</p>
</li></ul>
</li></ul><figure class="- topic/fig fig fignone" id="mpp_decode__id15" data-ofbid="mpp_decode__id15"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="mpp_decode__image_vtn_2nt_2dc" src="../../../images/mpp/frame_status.png" width="480" alt="frame_status"/></div><br/><figcaption data-caption-side="bottom" class="- topic/title title figcapcenter"><span class="figtitleprefix fig--title-label"><span class="fig--title-label-number"> 3</span><span class="fig--title-label-punctuation">. </span></span><span class="fig--title">frame 状态迁移</span></figcaption></figure></div>
</li><li class="- topic/li li" data-ofbid="d41009e180__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e182__20250121171516">frame manager 调用流程</p>
<p class="- topic/p p" data-ofbid="d41009e185__20250121171516">对于 JPEG、PNG 这类没有参考帧概念的编码格式,每一帧的状态是唯一的,解码后的数据帧可直接送 render list</p>
<figure class="- topic/fig fig fignone" id="mpp_decode__id16" data-ofbid="mpp_decode__id16"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="mpp_decode__image_xtn_2nt_2dc" src="../../../images/mpp/frame_manager_jpeg.png" width="576" alt="frame_manager_jpeg"/></div><br/><figcaption data-caption-side="bottom" class="- topic/title title figcapcenter"><span class="figtitleprefix fig--title-label"><span class="fig--title-label-number"> 4</span><span class="fig--title-label-punctuation">. </span></span><span class="fig--title">frame manager 调用流程JPEG/PNG</span></figcaption></figure>
<p class="- topic/p p" data-ofbid="d41009e195__20250121171516">但对于 H264 这类有参考帧的编码格式,解码后的视频帧可能既被显示占用也会被解码器用作参考帧,并且由于双向参考帧的存在, 视频帧需要重排序后才能送显示。
不同于 JPGH264 解码库内部存在一个 delay list 用于为显示帧重排序。</p>
<figure class="- topic/fig fig fignone" id="mpp_decode__id17" data-ofbid="mpp_decode__id17"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="mpp_decode__image_ytn_2nt_2dc" src="../../../images/mpp/frame_manager_264.png" width="576" alt="frame_manager_264"/></div><br/><figcaption data-caption-side="bottom" class="- topic/title title figcapcenter"><span class="figtitleprefix fig--title-label"><span class="fig--title-label-number"> 5</span><span class="fig--title-label-punctuation">. </span></span><span class="fig--title">frame manager 调用流程H264</span></figcaption></figure>
</li></ol>
</section><section class="- topic/section section" id="mpp_decode__id4" data-ofbid="mpp_decode__id4"><h2 class="- topic/title title sectiontitle"> 物理连续内存使用情况</h2>
<p class="- topic/p p" data-ofbid="d41009e211__20250121171516">H264 解码所需的物理连续内存如下所示:</p>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_ztn_2nt_2dc" data-ofbid="mpp_decode__table_ztn_2nt_2dc" data-cols="3"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 1</span><span class="table--title-label-punctuation">. </span></span><span class="table--title"></span></caption><colgroup><col style="width:34.527687296416936%"/><col style="width:32.57328990228013%"/><col style="width:32.89902280130293%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_ztn_2nt_2dc__entry__1">内存占用模块</th><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_ztn_2nt_2dc__entry__2">计算方式</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_ztn_2nt_2dc__entry__3">说明</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__1">输入码流</td><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__2">-</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__3">大小由应用层配置</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__1">输出帧</td><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__2">width*height*3/2*frame_num</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__3">
<div class="- topic/div div">
<div class="- topic/div div"> frame_num 至少需要(参考帧个数+1</div>
<div class="- topic/div div"> 显示占用个数可由应用层通过 struct decode_config</div>
<div class="- topic/div div"> 结构体中的 extra_frame_num 配置</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__1">帧内预测(需要上一行数据)</td><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">帧格式width*2</div>
<div class="- topic/div div">MBAFFwidth*4</div>
</div>
</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__3">-</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__1">宏块信息</td><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__2">固定 12K</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__3">-</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__1">dblk 模块(上一个宏块行最后 4 行数据)</td><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">帧格式width*8</div>
<div class="- topic/div div">MBAFFwidth*16</div>
</div>
</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__3">-</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__1">co-located 信息</td><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__2">固定 68K</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_ztn_2nt_2dc__entry__3">-</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_ztn_2nt_2dc__entry__1">每一帧 co-located 数据缓存</td><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_ztn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">(width/16)*(height/16)*32*frame_num</div>
</div>
</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_ztn_2nt_2dc__entry__3">-</td></tr></tbody></table></div>
<div class="- topic/note note note note_note" id="mpp_decode__note_ttp_qn3_ddc" data-ofbid="mpp_decode__note_ttp_qn3_ddc"><span class="note__title">注:</span>
<p class="- topic/p p" data-ofbid="d41009e317__20250121171516">co-located 两个 bufferI、P 帧解码时会往 buffer 里写数据B 帧解码时从 buffer 读数据。 如果当前码流中没有 B
帧,这两块内存也需要申请。</p>
</div>
</section><section class="- topic/section section" id="mpp_decode__id5" data-ofbid="mpp_decode__id5"><h2 class="- topic/title title sectiontitle">MPP Decoder 调用流程</h2>
<ol class="- topic/ol ol" id="mpp_decode__ol_ht4_25h_d1c" data-ofbid="mpp_decode__ol_ht4_25h_d1c"><li class="- topic/li li" data-ofbid="d41009e327__20250121171516">在调用 MPP Decoder 的解码函数时,解码模块从 Packet manager 取一笔码流,同时从 Frame maneger 取一个空闲图像
buffer对码流进行解码 并输出图像到图像 buffer。</li><li class="- topic/li li" data-ofbid="d41009e329__20250121171516">解码后,解码模块将码流 buffer 归还 Packet manager将解码图像 buffer 归还 Frame maneger。</li><li class="- topic/li li" data-ofbid="d41009e331__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e333__20250121171516">为保证解码效率,建议调用者创建 3 个线程实现解码功能:</p>
<ul class="- topic/ul ul" id="mpp_decode__ul_sxt_fsh_d1c" data-ofbid="mpp_decode__ul_sxt_fsh_d1c"><li class="- topic/li li" data-ofbid="d41009e337__20250121171516"><span class="+ topic/ph ui-d/uicontrol ph uicontrol">send data thread</span><p class="- topic/p p" data-ofbid="d41009e340__20250121171516">通过 mpp_decoder_get_packet 和
mpp_decoder_put_packet 这两个接口把码流数据送到 packet 管理模块</p></li><li class="- topic/li li" data-ofbid="d41009e342__20250121171516"><span class="+ topic/ph ui-d/uicontrol ph uicontrol">decode thread</span><p class="- topic/p p" data-ofbid="d41009e345__20250121171516">通过调用 mpp_decoder_decode 控制解码,解码库从
packet 管理模块取一笔码流数据,解码完成后,将视频帧送入 frame 管理模块</p></li><li class="- topic/li li" data-ofbid="d41009e347__20250121171516"><span class="+ topic/ph ui-d/uicontrol ph uicontrol">render thread</span><p class="- topic/p p" data-ofbid="d41009e350__20250121171516">通过
<span class="+ topic/keyword pr-d/parmname keyword parmname">mpp_decoder_get_frame</span>
<span class="+ topic/keyword pr-d/parmname keyword parmname">mpp_decoder_put_frame</span> 两个接口从 frame
管理模块获取视频帧,并控制该帧显示时机</p><figure class="- topic/fig fig fignone" id="mpp_decode__fig_pmr_c5h_d1c" data-ofbid="mpp_decode__fig_pmr_c5h_d1c"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="mpp_decode__image_wxt_fsh_d1c" src="../../../images/mpp/mpp_decoder_flow.png" width="384" alt="mpp_decoder_flow"/></div><br/><figcaption data-caption-side="bottom" class="- topic/title title figcapcenter"><span class="figtitleprefix fig--title-label"><span class="fig--title-label-number"> 6</span><span class="fig--title-label-punctuation">. </span></span><span class="fig--title">mpp_decoder 调用流程</span></figcaption></figure></li></ul>
</li></ol>
</section><section class="- topic/section section" id="mpp_decode__id6" data-ofbid="mpp_decode__id6"><h2 class="- topic/title title sectiontitle">MPP Decoder 数据结构</h2>
<ul class="- topic/ul ul" id="mpp_decode__ul_aq3_lfn_4dc" data-ofbid="mpp_decode__ul_aq3_lfn_4dc"><li class="- topic/li li" data-ofbid="d41009e372__20250121171516">
<div class="- topic/div div section" id="mpp_decode__struct-decode-config">
<strong class="+ topic/ph hi-d/b ph b">struct decode_config</strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_f5n_2nt_2dc" data-ofbid="mpp_decode__codeblock_f5n_2nt_2dc"><strong class="hl-keyword">struct</strong> decode_config {
<strong class="hl-keyword">enum</strong> mpp_pixel_format pix_fmt; <em class="hl-comment">// output pixel format</em>
<strong class="hl-keyword">int</strong> bitstream_buffer_size; <em class="hl-comment">// bitstream buffer size in pm</em>
<strong class="hl-keyword">int</strong> packet_count; <em class="hl-comment">// packet number in pm</em>
<strong class="hl-keyword">int</strong> extra_frame_num; <em class="hl-comment">// extra frame number in fm</em>
};</pre><p class="- topic/p p" data-ofbid="d41009e381__20250121171516"><code class="+ topic/ph pr-d/codeph ph codeph">decode_config</code> 结构体用于配置解码器初始化使用的参数。</p><ul class="- topic/ul ul simple" id="mpp_decode__ul_g5n_2nt_2dc" data-ofbid="mpp_decode__ul_g5n_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e386__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e388__20250121171516">pix_fmt 表示解码输出的颜色格式</p>
</li><li class="- topic/li li" data-ofbid="d41009e391__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e393__20250121171516">bitstream_buffer_size 表示存放输入码流缓存的总长度</p>
</li><li class="- topic/li li" data-ofbid="d41009e396__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e398__20250121171516">packet_count 表示 packet manager 中 packet 的最大个数</p>
</li><li class="- topic/li li" data-ofbid="d41009e401__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e403__20250121171516">extra_frame_num 表示解码器额外分配的帧个数,主要用于缓存显示帧以保证显示平滑。</p>
</li></ul>
</div>
</li><li class="- topic/li li" data-ofbid="d41009e408__20250121171516">
<div class="- topic/div div section" id="mpp_decode__struct-mpp-packet">
<strong class="+ topic/ph hi-d/b ph b">struct mpp_packet</strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_h5n_2nt_2dc" data-ofbid="mpp_decode__codeblock_h5n_2nt_2dc"><strong class="hl-keyword">struct</strong> mpp_packet {
<strong class="hl-keyword">void</strong> *data;
<strong class="hl-keyword">int</strong> size;
<strong class="hl-keyword">long</strong> <strong class="hl-keyword">long</strong> pts;
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">int</strong> flag;
};</pre><p class="- topic/p p" data-ofbid="d41009e417__20250121171516"><code class="+ topic/ph pr-d/codeph ph codeph">mpp_packet</code> 结构体用于表示输入码流信息。</p><ul class="- topic/ul ul simple" id="mpp_decode__ul_i5n_2nt_2dc" data-ofbid="mpp_decode__ul_i5n_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e422__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e424__20250121171516">data 表示码流数据存放的起始地址</p>
</li><li class="- topic/li li" data-ofbid="d41009e427__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e429__20250121171516">size 表示该笔码流数据长度</p>
</li><li class="- topic/li li" data-ofbid="d41009e432__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e434__20250121171516">pts 表示该笔码流的时间戳</p>
</li><li class="- topic/li li" data-ofbid="d41009e437__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e439__20250121171516">flag 表示该笔码流的标记位目前仅用于确定该码流是否为最后一笔码流PACKET_FLAG_EOS</p>
</li></ul>
</div>
</li><li class="- topic/li li" data-ofbid="d41009e444__20250121171516">
<div class="- topic/div div section" id="mpp_decode__struct-mpp-frame">
<strong class="+ topic/ph hi-d/b ph b">struct mpp_frame</strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_j5n_2nt_2dc" data-ofbid="mpp_decode__codeblock_j5n_2nt_2dc"><strong class="hl-keyword">struct</strong> mpp_size {
<strong class="hl-keyword">int</strong> width;
<strong class="hl-keyword">int</strong> height;
};
<strong class="hl-keyword">struct</strong> mpp_rect {
<strong class="hl-keyword">int</strong> x;
<strong class="hl-keyword">int</strong> y;
<strong class="hl-keyword">int</strong> width;
<strong class="hl-keyword">int</strong> height;
};
<strong class="hl-keyword">enum</strong> mpp_buf_type {
MPP_DMA_BUF_FD,
MPP_PHY_ADDR,
};
<strong class="hl-keyword">struct</strong> mpp_buf {
<strong class="hl-keyword">enum</strong> mpp_buf_type buf_type;
<strong class="hl-keyword">union</strong> {
<strong class="hl-keyword">int</strong> fd[<span class="hl-number">3</span>];
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">int</strong> phy_addr[<span class="hl-number">3</span>];
};
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">int</strong> stride[<span class="hl-number">3</span>];
<strong class="hl-keyword">struct</strong> mpp_size size;
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">int</strong> crop_en;
<strong class="hl-keyword">struct</strong> mpp_rect crop;
<strong class="hl-keyword">enum</strong> mpp_pixel_format format;
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">int</strong> flags;
};</pre><ul class="- topic/ul ul simple" id="mpp_decode__ul_k5n_2nt_2dc" data-ofbid="mpp_decode__ul_k5n_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e454__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e456__20250121171516">buf_type表示 mpp_buf 类型,以 fd 方式 MPP_DMA_BUF_FD 或 以物理地址方式
MPP_PHY_ADDR</p>
</li><li class="- topic/li li" data-ofbid="d41009e459__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e461__20250121171516">fd[3]:表示 buffer 三个分量的 fd</p>
</li><li class="- topic/li li" data-ofbid="d41009e464__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e466__20250121171516">phy_addr[3]:表示 buffer 三个分量的物理地址</p>
</li><li class="- topic/li li" data-ofbid="d41009e469__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e471__20250121171516">stride[3]:表示 buffer 三个分量的 stride</p>
</li><li class="- topic/li li" data-ofbid="d41009e474__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e476__20250121171516">size表示 buffer 的宽、高</p>
</li><li class="- topic/li li" data-ofbid="d41009e479__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e481__20250121171516">crop_en 表示该 buffer 是否需要 crop</p>
</li><li class="- topic/li li" data-ofbid="d41009e484__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e486__20250121171516">crop表示该 buffer 的 crop 信息</p>
</li><li class="- topic/li li" data-ofbid="d41009e489__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e491__20250121171516">format 表示该 buffer 的颜色格式类型</p>
</li></ul><pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_l5n_2nt_2dc" data-ofbid="mpp_decode__codeblock_l5n_2nt_2dc"><strong class="hl-keyword">struct</strong> mpp_frame {
<strong class="hl-keyword">struct</strong> mpp_buf buf;
<strong class="hl-keyword">long</strong> <strong class="hl-keyword">long</strong> pts;
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">int</strong> id;
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">int</strong> flags;
};</pre>
<ul class="- topic/ul ul simple" id="mpp_decode__ul_m5n_2nt_2dc" data-ofbid="mpp_decode__ul_m5n_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e498__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e500__20250121171516">buf表示 mpp_frame 的 buffer 信息</p>
</li><li class="- topic/li li" data-ofbid="d41009e503__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e505__20250121171516">pts表示 mpp_frame 的时间戳</p>
</li><li class="- topic/li li" data-ofbid="d41009e508__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e510__20250121171516">id表示 mpp_frame 的唯一标识</p>
</li><li class="- topic/li li" data-ofbid="d41009e513__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e515__20250121171516">flags表示 mpp_frame 的标志位</p>
</li></ul>
</div>
</li><li class="- topic/li li" data-ofbid="d41009e520__20250121171516">
<div class="- topic/div div section" id="mpp_decode__enum-mpp-dec-errno">
<strong class="+ topic/ph hi-d/b ph b">enum mpp_dec_errno</strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_n5n_2nt_2dc" data-ofbid="mpp_decode__codeblock_n5n_2nt_2dc"><strong class="hl-keyword">enum</strong> mpp_dec_errno {
DEC_ERR_NOT_SUPPORT = <span class="hl-number">0x90000001</span>,
DEC_ERR_NO_EMPTY_PACKET = <span class="hl-number">0x90000002</span>, <em class="hl-comment">// no packet in empty list</em>
DEC_ERR_NO_READY_PACKET = <span class="hl-number">0x90000003</span>, <em class="hl-comment">//</em>
DEC_ERR_NO_EMPTY_FRAME = <span class="hl-number">0x90000004</span>, <em class="hl-comment">//</em>
DEC_ERR_NO_RENDER_FRAME = <span class="hl-number">0x90000005</span>, <em class="hl-comment">//</em>
DEC_ERR_NULL_PTR = <span class="hl-number">0x90000006</span>,
DEC_ERR_FM_NOT_CREATE = <span class="hl-number">0x90000006</span>,
};</pre><ul class="- topic/ul ul simple" id="mpp_decode__ul_o5n_2nt_2dc" data-ofbid="mpp_decode__ul_o5n_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e530__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e532__20250121171516">DEC_ERR_NOT_SUPPORT该码流不支持</p>
</li><li class="- topic/li li" data-ofbid="d41009e535__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e537__20250121171516">DEC_ERR_NO_EMPTY_PACKETpacket manager 中缺少空闲的 packet可能是解码速度小于送
packet 速度,此时需要等待一段时间;</p>
</li><li class="- topic/li li" data-ofbid="d41009e540__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e542__20250121171516">DEC_ERR_NO_READY_PACKETpacket manager 中缺少填好码流数据的 packet可能是送
packet 速度小于解码速度,此时需要等待一段时间;</p>
</li><li class="- topic/li li" data-ofbid="d41009e545__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e547__20250121171516">DEC_ERR_NO_EMPTY_FRAMEframe manager 中缺少空闲的
frame表示所有帧都处于使用状态通常是解码速度大于显示速度导致此时需要等待一段时间</p>
</li><li class="- topic/li li" data-ofbid="d41009e550__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e552__20250121171516">DEC_ERR_NO_RENDER_FRAMEframe manager 中缺少待显示的
frame表示所有帧都处于空闲状态通常是解码速度小于显示速度导致此时需要等待一段时间</p>
</li><li class="- topic/li li" data-ofbid="d41009e555__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e557__20250121171516">DEC_ERR_NULL_PTR表示接口函数输入参数存在空指针</p>
</li><li class="- topic/li li" data-ofbid="d41009e560__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e562__20250121171516">DEC_ERR_FM_NOT_CREATE表示在获取待显示 frame 时 frame manager 还未创建</p>
</li></ul>
</div>
</li><li class="- topic/li li" data-ofbid="d41009e567__20250121171516">
<div class="- topic/div div section" id="mpp_decode__enum-mpp-codec-type">
<strong class="+ topic/ph hi-d/b ph b">enum mpp_codec_type</strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_p5n_2nt_2dc" data-ofbid="mpp_decode__codeblock_p5n_2nt_2dc"><strong class="hl-keyword">enum</strong> mpp_codec_type {
MPP_CODEC_VIDEO_DECODER_H264 = <span class="hl-number">0x1000</span>, <em class="hl-comment">// decoder</em>
MPP_CODEC_VIDEO_DECODER_MJPEG,
MPP_CODEC_VIDEO_DECODER_PNG,
MPP_CODEC_VIDEO_ENCODER_H264 = <span class="hl-number">0x2000</span>, <em class="hl-comment">// encoder</em>
};</pre><p class="- topic/p p" data-ofbid="d41009e576__20250121171516">mpp_codec_type 枚举类型表示支持的编解码格式。</p>
</div>
</li><li class="- topic/li li" data-ofbid="d41009e580__20250121171516">
<div class="- topic/div div section" id="mpp_decode__enum-mpp-dec-cmd">
<strong class="+ topic/ph hi-d/b ph b">enum mpp_dec_cmd</strong>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_q5n_2nt_2dc" data-ofbid="mpp_decode__codeblock_q5n_2nt_2dc"><strong class="hl-keyword">enum</strong> mpp_dec_cmd {
MPP_DEC_INIT_CMD_SET_EXT_FRAME_ALLOCATOR, <em class="hl-comment">// frame buffer allocator</em>
MPP_DEC_INIT_CMD_SET_ROT_FLIP_FLAG,
MPP_DEC_INIT_CMD_SET_SCALE,
MPP_DEC_INIT_CMD_SET_CROP_INFO,
MPP_DEC_INIT_CMD_SET_OUTPUT_POS,
};</pre><ul class="- topic/ul ul simple" id="mpp_decode__ul_r5n_2nt_2dc" data-ofbid="mpp_decode__ul_r5n_2nt_2dc"><li class="- topic/li li" data-ofbid="d41009e590__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e592__20250121171516"> MPP_DEC_INIT_CMD_SET_EXT_FRAME_ALLOCATOR表示由外部设置帧 buffer 分配器</p>
</li><li class="- topic/li li" data-ofbid="d41009e595__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e597__20250121171516">MPP_DEC_INIT_CMD_SET_ROT_FLIP_FLAG: 表示设置旋转、镜像后处理,只用于 JPEG</p>
</li><li class="- topic/li li" data-ofbid="d41009e600__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e602__20250121171516">MPP_DEC_INIT_CMD_SET_SCALE 表示设置缩放系数,只用于 JPEG</p>
</li><li class="- topic/li li" data-ofbid="d41009e605__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e607__20250121171516">MPP_DEC_INIT_CMD_SET_CROP_INFO表示设置输出 crop 信息</p>
</li><li class="- topic/li li" data-ofbid="d41009e610__20250121171516">
<p class="- topic/p p" data-ofbid="d41009e612__20250121171516"> MPP_DEC_INIT_CMD_SET_OUTPUT_POS表示设置解码图像在输出缓存的位置</p>
</li></ul>
</div>
</li></ul>
</section><section class="- topic/section section" id="mpp_decode__id7" data-ofbid="mpp_decode__id7"><h2 class="- topic/title title sectiontitle">MPP Decoder 接口设计</h2>
<p class="- topic/p p" data-ofbid="d41009e623__20250121171516">接口如下 :</p>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_s5n_2nt_2dc" data-ofbid="mpp_decode__codeblock_s5n_2nt_2dc"><strong class="hl-keyword">struct</strong> decode_config {
<strong class="hl-keyword">enum</strong> mpp_pixel_format pix_fmt; <em class="hl-comment">// output pixel format</em>
<strong class="hl-keyword">int</strong> bitstream_buffer_size; <em class="hl-comment">// bitstream buffer size in pm</em>
<strong class="hl-keyword">int</strong> packet_count; <em class="hl-comment">// packet number in pm</em>
<strong class="hl-keyword">int</strong> extra_frame_num; <em class="hl-comment">// extra frame number in fm</em>
};
<strong class="hl-keyword">struct</strong> mpp_decoder* create_mpp_decoder(<strong class="hl-keyword">enum</strong> mpp_codec_type type);
<strong class="hl-keyword">void</strong> destory_mpp_decoder(<strong class="hl-keyword">struct</strong> mpp_decoder* decoder);
<strong class="hl-keyword">int</strong> mpp_decoder_init(<strong class="hl-keyword">struct</strong> mpp_decoder *decoder, <strong class="hl-keyword">struct</strong> decode_config *config);
<strong class="hl-keyword">int</strong> mpp_decoder_decode(<strong class="hl-keyword">struct</strong> mpp_decoder* decoder);
<strong class="hl-keyword">int</strong> mpp_decoder_control(<strong class="hl-keyword">struct</strong> mpp_decoder* decoder, <strong class="hl-keyword">int</strong> cmd, <strong class="hl-keyword">void</strong> *param);
<strong class="hl-keyword">int</strong> mpp_decoder_reset(<strong class="hl-keyword">struct</strong> mpp_decoder* decoder);
<strong class="hl-keyword">int</strong> mpp_decoder_get_packet(<strong class="hl-keyword">struct</strong> mpp_decoder* decoder, <strong class="hl-keyword">struct</strong> mpp_packet* packet, <strong class="hl-keyword">int</strong> size);
<strong class="hl-keyword">int</strong> mpp_decoder_put_packet(<strong class="hl-keyword">struct</strong> mpp_decoder* decoder, <strong class="hl-keyword">struct</strong> mpp_packet* packet);
<strong class="hl-keyword">int</strong> mpp_decoder_get_frame(<strong class="hl-keyword">struct</strong> mpp_decoder* decoder, <strong class="hl-keyword">struct</strong> mpp_frame* frame);
<strong class="hl-keyword">int</strong> mpp_decoder_put_frame(<strong class="hl-keyword">struct</strong> mpp_decoder* decoder, <strong class="hl-keyword">struct</strong> mpp_frame* frame);</pre>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_t5n_2nt_2dc" data-ofbid="mpp_decode__table_t5n_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 2</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_create</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_t5n_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_t5n_2nt_2dc__entry__2">struct mpp_decoder* mpp_decoder_create(enum mpp_codec_type
type)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_t5n_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_t5n_2nt_2dc__entry__2">创建 mpp_decoder 对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_t5n_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_t5n_2nt_2dc__entry__2">type: 解码器类型</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_t5n_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_t5n_2nt_2dc__entry__2">mpp_decoder 对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_t5n_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_t5n_2nt_2dc__entry__2">-</td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_u5n_2nt_2dc" data-ofbid="mpp_decode__table_u5n_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 3</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_destory</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_u5n_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_u5n_2nt_2dc__entry__2">void mpp_decoder_destory(struct mpp_decoder* decoder)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_u5n_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_u5n_2nt_2dc__entry__2">销毁 mpp_decoder 对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_u5n_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_u5n_2nt_2dc__entry__2">decoder: mpp_decoder 对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_u5n_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_u5n_2nt_2dc__entry__2"></td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_u5n_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_u5n_2nt_2dc__entry__2">-</td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_v5n_2nt_2dc" data-ofbid="mpp_decode__table_v5n_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 4</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_init</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_v5n_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_v5n_2nt_2dc__entry__2">int mpp_decoder_init(struct mpp_decoder *decoder, struct
decode_config *config)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_v5n_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_v5n_2nt_2dc__entry__2">初始化解码器</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_v5n_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_v5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">decoder: mpp_decoder 对象</div>
<div class="- topic/div div"> config解码器的配置参数</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_v5n_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_v5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0:成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_v5n_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_v5n_2nt_2dc__entry__2">-</td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_w5n_2nt_2dc" data-ofbid="mpp_decode__table_w5n_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 5</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_decode</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_w5n_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_w5n_2nt_2dc__entry__2">int mpp_decoder_decode(struct mpp_decoder* decoder)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_w5n_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_w5n_2nt_2dc__entry__2">解码一笔数据</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_w5n_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_w5n_2nt_2dc__entry__2">decoder: mpp_decoder 对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_w5n_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_w5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0:成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_w5n_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_w5n_2nt_2dc__entry__2">- </td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_x5n_2nt_2dc" data-ofbid="mpp_decode__table_x5n_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 6</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_control</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_x5n_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_x5n_2nt_2dc__entry__2">int mpp_decoder_control(struct mpp_decoder* decoder, int cmd,
void* param)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_x5n_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_x5n_2nt_2dc__entry__2">向 mpp_decoder 对象发送控制命令</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_x5n_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_x5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div"><span class="+ topic/keyword pr-d/parmname keyword parmname">decoder</span>: mpp_decoder 对象</div>
<div class="- topic/div div"><span class="+ topic/keyword pr-d/parmname keyword parmname">cmd</span>: 控制命令类型</div>
<div class="- topic/div div"><span class="+ topic/keyword pr-d/parmname keyword parmname">param</span>: 控制参数</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_x5n_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_x5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0:成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_x5n_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_x5n_2nt_2dc__entry__2">- </td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_y5n_2nt_2dc" data-ofbid="mpp_decode__table_y5n_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 7</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_reset</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_y5n_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_y5n_2nt_2dc__entry__2">int mpp_decoder_reset(struct mpp_decoder* decoder)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_y5n_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_y5n_2nt_2dc__entry__2">重置 mpp_decoder 对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_y5n_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_y5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">decoder: mpp_decoder 对象</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_y5n_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_y5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0:成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_y5n_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_y5n_2nt_2dc__entry__2">- </td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_z5n_2nt_2dc" data-ofbid="mpp_decode__table_z5n_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 8</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_get_packet</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_z5n_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_z5n_2nt_2dc__entry__2">int mpp_decoder_get_packet(struct mpp_decoder* decoder, struct
mpp_packet* packet, int size)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_z5n_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_z5n_2nt_2dc__entry__2">获取一个写码流数据的 packet</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_z5n_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_z5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">decoder: mpp_decoder 对象</div>
<div class="- topic/div div"> packet:码流数据结构指针</div>
<div class="- topic/div div"> size:上层应用申请 packet 的 buffer 大小</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_z5n_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_z5n_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0:成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_z5n_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_z5n_2nt_2dc__entry__2">- </td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_avn_2nt_2dc" data-ofbid="mpp_decode__table_avn_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 9</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_put_packet</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_avn_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_avn_2nt_2dc__entry__2">int mpp_decoder_put_packet(struct mpp_decoder* decoder, struct
mpp_packet* packet)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_avn_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_avn_2nt_2dc__entry__2">归还码流数据的 packet 对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_avn_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_avn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">decoder: mpp_decoder 对象</div>
<div class="- topic/div div"> packet:码流数据结构指针</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_avn_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_avn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0:成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_avn_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_avn_2nt_2dc__entry__2">- </td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_bvn_2nt_2dc" data-ofbid="mpp_decode__table_bvn_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 10</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_get_frame</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_bvn_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_bvn_2nt_2dc__entry__2">int mpp_decoder_get_frame(struct mpp_decoder* decoder, struct
mpp_frame* frame)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_bvn_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_bvn_2nt_2dc__entry__2">获取一个视频帧对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_bvn_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_bvn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">decoder: mpp_decoder 对象</div>
<div class="- topic/div div"> frame:视频帧数据结构指针</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_bvn_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_bvn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0:成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_bvn_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_bvn_2nt_2dc__entry__2">- </td></tr></tbody></table></div>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_cvn_2nt_2dc" data-ofbid="mpp_decode__table_cvn_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 11</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_decoder_put_frame</span></caption><colgroup><col style="width:22.98850574712644%"/><col style="width:77.01149425287358%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_cvn_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_cvn_2nt_2dc__entry__2">int mpp_decoder_put_frame(struct mpp_decoder* decoder, struct
mpp_frame* frame)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_cvn_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_cvn_2nt_2dc__entry__2">归还视频帧对象</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_cvn_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_cvn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">decoder: mpp_decoder 对象</div>
<div class="- topic/div div"> frame:视频帧数据结构指针</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_cvn_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_cvn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0:成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_cvn_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_cvn_2nt_2dc__entry__2">-</td></tr></tbody></table></div>
</section><section class="- topic/section section" id="mpp_decode__mpp_decoder-demo" data-ofbid="mpp_decode__mpp_decoder-demo"><h2 class="- topic/title title sectiontitle">MPP Decoder 参考 Demo</h2>
<div class="- topic/p p" id="mpp_decode__ref-picture-decoder-test" data-ofbid="mpp_decode__ref-picture-decoder-test">以下 Demo 为基本流程调用,具体实现可以参考代码
<span class="+ topic/ph sw-d/filepath ph filepath">mpp/mpp_test/picture_decoder_test.c</span><pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="mpp_decode__codeblock_cfs_scw_3dc" data-ofbid="mpp_decode__codeblock_cfs_scw_3dc"><em class="hl-comment">//* 1.创建 mpp_decoder 对象</em>
<strong class="hl-keyword">struct</strong> mpp_decoder* dec = mpp_decoder_create(type);
<strong class="hl-keyword">struct</strong> decode_config config;
config.bitstream_buffer_size = (file_len + <span class="hl-number">1023</span>) &amp; (~<span class="hl-number">1023</span>);
config.extra_frame_num = <span class="hl-number">0</span>;
config.packet_count = <span class="hl-number">1</span>;
config.pix_fmt = MPP_FMT_ARGB_<span class="hl-number">8888</span>;
<em class="hl-comment">//* 2. 初始化 mpp_decoder</em>
mpp_decoder_init(dec, &amp;config);
<em class="hl-comment">//* 3. 获取一个空的 packet</em>
<strong class="hl-keyword">struct</strong> mpp_packet packet;
memset(&amp;packet, <span class="hl-number">0</span>, <strong class="hl-keyword">sizeof</strong>(<strong class="hl-keyword">struct</strong> mpp_packet));
mpp_decoder_get_packet(dec, &amp;packet, file_len);
<em class="hl-comment">//* 4. 把视频码流数据拷贝到 packet</em>
fread(packet.data, <span class="hl-number">1</span>, file_len, fp);
packet.size = file_len;
packet.flag = PACKET_FLAG_EOS;
<em class="hl-comment">//* 5. 归还 packet</em>
mpp_decoder_put_packet(dec, &amp;packet);
<em class="hl-comment">//* 6. 解码该笔码流数据</em>
mpp_decoder_decode(dec);
<em class="hl-comment">//* 7. 获取解码后视频帧数据</em>
<strong class="hl-keyword">struct</strong> mpp_frame frame;
memset(&amp;frame, <span class="hl-number">0</span>, <strong class="hl-keyword">sizeof</strong>(<strong class="hl-keyword">struct</strong> mpp_frame));
mpp_decoder_get_frame(dec, &amp;frame);
<em class="hl-comment">//* 8. 显示该视频帧</em>
<em class="hl-comment">// render_frame...</em>
<em class="hl-comment">//* 9. 归还该视频帧</em>
mpp_decoder_put_frame(dec, &amp;frame);
<em class="hl-comment">//* 10. 销毁 mpp_decoder</em>
mpp_decoder_destory(dec);</pre></div>
</section><section class="- topic/section section" id="mpp_decode__id8" data-ofbid="mpp_decode__id8"><h2 class="- topic/title title sectiontitle">接口设计</h2>
<p class="- topic/p p" data-ofbid="d41009e1132__20250121171516">输出 JPEG 图片的缓存 buffer 由调用者申请,但调用者并不知道编码后图片的实际大小, 为避免 VE 写输出数据时越界,该 buffer
需要预先申请较大的内存。</p>
<div class="table-container"><table class="- topic/table table frame-all" id="mpp_decode__table_evn_2nt_2dc" data-ofbid="mpp_decode__table_evn_2nt_2dc" data-cols="2"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 12</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">mpp_encode_jpeg</span></caption><colgroup><col style="width:16.666666666666664%"/><col style="width:83.33333333333334%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="mpp_decode__table_evn_2nt_2dc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="mpp_decode__table_evn_2nt_2dc__entry__2">int mpp_encode_jpeg(struct mpp_frame* frame, int quality, int
dma_buf_fd, int buf_len, int* len)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_evn_2nt_2dc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_evn_2nt_2dc__entry__2">编码一帧 JPEG 图片</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_evn_2nt_2dc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_evn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">frame: 待编码的原始 YUV 数据</div>
<div class="- topic/div div">quality: 编码质量,取值范围 1~1001 表示编码图片质量最差100 表示最好</div>
<div class="- topic/div div">dma_buf_fd输出 JPEG 图片存放的 dma-buf fd</div>
<div class="- topic/div div">buf_len输出 JPEG 图片 dma-buf 的长度</div>
<div class="- topic/div div">len: 输出 JPEG 图片的真实大小</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="mpp_decode__table_evn_2nt_2dc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="mpp_decode__table_evn_2nt_2dc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">0: 成功</div>
<div class="- topic/div div">&lt;0:失败</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="mpp_decode__table_evn_2nt_2dc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="mpp_decode__table_evn_2nt_2dc__entry__2">-</td></tr></tbody></table></div>
</section></div></article></main></div>
</div>
<nav role="navigation" id="wh_topic_toc" aria-label="On this page" class="col-lg-2 d-none d-lg-block navbar d-print-none">
<div id="wh_topic_toc_content">
<div class=" wh_topic_toc "><div class="wh_topic_label">在本页上</div><ul><li class="section-item"><div class="section-title"><a href="#mpp_decode__packet" data-tocid="mpp_decode__packet">Packet 管理机制</a></div></li><li class="section-item"><div class="section-title"><a href="#mpp_decode__frame" data-tocid="mpp_decode__frame">Frame 管理机制</a></div></li><li class="section-item"><div class="section-title"><a href="#mpp_decode__id4" data-tocid="mpp_decode__id4"> 物理连续内存使用情况</a></div></li><li class="section-item"><div class="section-title"><a href="#mpp_decode__id5" data-tocid="mpp_decode__id5">MPP Decoder 调用流程</a></div></li><li class="section-item"><div class="section-title"><a href="#mpp_decode__id6" data-tocid="mpp_decode__id6">MPP Decoder 数据结构</a></div></li><li class="section-item"><div class="section-title"><a href="#mpp_decode__id7" data-tocid="mpp_decode__id7">MPP Decoder 接口设计</a></div></li><li class="section-item"><div class="section-title"><a href="#mpp_decode__mpp_decoder-demo" data-tocid="mpp_decode__mpp_decoder-demo">MPP Decoder 参考 Demo</a></div></li><li class="section-item"><div class="section-title"><a href="#mpp_decode__id8" data-tocid="mpp_decode__id8">接口设计</a></div></li></ul></div>
</div>
</nav>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-21
</div>
</div>
</div>
</footer>
<div id="go2top" class="d-print-none">
<span class="oxy-icon oxy-icon-up"></span>
</div>
<div id="modal_img_large" class="modal">
<span class="close oxy-icon oxy-icon-remove"></span>
<div id="modal_img_container"></div>
<div id="caption"></div>
</div>
<script src="${pd}/publishing/publishing-styles-AIC-template/js/custom.js" defer="defer"></script>
</body>
</html>