Commit d1ce43a3 authored by Michael Niedermayer's avatar Michael Niedermayer

doc/examples/muxing: mark correct frame as writeable

Bug found from comparing 56f98e34 to HEAD
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent fbd46e2f
......@@ -266,7 +266,7 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
* 'nb_channels' channels. */
static AVFrame *get_audio_frame(OutputStream *ost)
{
int j, i, v, ret;
int j, i, v;
int16_t *q = (int16_t*)ost->frame->data[0];
/* check if we want to generate more frames */
......@@ -274,14 +274,6 @@ static AVFrame *get_audio_frame(OutputStream *ost)
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
return NULL;
/* when we pass a frame to the encoder, it may keep a reference to it
* internally;
* make sure we do not overwrite it here
*/
ret = av_frame_make_writable(ost->frame);
if (ret < 0)
exit(1);
for (j = 0; j < ost->frame->nb_samples; j++) {
v = (int)(sin(ost->t) * 10000);
for (i = 0; i < ost->st->codec->channels; i++)
......@@ -321,6 +313,14 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
c->sample_rate, c->sample_rate, AV_ROUND_UP);
av_assert0(dst_nb_samples == frame->nb_samples);
/* when we pass a frame to the encoder, it may keep a reference to it
* internally;
* make sure we do not overwrite it here
*/
ret = av_frame_make_writable(ost->tmp_frame);
if (ret < 0)
exit(1);
/* convert to destination format */
ret = swr_convert(ost->swr_ctx,
ost->tmp_frame->data, dst_nb_samples,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment