diff mbox series

[FFmpeg-devel,1/2] avdevice/xcbgrab: move some initialization code from pixfmt_from_pixmap_format to create_stream

Message ID 20200101225619.4103-1-cus@passwd.hu
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avdevice/xcbgrab: move some initialization code from pixfmt_from_pixmap_format to create_stream
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Marton Balint Jan. 1, 2020, 10:56 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavdevice/xcbgrab.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

Comments

Marton Balint Jan. 24, 2020, 12:35 a.m. UTC | #1
On Wed, 1 Jan 2020, Marton Balint wrote:

> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavdevice/xcbgrab.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)

Applied the series.

Regards,
Marton

>
> diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
> index 113cce71a5..06b486a536 100644
> --- a/libavdevice/xcbgrab.c
> +++ b/libavdevice/xcbgrab.c
> @@ -487,7 +487,7 @@ static xcb_screen_t *get_screen(const xcb_setup_t *setup, int screen_num)
> }
> 
> static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth,
> -                                     int *pix_fmt)
> +                                     int *pix_fmt, int *bpp)
> {
>     XCBGrabContext *c        = s->priv_data;
>     const xcb_setup_t *setup = xcb_get_setup(c->conn);
> @@ -525,14 +525,7 @@ static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth,
>         }
>
>         if (*pix_fmt) {
> -            c->bpp        = fmt->bits_per_pixel;
> -            c->frame_size = c->width * c->height * fmt->bits_per_pixel / 8;
> -#if CONFIG_LIBXCB_SHM
> -            c->shm_pool = av_buffer_pool_init2(c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE,
> -                                               c->conn, allocate_shm_buffer, NULL);
> -            if (!c->shm_pool)
> -                return AVERROR(ENOMEM);
> -#endif
> +            *bpp        = fmt->bits_per_pixel;
>             return 0;
>         }
> 
> @@ -592,9 +585,18 @@ static int create_stream(AVFormatContext *s)
>     st->codecpar->width      = c->width;
>     st->codecpar->height     = c->height;
> 
> -    ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format);
> -
> +    ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format, &c->bpp);
>     free(geo);
> +    if (ret < 0)
> +        return ret;
> +
> +    c->frame_size = c->width * c->height * c->bpp / 8;
> +#if CONFIG_LIBXCB_SHM
> +    c->shm_pool = av_buffer_pool_init2(c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE,
> +                                           c->conn, allocate_shm_buffer, NULL);
> +    if (!c->shm_pool)
> +        return AVERROR(ENOMEM);
> +#endif
>
>     return ret;
> }
> -- 
> 2.16.4
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index 113cce71a5..06b486a536 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -487,7 +487,7 @@  static xcb_screen_t *get_screen(const xcb_setup_t *setup, int screen_num)
 }
 
 static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth,
-                                     int *pix_fmt)
+                                     int *pix_fmt, int *bpp)
 {
     XCBGrabContext *c        = s->priv_data;
     const xcb_setup_t *setup = xcb_get_setup(c->conn);
@@ -525,14 +525,7 @@  static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth,
         }
 
         if (*pix_fmt) {
-            c->bpp        = fmt->bits_per_pixel;
-            c->frame_size = c->width * c->height * fmt->bits_per_pixel / 8;
-#if CONFIG_LIBXCB_SHM
-            c->shm_pool = av_buffer_pool_init2(c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE,
-                                               c->conn, allocate_shm_buffer, NULL);
-            if (!c->shm_pool)
-                return AVERROR(ENOMEM);
-#endif
+            *bpp        = fmt->bits_per_pixel;
             return 0;
         }
 
@@ -592,9 +585,18 @@  static int create_stream(AVFormatContext *s)
     st->codecpar->width      = c->width;
     st->codecpar->height     = c->height;
 
-    ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format);
-
+    ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format, &c->bpp);
     free(geo);
+    if (ret < 0)
+        return ret;
+
+    c->frame_size = c->width * c->height * c->bpp / 8;
+#if CONFIG_LIBXCB_SHM
+    c->shm_pool = av_buffer_pool_init2(c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE,
+                                           c->conn, allocate_shm_buffer, NULL);
+    if (!c->shm_pool)
+        return AVERROR(ENOMEM);
+#endif
 
     return ret;
 }