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 / demuxing__decoding_8c_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: doc/examples/demuxing_decoding.c 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">doc/examples/demuxing_decoding.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="demuxing__decoding_8c.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) 2012 Stefano Sabatini</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<a name="l00005"></a>00005 <span class="comment"> * of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<a name="l00006"></a>00006 <span class="comment"> * in the Software without restriction, including without limitation the rights</span>
<a name="l00007"></a>00007 <span class="comment"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<a name="l00008"></a>00008 <span class="comment"> * copies of the Software, and to permit persons to whom the Software is</span>
<a name="l00009"></a>00009 <span class="comment"> * furnished to do so, subject to the following conditions:</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> * The above copyright notice and this permission notice shall be included in</span>
<a name="l00012"></a>00012 <span class="comment"> * all copies or substantial portions of the Software.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<a name="l00015"></a>00015 <span class="comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<a name="l00016"></a>00016 <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span>
<a name="l00017"></a>00017 <span class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<a name="l00018"></a>00018 <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<a name="l00019"></a>00019 <span class="comment"> * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
<a name="l00020"></a>00020 <span class="comment"> * THE SOFTWARE.</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 <span class="comment"></span>
<a name="l00023"></a>00023 <span class="comment">/**</span>
<a name="l00024"></a>00024 <span class="comment"> * @file</span>
<a name="l00025"></a>00025 <span class="comment"> * Demuxing and decoding example.</span>
<a name="l00026"></a>00026 <span class="comment"> *</span>
<a name="l00027"></a>00027 <span class="comment"> * Show how to use the libavformat and libavcodec API to demux and</span>
<a name="l00028"></a>00028 <span class="comment"> * decode audio and video data.</span>
<a name="l00029"></a>00029 <span class="comment"> * @example demuxing_decoding.c</span>
<a name="l00030"></a>00030 <span class="comment"> */</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="imgutils_8h.html" title="misc image utilities">libavutil/imgutils.h</a>&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;<a class="code" href="samplefmt_8h.html">libavutil/samplefmt.h</a>&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;<a class="code" href="timestamp_8h.html" title="timestamp utils, mostly useful for debugging/logging purposes">libavutil/timestamp.h</a>&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;<a class="code" href="avformat_8h.html" title="Main libavformat public API header.">libavformat/avformat.h</a>&gt;</span>
<a name="l00036"></a>00036 
<a name="l00037"></a><a class="code" href="demuxing__decoding_8c.html#a409462acdf7aebe5bfbe1bcd811efa5d">00037</a> <span class="keyword">static</span> <a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *<a class="code" href="demuxing__decoding_8c.html#a409462acdf7aebe5bfbe1bcd811efa5d">fmt_ctx</a> = NULL;
<a name="l00038"></a><a class="code" href="demuxing__decoding_8c.html#a2e10f5f24d4c8dd311b8eedc376accf5">00038</a> <span class="keyword">static</span> <a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *<a class="code" href="demuxing__decoding_8c.html#a2e10f5f24d4c8dd311b8eedc376accf5">video_dec_ctx</a> = NULL, *<a class="code" href="demuxing__decoding_8c.html#adecce4fda9b9d4fc0d6713d461755cfd">audio_dec_ctx</a>;
<a name="l00039"></a><a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">00039</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a>, <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a>;
<a name="l00040"></a><a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">00040</a> <span class="keyword">static</span> <span class="keyword">enum</span> <a class="code" href="pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5" title="Pixel format.">AVPixelFormat</a> <a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">pix_fmt</a>;
<a name="l00041"></a><a class="code" href="demuxing__decoding_8c.html#a9decdb9a2529baa6bd2a855a12f1f0fc">00041</a> <span class="keyword">static</span> <a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *<a class="code" href="demuxing__decoding_8c.html#a9decdb9a2529baa6bd2a855a12f1f0fc">video_stream</a> = NULL, *<a class="code" href="demuxing__decoding_8c.html#ab269038fe8cd6f8fa4ccec9eaf939345">audio_stream</a> = NULL;
<a name="l00042"></a><a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">00042</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">src_filename</a> = NULL;
<a name="l00043"></a><a class="code" href="demuxing__decoding_8c.html#a780830fc3afc836feb64d80eef4185b5">00043</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="demuxing__decoding_8c.html#a780830fc3afc836feb64d80eef4185b5">video_dst_filename</a> = NULL;
<a name="l00044"></a><a class="code" href="demuxing__decoding_8c.html#a9f79f9440c018d4eb8448d849f35f467">00044</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="demuxing__decoding_8c.html#a9f79f9440c018d4eb8448d849f35f467">audio_dst_filename</a> = NULL;
<a name="l00045"></a><a class="code" href="demuxing__decoding_8c.html#ac3ad9da7180c9a9baa85e968eb6937e3">00045</a> <span class="keyword">static</span> FILE *<a class="code" href="demuxing__decoding_8c.html#ac3ad9da7180c9a9baa85e968eb6937e3">video_dst_file</a> = NULL;
<a name="l00046"></a><a class="code" href="demuxing__decoding_8c.html#af0d7c67df6575ed6b3b7de4d843ed7a6">00046</a> <span class="keyword">static</span> FILE *<a class="code" href="demuxing__decoding_8c.html#af0d7c67df6575ed6b3b7de4d843ed7a6">audio_dst_file</a> = NULL;
<a name="l00047"></a>00047 
<a name="l00048"></a><a class="code" href="demuxing__decoding_8c.html#a0b39e94f88658412ecadb5e2116baccc">00048</a> <span class="keyword">static</span> uint8_t *<a class="code" href="demuxing__decoding_8c.html#a0b39e94f88658412ecadb5e2116baccc">video_dst_data</a>[4] = {NULL};
<a name="l00049"></a><a class="code" href="demuxing__decoding_8c.html#a8dbcd4dc85b9345bde18395026d0ffe4">00049</a> <span class="keyword">static</span> <span class="keywordtype">int</span>      <a class="code" href="demuxing__decoding_8c.html#a8dbcd4dc85b9345bde18395026d0ffe4">video_dst_linesize</a>[4];
<a name="l00050"></a><a class="code" href="demuxing__decoding_8c.html#a849609cb135f2d344ff03e99610b43df">00050</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#a849609cb135f2d344ff03e99610b43df">video_dst_bufsize</a>;
<a name="l00051"></a>00051 
<a name="l00052"></a><a class="code" href="demuxing__decoding_8c.html#af35f69f407b98b5244f837e25813bc11">00052</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#af35f69f407b98b5244f837e25813bc11">video_stream_idx</a> = -1, <a class="code" href="demuxing__decoding_8c.html#a16cd83c72f483b9fa2844c5516452798">audio_stream_idx</a> = -1;
<a name="l00053"></a><a class="code" href="demuxing__decoding_8c.html#ad7d33d579a8d4241a5e643e39287a209">00053</a> <span class="keyword">static</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> = NULL;
<a name="l00054"></a><a class="code" href="demuxing__decoding_8c.html#a3d4c6562f0b27cf0cacbbea5c038c090">00054</a> <span class="keyword">static</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 name="l00055"></a><a class="code" href="demuxing__decoding_8c.html#ac9f496a4d3575928c5b94568bbedd753">00055</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#ac9f496a4d3575928c5b94568bbedd753">video_frame_count</a> = 0;
<a name="l00056"></a><a class="code" href="demuxing__decoding_8c.html#a48eccd48ea840bc45254f44995320463">00056</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#a48eccd48ea840bc45254f44995320463">audio_frame_count</a> = 0;
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="comment">/* The different ways of decoding and managing data memory. You are not</span>
<a name="l00059"></a>00059 <span class="comment"> * supposed to support all the modes in your application but pick the one most</span>
<a name="l00060"></a>00060 <span class="comment"> * appropriate to your needs. Look for the use of api_mode in this example to</span>
<a name="l00061"></a>00061 <span class="comment"> * see what are the differences of API usage between them */</span>
<a name="l00062"></a>00062 <span class="keyword">enum</span> {
<a name="l00063"></a><a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2dab844a3f0eaa875df057068f0367489b1">00063</a>     <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2dab844a3f0eaa875df057068f0367489b1">API_MODE_OLD</a>                  = 0, <span class="comment">/* old method, deprecated */</span>
<a name="l00064"></a><a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2da8a168414de8770c24226d90ba3d1f7cc">00064</a>     <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2da8a168414de8770c24226d90ba3d1f7cc">API_MODE_NEW_API_REF_COUNT</a>    = 1, <span class="comment">/* new method, using the frame reference counting */</span>
<a name="l00065"></a><a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2da328cfb892cfa821bdad4cad6ab6d9ea1">00065</a>     <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2da328cfb892cfa821bdad4cad6ab6d9ea1">API_MODE_NEW_API_NO_REF_COUNT</a> = 2, <span class="comment">/* new method, without reference counting */</span>
<a name="l00066"></a>00066 };
<a name="l00067"></a>00067 
<a name="l00068"></a><a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">00068</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">api_mode</a> = <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2dab844a3f0eaa875df057068f0367489b1">API_MODE_OLD</a>;
<a name="l00069"></a>00069 
<a name="l00070"></a><a class="code" href="demuxing__decoding_8c.html#af8c0388188ed14c6585580b04d960a2c">00070</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#af8c0388188ed14c6585580b04d960a2c">decode_packet</a>(<span class="keywordtype">int</span> *got_frame, <span class="keywordtype">int</span> cached)
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072     <span class="keywordtype">int</span> ret = 0;
<a name="l00073"></a>00073     <span class="keywordtype">int</span> decoded = pkt.<a class="code" href="structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4">size</a>;
<a name="l00074"></a>00074 
<a name="l00075"></a>00075     *got_frame = 0;
<a name="l00076"></a>00076 
<a name="l00077"></a>00077     <span class="keywordflow">if</span> (pkt.<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a> == <a class="code" href="demuxing__decoding_8c.html#af35f69f407b98b5244f837e25813bc11">video_stream_idx</a>) {
<a name="l00078"></a>00078         <span class="comment">/* decode video frame */</span>
<a name="l00079"></a>00079         ret = <a class="code" href="group__lavc__decoding.html#ga99ee61b6dcffb7817a275d39da58cc74" title="Decode the video frame of size avpkt-&gt;size from avpkt-&gt;data into picture.">avcodec_decode_video2</a>(video_dec_ctx, frame, got_frame, &amp;pkt);
<a name="l00080"></a>00080         <span class="keywordflow">if</span> (ret &lt; 0) {
<a name="l00081"></a>00081             fprintf(stderr, <span class="stringliteral">&quot;Error decoding video frame (%s)\n&quot;</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));
<a name="l00082"></a>00082             <span class="keywordflow">return</span> ret;
<a name="l00083"></a>00083         }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085         <span class="keywordflow">if</span> (*got_frame) {
<a name="l00086"></a>00086 
<a name="l00087"></a>00087             <span class="keywordflow">if</span> (frame-&gt;<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> || frame-&gt;<a class="code" href="structAVFrame.html#a3f89733f429c98ba5bc64373fb0a3f13">height</a> != <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a> ||
<a name="l00088"></a>00088                 frame-&gt;<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>) {
<a name="l00089"></a>00089                 <span class="comment">/* To handle this change, one could call av_image_alloc again and</span>
<a name="l00090"></a>00090 <span class="comment">                 * decode the following frames into another rawvideo file. */</span>
<a name="l00091"></a>00091                 fprintf(stderr, <span class="stringliteral">&quot;Error: Width, height and pixel format have to be &quot;</span>
<a name="l00092"></a>00092                         <span class="stringliteral">&quot;constant in a rawvideo file, but the width, height or &quot;</span>
<a name="l00093"></a>00093                         <span class="stringliteral">&quot;pixel format of the input video changed:\n&quot;</span>
<a name="l00094"></a>00094                         <span class="stringliteral">&quot;old: width = %d, height = %d, format = %s\n&quot;</span>
<a name="l00095"></a>00095                         <span class="stringliteral">&quot;new: width = %d, height = %d, format = %s\n&quot;</span>,
<a name="l00096"></a>00096                         <a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a>, <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a>, <a class="code" href="pixdesc_8h.html#ab92e2a8a9b58c982560c49df9f01e47e" title="Return the short name for a pixel format, NULL in case pix_fmt is unknown.">av_get_pix_fmt_name</a>(<a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">pix_fmt</a>),
<a name="l00097"></a>00097                         frame-&gt;<a class="code" href="structAVFrame.html#a1e71ce60cedd5f3b6811714a9f7f9e0a" title="width and height of the video frame">width</a>, frame-&gt;<a class="code" href="structAVFrame.html#a3f89733f429c98ba5bc64373fb0a3f13">height</a>,
<a name="l00098"></a>00098                         <a class="code" href="pixdesc_8h.html#ab92e2a8a9b58c982560c49df9f01e47e" title="Return the short name for a pixel format, NULL in case pix_fmt is unknown.">av_get_pix_fmt_name</a>(frame-&gt;<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 name="l00099"></a>00099                 <span class="keywordflow">return</span> -1;
<a name="l00100"></a>00100             }
<a name="l00101"></a>00101 
<a name="l00102"></a>00102             printf(<span class="stringliteral">&quot;video_frame%s n:%d coded_n:%d pts:%s\n&quot;</span>,
<a name="l00103"></a>00103                    cached ? <span class="stringliteral">&quot;(cached)&quot;</span> : <span class="stringliteral">&quot;&quot;</span>,
<a name="l00104"></a>00104                    <a class="code" href="demuxing__decoding_8c.html#ac9f496a4d3575928c5b94568bbedd753">video_frame_count</a>++, frame-&gt;<a class="code" href="structAVFrame.html#a02ca9bb7f500d3d850f8736f3cb29c6c" title="picture number in bitstream order">coded_picture_number</a>,
<a name="l00105"></a>00105                    <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>(frame-&gt;<a class="code" href="structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4" title="Presentation timestamp in time_base units (time when frame should be shown to user).">pts</a>, &amp;video_dec_ctx-&gt;<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="l00106"></a>00106 
<a name="l00107"></a>00107             <span class="comment">/* copy decoded frame to destination buffer:</span>
<a name="l00108"></a>00108 <span class="comment">             * this is required since rawvideo expects non aligned data */</span>
<a name="l00109"></a>00109             <a class="code" href="group__lavu__picture.html#ga6b5a267e202daadf81cbde6584055d1e" title="Copy image in src_data to dst_data.">av_image_copy</a>(<a class="code" href="demuxing__decoding_8c.html#a0b39e94f88658412ecadb5e2116baccc">video_dst_data</a>, <a class="code" href="demuxing__decoding_8c.html#a8dbcd4dc85b9345bde18395026d0ffe4">video_dst_linesize</a>,
<a name="l00110"></a>00110                           (<span class="keyword">const</span> uint8_t **)(frame-&gt;<a class="code" href="structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992" title="pointer to the picture/channel planes.">data</a>), frame-&gt;<a class="code" href="structAVFrame.html#aa52bfc6605f6a3059a0c3226cc0f6567" title="For video, size in bytes of each picture line.">linesize</a>,
<a name="l00111"></a>00111                           <a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">pix_fmt</a>, <a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a>, <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a>);
<a name="l00112"></a>00112 
<a name="l00113"></a>00113             <span class="comment">/* write to rawvideo file */</span>
<a name="l00114"></a>00114             fwrite(<a class="code" href="demuxing__decoding_8c.html#a0b39e94f88658412ecadb5e2116baccc">video_dst_data</a>[0], 1, <a class="code" href="demuxing__decoding_8c.html#a849609cb135f2d344ff03e99610b43df">video_dst_bufsize</a>, <a class="code" href="demuxing__decoding_8c.html#ac3ad9da7180c9a9baa85e968eb6937e3">video_dst_file</a>);
<a name="l00115"></a>00115         }
<a name="l00116"></a>00116     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pkt.<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a> == <a class="code" href="demuxing__decoding_8c.html#a16cd83c72f483b9fa2844c5516452798">audio_stream_idx</a>) {
<a name="l00117"></a>00117         <span class="comment">/* decode audio frame */</span>
<a name="l00118"></a>00118         ret = <a class="code" href="group__lavc__decoding.html#ga834bb1b062fbcc2de4cf7fb93f154a3e" title="Decode the audio frame of size avpkt-&gt;size from avpkt-&gt;data into frame.">avcodec_decode_audio4</a>(<a class="code" href="demuxing__decoding_8c.html#adecce4fda9b9d4fc0d6713d461755cfd">audio_dec_ctx</a>, frame, got_frame, &amp;pkt);
<a name="l00119"></a>00119         <span class="keywordflow">if</span> (ret &lt; 0) {
<a name="l00120"></a>00120             fprintf(stderr, <span class="stringliteral">&quot;Error decoding audio frame (%s)\n&quot;</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));
<a name="l00121"></a>00121             <span class="keywordflow">return</span> ret;
<a name="l00122"></a>00122         }
<a name="l00123"></a>00123         <span class="comment">/* Some audio decoders decode only part of the packet, and have to be</span>
<a name="l00124"></a>00124 <span class="comment">         * called again with the remainder of the packet data.</span>
<a name="l00125"></a>00125 <span class="comment">         * Sample: fate-suite/lossless-audio/luckynight-partial.shn</span>
<a name="l00126"></a>00126 <span class="comment">         * Also, some decoders might over-read the packet. */</span>
<a name="l00127"></a>00127         decoded = <a class="code" href="common_8h.html#a0f84cbd7fd810cd678157c98cbfad4b0">FFMIN</a>(ret, pkt.<a class="code" href="structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4">size</a>);
<a name="l00128"></a>00128 
<a name="l00129"></a>00129         <span class="keywordflow">if</span> (*got_frame) {
<a name="l00130"></a>00130             <span class="keywordtype">size_t</span> unpadded_linesize = frame-&gt;<a class="code" href="structAVFrame.html#a02f45ab8191aea1660159f1e464237ea" title="number of audio samples (per channel) described by this frame">nb_samples</a> * <a class="code" href="group__lavu__sampfmts.html#ga0c3c218e1dd570ad4917c69a35a6c77d" title="Return number of bytes per sample.">av_get_bytes_per_sample</a>(frame-&gt;<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 name="l00131"></a>00131             printf(<span class="stringliteral">&quot;audio_frame%s n:%d nb_samples:%d pts:%s\n&quot;</span>,
<a name="l00132"></a>00132                    cached ? <span class="stringliteral">&quot;(cached)&quot;</span> : <span class="stringliteral">&quot;&quot;</span>,
<a name="l00133"></a>00133                    <a class="code" href="demuxing__decoding_8c.html#a48eccd48ea840bc45254f44995320463">audio_frame_count</a>++, frame-&gt;<a class="code" href="structAVFrame.html#a02f45ab8191aea1660159f1e464237ea" title="number of audio samples (per channel) described by this frame">nb_samples</a>,
<a name="l00134"></a>00134                    <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>(frame-&gt;<a class="code" href="structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4" title="Presentation timestamp in time_base units (time when frame should be shown to user).">pts</a>, &amp;<a class="code" href="demuxing__decoding_8c.html#adecce4fda9b9d4fc0d6713d461755cfd">audio_dec_ctx</a>-&gt;<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="l00135"></a>00135 
<a name="l00136"></a>00136             <span class="comment">/* Write the raw audio data samples of the first plane. This works</span>
<a name="l00137"></a>00137 <span class="comment">             * fine for packed formats (e.g. AV_SAMPLE_FMT_S16). However,</span>
<a name="l00138"></a>00138 <span class="comment">             * most audio decoders output planar audio, which uses a separate</span>
<a name="l00139"></a>00139 <span class="comment">             * plane of audio samples for each channel (e.g. AV_SAMPLE_FMT_S16P).</span>
<a name="l00140"></a>00140 <span class="comment">             * In other words, this code will write only the first audio channel</span>
<a name="l00141"></a>00141 <span class="comment">             * in these cases.</span>
<a name="l00142"></a>00142 <span class="comment">             * You should use libswresample or libavfilter to convert the frame</span>
<a name="l00143"></a>00143 <span class="comment">             * to packed data. */</span>
<a name="l00144"></a>00144             fwrite(frame-&gt;<a class="code" href="structAVFrame.html#afca04d808393822625e09b5ba91c6756" title="pointers to the data planes/channels.">extended_data</a>[0], 1, unpadded_linesize, <a class="code" href="demuxing__decoding_8c.html#af0d7c67df6575ed6b3b7de4d843ed7a6">audio_dst_file</a>);
<a name="l00145"></a>00145         }
<a name="l00146"></a>00146     }
<a name="l00147"></a>00147 
<a name="l00148"></a>00148     <span class="comment">/* If we use the new API with reference counting, we own the data and need</span>
<a name="l00149"></a>00149 <span class="comment">     * to de-reference it when we don&#39;t use it anymore */</span>
<a name="l00150"></a>00150     <span class="keywordflow">if</span> (*got_frame &amp;&amp; <a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">api_mode</a> == <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2da8a168414de8770c24226d90ba3d1f7cc">API_MODE_NEW_API_REF_COUNT</a>)
<a name="l00151"></a>00151         <a class="code" href="group__lavu__frame.html#ga0a2b687f9c1c5ed0089b01fd61227108" title="Unreference all the buffers referenced by frame and reset the frame fields.">av_frame_unref</a>(frame);
<a name="l00152"></a>00152 
<a name="l00153"></a>00153     <span class="keywordflow">return</span> decoded;
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155 
<a name="l00156"></a><a class="code" href="demuxing__decoding_8c.html#a85e44b1a7e74c90b84b2298caefb5f73">00156</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#a85e44b1a7e74c90b84b2298caefb5f73">open_codec_context</a>(<span class="keywordtype">int</span> *stream_idx,
<a name="l00157"></a>00157                               <a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *fmt_ctx, <span class="keyword">enum</span> <a class="code" href="group__lavu__misc.html#ga9a84bba4713dfced21a1a56163be1f48">AVMediaType</a> type)
<a name="l00158"></a>00158 {
<a name="l00159"></a>00159     <span class="keywordtype">int</span> ret, stream_index;
<a name="l00160"></a>00160     <a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *st;
<a name="l00161"></a>00161     <a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *<a class="code" href="filtering__audio_8c.html#ac2bf6798f37e95d3d2ff2d44e4ab3c12">dec_ctx</a> = NULL;
<a name="l00162"></a>00162     <a class="code" href="structAVCodec.html" title="AVCodec.">AVCodec</a> *dec = NULL;
<a name="l00163"></a>00163     <a class="code" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> *opts = NULL;
<a name="l00164"></a>00164 
<a name="l00165"></a>00165     ret = <a class="code" href="group__lavf__decoding.html#gaa6fa468c922ff5c60a6021dcac09aff9" title="Find the &quot;best&quot; stream in the file.">av_find_best_stream</a>(fmt_ctx, type, -1, -1, NULL, 0);
<a name="l00166"></a>00166     <span class="keywordflow">if</span> (ret &lt; 0) {
<a name="l00167"></a>00167         fprintf(stderr, <span class="stringliteral">&quot;Could not find %s stream in input file &#39;%s&#39;\n&quot;</span>,
<a name="l00168"></a>00168                 <a class="code" href="group__lavu__misc.html#gaf21645cfa855b2caf9699d7dc7b2d08e" title="Return a string describing the media_type enum, NULL if media_type is unknown.">av_get_media_type_string</a>(type), <a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">src_filename</a>);
<a name="l00169"></a>00169         <span class="keywordflow">return</span> ret;
<a name="l00170"></a>00170     } <span class="keywordflow">else</span> {
<a name="l00171"></a>00171         stream_index = ret;
<a name="l00172"></a>00172         st = fmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index];
<a name="l00173"></a>00173 
<a name="l00174"></a>00174         <span class="comment">/* find decoder for the stream */</span>
<a name="l00175"></a>00175         dec_ctx = st-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
<a name="l00176"></a>00176         dec = <a class="code" href="group__lavc__decoding.html#ga19a0ca553277f019dd5b0fec6e1f9dca" title="Find a registered decoder with a matching codec ID.">avcodec_find_decoder</a>(dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#adc5f65d6099fd8339c1580c091777223">codec_id</a>);
<a name="l00177"></a>00177         <span class="keywordflow">if</span> (!dec) {
<a name="l00178"></a>00178             fprintf(stderr, <span class="stringliteral">&quot;Failed to find %s codec\n&quot;</span>,
<a name="l00179"></a>00179                     <a class="code" href="group__lavu__misc.html#gaf21645cfa855b2caf9699d7dc7b2d08e" title="Return a string describing the media_type enum, NULL if media_type is unknown.">av_get_media_type_string</a>(type));
<a name="l00180"></a>00180             <span class="keywordflow">return</span> <a class="code" href="group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca">AVERROR</a>(EINVAL);
<a name="l00181"></a>00181         }
<a name="l00182"></a>00182 
<a name="l00183"></a>00183         <span class="comment">/* Init the decoders, with or without reference counting */</span>
<a name="l00184"></a>00184         <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">api_mode</a> == <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2da8a168414de8770c24226d90ba3d1f7cc">API_MODE_NEW_API_REF_COUNT</a>)
<a name="l00185"></a>00185             <a class="code" href="group__lavu__dict.html#ga8d9c2de72b310cef8e6a28c9cd3acbbe" title="Set the given entry in *pm, overwriting an existing entry.">av_dict_set</a>(&amp;opts, <span class="stringliteral">&quot;refcounted_frames&quot;</span>, <span class="stringliteral">&quot;1&quot;</span>, 0);
<a name="l00186"></a>00186         <span class="keywordflow">if</span> ((ret = <a class="code" href="group__lavc__core.html#ga11f785a188d7d9df71621001465b0f1d" title="Initialize the AVCodecContext to use the given AVCodec.">avcodec_open2</a>(dec_ctx, dec, &amp;opts)) &lt; 0) {
<a name="l00187"></a>00187             fprintf(stderr, <span class="stringliteral">&quot;Failed to open %s codec\n&quot;</span>,
<a name="l00188"></a>00188                     <a class="code" href="group__lavu__misc.html#gaf21645cfa855b2caf9699d7dc7b2d08e" title="Return a string describing the media_type enum, NULL if media_type is unknown.">av_get_media_type_string</a>(type));
<a name="l00189"></a>00189             <span class="keywordflow">return</span> ret;
<a name="l00190"></a>00190         }
<a name="l00191"></a>00191         *stream_idx = stream_index;
<a name="l00192"></a>00192     }
<a name="l00193"></a>00193 
<a name="l00194"></a>00194     <span class="keywordflow">return</span> 0;
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 
<a name="l00197"></a><a class="code" href="demuxing__decoding_8c.html#a5e068fc5e6dc5c59638ec235f7f6db89">00197</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="demuxing__decoding_8c.html#a5e068fc5e6dc5c59638ec235f7f6db89">get_format_from_sample_fmt</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> **fmt,
<a name="l00198"></a>00198                                       <span class="keyword">enum</span> <a class="code" href="group__lavu__sampfmts.html#gaf9a51ca15301871723577c730b5865c5" title="Audio sample formats.">AVSampleFormat</a> sample_fmt)
<a name="l00199"></a>00199 {
<a name="l00200"></a>00200     <span class="keywordtype">int</span> i;
<a name="l00201"></a>00201     <span class="keyword">struct </span>sample_fmt_entry {
<a name="l00202"></a>00202         <span class="keyword">enum</span> <a class="code" href="group__lavu__sampfmts.html#gaf9a51ca15301871723577c730b5865c5" title="Audio sample formats.">AVSampleFormat</a> sample_fmt; <span class="keyword">const</span> <span class="keywordtype">char</span> *fmt_be, *fmt_le;
<a name="l00203"></a>00203     } sample_fmt_entries[] = {
<a name="l00204"></a>00204         { <a class="code" href="group__lavu__sampfmts.html#ggaf9a51ca15301871723577c730b5865c5adf0f66f21492f8fd5db6debb8b3f932a" title="unsigned 8 bits">AV_SAMPLE_FMT_U8</a>,  <span class="stringliteral">&quot;u8&quot;</span>,    <span class="stringliteral">&quot;u8&quot;</span>    },
<a name="l00205"></a>00205         { <a class="code" href="group__lavu__sampfmts.html#ggaf9a51ca15301871723577c730b5865c5aea6132df57aebc3f76e10665395c46af" title="signed 16 bits">AV_SAMPLE_FMT_S16</a>, <span class="stringliteral">&quot;s16be&quot;</span>, <span class="stringliteral">&quot;s16le&quot;</span> },
<a name="l00206"></a>00206         { <a class="code" href="group__lavu__sampfmts.html#ggaf9a51ca15301871723577c730b5865c5ab7ae6bb6718c07cd316778783a57a63b" title="signed 32 bits">AV_SAMPLE_FMT_S32</a>, <span class="stringliteral">&quot;s32be&quot;</span>, <span class="stringliteral">&quot;s32le&quot;</span> },
<a name="l00207"></a>00207         { <a class="code" href="group__lavu__sampfmts.html#ggaf9a51ca15301871723577c730b5865c5a5251d62cc3c7f18e56bc8e0c48a27903" title="float">AV_SAMPLE_FMT_FLT</a>, <span class="stringliteral">&quot;f32be&quot;</span>, <span class="stringliteral">&quot;f32le&quot;</span> },
<a name="l00208"></a>00208         { <a class="code" href="group__lavu__sampfmts.html#ggaf9a51ca15301871723577c730b5865c5ae35a2a6a7593723d9fe4bcefb2876606" title="double">AV_SAMPLE_FMT_DBL</a>, <span class="stringliteral">&quot;f64be&quot;</span>, <span class="stringliteral">&quot;f64le&quot;</span> },
<a name="l00209"></a>00209     };
<a name="l00210"></a>00210     *fmt = NULL;
<a name="l00211"></a>00211 
<a name="l00212"></a>00212     <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="common_8h.html#a3508a98d3ee7e2c9a4841fe264cf70f7">FF_ARRAY_ELEMS</a>(sample_fmt_entries); i++) {
<a name="l00213"></a>00213         <span class="keyword">struct </span>sample_fmt_entry *entry = &amp;sample_fmt_entries[i];
<a name="l00214"></a>00214         <span class="keywordflow">if</span> (sample_fmt == entry-&gt;sample_fmt) {
<a name="l00215"></a>00215             *fmt = <a class="code" href="common_8h.html#a309bdca20f6a78431379fc69442d98ea">AV_NE</a>(entry-&gt;fmt_be, entry-&gt;fmt_le);
<a name="l00216"></a>00216             <span class="keywordflow">return</span> 0;
<a name="l00217"></a>00217         }
<a name="l00218"></a>00218     }
<a name="l00219"></a>00219 
<a name="l00220"></a>00220     fprintf(stderr,
<a name="l00221"></a>00221             <span class="stringliteral">&quot;sample format %s is not supported as output format\n&quot;</span>,
<a name="l00222"></a>00222             <a class="code" href="group__lavu__sampfmts.html#ga31b9d149b2de9821a65f4f5612970838" title="Return the name of sample_fmt, or NULL if sample_fmt is not recognized.">av_get_sample_fmt_name</a>(sample_fmt));
<a name="l00223"></a>00223     <span class="keywordflow">return</span> -1;
<a name="l00224"></a>00224 }
<a name="l00225"></a>00225 
<a name="l00226"></a><a class="code" href="demuxing__decoding_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">00226</a> <span class="keywordtype">int</span> <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 name="l00227"></a>00227 {
<a name="l00228"></a>00228     <span class="keywordtype">int</span> ret = 0, got_frame;
<a name="l00229"></a>00229 
<a name="l00230"></a>00230     <span class="keywordflow">if</span> (argc != 4 &amp;&amp; argc != 5) {
<a name="l00231"></a>00231         fprintf(stderr, <span class="stringliteral">&quot;usage: %s [-refcount=&lt;old|new_norefcount|new_refcount&gt;] &quot;</span>
<a name="l00232"></a>00232                 <span class="stringliteral">&quot;input_file video_output_file audio_output_file\n&quot;</span>
<a name="l00233"></a>00233                 <span class="stringliteral">&quot;API example program to show how to read frames from an input file.\n&quot;</span>
<a name="l00234"></a>00234                 <span class="stringliteral">&quot;This program reads frames from a file, decodes them, and writes decoded\n&quot;</span>
<a name="l00235"></a>00235                 <span class="stringliteral">&quot;video frames to a rawvideo file named video_output_file, and decoded\n&quot;</span>
<a name="l00236"></a>00236                 <span class="stringliteral">&quot;audio frames to a rawaudio file named audio_output_file.\n\n&quot;</span>
<a name="l00237"></a>00237                 <span class="stringliteral">&quot;If the -refcount option is specified, the program use the\n&quot;</span>
<a name="l00238"></a>00238                 <span class="stringliteral">&quot;reference counting frame system which allows keeping a copy of\n&quot;</span>
<a name="l00239"></a>00239                 <span class="stringliteral">&quot;the data for longer than one decode call. If unset, it&#39;s using\n&quot;</span>
<a name="l00240"></a>00240                 <span class="stringliteral">&quot;the classic old method.\n&quot;</span>
<a name="l00241"></a>00241                 <span class="stringliteral">&quot;\n&quot;</span>, argv[0]);
<a name="l00242"></a>00242         exit(1);
<a name="l00243"></a>00243     }
<a name="l00244"></a>00244     <span class="keywordflow">if</span> (argc == 5) {
<a name="l00245"></a>00245         <span class="keyword">const</span> <span class="keywordtype">char</span> *mode = argv[1] + strlen(<span class="stringliteral">&quot;-refcount=&quot;</span>);
<a name="l00246"></a>00246         <span class="keywordflow">if</span>      (!strcmp(mode, <span class="stringliteral">&quot;old&quot;</span>))            <a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">api_mode</a> = <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2dab844a3f0eaa875df057068f0367489b1">API_MODE_OLD</a>;
<a name="l00247"></a>00247         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(mode, <span class="stringliteral">&quot;new_norefcount&quot;</span>)) <a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">api_mode</a> = <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2da328cfb892cfa821bdad4cad6ab6d9ea1">API_MODE_NEW_API_NO_REF_COUNT</a>;
<a name="l00248"></a>00248         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(mode, <span class="stringliteral">&quot;new_refcount&quot;</span>))   <a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">api_mode</a> = <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2da8a168414de8770c24226d90ba3d1f7cc">API_MODE_NEW_API_REF_COUNT</a>;
<a name="l00249"></a>00249         <span class="keywordflow">else</span> {
<a name="l00250"></a>00250             fprintf(stderr, <span class="stringliteral">&quot;unknow mode &#39;%s&#39;\n&quot;</span>, mode);
<a name="l00251"></a>00251             exit(1);
<a name="l00252"></a>00252         }
<a name="l00253"></a>00253         argv++;
<a name="l00254"></a>00254     }
<a name="l00255"></a>00255     <a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">src_filename</a> = argv[1];
<a name="l00256"></a>00256     <a class="code" href="demuxing__decoding_8c.html#a780830fc3afc836feb64d80eef4185b5">video_dst_filename</a> = argv[2];
<a name="l00257"></a>00257     <a class="code" href="demuxing__decoding_8c.html#a9f79f9440c018d4eb8448d849f35f467">audio_dst_filename</a> = argv[3];
<a name="l00258"></a>00258 
<a name="l00259"></a>00259     <span class="comment">/* register all formats and codecs */</span>
<a name="l00260"></a>00260     <a class="code" href="group__lavf__core.html#ga917265caec45ef5a0646356ed1a507e3" title="Initialize libavformat and register all the muxers, demuxers and protocols.">av_register_all</a>();
<a name="l00261"></a>00261 
<a name="l00262"></a>00262     <span class="comment">/* open input file, and allocate format context */</span>
<a name="l00263"></a>00263     <span class="keywordflow">if</span> (<a class="code" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input</a>(&amp;fmt_ctx, <a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">src_filename</a>, NULL, NULL) &lt; 0) {
<a name="l00264"></a>00264         fprintf(stderr, <span class="stringliteral">&quot;Could not open source file %s\n&quot;</span>, <a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">src_filename</a>);
<a name="l00265"></a>00265         exit(1);
<a name="l00266"></a>00266     }
<a name="l00267"></a>00267 
<a name="l00268"></a>00268     <span class="comment">/* retrieve stream information */</span>
<a name="l00269"></a>00269     <span class="keywordflow">if</span> (<a class="code" href="group__lavf__decoding.html#gad42172e27cddafb81096939783b157bb" title="Read packets of a media file to get stream information.">avformat_find_stream_info</a>(fmt_ctx, NULL) &lt; 0) {
<a name="l00270"></a>00270         fprintf(stderr, <span class="stringliteral">&quot;Could not find stream information\n&quot;</span>);
<a name="l00271"></a>00271         exit(1);
<a name="l00272"></a>00272     }
<a name="l00273"></a>00273 
<a name="l00274"></a>00274     <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#a85e44b1a7e74c90b84b2298caefb5f73">open_codec_context</a>(&amp;<a class="code" href="demuxing__decoding_8c.html#af35f69f407b98b5244f837e25813bc11">video_stream_idx</a>, fmt_ctx, <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>) &gt;= 0) {
<a name="l00275"></a>00275         video_stream = fmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[<a class="code" href="demuxing__decoding_8c.html#af35f69f407b98b5244f837e25813bc11">video_stream_idx</a>];
<a name="l00276"></a>00276         video_dec_ctx = video_stream-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
<a name="l00277"></a>00277 
<a name="l00278"></a>00278         <a class="code" href="demuxing__decoding_8c.html#ac3ad9da7180c9a9baa85e968eb6937e3">video_dst_file</a> = fopen(<a class="code" href="demuxing__decoding_8c.html#a780830fc3afc836feb64d80eef4185b5">video_dst_filename</a>, <span class="stringliteral">&quot;wb&quot;</span>);
<a name="l00279"></a>00279         <span class="keywordflow">if</span> (!<a class="code" href="demuxing__decoding_8c.html#ac3ad9da7180c9a9baa85e968eb6937e3">video_dst_file</a>) {
<a name="l00280"></a>00280             fprintf(stderr, <span class="stringliteral">&quot;Could not open destination file %s\n&quot;</span>, <a class="code" href="demuxing__decoding_8c.html#a780830fc3afc836feb64d80eef4185b5">video_dst_filename</a>);
<a name="l00281"></a>00281             ret = 1;
<a name="l00282"></a>00282             <span class="keywordflow">goto</span> end;
<a name="l00283"></a>00283         }
<a name="l00284"></a>00284 
<a name="l00285"></a>00285         <span class="comment">/* allocate image where the decoded image will be put */</span>
<a name="l00286"></a>00286         <a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a> = video_dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>;
<a name="l00287"></a>00287         <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a> = video_dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>;
<a name="l00288"></a>00288         <a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">pix_fmt</a> = video_dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a>;
<a name="l00289"></a>00289         ret = <a class="code" href="group__lavu__picture.html#ga841e0a89a642e24141af1918a2c10448" title="Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...">av_image_alloc</a>(<a class="code" href="demuxing__decoding_8c.html#a0b39e94f88658412ecadb5e2116baccc">video_dst_data</a>, <a class="code" href="demuxing__decoding_8c.html#a8dbcd4dc85b9345bde18395026d0ffe4">video_dst_linesize</a>,
<a name="l00290"></a>00290                              <a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a>, <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a>, <a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">pix_fmt</a>, 1);
<a name="l00291"></a>00291         <span class="keywordflow">if</span> (ret &lt; 0) {
<a name="l00292"></a>00292             fprintf(stderr, <span class="stringliteral">&quot;Could not allocate raw video buffer\n&quot;</span>);
<a name="l00293"></a>00293             <span class="keywordflow">goto</span> end;
<a name="l00294"></a>00294         }
<a name="l00295"></a>00295         <a class="code" href="demuxing__decoding_8c.html#a849609cb135f2d344ff03e99610b43df">video_dst_bufsize</a> = ret;
<a name="l00296"></a>00296     }
<a name="l00297"></a>00297 
<a name="l00298"></a>00298     <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#a85e44b1a7e74c90b84b2298caefb5f73">open_codec_context</a>(&amp;<a class="code" href="demuxing__decoding_8c.html#a16cd83c72f483b9fa2844c5516452798">audio_stream_idx</a>, fmt_ctx, <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48a7b4e33b8f30ac94d34ce8d9f7c33927a">AVMEDIA_TYPE_AUDIO</a>) &gt;= 0) {
<a name="l00299"></a>00299         <a class="code" href="demuxing__decoding_8c.html#ab269038fe8cd6f8fa4ccec9eaf939345">audio_stream</a> = fmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[<a class="code" href="demuxing__decoding_8c.html#a16cd83c72f483b9fa2844c5516452798">audio_stream_idx</a>];
<a name="l00300"></a>00300         <a class="code" href="demuxing__decoding_8c.html#adecce4fda9b9d4fc0d6713d461755cfd">audio_dec_ctx</a> = <a class="code" href="demuxing__decoding_8c.html#ab269038fe8cd6f8fa4ccec9eaf939345">audio_stream</a>-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
<a name="l00301"></a>00301         <a class="code" href="demuxing__decoding_8c.html#af0d7c67df6575ed6b3b7de4d843ed7a6">audio_dst_file</a> = fopen(<a class="code" href="demuxing__decoding_8c.html#a9f79f9440c018d4eb8448d849f35f467">audio_dst_filename</a>, <span class="stringliteral">&quot;wb&quot;</span>);
<a name="l00302"></a>00302         <span class="keywordflow">if</span> (!<a class="code" href="demuxing__decoding_8c.html#af0d7c67df6575ed6b3b7de4d843ed7a6">audio_dst_file</a>) {
<a name="l00303"></a>00303             fprintf(stderr, <span class="stringliteral">&quot;Could not open destination file %s\n&quot;</span>, <a class="code" href="demuxing__decoding_8c.html#a9f79f9440c018d4eb8448d849f35f467">audio_dst_filename</a>);
<a name="l00304"></a>00304             ret = 1;
<a name="l00305"></a>00305             <span class="keywordflow">goto</span> end;
<a name="l00306"></a>00306         }
<a name="l00307"></a>00307     }
<a name="l00308"></a>00308 
<a name="l00309"></a>00309     <span class="comment">/* dump input information to stderr */</span>
<a name="l00310"></a>00310     <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>(fmt_ctx, 0, <a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">src_filename</a>, 0);
<a name="l00311"></a>00311 
<a name="l00312"></a>00312     <span class="keywordflow">if</span> (!<a class="code" href="demuxing__decoding_8c.html#ab269038fe8cd6f8fa4ccec9eaf939345">audio_stream</a> &amp;&amp; !video_stream) {
<a name="l00313"></a>00313         fprintf(stderr, <span class="stringliteral">&quot;Could not find audio or video stream in the input, aborting\n&quot;</span>);
<a name="l00314"></a>00314         ret = 1;
<a name="l00315"></a>00315         <span class="keywordflow">goto</span> end;
<a name="l00316"></a>00316     }
<a name="l00317"></a>00317 
<a name="l00318"></a>00318     <span class="comment">/* When using the new API, you need to use the libavutil/frame.h API, while</span>
<a name="l00319"></a>00319 <span class="comment">     * the classic frame management is available in libavcodec */</span>
<a name="l00320"></a>00320     <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">api_mode</a> == <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2dab844a3f0eaa875df057068f0367489b1">API_MODE_OLD</a>)
<a name="l00321"></a>00321         frame = avcodec_alloc_frame();
<a name="l00322"></a>00322     <span class="keywordflow">else</span>
<a name="l00323"></a>00323         frame = <a class="code" href="group__lavu__frame.html#gac700017c5270c79c1e1befdeeb008b2f" title="Allocate an AVFrame and set its fields to default values.">av_frame_alloc</a>();
<a name="l00324"></a>00324     <span class="keywordflow">if</span> (!frame) {
<a name="l00325"></a>00325         fprintf(stderr, <span class="stringliteral">&quot;Could not allocate frame\n&quot;</span>);
<a name="l00326"></a>00326         ret = <a class="code" href="group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca">AVERROR</a>(ENOMEM);
<a name="l00327"></a>00327         <span class="keywordflow">goto</span> end;
<a name="l00328"></a>00328     }
<a name="l00329"></a>00329 
<a name="l00330"></a>00330     <span class="comment">/* initialize packet, set data to NULL, let the demuxer fill it */</span>
<a name="l00331"></a>00331     <a class="code" href="group__lavc__packet.html#gac9cb9756175b96e7441575803757fb73" title="Initialize optional fields of a packet with default values.">av_init_packet</a>(&amp;pkt);
<a name="l00332"></a>00332     pkt.<a class="code" href="structAVPacket.html#aaf4fe58dfcc7c232c1f2268b539d8367">data</a> = NULL;
<a name="l00333"></a>00333     pkt.<a class="code" href="structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4">size</a> = 0;
<a name="l00334"></a>00334 
<a name="l00335"></a>00335     <span class="keywordflow">if</span> (video_stream)
<a name="l00336"></a>00336         printf(<span class="stringliteral">&quot;Demuxing video from file &#39;%s&#39; into &#39;%s&#39;\n&quot;</span>, <a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">src_filename</a>, <a class="code" href="demuxing__decoding_8c.html#a780830fc3afc836feb64d80eef4185b5">video_dst_filename</a>);
<a name="l00337"></a>00337     <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#ab269038fe8cd6f8fa4ccec9eaf939345">audio_stream</a>)
<a name="l00338"></a>00338         printf(<span class="stringliteral">&quot;Demuxing audio from file &#39;%s&#39; into &#39;%s&#39;\n&quot;</span>, <a class="code" href="demuxing__decoding_8c.html#ad3e56268ab4ce7a25e7a17c2e088a3c1">src_filename</a>, <a class="code" href="demuxing__decoding_8c.html#a9f79f9440c018d4eb8448d849f35f467">audio_dst_filename</a>);
<a name="l00339"></a>00339 
<a name="l00340"></a>00340     <span class="comment">/* read frames from the file */</span>
<a name="l00341"></a>00341     <span class="keywordflow">while</span> (<a class="code" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" title="Return the next frame of a stream.">av_read_frame</a>(fmt_ctx, &amp;pkt) &gt;= 0) {
<a name="l00342"></a>00342         <a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> orig_pkt = <a class="code" href="demuxing__decoding_8c.html#a3d4c6562f0b27cf0cacbbea5c038c090">pkt</a>;
<a name="l00343"></a>00343         <span class="keywordflow">do</span> {
<a name="l00344"></a>00344             ret = <a class="code" href="demuxing__decoding_8c.html#af8c0388188ed14c6585580b04d960a2c">decode_packet</a>(&amp;got_frame, 0);
<a name="l00345"></a>00345             <span class="keywordflow">if</span> (ret &lt; 0)
<a name="l00346"></a>00346                 <span class="keywordflow">break</span>;
<a name="l00347"></a>00347             pkt.<a class="code" href="structAVPacket.html#aaf4fe58dfcc7c232c1f2268b539d8367">data</a> += ret;
<a name="l00348"></a>00348             pkt.<a class="code" href="structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4">size</a> -= ret;
<a name="l00349"></a>00349         } <span class="keywordflow">while</span> (pkt.<a class="code" href="structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4">size</a> &gt; 0);
<a name="l00350"></a>00350         <a class="code" href="group__lavc__packet.html#gae65881462e78f98b268f34661d921ee0" title="Free a packet.">av_free_packet</a>(&amp;orig_pkt);
<a name="l00351"></a>00351     }
<a name="l00352"></a>00352 
<a name="l00353"></a>00353     <span class="comment">/* flush cached frames */</span>
<a name="l00354"></a>00354     pkt.<a class="code" href="structAVPacket.html#aaf4fe58dfcc7c232c1f2268b539d8367">data</a> = NULL;
<a name="l00355"></a>00355     pkt.<a class="code" href="structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4">size</a> = 0;
<a name="l00356"></a>00356     <span class="keywordflow">do</span> {
<a name="l00357"></a>00357         <a class="code" href="demuxing__decoding_8c.html#af8c0388188ed14c6585580b04d960a2c">decode_packet</a>(&amp;got_frame, 1);
<a name="l00358"></a>00358     } <span class="keywordflow">while</span> (got_frame);
<a name="l00359"></a>00359 
<a name="l00360"></a>00360     printf(<span class="stringliteral">&quot;Demuxing succeeded.\n&quot;</span>);
<a name="l00361"></a>00361 
<a name="l00362"></a>00362     <span class="keywordflow">if</span> (video_stream) {
<a name="l00363"></a>00363         printf(<span class="stringliteral">&quot;Play the output video file with the command:\n&quot;</span>
<a name="l00364"></a>00364                <span class="stringliteral">&quot;ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n&quot;</span>,
<a name="l00365"></a>00365                <a class="code" href="pixdesc_8h.html#ab92e2a8a9b58c982560c49df9f01e47e" title="Return the short name for a pixel format, NULL in case pix_fmt is unknown.">av_get_pix_fmt_name</a>(<a class="code" href="demuxing__decoding_8c.html#a7331e302ea7bb48e0b605a069576e135">pix_fmt</a>), <a class="code" href="demuxing__decoding_8c.html#a2474a5474cbff19523a51eb1de01cda4">width</a>, <a class="code" href="demuxing__decoding_8c.html#ad12fc34ce789bce6c8a05d8a17138534">height</a>,
<a name="l00366"></a>00366                <a class="code" href="demuxing__decoding_8c.html#a780830fc3afc836feb64d80eef4185b5">video_dst_filename</a>);
<a name="l00367"></a>00367     }
<a name="l00368"></a>00368 
<a name="l00369"></a>00369     <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#ab269038fe8cd6f8fa4ccec9eaf939345">audio_stream</a>) {
<a name="l00370"></a>00370         <span class="keyword">enum</span> <a class="code" href="group__lavu__sampfmts.html#gaf9a51ca15301871723577c730b5865c5" title="Audio sample formats.">AVSampleFormat</a> sfmt = <a class="code" href="demuxing__decoding_8c.html#adecce4fda9b9d4fc0d6713d461755cfd">audio_dec_ctx</a>-&gt;<a class="code" href="structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45" title="audio sample format">sample_fmt</a>;
<a name="l00371"></a>00371         <span class="keywordtype">int</span> n_channels = <a class="code" href="demuxing__decoding_8c.html#adecce4fda9b9d4fc0d6713d461755cfd">audio_dec_ctx</a>-&gt;<a class="code" href="structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels">channels</a>;
<a name="l00372"></a>00372         <span class="keyword">const</span> <span class="keywordtype">char</span> *fmt;
<a name="l00373"></a>00373 
<a name="l00374"></a>00374         <span class="keywordflow">if</span> (<a class="code" href="group__lavu__sampfmts.html#ga06ba8a64dc4382c422789a5d0b6bf592" title="Check if the sample format is planar.">av_sample_fmt_is_planar</a>(sfmt)) {
<a name="l00375"></a>00375             <span class="keyword">const</span> <span class="keywordtype">char</span> *packed = <a class="code" href="group__lavu__sampfmts.html#ga31b9d149b2de9821a65f4f5612970838" title="Return the name of sample_fmt, or NULL if sample_fmt is not recognized.">av_get_sample_fmt_name</a>(sfmt);
<a name="l00376"></a>00376             printf(<span class="stringliteral">&quot;Warning: the sample format the decoder produced is planar &quot;</span>
<a name="l00377"></a>00377                    <span class="stringliteral">&quot;(%s). This example will output the first channel only.\n&quot;</span>,
<a name="l00378"></a>00378                    packed ? packed : <span class="stringliteral">&quot;?&quot;</span>);
<a name="l00379"></a>00379             sfmt = <a class="code" href="group__lavu__sampfmts.html#ga7817ec0eff4dc6fc0962f31e6d138bca" title="Get the packed alternative form of the given sample format.">av_get_packed_sample_fmt</a>(sfmt);
<a name="l00380"></a>00380             n_channels = 1;
<a name="l00381"></a>00381         }
<a name="l00382"></a>00382 
<a name="l00383"></a>00383         <span class="keywordflow">if</span> ((ret = <a class="code" href="demuxing__decoding_8c.html#a5e068fc5e6dc5c59638ec235f7f6db89">get_format_from_sample_fmt</a>(&amp;fmt, sfmt)) &lt; 0)
<a name="l00384"></a>00384             <span class="keywordflow">goto</span> end;
<a name="l00385"></a>00385 
<a name="l00386"></a>00386         printf(<span class="stringliteral">&quot;Play the output audio file with the command:\n&quot;</span>
<a name="l00387"></a>00387                <span class="stringliteral">&quot;ffplay -f %s -ac %d -ar %d %s\n&quot;</span>,
<a name="l00388"></a>00388                fmt, n_channels, <a class="code" href="demuxing__decoding_8c.html#adecce4fda9b9d4fc0d6713d461755cfd">audio_dec_ctx</a>-&gt;<a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>,
<a name="l00389"></a>00389                <a class="code" href="demuxing__decoding_8c.html#a9f79f9440c018d4eb8448d849f35f467">audio_dst_filename</a>);
<a name="l00390"></a>00390     }
<a name="l00391"></a>00391 
<a name="l00392"></a>00392 end:
<a name="l00393"></a>00393     <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>(video_dec_ctx);
<a name="l00394"></a>00394     <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>(<a class="code" href="demuxing__decoding_8c.html#adecce4fda9b9d4fc0d6713d461755cfd">audio_dec_ctx</a>);
<a name="l00395"></a>00395     <a class="code" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4" title="Close an opened input AVFormatContext.">avformat_close_input</a>(&amp;fmt_ctx);
<a name="l00396"></a>00396     <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#ac3ad9da7180c9a9baa85e968eb6937e3">video_dst_file</a>)
<a name="l00397"></a>00397         fclose(<a class="code" href="demuxing__decoding_8c.html#ac3ad9da7180c9a9baa85e968eb6937e3">video_dst_file</a>);
<a name="l00398"></a>00398     <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#af0d7c67df6575ed6b3b7de4d843ed7a6">audio_dst_file</a>)
<a name="l00399"></a>00399         fclose(<a class="code" href="demuxing__decoding_8c.html#af0d7c67df6575ed6b3b7de4d843ed7a6">audio_dst_file</a>);
<a name="l00400"></a>00400     <span class="keywordflow">if</span> (<a class="code" href="demuxing__decoding_8c.html#a4bb7a82d583b93cb9e28b93dda64ff14">api_mode</a> == <a class="code" href="demuxing__decoding_8c.html#a0411cd49bb5b71852cecd93bcbf0ca2dab844a3f0eaa875df057068f0367489b1">API_MODE_OLD</a>)
<a name="l00401"></a>00401         avcodec_free_frame(&amp;frame);
<a name="l00402"></a>00402     <span class="keywordflow">else</span>
<a name="l00403"></a>00403         <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>(&amp;frame);
<a name="l00404"></a>00404     <a class="code" href="group__lavu__mem.html#ga0c9096f498624c525aa2315b8a20c411" title="Free a memory block which has been allocated with av_malloc(z)() or av_realloc().">av_free</a>(<a class="code" href="demuxing__decoding_8c.html#a0b39e94f88658412ecadb5e2116baccc">video_dst_data</a>[0]);
<a name="l00405"></a>00405 
<a name="l00406"></a>00406     <span class="keywordflow">return</span> ret &lt; 0;
<a name="l00407"></a>00407 }
</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>