1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

doc/examples/muxing: mark correct frame as writeable

Bug found from comparing 56f98e340f to HEAD
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-07-27 01:35:10 +02:00
parent fbd46e2f1c
commit d1ce43a3e8

View File

@ -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,