<div dir="ltr">Hi,<div><br><div>I am using <a href="https://git.ffmpeg.org/gitweb/ffmpeg.git/blob_plain/HEAD:/doc/examples/decode_audio.c">https://git.ffmpeg.org/gitweb/ffmpeg.git/blob_plain/HEAD:/doc/examples/decode_audio.c</a> as a base for my audio decoder.</div><div>Audio decoding sounds ok however looks like ffmpeg outputs decoded PCM audio based on codec type. Below are my observations for the sample_fmt.</div><div><br></div><div>mpeg1/mpeg2 audio : s16p<br>aac,aac_latm,ac3,eac3 : fltp<br></div><div><br></div><div>I want to normalize my decoded PCM output to always "
fltp
". I came across about AVCodecContext::request_sample_fmt however this setting is not working.</div><div>I am trying below code for mpeg1/mpeg2 audio.</div><div><div style="color:rgb(0,0,0);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div> <span style="color:rgb(0,16,128)">DecCtx</span> = <span style="color:rgb(121,94,38)">avcodec_alloc_context3</span>(<span style="color:rgb(0,16,128)">Codec</span>);</div><div> <span style="color:rgb(175,0,219)">if</span> (!<span style="color:rgb(0,16,128)">DecCtx</span>)</div><div> {</div><div> <span style="color:rgb(175,0,219)">return</span> <span style="color:rgb(0,0,255)">false</span>;<br></div><div> }</div><div> </div><div> <span style="color:rgb(0,16,128)">DecCtx</span>-><span style="color:rgb(0,16,128)">request_sample_fmt</span> = AV_SAMPLE_FMT_FLTP;</div><div><br></div><div> <span style="color:rgb(175,0,219)">if</span> (<span style="color:rgb(121,94,38)">avcodec_open2</span>(<span style="color:rgb(0,16,128)">DecCtx</span>, <span style="color:rgb(0,16,128)">Codec</span>, <span style="color:rgb(0,0,255)">NULL</span>) < <span style="color:rgb(9,134,88)">0</span>)</div><div> {</div><div> <span style="color:rgb(175,0,219)">return</span> <span style="color:rgb(0,0,255)">false</span>;<br></div><div> }</div></div></div><div style="color:rgb(0,0,0);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div> <span style="color:rgb(0,0,255)">const</span> <span style="color:rgb(0,0,255)">char</span> *<span style="color:rgb(0,16,128)">sample_fmt</span> = <span style="color:rgb(121,94,38)">av_get_sample_fmt_name</span>(<span style="color:rgb(0,16,128)">m_pDecCtx</span>-><span style="color:rgb(0,16,128)">sample_fmt</span>);</div><div> <span style="color:rgb(121,94,38)">printf</span>(<span style="color:rgb(163,21,21)">"[CffmpegAudioDecoder-Open: AVSampleFormat=%s]</span><span style="color:rgb(238,0,0)">\n</span><span style="color:rgb(163,21,21)">"</span>,<span style="color:rgb(0,16,128)">sample_fmt</span>); -->always fetting s16p</div><div><br></div><div>I am wondering what am I missing?</div><div>Please help! Thanks in advance.</div><div><br></div><div>Regards,</div><div>Rohit Khali</div></div><div></div></div></div>