Commit de705e52 authored by Lukasz Marek's avatar Lukasz Marek

lavd/xv: implement repaint message

Signed-off-by: 's avatarLukasz Marek <lukasz.m.luki2@gmail.com>
parent 9fcdfac8
...@@ -251,21 +251,12 @@ static void compute_display_area(AVFormatContext *s) ...@@ -251,21 +251,12 @@ static void compute_display_area(AVFormatContext *s)
} }
} }
static int write_picture(AVFormatContext *s, AVPicture *pict) static int xv_repaint(AVFormatContext *s)
{ {
XVContext *xv = s->priv_data; XVContext *xv = s->priv_data;
XvImage *img = xv->yuv_image;
XWindowAttributes window_attrs; XWindowAttributes window_attrs;
uint8_t *data[3] = {
img->data + img->offsets[0],
img->data + img->offsets[1],
img->data + img->offsets[2]
};
av_image_copy(data, img->pitches, (const uint8_t **)pict->data, pict->linesize,
xv->image_format, img->width, img->height);
XGetWindowAttributes(xv->display, xv->window, &window_attrs); XGetWindowAttributes(xv->display, xv->window, &window_attrs);
if (window_attrs.width != xv->window_width || window_attrs.height != xv->window_height) { if (window_attrs.width != xv->window_width || window_attrs.height != xv->window_height) {
XRectangle rect[2]; XRectangle rect[2];
xv->dest_w = window_attrs.width; xv->dest_w = window_attrs.width;
...@@ -298,6 +289,20 @@ static int write_picture(AVFormatContext *s, AVPicture *pict) ...@@ -298,6 +289,20 @@ static int write_picture(AVFormatContext *s, AVPicture *pict)
return 0; return 0;
} }
static int write_picture(AVFormatContext *s, AVPicture *pict)
{
XVContext *xv = s->priv_data;
XvImage *img = xv->yuv_image;
uint8_t *data[3] = {
img->data + img->offsets[0],
img->data + img->offsets[1],
img->data + img->offsets[2]
};
av_image_copy(data, img->pitches, (const uint8_t **)pict->data, pict->linesize,
xv->image_format, img->width, img->height);
return xv_repaint(s);
}
static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) static int xv_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
AVPicture pict; AVPicture pict;
...@@ -316,6 +321,17 @@ static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame, ...@@ -316,6 +321,17 @@ static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame,
return write_picture(s, (AVPicture *)*frame); return write_picture(s, (AVPicture *)*frame);
} }
static int xv_control_message(AVFormatContext *s, int type, void *data, size_t data_size)
{
switch(type) {
case AV_APP_TO_DEV_WINDOW_REPAINT:
return xv_repaint(s);
default:
break;
}
return AVERROR(ENOSYS);
}
#define OFFSET(x) offsetof(XVContext, x) #define OFFSET(x) offsetof(XVContext, x)
static const AVOption options[] = { static const AVOption options[] = {
{ "display_name", "set display name", OFFSET(display_name), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "display_name", "set display name", OFFSET(display_name), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
...@@ -346,6 +362,7 @@ AVOutputFormat ff_xv_muxer = { ...@@ -346,6 +362,7 @@ AVOutputFormat ff_xv_muxer = {
.write_packet = xv_write_packet, .write_packet = xv_write_packet,
.write_uncoded_frame = xv_write_frame, .write_uncoded_frame = xv_write_frame,
.write_trailer = xv_write_trailer, .write_trailer = xv_write_trailer,
.control_message = xv_control_message,
.flags = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS, .flags = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS,
.priv_class = &xv_class, .priv_class = &xv_class,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment