<div dir="ltr">Dear all,<div><br></div><div>I read this description in avformat.h </div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">/**</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">Wrap</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">an</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">existing</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">array</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">as</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">stream</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">side</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">data.</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,255)">@param</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">st</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">stream</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,255)">@param</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">type</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">side</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">information</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">type</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,255)">@param</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">data</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">side</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">data</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">array.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">It</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">must</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">be</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">allocated</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">with</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">av_malloc()</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">family</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">of</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">functions.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">The</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">ownership</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">of</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">data</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">is</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">transferred</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">to</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">st.</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,255)">@param</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">size</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">side</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">information</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">size</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,255)">@return</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">zero</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">on</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">success,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">a</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">negative</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">AVERROR</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">code</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">on</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">failure.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">On</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">failure,</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">stream</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">is</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">unchanged</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">and</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">data</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">remains</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">owned</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">by</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">caller.</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*/</span></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">av_stream_add_side_data</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,0,128)">AVStream</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span>st<span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">enum</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">AVPacketSideDataType</span><span style="color:rgb(192,192,192)"> </span>type<span style="color:rgb(0,0,0)">,</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">uint8_t</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span>data<span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">size_t</span><span style="color:rgb(192,192,192)"> </span>size<span style="color:rgb(0,0,0)">);</span></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">I have two AVStream variables, say in_stream and out_stream.</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">I want to copy in_stream side data to out_stream. As suggested in</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">the comments, out_stream->side_data should be allocated with av_malloc() family of functions. </span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">I want to know how should I allocate <b>out_stream->side_data->data</b> ? </span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">When I try </span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">out_stream->side_data->data = (uint8_t*) av_mallocz(in_stream->side_data->size*sizeof(uint8_t*)); </span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">it leads to an unexpected error. Can anyone suggest how should I allocate this?</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">Regards,</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">Davood Falahati</span></pre></pre>
</div></div>