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

Michael Niedermayer michaelni at gmx.at
Tue May 12 14:51:55 CEST 2015


On Tue, May 12, 2015 at 02:31:38PM +0200, Andreas Cadhalpun wrote:
> 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
> 

>  demuxing_decoding.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
> ee1725417c3d550a65ba846e9195ded4ebdf4a3d  0001-examples-demuxing_decoding-fully-initialize-the-vide.patch
> From a52993c013dc2d64cd2f099fe472704fd2a75d6d Mon Sep 17 00:00:00 2001
> From: Andreas Cadhalpun <Andreas.Cadhalpun at 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.Cadhalpun at 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);
> +            }

i wonder if this shouldnt be moved to av_image_alloc() ?

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150512/e2d19e51/attachment.asc>


More information about the ffmpeg-devel mailing list