<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Regarding the API example <a href="http://ffmpeg.org/doxygen/trunk/transcode_aac_8c-example.html">http://ffmpeg.org/doxygen/trunk/transcode_aac_8c-example.html</a><div><br></div><div>this part of the code gave syntax error with c++</div><div><br></div><div><br></div><div><div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;"><span class="comment" style="color: rgb(128, 0, 0);">/**</span></div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;"><span class="comment" style="color: rgb(128, 0, 0);">     * Allocate as many pointers as there are audio channels.</span></div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;"><span class="comment" style="color: rgb(128, 0, 0);">     * Each pointer will later point to the audio samples of the corresponding</span></div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;"><span class="comment" style="color: rgb(128, 0, 0);">     * channels (although it may be NULL for interleaved formats).</span></div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;"><span class="comment" style="color: rgb(128, 0, 0);">     */</span></div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;"><span class="keywordflow" style="color: rgb(224, 128, 0);">if</span> (!(*converted_input_samples = calloc(output_codec_context-><a class="code" href="http://ffmpeg.org/doxygen/trunk/structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels" style="color: rgb(70, 101, 162); text-decoration: none;">channels</a>,</div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;">                                            <span class="keyword" style="color: rgb(0, 128, 0);">sizeof</span>(**converted_input_samples)))) {</div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;"> fprintf(stderr, <span class="stringliteral" style="color: rgb(0, 32, 128);">"Could not allocate converted input sample pointers\n"</span>);</div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;"> <span class="keywordflow" style="color: rgb(224, 128, 0);">return</span> <a class="code" href="http://ffmpeg.org/doxygen/trunk/group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca" style="color: rgb(70, 101, 162); text-decoration: none;">AVERROR</a>(ENOMEM);</div><div class="line" style="text-indent: -53px; font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; -webkit-transition-property: background-color, box-shadow; transition-duration: 0.5s; -webkit-transition-duration: 0.5s;">}</div></div></div><div><br></div><div><br></div><div>I had to change it to :</div><div><br></div><div>
<pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>(!(**converted_input_samples<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>(<span style=" color:#800080;">u_int8_t</span><span style=" color:#c0c0c0;"> </span>*)calloc(output_codec_context-><span style=" color:#800000;">channels</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">sizeof</span>(<span style=" color:#000080;">uint8_t</span>))))<!--EndFragment--></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;">but anyway, the call to the function <span style="font-family: Calibri, sans-serif; font-size: 12pt;">init_converted_samples</span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="font-family: Calibri, sans-serif; font-size: 12pt;">send </span><span style="font-family: monospace, fixed; font-size: 13px; line-height: 13px; white-space: pre-wrap;">converted_input_samples as NULL</span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><font face="monospace, fixed" size="4"><span style="line-height: 13px; white-space: pre-wrap;">so it make a segmentation fault.</span></font></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><font face="monospace, fixed" size="4"><span style="line-height: 13px; white-space: pre-wrap;"><br></span></font></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><font face="monospace, fixed" size="4"><span style="line-height: 13px; white-space: pre-wrap;">How should I fix that segmentation fault?</span></font></pre>
</div>                                      </div></body>
</html>