[FFmpeg-cvslog] lavd/xv: simplify write_packet
Lukasz Marek
git at videolan.org
Fri Nov 15 10:00:24 CET 2013
ffmpeg | branch: master | Lukasz Marek <lukasz.m.luki at gmail.com> | Thu Nov 14 21:17:00 2013 +0100| [5d8619595b84e1edf7add6e8e348e7c5767d3d3f] | committer: Stefano Sabatini
lavd/xv: simplify write_packet
Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
Signed-off-by: Stefano Sabatini <stefasab at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5d8619595b84e1edf7add6e8e348e7c5767d3d3f
---
libavdevice/xv.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/libavdevice/xv.c b/libavdevice/xv.c
index 50d72a5..23c8761 100644
--- a/libavdevice/xv.c
+++ b/libavdevice/xv.c
@@ -35,6 +35,7 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/imgutils.h"
#include "avdevice.h"
typedef struct {
@@ -148,22 +149,15 @@ static int xv_write_packet(AVFormatContext *s, AVPacket *pkt)
XWindowAttributes window_attrs;
AVPicture pict;
AVCodecContext *ctx = s->streams[0]->codec;
- int y, h;
-
- h = img->height / 2;
+ uint8_t *data[3] = {
+ img->data + img->offsets[0],
+ img->data + img->offsets[1],
+ img->data + img->offsets[2]
+ };
avpicture_fill(&pict, pkt->data, ctx->pix_fmt, ctx->width, ctx->height);
- for (y = 0; y < img->height; y++) {
- memcpy(&img->data[img->offsets[0] + (y * img->pitches[0])],
- &pict.data[0][y * pict.linesize[0]], img->pitches[0]);
- }
-
- for (y = 0; y < h; ++y) {
- memcpy(&img->data[img->offsets[1] + (y * img->pitches[1])],
- &pict.data[1][y * pict.linesize[1]], img->pitches[1]);
- memcpy(&img->data[img->offsets[2] + (y * img->pitches[2])],
- &pict.data[2][y * pict.linesize[2]], img->pitches[2]);
- }
+ av_image_copy(data, img->pitches, (const uint8_t **)pict.data, pict.linesize,
+ AV_PIX_FMT_YUV420P, img->width, img->height);
XGetWindowAttributes(xv->display, xv->window, &window_attrs);
if (XvShmPutImage(xv->display, xv->xv_port, xv->window, xv->gc,
More information about the ffmpeg-cvslog
mailing list