[FFmpeg-devel] [PATCH]Support pal8 in x11grab

Michael Niedermayer michaelni at gmx.at
Wed Oct 23 15:38:44 CEST 2013


On Wed, Oct 23, 2013 at 10:48:13AM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #3068.
> 
> Please comment, Carl Eugen

>  x11grab.c |   28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 6afc4d7ae0b35866429db09be810834a9a9b3ef4  patchx11pal8.diff
> diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
> index eb23ec3..7fbf057 100644
> --- a/libavdevice/x11grab.c
> +++ b/libavdevice/x11grab.c
> @@ -77,6 +77,8 @@ struct x11grab {
>      int  follow_mouse;       /**< Set by a private option. */
>      int  show_region;        /**< set by a private option. */
>      AVRational framerate;         /**< Set by a private option. */
> +    int palette_changed;
> +    uint32_t palette[256];
>  
>      Cursor c;
>      Window region_win;       /**< This is used by show_region option. */
> @@ -167,6 +169,9 @@ x11grab_read_header(AVFormatContext *s1)
>      int use_shm;
>      char *dpyname, *offset;
>      int ret = 0;
> +    Colormap color_map;
> +    XColor *color;
> +    int i;
>  
>      dpyname = av_strdup(s1->filename);
>      if (!dpyname)
> @@ -258,6 +263,19 @@ x11grab_read_header(AVFormatContext *s1)
>      case 8:
>          av_log (s1, AV_LOG_DEBUG, "8 bit palette\n");
>          input_pixfmt = AV_PIX_FMT_PAL8;
> +        color = av_malloc(256 * sizeof(XColor));
> +        if (!color)
> +            return AVERROR(ENOMEM);
> +        color_map = DefaultColormap(dpy, screen);
> +        for (i = 0; i < 256; ++i)
> +            color[i].pixel = i;
> +        XQueryColors(dpy, color_map, color, 256);
> +        for (i = 0; i < 256; ++i)
> +            x11grab->palette[i] = (color[i].red   & 0xFF00) << 8 |
> +                                  (color[i].green & 0xFF00)      |
> +                                  (color[i].blue  & 0xFF00) >> 8;
> +        x11grab->palette_changed = 1;
> +        av_freep(&color);

XColor color[256]
would avoid the malloc, cheking and free

otherwise should be ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131023/a7e34d6b/attachment.asc>


More information about the ffmpeg-devel mailing list