Repository URL to install this package:
Version:
7:2.7.1-1ubuntu3 ▾
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>FFmpeg: muxing.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">FFmpeg
 <span id="projectnumber">2.7.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<div class="title">muxing.c</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
<span class="comment"> * Copyright (c) 2003 Fabrice Bellard</span>
<span class="comment"> *</span>
<span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="comment"> * of this software and associated documentation files (the "Software"), to deal</span>
<span class="comment"> * in the Software without restriction, including without limitation the rights</span>
<span class="comment"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="comment"> * copies of the Software, and to permit persons to whom the Software is</span>
<span class="comment"> * furnished to do so, subject to the following conditions:</span>
<span class="comment"> *</span>
<span class="comment"> * The above copyright notice and this permission notice shall be included in</span>
<span class="comment"> * all copies or substantial portions of the Software.</span>
<span class="comment"> *</span>
<span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span>
<span class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="comment"> * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
<span class="comment"> * THE SOFTWARE.</span>
<span class="comment"> */</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * @file</span>
<span class="comment"> * libavformat API example.</span>
<span class="comment"> *</span>
<span class="comment"> * Output a media file in any supported libavformat format. The default</span>
<span class="comment"> * codecs are used.</span>
<span class="comment"> * @example muxing.c</span>
<span class="comment"> */</span>
<span class="preprocessor">#include <stdlib.h></span>
<span class="preprocessor">#include <stdio.h></span>
<span class="preprocessor">#include <string.h></span>
<span class="preprocessor">#include <math.h></span>
<span class="preprocessor">#include <<a class="code" href="avassert_8h.html" title="simple assert() macros that are a bit more flexible than ISO C assert().">libavutil/avassert.h</a>></span>
<span class="preprocessor">#include <<a class="code" href="channel__layout_8h.html" title="audio channel layout utility functions">libavutil/channel_layout.h</a>></span>
<span class="preprocessor">#include <<a class="code" href="opt_8h.html" title="AVOptions.">libavutil/opt.h</a>></span>
<span class="preprocessor">#include <<a class="code" href="mathematics_8h.html">libavutil/mathematics.h</a>></span>
<span class="preprocessor">#include <<a class="code" href="timestamp_8h.html" title="timestamp utils, mostly useful for debugging/logging purposes">libavutil/timestamp.h</a>></span>
<span class="preprocessor">#include <<a class="code" href="avformat_8h.html" title="Main libavformat public API header.">libavformat/avformat.h</a>></span>
<span class="preprocessor">#include <<a class="code" href="swscale_8h.html" title="external API header">libswscale/swscale.h</a>></span>
<span class="preprocessor">#include <<a class="code" href="swresample_8h.html" title="libswresample public header">libswresample/swresample.h</a>></span>
<span class="preprocessor">#define STREAM_DURATION 10.0</span>
<span class="preprocessor"></span><span class="preprocessor">#define STREAM_FRAME_RATE 25 </span><span class="comment">/* 25 images/s */</span>
<span class="preprocessor">#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P </span><span class="comment">/* default pix_fmt */</span>
<span class="preprocessor">#define SCALE_FLAGS SWS_BICUBIC</span>
<span class="preprocessor"></span>
<span class="comment">// a wrapper around a single output AVStream</span>
<span class="keyword">typedef</span> <span class="keyword">struct </span><a name="_a0"></a><a class="code" href="structOutputStream.html">OutputStream</a> {
<a name="_a1"></a><a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *<a name="a2"></a><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>;
<span class="comment">/* pts of the next frame that will be generated */</span>
int64_t <a name="a3"></a><a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a>;
<span class="keywordtype">int</span> <a name="a4"></a><a class="code" href="structOutputStream.html#a0c3b9816e5c50c0ed816343d224121e7">samples_count</a>;
<a name="_a5"></a><a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a name="a6"></a><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>;
<a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a name="a7"></a><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a>;
<span class="keywordtype">float</span> <a name="a8"></a><a class="code" href="structOutputStream.html#ab5bc1d10f171e32c5241ab23271ae765">t</a>, <a name="a9"></a><a class="code" href="structOutputStream.html#afacbd1335db05b68d2ea528c8b5d197b">tincr</a>, <a name="a10"></a><a class="code" href="structOutputStream.html#a04fe3fc54e1a382047e501c4ce63497b">tincr2</a>;
<span class="keyword">struct </span>SwsContext *<a name="a11"></a><a class="code" href="structOutputStream.html#a87e6c2172dab3143e4857aaaf6558573">sws_ctx</a>;
<span class="keyword">struct </span><a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *<a name="a12"></a><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>;
} <a class="code" href="structOutputStream.html">OutputStream</a>;
<span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a13"></a><a class="code" href="muxing_8c.html#ac7a1319852323152629ce60c4ef04ed5">log_packet</a>(<span class="keyword">const</span> <a name="_a14"></a><a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *<a name="a15"></a><a class="code" href="demuxing__decoding_8c.html#a409462acdf7aebe5bfbe1bcd811efa5d">fmt_ctx</a>, <span class="keyword">const</span> <a name="_a16"></a><a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> *<a name="a17"></a><a class="code" href="demuxing__decoding_8c.html#a3d4c6562f0b27cf0cacbbea5c038c090">pkt</a>)
{
<a name="_a18"></a><a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a> *time_base = &fmt_ctx-><a name="a19"></a><a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[pkt-><a name="a20"></a><a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>]-><a name="a21"></a><a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>;
printf(<span class="stringliteral">"pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n"</span>,
<a name="a22"></a><a class="code" href="timestamp_8h.html#a86d797e907fa454ed5fd34bfb0bcd747" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2str</a>(pkt-><a name="a23"></a><a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...">pts</a>), <a name="a24"></a><a class="code" href="timestamp_8h.html#ad344b91ede6b86fc0a530611293f42da" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2timestr</a>(pkt-><a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...">pts</a>, time_base),
<a class="code" href="timestamp_8h.html#a86d797e907fa454ed5fd34bfb0bcd747" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2str</a>(pkt-><a name="a25"></a><a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...">dts</a>), <a class="code" href="timestamp_8h.html#ad344b91ede6b86fc0a530611293f42da" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2timestr</a>(pkt-><a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...">dts</a>, time_base),
<a class="code" href="timestamp_8h.html#a86d797e907fa454ed5fd34bfb0bcd747" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2str</a>(pkt-><a name="a26"></a><a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream->time_base units, 0 if unknown.">duration</a>), <a class="code" href="timestamp_8h.html#ad344b91ede6b86fc0a530611293f42da" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2timestr</a>(pkt-><a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream->time_base units, 0 if unknown.">duration</a>, time_base),
pkt-><a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>);
}
<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a27"></a><a class="code" href="muxing_8c.html#ab85f450fd9ee7aad777fc135b62dd3cd">write_frame</a>(<a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *fmt_ctx, <span class="keyword">const</span> <a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a> *time_base, <a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *st, <a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> *pkt)
{
<span class="comment">/* rescale output packet timestamp values from codec to stream timebase */</span>
<a name="a28"></a><a class="code" href="group__lavc__packet.html#gae5c86e4d93f6e7aa62ef2c60763ea67e" title="Convert valid timing fields (timestamps / durations) in a packet from one timebase to another...">av_packet_rescale_ts</a>(pkt, *time_base, st-><a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>);
pkt-><a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a> = st-><a name="a29"></a><a class="code" href="structAVStream.html#a6ca823054632821e085377f7d371a2d1" title="stream index in AVFormatContext">index</a>;
<span class="comment">/* Write the compressed frame to the media file. */</span>
<a class="code" href="muxing_8c.html#ac7a1319852323152629ce60c4ef04ed5">log_packet</a>(fmt_ctx, pkt);
<span class="keywordflow">return</span> <a name="a30"></a><a class="code" href="group__lavf__encoding.html#ga37352ed2c63493c38219d935e71db6c1" title="Write a packet to an output media file ensuring correct interleaving.">av_interleaved_write_frame</a>(fmt_ctx, pkt);
}
<span class="comment">/* Add an output stream. */</span>
<span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a31"></a><a class="code" href="muxing_8c.html#aead090f3b6525cfdfa572f18f7575219">add_stream</a>(<a class="code" href="structOutputStream.html">OutputStream</a> *ost, <a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *oc,
<a name="_a32"></a><a class="code" href="structAVCodec.html" title="AVCodec.">AVCodec</a> **codec,
<span class="keyword">enum</span> <a class="code" href="group__lavc__core.html#gaadca229ad2c20e060a14fec08a5cc7ce" title="Identify the syntax and semantics of the bitstream.">AVCodecID</a> codec_id)
{
<a name="_a33"></a><a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *c;
<span class="keywordtype">int</span> i;
<span class="comment">/* find the encoder */</span>
*codec = <a name="a34"></a><a class="code" href="group__lavc__encoding.html#ga9f820c481615c3a02d0407bac0bdbf25" title="Find a registered encoder with a matching codec ID.">avcodec_find_encoder</a>(codec_id);
<span class="keywordflow">if</span> (!(*codec)) {
fprintf(stderr, <span class="stringliteral">"Could not find encoder for '%s'\n"</span>,
<a name="a35"></a><a class="code" href="group__lavc__misc.html#ga2016a52e94f867ebe5113bdf448e182d" title="Get the name of a codec.">avcodec_get_name</a>(codec_id));
exit(1);
}
ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a> = <a name="a36"></a><a class="code" href="group__lavf__core.html#gadcb0fd3e507d9b58fe78f61f8ad39827" title="Add a new stream to a media file.">avformat_new_stream</a>(oc, *codec);
<span class="keywordflow">if</span> (!ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>) {
fprintf(stderr, <span class="stringliteral">"Could not allocate stream\n"</span>);
exit(1);
}
ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a name="a37"></a><a class="code" href="structAVStream.html#a6873ed62f196c24e8bf282609231786f" title="Format-specific stream ID.">id</a> = oc-><a name="a38"></a><a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a>-1;
c = ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a name="a39"></a><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
<span class="keywordflow">switch</span> ((*codec)->type) {
<span class="keywordflow">case</span> <a name="a40"></a><a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48a7b4e33b8f30ac94d34ce8d9f7c33927a">AVMEDIA_TYPE_AUDIO</a>:
c-><a name="a41"></a><a class="code" href="structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45" title="audio sample format">sample_fmt</a> = (*codec)->sample_fmts ?
(*codec)->sample_fmts[0] : <a name="a42"></a><a class="code" href="group__lavu__sampfmts.html#ggaf9a51ca15301871723577c730b5865c5a2d21c520e4ab21100b6440ec2d81ba1b" title="float, planar">AV_SAMPLE_FMT_FLTP</a>;
c-><a name="a43"></a><a class="code" href="structAVCodecContext.html#ad9214d5af3e98ea7f1d4e94be6a522de" title="the average bitrate">bit_rate</a> = 64000;
c-><a name="a44"></a><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a> = 44100;
<span class="keywordflow">if</span> ((*codec)->supported_samplerates) {
c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a> = (*codec)->supported_samplerates[0];
<span class="keywordflow">for</span> (i = 0; (*codec)->supported_samplerates[i]; i++) {
<span class="keywordflow">if</span> ((*codec)->supported_samplerates[i] == 44100)
c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a> = 44100;
}
}
c-><a name="a45"></a><a class="code" href="structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels">channels</a> = <a name="a46"></a><a class="code" href="group__channel__mask__c.html#gac95619abeb32e4a3daa18e3ff3419380" title="Return the number of channels in the channel layout.">av_get_channel_layout_nb_channels</a>(c-><a name="a47"></a><a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>);
c-><a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a> = <a name="a48"></a><a class="code" href="group__channel__mask__c.html#gabc6d6651bba254cd0fa2c42a57228e65">AV_CH_LAYOUT_STEREO</a>;
<span class="keywordflow">if</span> ((*codec)->channel_layouts) {
c-><a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a> = (*codec)->channel_layouts[0];
<span class="keywordflow">for</span> (i = 0; (*codec)->channel_layouts[i]; i++) {
<span class="keywordflow">if</span> ((*codec)->channel_layouts[i] == <a class="code" href="group__channel__mask__c.html#gabc6d6651bba254cd0fa2c42a57228e65">AV_CH_LAYOUT_STEREO</a>)
c-><a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a> = <a class="code" href="group__channel__mask__c.html#gabc6d6651bba254cd0fa2c42a57228e65">AV_CH_LAYOUT_STEREO</a>;
}
}
c-><a class="code" href="structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels">channels</a> = <a class="code" href="group__channel__mask__c.html#gac95619abeb32e4a3daa18e3ff3419380" title="Return the number of channels in the channel layout.">av_get_channel_layout_nb_channels</a>(c-><a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>);
ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a> = (<a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a>){ 1, c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a> };
<span class="keywordflow">break</span>;
<span class="keywordflow">case</span> <a name="a49"></a><a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>:
c-><a name="a50"></a><a class="code" href="structAVCodecContext.html#adc5f65d6099fd8339c1580c091777223">codec_id</a> = codec_id;
c-><a class="code" href="structAVCodecContext.html#ad9214d5af3e98ea7f1d4e94be6a522de" title="the average bitrate">bit_rate</a> = 400000;
<span class="comment">/* Resolution must be a multiple of two. */</span>
c-><a name="a51"></a><a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a> = 352;
c-><a name="a52"></a><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a> = 288;
<span class="comment">/* timebase: This is the fundamental unit of time (in seconds) in terms</span>
<span class="comment"> * of which frame timestamps are represented. For fixed-fps content,</span>
<span class="comment"> * timebase should be 1/framerate and timestamp increments should be</span>
<span class="comment"> * identical to 1. */</span>
ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a> = (<a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a>){ 1, <a name="a53"></a><a class="code" href="muxing_8c.html#ad0fa7a6ac51a4021276c0a04dfe2283b">STREAM_FRAME_RATE</a> };
c-><a name="a54"></a><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a> = ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>;
c-><a name="a55"></a><a class="code" href="structAVCodecContext.html#a9b6b3f1fcbdcc2ad9f4dbb4370496e38" title="the number of pictures in a group of pictures, or 0 for intra_only">gop_size</a> = 12; <span class="comment">/* emit one intra frame every twelve frames at most */</span>
c-><a name="a56"></a><a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a> = <a name="a57"></a><a class="code" href="muxing_8c.html#ae67b157ab0198fa81bf675b378ff06fd">STREAM_PIX_FMT</a>;
<span class="keywordflow">if</span> (c-><a class="code" href="structAVCodecContext.html#adc5f65d6099fd8339c1580c091777223">codec_id</a> == <a name="a58"></a><a class="code" href="group__lavc__core.html#ggaadca229ad2c20e060a14fec08a5cc7ceaf614abb36f7c5d0c42ed522c1d6c99f0" title="preferred ID for MPEG-1/2 video decoding">AV_CODEC_ID_MPEG2VIDEO</a>) {
<span class="comment">/* just for testing, we also add B frames */</span>
c-><a name="a59"></a><a class="code" href="structAVCodecContext.html#a3e5334a611a3e2a6a653805bb9e2d4d4" title="maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...">max_b_frames</a> = 2;
}
<span class="keywordflow">if</span> (c-><a class="code" href="structAVCodecContext.html#adc5f65d6099fd8339c1580c091777223">codec_id</a> == <a name="a60"></a><a class="code" href="group__lavc__core.html#ggaadca229ad2c20e060a14fec08a5cc7ceaf019b13f4891b36ae579cd7bc96d1f78">AV_CODEC_ID_MPEG1VIDEO</a>) {
<span class="comment">/* Needed to avoid using macroblocks in which some coeffs overflow.</span>
<span class="comment"> * This does not happen with normal video, it just happens here as</span>
<span class="comment"> * the motion of the chroma plane does not match the luma plane. */</span>
c-><a name="a61"></a><a class="code" href="structAVCodecContext.html#a66af0e26734255f1eacabd7d67558482" title="macroblock decision mode">mb_decision</a> = 2;
}
<span class="keywordflow">break</span>;
<span class="keywordflow">default</span>:
<span class="keywordflow">break</span>;
}
<span class="comment">/* Some formats want stream headers to be separate. */</span>
<span class="keywordflow">if</span> (oc-><a name="a62"></a><a class="code" href="structAVFormatContext.html#a20d80ac07e38ff5c268d15aaf2798b98" title="The output container format.">oformat</a>-><a name="a63"></a><a class="code" href="structAVOutputFormat.html#aad55a00e728a020c1dcfaaf695320445" title="can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT">flags</a> & <a name="a64"></a><a class="code" href="avformat_8h.html#ab203c7b734e9c31b7c37d34f6e2c6aef" title="Format wants global header.">AVFMT_GLOBALHEADER</a>)
c-><a name="a65"></a><a class="code" href="structAVCodecContext.html#abb01e291550fa3fb96188af4d494587e" title="CODEC_FLAG_*.">flags</a> |= <a name="a66"></a><a class="code" href="group__lavc__core.html#gaab6ceefd617cf265ef7ea1b87ed5933e" title="Place global headers in extradata instead of every keyframe.">CODEC_FLAG_GLOBAL_HEADER</a>;
}
<span class="comment">/**************************************************************/</span>
<span class="comment">/* audio output */</span>
<span class="keyword">static</span> <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a name="a67"></a><a class="code" href="muxing_8c.html#a368b2deb0a63160293db69808acfeff2">alloc_audio_frame</a>(<span class="keyword">enum</span> <a class="code" href="group__lavu__sampfmts.html#gaf9a51ca15301871723577c730b5865c5" title="Audio sample formats.">AVSampleFormat</a> sample_fmt,
uint64_t channel_layout,
<span class="keywordtype">int</span> sample_rate, <span class="keywordtype">int</span> nb_samples)
{
<a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a name="a68"></a><a class="code" href="demuxing__decoding_8c.html#ad7d33d579a8d4241a5e643e39287a209">frame</a> = <a name="a69"></a><a class="code" href="group__lavu__frame.html#gac700017c5270c79c1e1befdeeb008b2f" title="Allocate an AVFrame and set its fields to default values.">av_frame_alloc</a>();
<span class="keywordtype">int</span> ret;
<span class="keywordflow">if</span> (!frame) {
fprintf(stderr, <span class="stringliteral">"Error allocating an audio frame\n"</span>);
exit(1);
}
frame-><a name="a70"></a><a class="code" href="structAVFrame.html#aed14fa772ce46881020fd1545c86432c" title="format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...">format</a> = sample_fmt;
frame-><a name="a71"></a><a class="code" href="structAVFrame.html#a5f343e0325e3e9d9ed20e34c9e156aef" title="Channel layout of the audio data.">channel_layout</a> = channel_layout;
frame-><a name="a72"></a><a class="code" href="structAVFrame.html#ac85daa1316e1f47e78da0ca19b7c60e6" title="Sample rate of the audio data.">sample_rate</a> = sample_rate;
frame-><a name="a73"></a><a class="code" href="structAVFrame.html#a02f45ab8191aea1660159f1e464237ea" title="number of audio samples (per channel) described by this frame">nb_samples</a> = nb_samples;
<span class="keywordflow">if</span> (nb_samples) {
ret = <a name="a74"></a><a class="code" href="group__lavu__frame.html#ga6b1acbfa82c79bf7fd78d868572f0ceb" title="Allocate new buffer(s) for audio or video data.">av_frame_get_buffer</a>(frame, 0);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Error allocating an audio buffer\n"</span>);
exit(1);
}
}
<span class="keywordflow">return</span> <a class="code" href="demuxing__decoding_8c.html#ad7d33d579a8d4241a5e643e39287a209">frame</a>;
}
<span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a75"></a><a class="code" href="muxing_8c.html#ae7697b74a6a8605a91487b43e31f29be">open_audio</a>(<a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *oc, <a class="code" href="structAVCodec.html" title="AVCodec.">AVCodec</a> *codec, <a class="code" href="structOutputStream.html">OutputStream</a> *ost, <a class="code" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> *opt_arg)
{
<a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *c;
<span class="keywordtype">int</span> nb_samples;
<span class="keywordtype">int</span> ret;
<a class="code" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> *opt = NULL;
c = ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
<span class="comment">/* open it */</span>
<a name="a76"></a><a class="code" href="group__lavu__dict.html#ga6dabaab2d8a53674db6ffd5ac8de3d9f" title="Copy entries from one AVDictionary struct into another.">av_dict_copy</a>(&opt, opt_arg, 0);
ret = <a name="a77"></a><a class="code" href="group__lavc__core.html#ga11f785a188d7d9df71621001465b0f1d" title="Initialize the AVCodecContext to use the given AVCodec.">avcodec_open2</a>(c, codec, &opt);
<a name="a78"></a><a class="code" href="group__lavu__dict.html#ga1bafd682b1fbb90e48a4cc3814b820f7" title="Free all the memory allocated for an AVDictionary struct and all keys and values.">av_dict_free</a>(&opt);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Could not open audio codec: %s\n"</span>, <a name="a79"></a><a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));
exit(1);
}
<span class="comment">/* init signal generator */</span>
ost-><a class="code" href="structOutputStream.html#ab5bc1d10f171e32c5241ab23271ae765">t</a> = 0;
ost-><a class="code" href="structOutputStream.html#afacbd1335db05b68d2ea528c8b5d197b">tincr</a> = 2 * M_PI * 110.0 / c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>;
<span class="comment">/* increment frequency by 110 Hz per second */</span>
ost-><a class="code" href="structOutputStream.html#a04fe3fc54e1a382047e501c4ce63497b">tincr2</a> = 2 * M_PI * 110.0 / c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a> / c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>;
<span class="keywordflow">if</span> (c-><a name="a80"></a><a class="code" href="structAVCodecContext.html#ab00398f08f8622c3e6c0f1a12eb99808">codec</a>-><a name="a81"></a><a class="code" href="structAVCodec.html#af51f7ff3dac8b730f46b9713e49a2518" title="Codec capabilities.">capabilities</a> & <a name="a82"></a><a class="code" href="group__lavc__core.html#gaa2e644f74c8013e29ec51d6accc7ac1b" title="Audio encoder supports receiving a different number of samples in each call.">CODEC_CAP_VARIABLE_FRAME_SIZE</a>)
nb_samples = 10000;
<span class="keywordflow">else</span>
nb_samples = c-><a name="a83"></a><a class="code" href="structAVCodecContext.html#aec57f0d859a6df8b479cd93ca3a44a33" title="Number of samples per channel in an audio frame.">frame_size</a>;
ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a> = <a class="code" href="muxing_8c.html#a368b2deb0a63160293db69808acfeff2">alloc_audio_frame</a>(c-><a class="code" href="structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45" title="audio sample format">sample_fmt</a>, c-><a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>,
c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>, nb_samples);
ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a> = <a class="code" href="muxing_8c.html#a368b2deb0a63160293db69808acfeff2">alloc_audio_frame</a>(<a name="a84"></a><a class="code" href="group__lavu__sampfmts.html#ggaf9a51ca15301871723577c730b5865c5aea6132df57aebc3f76e10665395c46af" title="signed 16 bits">AV_SAMPLE_FMT_S16</a>, c-><a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>,
c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>, nb_samples);
<span class="comment">/* create resampler context */</span>
ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a> = <a name="a85"></a><a class="code" href="group__lswr.html#gaf58c4ff10f73d74bdab8e5aa7193147c" title="Allocate SwrContext.">swr_alloc</a>();
<span class="keywordflow">if</span> (!ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>) {
fprintf(stderr, <span class="stringliteral">"Could not allocate resampler context\n"</span>);
exit(1);
}
<span class="comment">/* set options */</span>
<a name="a86"></a><a class="code" href="group__opt__set__funcs.html#ga3adf7185c21cc080890a5ec02c2e56b2">av_opt_set_int</a> (ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>, <span class="stringliteral">"in_channel_count"</span>, c-><a class="code" href="structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels">channels</a>, 0);
<a class="code" href="group__opt__set__funcs.html#ga3adf7185c21cc080890a5ec02c2e56b2">av_opt_set_int</a> (ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>, <span class="stringliteral">"in_sample_rate"</span>, c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>, 0);
<a name="a87"></a><a class="code" href="group__opt__set__funcs.html#gad446f7a7b92442e464d43e400e661040">av_opt_set_sample_fmt</a>(ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>, <span class="stringliteral">"in_sample_fmt"</span>, <a class="code" href="group__lavu__sampfmts.html#ggaf9a51ca15301871723577c730b5865c5aea6132df57aebc3f76e10665395c46af" title="signed 16 bits">AV_SAMPLE_FMT_S16</a>, 0);
<a class="code" href="group__opt__set__funcs.html#ga3adf7185c21cc080890a5ec02c2e56b2">av_opt_set_int</a> (ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>, <span class="stringliteral">"out_channel_count"</span>, c-><a class="code" href="structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels">channels</a>, 0);
<a class="code" href="group__opt__set__funcs.html#ga3adf7185c21cc080890a5ec02c2e56b2">av_opt_set_int</a> (ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>, <span class="stringliteral">"out_sample_rate"</span>, c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>, 0);
<a class="code" href="group__opt__set__funcs.html#gad446f7a7b92442e464d43e400e661040">av_opt_set_sample_fmt</a>(ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>, <span class="stringliteral">"out_sample_fmt"</span>, c-><a class="code" href="structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45" title="audio sample format">sample_fmt</a>, 0);
<span class="comment">/* initialize the resampling context */</span>
<span class="keywordflow">if</span> ((ret = <a name="a88"></a><a class="code" href="group__lswr.html#gae173e8ed91717700471a1dcd06f00f67" title="Initialize context after user parameters have been set.">swr_init</a>(ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>)) < 0) {
fprintf(stderr, <span class="stringliteral">"Failed to initialize the resampling context\n"</span>);
exit(1);
}
}
<span class="comment">/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and</span>
<span class="comment"> * 'nb_channels' channels. */</span>
<span class="keyword">static</span> <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a name="a89"></a><a class="code" href="muxing_8c.html#a58000b15271c25fa9b2839d82f6971dc">get_audio_frame</a>(<a class="code" href="structOutputStream.html">OutputStream</a> *ost)
{
<a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *frame = ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a>;
<span class="keywordtype">int</span> j, i, v;
int16_t *q = (int16_t*)frame-><a name="a90"></a><a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>[0];
<span class="comment">/* check if we want to generate more frames */</span>
if (<a name="a91"></a><a class="code" href="group__lavu__math.html#ga151744358fff630942b926e67e67c415" title="Compare 2 timestamps each in its own timebases.">av_compare_ts</a>(ost-><a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a>, ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>,
<a name="a92"></a><a class="code" href="muxing_8c.html#ace0cad5fe744009aeaa62eb1fbb31831">STREAM_DURATION</a>, (<a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a>){ 1, 1 }) >= 0)
<span class="keywordflow">return</span> NULL;
<span class="keywordflow">for</span> (j = 0; j <frame-><a class="code" href="structAVFrame.html#a02f45ab8191aea1660159f1e464237ea" title="number of audio samples (per channel) described by this frame">nb_samples</a>; j++) {
v = (int)(sin(ost-><a class="code" href="structOutputStream.html#ab5bc1d10f171e32c5241ab23271ae765">t</a>) * 10000);
<span class="keywordflow">for</span> (i = 0; i < ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-><a class="code" href="structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels">channels</a>; i++)
*q++ = v;
ost-><a class="code" href="structOutputStream.html#ab5bc1d10f171e32c5241ab23271ae765">t</a> += ost-><a class="code" href="structOutputStream.html#afacbd1335db05b68d2ea528c8b5d197b">tincr</a>;
ost-><a class="code" href="structOutputStream.html#afacbd1335db05b68d2ea528c8b5d197b">tincr</a> += ost-><a class="code" href="structOutputStream.html#a04fe3fc54e1a382047e501c4ce63497b">tincr2</a>;
}
frame-><a name="a93"></a><a class="code" href="structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4" title="Presentation timestamp in time_base units (time when frame should be shown to user).">pts</a> = ost-><a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a>;
ost-><a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a> += frame-><a class="code" href="structAVFrame.html#a02f45ab8191aea1660159f1e464237ea" title="number of audio samples (per channel) described by this frame">nb_samples</a>;
<span class="keywordflow">return</span> <a class="code" href="demuxing__decoding_8c.html#ad7d33d579a8d4241a5e643e39287a209">frame</a>;
}
<span class="comment">/*</span>
<span class="comment"> * encode one audio frame and send it to the muxer</span>
<span class="comment"> * return 1 when encoding is finished, 0 otherwise</span>
<span class="comment"> */</span>
<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a94"></a><a class="code" href="muxing_8c.html#a789f35413429ab70610c90c22fc7a4d3">write_audio_frame</a>(<a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *oc, <a class="code" href="structOutputStream.html">OutputStream</a> *ost)
{
<a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *c;
<a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> pkt = { 0 }; <span class="comment">// data and size must be 0;</span>
<a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a class="code" href="demuxing__decoding_8c.html#ad7d33d579a8d4241a5e643e39287a209">frame</a>;
<span class="keywordtype">int</span> ret;
<span class="keywordtype">int</span> got_packet;
<span class="keywordtype">int</span> dst_nb_samples;
<a name="a95"></a><a class="code" href="group__lavc__packet.html#gac9cb9756175b96e7441575803757fb73" title="Initialize optional fields of a packet with default values.">av_init_packet</a>(&pkt);
c = ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
frame = <a class="code" href="muxing_8c.html#a58000b15271c25fa9b2839d82f6971dc">get_audio_frame</a>(ost);
<span class="keywordflow">if</span> (frame) {
<span class="comment">/* convert samples from native format to destination codec format, using the resampler */</span>
<span class="comment">/* compute destination number of samples */</span>
dst_nb_samples = <a name="a96"></a><a class="code" href="group__lavu__math.html#gad686ab94939ed4c65218309e94bdca72" title="Rescale a 64-bit integer with specified rounding.">av_rescale_rnd</a>(<a name="a97"></a><a class="code" href="group__lswr.html#ga5121a5a7890a2d23b72dc871dd0ebb06" title="Gets the delay the next input sample will experience relative to the next output sample.">swr_get_delay</a>(ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>, c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>) + frame-><a class="code" href="structAVFrame.html#a02f45ab8191aea1660159f1e464237ea" title="number of audio samples (per channel) described by this frame">nb_samples</a>,
c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>, c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>, <a name="a98"></a><a class="code" href="group__lavu__math.html#gga921d656eaf2c4d6800a734a13af021d0aa1d28e08e2f8b49b256e056f93038c1a" title="Round toward +infinity.">AV_ROUND_UP</a>);
<a name="a99"></a><a class="code" href="avassert_8h.html#aae204192396f78cc8c5cd7ad5c57c23f" title="assert() equivalent, that is always enabled.">av_assert0</a>(dst_nb_samples == frame-><a class="code" href="structAVFrame.html#a02f45ab8191aea1660159f1e464237ea" title="number of audio samples (per channel) described by this frame">nb_samples</a>);
<span class="comment">/* when we pass a frame to the encoder, it may keep a reference to it</span>
<span class="comment"> * internally;</span>
<span class="comment"> * make sure we do not overwrite it here</span>
<span class="comment"> */</span>
ret = <a name="a100"></a><a class="code" href="group__lavu__frame.html#gadd5417c06f5a6b419b0dbd8f0ff363fd" title="Ensure that the frame data is writable, avoiding data copy if possible.">av_frame_make_writable</a>(ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>);
<span class="keywordflow">if</span> (ret < 0)
exit(1);
<span class="comment">/* convert to destination format */</span>
ret = <a name="a101"></a><a class="code" href="group__lswr.html#gaa5bb6cab830146efa8c760fa66ee582a" title="Convert audio.">swr_convert</a>(ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>,
ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>-><a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>, dst_nb_samples,
(<span class="keyword">const</span> uint8_t **)frame-><a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>, frame-><a class="code" href="structAVFrame.html#a02f45ab8191aea1660159f1e464237ea" title="number of audio samples (per channel) described by this frame">nb_samples</a>);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Error while converting\n"</span>);
exit(1);
}
frame = ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>;
frame-><a class="code" href="structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4" title="Presentation timestamp in time_base units (time when frame should be shown to user).">pts</a> = <a name="a102"></a><a class="code" href="group__lavu__math.html#gaf02994a8bbeaa91d4757df179cbe567f" title="Rescale a 64-bit integer by 2 rational numbers.">av_rescale_q</a>(ost-><a class="code" href="structOutputStream.html#a0c3b9816e5c50c0ed816343d224121e7">samples_count</a>, (<a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a>){1, c-><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>}, c-><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>);
ost-><a class="code" href="structOutputStream.html#a0c3b9816e5c50c0ed816343d224121e7">samples_count</a> += dst_nb_samples;
}
ret = <a name="a103"></a><a class="code" href="group__lavc__encoding.html#ga93a49fbd0973b216dcb8a8c5dffe1d82" title="Encode a frame of audio.">avcodec_encode_audio2</a>(c, &pkt, frame, &got_packet);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Error encoding audio frame: %s\n"</span>, <a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));
exit(1);
}
<span class="keywordflow">if</span> (got_packet) {
ret = <a class="code" href="muxing_8c.html#ab85f450fd9ee7aad777fc135b62dd3cd">write_frame</a>(oc, &c-><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>, ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>, &pkt);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Error while writing audio frame: %s\n"</span>,
<a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));
exit(1);
}
}
<span class="keywordflow">return</span> (frame || got_packet) ? 0 : 1;
}
<span class="comment">/**************************************************************/</span>
<span class="comment">/* video output */</span>
<span class="keyword">static</span> <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a name="a104"></a><a class="code" href="muxing_8c.html#a03824343735e44b58ec03ff1691f8b45">alloc_picture</a>(<span class="keyword">enum</span> <a class="code" href="pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5" title="Pixel format.">AVPixelFormat</a> <a name="a105"></a><a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">pix_fmt</a>, <span class="keywordtype">int</span> <a name="a106"></a><a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a>, <span class="keywordtype">int</span> <a name="a107"></a><a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a>)
{
<a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *picture;
<span class="keywordtype">int</span> ret;
picture = <a class="code" href="group__lavu__frame.html#gac700017c5270c79c1e1befdeeb008b2f" title="Allocate an AVFrame and set its fields to default values.">av_frame_alloc</a>();
<span class="keywordflow">if</span> (!picture)
<span class="keywordflow">return</span> NULL;
picture-><a class="code" href="structAVFrame.html#aed14fa772ce46881020fd1545c86432c" title="format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...">format</a> = <a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">pix_fmt</a>;
picture-><a name="a108"></a><a class="code" href="structAVFrame.html#a1e71ce60cedd5f3b6811714a9f7f9e0a" title="width and height of the video frame">width</a> = <a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a>;
picture-><a name="a109"></a><a class="code" href="structAVFrame.html#a3f89733f429c98ba5bc64373fb0a3f13">height</a> = <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a>;
<span class="comment">/* allocate the buffers for the frame data */</span>
ret = <a class="code" href="group__lavu__frame.html#ga6b1acbfa82c79bf7fd78d868572f0ceb" title="Allocate new buffer(s) for audio or video data.">av_frame_get_buffer</a>(picture, 32);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Could not allocate frame data.\n"</span>);
exit(1);
}
<span class="keywordflow">return</span> picture;
}
<span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a110"></a><a class="code" href="muxing_8c.html#a34f7b1a6fc3698c190131c3df2e85903">open_video</a>(<a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *oc, <a class="code" href="structAVCodec.html" title="AVCodec.">AVCodec</a> *codec, <a class="code" href="structOutputStream.html">OutputStream</a> *ost, <a class="code" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> *opt_arg)
{
<span class="keywordtype">int</span> ret;
<a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *c = ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
<a class="code" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> *opt = NULL;
<a class="code" href="group__lavu__dict.html#ga6dabaab2d8a53674db6ffd5ac8de3d9f" title="Copy entries from one AVDictionary struct into another.">av_dict_copy</a>(&opt, opt_arg, 0);
<span class="comment">/* open the codec */</span>
ret = <a class="code" href="group__lavc__core.html#ga11f785a188d7d9df71621001465b0f1d" title="Initialize the AVCodecContext to use the given AVCodec.">avcodec_open2</a>(c, codec, &opt);
<a class="code" href="group__lavu__dict.html#ga1bafd682b1fbb90e48a4cc3814b820f7" title="Free all the memory allocated for an AVDictionary struct and all keys and values.">av_dict_free</a>(&opt);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Could not open video codec: %s\n"</span>, <a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));
exit(1);
}
<span class="comment">/* allocate and init a re-usable frame */</span>
ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a> = <a class="code" href="muxing_8c.html#a03824343735e44b58ec03ff1691f8b45">alloc_picture</a>(c-><a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a>, c-><a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>, c-><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>);
<span class="keywordflow">if</span> (!ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>) {
fprintf(stderr, <span class="stringliteral">"Could not allocate video frame\n"</span>);
exit(1);
}
<span class="comment">/* If the output format is not YUV420P, then a temporary YUV420P</span>
<span class="comment"> * picture is needed too. It is then converted to the required</span>
<span class="comment"> * output format. */</span>
ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a> = NULL;
<span class="keywordflow">if</span> (c-><a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a> != <a name="a111"></a><a class="code" href="pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5a1aa7677092740d8def31655b5d7f0cc2" title="planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)">AV_PIX_FMT_YUV420P</a>) {
ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a> = <a class="code" href="muxing_8c.html#a03824343735e44b58ec03ff1691f8b45">alloc_picture</a>(<a class="code" href="pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5a1aa7677092740d8def31655b5d7f0cc2" title="planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)">AV_PIX_FMT_YUV420P</a>, c-><a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>, c-><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>);
<span class="keywordflow">if</span> (!ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a>) {
fprintf(stderr, <span class="stringliteral">"Could not allocate temporary picture\n"</span>);
exit(1);
}
}
}
<span class="comment">/* Prepare a dummy image. */</span>
<span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a112"></a><a class="code" href="muxing_8c.html#acc346658c36a422fc9ab42bbb976138e">fill_yuv_image</a>(<a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *pict, <span class="keywordtype">int</span> frame_index,
<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height)
{
<span class="keywordtype">int</span> x, y, i, ret;
<span class="comment">/* when we pass a frame to the encoder, it may keep a reference to it</span>
<span class="comment"> * internally;</span>
<span class="comment"> * make sure we do not overwrite it here</span>
<span class="comment"> */</span>
ret = <a class="code" href="group__lavu__frame.html#gadd5417c06f5a6b419b0dbd8f0ff363fd" title="Ensure that the frame data is writable, avoiding data copy if possible.">av_frame_make_writable</a>(pict);
<span class="keywordflow">if</span> (ret < 0)
exit(1);
i = frame_index;
<span class="comment">/* Y */</span>
<span class="keywordflow">for</span> (y = 0; y < <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a>; y++)
<span class="keywordflow">for</span> (x = 0; x < <a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a>; x++)
pict-><a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>[0][y * pict-><a name="a113"></a><a class="code" href="structAVFrame.html#aa52bfc6605f6a3059a0c3226cc0f6567" title="For video, size in bytes of each picture line.">linesize</a>[0] + x] = x + y + i * 3;
<span class="comment">/* Cb and Cr */</span>
for (y = 0; y < height / 2; y++) {
<span class="keywordflow">for</span> (x = 0; x < width / 2; x++) {
pict-><a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>[1][y * pict-><a class="code" href="structAVFrame.html#aa52bfc6605f6a3059a0c3226cc0f6567" title="For video, size in bytes of each picture line.">linesize</a>[1] + x] = 128 + y + i * 2;
pict-><a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>[2][y * pict-><a class="code" href="structAVFrame.html#aa52bfc6605f6a3059a0c3226cc0f6567" title="For video, size in bytes of each picture line.">linesize</a>[2] + x] = 64 + x + i * 5;
}
}
}
<span class="keyword">static</span> <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a name="a114"></a><a class="code" href="muxing_8c.html#a2a1515bfcdc1e221407cba978bcad1f0">get_video_frame</a>(<a class="code" href="structOutputStream.html">OutputStream</a> *ost)
{
<a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *c = ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
<span class="comment">/* check if we want to generate more frames */</span>
<span class="keywordflow">if</span> (<a class="code" href="group__lavu__math.html#ga151744358fff630942b926e67e67c415" title="Compare 2 timestamps each in its own timebases.">av_compare_ts</a>(ost-><a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a>, ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>,
<a class="code" href="muxing_8c.html#ace0cad5fe744009aeaa62eb1fbb31831">STREAM_DURATION</a>, (<a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a>){ 1, 1 }) >= 0)
<span class="keywordflow">return</span> NULL;
<span class="keywordflow">if</span> (c-><a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a> != <a class="code" href="pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5a1aa7677092740d8def31655b5d7f0cc2" title="planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)">AV_PIX_FMT_YUV420P</a>) {
<span class="comment">/* as we only generate a YUV420P picture, we must convert it</span>
<span class="comment"> * to the codec pixel format if needed */</span>
<span class="keywordflow">if</span> (!ost-><a class="code" href="structOutputStream.html#a87e6c2172dab3143e4857aaaf6558573">sws_ctx</a>) {
ost-><a class="code" href="structOutputStream.html#a87e6c2172dab3143e4857aaaf6558573">sws_ctx</a> = <a name="a115"></a><a class="code" href="group__libsws.html#gaf360d1a9e0e60f906f74d7d44f9abfdd" title="Allocate and return an SwsContext.">sws_getContext</a>(c-><a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>, c-><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>,
<a class="code" href="pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5a1aa7677092740d8def31655b5d7f0cc2" title="planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)">AV_PIX_FMT_YUV420P</a>,
c-><a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>, c-><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>,
c-><a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a>,
<a name="a116"></a><a class="code" href="muxing_8c.html#ab746bcb79e75e498c4925ccd72a34f63">SCALE_FLAGS</a>, NULL, NULL, NULL);
<span class="keywordflow">if</span> (!ost-><a class="code" href="structOutputStream.html#a87e6c2172dab3143e4857aaaf6558573">sws_ctx</a>) {
fprintf(stderr,
<span class="stringliteral">"Could not initialize the conversion context\n"</span>);
exit(1);
}
}
<a class="code" href="muxing_8c.html#acc346658c36a422fc9ab42bbb976138e">fill_yuv_image</a>(ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a>, ost-><a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a>, c-><a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>, c-><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>);
<a name="a117"></a><a class="code" href="group__libsws.html#gae531c9754c9205d90ad6800015046d74" title="Scale the image slice in srcSlice and put the resulting scaled slice in the image in dst...">sws_scale</a>(ost-><a class="code" href="structOutputStream.html#a87e6c2172dab3143e4857aaaf6558573">sws_ctx</a>,
(<span class="keyword">const</span> uint8_t * <span class="keyword">const</span> *)ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a>-><a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>, ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a>-><a class="code" href="structAVFrame.html#aa52bfc6605f6a3059a0c3226cc0f6567" title="For video, size in bytes of each picture line.">linesize</a>,
0, c-><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>, ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>-><a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>, ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>-><a class="code" href="structAVFrame.html#aa52bfc6605f6a3059a0c3226cc0f6567" title="For video, size in bytes of each picture line.">linesize</a>);
} <span class="keywordflow">else</span> {
<a class="code" href="muxing_8c.html#acc346658c36a422fc9ab42bbb976138e">fill_yuv_image</a>(ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>, ost-><a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a>, c-><a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>, c-><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>);
}
ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>-><a class="code" href="structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4" title="Presentation timestamp in time_base units (time when frame should be shown to user).">pts</a> = ost-><a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a>++;
<span class="keywordflow">return</span> ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>;
}
<span class="comment">/*</span>
<span class="comment"> * encode one video frame and send it to the muxer</span>
<span class="comment"> * return 1 when encoding is finished, 0 otherwise</span>
<span class="comment"> */</span>
<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a118"></a><a class="code" href="muxing_8c.html#a435288caae5076cca3273215cb6ad395">write_video_frame</a>(<a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *oc, <a class="code" href="structOutputStream.html">OutputStream</a> *ost)
{
<span class="keywordtype">int</span> ret;
<a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *c;
<a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *<a class="code" href="demuxing__decoding_8c.html#ad7d33d579a8d4241a5e643e39287a209">frame</a>;
<span class="keywordtype">int</span> got_packet = 0;
c = ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
frame = <a class="code" href="muxing_8c.html#a2a1515bfcdc1e221407cba978bcad1f0">get_video_frame</a>(ost);
<span class="keywordflow">if</span> (oc-><a class="code" href="structAVFormatContext.html#a20d80ac07e38ff5c268d15aaf2798b98" title="The output container format.">oformat</a>-><a class="code" href="structAVOutputFormat.html#aad55a00e728a020c1dcfaaf695320445" title="can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT">flags</a> & <a name="a119"></a><a class="code" href="avformat_8h.html#a71f4268e7674596c14c18b4bb3e60a3e" title="Format wants AVPicture structure for raw picture data.">AVFMT_RAWPICTURE</a>) {
<span class="comment">/* a hack to avoid data copy with some raw video muxers */</span>
<a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> <a class="code" href="demuxing__decoding_8c.html#a3d4c6562f0b27cf0cacbbea5c038c090">pkt</a>;
<a class="code" href="group__lavc__packet.html#gac9cb9756175b96e7441575803757fb73" title="Initialize optional fields of a packet with default values.">av_init_packet</a>(&pkt);
<span class="keywordflow">if</span> (!frame)
<span class="keywordflow">return</span> 1;
pkt.<a name="a120"></a><a class="code" href="structAVPacket.html#a437be96a9da675f12caa228a9c81bd82" title="A combination of AV_PKT_FLAG values.">flags</a> |= <a name="a121"></a><a class="code" href="group__lavc__packet.html#ga75603d7c2b8adf5829f4fd2fb860168f" title="The packet contains a keyframe.">AV_PKT_FLAG_KEY</a>;
pkt.<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a> = ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a6ca823054632821e085377f7d371a2d1" title="stream index in AVFormatContext">index</a>;
pkt.<a name="a122"></a><a class="code" href="structAVPacket.html#aaf4fe58dfcc7c232c1f2268b539d8367">data</a> = (uint8_t *)frame;
pkt.<a name="a123"></a><a class="code" href="structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4">size</a> = <span class="keyword">sizeof</span>(<a name="_a124"></a><a class="code" href="structAVPicture.html" title="Picture data structure.">AVPicture</a>);
pkt.<a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...">pts</a> = pkt.<a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...">dts</a> = frame-><a class="code" href="structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4" title="Presentation timestamp in time_base units (time when frame should be shown to user).">pts</a>;
<a class="code" href="group__lavc__packet.html#gae5c86e4d93f6e7aa62ef2c60763ea67e" title="Convert valid timing fields (timestamps / durations) in a packet from one timebase to another...">av_packet_rescale_ts</a>(&pkt, c-><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>, ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>);
ret = <a class="code" href="group__lavf__encoding.html#ga37352ed2c63493c38219d935e71db6c1" title="Write a packet to an output media file ensuring correct interleaving.">av_interleaved_write_frame</a>(oc, &pkt);
} <span class="keywordflow">else</span> {
<a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> pkt = { 0 };
<a class="code" href="group__lavc__packet.html#gac9cb9756175b96e7441575803757fb73" title="Initialize optional fields of a packet with default values.">av_init_packet</a>(&pkt);
<span class="comment">/* encode the image */</span>
ret = <a name="a125"></a><a class="code" href="group__lavc__encoding.html#gaa2dc9e9ea2567ebb2801a08153c7306b" title="Encode a frame of video.">avcodec_encode_video2</a>(c, &pkt, frame, &got_packet);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Error encoding video frame: %s\n"</span>, <a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));
exit(1);
}
<span class="keywordflow">if</span> (got_packet) {
ret = <a class="code" href="muxing_8c.html#ab85f450fd9ee7aad777fc135b62dd3cd">write_frame</a>(oc, &c-><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>, ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>, &pkt);
} <span class="keywordflow">else</span> {
ret = 0;
}
}
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Error while writing video frame: %s\n"</span>, <a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));
exit(1);
}
<span class="keywordflow">return</span> (frame || got_packet) ? 0 : 1;
}
<span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a126"></a><a class="code" href="muxing_8c.html#a92d8b2751255677797d807161fae9d19">close_stream</a>(<a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *oc, <a class="code" href="structOutputStream.html">OutputStream</a> *ost)
{
<a name="a127"></a><a class="code" href="group__lavc__core.html#gaf4daa92361efb3523ef5afeb0b54077f" title="Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...">avcodec_close</a>(ost-><a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>);
<a name="a128"></a><a class="code" href="group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc" title="Free the frame and any dynamically allocated objects in it, e.g.">av_frame_free</a>(&ost-><a class="code" href="structOutputStream.html#a09ee2998f47d0e69c99dee8a6f71105a">frame</a>);
<a class="code" href="group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc" title="Free the frame and any dynamically allocated objects in it, e.g.">av_frame_free</a>(&ost-><a class="code" href="structOutputStream.html#a2ffa8b8369d869e8a440c2611ba91ae2">tmp_frame</a>);
<a name="a129"></a><a class="code" href="group__libsws.html#gad3af0ca76f071dbe0173444db9882932" title="Free the swscaler context swsContext.">sws_freeContext</a>(ost-><a class="code" href="structOutputStream.html#a87e6c2172dab3143e4857aaaf6558573">sws_ctx</a>);
<a name="a130"></a><a class="code" href="group__lswr.html#ga818f7d78b1ad7d8d5b70de374b668c34" title="Free the given SwrContext and set the pointer to NULL.">swr_free</a>(&ost-><a class="code" href="structOutputStream.html#a1a5c19db8f6a49a4d7a14168e4b73ec1">swr_ctx</a>);
}
<span class="comment">/**************************************************************/</span>
<span class="comment">/* media file output */</span>
<span class="keywordtype">int</span> <a name="a131"></a><a class="code" href="avio__list__dir_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
{
<a class="code" href="structOutputStream.html">OutputStream</a> video_st = { 0 }, audio_st = { 0 };
<span class="keyword">const</span> <span class="keywordtype">char</span> *filename;
<a name="_a132"></a><a class="code" href="structAVOutputFormat.html">AVOutputFormat</a> *fmt;
<a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *oc;
<a class="code" href="structAVCodec.html" title="AVCodec.">AVCodec</a> *audio_codec, *video_codec;
<span class="keywordtype">int</span> ret;
<span class="keywordtype">int</span> have_video = 0, have_audio = 0;
<span class="keywordtype">int</span> encode_video = 0, encode_audio = 0;
<a class="code" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> *opt = NULL;
<span class="comment">/* Initialize libavcodec, and register all codecs and formats. */</span>
<a name="a133"></a><a class="code" href="group__lavf__core.html#ga917265caec45ef5a0646356ed1a507e3" title="Initialize libavformat and register all the muxers, demuxers and protocols.">av_register_all</a>();
<span class="keywordflow">if</span> (argc < 2) {
printf(<span class="stringliteral">"usage: %s output_file\n"</span>
<span class="stringliteral">"API example program to output a media file with libavformat.\n"</span>
<span class="stringliteral">"This program generates a synthetic audio and video stream, encodes and\n"</span>
<span class="stringliteral">"muxes them into a file named output_file.\n"</span>
<span class="stringliteral">"The output format is automatically guessed according to the file extension.\n"</span>
<span class="stringliteral">"Raw images can also be output by using '%%d' in the filename.\n"</span>
<span class="stringliteral">"\n"</span>, argv[0]);
<span class="keywordflow">return</span> 1;
}
filename = argv[1];
<span class="keywordflow">if</span> (argc > 3 && !strcmp(argv[2], <span class="stringliteral">"-flags"</span>)) {
<a name="a134"></a><a class="code" href="group__lavu__dict.html#ga8d9c2de72b310cef8e6a28c9cd3acbbe" title="Set the given entry in *pm, overwriting an existing entry.">av_dict_set</a>(&opt, argv[2]+1, argv[3], 0);
}
<span class="comment">/* allocate the output media context */</span>
<a name="a135"></a><a class="code" href="avformat_8h.html#a6ddf3d982feb45fa5081420ee911f5d5" title="Allocate an AVFormatContext for an output format.">avformat_alloc_output_context2</a>(&oc, NULL, NULL, filename);
<span class="keywordflow">if</span> (!oc) {
printf(<span class="stringliteral">"Could not deduce output format from file extension: using MPEG.\n"</span>);
<a class="code" href="avformat_8h.html#a6ddf3d982feb45fa5081420ee911f5d5" title="Allocate an AVFormatContext for an output format.">avformat_alloc_output_context2</a>(&oc, NULL, <span class="stringliteral">"mpeg"</span>, filename);
}
<span class="keywordflow">if</span> (!oc)
<span class="keywordflow">return</span> 1;
fmt = oc-><a class="code" href="structAVFormatContext.html#a20d80ac07e38ff5c268d15aaf2798b98" title="The output container format.">oformat</a>;
<span class="comment">/* Add the audio and video streams using the default format codecs</span>
<span class="comment"> * and initialize the codecs. */</span>
<span class="keywordflow">if</span> (fmt-><a name="a136"></a><a class="code" href="structAVOutputFormat.html#a1354a9c8542b1b698157218336bd4754" title="default video codec">video_codec</a> != <a name="a137"></a><a class="code" href="group__lavc__core.html#ggaadca229ad2c20e060a14fec08a5cc7cea48761c50b102343e2648c3e28a94e7ab">AV_CODEC_ID_NONE</a>) {
<a class="code" href="muxing_8c.html#aead090f3b6525cfdfa572f18f7575219">add_stream</a>(&video_st, oc, &video_codec, fmt-><a class="code" href="structAVOutputFormat.html#a1354a9c8542b1b698157218336bd4754" title="default video codec">video_codec</a>);
have_video = 1;
encode_video = 1;
}
<span class="keywordflow">if</span> (fmt-><a name="a138"></a><a class="code" href="structAVOutputFormat.html#a2e4fff0aa061984d586ea08ecad96141" title="default audio codec">audio_codec</a> != <a class="code" href="group__lavc__core.html#ggaadca229ad2c20e060a14fec08a5cc7cea48761c50b102343e2648c3e28a94e7ab">AV_CODEC_ID_NONE</a>) {
<a class="code" href="muxing_8c.html#aead090f3b6525cfdfa572f18f7575219">add_stream</a>(&audio_st, oc, &audio_codec, fmt-><a class="code" href="structAVOutputFormat.html#a2e4fff0aa061984d586ea08ecad96141" title="default audio codec">audio_codec</a>);
have_audio = 1;
encode_audio = 1;
}
<span class="comment">/* Now that all the parameters are set, we can open the audio and</span>
<span class="comment"> * video codecs and allocate the necessary encode buffers. */</span>
<span class="keywordflow">if</span> (have_video)
<a class="code" href="muxing_8c.html#a34f7b1a6fc3698c190131c3df2e85903">open_video</a>(oc, video_codec, &video_st, opt);
<span class="keywordflow">if</span> (have_audio)
<a class="code" href="muxing_8c.html#ae7697b74a6a8605a91487b43e31f29be">open_audio</a>(oc, audio_codec, &audio_st, opt);
<a name="a139"></a><a class="code" href="group__lavf__misc.html#gae2645941f2dc779c307eb6314fd39f10" title="Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.">av_dump_format</a>(oc, 0, filename, 1);
<span class="comment">/* open the output file, if needed */</span>
<span class="keywordflow">if</span> (!(fmt-><a class="code" href="structAVOutputFormat.html#aad55a00e728a020c1dcfaaf695320445" title="can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT">flags</a> & <a name="a140"></a><a class="code" href="avformat_8h.html#a752cce390d480521919aa5d8be24ac0b" title="Demuxer will use avio_open, no opened file should be provided by the caller.">AVFMT_NOFILE</a>)) {
ret = <a name="a141"></a><a class="code" href="avio_8h.html#a371a670112abc5f3e15bc570da076301" title="Create and initialize a AVIOContext for accessing the resource indicated by url.">avio_open</a>(&oc-><a name="a142"></a><a class="code" href="structAVFormatContext.html#a1e7324262b6b78522e52064daaa7bc87" title="I/O context.">pb</a>, filename, <a name="a143"></a><a class="code" href="avio_8h.html#a5c9308f296545a8f3b7687d277a6dabc" title="write-only">AVIO_FLAG_WRITE</a>);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Could not open '%s': %s\n"</span>, filename,
<a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));
<span class="keywordflow">return</span> 1;
}
}
<span class="comment">/* Write the stream header, if any. */</span>
ret = <a name="a144"></a><a class="code" href="group__lavf__encoding.html#ga78d4e734fecb1d2385536e6dd5b7b9f5" title="Allocate the stream private data and write the stream header to an output media file.">avformat_write_header</a>(oc, &opt);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Error occurred when opening output file: %s\n"</span>,
<a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));
<span class="keywordflow">return</span> 1;
}
<span class="keywordflow">while</span> (encode_video || encode_audio) {
<span class="comment">/* select the stream to encode */</span>
<span class="keywordflow">if</span> (encode_video &&
(!encode_audio || <a class="code" href="group__lavu__math.html#ga151744358fff630942b926e67e67c415" title="Compare 2 timestamps each in its own timebases.">av_compare_ts</a>(video_st.<a class="code" href="structOutputStream.html#aaa3b9001e4dac709017237c1c177cd0a">next_pts</a>, video_st.<a class="code" href="structOutputStream.html#ac11510a2eeed3e6a14f0fbc85db2e088">st</a>-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>,
audio_st.next_pts, audio_st.st->codec->time_base) <= 0)) {
encode_video = !<a class="code" href="muxing_8c.html#a435288caae5076cca3273215cb6ad395">write_video_frame</a>(oc, &video_st);
} <span class="keywordflow">else</span> {
encode_audio = !<a class="code" href="muxing_8c.html#a789f35413429ab70610c90c22fc7a4d3">write_audio_frame</a>(oc, &audio_st);
}
}
<span class="comment">/* Write the trailer, if any. The trailer must be written before you</span>
<span class="comment"> * close the CodecContexts open when you wrote the header; otherwise</span>
<span class="comment"> * av_write_trailer() may try to use memory that was freed on</span>
<span class="comment"> * av_codec_close(). */</span>
<a name="a145"></a><a class="code" href="group__lavf__encoding.html#ga7f14007e7dc8f481f054b21614dfec13" title="Write the stream trailer to an output media file and free the file private data.">av_write_trailer</a>(oc);
<span class="comment">/* Close each codec. */</span>
<span class="keywordflow">if</span> (have_video)
<a class="code" href="muxing_8c.html#a92d8b2751255677797d807161fae9d19">close_stream</a>(oc, &video_st);
<span class="keywordflow">if</span> (have_audio)
<a class="code" href="muxing_8c.html#a92d8b2751255677797d807161fae9d19">close_stream</a>(oc, &audio_st);
<span class="keywordflow">if</span> (!(fmt-><a class="code" href="structAVOutputFormat.html#aad55a00e728a020c1dcfaaf695320445" title="can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT">flags</a> & <a class="code" href="avformat_8h.html#a752cce390d480521919aa5d8be24ac0b" title="Demuxer will use avio_open, no opened file should be provided by the caller.">AVFMT_NOFILE</a>))
<span class="comment">/* Close the output file. */</span>
<a name="a146"></a><a class="code" href="avio_8h.html#ae118a1f37f1e48617609ead9910aac15" title="Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...">avio_closep</a>(&oc-><a class="code" href="structAVFormatContext.html#a1e7324262b6b78522e52064daaa7bc87" title="I/O context.">pb</a>);
<span class="comment">/* free the stream */</span>
<a name="a147"></a><a class="code" href="group__lavf__core.html#gac2990b13b68e831a408fce8e1d0d6445" title="Free an AVFormatContext and all its streams.">avformat_free_context</a>(oc);
<span class="keywordflow">return</span> 0;
}
</pre></div> </div><!-- contents -->
</div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>
Generated by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>
</body>
</html>