From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4D40344FCD for ; Thu, 16 Mar 2023 16:14:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D501668BFB3; Thu, 16 Mar 2023 18:14:03 +0200 (EET) Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D97A868BCE8 for ; Thu, 16 Mar 2023 18:13:56 +0200 (EET) Received: by mail-oi1-f170.google.com with SMTP id bi17so1732908oib.3 for ; Thu, 16 Mar 2023 09:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678983235; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=DzP7z8IhH7453aoeTnvR0O3nOQlzMTNsTxxbTKHiqSw=; b=WWNV63z/jUcO97XEHB5frAbzBIW3Mkh2wXo5tLvTyduz/tGj3pLbb701a3fUOUQfBf 2SDoIX6Z7aKK77fDxNLlCliTaK4bo0CJW6Y9IzMZWcXf1aPaFq27hvPXKOR2kVUupEOm 7uj0RIaZR4WyqdbDgUwDiTdlUX2NSQeKjUntP+DumL60YRVeKutEYXaj7zpTlbReR67X /i4gl4ZgHxax9WhKF6VFerRM+waXPx9wQblPXQliKR5OTSPM5SA/i1KlwxQ4Z+q1ysDY EP1uN8duH49iXT4HTOeQLqByVwARJczeSJUvIZc2lTI3gEPdM6V3c9lTX5Icgy1y9dbK fnyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678983235; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DzP7z8IhH7453aoeTnvR0O3nOQlzMTNsTxxbTKHiqSw=; b=Lerl/PgE9BSlz0lxgBsSqCjxMTimOwJ7neULzfVYAP0fmGAjGErRnqrOsaI4fHNxce pOsdOAK4J9/+GdxtX4APDe25m69SeiWvp8JZVNlszF/GR4YMt+voxrp48kE9c2TpLSnp t6pFhmFyQV+aQT7iYktZTtmQzes0SO8ODD9BfTPNNL+zgUWv4TMb1sOC4gRjt9kBurpt IEQD2r9VTjtbyKgBTKPDrI1HyM4vShEieMHXo/yx4/A0WM16BF3GR7hA8hz2CqK8PJ9u vZTYNZD2AucKlY4WbfahLu5UbETM5qeJYC+V+qNeNDM8zSS/ojDvpUW2xJvk+uvJVCON WvBQ== X-Gm-Message-State: AO0yUKVLDL25zZJAQbI9bwFgp6dPgSjBRD2rnLn0OHoOB4/3kfXCnb5j eivw9QpDl7t8YReZisTidJzWHGNFdHw= X-Google-Smtp-Source: AK7set9IwdXI/yBAOikRdvDX1qiydi/9bDnJ84HyZQDhXLsHt3w2ZhkTyal5t1KdNKWvLwAPjEhRuQ== X-Received: by 2002:a05:6808:290f:b0:384:2357:dccd with SMTP id ev15-20020a056808290f00b003842357dccdmr3018807oib.40.1678983234721; Thu, 16 Mar 2023 09:13:54 -0700 (PDT) Received: from [192.168.0.14] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id k184-20020aca3dc1000000b00383e12e20c5sm3465871oia.24.2023.03.16.09.13.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Mar 2023 09:13:54 -0700 (PDT) Message-ID: Date: Thu, 16 Mar 2023 13:13:54 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 To: ffmpeg-devel@ffmpeg.org References: <20230315233445.5282-1-michael@niedermayer.cc> Content-Language: en-US From: James Almer In-Reply-To: <20230315233445.5282-1-michael@niedermayer.cc> Subject: Re: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_uspp: update to new APIs 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 3/15/2023 8:34 PM, Michael Niedermayer wrote: > Signed-off-by: Michael Niedermayer > --- > configure | 1 - > libavfilter/vf_uspp.c | 49 ++++++++++++++++++++++++++++++++++++------- > 2 files changed, 41 insertions(+), 9 deletions(-) > > diff --git a/configure b/configure > index 03d3c429a5..0370e25577 100755 > --- a/configure > +++ b/configure > @@ -7359,7 +7359,6 @@ enable frame_thread_encoder > # they are kept disabled for now, but will be removed if > # nobody updates and re-enables them > disable mcdeint_filter > -disable uspp_filter > > enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; } > > diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c > index 051de00771..43114e1b50 100644 > --- a/libavfilter/vf_uspp.c > +++ b/libavfilter/vf_uspp.c > @@ -53,6 +53,7 @@ typedef struct USPPContext { > int outbuf_size; > uint8_t *outbuf; > AVCodecContext *avctx_enc[BLOCK*BLOCK]; > + AVCodecContext *avctx_dec[BLOCK*BLOCK]; Wouldn't it be more efficient to try to implement recon_frame support on more encoders, including snow, and limit this filter to those in patch 2/2? I suggest this mainly seeing how you're creating 256 encoders and now also 256 decoders, all of which might be threaded since you're not forcing them to use a single thread, and in patch 3 you'll add slice threading on top of that. > AVPacket *pkt; > AVFrame *frame; > AVFrame *frame_dec; > @@ -244,7 +245,6 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3], > const int BLOCKc = BLOCK >> p->hsub; > int offset; > AVPacket *pkt = p->pkt; > - int got_pkt_ptr; > > av_packet_unref(pkt); > pkt->data = p->outbuf; > @@ -255,14 +255,28 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3], > p->frame->data[2] = p->src[2] + x1c + y1c * p->frame->linesize[2]; > p->frame->format = p->avctx_enc[i]->pix_fmt; > > - ret = avcodec_encode_video2(p->avctx_enc[i], pkt, p->frame, &got_pkt_ptr); > + ret = avcodec_send_frame(p->avctx_enc[i], p->frame); > if (ret < 0) { > - av_log(p->avctx_enc[i], AV_LOG_ERROR, "Encoding failed\n"); > + av_log(p->avctx_enc[i], AV_LOG_ERROR, "Error sending a frame for encoding\n"); > + continue; > + } > + ret = avcodec_receive_packet(p->avctx_enc[i], pkt); > + if (ret < 0) { > + av_log(p->avctx_enc[i], AV_LOG_ERROR, "Error receiving a packet from encoding\n"); > continue; > } > - av_packet_unref(pkt); > > - p->frame_dec = p->avctx_enc[i]->coded_frame; > + ret = avcodec_send_packet(p->avctx_dec[i], pkt); > + av_packet_unref(pkt); > + if (ret < 0) { > + av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error sending a packet for decoding\n"); > + continue; > + } > + ret = avcodec_receive_frame(p->avctx_dec[i], p->frame_dec); > + if (ret < 0) { > + av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error receiving a frame from decoding\n"); > + continue; > + } > > offset = (BLOCK-x1) + (BLOCK-y1) * p->frame_dec->linesize[0]; > > @@ -315,10 +329,15 @@ static int config_input(AVFilterLink *inlink) > int i; > > const AVCodec *enc = avcodec_find_encoder(AV_CODEC_ID_SNOW); > + const AVCodec *dec = avcodec_find_decoder(AV_CODEC_ID_SNOW); > if (!enc) { > av_log(ctx, AV_LOG_ERROR, "SNOW encoder not found.\n"); > return AVERROR(EINVAL); > } > + if (!dec) { > + av_log(ctx, AV_LOG_ERROR, "SNOW decoder not found.\n"); > + return AVERROR(EINVAL); > + } > > uspp->hsub = desc->log2_chroma_w; > uspp->vsub = desc->log2_chroma_h; > @@ -341,15 +360,20 @@ static int config_input(AVFilterLink *inlink) > } > > for (i = 0; i < (1<log2_count); i++) { > - AVCodecContext *avctx_enc; > + AVCodecContext *avctx_enc, *avctx_dec; > AVDictionary *opts = NULL; > int ret; > > if (!(uspp->avctx_enc[i] = avcodec_alloc_context3(NULL))) > return AVERROR(ENOMEM); > + if (!(uspp->avctx_dec[i] = avcodec_alloc_context3(NULL))) > + return AVERROR(ENOMEM); > > avctx_enc = uspp->avctx_enc[i]; > + avctx_dec = uspp->avctx_dec[i]; > + avctx_dec->width = > avctx_enc->width = width + BLOCK; > + avctx_dec->height = > avctx_enc->height = height + BLOCK; > avctx_enc->time_base = (AVRational){1,25}; // meaningless > avctx_enc->gop_size = INT_MAX; > @@ -358,17 +382,24 @@ static int config_input(AVFilterLink *inlink) > avctx_enc->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY; > avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; > avctx_enc->global_quality = 123; > - av_dict_set(&opts, "no_bitstream", "1", 0); > ret = avcodec_open2(avctx_enc, enc, &opts); > av_dict_free(&opts); > if (ret < 0) > return ret; > av_assert0(avctx_enc->codec); > + > + > + ret = avcodec_open2(avctx_dec, dec, NULL); > + if (ret < 0) > + return ret; > + > } > > uspp->outbuf_size = (width + BLOCK) * (height + BLOCK) * 10; > if (!(uspp->frame = av_frame_alloc())) > return AVERROR(ENOMEM); > + if (!(uspp->frame_dec = av_frame_alloc())) > + return AVERROR(ENOMEM); > if (!(uspp->pkt = av_packet_alloc())) > return AVERROR(ENOMEM); > if (!(uspp->outbuf = av_malloc(uspp->outbuf_size))) > @@ -460,8 +491,10 @@ static av_cold void uninit(AVFilterContext *ctx) > av_freep(&uspp->src[i]); > } > > - for (i = 0; i < (1 << uspp->log2_count); i++) > + for (i = 0; i < (1 << uspp->log2_count); i++) { > avcodec_free_context(&uspp->avctx_enc[i]); > + avcodec_free_context(&uspp->avctx_dec[i]); > + } > > av_freep(&uspp->non_b_qp_table); > av_freep(&uspp->outbuf); _______________________________________________ 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".