[FFmpeg-devel] [PATCH] examples/demuxing_decoding: use correct size of video_dst_data[0]

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Mon May 11 23:34:32 CEST 2015


Currently video_dst_bufsize is used, which is set to the return value
of av_image_alloc, but this is the combined size of all planes.
Only the first plane is written in fwrite.

The size of the first plane is the product of video_dst_linesize[0] and
height.

This fixes 'Syscall param write(buf) points to uninitialised byte(s)'
valgrind warnings.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 doc/examples/demuxing_decoding.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
index feeeb96..81c8a92 100644
--- a/doc/examples/demuxing_decoding.c
+++ b/doc/examples/demuxing_decoding.c
@@ -47,7 +47,6 @@ static FILE *audio_dst_file = NULL;
 
 static uint8_t *video_dst_data[4] = {NULL};
 static int      video_dst_linesize[4];
-static int video_dst_bufsize;
 
 static int video_stream_idx = -1, audio_stream_idx = -1;
 static AVFrame *frame = NULL;
@@ -109,7 +108,7 @@ static int decode_packet(int *got_frame, int cached)
                           pix_fmt, width, height);
 
             /* write to rawvideo file */
-            fwrite(video_dst_data[0], 1, video_dst_bufsize, video_dst_file);
+            fwrite(video_dst_data[0], 1, video_dst_linesize[0] * height, video_dst_file);
         }
     } else if (pkt.stream_index == audio_stream_idx) {
         /* decode audio frame */
@@ -290,7 +289,6 @@ int main (int argc, char **argv)
             fprintf(stderr, "Could not allocate raw video buffer\n");
             goto end;
         }
-        video_dst_bufsize = ret;
     }
 
     if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
-- 
2.1.4



More information about the ffmpeg-devel mailing list