[FFmpeg-devel] trac issue #251 and AVFMT_RAWPICTURE
Michael Niedermayer
michaelni at gmx.at
Mon May 30 21:31:46 CEST 2011
On Mon, May 30, 2011 at 05:14:35PM +0200, Stefano Sabatini wrote:
> On date Monday 2011-05-30 14:45:49 +0200, Michael Niedermayer encoded:
> > On Mon, May 30, 2011 at 01:27:42AM +0200, Stefano Sabatini wrote:
> > > Hi,
> > >
> > > curiously today is the second time I step into the AVFMT_RAWPICTURE
> > > flag.
> > >
> > > yuv4mpeg is currently segfaulting with -vcodec copy, that's because
> > > the code which converts AVFrame -> AVPicture in
> > > ffmpeg.c:do_video_out() is not executed, and the code in
> > > yuv4_write_packet:
> > >
> > > picture = (AVPicture *)pkt->data;
> > > ...
> > > ptr = pkt->data[0];
> > > ...
> > >
> > > ptr = picture->data[0]; => set to NULL
> > > for(i=0;i<height;i++) {
> > > avio_write(pb, ptr, width);
> > > ptr += picture->linesize[0];
> > > }
> > >
> > > fails with a crash.
> > >
> > > AVFMT_RAWPICTURE is currently used only in yuv4mpeg and in nullenc
> > > (where it is not even required), so I wonder if it would make sense to
> > > simply drop the flag (and simplify the API, which is currently
> > > complicated for so small gain).
> >
> > i dont know
> > if AVFMT_RAWPICTURE could be used more widespread and would allow
> > avoiding a memcpy() it might be better tio keep it otherwise i guess
> > we should drop it
>
> Check if the attached patch looks fine to you (and yes
> AVFMT_RAWPICTURE may be useful in other places, e.g. in the SDL output
> device, so...).
> --
> FFmpeg = Fast & Faithful Multimedia Portable Explosive Governor
> ffmpeg.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
> c284a8ea329db8f2359d8dd9c557a8a2ae8fc0ae 0001-ffmpeg-handle-copy-of-packets-for-AVFMT_RAWPICTURE-o.patch
> From ffc80e1305a8d27fd7c8f043be47397612b9f962 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Mon, 30 May 2011 16:52:35 +0200
> Subject: [PATCH] ffmpeg: handle copy of packets for AVFMT_RAWPICTURE output formats
>
> Implement the required AVPicture -> AVPacket conversion required by
> AVFMT_RAWPICTURE formats.
>
> Fix trac issue #251.
> ---
> ffmpeg.c | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 220feb2..4980620 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -1784,6 +1784,14 @@ static int output_packet(AVInputStream *ist, int ist_index,
> opkt.size = data_size;
> }
>
> + if (os->oformat->flags & AVFMT_RAWPICTURE) {
> + /* convert rawvideo picture to packet, as expected by the output format */
> + AVPicture pict;
> + avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);
> + opkt.data = (uint8_t *)&pict;
> + opkt.size = sizeof(AVPicture);
> + opkt.flags |= AV_PKT_FLAG_KEY;
> + }
> write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);
This looks like you pass a pointer to a stack variable after its
block in which it lives.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110530/f123cc14/attachment.asc>
More information about the ffmpeg-devel
mailing list