On Sun, Feb 23, 2014 at 10:59 AM, Reinhard Tartler <[email protected]>wrote:

> On Sun, Feb 23, 2014 at 10:29 AM, Anton Khirnov <[email protected]> wrote:
>
> [snipped for brevity]

> >
> > This can be replaced by
> > if (ret >= 0 && got_packet) {
> >     fwrite(pkt.data, 1, pkt.size, encode->output_file);
> >     av_free_packet(&pkt);
> > }
> > return (ret >= 0) ? TRUE : FALSE;
> >
> > With those changes, the new code is about the same length as the old,
> possibly
> > even shorter.
>
> Please double check if I got your suggestions right:
>
>
> gboolean mpeg_encode_frame(gpointer data, GdkPixbuf * pixbuf) {
>   encode_t * encode = data;
>   gint out_size;
>   AVPacket pkt = { 0 };
>   int ret, got_packet = 0;
>
>   convert_rgb_pixbuf_to_yuv(encode->yuv, pixbuf);
>
>   /* encode the image */
>   ret = avcodec_encode_video2(encode->context, &pkt, encode->picture,
> &got_packet);
>
>   if (ret >= 0 && got_packet) {
>       fwrite(pkt.data, 1, pkt.size, encode->output_file);
>

Please don't ignore the return result from fwrite().


>       av_free_packet(&pkt);
>   }
>   return (ret >= 0) ? TRUE : FALSE;
> };
>
>
-- Sean McG.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to