Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > e9a2bf4cbad8eb886872edae7c352314 > files > 37

libvpx-devel-1.0.0-1.fc15.i686.rpm

<!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"/>
<title>WebM VP8 Codec SDK: vpxdec</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">WebM VP8 Codec SDK</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><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><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="samples.html">Sample Code</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">vpxdec </div>  </div>
</div>
<div class="contents">
<div class="textblock"><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) 2010 The WebM project authors. All Rights Reserved.</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> *  Use of this source code is governed by a BSD-style license</span>
<a name="l00005"></a>00005 <span class="comment"> *  that can be found in the LICENSE file in the root of the source</span>
<a name="l00006"></a>00006 <span class="comment"> *  tree. An additional intellectual property rights grant can be found</span>
<a name="l00007"></a>00007 <span class="comment"> *  in the file PATENTS.  All contributing project authors may</span>
<a name="l00008"></a>00008 <span class="comment"> *  be found in the AUTHORS file in the root of the source tree.</span>
<a name="l00009"></a>00009 <span class="comment"> */</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="comment">/* This is a simple program that reads ivf files and decodes them</span>
<a name="l00013"></a>00013 <span class="comment"> * using the new interface. Decoded frames are output as YV12 raw.</span>
<a name="l00014"></a>00014 <span class="comment"> */</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;stdarg.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;limits.h&gt;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="preprocessor">#define VPX_CODEC_DISABLE_COMPAT 1</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#include &quot;vpx_config.h&quot;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="vpx__decoder_8h.html" title="Describes the decoder algorithm interface to applications.">vpx/vpx_decoder.h</a>&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;vpx_ports/vpx_timer.h&quot;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#if CONFIG_VP8_DECODER</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="vp8dx_8h.html" title="Provides definitions for using the VP8 algorithm within the vpx Decoder interface.">vpx/vp8dx.h</a>&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#endif</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#if CONFIG_MD5</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include &quot;md5_utils.h&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#endif</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span><span class="preprocessor">#include &quot;tools_common.h&quot;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;nestegg/include/nestegg/nestegg.h&quot;</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="preprocessor">#if CONFIG_OS_SUPPORT</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#if defined(_MSC_VER)</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#include &lt;io.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#define snprintf _snprintf</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span><span class="preprocessor">#define isatty   _isatty</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#define fileno   _fileno</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#endif</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>
<a name="l00045"></a>00045 <span class="preprocessor">#ifndef PATH_MAX</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span><span class="preprocessor">#define PATH_MAX 256</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a>00049 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *exec_name;
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="preprocessor">#define VP8_FOURCC (0x00385056)</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">struct</span>
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054     <span class="keywordtype">char</span> <span class="keyword">const</span> *name;
<a name="l00055"></a>00055     <span class="keyword">const</span> <a class="code" href="group__codec.html#gad654f3da60151f5dfef70aca00ef1e9e" title="Codec interface structure.">vpx_codec_iface_t</a> *iface;
<a name="l00056"></a>00056     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>             fourcc;
<a name="l00057"></a>00057     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>             fourcc_mask;
<a name="l00058"></a>00058 } ifaces[] =
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060 <span class="preprocessor">#if CONFIG_VP8_DECODER</span>
<a name="l00061"></a>00061 <span class="preprocessor"></span>    {<span class="stringliteral">&quot;vp8&quot;</span>,  &amp;vpx_codec_vp8_dx_algo,   VP8_FOURCC, 0x00FFFFFF},
<a name="l00062"></a>00062 <span class="preprocessor">#endif</span>
<a name="l00063"></a>00063 <span class="preprocessor"></span>};
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 <span class="preprocessor">#include &quot;args.h&quot;</span>
<a name="l00066"></a>00066 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t codecarg = ARG_DEF(NULL, <span class="stringliteral">&quot;codec&quot;</span>, 1,
<a name="l00067"></a>00067                                   <span class="stringliteral">&quot;Codec to use&quot;</span>);
<a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t use_yv12 = ARG_DEF(NULL, <span class="stringliteral">&quot;yv12&quot;</span>, 0,
<a name="l00069"></a>00069                                   <span class="stringliteral">&quot;Output raw YV12 frames&quot;</span>);
<a name="l00070"></a>00070 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t use_i420 = ARG_DEF(NULL, <span class="stringliteral">&quot;i420&quot;</span>, 0,
<a name="l00071"></a>00071                                   <span class="stringliteral">&quot;Output raw I420 frames&quot;</span>);
<a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t flipuvarg = ARG_DEF(NULL, <span class="stringliteral">&quot;flipuv&quot;</span>, 0,
<a name="l00073"></a>00073                                    <span class="stringliteral">&quot;Flip the chroma planes in the output&quot;</span>);
<a name="l00074"></a>00074 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t noblitarg = ARG_DEF(NULL, <span class="stringliteral">&quot;noblit&quot;</span>, 0,
<a name="l00075"></a>00075                                    <span class="stringliteral">&quot;Don&#39;t process the decoded frames&quot;</span>);
<a name="l00076"></a>00076 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t progressarg = ARG_DEF(NULL, <span class="stringliteral">&quot;progress&quot;</span>, 0,
<a name="l00077"></a>00077                                      <span class="stringliteral">&quot;Show progress after each frame decodes&quot;</span>);
<a name="l00078"></a>00078 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t limitarg = ARG_DEF(NULL, <span class="stringliteral">&quot;limit&quot;</span>, 1,
<a name="l00079"></a>00079                                   <span class="stringliteral">&quot;Stop decoding after n frames&quot;</span>);
<a name="l00080"></a>00080 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t postprocarg = ARG_DEF(NULL, <span class="stringliteral">&quot;postproc&quot;</span>, 0,
<a name="l00081"></a>00081                                      <span class="stringliteral">&quot;Postprocess decoded frames&quot;</span>);
<a name="l00082"></a>00082 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t summaryarg = ARG_DEF(NULL, <span class="stringliteral">&quot;summary&quot;</span>, 0,
<a name="l00083"></a>00083                                     <span class="stringliteral">&quot;Show timing summary&quot;</span>);
<a name="l00084"></a>00084 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t outputfile = ARG_DEF(<span class="stringliteral">&quot;o&quot;</span>, <span class="stringliteral">&quot;output&quot;</span>, 1,
<a name="l00085"></a>00085                                     <span class="stringliteral">&quot;Output file name pattern (see below)&quot;</span>);
<a name="l00086"></a>00086 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t threadsarg = ARG_DEF(<span class="stringliteral">&quot;t&quot;</span>, <span class="stringliteral">&quot;threads&quot;</span>, 1,
<a name="l00087"></a>00087                                     <span class="stringliteral">&quot;Max threads to use&quot;</span>);
<a name="l00088"></a>00088 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t verbosearg = ARG_DEF(<span class="stringliteral">&quot;v&quot;</span>, <span class="stringliteral">&quot;verbose&quot;</span>, 0,
<a name="l00089"></a>00089                                   <span class="stringliteral">&quot;Show version string&quot;</span>);
<a name="l00090"></a>00090 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t error_concealment = ARG_DEF(NULL, <span class="stringliteral">&quot;error-concealment&quot;</span>, 0,
<a name="l00091"></a>00091                                        <span class="stringliteral">&quot;Enable decoder error-concealment&quot;</span>);
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 <span class="preprocessor">#if CONFIG_MD5</span>
<a name="l00095"></a>00095 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">const</span> arg_def_t md5arg = ARG_DEF(NULL, <span class="stringliteral">&quot;md5&quot;</span>, 0,
<a name="l00096"></a>00096                                         <span class="stringliteral">&quot;Compute the MD5 sum of the decoded frame&quot;</span>);
<a name="l00097"></a>00097 <span class="preprocessor">#endif</span>
<a name="l00098"></a>00098 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">const</span> arg_def_t *all_args[] =
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100     &amp;codecarg, &amp;use_yv12, &amp;use_i420, &amp;flipuvarg, &amp;noblitarg,
<a name="l00101"></a>00101     &amp;progressarg, &amp;limitarg, &amp;postprocarg, &amp;summaryarg, &amp;outputfile,
<a name="l00102"></a>00102     &amp;threadsarg, &amp;verbosearg,
<a name="l00103"></a>00103 <span class="preprocessor">#if CONFIG_MD5</span>
<a name="l00104"></a>00104 <span class="preprocessor"></span>    &amp;md5arg,
<a name="l00105"></a>00105 <span class="preprocessor">#endif</span>
<a name="l00106"></a>00106 <span class="preprocessor"></span>    &amp;error_concealment,
<a name="l00107"></a>00107     NULL
<a name="l00108"></a>00108 };
<a name="l00109"></a>00109 
<a name="l00110"></a>00110 <span class="preprocessor">#if CONFIG_VP8_DECODER</span>
<a name="l00111"></a>00111 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">const</span> arg_def_t addnoise_level = ARG_DEF(NULL, <span class="stringliteral">&quot;noise-level&quot;</span>, 1,
<a name="l00112"></a>00112                                         <span class="stringliteral">&quot;Enable VP8 postproc add noise&quot;</span>);
<a name="l00113"></a>00113 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t deblock = ARG_DEF(NULL, <span class="stringliteral">&quot;deblock&quot;</span>, 0,
<a name="l00114"></a>00114                                  <span class="stringliteral">&quot;Enable VP8 deblocking&quot;</span>);
<a name="l00115"></a>00115 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t demacroblock_level = ARG_DEF(NULL, <span class="stringliteral">&quot;demacroblock-level&quot;</span>, 1,
<a name="l00116"></a>00116         <span class="stringliteral">&quot;Enable VP8 demacroblocking, w/ level&quot;</span>);
<a name="l00117"></a>00117 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t pp_debug_info = ARG_DEF(NULL, <span class="stringliteral">&quot;pp-debug-info&quot;</span>, 1,
<a name="l00118"></a>00118                                        <span class="stringliteral">&quot;Enable VP8 visible debug info&quot;</span>);
<a name="l00119"></a>00119 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t pp_disp_ref_frame = ARG_DEF(NULL, <span class="stringliteral">&quot;pp-dbg-ref-frame&quot;</span>, 1,
<a name="l00120"></a>00120                                        <span class="stringliteral">&quot;Display only selected reference frame per macro block&quot;</span>);
<a name="l00121"></a>00121 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t pp_disp_mb_modes = ARG_DEF(NULL, <span class="stringliteral">&quot;pp-dbg-mb-modes&quot;</span>, 1,
<a name="l00122"></a>00122                                        <span class="stringliteral">&quot;Display only selected macro block modes&quot;</span>);
<a name="l00123"></a>00123 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t pp_disp_b_modes = ARG_DEF(NULL, <span class="stringliteral">&quot;pp-dbg-b-modes&quot;</span>, 1,
<a name="l00124"></a>00124                                        <span class="stringliteral">&quot;Display only selected block modes&quot;</span>);
<a name="l00125"></a>00125 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t pp_disp_mvs = ARG_DEF(NULL, <span class="stringliteral">&quot;pp-dbg-mvs&quot;</span>, 1,
<a name="l00126"></a>00126                                        <span class="stringliteral">&quot;Draw only selected motion vectors&quot;</span>);
<a name="l00127"></a>00127 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t mfqe = ARG_DEF(NULL, <span class="stringliteral">&quot;mfqe&quot;</span>, 0,
<a name="l00128"></a>00128                                        <span class="stringliteral">&quot;Enable multiframe quality enhancement&quot;</span>);
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 <span class="keyword">static</span> <span class="keyword">const</span> arg_def_t *vp8_pp_args[] =
<a name="l00131"></a>00131 {
<a name="l00132"></a>00132     &amp;addnoise_level, &amp;deblock, &amp;demacroblock_level, &amp;pp_debug_info,
<a name="l00133"></a>00133     &amp;pp_disp_ref_frame, &amp;pp_disp_mb_modes, &amp;pp_disp_b_modes, &amp;pp_disp_mvs, &amp;mfqe,
<a name="l00134"></a>00134     NULL
<a name="l00135"></a>00135 };
<a name="l00136"></a>00136 <span class="preprocessor">#endif</span>
<a name="l00137"></a>00137 <span class="preprocessor"></span>
<a name="l00138"></a>00138 <span class="keyword">static</span> <span class="keywordtype">void</span> usage_exit()
<a name="l00139"></a>00139 {
<a name="l00140"></a>00140     <span class="keywordtype">int</span> i;
<a name="l00141"></a>00141 
<a name="l00142"></a>00142     fprintf(stderr, <span class="stringliteral">&quot;Usage: %s &lt;options&gt; filename\n\n&quot;</span>
<a name="l00143"></a>00143             <span class="stringliteral">&quot;Options:\n&quot;</span>, exec_name);
<a name="l00144"></a>00144     arg_show_usage(stderr, all_args);
<a name="l00145"></a>00145 <span class="preprocessor">#if CONFIG_VP8_DECODER</span>
<a name="l00146"></a>00146 <span class="preprocessor"></span>    fprintf(stderr, <span class="stringliteral">&quot;\nVP8 Postprocessing Options:\n&quot;</span>);
<a name="l00147"></a>00147     arg_show_usage(stderr, vp8_pp_args);
<a name="l00148"></a>00148 <span class="preprocessor">#endif</span>
<a name="l00149"></a>00149 <span class="preprocessor"></span>    fprintf(stderr,
<a name="l00150"></a>00150             <span class="stringliteral">&quot;\nOutput File Patterns:\n\n&quot;</span>
<a name="l00151"></a>00151             <span class="stringliteral">&quot;  The -o argument specifies the name of the file(s) to &quot;</span>
<a name="l00152"></a>00152             <span class="stringliteral">&quot;write to. If the\n  argument does not include any escape &quot;</span>
<a name="l00153"></a>00153             <span class="stringliteral">&quot;characters, the output will be\n  written to a single file. &quot;</span>
<a name="l00154"></a>00154             <span class="stringliteral">&quot;Otherwise, the filename will be calculated by\n  expanding &quot;</span>
<a name="l00155"></a>00155             <span class="stringliteral">&quot;the following escape characters:\n&quot;</span>
<a name="l00156"></a>00156             <span class="stringliteral">&quot;\n\t%%w   - Frame width&quot;</span>
<a name="l00157"></a>00157             <span class="stringliteral">&quot;\n\t%%h   - Frame height&quot;</span>
<a name="l00158"></a>00158             <span class="stringliteral">&quot;\n\t%%&lt;n&gt; - Frame number, zero padded to &lt;n&gt; places (1..9)&quot;</span>
<a name="l00159"></a>00159             <span class="stringliteral">&quot;\n\n  Pattern arguments are only supported in conjunction &quot;</span>
<a name="l00160"></a>00160             <span class="stringliteral">&quot;with the --yv12 and\n  --i420 options. If the -o option is &quot;</span>
<a name="l00161"></a>00161             <span class="stringliteral">&quot;not specified, the output will be\n  directed to stdout.\n&quot;</span>
<a name="l00162"></a>00162             );
<a name="l00163"></a>00163     fprintf(stderr, <span class="stringliteral">&quot;\nIncluded decoders:\n\n&quot;</span>);
<a name="l00164"></a>00164 
<a name="l00165"></a>00165     <span class="keywordflow">for</span> (i = 0; i &lt; <span class="keyword">sizeof</span>(ifaces) / <span class="keyword">sizeof</span>(ifaces[0]); i++)
<a name="l00166"></a>00166         fprintf(stderr, <span class="stringliteral">&quot;    %-6s - %s\n&quot;</span>,
<a name="l00167"></a>00167                 ifaces[i].name,
<a name="l00168"></a>00168                 <a class="code" href="group__codec.html#ga9eee39f450d8cdcf5aba0e2bda6e5aa8" title="Return the name for a given interface.">vpx_codec_iface_name</a>(ifaces[i].iface));
<a name="l00169"></a>00169 
<a name="l00170"></a>00170     exit(EXIT_FAILURE);
<a name="l00171"></a>00171 }
<a name="l00172"></a>00172 
<a name="l00173"></a>00173 <span class="keywordtype">void</span> die(<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...)
<a name="l00174"></a>00174 {
<a name="l00175"></a>00175     va_list ap;
<a name="l00176"></a>00176     va_start(ap, fmt);
<a name="l00177"></a>00177     vfprintf(stderr, fmt, ap);
<a name="l00178"></a>00178     fprintf(stderr, <span class="stringliteral">&quot;\n&quot;</span>);
<a name="l00179"></a>00179     usage_exit();
<a name="l00180"></a>00180 }
<a name="l00181"></a>00181 
<a name="l00182"></a>00182 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mem_get_le16(<span class="keyword">const</span> <span class="keywordtype">void</span> *vmem)
<a name="l00183"></a>00183 {
<a name="l00184"></a>00184     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>  val;
<a name="l00185"></a>00185     <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *mem = (<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)vmem;
<a name="l00186"></a>00186 
<a name="l00187"></a>00187     val = mem[1] &lt;&lt; 8;
<a name="l00188"></a>00188     val |= mem[0];
<a name="l00189"></a>00189     <span class="keywordflow">return</span> val;
<a name="l00190"></a>00190 }
<a name="l00191"></a>00191 
<a name="l00192"></a>00192 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mem_get_le32(<span class="keyword">const</span> <span class="keywordtype">void</span> *vmem)
<a name="l00193"></a>00193 {
<a name="l00194"></a>00194     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>  val;
<a name="l00195"></a>00195     <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *mem = (<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)vmem;
<a name="l00196"></a>00196 
<a name="l00197"></a>00197     val = mem[3] &lt;&lt; 24;
<a name="l00198"></a>00198     val |= mem[2] &lt;&lt; 16;
<a name="l00199"></a>00199     val |= mem[1] &lt;&lt; 8;
<a name="l00200"></a>00200     val |= mem[0];
<a name="l00201"></a>00201     <span class="keywordflow">return</span> val;
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 
<a name="l00204"></a>00204 <span class="keyword">enum</span> file_kind
<a name="l00205"></a>00205 {
<a name="l00206"></a>00206     RAW_FILE,
<a name="l00207"></a>00207     IVF_FILE,
<a name="l00208"></a>00208     WEBM_FILE
<a name="l00209"></a>00209 };
<a name="l00210"></a>00210 
<a name="l00211"></a>00211 <span class="keyword">struct </span>input_ctx
<a name="l00212"></a>00212 {
<a name="l00213"></a>00213     <span class="keyword">enum</span> file_kind  kind;
<a name="l00214"></a>00214     FILE           *infile;
<a name="l00215"></a>00215     nestegg        *nestegg_ctx;
<a name="l00216"></a>00216     nestegg_packet *pkt;
<a name="l00217"></a>00217     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>    chunk;
<a name="l00218"></a>00218     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>    chunks;
<a name="l00219"></a>00219     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>    video_track;
<a name="l00220"></a>00220 };
<a name="l00221"></a>00221 
<a name="l00222"></a>00222 <span class="preprocessor">#define IVF_FRAME_HDR_SZ (sizeof(uint32_t) + sizeof(uint64_t))</span>
<a name="l00223"></a>00223 <span class="preprocessor"></span><span class="preprocessor">#define RAW_FRAME_HDR_SZ (sizeof(uint32_t))</span>
<a name="l00224"></a>00224 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">int</span> read_frame(<span class="keyword">struct</span> input_ctx      *input,
<a name="l00225"></a>00225                       uint8_t               **buf,
<a name="l00226"></a>00226                       <span class="keywordtype">size_t</span>                *buf_sz,
<a name="l00227"></a>00227                       <span class="keywordtype">size_t</span>                *buf_alloc_sz)
<a name="l00228"></a>00228 {
<a name="l00229"></a>00229     <span class="keywordtype">char</span>            raw_hdr[IVF_FRAME_HDR_SZ];
<a name="l00230"></a>00230     <span class="keywordtype">size_t</span>          new_buf_sz;
<a name="l00231"></a>00231     FILE           *infile = input-&gt;infile;
<a name="l00232"></a>00232     <span class="keyword">enum</span> file_kind  kind = input-&gt;kind;
<a name="l00233"></a>00233     <span class="keywordflow">if</span>(kind == WEBM_FILE)
<a name="l00234"></a>00234     {
<a name="l00235"></a>00235         <span class="keywordflow">if</span>(input-&gt;chunk &gt;= input-&gt;chunks)
<a name="l00236"></a>00236         {
<a name="l00237"></a>00237             <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> track;
<a name="l00238"></a>00238 
<a name="l00239"></a>00239             <span class="keywordflow">do</span>
<a name="l00240"></a>00240             {
<a name="l00241"></a>00241                 <span class="comment">/* End of this packet, get another. */</span>
<a name="l00242"></a>00242                 <span class="keywordflow">if</span>(input-&gt;pkt)
<a name="l00243"></a>00243                     nestegg_free_packet(input-&gt;pkt);
<a name="l00244"></a>00244 
<a name="l00245"></a>00245                 <span class="keywordflow">if</span>(nestegg_read_packet(input-&gt;nestegg_ctx, &amp;input-&gt;pkt) &lt;= 0
<a name="l00246"></a>00246                    || nestegg_packet_track(input-&gt;pkt, &amp;track))
<a name="l00247"></a>00247                     <span class="keywordflow">return</span> 1;
<a name="l00248"></a>00248 
<a name="l00249"></a>00249             } <span class="keywordflow">while</span>(track != input-&gt;video_track);
<a name="l00250"></a>00250 
<a name="l00251"></a>00251             <span class="keywordflow">if</span>(nestegg_packet_count(input-&gt;pkt, &amp;input-&gt;chunks))
<a name="l00252"></a>00252                 <span class="keywordflow">return</span> 1;
<a name="l00253"></a>00253             input-&gt;chunk = 0;
<a name="l00254"></a>00254         }
<a name="l00255"></a>00255 
<a name="l00256"></a>00256         <span class="keywordflow">if</span>(nestegg_packet_data(input-&gt;pkt, input-&gt;chunk, buf, buf_sz))
<a name="l00257"></a>00257             <span class="keywordflow">return</span> 1;
<a name="l00258"></a>00258         input-&gt;chunk++;
<a name="l00259"></a>00259 
<a name="l00260"></a>00260         <span class="keywordflow">return</span> 0;
<a name="l00261"></a>00261     }
<a name="l00262"></a>00262     <span class="comment">/* For both the raw and ivf formats, the frame size is the first 4 bytes</span>
<a name="l00263"></a>00263 <span class="comment">     * of the frame header. We just need to special case on the header</span>
<a name="l00264"></a>00264 <span class="comment">     * size.</span>
<a name="l00265"></a>00265 <span class="comment">     */</span>
<a name="l00266"></a>00266     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (fread(raw_hdr, kind==IVF_FILE
<a name="l00267"></a>00267                    ? IVF_FRAME_HDR_SZ : RAW_FRAME_HDR_SZ, 1, infile) != 1)
<a name="l00268"></a>00268     {
<a name="l00269"></a>00269         <span class="keywordflow">if</span> (!feof(infile))
<a name="l00270"></a>00270             fprintf(stderr, <span class="stringliteral">&quot;Failed to read frame size\n&quot;</span>);
<a name="l00271"></a>00271 
<a name="l00272"></a>00272         new_buf_sz = 0;
<a name="l00273"></a>00273     }
<a name="l00274"></a>00274     <span class="keywordflow">else</span>
<a name="l00275"></a>00275     {
<a name="l00276"></a>00276         new_buf_sz = mem_get_le32(raw_hdr);
<a name="l00277"></a>00277 
<a name="l00278"></a>00278         <span class="keywordflow">if</span> (new_buf_sz &gt; 256 * 1024 * 1024)
<a name="l00279"></a>00279         {
<a name="l00280"></a>00280             fprintf(stderr, <span class="stringliteral">&quot;Error: Read invalid frame size (%u)\n&quot;</span>,
<a name="l00281"></a>00281                     (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)new_buf_sz);
<a name="l00282"></a>00282             new_buf_sz = 0;
<a name="l00283"></a>00283         }
<a name="l00284"></a>00284 
<a name="l00285"></a>00285         <span class="keywordflow">if</span> (kind == RAW_FILE &amp;&amp; new_buf_sz &gt; 256 * 1024)
<a name="l00286"></a>00286             fprintf(stderr, <span class="stringliteral">&quot;Warning: Read invalid frame size (%u)&quot;</span>
<a name="l00287"></a>00287                     <span class="stringliteral">&quot; - not a raw file?\n&quot;</span>, (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)new_buf_sz);
<a name="l00288"></a>00288 
<a name="l00289"></a>00289         <span class="keywordflow">if</span> (new_buf_sz &gt; *buf_alloc_sz)
<a name="l00290"></a>00290         {
<a name="l00291"></a>00291             uint8_t *new_buf = realloc(*buf, 2 * new_buf_sz);
<a name="l00292"></a>00292 
<a name="l00293"></a>00293             <span class="keywordflow">if</span> (new_buf)
<a name="l00294"></a>00294             {
<a name="l00295"></a>00295                 *buf = new_buf;
<a name="l00296"></a>00296                 *buf_alloc_sz = 2 * new_buf_sz;
<a name="l00297"></a>00297             }
<a name="l00298"></a>00298             <span class="keywordflow">else</span>
<a name="l00299"></a>00299             {
<a name="l00300"></a>00300                 fprintf(stderr, <span class="stringliteral">&quot;Failed to allocate compressed data buffer\n&quot;</span>);
<a name="l00301"></a>00301                 new_buf_sz = 0;
<a name="l00302"></a>00302             }
<a name="l00303"></a>00303         }
<a name="l00304"></a>00304     }
<a name="l00305"></a>00305 
<a name="l00306"></a>00306     *buf_sz = new_buf_sz;
<a name="l00307"></a>00307 
<a name="l00308"></a>00308     <span class="keywordflow">if</span> (!feof(infile))
<a name="l00309"></a>00309     {
<a name="l00310"></a>00310         <span class="keywordflow">if</span> (fread(*buf, 1, *buf_sz, infile) != *buf_sz)
<a name="l00311"></a>00311         {
<a name="l00312"></a>00312             fprintf(stderr, <span class="stringliteral">&quot;Failed to read full frame\n&quot;</span>);
<a name="l00313"></a>00313             <span class="keywordflow">return</span> 1;
<a name="l00314"></a>00314         }
<a name="l00315"></a>00315 
<a name="l00316"></a>00316         <span class="keywordflow">return</span> 0;
<a name="l00317"></a>00317     }
<a name="l00318"></a>00318 
<a name="l00319"></a>00319     <span class="keywordflow">return</span> 1;
<a name="l00320"></a>00320 }
<a name="l00321"></a>00321 
<a name="l00322"></a>00322 <span class="keywordtype">void</span> *out_open(<span class="keyword">const</span> <span class="keywordtype">char</span> *out_fn, <span class="keywordtype">int</span> do_md5)
<a name="l00323"></a>00323 {
<a name="l00324"></a>00324     <span class="keywordtype">void</span> *out = NULL;
<a name="l00325"></a>00325 
<a name="l00326"></a>00326     <span class="keywordflow">if</span> (do_md5)
<a name="l00327"></a>00327     {
<a name="l00328"></a>00328 <span class="preprocessor">#if CONFIG_MD5</span>
<a name="l00329"></a>00329 <span class="preprocessor"></span>        MD5Context *md5_ctx = out = malloc(<span class="keyword">sizeof</span>(MD5Context));
<a name="l00330"></a>00330         (void)out_fn;
<a name="l00331"></a>00331         MD5Init(md5_ctx);
<a name="l00332"></a>00332 <span class="preprocessor">#endif</span>
<a name="l00333"></a>00333 <span class="preprocessor"></span>    }
<a name="l00334"></a>00334     <span class="keywordflow">else</span>
<a name="l00335"></a>00335     {
<a name="l00336"></a>00336         FILE *outfile = out = strcmp(<span class="stringliteral">&quot;-&quot;</span>, out_fn) ? fopen(out_fn, <span class="stringliteral">&quot;wb&quot;</span>)
<a name="l00337"></a>00337                                                   : set_binary_mode(stdout);
<a name="l00338"></a>00338 
<a name="l00339"></a>00339         <span class="keywordflow">if</span> (!outfile)
<a name="l00340"></a>00340         {
<a name="l00341"></a>00341             fprintf(stderr, <span class="stringliteral">&quot;Failed to output file&quot;</span>);
<a name="l00342"></a>00342             exit(EXIT_FAILURE);
<a name="l00343"></a>00343         }
<a name="l00344"></a>00344     }
<a name="l00345"></a>00345 
<a name="l00346"></a>00346     <span class="keywordflow">return</span> out;
<a name="l00347"></a>00347 }
<a name="l00348"></a>00348 
<a name="l00349"></a>00349 <span class="keywordtype">void</span> out_put(<span class="keywordtype">void</span> *out, <span class="keyword">const</span> uint8_t *buf, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len, <span class="keywordtype">int</span> do_md5)
<a name="l00350"></a>00350 {
<a name="l00351"></a>00351     <span class="keywordflow">if</span> (do_md5)
<a name="l00352"></a>00352     {
<a name="l00353"></a>00353 <span class="preprocessor">#if CONFIG_MD5</span>
<a name="l00354"></a>00354 <span class="preprocessor"></span>        MD5Update(out, buf, len);
<a name="l00355"></a>00355 <span class="preprocessor">#endif</span>
<a name="l00356"></a>00356 <span class="preprocessor"></span>    }
<a name="l00357"></a>00357     <span class="keywordflow">else</span>
<a name="l00358"></a>00358     {
<a name="l00359"></a>00359         <span class="keywordflow">if</span>(fwrite(buf, 1, len, out));
<a name="l00360"></a>00360     }
<a name="l00361"></a>00361 }
<a name="l00362"></a>00362 
<a name="l00363"></a>00363 <span class="keywordtype">void</span> out_close(<span class="keywordtype">void</span> *out, <span class="keyword">const</span> <span class="keywordtype">char</span> *out_fn, <span class="keywordtype">int</span> do_md5)
<a name="l00364"></a>00364 {
<a name="l00365"></a>00365     <span class="keywordflow">if</span> (do_md5)
<a name="l00366"></a>00366     {
<a name="l00367"></a>00367 <span class="preprocessor">#if CONFIG_MD5</span>
<a name="l00368"></a>00368 <span class="preprocessor"></span>        uint8_t md5[16];
<a name="l00369"></a>00369         <span class="keywordtype">int</span> i;
<a name="l00370"></a>00370 
<a name="l00371"></a>00371         MD5Final(md5, out);
<a name="l00372"></a>00372         free(out);
<a name="l00373"></a>00373 
<a name="l00374"></a>00374         <span class="keywordflow">for</span> (i = 0; i &lt; 16; i++)
<a name="l00375"></a>00375             printf(<span class="stringliteral">&quot;%02x&quot;</span>, md5[i]);
<a name="l00376"></a>00376 
<a name="l00377"></a>00377         printf(<span class="stringliteral">&quot;  %s\n&quot;</span>, out_fn);
<a name="l00378"></a>00378 <span class="preprocessor">#endif</span>
<a name="l00379"></a>00379 <span class="preprocessor"></span>    }
<a name="l00380"></a>00380     <span class="keywordflow">else</span>
<a name="l00381"></a>00381     {
<a name="l00382"></a>00382         fclose(out);
<a name="l00383"></a>00383     }
<a name="l00384"></a>00384 }
<a name="l00385"></a>00385 
<a name="l00386"></a>00386 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> file_is_ivf(FILE *infile,
<a name="l00387"></a>00387                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *fourcc,
<a name="l00388"></a>00388                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *width,
<a name="l00389"></a>00389                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *height,
<a name="l00390"></a>00390                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *fps_den,
<a name="l00391"></a>00391                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *fps_num)
<a name="l00392"></a>00392 {
<a name="l00393"></a>00393     <span class="keywordtype">char</span> raw_hdr[32];
<a name="l00394"></a>00394     <span class="keywordtype">int</span> is_ivf = 0;
<a name="l00395"></a>00395 
<a name="l00396"></a>00396     <span class="keywordflow">if</span> (fread(raw_hdr, 1, 32, infile) == 32)
<a name="l00397"></a>00397     {
<a name="l00398"></a>00398         <span class="keywordflow">if</span> (raw_hdr[0] == <span class="charliteral">&#39;D&#39;</span> &amp;&amp; raw_hdr[1] == <span class="charliteral">&#39;K&#39;</span>
<a name="l00399"></a>00399             &amp;&amp; raw_hdr[2] == <span class="charliteral">&#39;I&#39;</span> &amp;&amp; raw_hdr[3] == <span class="charliteral">&#39;F&#39;</span>)
<a name="l00400"></a>00400         {
<a name="l00401"></a>00401             is_ivf = 1;
<a name="l00402"></a>00402 
<a name="l00403"></a>00403             <span class="keywordflow">if</span> (mem_get_le16(raw_hdr + 4) != 0)
<a name="l00404"></a>00404                 fprintf(stderr, <span class="stringliteral">&quot;Error: Unrecognized IVF version! This file may not&quot;</span>
<a name="l00405"></a>00405                         <span class="stringliteral">&quot; decode properly.&quot;</span>);
<a name="l00406"></a>00406 
<a name="l00407"></a>00407             *fourcc = mem_get_le32(raw_hdr + 8);
<a name="l00408"></a>00408             *width = mem_get_le16(raw_hdr + 12);
<a name="l00409"></a>00409             *height = mem_get_le16(raw_hdr + 14);
<a name="l00410"></a>00410             *fps_num = mem_get_le32(raw_hdr + 16);
<a name="l00411"></a>00411             *fps_den = mem_get_le32(raw_hdr + 20);
<a name="l00412"></a>00412 
<a name="l00413"></a>00413             <span class="comment">/* Some versions of vpxenc used 1/(2*fps) for the timebase, so</span>
<a name="l00414"></a>00414 <span class="comment">             * we can guess the framerate using only the timebase in this</span>
<a name="l00415"></a>00415 <span class="comment">             * case. Other files would require reading ahead to guess the</span>
<a name="l00416"></a>00416 <span class="comment">             * timebase, like we do for webm.</span>
<a name="l00417"></a>00417 <span class="comment">             */</span>
<a name="l00418"></a>00418             <span class="keywordflow">if</span>(*fps_num &lt; 1000)
<a name="l00419"></a>00419             {
<a name="l00420"></a>00420                 <span class="comment">/* Correct for the factor of 2 applied to the timebase in the</span>
<a name="l00421"></a>00421 <span class="comment">                 * encoder.</span>
<a name="l00422"></a>00422 <span class="comment">                 */</span>
<a name="l00423"></a>00423                 <span class="keywordflow">if</span>(*fps_num&amp;1)*fps_den&lt;&lt;=1;
<a name="l00424"></a>00424                 <span class="keywordflow">else</span> *fps_num&gt;&gt;=1;
<a name="l00425"></a>00425             }
<a name="l00426"></a>00426             <span class="keywordflow">else</span>
<a name="l00427"></a>00427             {
<a name="l00428"></a>00428                 <span class="comment">/* Don&#39;t know FPS for sure, and don&#39;t have readahead code</span>
<a name="l00429"></a>00429 <span class="comment">                 * (yet?), so just default to 30fps.</span>
<a name="l00430"></a>00430 <span class="comment">                 */</span>
<a name="l00431"></a>00431                 *fps_num = 30;
<a name="l00432"></a>00432                 *fps_den = 1;
<a name="l00433"></a>00433             }
<a name="l00434"></a>00434         }
<a name="l00435"></a>00435     }
<a name="l00436"></a>00436 
<a name="l00437"></a>00437     <span class="keywordflow">if</span> (!is_ivf)
<a name="l00438"></a>00438         rewind(infile);
<a name="l00439"></a>00439 
<a name="l00440"></a>00440     <span class="keywordflow">return</span> is_ivf;
<a name="l00441"></a>00441 }
<a name="l00442"></a>00442 
<a name="l00443"></a>00443 
<a name="l00444"></a>00444 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> file_is_raw(FILE *infile,
<a name="l00445"></a>00445                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *fourcc,
<a name="l00446"></a>00446                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *width,
<a name="l00447"></a>00447                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *height,
<a name="l00448"></a>00448                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *fps_den,
<a name="l00449"></a>00449                          <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *fps_num)
<a name="l00450"></a>00450 {
<a name="l00451"></a>00451     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> buf[32];
<a name="l00452"></a>00452     <span class="keywordtype">int</span> is_raw = 0;
<a name="l00453"></a>00453     <a class="code" href="structvpx__codec__stream__info.html" title="Stream properties.">vpx_codec_stream_info_t</a> si;
<a name="l00454"></a>00454 
<a name="l00455"></a>00455     si.<a class="code" href="structvpx__codec__stream__info.html#a8e5eb38a9042da54a20607f71591ddbf">sz</a> = <span class="keyword">sizeof</span>(si);
<a name="l00456"></a>00456 
<a name="l00457"></a>00457     <span class="keywordflow">if</span> (fread(buf, 1, 32, infile) == 32)
<a name="l00458"></a>00458     {
<a name="l00459"></a>00459         <span class="keywordtype">int</span> i;
<a name="l00460"></a>00460 
<a name="l00461"></a>00461         <span class="keywordflow">if</span>(mem_get_le32(buf) &lt; 256 * 1024 * 1024)
<a name="l00462"></a>00462             <span class="keywordflow">for</span> (i = 0; i &lt; <span class="keyword">sizeof</span>(ifaces) / <span class="keyword">sizeof</span>(ifaces[0]); i++)
<a name="l00463"></a>00463                 <span class="keywordflow">if</span>(!<a class="code" href="group__decoder.html#gadfee4664d644175d5aac1465ef11c4b0" title="Parse stream info from a buffer.">vpx_codec_peek_stream_info</a>(ifaces[i].iface,
<a name="l00464"></a>00464                                                buf + 4, 32 - 4, &amp;si))
<a name="l00465"></a>00465                 {
<a name="l00466"></a>00466                     is_raw = 1;
<a name="l00467"></a>00467                     *fourcc = ifaces[i].fourcc;
<a name="l00468"></a>00468                     *width = si.<a class="code" href="structvpx__codec__stream__info.html#a957dbfa83c93d9b3dc08498a6b97c77d">w</a>;
<a name="l00469"></a>00469                     *height = si.<a class="code" href="structvpx__codec__stream__info.html#af7a8b114547e434d182c722bdace63a0">h</a>;
<a name="l00470"></a>00470                     *fps_num = 30;
<a name="l00471"></a>00471                     *fps_den = 1;
<a name="l00472"></a>00472                     <span class="keywordflow">break</span>;
<a name="l00473"></a>00473                 }
<a name="l00474"></a>00474     }
<a name="l00475"></a>00475 
<a name="l00476"></a>00476     rewind(infile);
<a name="l00477"></a>00477     <span class="keywordflow">return</span> is_raw;
<a name="l00478"></a>00478 }
<a name="l00479"></a>00479 
<a name="l00480"></a>00480 
<a name="l00481"></a>00481 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00482"></a>00482 nestegg_read_cb(<span class="keywordtype">void</span> *buffer, <span class="keywordtype">size_t</span> length, <span class="keywordtype">void</span> *userdata)
<a name="l00483"></a>00483 {
<a name="l00484"></a>00484     FILE *f = userdata;
<a name="l00485"></a>00485 
<a name="l00486"></a>00486     <span class="keywordflow">if</span>(fread(buffer, 1, length, f) &lt; length)
<a name="l00487"></a>00487     {
<a name="l00488"></a>00488         <span class="keywordflow">if</span> (ferror(f))
<a name="l00489"></a>00489             <span class="keywordflow">return</span> -1;
<a name="l00490"></a>00490         <span class="keywordflow">if</span> (feof(f))
<a name="l00491"></a>00491             <span class="keywordflow">return</span> 0;
<a name="l00492"></a>00492     }
<a name="l00493"></a>00493     <span class="keywordflow">return</span> 1;
<a name="l00494"></a>00494 }
<a name="l00495"></a>00495 
<a name="l00496"></a>00496 
<a name="l00497"></a>00497 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00498"></a>00498 nestegg_seek_cb(int64_t offset, <span class="keywordtype">int</span> whence, <span class="keywordtype">void</span> * userdata)
<a name="l00499"></a>00499 {
<a name="l00500"></a>00500     <span class="keywordflow">switch</span>(whence) {
<a name="l00501"></a>00501         <span class="keywordflow">case</span> NESTEGG_SEEK_SET: whence = SEEK_SET; <span class="keywordflow">break</span>;
<a name="l00502"></a>00502         <span class="keywordflow">case</span> NESTEGG_SEEK_CUR: whence = SEEK_CUR; <span class="keywordflow">break</span>;
<a name="l00503"></a>00503         <span class="keywordflow">case</span> NESTEGG_SEEK_END: whence = SEEK_END; <span class="keywordflow">break</span>;
<a name="l00504"></a>00504     };
<a name="l00505"></a>00505     <span class="keywordflow">return</span> fseek(userdata, offset, whence)? -1 : 0;
<a name="l00506"></a>00506 }
<a name="l00507"></a>00507 
<a name="l00508"></a>00508 
<a name="l00509"></a>00509 <span class="keyword">static</span> int64_t
<a name="l00510"></a>00510 nestegg_tell_cb(<span class="keywordtype">void</span> * userdata)
<a name="l00511"></a>00511 {
<a name="l00512"></a>00512     <span class="keywordflow">return</span> ftell(userdata);
<a name="l00513"></a>00513 }
<a name="l00514"></a>00514 
<a name="l00515"></a>00515 
<a name="l00516"></a>00516 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00517"></a>00517 nestegg_log_cb(nestegg * context, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> severity, <span class="keywordtype">char</span> <span class="keyword">const</span> * format,
<a name="l00518"></a>00518                ...)
<a name="l00519"></a>00519 {
<a name="l00520"></a>00520     va_list ap;
<a name="l00521"></a>00521 
<a name="l00522"></a>00522     va_start(ap, format);
<a name="l00523"></a>00523     vfprintf(stderr, format, ap);
<a name="l00524"></a>00524     fprintf(stderr, <span class="stringliteral">&quot;\n&quot;</span>);
<a name="l00525"></a>00525     va_end(ap);
<a name="l00526"></a>00526 }
<a name="l00527"></a>00527 
<a name="l00528"></a>00528 
<a name="l00529"></a>00529 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00530"></a>00530 webm_guess_framerate(<span class="keyword">struct</span> input_ctx *input,
<a name="l00531"></a>00531                      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>     *fps_den,
<a name="l00532"></a>00532                      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>     *fps_num)
<a name="l00533"></a>00533 {
<a name="l00534"></a>00534     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00535"></a>00535     uint64_t     tstamp=0;
<a name="l00536"></a>00536 
<a name="l00537"></a>00537     <span class="comment">/* Guess the framerate. Read up to 1 second, or 50 video packets,</span>
<a name="l00538"></a>00538 <span class="comment">     * whichever comes first.</span>
<a name="l00539"></a>00539 <span class="comment">     */</span>
<a name="l00540"></a>00540     <span class="keywordflow">for</span>(i=0; tstamp &lt; 1000000000 &amp;&amp; i &lt; 50;)
<a name="l00541"></a>00541     {
<a name="l00542"></a>00542         nestegg_packet * pkt;
<a name="l00543"></a>00543         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> track;
<a name="l00544"></a>00544 
<a name="l00545"></a>00545         <span class="keywordflow">if</span>(nestegg_read_packet(input-&gt;nestegg_ctx, &amp;pkt) &lt;= 0)
<a name="l00546"></a>00546             <span class="keywordflow">break</span>;
<a name="l00547"></a>00547 
<a name="l00548"></a>00548         nestegg_packet_track(pkt, &amp;track);
<a name="l00549"></a>00549         <span class="keywordflow">if</span>(track == input-&gt;video_track)
<a name="l00550"></a>00550         {
<a name="l00551"></a>00551             nestegg_packet_tstamp(pkt, &amp;tstamp);
<a name="l00552"></a>00552             i++;
<a name="l00553"></a>00553         }
<a name="l00554"></a>00554 
<a name="l00555"></a>00555         nestegg_free_packet(pkt);
<a name="l00556"></a>00556     }
<a name="l00557"></a>00557 
<a name="l00558"></a>00558     <span class="keywordflow">if</span>(nestegg_track_seek(input-&gt;nestegg_ctx, input-&gt;video_track, 0))
<a name="l00559"></a>00559         <span class="keywordflow">goto</span> fail;
<a name="l00560"></a>00560 
<a name="l00561"></a>00561     *fps_num = (i - 1) * 1000000;
<a name="l00562"></a>00562     *fps_den = tstamp / 1000;
<a name="l00563"></a>00563     <span class="keywordflow">return</span> 0;
<a name="l00564"></a>00564 fail:
<a name="l00565"></a>00565     nestegg_destroy(input-&gt;nestegg_ctx);
<a name="l00566"></a>00566     input-&gt;nestegg_ctx = NULL;
<a name="l00567"></a>00567     rewind(input-&gt;infile);
<a name="l00568"></a>00568     <span class="keywordflow">return</span> 1;
<a name="l00569"></a>00569 }
<a name="l00570"></a>00570 
<a name="l00571"></a>00571 
<a name="l00572"></a>00572 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00573"></a>00573 file_is_webm(<span class="keyword">struct</span> input_ctx *input,
<a name="l00574"></a>00574              <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>     *fourcc,
<a name="l00575"></a>00575              <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>     *width,
<a name="l00576"></a>00576              <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>     *height,
<a name="l00577"></a>00577              <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>     *fps_den,
<a name="l00578"></a>00578              <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>     *fps_num)
<a name="l00579"></a>00579 {
<a name="l00580"></a>00580     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i, n;
<a name="l00581"></a>00581     <span class="keywordtype">int</span>          track_type = -1;
<a name="l00582"></a>00582 
<a name="l00583"></a>00583     nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb,
<a name="l00584"></a>00584                      input-&gt;infile};
<a name="l00585"></a>00585     nestegg_video_params params;
<a name="l00586"></a>00586 
<a name="l00587"></a>00587     <span class="keywordflow">if</span>(nestegg_init(&amp;input-&gt;nestegg_ctx, io, NULL))
<a name="l00588"></a>00588         <span class="keywordflow">goto</span> fail;
<a name="l00589"></a>00589 
<a name="l00590"></a>00590     <span class="keywordflow">if</span>(nestegg_track_count(input-&gt;nestegg_ctx, &amp;n))
<a name="l00591"></a>00591         <span class="keywordflow">goto</span> fail;
<a name="l00592"></a>00592 
<a name="l00593"></a>00593     <span class="keywordflow">for</span>(i=0; i&lt;n; i++)
<a name="l00594"></a>00594     {
<a name="l00595"></a>00595         track_type = nestegg_track_type(input-&gt;nestegg_ctx, i);
<a name="l00596"></a>00596 
<a name="l00597"></a>00597         <span class="keywordflow">if</span>(track_type == NESTEGG_TRACK_VIDEO)
<a name="l00598"></a>00598             <span class="keywordflow">break</span>;
<a name="l00599"></a>00599         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(track_type &lt; 0)
<a name="l00600"></a>00600             <span class="keywordflow">goto</span> fail;
<a name="l00601"></a>00601     }
<a name="l00602"></a>00602 
<a name="l00603"></a>00603     <span class="keywordflow">if</span>(nestegg_track_codec_id(input-&gt;nestegg_ctx, i) != NESTEGG_CODEC_VP8)
<a name="l00604"></a>00604     {
<a name="l00605"></a>00605         fprintf(stderr, <span class="stringliteral">&quot;Not VP8 video, quitting.\n&quot;</span>);
<a name="l00606"></a>00606         exit(1);
<a name="l00607"></a>00607     }
<a name="l00608"></a>00608 
<a name="l00609"></a>00609     input-&gt;video_track = i;
<a name="l00610"></a>00610 
<a name="l00611"></a>00611     <span class="keywordflow">if</span>(nestegg_track_video_params(input-&gt;nestegg_ctx, i, &amp;params))
<a name="l00612"></a>00612         <span class="keywordflow">goto</span> fail;
<a name="l00613"></a>00613 
<a name="l00614"></a>00614     *fps_den = 0;
<a name="l00615"></a>00615     *fps_num = 0;
<a name="l00616"></a>00616     *fourcc = VP8_FOURCC;
<a name="l00617"></a>00617     *width = params.width;
<a name="l00618"></a>00618     *height = params.height;
<a name="l00619"></a>00619     <span class="keywordflow">return</span> 1;
<a name="l00620"></a>00620 fail:
<a name="l00621"></a>00621     input-&gt;nestegg_ctx = NULL;
<a name="l00622"></a>00622     rewind(input-&gt;infile);
<a name="l00623"></a>00623     <span class="keywordflow">return</span> 0;
<a name="l00624"></a>00624 }
<a name="l00625"></a>00625 
<a name="l00626"></a>00626 
<a name="l00627"></a>00627 <span class="keywordtype">void</span> show_progress(<span class="keywordtype">int</span> frame_in, <span class="keywordtype">int</span> frame_out, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> dx_time)
<a name="l00628"></a>00628 {
<a name="l00629"></a>00629     fprintf(stderr, <span class="stringliteral">&quot;%d decoded frames/%d showed frames in %lu us (%.2f fps)\r&quot;</span>,
<a name="l00630"></a>00630             frame_in, frame_out, dx_time,
<a name="l00631"></a>00631             (<span class="keywordtype">float</span>)frame_out * 1000000.0 / (<span class="keywordtype">float</span>)dx_time);
<a name="l00632"></a>00632 }
<a name="l00633"></a>00633 
<a name="l00634"></a>00634 
<a name="l00635"></a>00635 <span class="keywordtype">void</span> generate_filename(<span class="keyword">const</span> <span class="keywordtype">char</span> *pattern, <span class="keywordtype">char</span> *out, <span class="keywordtype">size_t</span> q_len,
<a name="l00636"></a>00636                        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> d_w, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> d_h,
<a name="l00637"></a>00637                        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> frame_in)
<a name="l00638"></a>00638 {
<a name="l00639"></a>00639     <span class="keyword">const</span> <span class="keywordtype">char</span> *p = pattern;
<a name="l00640"></a>00640     <span class="keywordtype">char</span> *q = out;
<a name="l00641"></a>00641 
<a name="l00642"></a>00642     <span class="keywordflow">do</span>
<a name="l00643"></a>00643     {
<a name="l00644"></a>00644         <span class="keywordtype">char</span> *next_pat = strchr(p, <span class="charliteral">&#39;%&#39;</span>);
<a name="l00645"></a>00645 
<a name="l00646"></a>00646         <span class="keywordflow">if</span>(p == next_pat)
<a name="l00647"></a>00647         {
<a name="l00648"></a>00648             <span class="keywordtype">size_t</span> pat_len;
<a name="l00649"></a>00649 
<a name="l00650"></a>00650             <span class="comment">// parse the pattern</span>
<a name="l00651"></a>00651             q[q_len - 1] = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00652"></a>00652             <span class="keywordflow">switch</span>(p[1])
<a name="l00653"></a>00653             {
<a name="l00654"></a>00654             <span class="keywordflow">case</span> <span class="charliteral">&#39;w&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%d&quot;</span>, d_w); <span class="keywordflow">break</span>;
<a name="l00655"></a>00655             <span class="keywordflow">case</span> <span class="charliteral">&#39;h&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%d&quot;</span>, d_h); <span class="keywordflow">break</span>;
<a name="l00656"></a>00656             <span class="keywordflow">case</span> <span class="charliteral">&#39;1&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00657"></a>00657             <span class="keywordflow">case</span> <span class="charliteral">&#39;2&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%02d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00658"></a>00658             <span class="keywordflow">case</span> <span class="charliteral">&#39;3&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%03d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00659"></a>00659             <span class="keywordflow">case</span> <span class="charliteral">&#39;4&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%04d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00660"></a>00660             <span class="keywordflow">case</span> <span class="charliteral">&#39;5&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%05d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00661"></a>00661             <span class="keywordflow">case</span> <span class="charliteral">&#39;6&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%06d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00662"></a>00662             <span class="keywordflow">case</span> <span class="charliteral">&#39;7&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%07d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00663"></a>00663             <span class="keywordflow">case</span> <span class="charliteral">&#39;8&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%08d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00664"></a>00664             <span class="keywordflow">case</span> <span class="charliteral">&#39;9&#39;</span>: snprintf(q, q_len - 1, <span class="stringliteral">&quot;%09d&quot;</span>, frame_in); <span class="keywordflow">break</span>;
<a name="l00665"></a>00665             <span class="keywordflow">default</span>:
<a name="l00666"></a>00666                 die(<span class="stringliteral">&quot;Unrecognized pattern %%%c\n&quot;</span>, p[1]);
<a name="l00667"></a>00667             }
<a name="l00668"></a>00668 
<a name="l00669"></a>00669             pat_len = strlen(q);
<a name="l00670"></a>00670             <span class="keywordflow">if</span>(pat_len &gt;= q_len - 1)
<a name="l00671"></a>00671                 die(<span class="stringliteral">&quot;Output filename too long.\n&quot;</span>);
<a name="l00672"></a>00672             q += pat_len;
<a name="l00673"></a>00673             p += 2;
<a name="l00674"></a>00674             q_len -= pat_len;
<a name="l00675"></a>00675         }
<a name="l00676"></a>00676         <span class="keywordflow">else</span>
<a name="l00677"></a>00677         {
<a name="l00678"></a>00678             <span class="keywordtype">size_t</span> copy_len;
<a name="l00679"></a>00679 
<a name="l00680"></a>00680             <span class="comment">// copy the next segment</span>
<a name="l00681"></a>00681             <span class="keywordflow">if</span>(!next_pat)
<a name="l00682"></a>00682                 copy_len = strlen(p);
<a name="l00683"></a>00683             <span class="keywordflow">else</span>
<a name="l00684"></a>00684                 copy_len = next_pat - p;
<a name="l00685"></a>00685 
<a name="l00686"></a>00686             <span class="keywordflow">if</span>(copy_len &gt;= q_len - 1)
<a name="l00687"></a>00687                 die(<span class="stringliteral">&quot;Output filename too long.\n&quot;</span>);
<a name="l00688"></a>00688 
<a name="l00689"></a>00689             memcpy(q, p, copy_len);
<a name="l00690"></a>00690             q[copy_len] = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00691"></a>00691             q += copy_len;
<a name="l00692"></a>00692             p += copy_len;
<a name="l00693"></a>00693             q_len -= copy_len;
<a name="l00694"></a>00694         }
<a name="l00695"></a>00695     } <span class="keywordflow">while</span>(*p);
<a name="l00696"></a>00696 }
<a name="l00697"></a>00697 
<a name="l00698"></a>00698 
<a name="l00699"></a>00699 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span> **argv_)
<a name="l00700"></a>00700 {
<a name="l00701"></a>00701     <a class="code" href="structvpx__codec__ctx.html" title="Codec context structure.">vpx_codec_ctx_t</a>          decoder;
<a name="l00702"></a>00702     <span class="keywordtype">char</span>                  *fn = NULL;
<a name="l00703"></a>00703     <span class="keywordtype">int</span>                    i;
<a name="l00704"></a>00704     uint8_t               *buf = NULL;
<a name="l00705"></a>00705     <span class="keywordtype">size_t</span>                 buf_sz = 0, buf_alloc_sz = 0;
<a name="l00706"></a>00706     FILE                  *infile;
<a name="l00707"></a>00707     <span class="keywordtype">int</span>                    frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0, do_md5 = 0, progress = 0;
<a name="l00708"></a>00708     <span class="keywordtype">int</span>                    stop_after = 0, postproc = 0, summary = 0, quiet = 1;
<a name="l00709"></a>00709     <span class="keywordtype">int</span>                    ec_enabled = 0;
<a name="l00710"></a>00710     <a class="code" href="group__codec.html#gad654f3da60151f5dfef70aca00ef1e9e" title="Codec interface structure.">vpx_codec_iface_t</a>       *iface = NULL;
<a name="l00711"></a>00711     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>           fourcc;
<a name="l00712"></a>00712     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>          dx_time = 0;
<a name="l00713"></a>00713     <span class="keyword">struct </span>arg               arg;
<a name="l00714"></a>00714     <span class="keywordtype">char</span>                   **argv, **argi, **argj;
<a name="l00715"></a>00715     <span class="keyword">const</span> <span class="keywordtype">char</span>             *outfile_pattern = 0;
<a name="l00716"></a>00716     <span class="keywordtype">char</span>                    outfile[PATH_MAX];
<a name="l00717"></a>00717     <span class="keywordtype">int</span>                     single_file;
<a name="l00718"></a>00718     <span class="keywordtype">int</span>                     use_y4m = 1;
<a name="l00719"></a>00719     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>            width;
<a name="l00720"></a>00720     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>            height;
<a name="l00721"></a>00721     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>            fps_den;
<a name="l00722"></a>00722     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>            fps_num;
<a name="l00723"></a>00723     <span class="keywordtype">void</span>                   *out = NULL;
<a name="l00724"></a>00724     <a class="code" href="structvpx__codec__dec__cfg.html" title="Initialization Configurations.">vpx_codec_dec_cfg_t</a>     cfg = {0};
<a name="l00725"></a>00725 <span class="preprocessor">#if CONFIG_VP8_DECODER</span>
<a name="l00726"></a>00726 <span class="preprocessor"></span>    <a class="code" href="structvp8__postproc__cfg.html" title="post process flags">vp8_postproc_cfg_t</a>      vp8_pp_cfg = {0};
<a name="l00727"></a>00727     <span class="keywordtype">int</span>                     vp8_dbg_color_ref_frame = 0;
<a name="l00728"></a>00728     <span class="keywordtype">int</span>                     vp8_dbg_color_mb_modes = 0;
<a name="l00729"></a>00729     <span class="keywordtype">int</span>                     vp8_dbg_color_b_modes = 0;
<a name="l00730"></a>00730     <span class="keywordtype">int</span>                     vp8_dbg_display_mv = 0;
<a name="l00731"></a>00731 <span class="preprocessor">#endif</span>
<a name="l00732"></a>00732 <span class="preprocessor"></span>    <span class="keyword">struct </span>input_ctx        input = {0};
<a name="l00733"></a>00733     <span class="keywordtype">int</span>                     frames_corrupted = 0;
<a name="l00734"></a>00734     <span class="keywordtype">int</span>                     dec_flags = 0;
<a name="l00735"></a>00735 
<a name="l00736"></a>00736     <span class="comment">/* Parse command line */</span>
<a name="l00737"></a>00737     exec_name = argv_[0];
<a name="l00738"></a>00738     argv = argv_dup(argc - 1, argv_ + 1);
<a name="l00739"></a>00739 
<a name="l00740"></a>00740     <span class="keywordflow">for</span> (argi = argj = argv; (*argj = *argi); argi += arg.argv_step)
<a name="l00741"></a>00741     {
<a name="l00742"></a>00742         memset(&amp;arg, 0, <span class="keyword">sizeof</span>(arg));
<a name="l00743"></a>00743         arg.argv_step = 1;
<a name="l00744"></a>00744 
<a name="l00745"></a>00745         <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;codecarg, argi))
<a name="l00746"></a>00746         {
<a name="l00747"></a>00747             <span class="keywordtype">int</span> j, k = -1;
<a name="l00748"></a>00748 
<a name="l00749"></a>00749             <span class="keywordflow">for</span> (j = 0; j &lt; <span class="keyword">sizeof</span>(ifaces) / <span class="keyword">sizeof</span>(ifaces[0]); j++)
<a name="l00750"></a>00750                 <span class="keywordflow">if</span> (!strcmp(ifaces[j].name, arg.val))
<a name="l00751"></a>00751                     k = j;
<a name="l00752"></a>00752 
<a name="l00753"></a>00753             <span class="keywordflow">if</span> (k &gt;= 0)
<a name="l00754"></a>00754                 iface = ifaces[k].iface;
<a name="l00755"></a>00755             <span class="keywordflow">else</span>
<a name="l00756"></a>00756                 die(<span class="stringliteral">&quot;Error: Unrecognized argument (%s) to --codec\n&quot;</span>,
<a name="l00757"></a>00757                     arg.val);
<a name="l00758"></a>00758         }
<a name="l00759"></a>00759         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;outputfile, argi))
<a name="l00760"></a>00760             outfile_pattern = arg.val;
<a name="l00761"></a>00761         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;use_yv12, argi))
<a name="l00762"></a>00762         {
<a name="l00763"></a>00763             use_y4m = 0;
<a name="l00764"></a>00764             flipuv = 1;
<a name="l00765"></a>00765         }
<a name="l00766"></a>00766         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;use_i420, argi))
<a name="l00767"></a>00767         {
<a name="l00768"></a>00768             use_y4m = 0;
<a name="l00769"></a>00769             flipuv = 0;
<a name="l00770"></a>00770         }
<a name="l00771"></a>00771         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;flipuvarg, argi))
<a name="l00772"></a>00772             flipuv = 1;
<a name="l00773"></a>00773         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;noblitarg, argi))
<a name="l00774"></a>00774             noblit = 1;
<a name="l00775"></a>00775         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;progressarg, argi))
<a name="l00776"></a>00776             progress = 1;
<a name="l00777"></a>00777         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;limitarg, argi))
<a name="l00778"></a>00778             stop_after = arg_parse_uint(&amp;arg);
<a name="l00779"></a>00779         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;postprocarg, argi))
<a name="l00780"></a>00780             postproc = 1;
<a name="l00781"></a>00781         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;md5arg, argi))
<a name="l00782"></a>00782             do_md5 = 1;
<a name="l00783"></a>00783         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;summaryarg, argi))
<a name="l00784"></a>00784             summary = 1;
<a name="l00785"></a>00785         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;threadsarg, argi))
<a name="l00786"></a>00786             cfg.<a class="code" href="structvpx__codec__dec__cfg.html#afca69d81e99ee15e1d641a639aefb7eb">threads</a> = arg_parse_uint(&amp;arg);
<a name="l00787"></a>00787         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;verbosearg, argi))
<a name="l00788"></a>00788             quiet = 0;
<a name="l00789"></a>00789 
<a name="l00790"></a>00790 <span class="preprocessor">#if CONFIG_VP8_DECODER</span>
<a name="l00791"></a>00791 <span class="preprocessor"></span>        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;addnoise_level, argi))
<a name="l00792"></a>00792         {
<a name="l00793"></a>00793             postproc = 1;
<a name="l00794"></a>00794             vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#ae9adc230642ac230f39eb4c531cf85e5">post_proc_flag</a> |= VP8_ADDNOISE;
<a name="l00795"></a>00795             vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#a32f28e4003e5d9bf55d188247f3f156c">noise_level</a> = arg_parse_uint(&amp;arg);
<a name="l00796"></a>00796         }
<a name="l00797"></a>00797         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;demacroblock_level, argi))
<a name="l00798"></a>00798         {
<a name="l00799"></a>00799             postproc = 1;
<a name="l00800"></a>00800             vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#ae9adc230642ac230f39eb4c531cf85e5">post_proc_flag</a> |= VP8_DEMACROBLOCK;
<a name="l00801"></a>00801             vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#afe919a9546e79798d840b1492f7e0249">deblocking_level</a> = arg_parse_uint(&amp;arg);
<a name="l00802"></a>00802         }
<a name="l00803"></a>00803         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;deblock, argi))
<a name="l00804"></a>00804         {
<a name="l00805"></a>00805             postproc = 1;
<a name="l00806"></a>00806             vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#ae9adc230642ac230f39eb4c531cf85e5">post_proc_flag</a> |= VP8_DEBLOCK;
<a name="l00807"></a>00807         }
<a name="l00808"></a>00808         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;mfqe, argi))
<a name="l00809"></a>00809         {
<a name="l00810"></a>00810             postproc = 1;
<a name="l00811"></a>00811             vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#ae9adc230642ac230f39eb4c531cf85e5">post_proc_flag</a> |= VP8_MFQE;
<a name="l00812"></a>00812         }
<a name="l00813"></a>00813         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;pp_debug_info, argi))
<a name="l00814"></a>00814         {
<a name="l00815"></a>00815             <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> level = arg_parse_uint(&amp;arg);
<a name="l00816"></a>00816 
<a name="l00817"></a>00817             postproc = 1;
<a name="l00818"></a>00818             vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#ae9adc230642ac230f39eb4c531cf85e5">post_proc_flag</a> &amp;= ~0x7;
<a name="l00819"></a>00819 
<a name="l00820"></a>00820             <span class="keywordflow">if</span> (level)
<a name="l00821"></a>00821                 vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#ae9adc230642ac230f39eb4c531cf85e5">post_proc_flag</a> |= level;
<a name="l00822"></a>00822         }
<a name="l00823"></a>00823         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;pp_disp_ref_frame, argi))
<a name="l00824"></a>00824         {
<a name="l00825"></a>00825             <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> flags = arg_parse_int(&amp;arg);
<a name="l00826"></a>00826             <span class="keywordflow">if</span> (flags)
<a name="l00827"></a>00827             {
<a name="l00828"></a>00828                 postproc = 1;
<a name="l00829"></a>00829                 vp8_dbg_color_ref_frame = flags;
<a name="l00830"></a>00830             }
<a name="l00831"></a>00831         }
<a name="l00832"></a>00832         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;pp_disp_mb_modes, argi))
<a name="l00833"></a>00833         {
<a name="l00834"></a>00834             <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> flags = arg_parse_int(&amp;arg);
<a name="l00835"></a>00835             <span class="keywordflow">if</span> (flags)
<a name="l00836"></a>00836             {
<a name="l00837"></a>00837                 postproc = 1;
<a name="l00838"></a>00838                 vp8_dbg_color_mb_modes = flags;
<a name="l00839"></a>00839             }
<a name="l00840"></a>00840         }
<a name="l00841"></a>00841         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;pp_disp_b_modes, argi))
<a name="l00842"></a>00842         {
<a name="l00843"></a>00843             <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> flags = arg_parse_int(&amp;arg);
<a name="l00844"></a>00844             <span class="keywordflow">if</span> (flags)
<a name="l00845"></a>00845             {
<a name="l00846"></a>00846                 postproc = 1;
<a name="l00847"></a>00847                 vp8_dbg_color_b_modes = flags;
<a name="l00848"></a>00848             }
<a name="l00849"></a>00849         }
<a name="l00850"></a>00850         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;pp_disp_mvs, argi))
<a name="l00851"></a>00851         {
<a name="l00852"></a>00852             <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> flags = arg_parse_int(&amp;arg);
<a name="l00853"></a>00853             <span class="keywordflow">if</span> (flags)
<a name="l00854"></a>00854             {
<a name="l00855"></a>00855                 postproc = 1;
<a name="l00856"></a>00856                 vp8_dbg_display_mv = flags;
<a name="l00857"></a>00857             }
<a name="l00858"></a>00858         }
<a name="l00859"></a>00859         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (arg_match(&amp;arg, &amp;error_concealment, argi))
<a name="l00860"></a>00860         {
<a name="l00861"></a>00861             ec_enabled = 1;
<a name="l00862"></a>00862         }
<a name="l00863"></a>00863 
<a name="l00864"></a>00864 <span class="preprocessor">#endif</span>
<a name="l00865"></a>00865 <span class="preprocessor"></span>        <span class="keywordflow">else</span>
<a name="l00866"></a>00866             argj++;
<a name="l00867"></a>00867     }
<a name="l00868"></a>00868 
<a name="l00869"></a>00869     <span class="comment">/* Check for unrecognized options */</span>
<a name="l00870"></a>00870     <span class="keywordflow">for</span> (argi = argv; *argi; argi++)
<a name="l00871"></a>00871         <span class="keywordflow">if</span> (argi[0][0] == <span class="charliteral">&#39;-&#39;</span> &amp;&amp; strlen(argi[0]) &gt; 1)
<a name="l00872"></a>00872             die(<span class="stringliteral">&quot;Error: Unrecognized option %s\n&quot;</span>, *argi);
<a name="l00873"></a>00873 
<a name="l00874"></a>00874     <span class="comment">/* Handle non-option arguments */</span>
<a name="l00875"></a>00875     fn = argv[0];
<a name="l00876"></a>00876 
<a name="l00877"></a>00877     <span class="keywordflow">if</span> (!fn)
<a name="l00878"></a>00878         usage_exit();
<a name="l00879"></a>00879 
<a name="l00880"></a>00880     <span class="comment">/* Open file */</span>
<a name="l00881"></a>00881     infile = strcmp(fn, <span class="stringliteral">&quot;-&quot;</span>) ? fopen(fn, <span class="stringliteral">&quot;rb&quot;</span>) : set_binary_mode(stdin);
<a name="l00882"></a>00882 
<a name="l00883"></a>00883     <span class="keywordflow">if</span> (!infile)
<a name="l00884"></a>00884     {
<a name="l00885"></a>00885         fprintf(stderr, <span class="stringliteral">&quot;Failed to open file &#39;%s&#39;&quot;</span>,
<a name="l00886"></a>00886                 strcmp(fn, <span class="stringliteral">&quot;-&quot;</span>) ? fn : <span class="stringliteral">&quot;stdin&quot;</span>);
<a name="l00887"></a>00887         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l00888"></a>00888     }
<a name="l00889"></a>00889 <span class="preprocessor">#if CONFIG_OS_SUPPORT</span>
<a name="l00890"></a>00890 <span class="preprocessor"></span>    <span class="comment">/* Make sure we don&#39;t dump to the terminal, unless forced to with -o - */</span>
<a name="l00891"></a>00891     <span class="keywordflow">if</span>(!outfile_pattern &amp;&amp; isatty(fileno(stdout)) &amp;&amp; !do_md5 &amp;&amp; !noblit)
<a name="l00892"></a>00892     {
<a name="l00893"></a>00893         fprintf(stderr,
<a name="l00894"></a>00894                 <span class="stringliteral">&quot;Not dumping raw video to your terminal. Use &#39;-o -&#39; to &quot;</span>
<a name="l00895"></a>00895                 <span class="stringliteral">&quot;override.\n&quot;</span>);
<a name="l00896"></a>00896         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l00897"></a>00897     }
<a name="l00898"></a>00898 <span class="preprocessor">#endif</span>
<a name="l00899"></a>00899 <span class="preprocessor"></span>    input.infile = infile;
<a name="l00900"></a>00900     <span class="keywordflow">if</span>(file_is_ivf(infile, &amp;fourcc, &amp;width, &amp;height, &amp;fps_den,
<a name="l00901"></a>00901                    &amp;fps_num))
<a name="l00902"></a>00902         input.kind = IVF_FILE;
<a name="l00903"></a>00903     <span class="keywordflow">else</span> <span class="keywordflow">if</span>(file_is_webm(&amp;input, &amp;fourcc, &amp;width, &amp;height, &amp;fps_den, &amp;fps_num))
<a name="l00904"></a>00904         input.kind = WEBM_FILE;
<a name="l00905"></a>00905     <span class="keywordflow">else</span> <span class="keywordflow">if</span>(file_is_raw(infile, &amp;fourcc, &amp;width, &amp;height, &amp;fps_den, &amp;fps_num))
<a name="l00906"></a>00906         input.kind = RAW_FILE;
<a name="l00907"></a>00907     <span class="keywordflow">else</span>
<a name="l00908"></a>00908     {
<a name="l00909"></a>00909         fprintf(stderr, <span class="stringliteral">&quot;Unrecognized input file type.\n&quot;</span>);
<a name="l00910"></a>00910         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l00911"></a>00911     }
<a name="l00912"></a>00912 
<a name="l00913"></a>00913     <span class="comment">/* If the output file is not set or doesn&#39;t have a sequence number in</span>
<a name="l00914"></a>00914 <span class="comment">     * it, then we only open it once.</span>
<a name="l00915"></a>00915 <span class="comment">     */</span>
<a name="l00916"></a>00916     outfile_pattern = outfile_pattern ? outfile_pattern : <span class="stringliteral">&quot;-&quot;</span>;
<a name="l00917"></a>00917     single_file = 1;
<a name="l00918"></a>00918     {
<a name="l00919"></a>00919         <span class="keyword">const</span> <span class="keywordtype">char</span> *p = outfile_pattern;
<a name="l00920"></a>00920         <span class="keywordflow">do</span>
<a name="l00921"></a>00921         {
<a name="l00922"></a>00922             p = strchr(p, <span class="charliteral">&#39;%&#39;</span>);
<a name="l00923"></a>00923             <span class="keywordflow">if</span>(p &amp;&amp; p[1] &gt;= <span class="charliteral">&#39;1&#39;</span> &amp;&amp; p[1] &lt;= <span class="charliteral">&#39;9&#39;</span>)
<a name="l00924"></a>00924             {
<a name="l00925"></a>00925                 <span class="comment">// pattern contains sequence number, so it&#39;s not unique.</span>
<a name="l00926"></a>00926                 single_file = 0;
<a name="l00927"></a>00927                 <span class="keywordflow">break</span>;
<a name="l00928"></a>00928             }
<a name="l00929"></a>00929             <span class="keywordflow">if</span>(p)
<a name="l00930"></a>00930                 p++;
<a name="l00931"></a>00931         } <span class="keywordflow">while</span>(p);
<a name="l00932"></a>00932     }
<a name="l00933"></a>00933 
<a name="l00934"></a>00934     <span class="keywordflow">if</span>(single_file &amp;&amp; !noblit)
<a name="l00935"></a>00935     {
<a name="l00936"></a>00936         generate_filename(outfile_pattern, outfile, <span class="keyword">sizeof</span>(outfile)-1,
<a name="l00937"></a>00937                           width, height, 0);
<a name="l00938"></a>00938         out = out_open(outfile, do_md5);
<a name="l00939"></a>00939     }
<a name="l00940"></a>00940 
<a name="l00941"></a>00941     <span class="keywordflow">if</span> (use_y4m &amp;&amp; !noblit)
<a name="l00942"></a>00942     {
<a name="l00943"></a>00943         <span class="keywordtype">char</span> buffer[128];
<a name="l00944"></a>00944         <span class="keywordflow">if</span> (!single_file)
<a name="l00945"></a>00945         {
<a name="l00946"></a>00946             fprintf(stderr, <span class="stringliteral">&quot;YUV4MPEG2 not supported with output patterns,&quot;</span>
<a name="l00947"></a>00947                             <span class="stringliteral">&quot; try --i420 or --yv12.\n&quot;</span>);
<a name="l00948"></a>00948             <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l00949"></a>00949         }
<a name="l00950"></a>00950 
<a name="l00951"></a>00951         <span class="keywordflow">if</span>(input.kind == WEBM_FILE)
<a name="l00952"></a>00952             <span class="keywordflow">if</span>(webm_guess_framerate(&amp;input, &amp;fps_den, &amp;fps_num))
<a name="l00953"></a>00953             {
<a name="l00954"></a>00954                 fprintf(stderr, <span class="stringliteral">&quot;Failed to guess framerate -- error parsing &quot;</span>
<a name="l00955"></a>00955                                 <span class="stringliteral">&quot;webm file?\n&quot;</span>);
<a name="l00956"></a>00956                 <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l00957"></a>00957             }
<a name="l00958"></a>00958 
<a name="l00959"></a>00959 
<a name="l00960"></a>00960         <span class="comment">/*Note: We can&#39;t output an aspect ratio here because IVF doesn&#39;t</span>
<a name="l00961"></a>00961 <span class="comment">           store one, and neither does VP8.</span>
<a name="l00962"></a>00962 <span class="comment">          That will have to wait until these tools support WebM natively.*/</span>
<a name="l00963"></a>00963         sprintf(buffer, <span class="stringliteral">&quot;YUV4MPEG2 C%s W%u H%u F%u:%u I%c\n&quot;</span>,
<a name="l00964"></a>00964                 <span class="stringliteral">&quot;420jpeg&quot;</span>, width, height, fps_num, fps_den, <span class="charliteral">&#39;p&#39;</span>);
<a name="l00965"></a>00965         out_put(out, (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)buffer, strlen(buffer), do_md5);
<a name="l00966"></a>00966     }
<a name="l00967"></a>00967 
<a name="l00968"></a>00968     <span class="comment">/* Try to determine the codec from the fourcc. */</span>
<a name="l00969"></a>00969     <span class="keywordflow">for</span> (i = 0; i &lt; <span class="keyword">sizeof</span>(ifaces) / <span class="keyword">sizeof</span>(ifaces[0]); i++)
<a name="l00970"></a>00970         <span class="keywordflow">if</span> ((fourcc &amp; ifaces[i].fourcc_mask) == ifaces[i].fourcc)
<a name="l00971"></a>00971         {
<a name="l00972"></a>00972             <a class="code" href="group__codec.html#gad654f3da60151f5dfef70aca00ef1e9e" title="Codec interface structure.">vpx_codec_iface_t</a>  *ivf_iface = ifaces[i].iface;
<a name="l00973"></a>00973 
<a name="l00974"></a>00974             <span class="keywordflow">if</span> (iface &amp;&amp; iface != ivf_iface)
<a name="l00975"></a>00975                 fprintf(stderr, <span class="stringliteral">&quot;Notice -- IVF header indicates codec: %s\n&quot;</span>,
<a name="l00976"></a>00976                         ifaces[i].name);
<a name="l00977"></a>00977             <span class="keywordflow">else</span>
<a name="l00978"></a>00978                 iface = ivf_iface;
<a name="l00979"></a>00979 
<a name="l00980"></a>00980             <span class="keywordflow">break</span>;
<a name="l00981"></a>00981         }
<a name="l00982"></a>00982 
<a name="l00983"></a>00983     dec_flags = (postproc ? <a class="code" href="group__decoder.html#ga6fe14f30254aff769412b128b29664cc" title="Initialization-time Feature Enabling.">VPX_CODEC_USE_POSTPROC</a> : 0) |
<a name="l00984"></a>00984                 (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0);
<a name="l00985"></a>00985     <span class="keywordflow">if</span> (<a class="code" href="group__decoder.html#ga8c2f0b12f1bd4927eb3c68b01eab19d3" title="Convenience macro for vpx_codec_dec_init_ver()">vpx_codec_dec_init</a>(&amp;decoder, iface ? iface :  ifaces[0].iface, &amp;cfg,
<a name="l00986"></a>00986                            dec_flags))
<a name="l00987"></a>00987     {
<a name="l00988"></a>00988         fprintf(stderr, <span class="stringliteral">&quot;Failed to initialize decoder: %s\n&quot;</span>, <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l00989"></a>00989         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l00990"></a>00990     }
<a name="l00991"></a>00991 
<a name="l00992"></a>00992     <span class="keywordflow">if</span> (!quiet)
<a name="l00993"></a>00993         fprintf(stderr, <span class="stringliteral">&quot;%s\n&quot;</span>, decoder.<a class="code" href="structvpx__codec__ctx.html#a7ed1bf8f6434ea2df01da8011849c6cb">name</a>);
<a name="l00994"></a>00994 
<a name="l00995"></a>00995 <span class="preprocessor">#if CONFIG_VP8_DECODER</span>
<a name="l00996"></a>00996 <span class="preprocessor"></span>
<a name="l00997"></a>00997     <span class="keywordflow">if</span> (vp8_pp_cfg.<a class="code" href="structvp8__postproc__cfg.html#ae9adc230642ac230f39eb4c531cf85e5">post_proc_flag</a>
<a name="l00998"></a>00998         &amp;&amp; <a class="code" href="group__codec.html#gac1b91e04698c1bd4c0a2b8aa85b08cd2" title="vpx_codec_control wrapper macro">vpx_codec_control</a>(&amp;decoder, <a class="code" href="group__vp8.html#gga8cadbc8e0af3da96ef7a2dbd4ed06599a43e85c68bc1c1473f4a94b005a59482c">VP8_SET_POSTPROC</a>, &amp;vp8_pp_cfg))
<a name="l00999"></a>00999     {
<a name="l01000"></a>01000         fprintf(stderr, <span class="stringliteral">&quot;Failed to configure postproc: %s\n&quot;</span>, <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l01001"></a>01001         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l01002"></a>01002     }
<a name="l01003"></a>01003 
<a name="l01004"></a>01004     <span class="keywordflow">if</span> (vp8_dbg_color_ref_frame
<a name="l01005"></a>01005         &amp;&amp; <a class="code" href="group__codec.html#gac1b91e04698c1bd4c0a2b8aa85b08cd2" title="vpx_codec_control wrapper macro">vpx_codec_control</a>(&amp;decoder, <a class="code" href="group__vp8.html#gga8cadbc8e0af3da96ef7a2dbd4ed06599ab52ea7a97668b603812dfc205b0fd783">VP8_SET_DBG_COLOR_REF_FRAME</a>, vp8_dbg_color_ref_frame))
<a name="l01006"></a>01006     {
<a name="l01007"></a>01007         fprintf(stderr, <span class="stringliteral">&quot;Failed to configure reference block visualizer: %s\n&quot;</span>, <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l01008"></a>01008         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l01009"></a>01009     }
<a name="l01010"></a>01010 
<a name="l01011"></a>01011     <span class="keywordflow">if</span> (vp8_dbg_color_mb_modes
<a name="l01012"></a>01012         &amp;&amp; <a class="code" href="group__codec.html#gac1b91e04698c1bd4c0a2b8aa85b08cd2" title="vpx_codec_control wrapper macro">vpx_codec_control</a>(&amp;decoder, <a class="code" href="group__vp8.html#gga8cadbc8e0af3da96ef7a2dbd4ed06599aa0d5c3eaa7cbecaf64403edc8450b060">VP8_SET_DBG_COLOR_MB_MODES</a>, vp8_dbg_color_mb_modes))
<a name="l01013"></a>01013     {
<a name="l01014"></a>01014         fprintf(stderr, <span class="stringliteral">&quot;Failed to configure macro block visualizer: %s\n&quot;</span>, <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l01015"></a>01015         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l01016"></a>01016     }
<a name="l01017"></a>01017 
<a name="l01018"></a>01018     <span class="keywordflow">if</span> (vp8_dbg_color_b_modes
<a name="l01019"></a>01019         &amp;&amp; <a class="code" href="group__codec.html#gac1b91e04698c1bd4c0a2b8aa85b08cd2" title="vpx_codec_control wrapper macro">vpx_codec_control</a>(&amp;decoder, <a class="code" href="group__vp8.html#gga8cadbc8e0af3da96ef7a2dbd4ed06599ae0052b9dd3c64a4bb822abafb4755a87">VP8_SET_DBG_COLOR_B_MODES</a>, vp8_dbg_color_b_modes))
<a name="l01020"></a>01020     {
<a name="l01021"></a>01021         fprintf(stderr, <span class="stringliteral">&quot;Failed to configure block visualizer: %s\n&quot;</span>, <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l01022"></a>01022         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l01023"></a>01023     }
<a name="l01024"></a>01024 
<a name="l01025"></a>01025     <span class="keywordflow">if</span> (vp8_dbg_display_mv
<a name="l01026"></a>01026         &amp;&amp; <a class="code" href="group__codec.html#gac1b91e04698c1bd4c0a2b8aa85b08cd2" title="vpx_codec_control wrapper macro">vpx_codec_control</a>(&amp;decoder, <a class="code" href="group__vp8.html#gga8cadbc8e0af3da96ef7a2dbd4ed06599abc6aef0d7e0486d25348de217ad8441d">VP8_SET_DBG_DISPLAY_MV</a>, vp8_dbg_display_mv))
<a name="l01027"></a>01027     {
<a name="l01028"></a>01028         fprintf(stderr, <span class="stringliteral">&quot;Failed to configure motion vector visualizer: %s\n&quot;</span>, <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l01029"></a>01029         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l01030"></a>01030     }
<a name="l01031"></a>01031 <span class="preprocessor">#endif</span>
<a name="l01032"></a>01032 <span class="preprocessor"></span>
<a name="l01033"></a>01033     <span class="comment">/* Decode file */</span>
<a name="l01034"></a>01034     <span class="keywordflow">while</span> (!read_frame(&amp;input, &amp;buf, &amp;buf_sz, &amp;buf_alloc_sz))
<a name="l01035"></a>01035     {
<a name="l01036"></a>01036         <a class="code" href="group__codec.html#ga6ea348f76b1f8a1fe50e14db684146c6" title="Iterator.">vpx_codec_iter_t</a>  iter = NULL;
<a name="l01037"></a>01037         <a class="code" href="structvpx__image.html" title="Image Descriptor.">vpx_image_t</a>    *img;
<a name="l01038"></a>01038         <span class="keyword">struct </span>vpx_usec_timer timer;
<a name="l01039"></a>01039         <span class="keywordtype">int</span>                   corrupted;
<a name="l01040"></a>01040 
<a name="l01041"></a>01041         vpx_usec_timer_start(&amp;timer);
<a name="l01042"></a>01042 
<a name="l01043"></a>01043         <span class="keywordflow">if</span> (<a class="code" href="group__decoder.html#ga3441e157a7a69108bca9a069f2ee8e0d" title="Decode data.">vpx_codec_decode</a>(&amp;decoder, buf, buf_sz, NULL, 0))
<a name="l01044"></a>01044         {
<a name="l01045"></a>01045             <span class="keyword">const</span> <span class="keywordtype">char</span> *detail = <a class="code" href="group__codec.html#ga29273cb552ed1a437fe263c4a0a54300" title="Retrieve detailed error information for codec context.">vpx_codec_error_detail</a>(&amp;decoder);
<a name="l01046"></a>01046             fprintf(stderr, <span class="stringliteral">&quot;Failed to decode frame: %s\n&quot;</span>, <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l01047"></a>01047 
<a name="l01048"></a>01048             <span class="keywordflow">if</span> (detail)
<a name="l01049"></a>01049                 fprintf(stderr, <span class="stringliteral">&quot;  Additional information: %s\n&quot;</span>, detail);
<a name="l01050"></a>01050 
<a name="l01051"></a>01051             <span class="keywordflow">goto</span> fail;
<a name="l01052"></a>01052         }
<a name="l01053"></a>01053 
<a name="l01054"></a>01054         vpx_usec_timer_mark(&amp;timer);
<a name="l01055"></a>01055         dx_time += vpx_usec_timer_elapsed(&amp;timer);
<a name="l01056"></a>01056 
<a name="l01057"></a>01057         ++frame_in;
<a name="l01058"></a>01058 
<a name="l01059"></a>01059         <span class="keywordflow">if</span> (<a class="code" href="group__codec.html#gac1b91e04698c1bd4c0a2b8aa85b08cd2" title="vpx_codec_control wrapper macro">vpx_codec_control</a>(&amp;decoder, <a class="code" href="group__vp8__decoder.html#ggaf9dd3f2e6d1412106ee791af768e57c1af9f82d9e7930e6a2244b30b031b79599">VP8D_GET_FRAME_CORRUPTED</a>, &amp;corrupted))
<a name="l01060"></a>01060         {
<a name="l01061"></a>01061             fprintf(stderr, <span class="stringliteral">&quot;Failed VP8_GET_FRAME_CORRUPTED: %s\n&quot;</span>,
<a name="l01062"></a>01062                     <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l01063"></a>01063             <span class="keywordflow">goto</span> fail;
<a name="l01064"></a>01064         }
<a name="l01065"></a>01065         frames_corrupted += corrupted;
<a name="l01066"></a>01066 
<a name="l01067"></a>01067         <span class="keywordflow">if</span> ((img = <a class="code" href="group__decoder.html#ga0e231c3a5ce445fdb2268d741da97500" title="Decoded frames iterator.">vpx_codec_get_frame</a>(&amp;decoder, &amp;iter)))
<a name="l01068"></a>01068             ++frame_out;
<a name="l01069"></a>01069 
<a name="l01070"></a>01070         <span class="keywordflow">if</span> (progress)
<a name="l01071"></a>01071             show_progress(frame_in, frame_out, dx_time);
<a name="l01072"></a>01072 
<a name="l01073"></a>01073         <span class="keywordflow">if</span> (!noblit)
<a name="l01074"></a>01074         {
<a name="l01075"></a>01075             <span class="keywordflow">if</span> (img)
<a name="l01076"></a>01076             {
<a name="l01077"></a>01077                 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> y;
<a name="l01078"></a>01078                 <span class="keywordtype">char</span> out_fn[PATH_MAX];
<a name="l01079"></a>01079                 uint8_t *buf;
<a name="l01080"></a>01080 
<a name="l01081"></a>01081                 <span class="keywordflow">if</span> (!single_file)
<a name="l01082"></a>01082                 {
<a name="l01083"></a>01083                     <span class="keywordtype">size_t</span> len = <span class="keyword">sizeof</span>(out_fn)-1;
<a name="l01084"></a>01084 
<a name="l01085"></a>01085                     out_fn[len] = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l01086"></a>01086                     generate_filename(outfile_pattern, out_fn, len-1,
<a name="l01087"></a>01087                                       img-&gt;<a class="code" href="structvpx__image.html#a806bf23143bf00a0b3fdbd6ba030c483">d_w</a>, img-&gt;<a class="code" href="structvpx__image.html#a31bc5f045d4f3c2b6bb0f57bb53078e7">d_h</a>, frame_in);
<a name="l01088"></a>01088                     out = out_open(out_fn, do_md5);
<a name="l01089"></a>01089                 }
<a name="l01090"></a>01090                 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(use_y4m)
<a name="l01091"></a>01091                     out_put(out, (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)<span class="stringliteral">&quot;FRAME\n&quot;</span>, 6, do_md5);
<a name="l01092"></a>01092 
<a name="l01093"></a>01093                 buf = img-&gt;<a class="code" href="structvpx__image.html#ab6258308ba7a5f4a113348120e20e2ce">planes</a>[<a class="code" href="vpx__image_8h.html#a08171c4636c655e1ab0b76e06219f9e2">VPX_PLANE_Y</a>];
<a name="l01094"></a>01094 
<a name="l01095"></a>01095                 <span class="keywordflow">for</span> (y = 0; y &lt; img-&gt;<a class="code" href="structvpx__image.html#a31bc5f045d4f3c2b6bb0f57bb53078e7">d_h</a>; y++)
<a name="l01096"></a>01096                 {
<a name="l01097"></a>01097                     out_put(out, buf, img-&gt;<a class="code" href="structvpx__image.html#a806bf23143bf00a0b3fdbd6ba030c483">d_w</a>, do_md5);
<a name="l01098"></a>01098                     buf += img-&gt;<a class="code" href="structvpx__image.html#ac9c7b83e3eea44cb680956f90dc789cf">stride</a>[<a class="code" href="vpx__image_8h.html#a08171c4636c655e1ab0b76e06219f9e2">VPX_PLANE_Y</a>];
<a name="l01099"></a>01099                 }
<a name="l01100"></a>01100 
<a name="l01101"></a>01101                 buf = img-&gt;<a class="code" href="structvpx__image.html#ab6258308ba7a5f4a113348120e20e2ce">planes</a>[flipuv?<a class="code" href="vpx__image_8h.html#aca9436ec761457cc6d2e356e0ac2fd23">VPX_PLANE_V</a>:<a class="code" href="vpx__image_8h.html#a4770fc8fa60021a2229f25553152cf81">VPX_PLANE_U</a>];
<a name="l01102"></a>01102 
<a name="l01103"></a>01103                 <span class="keywordflow">for</span> (y = 0; y &lt; (1 + img-&gt;<a class="code" href="structvpx__image.html#a31bc5f045d4f3c2b6bb0f57bb53078e7">d_h</a>) / 2; y++)
<a name="l01104"></a>01104                 {
<a name="l01105"></a>01105                     out_put(out, buf, (1 + img-&gt;<a class="code" href="structvpx__image.html#a806bf23143bf00a0b3fdbd6ba030c483">d_w</a>) / 2, do_md5);
<a name="l01106"></a>01106                     buf += img-&gt;<a class="code" href="structvpx__image.html#ac9c7b83e3eea44cb680956f90dc789cf">stride</a>[<a class="code" href="vpx__image_8h.html#a4770fc8fa60021a2229f25553152cf81">VPX_PLANE_U</a>];
<a name="l01107"></a>01107                 }
<a name="l01108"></a>01108 
<a name="l01109"></a>01109                 buf = img-&gt;<a class="code" href="structvpx__image.html#ab6258308ba7a5f4a113348120e20e2ce">planes</a>[flipuv?<a class="code" href="vpx__image_8h.html#a4770fc8fa60021a2229f25553152cf81">VPX_PLANE_U</a>:<a class="code" href="vpx__image_8h.html#aca9436ec761457cc6d2e356e0ac2fd23">VPX_PLANE_V</a>];
<a name="l01110"></a>01110 
<a name="l01111"></a>01111                 <span class="keywordflow">for</span> (y = 0; y &lt; (1 + img-&gt;<a class="code" href="structvpx__image.html#a31bc5f045d4f3c2b6bb0f57bb53078e7">d_h</a>) / 2; y++)
<a name="l01112"></a>01112                 {
<a name="l01113"></a>01113                     out_put(out, buf, (1 + img-&gt;<a class="code" href="structvpx__image.html#a806bf23143bf00a0b3fdbd6ba030c483">d_w</a>) / 2, do_md5);
<a name="l01114"></a>01114                     buf += img-&gt;<a class="code" href="structvpx__image.html#ac9c7b83e3eea44cb680956f90dc789cf">stride</a>[<a class="code" href="vpx__image_8h.html#aca9436ec761457cc6d2e356e0ac2fd23">VPX_PLANE_V</a>];
<a name="l01115"></a>01115                 }
<a name="l01116"></a>01116 
<a name="l01117"></a>01117                 <span class="keywordflow">if</span> (!single_file)
<a name="l01118"></a>01118                     out_close(out, out_fn, do_md5);
<a name="l01119"></a>01119             }
<a name="l01120"></a>01120         }
<a name="l01121"></a>01121 
<a name="l01122"></a>01122         <span class="keywordflow">if</span> (stop_after &amp;&amp; frame_in &gt;= stop_after)
<a name="l01123"></a>01123             <span class="keywordflow">break</span>;
<a name="l01124"></a>01124     }
<a name="l01125"></a>01125 
<a name="l01126"></a>01126     <span class="keywordflow">if</span> (summary || progress)
<a name="l01127"></a>01127     {
<a name="l01128"></a>01128         show_progress(frame_in, frame_out, dx_time);
<a name="l01129"></a>01129         fprintf(stderr, <span class="stringliteral">&quot;\n&quot;</span>);
<a name="l01130"></a>01130     }
<a name="l01131"></a>01131 
<a name="l01132"></a>01132     <span class="keywordflow">if</span> (frames_corrupted)
<a name="l01133"></a>01133         fprintf(stderr, <span class="stringliteral">&quot;WARNING: %d frames corrupted.\n&quot;</span>,frames_corrupted);
<a name="l01134"></a>01134 
<a name="l01135"></a>01135 fail:
<a name="l01136"></a>01136 
<a name="l01137"></a>01137     <span class="keywordflow">if</span> (<a class="code" href="group__codec.html#ga6ae21d96909660d0ac978b59a863f53b" title="Destroy a codec instance.">vpx_codec_destroy</a>(&amp;decoder))
<a name="l01138"></a>01138     {
<a name="l01139"></a>01139         fprintf(stderr, <span class="stringliteral">&quot;Failed to destroy decoder: %s\n&quot;</span>, <a class="code" href="group__codec.html#ga4d265df00d42b36a4f0e3eb83fc22c5e" title="Retrieve error synopsis for codec context.">vpx_codec_error</a>(&amp;decoder));
<a name="l01140"></a>01140         <span class="keywordflow">return</span> EXIT_FAILURE;
<a name="l01141"></a>01141     }
<a name="l01142"></a>01142 
<a name="l01143"></a>01143     <span class="keywordflow">if</span> (single_file &amp;&amp; !noblit)
<a name="l01144"></a>01144         out_close(out, outfile, do_md5);
<a name="l01145"></a>01145 
<a name="l01146"></a>01146     <span class="keywordflow">if</span>(input.nestegg_ctx)
<a name="l01147"></a>01147         nestegg_destroy(input.nestegg_ctx);
<a name="l01148"></a>01148     <span class="keywordflow">if</span>(input.kind != WEBM_FILE)
<a name="l01149"></a>01149         free(buf);
<a name="l01150"></a>01150     fclose(infile);
<a name="l01151"></a>01151     free(argv);
<a name="l01152"></a>01152 
<a name="l01153"></a>01153     <span class="keywordflow">return</span> frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS;
<a name="l01154"></a>01154 }
</pre></div> </div></div>
<hr class="footer"/><address class="footer"><small>Generated on Mon Jan 30 2012 for WebM VP8 Codec SDK by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>