Remove a memory allocation and the associated memcpy.
authorSven C. Dack <sven.c.dack@virginmedia.com>
Wed, 30 Mar 2011 15:02:29 +0000 (17:02 +0200)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Wed, 30 Mar 2011 15:02:29 +0000 (17:02 +0200)
libavdevice/x11grab.c

index be0586a..6a674ee 100644 (file)
@@ -386,10 +386,9 @@ x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
         nanosleep(&ts, NULL);
     }
 
-    if (av_new_packet(pkt, s->frame_size) < 0) {
-        return AVERROR(EIO);
-    }
-
+    av_init_packet(pkt);
+    pkt->data = image->data;
+    pkt->size = s->frame_size;
     pkt->pts = curtime;
 
     if(s->use_shm) {
@@ -406,9 +405,6 @@ x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
         paint_mouse_pointer(image, s);
     }
 
-
-    /* XXX: avoid memcpy */
-    memcpy(pkt->data, image->data, s->frame_size);
     return s->frame_size;
 }