mirror of https://git.ffmpeg.org/ffmpeg.git
lavd/xv: simplify write_packet
Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com> Signed-off-by: Stefano Sabatini <stefasab@gmail.com>
This commit is contained in:
parent
9244a68092
commit
5d8619595b
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/pixdesc.h"
|
#include "libavutil/pixdesc.h"
|
||||||
|
#include "libavutil/imgutils.h"
|
||||||
#include "avdevice.h"
|
#include "avdevice.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -148,22 +149,15 @@ static int xv_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
XWindowAttributes window_attrs;
|
XWindowAttributes window_attrs;
|
||||||
AVPicture pict;
|
AVPicture pict;
|
||||||
AVCodecContext *ctx = s->streams[0]->codec;
|
AVCodecContext *ctx = s->streams[0]->codec;
|
||||||
int y, h;
|
uint8_t *data[3] = {
|
||||||
|
img->data + img->offsets[0],
|
||||||
h = img->height / 2;
|
img->data + img->offsets[1],
|
||||||
|
img->data + img->offsets[2]
|
||||||
|
};
|
||||||
|
|
||||||
avpicture_fill(&pict, pkt->data, ctx->pix_fmt, ctx->width, ctx->height);
|
avpicture_fill(&pict, pkt->data, ctx->pix_fmt, ctx->width, ctx->height);
|
||||||
for (y = 0; y < img->height; y++) {
|
av_image_copy(data, img->pitches, (const uint8_t **)pict.data, pict.linesize,
|
||||||
memcpy(&img->data[img->offsets[0] + (y * img->pitches[0])],
|
AV_PIX_FMT_YUV420P, img->width, img->height);
|
||||||
&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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
XGetWindowAttributes(xv->display, xv->window, &window_attrs);
|
XGetWindowAttributes(xv->display, xv->window, &window_attrs);
|
||||||
if (XvShmPutImage(xv->display, xv->xv_port, xv->window, xv->gc,
|
if (XvShmPutImage(xv->display, xv->xv_port, xv->window, xv->gc,
|
||||||
|
|
Loading…
Reference in New Issue