[FFmpeg-devel] [PATCH] libavfilter-soc: make ffplay.c:request_input_frame() check for got_frame
Michael Niedermayer
michaelni
Sun Jan 11 18:20:21 CET 2009
On Sun, Jan 11, 2009 at 05:29:19PM +0100, Stefano Sabatini wrote:
> On date Sunday 2009-01-11 15:20:29 +0100, Michael Niedermayer encoded:
> > On Sun, Jan 11, 2009 at 01:38:12PM +0100, Stefano Sabatini wrote:
> [...]
> > > I was committing the change where I saw there was a (maybe) simpler
> > > solution.
> > > No need to change the get_video_frame() signature, after all it should
> > > a duty of the get_video_frame() function to ensure that it is indeed
> > > getting a frame, this change should be functionally equivalent to the
> > > other patch.
> > >
> > > Regards.
> > > --
> > > FFmpeg = Foolish and Fostering Minimal Portable Extreme Game
> >
> > > Index: libavfilter-soc/ffmpeg/ffplay.c
> > > ===================================================================
> > > --- libavfilter-soc.orig/ffmpeg/ffplay.c 2009-01-11 12:27:12.000000000 +0100
> > > +++ libavfilter-soc/ffmpeg/ffplay.c 2009-01-11 12:27:38.000000000 +0100
> > > @@ -1407,8 +1407,9 @@
> > >
> > > static int get_video_frame(VideoState *is, AVFrame *frame, uint64_t *pts, AVPacket *pkt)
> > > {
> > > - int len1, got_picture;
> > > + int len1, got_picture = 0;
> > >
> > > + while (!got_picture) {
> > > if (packet_queue_get(&is->videoq, pkt, 1) < 0)
> > > return -1;
> > >
> > > @@ -1423,6 +1424,7 @@
> > > len1 = avcodec_decode_video(is->video_st->codec,
> > > frame, &got_picture,
> > > pkt->data, pkt->size);
> > > + }
> >
> > are you ever freeing the packets?
>
> Good catch.
>
> First patch changes the signature of get_video_frame, second one
> introduces a loop in input_request_frame so that is checked that
> get_video_frame effectively got a frame, otherwise try to extract
> another frame, packets are always freed.
[...]
> Index: libavfilter-soc/ffmpeg/ffplay.c
> ===================================================================
> --- libavfilter-soc.orig/ffmpeg/ffplay.c 2009-01-11 17:16:17.000000000 +0100
> +++ libavfilter-soc/ffmpeg/ffplay.c 2009-01-11 17:19:53.000000000 +0100
> @@ -1473,15 +1473,16 @@
> AVPacket pkt;
> int got_picture = 0;
>
> + do {
> if(get_video_frame(priv->is, priv->frame, &pts, &pkt, &got_picture) < 0)
> return -1;
>
> + if (got_picture) {
> /* FIXME: until I figure out how to hook everything up to the codec
> * right, we're just copying the entire frame. */
> picref = avfilter_get_video_buffer(link, AV_PERM_WRITE);
> av_picture_copy((AVPicture *)&picref->data, (AVPicture *)priv->frame,
> picref->pic->format, picref->w, picref->h);
> - av_free_packet(&pkt);
>
> picref->pts = pts;
> picref->pixel_aspect = priv->is->video_st->codec->sample_aspect_ratio;
> @@ -1489,6 +1490,10 @@
> avfilter_draw_slice(link, 0, picref->h);
> avfilter_end_frame(link);
> avfilter_unref_pic(picref);
> + }
> +
> + av_free_packet(&pkt);
> + } while(!got_picture);
>
> return 0;
> }
while(!(ret= get_video_frame(priv->is, priv->frame, &pts, &pkt)))
av_free_packet(&pkt);
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090111/96374a65/attachment.pgp>
More information about the ffmpeg-devel
mailing list