doc/examples/muxing: mark correct frame as writeable
Bug found from comparing 56f98e340fca894a76d1ddbe33118b8d8c4db34a to HEAD Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
fbd46e2f1c
commit
d1ce43a3e8
@ -266,7 +266,7 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
|
|||||||
* 'nb_channels' channels. */
|
* 'nb_channels' channels. */
|
||||||
static AVFrame *get_audio_frame(OutputStream *ost)
|
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];
|
int16_t *q = (int16_t*)ost->frame->data[0];
|
||||||
|
|
||||||
/* check if we want to generate more frames */
|
/* 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)
|
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
|
||||||
return NULL;
|
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++) {
|
for (j = 0; j < ost->frame->nb_samples; j++) {
|
||||||
v = (int)(sin(ost->t) * 10000);
|
v = (int)(sin(ost->t) * 10000);
|
||||||
for (i = 0; i < ost->st->codec->channels; i++)
|
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);
|
c->sample_rate, c->sample_rate, AV_ROUND_UP);
|
||||||
av_assert0(dst_nb_samples == frame->nb_samples);
|
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 */
|
/* convert to destination format */
|
||||||
ret = swr_convert(ost->swr_ctx,
|
ret = swr_convert(ost->swr_ctx,
|
||||||
ost->tmp_frame->data, dst_nb_samples,
|
ost->tmp_frame->data, dst_nb_samples,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user