On 12.05.2015 00:28, Michael Niedermayer wrote:
> this breaks demuxing_decoding with pixel formats that use more than
> 1 plane
> 
> for example:
> doc/examples/demuxing_decoding lena255.jpg out.raw /dev/null
>     Could not find audio stream in input file 'lena255.jpg'
>     Input #0, image2, from 'lena255.jpg':
>     Duration: 00:00:00.04, start: 0.000000, bitrate: 3124 kb/s
>         Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 
> 255x255, 25 tbr, 25 tbn, 25 tbc
>     Demuxing video from file 'lena255.jpg' into 'out.raw'
>     video_frame n:0 coded_n:0 pts:NOPTS
>     Demuxing succeeded.
>     Play the output video file with the command:
>     ffplay -f rawvideo -pix_fmt yuvj444p -video_size 255x255 out.raw
> 
> but the printed command line for ffplay does not work as the stored
> image is not containing teh chroma planes

I see. Attached is a patch that should fix the warnings without breaking
anything. (It's not exactly beautiful, but it works.)

Best regards,
Andreas

>From a52993c013dc2d64cd2f099fe472704fd2a75d6d Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Tue, 12 May 2015 14:15:52 +0200
Subject: [PATCH] examples/demuxing_decoding: fully initialize the
 video_dst_data buffer

av_image_fill_pointers always alignes the palette, but the padding bytes
don't (and can't) get initialized in av_image_copy.

Thus initialize them explicitly.

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

Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
---
 doc/examples/demuxing_decoding.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
index feeeb96..4678604 100644
--- a/doc/examples/demuxing_decoding.c
+++ b/doc/examples/demuxing_decoding.c
@@ -71,6 +71,7 @@ static int decode_packet(int *got_frame, int cached)
 {
     int ret = 0;
     int decoded = pkt.size;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
 
     *got_frame = 0;
 
@@ -108,6 +109,14 @@ static int decode_packet(int *got_frame, int cached)
                           (const uint8_t **)(frame->data), frame->linesize,
                           pix_fmt, width, height);
 
+            if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
+                 desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
+                video_dst_data[1] - video_dst_data[0] > video_dst_linesize[0] * height) {
+                /* zero-initialize the padding before the palette */
+                memset(video_dst_data[0] + video_dst_linesize[0] * height, 0,
+                       video_dst_data[1] - video_dst_data[0] - video_dst_linesize[0] * height);
+            }
+
             /* write to rawvideo file */
             fwrite(video_dst_data[0], 1, video_dst_bufsize, video_dst_file);
         }
-- 
2.1.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to