From patchwork Wed Dec 13 13:12:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 45106 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp4264163pzf; Wed, 13 Dec 2023 05:17:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeLxPChPS1P4Sqi+TPJn7uqwSQF4UPud1sPr7m2VCTT/MGXZ3BwrZASWeSJiyBpX8/r+zP X-Received: by 2002:a19:675e:0:b0:50b:ed57:758c with SMTP id e30-20020a19675e000000b0050bed57758cmr6513763lfj.1.1702473435716; Wed, 13 Dec 2023 05:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702473435; cv=none; d=google.com; s=arc-20160816; b=DQdNT2k0FqHqHlm6adlWdaedBbcpq4VNpJXouOeXA2fxxxPbiT8aa90ljbPgij6ifz 5I3LWwZOZLW3f9FY3ZGdN21iy6CrsM5JzvoNRWTkGwUDLYKENLH/PlBRxKuEOYeWU394 kXDIo5SO9d1fxD0RVfwfKS0Q0BBNJvFTZ7sXoItHIcFNMMJOksQICq7oYA52pZROBb7w yCPeGj1seyQd8XkqfxNrSfVH2yckqH5hFmw2kZSGwny7BpK7D69hP2aWxKvX2tKjLjnN C4O/3ZICa8mUxbc7gsNvB0EER/3aKYg3v+1BVt//mkSdSzNBHmANg5dr4NgpsRA4Ic4o R4JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=nn8eco7JVXOa/OIAJPk24CaguhGqezab96+c9boMtN0=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=hMiFUfzUlLBFRwtwCk216ttfIaGleGL1pb2jsl4cxLxRu7FFoZU36YOFT8BdscpXt9 d9Jxr3FXfAk+fJA/ozA6ewwcrHAt73ECBFNpZHohZda1nfuEqsv0jKR/3k0tAA4By0NW B6e27OE0OSkxl49GT0itm6Qe8wAbTOq88E42yNgoxSSKs6QN2i89SHVcC3xW1BNF37ap mpFeq4MzJCe7JxR1PkAjjvZPl5NDIJe7l1WDTf4E3t7CSCmjt+AiulXQfcBUmBpgOwP3 bxOvvHax02mVieMgqb21n7dnv/EmWp8izLdhSRElDCkfn4Jfapotyb/3/1Kh9KNohtsS lytA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="Ky/iVNXz"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z38-20020a509e29000000b0055238966e45si70677ede.135.2023.12.13.05.17.15; Wed, 13 Dec 2023 05:17:15 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="Ky/iVNXz"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E904168D237; Wed, 13 Dec 2023 15:15:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 156CF68D1DE for ; Wed, 13 Dec 2023 15:15:44 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 7CA774BCFF; Wed, 13 Dec 2023 14:15:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1702473340; bh=aCvvFZQzFXRVQGem8J5EQXj+lefEwzd6Dd9dVBlTixU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ky/iVNXz6po8VAkNl2HC6hvfDuF/7Ivsed5MG8adByz2dUXFTJlag5FvcIPvQyzBT LkNzEo/aev3qD7HRwebo6Rb+lnRd/vkvRZERqrH9DDLBINU341i6vKk9nZ9GjeF/wS mOXZzUsRHCLl7SDR9rIgvv+owmA1sW+gr6jcThGA= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Dec 2023 14:12:03 +0100 Message-ID: <20231213131536.10242-7-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213131536.10242-1-ffmpeg@haasn.xyz> References: <20231213131536.10242-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 06/15] fftools/ffmpeg_filter: configure buffersrc with csp/range X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ORqs/UrDuJ8g From: Niklas Haas Propagates input metadata to the input filter graph. --- fftools/ffmpeg_filter.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index e5b00123f2..2da6d307a0 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -126,6 +126,8 @@ typedef struct InputFilterPriv { int width, height; AVRational sample_aspect_ratio; + enum AVColorSpace color_space; + enum AVColorRange color_range; int sample_rate; AVChannelLayout ch_layout; @@ -146,6 +148,8 @@ typedef struct InputFilterPriv { int width; int height; AVRational sample_aspect_ratio; + enum AVColorSpace color_space; + enum AVColorRange color_range; int sample_rate; AVChannelLayout ch_layout; @@ -257,6 +261,8 @@ static int sub2video_get_blank_frame(InputFilterPriv *ifp) frame->width = ifp->width; frame->height = ifp->height; frame->format = ifp->format; + frame->colorspace = ifp->color_space; + frame->color_range = ifp->color_range; ret = av_frame_get_buffer(frame, 0); if (ret < 0) @@ -833,6 +839,8 @@ static InputFilter *ifilter_alloc(FilterGraph *fg) ifp->index = fg->nb_inputs - 1; ifp->format = -1; ifp->fallback.format = -1; + ifp->color_space = ifp->fallback.color_space = AVCOL_SPC_UNSPECIFIED; + ifp->color_range = ifp->fallback.color_range = AVCOL_RANGE_UNSPECIFIED; ifp->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW); if (!ifp->frame_queue) @@ -1485,9 +1493,11 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprintf(&args, "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:" - "pixel_aspect=%d/%d", + "pixel_aspect=%d/%d:colorspace=%s:range=%s", ifp->width, ifp->height, ifp->format, - ifp->time_base.num, ifp->time_base.den, sar.num, sar.den); + ifp->time_base.num, ifp->time_base.den, sar.num, sar.den, + av_color_space_name(ifp->color_space), + av_color_range_name(ifp->color_range)); if (fr.num && fr.den) av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den); snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, @@ -1831,6 +1841,8 @@ int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec) ifp->fallback.width = dec->width; ifp->fallback.height = dec->height; ifp->fallback.sample_aspect_ratio = dec->sample_aspect_ratio; + ifp->fallback.color_space = dec->colorspace; + ifp->fallback.color_range = dec->color_range; } else if (dec->codec_type == AVMEDIA_TYPE_AUDIO) { int ret; @@ -1871,6 +1883,8 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr ifp->width = frame->width; ifp->height = frame->height; ifp->sample_aspect_ratio = frame->sample_aspect_ratio; + ifp->color_space = frame->colorspace; + ifp->color_range = frame->color_range; ifp->sample_rate = frame->sample_rate; ret = av_channel_layout_copy(&ifp->ch_layout, &frame->ch_layout); @@ -2543,6 +2557,8 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter, ifp->width = ifp->fallback.width; ifp->height = ifp->fallback.height; ifp->sample_aspect_ratio = ifp->fallback.sample_aspect_ratio; + ifp->color_space = ifp->fallback.color_space; + ifp->color_range = ifp->fallback.color_range; ret = av_channel_layout_copy(&ifp->ch_layout, &ifp->fallback.ch_layout); @@ -2586,7 +2602,9 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, break; case AVMEDIA_TYPE_VIDEO: need_reinit |= ifp->width != frame->width || - ifp->height != frame->height; + ifp->height != frame->height || + ifp->color_space != frame->colorspace || + ifp->color_range != frame->color_range; break; }