mirror of https://git.ffmpeg.org/ffmpeg.git
doc/examples/muxing: Fix av_frame_make_writable usage
This patch moves the av_frame_make_writable() call from fill_yuv_image to get_video_frame so that its argument can be the actual frame that will be sent to the encoder. This fixes data corruption issues in codecs that keep references on one or several previous frames. Signed-off-by: Sam Hocevar <sam@hocevar.net> Reviewed-by: wm4 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
69f7dd3524
commit
3115550abe
|
@ -440,15 +440,7 @@ static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
|
|||
static void fill_yuv_image(AVFrame *pict, int frame_index,
|
||||
int width, int height)
|
||||
{
|
||||
int x, y, i, ret;
|
||||
|
||||
/* 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(pict);
|
||||
if (ret < 0)
|
||||
exit(1);
|
||||
int x, y, i;
|
||||
|
||||
i = frame_index;
|
||||
|
||||
|
@ -475,6 +467,11 @@ static AVFrame *get_video_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 */
|
||||
if (av_frame_make_writable(ost->frame) < 0)
|
||||
exit(1);
|
||||
|
||||
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
||||
/* as we only generate a YUV420P picture, we must convert it
|
||||
* to the codec pixel format if needed */
|
||||
|
|
Loading…
Reference in New Issue