diff options
author | Nicolas George <george@nsup.org> | 2014-01-01 12:05:48 +0100 |
---|---|---|
committer | Nicolas George <george@nsup.org> | 2014-02-11 10:29:02 +0100 |
commit | d201a0f0f843fc108f5506d82937bb1b4cafb345 (patch) | |
tree | 7551c0e7231cb30d283097fc1cbff95795252b55 /libavdevice | |
parent | 62106fcc23cf52f8e44be572b58c3bb50f598763 (diff) | |
download | ffmpeg-d201a0f0f843fc108f5506d82937bb1b4cafb345.tar.gz |
lavd/xv: preliminary support of uncoded frame.
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/xv.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/libavdevice/xv.c b/libavdevice/xv.c index a4b44c8eda..89d6575f6c 100644 --- a/libavdevice/xv.c +++ b/libavdevice/xv.c @@ -36,6 +36,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" +#include "libavformat/internal.h" #include "avdevice.h" typedef struct { @@ -197,23 +198,19 @@ static int xv_write_header(AVFormatContext *s) return ret; } -static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) +static int write_picture(AVFormatContext *s, AVPicture *pict) { XVContext *xv = s->priv_data; XvImage *img = xv->yuv_image; XWindowAttributes window_attrs; - AVPicture pict; - AVCodecContext *ctx = s->streams[0]->codec; 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); - av_image_copy(data, img->pitches, (const uint8_t **)pict.data, pict.linesize, + 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); if (XvShmPutImage(xv->display, xv->xv_port, xv->window, xv->gc, xv->yuv_image, 0, 0, xv->image_width, xv->image_height, 0, 0, @@ -224,6 +221,24 @@ static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) return 0; } +static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) +{ + AVPicture pict; + AVCodecContext *ctx = s->streams[0]->codec; + + avpicture_fill(&pict, pkt->data, ctx->pix_fmt, ctx->width, ctx->height); + return write_picture(s, &pict); +} + +static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame, + unsigned flags) +{ + /* xv_write_header() should have accepted only supported formats */ + if ((flags & AV_WRITE_UNCODED_FRAME_QUERY)) + return 0; + return write_picture(s, (AVPicture *)*frame); +} + #define OFFSET(x) offsetof(XVContext, x) 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 }, @@ -250,6 +265,7 @@ AVOutputFormat ff_xv_muxer = { .video_codec = AV_CODEC_ID_RAWVIDEO, .write_header = xv_write_header, .write_packet = xv_write_packet, + .write_uncoded_frame = xv_write_frame, .write_trailer = xv_write_trailer, .flags = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS, .priv_class = &xv_class, |