﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-蜗牛的家</title><link>http://www.cppblog.com/bangle/</link><description>男儿当自强</description><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 09:37:17 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 09:37:17 GMT</pubDate><ttl>60</ttl><item><title>UML基础知识</title><link>http://www.cppblog.com/bangle/archive/2011/04/27/145141.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Wed, 27 Apr 2011 06:24:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2011/04/27/145141.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/145141.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2011/04/27/145141.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/145141.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/145141.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: UML基础知识&nbsp;UML简介在80年代末至90年代中，对面向对象分析与设计方法的研究发展到一个高潮。但是，诸多流派在思想和术语上有很多不同的提法，在术语、概念上的运用也各不相同，需要一种统一的符号来描述面向对象的分析和设计活动。UML应运而生。它不仅统一了Booch、Rumbaugh和Jacobson的表示方法，而且有进一步的发展，最终成为大众所共同接受的标准建模语言。统一建模...&nbsp;&nbsp;<a href='http://www.cppblog.com/bangle/archive/2011/04/27/145141.html'>阅读全文</a><img src ="http://www.cppblog.com/bangle/aggbug/145141.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2011-04-27 14:24 <a href="http://www.cppblog.com/bangle/archive/2011/04/27/145141.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>lamda的简单实现</title><link>http://www.cppblog.com/bangle/archive/2011/03/22/142527.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Tue, 22 Mar 2011 15:47:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2011/03/22/142527.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/142527.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2011/03/22/142527.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/142527.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/142527.html</trackback:ping><description><![CDATA[所谓Lambda，简单的说是快速的小函数生成.<br>在STL的算法中很多地方需要提供一个函数对象或仿函数如for_each<br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><span style="color: #000000;">for_each(v.begin(),&nbsp;v.end(),&nbsp;op());&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">原格式如此<br></span></div>
如果需要不用的算法就需要些不同的函数对象，但是引用了万能的lambda后效果就不同了,效果如下<br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><span style="color: #000000;">for_each(v.begin(),&nbsp;v.end(),&nbsp;_1</span><span style="color: #000000;">=</span><span style="color: #000000;">2</span><span style="color: #000000;">);&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">_1=2是一个仿函数,通过重载=实现<br></span></div>
需要的操作一目了然，简单分析下for_each第三个参数需要的是一个函数或仿函数，所以_1=2必然产生的是一个仿函数,大致可以推出是重载了=实现的产生仿函数，那么真正的操作还需要一个封装，即需要两个类实现，第一个类大致如下<br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;place_holder<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">重载需要的算法操作</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">typename&nbsp;R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;op</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">operator</span><span style="color: #000000;">=</span><span style="color: #000000;">(R&nbsp;i)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;op</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(i);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>};</span></div>
模板使得这个结构可以传入任何类型的参数，通过重载=操作内部返回了一个仿函数，具体的操作由一下的仿函数实现<br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><span style="color: #008000;">//</span><span style="color: #008000;">仿函数，即重载了()操作的类</span><span style="color: #008000;"><br></span><span style="color: #000000;">template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">typename&nbsp;T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;op<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;op(T&nbsp;i):&nbsp;_i(i)&nbsp;{}<br>&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;</span><span style="color: #0000ff;">operator</span><span style="color: #000000;">()(T&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">i)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;_i;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;_i;<br>};</span></div>
这个仿函数将传入的引用参数进行了赋值操作，实现了最终的操作.<br>以上的代码实现=操作如果需要其他操作则重载相应的操作例如+=<br>依次类推占位类实现+=并通过仿函数可以实现+=的操作以下是完成的代码<br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;lambda.cpp&nbsp;:&nbsp;定义控制台应用程序的入口点。<br></span><span style="color: #008000;">//<br></span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">stdafx.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">vector</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">algorithm</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br><br></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">namespace</span><span style="color: #000000;">&nbsp;std;<br><br></span><span style="color: #008000;">//</span><span style="color: #008000;">仿函数，即重载了()操作的类</span><span style="color: #008000;"><br></span><span style="color: #000000;">template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">typename&nbsp;T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;op<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;op(T&nbsp;i):&nbsp;_i(i)&nbsp;{}<br>&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;</span><span style="color: #0000ff;">operator</span><span style="color: #000000;">()(T&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">i)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;_i;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;_i;<br>};<br>template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">typename&nbsp;T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;op1<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;op1(T&nbsp;i):_i(i){}<br>&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;</span><span style="color: #0000ff;">operator</span><span style="color: #000000;">()(T&nbsp;</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">i)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;i&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;_i;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;_i;<br>};<br><br></span><span style="color: #008000;">//</span><span style="color: #008000;">占位符</span><span style="color: #008000;"><br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;place_holder<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">重载需要的算法操作</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">typename&nbsp;R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;op</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">operator</span><span style="color: #000000;">=</span><span style="color: #000000;">(R&nbsp;i)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;op</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(i);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">typename&nbsp;R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;op1</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">operator</span><span style="color: #000000;">+=</span><span style="color: #000000;">(R&nbsp;i)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;op1</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">R</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(i);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>};<br><br>place_holder&nbsp;_1;<br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;_tmain(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;argc,&nbsp;_TCHAR</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;argv[])<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;vector</span><span style="color: #000000;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;v;<br>&nbsp;&nbsp;&nbsp;&nbsp;v.push_back(</span><span style="color: #000000;">1</span><span style="color: #000000;">);<br>&nbsp;&nbsp;&nbsp;&nbsp;v.push_back(</span><span style="color: #000000;">2</span><span style="color: #000000;">);<br>&nbsp;&nbsp;&nbsp;&nbsp;v.push_back(</span><span style="color: #000000;">3</span><span style="color: #000000;">);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">for_each(v.begin(),&nbsp;v.end(),&nbsp;op());&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">原格式如此</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;for_each(v.begin(),&nbsp;v.end(),&nbsp;_1</span><span style="color: #000000;">=</span><span style="color: #000000;">2</span><span style="color: #000000;">);&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">_1=2是一个仿函数,通过重载=实现</span><span style="color: #008000;"><br></span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}</span></div>
<br><br>    <img src ="http://www.cppblog.com/bangle/aggbug/142527.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2011-03-22 23:47 <a href="http://www.cppblog.com/bangle/archive/2011/03/22/142527.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>bind函数的简单实现</title><link>http://www.cppblog.com/bangle/archive/2011/03/22/142526.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Tue, 22 Mar 2011 15:46:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2011/03/22/142526.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/142526.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2011/03/22/142526.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/142526.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/142526.html</trackback:ping><description><![CDATA[<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">stdafx.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">algorithm</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">iostream</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">vector</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br><br></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">namespace</span><span style="color: #000000;">&nbsp;std;<br><br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;">&nbsp;Person<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;Person(</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">&nbsp;name)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;name_(name)<br>&nbsp;&nbsp;&nbsp;&nbsp;{}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;Name()<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;name_;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;SetName(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;name)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name_&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;name;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;name_;<br>};<br><br>template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">typename&nbsp;R,&nbsp;typename&nbsp;T,&nbsp;typename&nbsp;Arg</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">class</span><span style="color: #000000;">&nbsp;simple_binder<br>{<br></span><span style="color: #0000ff;">public</span><span style="color: #000000;">:<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">explicit</span><span style="color: #000000;">&nbsp;simple_binder(R&nbsp;(T::</span><span style="color: #000000;">*</span><span style="color: #000000;">pfn)(Arg),&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;Arg</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">&nbsp;arg)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;pfn_(pfn)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;arg_(arg)<br>&nbsp;&nbsp;&nbsp;&nbsp;{}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;R&nbsp;</span><span style="color: #0000ff;">operator</span><span style="color: #000000;">()(T</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">&nbsp;t)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;(t.</span><span style="color: #000000;">*</span><span style="color: #000000;">pfn_)(arg_);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br></span><span style="color: #0000ff;">private</span><span style="color: #000000;">:<br>&nbsp;&nbsp;&nbsp;&nbsp;R&nbsp;(T::</span><span style="color: #000000;">*</span><span style="color: #000000;">pfn_)(Arg);<br>&nbsp;&nbsp;&nbsp;&nbsp;Arg&nbsp;arg_;<br>};<br><br>template&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">typename&nbsp;R,&nbsp;typename&nbsp;T,&nbsp;typename&nbsp;Arg</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>simple_binder</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">R,&nbsp;T,&nbsp;Arg</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>simple_bind(&nbsp;R&nbsp;(T::</span><span style="color: #000000;">*</span><span style="color: #000000;">pfn)(Arg),&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;Arg</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">&nbsp;arg)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;simple_binder</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">R,&nbsp;T,&nbsp;Arg</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(pfn,&nbsp;arg);<br>}<br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;main()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;Person&nbsp;person(</span><span style="color: #000000;">"</span><span style="color: #000000;">Ralph</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">smimple_bind生成一个仿函数类，这个类构造时赋值了arg<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">遇到(person)时，调用这个仿函数类重载的()操作即<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">t.*pfn(arg)<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">又回归为一个函数，不过参数可以自己控制了,娃哈哈</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;simple_bind(</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">Person::SetName,&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">(</span><span style="color: #000000;">"</span><span style="color: #000000;">Martin</span><span style="color: #000000;">"</span><span style="color: #000000;">))(person);<br>&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000;">&lt;&lt;</span><span style="color: #000000;">&nbsp;person.Name()&nbsp;</span><span style="color: #000000;">&lt;&lt;</span><span style="color: #000000;">&nbsp;endl;<br>}</span></div>
<br><img src ="http://www.cppblog.com/bangle/aggbug/142526.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2011-03-22 23:46 <a href="http://www.cppblog.com/bangle/archive/2011/03/22/142526.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>RGB、YUY2、YUYV、YVYU、UYVY与AYUV（转）</title><link>http://www.cppblog.com/bangle/archive/2009/07/07/89475.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Tue, 07 Jul 2009 10:19:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2009/07/07/89475.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/89475.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2009/07/07/89475.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/89475.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/89475.html</trackback:ping><description><![CDATA[<p>计算机彩色显示器显示色彩的原理与彩色电视机一样，都是采用R（Red）、G（Green）、B（Blue）相加混色的原理：通过发射出三种不同强度的电子束，使屏幕内侧覆盖的红、绿、蓝磷光材料发光而产生色彩。这种色彩的表示方法称为RGB色彩空间表示（它也是多媒体计算机技术中用得最多的一种色彩空间表示方法）。<br>根据三基色原理，任意一种色光F都可以用不同分量的R、G、B三色相加混合而成。<br><br>F = r [ R ] + g [ G ] + b [ B ]<br><br>其中，r、g、b分别为三基色参与混合的系数。当三基色分量都为0（最弱）时混合为黑色光；而当三基色分量都为k（最强）时混合为白色光。调整r、g、b三个系数的值，可以混合出介于黑色光和白色光之间的各种各样的色光。<br>那么YUV又从何而来呢？在现代彩色电视系统中，通常采用三管彩色摄像机或彩色CCD摄像机进行摄像，然后把摄得的彩色图像信号经分色、分别放大校正后得到RGB，再经过矩阵变换电路得到亮度信号Y和两个色差信号R－Y（即U）、B－Y（即V），最后发送端将亮度和色差三个信号分别进行编码，用同一信道发送出去。这种色彩的表示方法就是所谓的YUV色彩空间表示。<br>采用YUV色彩空间的重要性是它的亮度信号Y和色度信号U、V是分离的。如果只有Y信号分量而没有U、V分量，那么这样表示的图像就是黑白灰度图像。彩色电视采用YUV空间正是为了用亮度信号Y解决彩色电视机与黑白电视机的兼容问题，使黑白电视机也能接收彩色电视信号。<br>YUV与RGB相互转换的公式如下（RGB取值范围均为0-255）：<br><br>Y = 0.299R + 0.587G + 0.114B<br>U = -0.147R - 0.289G + 0.436B<br>V = 0.615R - 0.515G - 0.100B<br><br>R = Y + 1.14V<br>G = Y - 0.39U - 0.58V<br>B = Y + 2.03U<br><br>在DirectShow中，常见的RGB格式有RGB1、RGB4、RGB8、RGB565、RGB555、RGB24、RGB32、ARGB32等；常见的YUV格式有YUY2、YUYV、YVYU、UYVY、AYUV、Y41P、Y411、Y211、IF09、IYUV、YV12、YVU9、 YUV411、YUV420等。作为视频媒体类型的辅助说明类型（Subtype），它们对应的GUID见表2.3。<br><br>表2.3 常见的RGB和YUV格式<br><br>GUID&nbsp; &nbsp; 格式描述<br>MEDIASUBTYPE_RGB1&nbsp; &nbsp; 2色，每个像素用1位表示，需要调色板<br>MEDIASUBTYPE_RGB4&nbsp; &nbsp; 16色，每个像素用4位表示，需要调色板<br>MEDIASUBTYPE_RGB8&nbsp; &nbsp; 256色，每个像素用8位表示，需要调色板<br>MEDIASUBTYPE_RGB565&nbsp; &nbsp; 每个像素用16位表示，RGB分量分别使用5位、6位、5位<br>MEDIASUBTYPE_RGB555&nbsp; &nbsp; 每个像素用16位表示，RGB分量都使用5位（剩下的1位不用）<br>MEDIASUBTYPE_RGB24&nbsp; &nbsp; 每个像素用24位表示，RGB分量各使用8位<br>MEDIASUBTYPE_RGB32&nbsp; &nbsp; 每个像素用32位表示，RGB分量各使用8位（剩下的8位不用）<br>MEDIASUBTYPE_ARGB32&nbsp; &nbsp; 每个像素用32位表示，RGB分量各使用8位（剩下的8位用于表示Alpha通道值）<br>MEDIASUBTYPE_YUY2&nbsp; &nbsp; YUY2格式，以4:2:2方式打包<br>MEDIASUBTYPE_YUYV&nbsp; &nbsp; YUYV格式（实际格式与YUY2相同）<br>MEDIASUBTYPE_YVYU&nbsp; &nbsp; YVYU格式，以4:2:2方式打包<br>MEDIASUBTYPE_UYVY&nbsp; &nbsp; UYVY格式，以4:2:2方式打包<br>MEDIASUBTYPE_AYUV&nbsp; &nbsp; 带Alpha通道的4:4:4 YUV格式<br>MEDIASUBTYPE_Y41P&nbsp; &nbsp; Y41P格式，以4:1:1方式打包<br>MEDIASUBTYPE_Y411&nbsp; &nbsp; Y411格式（实际格式与Y41P相同）<br>MEDIASUBTYPE_Y211&nbsp; &nbsp; Y211格式<br>MEDIASUBTYPE_IF09&nbsp; &nbsp; IF09格式<br>MEDIASUBTYPE_IYUV&nbsp; &nbsp; IYUV格式<br>MEDIASUBTYPE_YV12&nbsp; &nbsp; YV12格式<br>MEDIASUBTYPE_YVU9&nbsp; &nbsp; YVU9格式<br><br>下面分别介绍各种RGB格式。<br><br>&#168;RGB1、RGB4、RGB8都是调色板类型的RGB格式，在描述这些媒体类型的格式细节时，通常会在BITMAPINFOHEADER数据结构后面跟着一个调色板（定义一系列颜色）。它们的图像数据并不是真正的颜色值，而是当前像素颜色值在调色板中的索引。以RGB1（2色位图）为例，比如它的调色板中定义的两种颜色值依次为0x000000（黑色）和0xFFFFFF（白色），那么图像数据001101010111&#8230;（每个像素用1位表示）表示对应各像素的颜色为：黑黑白白黑白黑白黑白白白&#8230;。<br><br>&#168; RGB565使用16位表示一个像素，这16位中的5位用于R，6位用于G，5位用于B。程序中通常使用一个字（WORD，一个字等于两个字节）来操作一个像素。当读出一个像素后，这个字的各个位意义如下：<br>高字节&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;低字节<br>R R R R R G G G&nbsp; &nbsp;&nbsp;&nbsp;G G G B B B B B<br>可以组合使用屏蔽字和移位操作来得到RGB各分量的值：<br><br>#define RGB565_MASK_RED&nbsp; &nbsp; 0xF800<br>#define RGB565_MASK_GREEN&nbsp;&nbsp;0x07E0<br>#define RGB565_MASK_BLUE&nbsp; &nbsp;0x001F<br>R = (wPixel &amp; RGB565_MASK_RED) &gt;&gt; 11;&nbsp; &nbsp;// 取值范围0-31<br>G = (wPixel &amp; RGB565_MASK_GREEN) &gt;&gt; 5;&nbsp;&nbsp;// 取值范围0-63<br>B =&nbsp;&nbsp;wPixel &amp; RGB565_MASK_BLUE;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// 取值范围0-31<br><br>&#168; RGB555是另一种16位的RGB格式，RGB分量都用5位表示（剩下的1位不用）。使用一个字读出一个像素后，这个字的各个位意义如下：<br>高字节&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 低字节<br>X R R R R G G&nbsp; &nbsp;&nbsp; &nbsp; G G G B B B B B&nbsp; &nbsp;&nbsp; &nbsp; （X表示不用，可以忽略）<br>可以组合使用屏蔽字和移位操作来得到RGB各分量的值：<br><br>#define RGB555_MASK_RED&nbsp; &nbsp; 0x7C00<br>#define RGB555_MASK_GREEN&nbsp;&nbsp;0x03E0<br>#define RGB555_MASK_BLUE&nbsp; &nbsp;0x001F<br>R = (wPixel &amp; RGB555_MASK_RED) &gt;&gt; 10;&nbsp; &nbsp;// 取值范围0-31<br>G = (wPixel &amp; RGB555_MASK_GREEN) &gt;&gt; 5;&nbsp;&nbsp;// 取值范围0-31<br>B =&nbsp;&nbsp;wPixel &amp; RGB555_MASK_BLUE;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// 取值范围0-31<br><br>&#168; RGB24使用24位来表示一个像素，RGB分量都用8位表示，取值范围为0-255。注意在内存中RGB各分量的排列顺序为：BGR BGR BGR&#8230;。通常可以使用RGBTRIPLE数据结构来操作一个像素，它的定义为：<br><br>typedef struct tagRGBTRIPLE { <br>BYTE rgbtBlue;&nbsp; &nbsp; // 蓝色分量<br>BYTE rgbtGreen;&nbsp; &nbsp;// 绿色分量<br>BYTE rgbtRed;&nbsp; &nbsp;&nbsp;&nbsp;// 红色分量<br>} RGBTRIPLE;<br><br>&#168; RGB32使用32位来表示一个像素，RGB分量各用去8位，剩下的8位用作Alpha通道或者不用。（ARGB32就是带Alpha通道的 RGB32。）注意在内存中RGB各分量的排列顺序为：BGRA BGRABGRA&#8230;。通常可以使用RGBQUAD数据结构来操作一个像素，它的定义为：<br><br>typedef struct tagRGBQUAD {<br>BYTE&nbsp; &nbsp; rgbBlue;&nbsp; &nbsp;&nbsp; &nbsp;// 蓝色分量<br>BYTE&nbsp; &nbsp; rgbGreen;&nbsp; &nbsp;&nbsp;&nbsp;// 绿色分量<br>BYTE&nbsp; &nbsp; rgbRed;&nbsp; &nbsp;&nbsp; &nbsp; // 红色分量<br>BYTE&nbsp; &nbsp; rgbReserved;&nbsp;&nbsp;// 保留字节（用作Alpha通道或忽略）<br>} RGBQUAD;<br><br>下面介绍各种YUV格式。YUV格式通常有两大类：打包（packed）格式和平面（planar）格式。前者将YUV分量存放在同一个数组中，通常是几个相邻的像素组成一个宏像素（macro-pixel）；而后者使用三个数组分开存放YUV三个分量，就像是一个三维平面一样。表2.3中的YUY2到 Y211都是打包格式，而IF09到YVU9都是平面格式。（注意：在介绍各种具体格式时，YUV各分量都会带有下标，如Y0、U0、V0表示第一个像素的YUV分量，Y1、U1、V1表示第二个像素的YUV分量，以此类推。）<br><br>&#168; YUY2（和YUYV）格式为每个像素保留Y分量，而UV分量在水平方向上每两个像素采样一次。一个宏像素为4个字节，实际表示2个像素。（4:2:2的意思为一个宏像素中有4个Y分量、2个U分量和2个V分量。）图像数据中YUV分量排列顺序如下：<br>Y0 U0 Y1 V0&nbsp; &nbsp; Y2 U2 Y3 V2 &#8230;<br><br>&#168; YVYU格式跟YUY2类似，只是图像数据中YUV分量的排列顺序有所不同：<br>Y0 V0 Y1 U0&nbsp; &nbsp; Y2 V2 Y3 U2 &#8230;<br><br>&#168; UYVY格式跟YUY2类似，只是图像数据中YUV分量的排列顺序有所不同：<br>U0 Y0 V0 Y1&nbsp; &nbsp; U2 Y2 V2 Y3 &#8230;<br><br>&#168; AYUV格式带有一个Alpha通道，并且为每个像素都提取YUV分量，图像数据格式如下：<br>A0 Y0 U0 V0&nbsp; &nbsp; A1 Y1 U1 V1 &#8230;<br><br>&#168; Y41P（和Y411）格式为每个像素保留Y分量，而UV分量在水平方向上每4个像素采样一次。一个宏像素为12个字节，实际表示8个像素。图像数据中YUV分量排列顺序如下：<br>U0 Y0 V0 Y1&nbsp; &nbsp; U4 Y2 V4 Y3&nbsp; &nbsp; Y4 Y5 Y6 Y8 &#8230; <br><br>&#168; Y211格式在水平方向上Y分量每2个像素采样一次，而UV分量每4个像素采样一次。一个宏像素为4个字节，实际表示4个像素。图像数据中YUV分量排列顺序如下：<br>Y0 U0 Y2 V0&nbsp; &nbsp; Y4 U4 Y6 V4 &#8230;<br><br>&#168; YVU9格式为每个像素都提取Y分量，而在UV分量的提取时，首先将图像分成若干个4 x 4的宏块，然后每个宏块提取一个U分量和一个V分量。图像数据存储时，首先是整幅图像的Y分量数组，然后就跟着U分量数组，以及V分量数组。IF09格式与YVU9类似。<br><br>&#168; IYUV格式为每个像素都提取Y分量，而在UV分量的提取时，首先将图像分成若干个2 x 2的宏块，然后每个宏块提取一个U分量和一个V分量。YV12格式与IYUV类似。<br><br>&#168;YUV411、YUV420格式多见于DV数据中，前者用于NTSC制，后者用于PAL制。YUV411为每个像素都提取Y分量，而UV分量在水平方向上每4个像素采样一次。YUV420并非V分量采样为0，而是跟YUV411相比，在水平方向上提高一倍色差采样频率，在垂直方向上以U/V间隔的方式减小一半色差采样。<br></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #008000">//</span><span style="COLOR: #008000">YUV转UYVY格式</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;YUVtoUYVY(uint8_t&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">y_plane,&nbsp;uint8_t&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">u_plane,&nbsp;uint8_t&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">v_plane,&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;y_stride,&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;uv_stride,&nbsp;OUT&nbsp;uint8_t&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">pDstBuf,&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;width,&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;height)<br><img id=Codehighlighter1_164_490_Open_Image onclick="this.style.display='none'; Codehighlighter1_164_490_Open_Text.style.display='none'; Codehighlighter1_164_490_Closed_Image.style.display='inline'; Codehighlighter1_164_490_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_164_490_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_164_490_Closed_Text.style.display='none'; Codehighlighter1_164_490_Open_Image.style.display='inline'; Codehighlighter1_164_490_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_164_490_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_164_490_Open_Text><span style="COLOR: #000000">{<br><img id=Codehighlighter1_214_488_Open_Image onclick="this.style.display='none'; Codehighlighter1_214_488_Open_Text.style.display='none'; Codehighlighter1_214_488_Closed_Image.style.display='inline'; Codehighlighter1_214_488_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_214_488_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_214_488_Closed_Text.style.display='none'; Codehighlighter1_214_488_Open_Image.style.display='inline'; Codehighlighter1_214_488_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;row&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;&nbsp;row&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">&nbsp;height;&nbsp;row&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;row&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)&nbsp;</span><span id=Codehighlighter1_214_488_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_214_488_Open_Text><span style="COLOR: #000000">{<br><img id=Codehighlighter1_262_485_Open_Image onclick="this.style.display='none'; Codehighlighter1_262_485_Open_Text.style.display='none'; Codehighlighter1_262_485_Closed_Image.style.display='inline'; Codehighlighter1_262_485_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_262_485_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_262_485_Closed_Text.style.display='none'; Codehighlighter1_262_485_Open_Image.style.display='inline'; Codehighlighter1_262_485_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;col&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;&nbsp;col&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">&nbsp;width;&nbsp;col</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">col&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">)&nbsp;</span><span id=Codehighlighter1_262_485_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_262_485_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDstBuf[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;u_plane[row</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;uv_stride&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;col</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDstBuf[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;y_plane[row&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;y_stride&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;col];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDstBuf[</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;v_plane[row</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;uv_stride&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;col</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDstBuf[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;y_plane[row&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;y_stride&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;col&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDstBuf&nbsp;</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<img src ="http://www.cppblog.com/bangle/aggbug/89475.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2009-07-07 18:19 <a href="http://www.cppblog.com/bangle/archive/2009/07/07/89475.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>RTPSession翻译(转)</title><link>http://www.cppblog.com/bangle/archive/2009/06/26/88565.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Fri, 26 Jun 2009 05:13:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2009/06/26/88565.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/88565.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2009/06/26/88565.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/88565.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/88565.html</trackback:ping><description><![CDATA[<strong>RTPSession<br></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;对于大多数的RTP应用程序，RTPSession类可能是JRTPLIB唯一使用的类。它能完全处理RTCP部份的数据包，所以用户可以把精力集中在真正的数据收发。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;要知道RTPSession类在多线程下并不是安全的，因此，用户要通过某些锁同步机制来保证不会出现在不同线程当中调用同一个RTPSession实例。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RTPSession类有如下的接口。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; RTPSession(RTPTransmitter::TransmissionProtocol proto = RTPTransmitter::IPv4UDPProto)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;使用proto类型传输层创建一个PRTSession实例。如果proto使用用户自定义（user-defined）传输层，则相应的NewUserDefinedTransmitter()函数必须实现。<span style="COLOR: rgb(255,153,0)">ps:这里默认就行了，默认就是IPV4网络。</span><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int Create(const RTPSessionParams &amp;sessparams, const RTPTransmissionParams*transparams = 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;使用RTPSession参数sessparams和RTPTransmission参数transparams 真正创建一个RTP会话。如果transparams 为NULL，则使用默认的参数。<span style="COLOR: rgb(255,153,0)">ps:RTPSessionParams 我们可能要设得比较多，RTPTransmissionParams参数就只要设置其中的端口就行了，端口一定要设对，不然进行组播时，这个进程将不接收数据。设置方式可以看example.cpp。<br></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void Destroy()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;离开一个会话但不向其它组成员发送BYE包。<span style="COLOR: rgb(255,153,0)">ps:我不推荐用这个函数除非是错误处理，正常离开我们应该用ByeDestroy()。<br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void BYEDestroy(const RTPTime &amp;maxwaittime, const void *reason,size t reasonlength)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;发送一个BYE包并且离开会话。在发送BYE包前等待maxwaittime，如果超时，会不发送BYE包直接离开，BYE包会包含你的离开原因reason。相应的reasonlength表示reason长度。<span style="COLOR: rgb(255,153,0)">ps:因为BYE包是一个RTCP包，RTCP不是要发就发的，它的发送时间是为了平衡带宽通过计算得出来的，那就很有可能到了要发的时候以经超过了maxwaittime时间了，作者可能认一直保留个这会话这么久没意义。当然，我常常把maxwaittime设得很大</span>。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; bool IsActive()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;看看这个RTPSession实例是否以经通过Create建立了真实的会话。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; uint32 t GetLocalSSRC()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回我们的SSRC。<span style="COLOR: rgb(255,153,0)">ps:至于什么是SSRC，去看看RFC3550吧。我说过JRTPLIB只是RTP协议的包装，并没有做任何应用的事情。</span><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int AddDestination(const RTPAddress &amp;addr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;添加一个发送目标。<span style="COLOR: rgb(255,153,0)">ps: 当然，如果我们使用组播，这里只用调用一次，把我们的组播地址写进去。这样，这组的全部人都能收到你发的包。但是组播可因特网的上设置很烦。而且用组播测试也很烦（组播必须BIND一个端口，如果你想在同一台机器上运行两个软件实例来没试，你就会发现同一个端口BIND两次，当然，后面那次会失败，也就是说测试不了，要测？找两台机器，或用虚拟机<img src="http://www.cnitblog.com/CuteSoft_Client/CuteEditor/images/emdgust.gif" align=absMiddle border=0>），如果组播不满足，我们就要把组播变在单播，这时就要返复调用这个函数把其它组成员的IP都加进来了。具体可以看看example3.cpp。<br></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int DeleteDestination(const RTPAddress &amp;addr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;从发送地址列表中删除一下地址。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void ClearDestinations()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;清除发送地址列表。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; bool SupportsMulticasting()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回JRTPLIB是否支持组播。ps:这里指JRTPLIB本身，不是你的真实网络。编译JRTPLIB库时可能指定。<br>.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int JoinMulticastGroup(const RTPAddress &amp;addr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;加入一个组播组addr。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int LeaveMulticastGroup(const RTPAddress &amp;addr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;离开一个组播组addr。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void LeaveAllMulticastGroups()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;离开所有组播组。<span style="COLOR: rgb(255,153,0)">ps:我们可以同时加入多个组播组。.<br></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SendPacket(const void *data, size t len)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SendPacket(const void *data, size t len, uint8 t pt, bool mark,uint32 t timestampinc)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SendPacketEx(const void *data, size t len, uint16 t hdrextID,const void *hdrextdata, size t numhdrextwords)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SendPacketEx(const void *data, size t len, uint8 t pt, boolmark, uint32 t timestampinc, uint16 t hdrextID, const void *hdrextdata,size t numhdrextwords)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: rgb(255,153,0)">上面的4个函数都是发送数据包的，我想如果你没有看RTP协议，我说了你也晕。如果你RTP协议看了，再看看RTPSession.h的注识，你就懂了。</span><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetDefaultPayloadType(uint8 t pt)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设定默认的RTP PayloadType为PT。<span style="COLOR: rgb(255,153,0)">ps:和上面的第一个和第三个发送函数配套。至于应该设个什么数，如果你看BAIDU上乱七八糟的文章，当然的乱设就可能了。其实应该按RFC3551，根据你要传输的媒体类型来设。</span><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetDefaultMark(bool m)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;这设RTP数据包的Mark标识。<span style="COLOR: rgb(255,153,0)">ps:设为什么值好？这个，呵呵，连RFC3550也不能确定了。要看具体的RTP&nbsp;Payload规范，MPEG的，H263的都不一样。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MPEG2&nbsp;</span><span style="COLOR: rgb(255,153,0)"><font color=#008000>&nbsp;&nbsp;&nbsp;www.ietf.org/rfc/rfc2250.txt&nbsp;<br></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MPEG4&nbsp;&nbsp;&nbsp;&nbsp;</span><font color=#008000><span style="COLOR: rgb(255,153,0)">www.rfc-editor.org/rfc/rfc3016.txt&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H263&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.ietf.org/rfc/rfc2190.txt"><u><font color=#0000ff>www.ietf.org/rfc/rfc2190.txt</font></u></a></span>&nbsp;<br><br></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetDefaultTimestampIncrement(uint32 t timestampinc)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设置默认的时间戳的增量。<span style="COLOR: rgb(255,153,0)">ps:也是和上的第一和第三个函数配套的。每发一个RTP数据包timestamp就会自动增加<span style="COLOR: rgb(255,153,0)"><br></span></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int IncrementTimestamp(uint32 t inc)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;这个函数用来手工增加Timestamp。有时我这很好用，例如，一个RTP数据包因为只含有静音数据，我们没有发送，这是我们就应手工增加Timestamp以便发下一个RTP数据包时它的Timestamp是正确的。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int IncrementTimestampDefault()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;这个函数用于增加由SetDefaultTimestampIncrement设定的值。有时候这很有用，例如，一个RTP数据包因为只含有静音数据，我们没有发送。这时，这个函数就会被调用用来设置Timestamp以便下一个RTP包的Timestamp是正确的。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetPreTransmissionDelay(const RTPTime &amp;delay)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This function allows you to inform the library about the delay between<br>sampling the first sample of a packet and sending the packet. This delay is<br>taken into account when calculating the relation between RTP timestamp<br>and wallclock time, used for inter-media synchronization.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; RTPTransmissionInfo *GetTransmissionInfo()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This function returns an instance of a subclass of RTPTransmissionInfo<br>which will give some additional information about the transmitter (a list<br>of local IP addresses for example). The user has to delete the returned<br>instance when it is no longer needed.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int Poll()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If you&#8217;re not using the poll thread, this function must be called regularly<br>to process incoming data and to send RTCP data when necessary.<br>61<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int WaitForIncomingData(const RTPTime &amp;delay,bool *dataavailable= 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Waits at most a time delay until incoming data has been detected. Only<br>works when you&#8217;re not using the poll thread. If dataavailable is not NULL,<br>it should be set to true if data was actually read and to false otherwise.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int AbortWait()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If the previous function has been called, this one aborts the waiting. Only<br>works when you&#8217;re not using the poll thread.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; RTPTime GetRTCPDelay()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the time interval after which an RTCP compound packet may have<br>to be sent. Only works when you&#8217;re not using the poll thread.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int BeginDataAccess()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下面的函数（直到EndDataAccess）要在BeginDataAccess&nbsp;和EndDataAccess之间被调用，BeginDataAccess确保轮询(poll）线程不会在这期间访问source table&nbsp;。EndDataAccess&nbsp;调用完成后，轮询(poll）线程会得到锁而继续访问。<span style="COLOR: rgb(255,153,0)">ps:首先，你里的source table中的每一个source表示参与会议中的每一个参与者的每一个独立的媒体流。我们会在下面用到他们，但同时，poll线程也会轮询它们以正确处理和RTCP有关的内容。<br></span>&nbsp;&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; bool GotoFirstSource()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;开始递归参与者的第一个流，如果找到了，就返回tree,否则返回false。<span style="COLOR: rgb(255,153,0)">ps：我们通过这个函数和下面的GotoNextSource遍历source table中的每一个source。<br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; bool GotoNextSource()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设置当前的源（source）为source table中的下一个源。如果已经到尾部了就返回false.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; bool GotoPreviousSource()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设置当前的源（source）为source table中上一个源。如果已经到头部了就返回false.<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; bool GotoFirstSourceWithData()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;开始递归参与者中第一个有RTP数据的流，如果找到了，就返回tree,否则返回false。<span style="COLOR: rgb(255,153,0)">PS：在接收数据是我们常用的是这套函数，因为如果没有数据要来都没用。<br></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; bool GotoNextSourceWithData()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设置当前的源（source）为source table中有RTP数据的下一个源。如果已经到尾部了就返回false.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; bool GotoPreviousSourceWithData()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设置当前的源（source）为source table中有RTP数据的上一个源。如果已经到头部了就返回false.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; RTPSourceData *GetCurrentSourceInfo()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回当前参与者的当前源（source)的RTPSourceData&nbsp;实列。<span style="COLOR: rgb(255,153,0)">ps：返回的这个RTPSourceData&nbsp;就是本进程从期它参与者的RTCP数据包中收集得到的信息，对我们来说其实很有用，只是作者的例程没有用上，国内的网络也没有提到。在RFC3550中有关RTCP的东西都在这了，看过RFC3550的人都知到，里头谈得最多的就是RTCP。这个类我们以后会专门说。<br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; RTPSourceData *GetSourceInfo(uint32 t ssrc)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回由ssrc指定的RTPSourceData&nbsp;，或都NULL（当这个条目不存在）。<span style="COLOR: rgb(255,153,0)">ps：这个函数也很有用。因为GetCurrentSourceInfo只有在GotoFirstSource等上下文当中才能用。如果我们是在RTPSource子类的成员函数中，我们没有这个上下文，就只能用这个函数。</span><br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; RTPPacket *GetNextPacket()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;得到当前参与者当前媒体流的下一个RTP数据包。<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int EndDataAccess()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请看BeginDataAccess<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetReceiveMode(RTPTransmitter::ReceiveMode m)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the receive mode to m, which can be one of the following:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; RTPTransmitter::AcceptAll<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;All incoming data is accepted, no matter where it originated from.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; RTPTransmitter::AcceptSome<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Only data coming from specific sources will be accepted.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; RTPTransmitter::IgnoreSome<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;All incoming data is accepted, except for data coming from a specificset of sources.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Note that when the receive mode is changed, the list of addressed to be ignored or accepted will be cleared.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int AddToIgnoreList(const RTPAddress &amp;addr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adds addr to the list of addresses to ignore.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int DeleteFromIgnoreList(const RTPAddress &amp;addr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deletes addr from the list of addresses to ignore.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void ClearIgnoreList()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Clears the list of addresses to ignore.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int AddToAcceptList(const RTPAddress &amp;addr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adds addr to the list of addresses to accept.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int DeleteFromAcceptList(const RTPAddress &amp;addr)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deletes addr from the list of addresses to accept.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void ClearAcceptList()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Clears the list of addresses to accept.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetMaximumPacketSize(size t s)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the maximum allowed packet size to s.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetSessionBandwidth(double bw)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the session bandwidth to bw, which is specified in bytes per second.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetTimestampUnit(double u)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets our own timestamp unit to u. The timestamp unit is defined as a time<br>interval divided by the number of samples in that interval: for 8000Hz<br>audio this would be 1.0/8000.0.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void SetNameInterval(int count)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在处理source table中的sourcese后，RTCP packet&nbsp;builder(我们不用理这个内部的东西）会检查是否有其它（non-CNAME)SDES项目要发送。如果count为零或负数，则不发送，如果count为正数，则在sources table处理count次后会把SDES name item加到当前RTCP包中。<span style="COLOR: rgb(255,153,0)">ps: 其实每次处理sources table都会伴随都SDES RTCP数据包的发送，在这个数据包当中CNAME是必须的，但其它的项目不是必须的，这就函数确定了NAME项目发送的频度，如果为1，则表不每个 SDES&nbsp;RTCP数据包都带着它，如果为2则每两个SDES数据包就发送一次NAME项目，下面的SetEMailInterval、 SetLocationInterval、SetPhoneInterval、SetToolInterval、SetNoteInterval都是同一原理。关于这个ITEM的描述，请看RFC3550.老版本的JRTPLIB没有使用这套函数，而是用EnableSendName()等函数。<br></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void SetEMailInterval(int count)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;After all possible sources in the source table have been processed, the RTCP<br>packet builder will check if other (non-CNAME) SDES items need to be<br>sent. If count is zero or negative, nothing will happen. If count is positive,<br>an SDES e-mail item will be added after the sources in the source table<br>have been processed count times.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void SetLocationInterval(int count)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;After all possible sources in the source table have been processed, the RTCP<br>packet builder will check if other (non-CNAME) SDES items need to be<br>sent. If count is zero or negative, nothing will happen. If count is positive,<br>an SDES location item will be added after the sources in the source table<br>have been processed count times.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void SetPhoneInterval(int count)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;After all possible sources in the source table have been processed, the RTCP<br>packet builder will check if other (non-CNAME) SDES items need to be<br>sent. If count is zero or negative, nothing will happen. If count is positive,<br>an SDES phone item will be added after the sources in the source table<br>have been processed count times.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void SetToolInterval(int count)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;After all possible sources in the source table have been processed, the RTCP<br>packet builder will check if other (non-CNAME) SDES items need to be<br>sent. If count is zero or negative, nothing will happen. If count is positive,<br>an SDES tool item will be added after the sources in the source table have<br>been processed count times.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void SetNoteInterval(int count)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;After all possible sources in the source table have been processed, the RTCP<br>packet builder will check if other (non-CNAME) SDES items need to be<br>sent. If count is zero or negative, nothing will happen. If count is positive,<br>an SDES note item will be added after the sources in the source table have<br>been processed count times.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetLocalName(const void *s, size t len)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设置NAME SDES项目，以遍会议的其它人员看到你的名称。下同。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetLocalEMail(const void *s, size t len)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the SDES e-mail item for the local participant to the value s with<br>length len.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetLocalLocation(const void *s, size t len)<br>Sets the SDES location item for the local participant to the value s with<br>length len.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetLocalPhone(const void *s, size t len)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the SDES phone item for the local participant to the value s with<br>length len.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetLocalTool(const void *s, size t len)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the SDES tool item for the local participant to the value s with length<br>len.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; int SetLocalNote(const void *s, size t len)<br>Sets the SDES note item for the local participant to the value s with length<br>len.<br>In case you specified in the constructor that you want to use your own transmission<br>component, you should override the following function:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; RTPTransmitter *NewUserDefinedTransmitter()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The RTPTransmitter instance returned by this function will then be used to send<br>and receive RTP and RTCP packets. Note that when the session is destroyed,<br>this RTPTransmitter instance will be destroyed with a delete call.<br>By inheriting your own class from RTPSession and overriding one or more of the<br>functions below, certain events can be detected:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnRTPPacket(RTPPacket *pack, const RTPTime &amp;receivetime, const&nbsp;&nbsp;RTPAddress *senderaddress)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果有RTPPacket数据包来到，会调用这个函数处理。<span style="COLOR: rgb(255,153,0)">ps:这个函数在我们继承RTPSession类时很可能重载，这是获取RTP数据包除了上面所说的方法以外的另外一种方法，这个方法比较适合异步的情况。默认这个是一个空虚函数。除了这个函数以外，下面的几个函数了会经常重载。</span><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnRTCPCompoundPacket(RTCPCompoundPacket *pack, const RTPTime &amp;receivetime, const RTPAddress *senderaddress)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when an incoming RTCP packet is about to be processed.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnSSRCCollision(RTPSourceData *srcdat, const RTPAddress *senderaddress, bool isrtp)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when an SSRC collision was detected. The instance srcdat is the<br>one present in the table, the address senderaddress is the one that collided<br>with one of the addresses and isrtp indicates against which address<br>of srcdat the check failed.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnCNAMECollision(RTPSourceData *srcdat, const RTPAddress *senderaddress, const uint8 t *cname, size t cnamelength)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when another CNAME was received than the one already present for source srcdat.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnNewSource(RTPSourceData *srcdat)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当有一个新的条目加到source table时，调用这个函数。<span style="COLOR: rgb(255,153,0)">ps: 这也是一个比较重要的函数，因为这意味着很有可能有一个新的与会者加入。但令我很不高兴的是，这时候的RTPSourceData 里头的CNAME和NAME等字段都还是无效的，这不是RTCP的责任，因为在这个SDES RTCP数据包中所有的信息都以经有了（通过抓包证实了这一点）。我们的函数被调用后，需要延时一会才能得到有关这个Source的CNAME和NAME 等相关的信息。当然，如果你不想软件死掉，不能在这个函数体内以阻塞的方式延时。<br></span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnRemoveSource(RTPSourceData *srcdat)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当有一个条目从source table中移除时调用这个函数。<span style="COLOR: rgb(255,153,0)">ps：这通常意味着有一个与会者离开了，和OnNewSource不一样，这时的CNAME和NAME等都是有效的。用这个函数要注意，我们的&#8220;意味着两个字&#8221; 因为&#8220;加入&#8221;的可能不是一个新的与会者，而是一个现有与会者的一个新的媒体流。&#8220;离开&#8221;的也可能不是一个与会者，而只是其中一个与会者的其中一个媒体流，这两个函数只能给我们更新与会者提供一个触发条件而已。当OnNewSource调用时，我们要看看这个CNAME是不是以经在我们与会者名单中，如果不是，那就是一个新与会者。同时，如果OnRemoveSource被调用，则我们要看看这个CNAME的与会者还有没有其它的Source，如果没有了，这个与会者才是真正离开。这么很麻烦？？那就对了，那就是现在的H323和SIP要做的事情－－会话管理。<br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnTimeout(RTPSourceData *srcdat)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when participant srcdat is timed out.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnBYETimeout(RTPSourceData *srcdat)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when participant srcdat is timed after having sent a BYE packet.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnBYEPacket(RTPSourceData *srcdat)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when a BYE packet has been processed for source srcdat.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnAPPPacket(RTCPAPPPacket *apppacket, const RTPTime &amp;receivetime,<br>const RTPAddress *senderaddress)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;In called when an RTCP APP packet apppacket has been received at time<br>receivetime from address senderaddress.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnUnknownPacketType(RTCPPacket *rtcppack, const RTPTime &amp;receivetime,<br>const RTPAddress *senderaddress)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when an unknown RTCP packet type was detected.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnUnknownPacketFormat(RTCPPacket *rtcppack, const RTPTime &amp;receivetime,<br>const RTPAddress *senderaddress)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when an unknown packet format for a known packet type was<br>detected.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnNoteTimeout(RTPSourceData *srcdat)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when the SDES NOTE item for source srcdat has been timed out.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnSendRTCPCompoundPacket(RTCPCompoundPacket *pack)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when an RTCP compound packet has just been sent. Useful to<br>inspect outgoing RTCP data.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnPollThreadError(int errcode)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called when error errcode was detected in the poll thread.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8226; void OnPollThreadStep()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Is called each time the poll thread loops. This happens when incoming data<br>was detected or when its time to send an RTCP compound packet. <br>
<div><br></div>
<table style="BORDER-COLLAPSE: collapse" borderColor=#999999 cellSpacing=0 cellPadding=0 width="95%" bgColor=#f1f1f1 border=1>
    <tbody>
        <tr>
            <td>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><code><span style="COLOR: rgb(0,0,0)"><span class=Apple-style-span style="FONT-SIZE: large"><font class=Apple-style-span face=黑体>发送者报告（SR)</font></span></span></code></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace>V|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>P|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>RC|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>PT=SR=200|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>LEN|</font></p>
            <hr>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace>发送者SSRC<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>（已关联）</font></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace></font></p>
            <font class=Apple-style-span face=-webkit-monospace>
            <hr>
            NTP时间戳（高32位）<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'"><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#1e16102ba46e18bcfc12881bdd0af584"><u><font color=#0000ff>SR_GetNTPTimestamp</font></u></a> ()</span></font>
            <p>&#160;</p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace>NTP时间戳（低32位）</font></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace></font></p>
            <font class=Apple-style-span face=-webkit-monospace>
            <hr>
            RTP时间戳<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'"><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#c44c97ebfd98b5fc94aa5faa9564e177"><u><font color=#0000ff>SR_GetRTPTimestamp</font></u></a> ()&nbsp;</span></font>
            <p>&#160;</p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace></font></p>
            <font class=Apple-style-span face=-webkit-monospace>
            <hr>
            发送者分组计数器<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'"><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#f2353a0e213f1dad13134a5ce0145c04"><u><font color=#0000ff>SR_GetPacketCount</font></u></a>（）</span></font>
            <p>&#160;</p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace></font></p>
            <font class=Apple-style-span face=-webkit-monospace>
            <hr>
            发送者字节计数器<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'"><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#6271acf2d8b63149cb749a505b64c116"><u><font color=#0000ff>SR_GetByteCount</font></u></a> ()</span></font>
            <p>&#160;</p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><span class=Apple-style-span style="LINE-HEIGHT: normal"></span></p>
            <hr>
            ...(下面是这个发送者所发送的接收者报告，在下面和RR一起讨论）
            <p>&#160;</p>
            <hr>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace>附加信息：</font></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace>这个源是否有发送发送者报告</font></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace><span class=Apple-tab-span style="WHITE-SPACE: pre"></span><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'"><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#b9424b95cf70c09488e79a54b920a4f2"><u><font color=#0000ff>SR_HasInfo</font></u></a> ()<span class=Apple-style-span style="LINE-HEIGHT: 19px; FONT-FAMILY: -webkit-monospace"><span class=Apple-tab-span style="WHITE-SPACE: pre"> </span></span></span></font></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace>这个发送者报告接收的时间</font></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace><span class=Apple-tab-span style="WHITE-SPACE: pre"></span><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'"><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#1409afa6ce240477974d63524933e035"><u><font color=#0000ff>SR_GetReceiveTime</font></u></a> ()</span></font></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><span class=Apple-style-span style="LINE-HEIGHT: normal">以及以SR_Prev_开头的，获得倒数第二个发送者报告的信息。</span></p>
            </td>
        </tr>
    </tbody>
</table>
<br>
<div><br></div>
<table style="BORDER-COLLAPSE: collapse" borderColor=#999999 cellSpacing=0 cellPadding=0 width="95%" bgColor=#f1f1f1 border=1>
    <tbody>
        <tr>
            <td>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><code><span style="COLOR: rgb(0,0,0)"><span class=Apple-style-span style="FONT-SIZE: large"><font class=Apple-style-span face=黑体>接收者报告（RR</font></span><span style="COLOR: rgb(0,0,204)"><span class=Apple-style-span style="FONT-SIZE: large"><font class=Apple-style-span face=黑体>)</font></span></span></span></code></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace color=#0000cc><span class=Apple-style-span style="COLOR: rgb(0,0,0)">V|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>P|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>RC|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>PT=SR=201|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>LEN|</span></font></p>
            <p style="MARGIN: 5px; LINE-HEIGHT: 150%"><font class=Apple-style-span face=-webkit-monospace></font></p>
            <font class=Apple-style-span face=-webkit-monospace>
            <hr>
            </font>
            <p>&#160;</p>
            <div><font class=Apple-style-span face=-webkit-monospace><span class=Apple-style-span style="LINE-HEIGHT: 19px">SSRC1(第一个接收者报告块所关联的发送者）<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>（已关联）</span></font></div>
            <div><font class=Apple-style-span face=-webkit-monospace><span class=Apple-style-span style="LINE-HEIGHT: 19px">
            <hr>
            分组丢失率<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span>丢失分组总数|<span class=Apple-tab-span style="WHITE-SPACE: pre"> </span></span></font></div>
            <div><font class=Apple-style-span face=-webkit-monospace><span class=Apple-style-span style="LINE-HEIGHT: 19px"><span class=Apple-tab-span style="WHITE-SPACE: pre"></span><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'"><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#7e1354d52272c550c8bfabfab1ed58d2"><u><font color=#0000ff>RR_GetFractionLost</font></u></a> ()|<a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#0db6782f19198449bdd81614a79b328a"><u><font color=#0000ff>RR_GetPacketsLost</font></u></a> ()</span></span></font></div>
            <div>
            <hr>
            扩展的最高序号</div>
            <div><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#d17d9337d76a9fa4872ecc5de9075be9"><u><font color=#0000ff>RR_GetExtendedHighestSequenceNumber</font></u></a> ()</div>
            <div>
            <hr>
            间隔抖动</div>
            <div><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#6c4f9a6830151e971ffa909e48cccd0c"><u><font color=#0000ff>RR_GetJitter</font></u></a> ()</div>
            <div>
            <hr>
            最新的发送者报告时间戳（LSR)</div>
            <div><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#6e2cb37b8e933444cea6c136fd70d5af"><u><font color=#0000ff>RR_GetLastSRTimestamp</font></u></a> ()</div>
            <div>
            <hr>
            </div>
            <div>SR最新间隔（DLSR)</div>
            <div><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#6e2cb37b8e933444cea6c136fd70d5af"><u><font color=#0000ff>RR_GetLastSRTimestamp</font></u></a> ()</div>
            <div>
            <hr>
            </div>
            <div><font class=Apple-style-span face=-webkit-monospace><span class=Apple-style-span style="LINE-HEIGHT: 19px">附加信息：</span></font></div>
            <div><font class=Apple-style-span face=-webkit-monospace><span class=Apple-style-span style="LINE-HEIGHT: 19px">这个源是否有发送接收者报告</span></font></div>
            <div><font class=Apple-style-span face=-webkit-monospace><span class=Apple-style-span style="LINE-HEIGHT: 19px"><span class=Apple-tab-span style="WHITE-SPACE: pre"></span><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'"><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#b7004c2eecee6355d7ba277dcd6b2c00"><strong style="COLOR: black; BACKGROUND-COLOR: rgb(255,255,102)"><u>RR_HasInfo</u></strong></a> ()</span></span></font></div>
            <div>接收者报告接收时间</div>
            <div><span class=Apple-tab-span style="WHITE-SPACE: pre"></span><a class=el href="http://research.edm.uhasselt.be/jori/jrtplib/documentation/classRTPSourceData.html#c7c0014c40e9c1e9791b526f7b4ea42a"><u><font color=#0000ff>RR_GetReceiveTime</font></u></a> ()</div>
            <div><font class=Apple-style-span face=-webkit-monospace><span class=Apple-style-span style="LINE-HEIGHT: 19px"><span class=Apple-style-span style="LINE-HEIGHT: normal; FONT-FAMILY: 'Courier New'">以及以RR_Prev_开头的，获得倒数第二个接收者报告的信息。</span></span></font></div>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/bangle/aggbug/88565.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2009-06-26 13:13 <a href="http://www.cppblog.com/bangle/archive/2009/06/26/88565.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>YUV格式详细解释与FFMPEG的关系</title><link>http://www.cppblog.com/bangle/archive/2009/06/08/87070.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Mon, 08 Jun 2009 07:23:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2009/06/08/87070.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/87070.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2009/06/08/87070.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/87070.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/87070.html</trackback:ping><description><![CDATA[<div id=art width="100%">
<p align=left><strong><span>YUV</span></strong><strong><span>主要的采样格式</span></strong><strong><span> </span></strong></p>
<p align=left><span>主要的采样格式有</span><span>YCbCr 4:2:0</span><span>、</span><span>YCbCr 4:2:2</span><span>、</span><span>YCbCr 4:1:1</span><span>和</span><span> YCbCr 4:4:4</span><span>。其中</span><span>YCbCr 4:1:1 </span><span>比较常用，其含义为：每个点保存一个</span><span> 8bit </span><span>的亮度值</span><span>(</span><span>也就是</span><span>Y</span><span>值</span><span>), </span><span>每</span><span> 2x2 </span><span>个点保存一个</span><span> Cr </span><span>和</span><span>Cb </span><span>值</span><span>, </span><span>图像在肉眼中的感觉不会起太大的变化。所以</span><span>, </span><span>原来用</span><span> RGB(R,G,B </span><span>都是</span><span> 8bit unsigned) </span><span>模型</span><span>, 4 </span><span>个点需要</span><span> 8x3=24 bites</span><span>（如下图第一个图）</span><span>. </span><span>而现在仅需要</span><span> 8+(8/4)+(8/4)=12bites, </span><span>平均每个点占</span><span>12bites(</span><span>如下图第二个图</span><span>)</span><span>。这样就把图像的数据压缩了一半。</span><span> </span></p>
<p align=left><strong><span>&nbsp;&nbsp;&nbsp;&nbsp;</span></strong><strong><span>上边仅给出了理论上的示例，在实际数据存储中是有可能是不同的，下面给出几种具体的存储形式：</span></strong><strong><span> </span></strong></p>
<p align=left><span>（</span><span>1</span><span>）</span><span>&nbsp;&nbsp;&nbsp;&nbsp;<strong>YUV 4:4:4</strong> </span></p>
<p align=left><span>YUV</span><span>三个信道的抽样率相同，因此在生成的图像里，每个象素的三个分量信息完整（每个分量通常</span><span>8</span><span>比特），经过</span><span>8</span><span>比特量化之后，未经压缩的每个像素占用</span><span>3</span><span>个字节。</span><span> </span></p>
<p align=left><span>下面的四个像素为</span><span>: [Y<sub>0</sub> U<sub>0</sub> V<sub>0</sub>] [Y<sub>1</sub> U<sub>1</sub> V<sub>1</sub>] [Y<sub>2</sub> U<sub>2</sub> V<sub>2</sub>] [Y<sub>3</sub> U<sub>3</sub> V<sub>3</sub>] </span></p>
<p align=left><span>存放的码流为<span>: Y<sub>0</sub> U<sub>0</sub> V<sub>0</sub> Y<sub>1</sub> U<sub>1</sub> V<sub>1</sub> Y<sub>2</sub> U<sub>2</sub> V<sub>2</sub> Y<sub>3</sub> U<sub>3</sub> V<sub>3</sub></span></span></p>
<p align=left><strong><span>（<span>2</span>）<span>&nbsp;&nbsp; YUV 4:2:2</span></span></strong></p>
<p align=left><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span>每个色差信道的抽样率是亮度信道的一半，所以水平方向的色度抽样率只是<span>4:4:4</span>的一半。对非压缩的<span>8</span>比特量化的图像来说，每个由两个水平方向相邻的像素组成的宏像素需要占用<span>4</span>字节内存。</span></p>
<p align=left><span>下面的四个像素为</span><span>: [Y<sub>0</sub> U<sub>0</sub> V<sub>0</sub>] [Y<sub>1</sub> U<sub>1</sub> V<sub>1</sub>] [Y<sub>2</sub> U<sub>2</sub> V<sub>2</sub>] [Y<sub>3</sub> U<sub>3</sub> V<sub>3</sub>] </span></p>
<p align=left><span>存放的码流为<span>: Y<sub>0</sub> U<sub>0</sub> Y<sub>1</sub> V<sub>1</sub> Y<sub>2</sub> U<sub>2</sub> Y<sub>3</sub> V<sub>3</sub></span></span></p>
<p align=left><span>映射出像素点为：<span>[Y<sub>0</sub> U<sub>0</sub> V<sub>1</sub>] [Y<sub>1</sub> U<sub>0</sub> V<sub>1</sub>] [Y<sub>2</sub> U<sub>2</sub> V<sub>3</sub>] [Y<sub>3</sub> U<sub>2</sub> V<sub>3</sub>]<strong></strong></span></span></p>
<p align=left><strong><span>（<span>3</span>）<span>&nbsp;&nbsp; YUV 4:1:1</span></span></strong></p>
<p align=left><span>4:1:1</span><span>的色度抽样，是在水平方向上对色度进行<span>4:1</span>抽样。对于低端用户和消费类产品这仍然是可以接受的。对非压缩的<span>8</span>比特量化的视频来说，每个由<span>4</span>个水平方向相邻的像素组成的宏像素需要占用<span>6</span>字节内存<strong></strong></span></p>
<p align=left><span>下面的四个像素为</span><span>: [Y<sub>0</sub> U<sub>0</sub> V<sub>0</sub>] [Y<sub>1</sub> U<sub>1</sub> V<sub>1</sub>] [Y<sub>2</sub> U<sub>2</sub> V<sub>2</sub>] [Y<sub>3</sub> U<sub>3</sub> V<sub>3</sub>] </span></p>
<p align=left><span>存放的码流为<span>: Y<sub>0</sub> U<sub>0</sub> Y<sub>1</sub> Y<sub>2</sub> V<sub>2</sub> Y<sub>3</sub></span></span></p>
<p align=left><span>映射出像素点为：<span>[Y<sub>0</sub> U<sub>0</sub> V<sub>2</sub>] [Y<sub>1</sub> U<sub>0</sub> V<sub>2</sub>] [Y<sub>2</sub> U<sub>0</sub> V<sub>2</sub>] [Y<sub>3</sub> U<sub>0</sub> V<sub>2</sub>]</span></span></p>
<p align=left><strong><span>（<span>4</span>）<span>YUV4:2:0</span></span></strong></p>
<p align=left><span>&nbsp;&nbsp;&nbsp;&nbsp; 4:2:0</span><span>并不意味着只有<span>Y,Cb</span>而没有<span>Cr</span>分量。它指得是对每行扫描线来说，只有一种色度分量以<span>2:1</span>的抽样率存储。进行隔行扫描，相邻的扫描行存储不同的色度分量，也就是说，如果一行是<span>4:2:0</span>的话，下一行就是<span>4:0:2</span>，再下一行是<span>4:2:0...</span>以此类推。对每个色度分量来说，水平方向和竖直方向的抽样率都是<span>2:1</span>，所以可以说色度的抽样率是<span>4:1</span>。对非压缩的<span>8</span>比特量化的视频来说，每个由<span>2x2</span>个<span>2</span>行<span>2</span>列相邻的像素组成的宏像素需要占用<span>6</span>字节内存。</span></p>
<p align=left><span>下面八个像素为：<span>[Y<sub>0</sub> U<sub>0</sub> V<sub>0</sub>] [Y<sub>1</sub> U<sub>1</sub> V<sub>1</sub>] [Y<sub>2</sub> U<sub>2</sub> V<sub>2</sub>] [Y<sub>3</sub> U<sub>3</sub> V<sub>3</sub>]</span></span></p>
<p align=left><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Y<sub>5</sub> U<sub>5</sub> V<sub>5</sub>] [Y<sub>6</sub> U<sub>6</sub> V<sub>6</sub>] [Y<sub>7</sub>U<sub>7</sub> V<sub>7</sub>] [Y<sub>8</sub> U<sub>8</sub> V<sub>8</sub>]</span></p>
<p align=left><span>存放的码流为：<span>Y<sub>0</sub> U<sub>0</sub> Y<sub>1</sub> Y<sub>2</sub> U<sub>2</sub> Y<sub>3</sub></span></span></p>
<p align=left><sub><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></sub><span>Y<sub>5 </sub>V<sub>5</sub> Y<sub>6</sub> Y<sub>7</sub> V<sub>7</sub> Y<sub>8</sub></span></p>
<p align=left><span>映射出的像素点为：<span>[Y<sub>0</sub> U<sub>0</sub> V<sub>5</sub>] [Y<sub>1</sub> U<sub>0</sub> V<sub>5</sub>] [Y<sub>2</sub> U<sub>2</sub> V<sub>7</sub>] [Y<sub>3</sub> U<sub>2</sub> V<sub>7</sub>]</span></span></p>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Y<sub>5</sub> U<sub>0</sub> V<sub>5</sub>] [Y<sub>6</sub> U<sub>0</sub> V<sub>5</sub>] [Y<sub>7</sub>U<sub>2</sub> V<sub>7</sub>] [Y<sub>8</sub> U<sub>2</sub> V<sub>7</sub>]</span>&nbsp;<br><br>
<p>对应AVPicture里面有data[4]和linesize[4]其中data是一个指向指针的指针（二级、二维指针），也就是指向视频数据缓冲区的首地址，而data[0]~data[3]是一级指针，可以用如下的图来表示： </p>
<p>data --&gt;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data[0]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data[1]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data[2]<br></p>
<p>比如说，当pix_fmt=PIX_FMT_YUV420P时，data中的数据是按照YUV的格式存储的，也就是： </p>
<pre>data --&gt;YYYYYYYYYYYYYYUUUUUUUUUUUUUVVVVVVVVVVVV
^             ^            ^
|             |            |
data[0]    data[1]      data[2]
</pre>
<p>linesize是指对应于每一行的大小，为什么需要这个变量，是因为在YUV格式和RGB格式时，每行的大小不一定等于图像的宽度，对于RGB格式输出时,只有一个通道(bgrbgrbgr......)可用，即linesize[0],和data[0],so RGB24&nbsp;: data[0] = packet rgb//bgrbgrbgr...... </p>
<pre>linesize[0] = width*3
</pre>
<p>其他的如data[1][2][3]与linesize[1][2][3]无任何意义. </p>
<p>而对于ＹＵＶ格式输出时，有三个通道可用，即data[0][1][2],与linesize[0][1][2]，而yuv格式对于运动估计时，需要填充padding(right, bottom),故： </p>
<pre>linesize=width+padding size(16+16).
///////////////////////////////////////////////////////////////////////////////////////</pre>
<pre><br>&nbsp;&nbsp;&nbsp;case PIX_FMT_YUV420P:<br>&nbsp;&nbsp;&nbsp;case PIX_FMT_YUVJ420P:<br>&nbsp;&nbsp;&nbsp;case PIX_FMT_RGB555:<br>&nbsp;&nbsp;&nbsp;&nbsp;if (PIC_DIRECTION_0 == m_dwFilpPicDirection)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;data [0] += m_pYuvFrame-&gt;linesize[0] *&nbsp; m_pVCodecContext-&gt;height;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//因为是隔行扫描U与V只有高度的一半<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;data [1] += m_pYuvFrame-&gt;linesize[1] *&nbsp; m_pVCodecContext-&gt;height/2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;data [2] += m_pYuvFrame-&gt;linesize[2] *&nbsp; m_pVCodecContext-&gt;height/2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;linesize[0] = -m_pYuvFrame-&gt;linesize[0];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;linesize[1] = -m_pYuvFrame-&gt;linesize[1];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;linesize[2] = -m_pYuvFrame-&gt;linesize[2];<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&nbsp;&nbsp;&nbsp;case PIX_FMT_YUVJ422P:<br>&nbsp;&nbsp;&nbsp;case PIX_FMT_YUV422P:<br>&nbsp;&nbsp;&nbsp;case PIX_FMT_YUYVJ422:<br>&nbsp;&nbsp;&nbsp;case PIX_FMT_YUV411P:<br>&nbsp;&nbsp;&nbsp;case PIX_FMT_YUYV422:&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if (PIC_DIRECTION_0 == m_dwFilpPicDirection)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;data [0] += m_pYuvFrame-&gt;linesize[0] *&nbsp; m_pVCodecContext-&gt;height;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;data [1] += m_pYuvFrame-&gt;linesize[1] *&nbsp; m_pVCodecContext-&gt;height;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;data [2] += m_pYuvFrame-&gt;linesize[2] *&nbsp; m_pVCodecContext-&gt;height;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;linesize[0] = -m_pYuvFrame-&gt;linesize[0];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;linesize[1] = -m_pYuvFrame-&gt;linesize[1];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pYuvFrame-&gt;linesize[2] = -m_pYuvFrame-&gt;linesize[2];<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&nbsp;&nbsp;&nbsp;}<br>在FFMPEG中转换RGB时顺便颠倒图像的方向算法<br></pre>
</div>
<img src ="http://www.cppblog.com/bangle/aggbug/87070.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2009-06-08 15:23 <a href="http://www.cppblog.com/bangle/archive/2009/06/08/87070.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>浮点数运算汇编指令</title><link>http://www.cppblog.com/bangle/archive/2009/03/11/76200.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Wed, 11 Mar 2009 03:40:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2009/03/11/76200.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/76200.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2009/03/11/76200.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/76200.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/76200.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/bangle/archive/2009/03/11/76200.html'>阅读全文</a><img src ="http://www.cppblog.com/bangle/aggbug/76200.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2009-03-11 11:40 <a href="http://www.cppblog.com/bangle/archive/2009/03/11/76200.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>2月19</title><link>http://www.cppblog.com/bangle/archive/2009/02/19/74302.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Thu, 19 Feb 2009 07:56:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2009/02/19/74302.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/74302.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2009/02/19/74302.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/74302.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/74302.html</trackback:ping><description><![CDATA[不经清贫难成人，<br>不经打击老天真，<br>自古英雄出炼狱，<br>从来富贵落凡尘，<br>醉生梦死谁成器，<br>破马长枪顶乾坤。 
<img src ="http://www.cppblog.com/bangle/aggbug/74302.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2009-02-19 15:56 <a href="http://www.cppblog.com/bangle/archive/2009/02/19/74302.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>汇编指令与花指令</title><link>http://www.cppblog.com/bangle/archive/2009/02/17/74023.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Tue, 17 Feb 2009 04:44:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2009/02/17/74023.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/74023.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2009/02/17/74023.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/74023.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/74023.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/bangle/archive/2009/02/17/74023.html'>阅读全文</a><img src ="http://www.cppblog.com/bangle/aggbug/74023.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2009-02-17 12:44 <a href="http://www.cppblog.com/bangle/archive/2009/02/17/74023.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>情人节也加班</title><link>http://www.cppblog.com/bangle/archive/2009/02/14/73784.html</link><dc:creator>黑色天使</dc:creator><author>黑色天使</author><pubDate>Sat, 14 Feb 2009 05:47:00 GMT</pubDate><guid>http://www.cppblog.com/bangle/archive/2009/02/14/73784.html</guid><wfw:comment>http://www.cppblog.com/bangle/comments/73784.html</wfw:comment><comments>http://www.cppblog.com/bangle/archive/2009/02/14/73784.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bangle/comments/commentRss/73784.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bangle/services/trackbacks/73784.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/bangle/archive/2009/02/14/73784.html'>阅读全文</a><img src ="http://www.cppblog.com/bangle/aggbug/73784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bangle/" target="_blank">黑色天使</a> 2009-02-14 13:47 <a href="http://www.cppblog.com/bangle/archive/2009/02/14/73784.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>