Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
ffmpeg-doc / usr / share / doc / ffmpeg-doc / api / swresample_8h_source.html
Size: Mime:
<!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: libswresample/swresample.h Source File</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
   &#160;<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&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><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 id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">libswresample/swresample.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="swresample_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2011-2013 Michael Niedermayer (michaelni@gmx.at)</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * This file is part of libswresample</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * libswresample is free software; you can redistribute it and/or</span>
<a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00008"></a>00008 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00009"></a>00009 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> * libswresample is distributed in the hope that it will be useful,</span>
<a name="l00012"></a>00012 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00013"></a>00013 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00014"></a>00014 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00017"></a>00017 <span class="comment"> * License along with libswresample; if not, write to the Free Software</span>
<a name="l00018"></a>00018 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00019"></a>00019 <span class="comment"> */</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="preprocessor">#ifndef SWRESAMPLE_SWRESAMPLE_H</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define SWRESAMPLE_SWRESAMPLE_H</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00024"></a>00024 <span class="comment">/**</span>
<a name="l00025"></a>00025 <span class="comment"> * @file</span>
<a name="l00026"></a>00026 <span class="comment"> * @ingroup lswr</span>
<a name="l00027"></a>00027 <span class="comment"> * libswresample public header</span>
<a name="l00028"></a>00028 <span class="comment"> */</span>
<a name="l00029"></a>00029 <span class="comment"></span>
<a name="l00030"></a>00030 <span class="comment">/**</span>
<a name="l00031"></a>00031 <span class="comment"> * @defgroup lswr Libswresample</span>
<a name="l00032"></a>00032 <span class="comment"> * @{</span>
<a name="l00033"></a>00033 <span class="comment"> *</span>
<a name="l00034"></a>00034 <span class="comment"> * Libswresample (lswr) is a library that handles audio resampling, sample</span>
<a name="l00035"></a>00035 <span class="comment"> * format conversion and mixing.</span>
<a name="l00036"></a>00036 <span class="comment"> *</span>
<a name="l00037"></a>00037 <span class="comment"> * Interaction with lswr is done through SwrContext, which is</span>
<a name="l00038"></a>00038 <span class="comment"> * allocated with swr_alloc() or swr_alloc_set_opts(). It is opaque, so all parameters</span>
<a name="l00039"></a>00039 <span class="comment"> * must be set with the @ref avoptions API.</span>
<a name="l00040"></a>00040 <span class="comment"> *</span>
<a name="l00041"></a>00041 <span class="comment"> * The first thing you will need to do in order to use lswr is to allocate</span>
<a name="l00042"></a>00042 <span class="comment"> * SwrContext. This can be done with swr_alloc() or swr_alloc_set_opts(). If you</span>
<a name="l00043"></a>00043 <span class="comment"> * are using the former, you must set options through the @ref avoptions API.</span>
<a name="l00044"></a>00044 <span class="comment"> * The latter function provides the same feature, but it allows you to set some</span>
<a name="l00045"></a>00045 <span class="comment"> * common options in the same statement.</span>
<a name="l00046"></a>00046 <span class="comment"> *</span>
<a name="l00047"></a>00047 <span class="comment"> * For example the following code will setup conversion from planar float sample</span>
<a name="l00048"></a>00048 <span class="comment"> * format to interleaved signed 16-bit integer, downsampling from 48kHz to</span>
<a name="l00049"></a>00049 <span class="comment"> * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing</span>
<a name="l00050"></a>00050 <span class="comment"> * matrix). This is using the swr_alloc() function.</span>
<a name="l00051"></a>00051 <span class="comment"> * @code</span>
<a name="l00052"></a>00052 <span class="comment"> * SwrContext *swr = swr_alloc();</span>
<a name="l00053"></a>00053 <span class="comment"> * av_opt_set_channel_layout(swr, &quot;in_channel_layout&quot;,  AV_CH_LAYOUT_5POINT1, 0);</span>
<a name="l00054"></a>00054 <span class="comment"> * av_opt_set_channel_layout(swr, &quot;out_channel_layout&quot;, AV_CH_LAYOUT_STEREO,  0);</span>
<a name="l00055"></a>00055 <span class="comment"> * av_opt_set_int(swr, &quot;in_sample_rate&quot;,     48000,                0);</span>
<a name="l00056"></a>00056 <span class="comment"> * av_opt_set_int(swr, &quot;out_sample_rate&quot;,    44100,                0);</span>
<a name="l00057"></a>00057 <span class="comment"> * av_opt_set_sample_fmt(swr, &quot;in_sample_fmt&quot;,  AV_SAMPLE_FMT_FLTP, 0);</span>
<a name="l00058"></a>00058 <span class="comment"> * av_opt_set_sample_fmt(swr, &quot;out_sample_fmt&quot;, AV_SAMPLE_FMT_S16,  0);</span>
<a name="l00059"></a>00059 <span class="comment"> * @endcode</span>
<a name="l00060"></a>00060 <span class="comment"> *</span>
<a name="l00061"></a>00061 <span class="comment"> * The same job can be done using swr_alloc_set_opts() as well:</span>
<a name="l00062"></a>00062 <span class="comment"> * @code</span>
<a name="l00063"></a>00063 <span class="comment"> * SwrContext *swr = swr_alloc_set_opts(NULL,  // we&#39;re allocating a new context</span>
<a name="l00064"></a>00064 <span class="comment"> *                       AV_CH_LAYOUT_STEREO,  // out_ch_layout</span>
<a name="l00065"></a>00065 <span class="comment"> *                       AV_SAMPLE_FMT_S16,    // out_sample_fmt</span>
<a name="l00066"></a>00066 <span class="comment"> *                       44100,                // out_sample_rate</span>
<a name="l00067"></a>00067 <span class="comment"> *                       AV_CH_LAYOUT_5POINT1, // in_ch_layout</span>
<a name="l00068"></a>00068 <span class="comment"> *                       AV_SAMPLE_FMT_FLTP,   // in_sample_fmt</span>
<a name="l00069"></a>00069 <span class="comment"> *                       48000,                // in_sample_rate</span>
<a name="l00070"></a>00070 <span class="comment"> *                       0,                    // log_offset</span>
<a name="l00071"></a>00071 <span class="comment"> *                       NULL);                // log_ctx</span>
<a name="l00072"></a>00072 <span class="comment"> * @endcode</span>
<a name="l00073"></a>00073 <span class="comment"> *</span>
<a name="l00074"></a>00074 <span class="comment"> * Once all values have been set, it must be initialized with swr_init(). If</span>
<a name="l00075"></a>00075 <span class="comment"> * you need to change the conversion parameters, you can change the parameters</span>
<a name="l00076"></a>00076 <span class="comment"> * using @ref AVOptions, as described above in the first example; or by using</span>
<a name="l00077"></a>00077 <span class="comment"> * swr_alloc_set_opts(), but with the first argument the allocated context.</span>
<a name="l00078"></a>00078 <span class="comment"> * You must then call swr_init() again.</span>
<a name="l00079"></a>00079 <span class="comment"> *</span>
<a name="l00080"></a>00080 <span class="comment"> * The conversion itself is done by repeatedly calling swr_convert().</span>
<a name="l00081"></a>00081 <span class="comment"> * Note that the samples may get buffered in swr if you provide insufficient</span>
<a name="l00082"></a>00082 <span class="comment"> * output space or if sample rate conversion is done, which requires &quot;future&quot;</span>
<a name="l00083"></a>00083 <span class="comment"> * samples. Samples that do not require future input can be retrieved at any</span>
<a name="l00084"></a>00084 <span class="comment"> * time by using swr_convert() (in_count can be set to 0).</span>
<a name="l00085"></a>00085 <span class="comment"> * At the end of conversion the resampling buffer can be flushed by calling</span>
<a name="l00086"></a>00086 <span class="comment"> * swr_convert() with NULL in and 0 in_count.</span>
<a name="l00087"></a>00087 <span class="comment"> *</span>
<a name="l00088"></a>00088 <span class="comment"> * The samples used in the conversion process can be managed with the libavutil</span>
<a name="l00089"></a>00089 <span class="comment"> * @ref lavu_sampmanip &quot;samples manipulation&quot; API, including av_samples_alloc()</span>
<a name="l00090"></a>00090 <span class="comment"> * function used in the following example.</span>
<a name="l00091"></a>00091 <span class="comment"> *</span>
<a name="l00092"></a>00092 <span class="comment"> * The delay between input and output, can at any time be found by using</span>
<a name="l00093"></a>00093 <span class="comment"> * swr_get_delay().</span>
<a name="l00094"></a>00094 <span class="comment"> *</span>
<a name="l00095"></a>00095 <span class="comment"> * The following code demonstrates the conversion loop assuming the parameters</span>
<a name="l00096"></a>00096 <span class="comment"> * from above and caller-defined functions get_input() and handle_output():</span>
<a name="l00097"></a>00097 <span class="comment"> * @code</span>
<a name="l00098"></a>00098 <span class="comment"> * uint8_t **input;</span>
<a name="l00099"></a>00099 <span class="comment"> * int in_samples;</span>
<a name="l00100"></a>00100 <span class="comment"> *</span>
<a name="l00101"></a>00101 <span class="comment"> * while (get_input(&amp;input, &amp;in_samples)) {</span>
<a name="l00102"></a>00102 <span class="comment"> *     uint8_t *output;</span>
<a name="l00103"></a>00103 <span class="comment"> *     int out_samples = av_rescale_rnd(swr_get_delay(swr, 48000) +</span>
<a name="l00104"></a>00104 <span class="comment"> *                                      in_samples, 44100, 48000, AV_ROUND_UP);</span>
<a name="l00105"></a>00105 <span class="comment"> *     av_samples_alloc(&amp;output, NULL, 2, out_samples,</span>
<a name="l00106"></a>00106 <span class="comment"> *                      AV_SAMPLE_FMT_S16, 0);</span>
<a name="l00107"></a>00107 <span class="comment"> *     out_samples = swr_convert(swr, &amp;output, out_samples,</span>
<a name="l00108"></a>00108 <span class="comment"> *                                      input, in_samples);</span>
<a name="l00109"></a>00109 <span class="comment"> *     handle_output(output, out_samples);</span>
<a name="l00110"></a>00110 <span class="comment"> *     av_freep(&amp;output);</span>
<a name="l00111"></a>00111 <span class="comment"> * }</span>
<a name="l00112"></a>00112 <span class="comment"> * @endcode</span>
<a name="l00113"></a>00113 <span class="comment"> *</span>
<a name="l00114"></a>00114 <span class="comment"> * When the conversion is finished, the conversion</span>
<a name="l00115"></a>00115 <span class="comment"> * context and everything associated with it must be freed with swr_free().</span>
<a name="l00116"></a>00116 <span class="comment"> * A swr_close() function is also available, but it exists mainly for</span>
<a name="l00117"></a>00117 <span class="comment"> * compatibility with libavresample, and is not required to be called.</span>
<a name="l00118"></a>00118 <span class="comment"> *</span>
<a name="l00119"></a>00119 <span class="comment"> * There will be no memory leak if the data is not completely flushed before</span>
<a name="l00120"></a>00120 <span class="comment"> * swr_free().</span>
<a name="l00121"></a>00121 <span class="comment"> */</span>
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 <span class="preprocessor">#include &lt;stdint.h&gt;</span>
<a name="l00124"></a>00124 <span class="preprocessor">#include &quot;<a class="code" href="frame_8h.html" title="reference-counted frame API">libavutil/frame.h</a>&quot;</span>
<a name="l00125"></a>00125 <span class="preprocessor">#include &quot;<a class="code" href="samplefmt_8h.html">libavutil/samplefmt.h</a>&quot;</span>
<a name="l00126"></a>00126 
<a name="l00127"></a>00127 <span class="preprocessor">#include &quot;<a class="code" href="libswresample_2version_8h.html" title="Libswresample version macros.">libswresample/version.h</a>&quot;</span>
<a name="l00128"></a>00128 
<a name="l00129"></a>00129 <span class="preprocessor">#if LIBSWRESAMPLE_VERSION_MAJOR &lt; 1</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span><span class="preprocessor">#define SWR_CH_MAX 32   ///&lt; Maximum number of channels</span>
<a name="l00131"></a>00131 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00132"></a>00132 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00133"></a>00133 <span class="comment">/**</span>
<a name="l00134"></a>00134 <span class="comment"> * @name Option constants</span>
<a name="l00135"></a>00135 <span class="comment"> * These constants are used for the @ref avoptions interface for lswr.</span>
<a name="l00136"></a>00136 <span class="comment"> * @{</span>
<a name="l00137"></a>00137 <span class="comment"> *</span>
<a name="l00138"></a>00138 <span class="comment"> */</span>
<a name="l00139"></a>00139 
<a name="l00140"></a><a class="code" href="group__lswr.html#ga2226aca7f49137f3f29b6f731a985916">00140</a> <span class="preprocessor">#define SWR_FLAG_RESAMPLE 1 ///&lt; Force resampling even if equal sample rate</span>
<a name="l00141"></a>00141 <span class="preprocessor"></span><span class="comment">//TODO use int resample ?</span>
<a name="l00142"></a>00142 <span class="comment">//long term TODO can we enable this dynamically?</span>
<a name="l00143"></a>00143 <span class="comment"></span>
<a name="l00144"></a>00144 <span class="comment">/** Dithering algorithms */</span>
<a name="l00145"></a><a class="code" href="group__lswr.html#ga387e613b19e5269a46d9ff1a5ee3fcd4">00145</a> <span class="keyword">enum</span> <a class="code" href="group__lswr.html#ga387e613b19e5269a46d9ff1a5ee3fcd4" title="Dithering algorithms.">SwrDitherType</a> {
<a name="l00146"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4afacc17a82581598f762a8036ba559836">00146</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4afacc17a82581598f762a8036ba559836">SWR_DITHER_NONE</a> = 0,
<a name="l00147"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4a0fec2dd28b1357b50e9807ca6ecee83a">00147</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4a0fec2dd28b1357b50e9807ca6ecee83a">SWR_DITHER_RECTANGULAR</a>,
<a name="l00148"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ae4635dc355dc680eeb211e7af17ddfd2">00148</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ae4635dc355dc680eeb211e7af17ddfd2">SWR_DITHER_TRIANGULAR</a>,
<a name="l00149"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4a91276f2e437aa9d0d8bdffabe24f5532">00149</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4a91276f2e437aa9d0d8bdffabe24f5532">SWR_DITHER_TRIANGULAR_HIGHPASS</a>,
<a name="l00150"></a>00150 
<a name="l00151"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ae6858a54f5b2e1bffa9aaef20b2593c0">00151</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ae6858a54f5b2e1bffa9aaef20b2593c0" title="not part of API/ABI">SWR_DITHER_NS</a> = 64,         <span class="comment">///&lt; not part of API/ABI</span>
<a name="l00152"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4a6f6072071262f7f05a52057cfe48df87">00152</a> <span class="comment"></span>    <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4a6f6072071262f7f05a52057cfe48df87">SWR_DITHER_NS_LIPSHITZ</a>,
<a name="l00153"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ae197d7fc5592652aaa8edf1067c56af9">00153</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ae197d7fc5592652aaa8edf1067c56af9">SWR_DITHER_NS_F_WEIGHTED</a>,
<a name="l00154"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4a60eeb8ca5de47916a81f2c3a6534eed4">00154</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4a60eeb8ca5de47916a81f2c3a6534eed4">SWR_DITHER_NS_MODIFIED_E_WEIGHTED</a>,
<a name="l00155"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ad13d2ff2831d463eb46ca4c46dfec7b0">00155</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ad13d2ff2831d463eb46ca4c46dfec7b0">SWR_DITHER_NS_IMPROVED_E_WEIGHTED</a>,
<a name="l00156"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ae3aba4bf43c2210a148b11c0215b5d24">00156</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ae3aba4bf43c2210a148b11c0215b5d24">SWR_DITHER_NS_SHIBATA</a>,
<a name="l00157"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4af275c21089abbf78a6623544f34d76f9">00157</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4af275c21089abbf78a6623544f34d76f9">SWR_DITHER_NS_LOW_SHIBATA</a>,
<a name="l00158"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ac569828a706ccf22a8d5810c973c8f17">00158</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4ac569828a706ccf22a8d5810c973c8f17">SWR_DITHER_NS_HIGH_SHIBATA</a>,
<a name="l00159"></a><a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4aacbdf2f91bb14cf390116492115fb8ea">00159</a>     <a class="code" href="group__lswr.html#gga387e613b19e5269a46d9ff1a5ee3fcd4aacbdf2f91bb14cf390116492115fb8ea" title="not part of API/ABI">SWR_DITHER_NB</a>,              <span class="comment">///&lt; not part of API/ABI</span>
<a name="l00160"></a>00160 <span class="comment"></span>};
<a name="l00161"></a>00161 <span class="comment"></span>
<a name="l00162"></a>00162 <span class="comment">/** Resampling Engines */</span>
<a name="l00163"></a><a class="code" href="group__lswr.html#ga87f9e023bbe780d3ccf17dfc7abed580">00163</a> <span class="keyword">enum</span> <a class="code" href="group__lswr.html#ga87f9e023bbe780d3ccf17dfc7abed580" title="Resampling Engines.">SwrEngine</a> {
<a name="l00164"></a><a class="code" href="group__lswr.html#gga87f9e023bbe780d3ccf17dfc7abed580a11652db5af0c279d79deba1c577c9729">00164</a>     <a class="code" href="group__lswr.html#gga87f9e023bbe780d3ccf17dfc7abed580a11652db5af0c279d79deba1c577c9729" title="SW Resampler.">SWR_ENGINE_SWR</a>,             <span class="comment">/**&lt; SW Resampler */</span>
<a name="l00165"></a><a class="code" href="group__lswr.html#gga87f9e023bbe780d3ccf17dfc7abed580a2933f5b0b96829095a04a8acd19b27e7">00165</a>     <a class="code" href="group__lswr.html#gga87f9e023bbe780d3ccf17dfc7abed580a2933f5b0b96829095a04a8acd19b27e7" title="SoX Resampler.">SWR_ENGINE_SOXR</a>,            <span class="comment">/**&lt; SoX Resampler */</span>
<a name="l00166"></a><a class="code" href="group__lswr.html#gga87f9e023bbe780d3ccf17dfc7abed580a865af2e70ebb85b3cafb93f1854dbef9">00166</a>     <a class="code" href="group__lswr.html#gga87f9e023bbe780d3ccf17dfc7abed580a865af2e70ebb85b3cafb93f1854dbef9" title="not part of API/ABI">SWR_ENGINE_NB</a>,              <span class="comment">///&lt; not part of API/ABI</span>
<a name="l00167"></a>00167 <span class="comment"></span>};
<a name="l00168"></a>00168 <span class="comment"></span>
<a name="l00169"></a>00169 <span class="comment">/** Resampling Filter Types */</span>
<a name="l00170"></a><a class="code" href="group__lswr.html#ga2176b2a3a8b809788f6e7ccdc238b6be">00170</a> <span class="keyword">enum</span> <a class="code" href="group__lswr.html#ga2176b2a3a8b809788f6e7ccdc238b6be" title="Resampling Filter Types.">SwrFilterType</a> {
<a name="l00171"></a><a class="code" href="group__lswr.html#gga2176b2a3a8b809788f6e7ccdc238b6bea1a6413b9888bac851e2ee4f991f01d0c">00171</a>     <a class="code" href="group__lswr.html#gga2176b2a3a8b809788f6e7ccdc238b6bea1a6413b9888bac851e2ee4f991f01d0c" title="Cubic.">SWR_FILTER_TYPE_CUBIC</a>,              <span class="comment">/**&lt; Cubic */</span>
<a name="l00172"></a><a class="code" href="group__lswr.html#gga2176b2a3a8b809788f6e7ccdc238b6bea17f5dd4512b4abc2285905293a81cf55">00172</a>     <a class="code" href="group__lswr.html#gga2176b2a3a8b809788f6e7ccdc238b6bea17f5dd4512b4abc2285905293a81cf55" title="Blackman Nuttall Windowed Sinc.">SWR_FILTER_TYPE_BLACKMAN_NUTTALL</a>,   <span class="comment">/**&lt; Blackman Nuttall Windowed Sinc */</span>
<a name="l00173"></a><a class="code" href="group__lswr.html#gga2176b2a3a8b809788f6e7ccdc238b6bea8f492a5dc94b6e41a37f190c5492bf3f">00173</a>     <a class="code" href="group__lswr.html#gga2176b2a3a8b809788f6e7ccdc238b6bea8f492a5dc94b6e41a37f190c5492bf3f" title="Kaiser Windowed Sinc.">SWR_FILTER_TYPE_KAISER</a>,             <span class="comment">/**&lt; Kaiser Windowed Sinc */</span>
<a name="l00174"></a>00174 };
<a name="l00175"></a>00175 <span class="comment"></span>
<a name="l00176"></a>00176 <span class="comment">/**</span>
<a name="l00177"></a>00177 <span class="comment"> * @}</span>
<a name="l00178"></a>00178 <span class="comment"> */</span>
<a name="l00179"></a>00179 <span class="comment"></span>
<a name="l00180"></a>00180 <span class="comment">/**</span>
<a name="l00181"></a>00181 <span class="comment"> * The libswresample context. Unlike libavcodec and libavformat, this structure</span>
<a name="l00182"></a>00182 <span class="comment"> * is opaque. This means that if you would like to set options, you must use</span>
<a name="l00183"></a>00183 <span class="comment"> * the @ref avoptions API and cannot directly set values to members of the</span>
<a name="l00184"></a>00184 <span class="comment"> * structure.</span>
<a name="l00185"></a>00185 <span class="comment"> */</span>
<a name="l00186"></a><a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863">00186</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a>;
<a name="l00187"></a>00187 <span class="comment"></span>
<a name="l00188"></a>00188 <span class="comment">/**</span>
<a name="l00189"></a>00189 <span class="comment"> * Get the AVClass for SwrContext. It can be used in combination with</span>
<a name="l00190"></a>00190 <span class="comment"> * AV_OPT_SEARCH_FAKE_OBJ for examining options.</span>
<a name="l00191"></a>00191 <span class="comment"> *</span>
<a name="l00192"></a>00192 <span class="comment"> * @see av_opt_find().</span>
<a name="l00193"></a>00193 <span class="comment"> * @return the AVClass of SwrContext</span>
<a name="l00194"></a>00194 <span class="comment"> */</span>
<a name="l00195"></a>00195 <span class="keyword">const</span> <a class="code" href="structAVClass.html" title="Describe the class of an AVClass context structure.">AVClass</a> *<a class="code" href="group__lswr.html#ga6ca0298348b382cf0fe67d7f339a17f3" title="Get the AVClass for SwrContext.">swr_get_class</a>(<span class="keywordtype">void</span>);
<a name="l00196"></a>00196 <span class="comment"></span>
<a name="l00197"></a>00197 <span class="comment">/**</span>
<a name="l00198"></a>00198 <span class="comment"> * @name SwrContext constructor functions</span>
<a name="l00199"></a>00199 <span class="comment"> * @{</span>
<a name="l00200"></a>00200 <span class="comment"> */</span>
<a name="l00201"></a>00201 <span class="comment"></span>
<a name="l00202"></a>00202 <span class="comment">/**</span>
<a name="l00203"></a>00203 <span class="comment"> * Allocate SwrContext.</span>
<a name="l00204"></a>00204 <span class="comment"> *</span>
<a name="l00205"></a>00205 <span class="comment"> * If you use this function you will need to set the parameters (manually or</span>
<a name="l00206"></a>00206 <span class="comment"> * with swr_alloc_set_opts()) before calling swr_init().</span>
<a name="l00207"></a>00207 <span class="comment"> *</span>
<a name="l00208"></a>00208 <span class="comment"> * @see swr_alloc_set_opts(), swr_init(), swr_free()</span>
<a name="l00209"></a>00209 <span class="comment"> * @return NULL on error, allocated context otherwise</span>
<a name="l00210"></a>00210 <span class="comment"> */</span>
<a name="l00211"></a>00211 <span class="keyword">struct </span><a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *<a class="code" href="group__lswr.html#gaf58c4ff10f73d74bdab8e5aa7193147c" title="Allocate SwrContext.">swr_alloc</a>(<span class="keywordtype">void</span>);
<a name="l00212"></a>00212 <span class="comment"></span>
<a name="l00213"></a>00213 <span class="comment">/**</span>
<a name="l00214"></a>00214 <span class="comment"> * Initialize context after user parameters have been set.</span>
<a name="l00215"></a>00215 <span class="comment"> * @note The context must be configured using the AVOption API.</span>
<a name="l00216"></a>00216 <span class="comment"> *</span>
<a name="l00217"></a>00217 <span class="comment"> * @see av_opt_set_int()</span>
<a name="l00218"></a>00218 <span class="comment"> * @see av_opt_set_dict()</span>
<a name="l00219"></a>00219 <span class="comment"> *</span>
<a name="l00220"></a>00220 <span class="comment"> * @param[in,out]   s Swr context to initialize</span>
<a name="l00221"></a>00221 <span class="comment"> * @return AVERROR error code in case of failure.</span>
<a name="l00222"></a>00222 <span class="comment"> */</span>
<a name="l00223"></a>00223 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#gae173e8ed91717700471a1dcd06f00f67" title="Initialize context after user parameters have been set.">swr_init</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s);
<a name="l00224"></a>00224 <span class="comment"></span>
<a name="l00225"></a>00225 <span class="comment">/**</span>
<a name="l00226"></a>00226 <span class="comment"> * Check whether an swr context has been initialized or not.</span>
<a name="l00227"></a>00227 <span class="comment"> *</span>
<a name="l00228"></a>00228 <span class="comment"> * @param[in]       s Swr context to check</span>
<a name="l00229"></a>00229 <span class="comment"> * @see swr_init()</span>
<a name="l00230"></a>00230 <span class="comment"> * @return positive if it has been initialized, 0 if not initialized</span>
<a name="l00231"></a>00231 <span class="comment"> */</span>
<a name="l00232"></a>00232 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#gab11b02705e97404b6d74b18b2fcfdfcf" title="Check whether an swr context has been initialized or not.">swr_is_initialized</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s);
<a name="l00233"></a>00233 <span class="comment"></span>
<a name="l00234"></a>00234 <span class="comment">/**</span>
<a name="l00235"></a>00235 <span class="comment"> * Allocate SwrContext if needed and set/reset common parameters.</span>
<a name="l00236"></a>00236 <span class="comment"> *</span>
<a name="l00237"></a>00237 <span class="comment"> * This function does not require s to be allocated with swr_alloc(). On the</span>
<a name="l00238"></a>00238 <span class="comment"> * other hand, swr_alloc() can use swr_alloc_set_opts() to set the parameters</span>
<a name="l00239"></a>00239 <span class="comment"> * on the allocated context.</span>
<a name="l00240"></a>00240 <span class="comment"> *</span>
<a name="l00241"></a>00241 <span class="comment"> * @param s               existing Swr context if available, or NULL if not</span>
<a name="l00242"></a>00242 <span class="comment"> * @param out_ch_layout   output channel layout (AV_CH_LAYOUT_*)</span>
<a name="l00243"></a>00243 <span class="comment"> * @param out_sample_fmt  output sample format (AV_SAMPLE_FMT_*).</span>
<a name="l00244"></a>00244 <span class="comment"> * @param out_sample_rate output sample rate (frequency in Hz)</span>
<a name="l00245"></a>00245 <span class="comment"> * @param in_ch_layout    input channel layout (AV_CH_LAYOUT_*)</span>
<a name="l00246"></a>00246 <span class="comment"> * @param in_sample_fmt   input sample format (AV_SAMPLE_FMT_*).</span>
<a name="l00247"></a>00247 <span class="comment"> * @param in_sample_rate  input sample rate (frequency in Hz)</span>
<a name="l00248"></a>00248 <span class="comment"> * @param log_offset      logging level offset</span>
<a name="l00249"></a>00249 <span class="comment"> * @param log_ctx         parent logging context, can be NULL</span>
<a name="l00250"></a>00250 <span class="comment"> *</span>
<a name="l00251"></a>00251 <span class="comment"> * @see swr_init(), swr_free()</span>
<a name="l00252"></a>00252 <span class="comment"> * @return NULL on error, allocated context otherwise</span>
<a name="l00253"></a>00253 <span class="comment"> */</span>
<a name="l00254"></a>00254 <span class="keyword">struct </span><a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *<a class="code" href="group__lswr.html#gad7f29022726c871aadf935281a9813bc" title="Allocate SwrContext if needed and set/reset common parameters.">swr_alloc_set_opts</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s,
<a name="l00255"></a>00255                                       int64_t out_ch_layout, <span class="keyword">enum</span> <a class="code" href="group__lavu__sampfmts.html#gaf9a51ca15301871723577c730b5865c5" title="Audio sample formats.">AVSampleFormat</a> out_sample_fmt, <span class="keywordtype">int</span> out_sample_rate,
<a name="l00256"></a>00256                                       int64_t  in_ch_layout, <span class="keyword">enum</span> <a class="code" href="group__lavu__sampfmts.html#gaf9a51ca15301871723577c730b5865c5" title="Audio sample formats.">AVSampleFormat</a>  in_sample_fmt, <span class="keywordtype">int</span>  in_sample_rate,
<a name="l00257"></a>00257                                       <span class="keywordtype">int</span> log_offset, <span class="keywordtype">void</span> *log_ctx);
<a name="l00258"></a>00258 <span class="comment"></span>
<a name="l00259"></a>00259 <span class="comment">/**</span>
<a name="l00260"></a>00260 <span class="comment"> * @}</span>
<a name="l00261"></a>00261 <span class="comment"> *</span>
<a name="l00262"></a>00262 <span class="comment"> * @name SwrContext destructor functions</span>
<a name="l00263"></a>00263 <span class="comment"> * @{</span>
<a name="l00264"></a>00264 <span class="comment"> */</span>
<a name="l00265"></a>00265 <span class="comment"></span>
<a name="l00266"></a>00266 <span class="comment">/**</span>
<a name="l00267"></a>00267 <span class="comment"> * Free the given SwrContext and set the pointer to NULL.</span>
<a name="l00268"></a>00268 <span class="comment"> *</span>
<a name="l00269"></a>00269 <span class="comment"> * @param[in] s a pointer to a pointer to Swr context</span>
<a name="l00270"></a>00270 <span class="comment"> */</span>
<a name="l00271"></a>00271 <span class="keywordtype">void</span> <a class="code" href="group__lswr.html#ga818f7d78b1ad7d8d5b70de374b668c34" title="Free the given SwrContext and set the pointer to NULL.">swr_free</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> **s);
<a name="l00272"></a>00272 <span class="comment"></span>
<a name="l00273"></a>00273 <span class="comment">/**</span>
<a name="l00274"></a>00274 <span class="comment"> * Closes the context so that swr_is_initialized() returns 0.</span>
<a name="l00275"></a>00275 <span class="comment"> *</span>
<a name="l00276"></a>00276 <span class="comment"> * The context can be brought back to life by running swr_init(),</span>
<a name="l00277"></a>00277 <span class="comment"> * swr_init() can also be used without swr_close().</span>
<a name="l00278"></a>00278 <span class="comment"> * This function is mainly provided for simplifying the usecase</span>
<a name="l00279"></a>00279 <span class="comment"> * where one tries to support libavresample and libswresample.</span>
<a name="l00280"></a>00280 <span class="comment"> *</span>
<a name="l00281"></a>00281 <span class="comment"> * @param[in,out] s Swr context to be closed</span>
<a name="l00282"></a>00282 <span class="comment"> */</span>
<a name="l00283"></a>00283 <span class="keywordtype">void</span> <a class="code" href="group__lswr.html#gaa4bf1048740dfc08d68aba9f1b4db22e" title="Closes the context so that swr_is_initialized() returns 0.">swr_close</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s);
<a name="l00284"></a>00284 <span class="comment"></span>
<a name="l00285"></a>00285 <span class="comment">/**</span>
<a name="l00286"></a>00286 <span class="comment"> * @}</span>
<a name="l00287"></a>00287 <span class="comment"> *</span>
<a name="l00288"></a>00288 <span class="comment"> * @name Core conversion functions</span>
<a name="l00289"></a>00289 <span class="comment"> * @{</span>
<a name="l00290"></a>00290 <span class="comment"> */</span>
<a name="l00291"></a>00291 <span class="comment"></span>
<a name="l00292"></a>00292 <span class="comment">/** Convert audio.</span>
<a name="l00293"></a>00293 <span class="comment"> *</span>
<a name="l00294"></a>00294 <span class="comment"> * in and in_count can be set to 0 to flush the last few samples out at the</span>
<a name="l00295"></a>00295 <span class="comment"> * end.</span>
<a name="l00296"></a>00296 <span class="comment"> *</span>
<a name="l00297"></a>00297 <span class="comment"> * If more input is provided than output space, then the input will be buffered.</span>
<a name="l00298"></a>00298 <span class="comment"> * You can avoid this buffering by using swr_get_out_samples() to retrieve an</span>
<a name="l00299"></a>00299 <span class="comment"> * upper bound on the required number of output samples for the given number of</span>
<a name="l00300"></a>00300 <span class="comment"> * input samples. Conversion will run directly without copying whenever possible.</span>
<a name="l00301"></a>00301 <span class="comment"> *</span>
<a name="l00302"></a>00302 <span class="comment"> * @param s         allocated Swr context, with parameters set</span>
<a name="l00303"></a>00303 <span class="comment"> * @param out       output buffers, only the first one need be set in case of packed audio</span>
<a name="l00304"></a>00304 <span class="comment"> * @param out_count amount of space available for output in samples per channel</span>
<a name="l00305"></a>00305 <span class="comment"> * @param in        input buffers, only the first one need to be set in case of packed audio</span>
<a name="l00306"></a>00306 <span class="comment"> * @param in_count  number of input samples available in one channel</span>
<a name="l00307"></a>00307 <span class="comment"> *</span>
<a name="l00308"></a>00308 <span class="comment"> * @return number of samples output per channel, negative value on error</span>
<a name="l00309"></a>00309 <span class="comment"> */</span>
<a name="l00310"></a>00310 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#gaa5bb6cab830146efa8c760fa66ee582a" title="Convert audio.">swr_convert</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, uint8_t **out, <span class="keywordtype">int</span> out_count,
<a name="l00311"></a>00311                                 <span class="keyword">const</span> uint8_t **in , <span class="keywordtype">int</span> in_count);
<a name="l00312"></a>00312 <span class="comment"></span>
<a name="l00313"></a>00313 <span class="comment">/**</span>
<a name="l00314"></a>00314 <span class="comment"> * Convert the next timestamp from input to output</span>
<a name="l00315"></a>00315 <span class="comment"> * timestamps are in 1/(in_sample_rate * out_sample_rate) units.</span>
<a name="l00316"></a>00316 <span class="comment"> *</span>
<a name="l00317"></a>00317 <span class="comment"> * @note There are 2 slightly differently behaving modes.</span>
<a name="l00318"></a>00318 <span class="comment"> *       @li When automatic timestamp compensation is not used, (min_compensation &gt;= FLT_MAX)</span>
<a name="l00319"></a>00319 <span class="comment"> *              in this case timestamps will be passed through with delays compensated</span>
<a name="l00320"></a>00320 <span class="comment"> *       @li When automatic timestamp compensation is used, (min_compensation &lt; FLT_MAX)</span>
<a name="l00321"></a>00321 <span class="comment"> *              in this case the output timestamps will match output sample numbers.</span>
<a name="l00322"></a>00322 <span class="comment"> *              See ffmpeg-resampler(1) for the two modes of compensation.</span>
<a name="l00323"></a>00323 <span class="comment"> *</span>
<a name="l00324"></a>00324 <span class="comment"> * @param s[in]     initialized Swr context</span>
<a name="l00325"></a>00325 <span class="comment"> * @param pts[in]   timestamp for the next input sample, INT64_MIN if unknown</span>
<a name="l00326"></a>00326 <span class="comment"> * @see swr_set_compensation(), swr_drop_output(), and swr_inject_silence() are</span>
<a name="l00327"></a>00327 <span class="comment"> *      function used internally for timestamp compensation.</span>
<a name="l00328"></a>00328 <span class="comment"> * @return the output timestamp for the next output sample</span>
<a name="l00329"></a>00329 <span class="comment"> */</span>
<a name="l00330"></a>00330 int64_t <a class="code" href="group__lswr.html#gaad9811626c6c01a241f6bf46aff27333" title="Convert the next timestamp from input to output timestamps are in 1/(in_sample_rate * out_sample_rate...">swr_next_pts</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, int64_t <a class="code" href="transcode__aac_8c.html#a4fbb704fb96c36a78a36eee010306ce7" title="Global timestamp for the audio frames.">pts</a>);
<a name="l00331"></a>00331 <span class="comment"></span>
<a name="l00332"></a>00332 <span class="comment">/**</span>
<a name="l00333"></a>00333 <span class="comment"> * @}</span>
<a name="l00334"></a>00334 <span class="comment"> *</span>
<a name="l00335"></a>00335 <span class="comment"> * @name Low-level option setting functions</span>
<a name="l00336"></a>00336 <span class="comment"> * These functons provide a means to set low-level options that is not possible</span>
<a name="l00337"></a>00337 <span class="comment"> * with the AVOption API.</span>
<a name="l00338"></a>00338 <span class="comment"> * @{</span>
<a name="l00339"></a>00339 <span class="comment"> */</span>
<a name="l00340"></a>00340 <span class="comment"></span>
<a name="l00341"></a>00341 <span class="comment">/**</span>
<a name="l00342"></a>00342 <span class="comment"> * Activate resampling compensation (&quot;soft&quot; compensation). This function is</span>
<a name="l00343"></a>00343 <span class="comment"> * internally called when needed in swr_next_pts().</span>
<a name="l00344"></a>00344 <span class="comment"> *</span>
<a name="l00345"></a>00345 <span class="comment"> * @param[in,out] s             allocated Swr context. If it is not initialized,</span>
<a name="l00346"></a>00346 <span class="comment"> *                              or SWR_FLAG_RESAMPLE is not set, swr_init() is</span>
<a name="l00347"></a>00347 <span class="comment"> *                              called with the flag set.</span>
<a name="l00348"></a>00348 <span class="comment"> * @param[in]     sample_delta  delta in PTS per sample</span>
<a name="l00349"></a>00349 <span class="comment"> * @param[in]     compensation_distance number of samples to compensate for</span>
<a name="l00350"></a>00350 <span class="comment"> * @return    &gt;= 0 on success, AVERROR error codes if:</span>
<a name="l00351"></a>00351 <span class="comment"> *            @li @c s is NULL,</span>
<a name="l00352"></a>00352 <span class="comment"> *            @li @c compensation_distance is less than 0,</span>
<a name="l00353"></a>00353 <span class="comment"> *            @li @c compensation_distance is 0 but sample_delta is not,</span>
<a name="l00354"></a>00354 <span class="comment"> *            @li compensation unsupported by resampler, or</span>
<a name="l00355"></a>00355 <span class="comment"> *            @li swr_init() fails when called.</span>
<a name="l00356"></a>00356 <span class="comment"> */</span>
<a name="l00357"></a>00357 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#gab7f21690522b85d7757e13fa9853d4d8" title="Activate resampling compensation (&quot;soft&quot; compensation).">swr_set_compensation</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, <span class="keywordtype">int</span> sample_delta, <span class="keywordtype">int</span> compensation_distance);
<a name="l00358"></a>00358 <span class="comment"></span>
<a name="l00359"></a>00359 <span class="comment">/**</span>
<a name="l00360"></a>00360 <span class="comment"> * Set a customized input channel mapping.</span>
<a name="l00361"></a>00361 <span class="comment"> *</span>
<a name="l00362"></a>00362 <span class="comment"> * @param[in,out] s           allocated Swr context, not yet initialized</span>
<a name="l00363"></a>00363 <span class="comment"> * @param[in]     channel_map customized input channel mapping (array of channel</span>
<a name="l00364"></a>00364 <span class="comment"> *                            indexes, -1 for a muted channel)</span>
<a name="l00365"></a>00365 <span class="comment"> * @return &gt;= 0 on success, or AVERROR error code in case of failure.</span>
<a name="l00366"></a>00366 <span class="comment"> */</span>
<a name="l00367"></a>00367 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#ga1b528050b5f5b704aecbfbc257a17ef0" title="Set a customized input channel mapping.">swr_set_channel_mapping</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, <span class="keyword">const</span> <span class="keywordtype">int</span> *channel_map);
<a name="l00368"></a>00368 <span class="comment"></span>
<a name="l00369"></a>00369 <span class="comment">/**</span>
<a name="l00370"></a>00370 <span class="comment"> * Set a customized remix matrix.</span>
<a name="l00371"></a>00371 <span class="comment"> *</span>
<a name="l00372"></a>00372 <span class="comment"> * @param s       allocated Swr context, not yet initialized</span>
<a name="l00373"></a>00373 <span class="comment"> * @param matrix  remix coefficients; matrix[i + stride * o] is</span>
<a name="l00374"></a>00374 <span class="comment"> *                the weight of input channel i in output channel o</span>
<a name="l00375"></a>00375 <span class="comment"> * @param stride  offset between lines of the matrix</span>
<a name="l00376"></a>00376 <span class="comment"> * @return  &gt;= 0 on success, or AVERROR error code in case of failure.</span>
<a name="l00377"></a>00377 <span class="comment"> */</span>
<a name="l00378"></a>00378 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#gaf9064d65b1e654dc78f7d6bcd2e8c747" title="Set a customized remix matrix.">swr_set_matrix</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, <span class="keyword">const</span> <span class="keywordtype">double</span> *matrix, <span class="keywordtype">int</span> stride);
<a name="l00379"></a>00379 <span class="comment"></span>
<a name="l00380"></a>00380 <span class="comment">/**</span>
<a name="l00381"></a>00381 <span class="comment"> * @}</span>
<a name="l00382"></a>00382 <span class="comment"> *</span>
<a name="l00383"></a>00383 <span class="comment"> * @name Sample handling functions</span>
<a name="l00384"></a>00384 <span class="comment"> * @{</span>
<a name="l00385"></a>00385 <span class="comment"> */</span>
<a name="l00386"></a>00386 <span class="comment"></span>
<a name="l00387"></a>00387 <span class="comment">/**</span>
<a name="l00388"></a>00388 <span class="comment"> * Drops the specified number of output samples.</span>
<a name="l00389"></a>00389 <span class="comment"> *</span>
<a name="l00390"></a>00390 <span class="comment"> * This function, along with swr_inject_silence(), is called by swr_next_pts()</span>
<a name="l00391"></a>00391 <span class="comment"> * if needed for &quot;hard&quot; compensation.</span>
<a name="l00392"></a>00392 <span class="comment"> *</span>
<a name="l00393"></a>00393 <span class="comment"> * @param s     allocated Swr context</span>
<a name="l00394"></a>00394 <span class="comment"> * @param count number of samples to be dropped</span>
<a name="l00395"></a>00395 <span class="comment"> *</span>
<a name="l00396"></a>00396 <span class="comment"> * @return &gt;= 0 on success, or a negative AVERROR code on failure</span>
<a name="l00397"></a>00397 <span class="comment"> */</span>
<a name="l00398"></a>00398 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#ga43d7ba4507891fc25aacbbea5cdfb065" title="Drops the specified number of output samples.">swr_drop_output</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, <span class="keywordtype">int</span> count);
<a name="l00399"></a>00399 <span class="comment"></span>
<a name="l00400"></a>00400 <span class="comment">/**</span>
<a name="l00401"></a>00401 <span class="comment"> * Injects the specified number of silence samples.</span>
<a name="l00402"></a>00402 <span class="comment"> *</span>
<a name="l00403"></a>00403 <span class="comment"> * This function, along with swr_drop_output(), is called by swr_next_pts()</span>
<a name="l00404"></a>00404 <span class="comment"> * if needed for &quot;hard&quot; compensation.</span>
<a name="l00405"></a>00405 <span class="comment"> *</span>
<a name="l00406"></a>00406 <span class="comment"> * @param s     allocated Swr context</span>
<a name="l00407"></a>00407 <span class="comment"> * @param count number of samples to be dropped</span>
<a name="l00408"></a>00408 <span class="comment"> *</span>
<a name="l00409"></a>00409 <span class="comment"> * @return &gt;= 0 on success, or a negative AVERROR code on failure</span>
<a name="l00410"></a>00410 <span class="comment"> */</span>
<a name="l00411"></a>00411 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#ga4733ed4779ed3e30379de2a6ef8de837" title="Injects the specified number of silence samples.">swr_inject_silence</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, <span class="keywordtype">int</span> count);
<a name="l00412"></a>00412 <span class="comment"></span>
<a name="l00413"></a>00413 <span class="comment">/**</span>
<a name="l00414"></a>00414 <span class="comment"> * Gets the delay the next input sample will experience relative to the next output sample.</span>
<a name="l00415"></a>00415 <span class="comment"> *</span>
<a name="l00416"></a>00416 <span class="comment"> * Swresample can buffer data if more input has been provided than available</span>
<a name="l00417"></a>00417 <span class="comment"> * output space, also converting between sample rates needs a delay.</span>
<a name="l00418"></a>00418 <span class="comment"> * This function returns the sum of all such delays.</span>
<a name="l00419"></a>00419 <span class="comment"> * The exact delay is not necessarily an integer value in either input or</span>
<a name="l00420"></a>00420 <span class="comment"> * output sample rate. Especially when downsampling by a large value, the</span>
<a name="l00421"></a>00421 <span class="comment"> * output sample rate may be a poor choice to represent the delay, similarly</span>
<a name="l00422"></a>00422 <span class="comment"> * for upsampling and the input sample rate.</span>
<a name="l00423"></a>00423 <span class="comment"> *</span>
<a name="l00424"></a>00424 <span class="comment"> * @param s     swr context</span>
<a name="l00425"></a>00425 <span class="comment"> * @param base  timebase in which the returned delay will be:</span>
<a name="l00426"></a>00426 <span class="comment"> *              @li if it&#39;s set to 1 the returned delay is in seconds</span>
<a name="l00427"></a>00427 <span class="comment"> *              @li if it&#39;s set to 1000 the returned delay is in milliseconds</span>
<a name="l00428"></a>00428 <span class="comment"> *              @li if it&#39;s set to the input sample rate then the returned</span>
<a name="l00429"></a>00429 <span class="comment"> *                  delay is in input samples</span>
<a name="l00430"></a>00430 <span class="comment"> *              @li if it&#39;s set to the output sample rate then the returned</span>
<a name="l00431"></a>00431 <span class="comment"> *                  delay is in output samples</span>
<a name="l00432"></a>00432 <span class="comment"> *              @li if it&#39;s the least common multiple of in_sample_rate and</span>
<a name="l00433"></a>00433 <span class="comment"> *                  out_sample_rate then an exact rounding-free delay will be</span>
<a name="l00434"></a>00434 <span class="comment"> *                  returned</span>
<a name="l00435"></a>00435 <span class="comment"> * @returns     the delay in 1 / @c base units.</span>
<a name="l00436"></a>00436 <span class="comment"> */</span>
<a name="l00437"></a>00437 int64_t <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>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, int64_t base);
<a name="l00438"></a>00438 <span class="comment"></span>
<a name="l00439"></a>00439 <span class="comment">/**</span>
<a name="l00440"></a>00440 <span class="comment"> * Find an upper bound on the number of samples that the next swr_convert</span>
<a name="l00441"></a>00441 <span class="comment"> * call will output, if called with in_samples of input samples. This</span>
<a name="l00442"></a>00442 <span class="comment"> * depends on the internal state, and anything changing the internal state</span>
<a name="l00443"></a>00443 <span class="comment"> * (like further swr_convert() calls) will may change the number of samples</span>
<a name="l00444"></a>00444 <span class="comment"> * swr_get_out_samples() returns for the same number of input samples.</span>
<a name="l00445"></a>00445 <span class="comment"> *</span>
<a name="l00446"></a>00446 <span class="comment"> * @param in_samples    number of input samples.</span>
<a name="l00447"></a>00447 <span class="comment"> * @note any call to swr_inject_silence(), swr_convert(), swr_next_pts()</span>
<a name="l00448"></a>00448 <span class="comment"> *       or swr_set_compensation() invalidates this limit</span>
<a name="l00449"></a>00449 <span class="comment"> * @note it is recommended to pass the correct available buffer size</span>
<a name="l00450"></a>00450 <span class="comment"> *       to all functions like swr_convert() even if swr_get_out_samples()</span>
<a name="l00451"></a>00451 <span class="comment"> *       indicates that less would be used.</span>
<a name="l00452"></a>00452 <span class="comment"> * @returns an upper bound on the number of samples that the next swr_convert</span>
<a name="l00453"></a>00453 <span class="comment"> *          will output or a negative value to indicate an error</span>
<a name="l00454"></a>00454 <span class="comment"> */</span>
<a name="l00455"></a>00455 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#ga97a8d5f6abe3bcdfb6072412f17285a4" title="Find an upper bound on the number of samples that the next swr_convert call will output, if called with in_samples of input samples.">swr_get_out_samples</a>(<span class="keyword">struct</span> <a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *s, <span class="keywordtype">int</span> in_samples);
<a name="l00456"></a>00456 <span class="comment"></span>
<a name="l00457"></a>00457 <span class="comment">/**</span>
<a name="l00458"></a>00458 <span class="comment"> * @}</span>
<a name="l00459"></a>00459 <span class="comment"> *</span>
<a name="l00460"></a>00460 <span class="comment"> * @name Configuration accessors</span>
<a name="l00461"></a>00461 <span class="comment"> * @{</span>
<a name="l00462"></a>00462 <span class="comment"> */</span>
<a name="l00463"></a>00463 <span class="comment"></span>
<a name="l00464"></a>00464 <span class="comment">/**</span>
<a name="l00465"></a>00465 <span class="comment"> * Return the @ref LIBSWRESAMPLE_VERSION_INT constant.</span>
<a name="l00466"></a>00466 <span class="comment"> *</span>
<a name="l00467"></a>00467 <span class="comment"> * This is useful to check if the build-time libswresample has the same version</span>
<a name="l00468"></a>00468 <span class="comment"> * as the run-time one.</span>
<a name="l00469"></a>00469 <span class="comment"> *</span>
<a name="l00470"></a>00470 <span class="comment"> * @returns     the unsigned int-typed version</span>
<a name="l00471"></a>00471 <span class="comment"> */</span>
<a name="l00472"></a>00472 <span class="keywordtype">unsigned</span> <a class="code" href="group__lswr.html#gaed39c2153a1e26b4ef656ec8c765a2e3" title="Return the LIBSWRESAMPLE_VERSION_INT constant.">swresample_version</a>(<span class="keywordtype">void</span>);
<a name="l00473"></a>00473 <span class="comment"></span>
<a name="l00474"></a>00474 <span class="comment">/**</span>
<a name="l00475"></a>00475 <span class="comment"> * Return the swr build-time configuration.</span>
<a name="l00476"></a>00476 <span class="comment"> *</span>
<a name="l00477"></a>00477 <span class="comment"> * @returns     the build-time @c ./configure flags</span>
<a name="l00478"></a>00478 <span class="comment"> */</span>
<a name="l00479"></a>00479 <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="group__lswr.html#gad602fde7a824753d5adc57e7f1372e27" title="Return the swr build-time configuration.">swresample_configuration</a>(<span class="keywordtype">void</span>);
<a name="l00480"></a>00480 <span class="comment"></span>
<a name="l00481"></a>00481 <span class="comment">/**</span>
<a name="l00482"></a>00482 <span class="comment"> * Return the swr license.</span>
<a name="l00483"></a>00483 <span class="comment"> *</span>
<a name="l00484"></a>00484 <span class="comment"> * @returns     the license of libswresample, determined at build-time</span>
<a name="l00485"></a>00485 <span class="comment"> */</span>
<a name="l00486"></a>00486 <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="group__lswr.html#ga29c5657b18632e206a99d1ae27225499" title="Return the swr license.">swresample_license</a>(<span class="keywordtype">void</span>);
<a name="l00487"></a>00487 <span class="comment"></span>
<a name="l00488"></a>00488 <span class="comment">/**</span>
<a name="l00489"></a>00489 <span class="comment"> * @}</span>
<a name="l00490"></a>00490 <span class="comment"> *</span>
<a name="l00491"></a>00491 <span class="comment"> * @name AVFrame based API</span>
<a name="l00492"></a>00492 <span class="comment"> * @{</span>
<a name="l00493"></a>00493 <span class="comment"> */</span>
<a name="l00494"></a>00494 <span class="comment"></span>
<a name="l00495"></a>00495 <span class="comment">/**</span>
<a name="l00496"></a>00496 <span class="comment"> * Convert the samples in the input AVFrame and write them to the output AVFrame.</span>
<a name="l00497"></a>00497 <span class="comment"> *</span>
<a name="l00498"></a>00498 <span class="comment"> * Input and output AVFrames must have channel_layout, sample_rate and format set.</span>
<a name="l00499"></a>00499 <span class="comment"> *</span>
<a name="l00500"></a>00500 <span class="comment"> * If the output AVFrame does not have the data pointers allocated the nb_samples</span>
<a name="l00501"></a>00501 <span class="comment"> * field will be set using av_frame_get_buffer()</span>
<a name="l00502"></a>00502 <span class="comment"> * is called to allocate the frame.</span>
<a name="l00503"></a>00503 <span class="comment"> *</span>
<a name="l00504"></a>00504 <span class="comment"> * The output AVFrame can be NULL or have fewer allocated samples than required.</span>
<a name="l00505"></a>00505 <span class="comment"> * In this case, any remaining samples not written to the output will be added</span>
<a name="l00506"></a>00506 <span class="comment"> * to an internal FIFO buffer, to be returned at the next call to this function</span>
<a name="l00507"></a>00507 <span class="comment"> * or to swr_convert().</span>
<a name="l00508"></a>00508 <span class="comment"> *</span>
<a name="l00509"></a>00509 <span class="comment"> * If converting sample rate, there may be data remaining in the internal</span>
<a name="l00510"></a>00510 <span class="comment"> * resampling delay buffer. swr_get_delay() tells the number of</span>
<a name="l00511"></a>00511 <span class="comment"> * remaining samples. To get this data as output, call this function or</span>
<a name="l00512"></a>00512 <span class="comment"> * swr_convert() with NULL input.</span>
<a name="l00513"></a>00513 <span class="comment"> *</span>
<a name="l00514"></a>00514 <span class="comment"> * If the SwrContext configuration does not match the output and</span>
<a name="l00515"></a>00515 <span class="comment"> * input AVFrame settings the conversion does not take place and depending on</span>
<a name="l00516"></a>00516 <span class="comment"> * which AVFrame is not matching AVERROR_OUTPUT_CHANGED, AVERROR_INPUT_CHANGED</span>
<a name="l00517"></a>00517 <span class="comment"> * or the result of a bitwise-OR of them is returned.</span>
<a name="l00518"></a>00518 <span class="comment"> *</span>
<a name="l00519"></a>00519 <span class="comment"> * @see swr_delay()</span>
<a name="l00520"></a>00520 <span class="comment"> * @see swr_convert()</span>
<a name="l00521"></a>00521 <span class="comment"> * @see swr_get_delay()</span>
<a name="l00522"></a>00522 <span class="comment"> *</span>
<a name="l00523"></a>00523 <span class="comment"> * @param swr             audio resample context</span>
<a name="l00524"></a>00524 <span class="comment"> * @param output          output AVFrame</span>
<a name="l00525"></a>00525 <span class="comment"> * @param input           input AVFrame</span>
<a name="l00526"></a>00526 <span class="comment"> * @return                0 on success, AVERROR on failure or nonmatching</span>
<a name="l00527"></a>00527 <span class="comment"> *                        configuration.</span>
<a name="l00528"></a>00528 <span class="comment"> */</span>
<a name="l00529"></a>00529 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#gac482028c01d95580106183aa84b0930c" title="Convert the samples in the input AVFrame and write them to the output AVFrame.">swr_convert_frame</a>(<a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *swr,
<a name="l00530"></a>00530                       <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *output, <span class="keyword">const</span> <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *input);
<a name="l00531"></a>00531 <span class="comment"></span>
<a name="l00532"></a>00532 <span class="comment">/**</span>
<a name="l00533"></a>00533 <span class="comment"> * Configure or reconfigure the SwrContext using the information</span>
<a name="l00534"></a>00534 <span class="comment"> * provided by the AVFrames.</span>
<a name="l00535"></a>00535 <span class="comment"> *</span>
<a name="l00536"></a>00536 <span class="comment"> * The original resampling context is reset even on failure.</span>
<a name="l00537"></a>00537 <span class="comment"> * The function calls swr_close() internally if the context is open.</span>
<a name="l00538"></a>00538 <span class="comment"> *</span>
<a name="l00539"></a>00539 <span class="comment"> * @see swr_close();</span>
<a name="l00540"></a>00540 <span class="comment"> *</span>
<a name="l00541"></a>00541 <span class="comment"> * @param swr             audio resample context</span>
<a name="l00542"></a>00542 <span class="comment"> * @param output          output AVFrame</span>
<a name="l00543"></a>00543 <span class="comment"> * @param input           input AVFrame</span>
<a name="l00544"></a>00544 <span class="comment"> * @return                0 on success, AVERROR on failure.</span>
<a name="l00545"></a>00545 <span class="comment"> */</span>
<a name="l00546"></a>00546 <span class="keywordtype">int</span> <a class="code" href="group__lswr.html#ga73ade2cf6934765cf518c6c917b77c76" title="Configure or reconfigure the SwrContext using the information provided by the AVFrames.">swr_config_frame</a>(<a class="code" href="group__lswr.html#ga4aa775b7fba31d2c8dc14c7b7e282863" title="The libswresample context.">SwrContext</a> *swr, <span class="keyword">const</span> <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *out, <span class="keyword">const</span> <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *in);
<a name="l00547"></a>00547 <span class="comment"></span>
<a name="l00548"></a>00548 <span class="comment">/**</span>
<a name="l00549"></a>00549 <span class="comment"> * @}</span>
<a name="l00550"></a>00550 <span class="comment"> * @}</span>
<a name="l00551"></a>00551 <span class="comment"> */</span>
<a name="l00552"></a>00552 
<a name="l00553"></a>00553 <span class="preprocessor">#endif </span><span class="comment">/* SWRESAMPLE_SWRESAMPLE_H */</span>
</pre></div></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">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</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 &#160;<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>