From patchwork Wed Jan 1 22:56:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17119 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B503744AA9A for ; Thu, 2 Jan 2020 00:56:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9B1FF68A04F; Thu, 2 Jan 2020 00:56:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 13B7168A0BE for ; Thu, 2 Jan 2020 00:56:26 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id EB1D9E3545; Wed, 1 Jan 2020 23:56:25 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q4ETPVAfKver; Wed, 1 Jan 2020 23:56:24 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id AF9B6E3509; Wed, 1 Jan 2020 23:56:23 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Jan 2020 23:56:18 +0100 Message-Id: <20200101225619.4103-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 Subject: [FFmpeg-devel] [PATCH 1/2] avdevice/xcbgrab: move some initialization code from pixfmt_from_pixmap_format to create_stream X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavdevice/xcbgrab.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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; }