From patchwork Mon Feb 17 12:49:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 17820 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 2AFC94441CD for ; Mon, 17 Feb 2020 14:50:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D7A0689E0C; Mon, 17 Feb 2020 14:50:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 594E36880BB for ; Mon, 17 Feb 2020 14:50:03 +0200 (EET) X-ENS-nef-client: 129.199.129.80 Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 01HCo1gQ005644 for ; Mon, 17 Feb 2020 13:50:01 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id 8881EEB5CA; Mon, 17 Feb 2020 13:50:01 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 13:49:59 +0100 Message-Id: <20200217125000.13528-1-george@nsup.org> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Mon, 17 Feb 2020 13:50:01 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 1/2] lavd/opengl_enc: use proper context for logging. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Log as [opengl @ 0xaddress] instead of [opengl outdev @ 0xaddress]. Signed-off-by: Nicolas George --- libavdevice/opengl_enc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index fd0bb177d9..fa94345a7c 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -568,8 +568,9 @@ static void opengl_make_ortho(float matrix[16], float left, float right, matrix[15] = 1.0f; } -static av_cold int opengl_read_limits(OpenGLContext *opengl) +static av_cold int opengl_read_limits(AVFormatContext *h) { + OpenGLContext *opengl = h->priv_data; static const struct{ const char *extension; int major; @@ -588,16 +589,16 @@ static av_cold int opengl_read_limits(OpenGLContext *opengl) version = glGetString(GL_VERSION); extensions = glGetString(GL_EXTENSIONS); - av_log(opengl, AV_LOG_DEBUG, "OpenGL version: %s\n", version); + av_log(h, AV_LOG_DEBUG, "OpenGL version: %s\n", version); sscanf(version, "%d.%d", &major, &minor); for (i = 0; required_extensions[i].extension; i++) { if (major < required_extensions[i].major && (major == required_extensions[i].major && minor < required_extensions[i].minor) && !strstr(extensions, required_extensions[i].extension)) { - av_log(opengl, AV_LOG_ERROR, "Required extension %s is not supported.\n", + av_log(h, AV_LOG_ERROR, "Required extension %s is not supported.\n", required_extensions[i].extension); - av_log(opengl, AV_LOG_DEBUG, "Supported extensions are: %s\n", extensions); + av_log(h, AV_LOG_DEBUG, "Supported extensions are: %s\n", extensions); return AVERROR(ENOSYS); } } @@ -610,10 +611,10 @@ static av_cold int opengl_read_limits(OpenGLContext *opengl) opengl->unpack_subimage = 1; #endif - av_log(opengl, AV_LOG_DEBUG, "Non Power of 2 textures support: %s\n", opengl->non_pow_2_textures ? "Yes" : "No"); - av_log(opengl, AV_LOG_DEBUG, "Unpack Subimage extension support: %s\n", opengl->unpack_subimage ? "Yes" : "No"); - av_log(opengl, AV_LOG_DEBUG, "Max texture size: %dx%d\n", opengl->max_texture_size, opengl->max_texture_size); - av_log(opengl, AV_LOG_DEBUG, "Max viewport size: %dx%d\n", + av_log(h, AV_LOG_DEBUG, "Non Power of 2 textures support: %s\n", opengl->non_pow_2_textures ? "Yes" : "No"); + av_log(h, AV_LOG_DEBUG, "Unpack Subimage extension support: %s\n", opengl->unpack_subimage ? "Yes" : "No"); + av_log(h, AV_LOG_DEBUG, "Max texture size: %dx%d\n", opengl->max_texture_size, opengl->max_texture_size); + av_log(h, AV_LOG_DEBUG, "Max viewport size: %dx%d\n", opengl->max_viewport_width, opengl->max_viewport_height); OPENGL_ERROR_CHECK(opengl); @@ -1074,7 +1075,7 @@ static av_cold int opengl_write_header(AVFormatContext *h) if ((ret = opengl_create_window(h))) goto fail; - if ((ret = opengl_read_limits(opengl)) < 0) + if ((ret = opengl_read_limits(h)) < 0) goto fail; if (opengl->width > opengl->max_texture_size || opengl->height > opengl->max_texture_size) { From patchwork Mon Feb 17 12:50:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 17821 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 EBA604441CD for ; Mon, 17 Feb 2020 14:50:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D882B689D6C; Mon, 17 Feb 2020 14:50:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D1A6689CFF for ; Mon, 17 Feb 2020 14:50:03 +0200 (EET) X-ENS-nef-client: 129.199.129.80 Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 01HCo1kC005648 for ; Mon, 17 Feb 2020 13:50:02 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id C7B42EB5CD; Mon, 17 Feb 2020 13:50:01 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Feb 2020 13:50:00 +0100 Message-Id: <20200217125000.13528-2-george@nsup.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217125000.13528-1-george@nsup.org> References: <20200217125000.13528-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Mon, 17 Feb 2020 13:50:02 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 2/2] lavd/opengl_enc: check strings before parsing them. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fix a segfault if OpenGL was not initialized before calling write_header(). Signed-off-by: Nicolas George --- libavdevice/opengl_enc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index fa94345a7c..3d60f7d068 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -588,6 +588,10 @@ static av_cold int opengl_read_limits(AVFormatContext *h) version = glGetString(GL_VERSION); extensions = glGetString(GL_EXTENSIONS); + if (!version || !extensions) { + av_log(h, AV_LOG_ERROR, "OpenGL not available\n"); + return AVERROR(ENOSYS); + } av_log(h, AV_LOG_DEBUG, "OpenGL version: %s\n", version); sscanf(version, "%d.%d", &major, &minor);