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 DD4F746455 for ; Thu, 18 May 2023 17:31:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B199B68BF99; Thu, 18 May 2023 20:31:46 +0300 (EEST) Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02173688371 for ; Thu, 18 May 2023 20:31:39 +0300 (EEST) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6ab611e57c2so1778560a34.1 for ; Thu, 18 May 2023 10:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684431098; x=1687023098; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=V7DBtbPOzGTCaxIPoUufZSbLUyrS+wKLjNywMwig4jA=; b=oXeKSkax5Koyt4Apcg7wmuV3pR65MJsWvp6Tdh/ZZ/c4ck8VY31oWA1JP0rUBHbrZK eWwj3LMQCg3ACgCMYFa6lDq3HMinVJP6PrAMXf12/JxTo8Y6cixttmW/gVasDBaXp1+0 xA6adm/tevEJo6LuRKcR07rf5SjG0FZYkpmKI4JSwPoyRaiE816/QNMuIlaEoGrzs/RY rar8WWiMavVWwJSycaViBYU+vniy3qFzL6NiPJhh8a9wsXESLGrdcgeJiR2BcUMUYuK5 mqsvT2S6TDqvgTlASL7UHv5z0dnYtZsIRgq/Tkfbxrw6pXA6NGulyP0GLx9Y79STsTYQ bm2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684431098; x=1687023098; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V7DBtbPOzGTCaxIPoUufZSbLUyrS+wKLjNywMwig4jA=; b=QnzWEjpBDvtAfd1kidYEJaJsiEGP6w61Ac3g19Avu8L9VljjxJMofxwLIG05MSl5XL qwMBMRNBo5Ju4uiIJ+xrwAQkRGLkysLt1lnjl9atLjDP5OjXjVNMAmxDeSS6OwXW5o7E dh8bxucDf495IJlBzC1+3RZnMbalWM0Lt4o+fjhAS3iIwaJXW5lXCmH1DE93GzGdQ4Hv enmqDNsw8f7dJt8QBeXQVs9pqqJrq/T9wqsJubOfxDYZTj3uXEvUNguxX65IXYmf04LP Nto9ME6vZe3IZiYOGzBOvNDe8/z/0NWoae+nK3eu9hB6RnRlugM8g907S5S+G4TPwQzx sEFQ== X-Gm-Message-State: AC+VfDyx3SSvxHti0AlTkUs5YuXs5VIYJG9cHJbd9ru8SKMbfIcRvNxG Qb79R2pUZS9sdBB9dbKMTTnSdP06HzA= X-Google-Smtp-Source: ACHHUZ5SYh9WOLmVAWmyawGLsLh/2qF3Xs1T9fcpzm2mJ0ZlxB7LiUYoVAu5p/bTvP9emKkKQh92dw== X-Received: by 2002:a05:6808:1b25:b0:394:3c36:d91a with SMTP id bx37-20020a0568081b2500b003943c36d91amr1965921oib.15.1684431098052; Thu, 18 May 2023 10:31:38 -0700 (PDT) Received: from [192.168.0.12] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id h3-20020a4ad743000000b0051ffe0fe11bsm672001oot.6.2023.05.18.10.31.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 May 2023 10:31:37 -0700 (PDT) Message-ID: <05c66399-caa8-a69a-9b10-849fa6dae9d1@gmail.com> Date: Thu, 18 May 2023 14:31:48 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] avfilter/src_movie: activate & dr 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 5/18/2023 7:22 AM, Paul B Mahol wrote: > From af73b69a0be9033fddf222b6e9ac60799de85691 Mon Sep 17 00:00:00 2001 > From: Paul B Mahol > Date: Mon, 15 May 2023 21:54:25 +0200 > Subject: [PATCH 26/27] avfilter/src_movie: dr support > > Signed-off-by: Paul B Mahol > --- > libavfilter/src_movie.c | 44 +++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 42 insertions(+), 2 deletions(-) > > diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c > index 5937613d13..a2ecc5a625 100644 > --- a/libavfilter/src_movie.c > +++ b/libavfilter/src_movie.c > @@ -23,7 +23,6 @@ > * @file > * movie video source > * > - * @todo use direct rendering (no allocation of a new frame) > * @todo support a PTS correction mechanism > */ > > @@ -156,6 +155,43 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) > return found; > } > > +static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) > +{ > + int linesize_align[AV_NUM_DATA_POINTERS]; > + AVFilterLink *outlink = frame->opaque; > + int w, h, ow, oh; > + AVFrame *new; > + > + h = oh = frame->height; > + w = ow = frame->width; > + > + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) > + return avcodec_default_get_buffer2(avctx, frame, flags); > + > + switch (avctx->codec_type) { > + case AVMEDIA_TYPE_VIDEO: > + avcodec_align_dimensions2(avctx, &w, &h, linesize_align); > + new = ff_default_get_video_buffer(outlink, w, h); > + break; > + case AVMEDIA_TYPE_AUDIO: > + new = ff_default_get_audio_buffer(outlink, frame->nb_samples); I wonder, are these two functions thread safe? AVCodecContext.get_buffer2() no longer supports non-thread safe callbacks, and these seem to allocate and replace the pool inside outlink as required. If called from more than one thread with different frame parameters, wouldn't there be a race? > + break; > + default: > + return -1; > + } > + > + av_frame_copy_props(new, frame); > + av_frame_unref(frame); > + av_frame_move_ref(frame, new); > + av_frame_free(&new); > + > + frame->opaque = outlink; > + frame->width = ow; > + frame->height = oh; > + > + return 0; > +} > + > static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) > { > const AVCodec *codec; > @@ -171,6 +207,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) > if (!st->codec_ctx) > return AVERROR(ENOMEM); > > + st->codec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE; > + st->codec_ctx->get_buffer2 = get_buffer; > ret = avcodec_parameters_to_context(st->codec_ctx, st->st->codecpar); > if (ret < 0) > return ret; > @@ -479,8 +517,10 @@ static int movie_decode_packet(AVFilterContext *ctx) > /* send the packet to its decoder, if any */ > pkt_out_id = pkt.stream_index > movie->max_stream_index ? -1 : > movie->out_index[pkt.stream_index]; > - if (pkt_out_id >= 0) > + if (pkt_out_id >= 0) { > + pkt.opaque = ctx->outputs[pkt_out_id]; > ret = avcodec_send_packet(movie->st[pkt_out_id].codec_ctx, &pkt); > + } > av_packet_unref(&pkt); > > return ret; > -- > 2.39.1 > _______________________________________________ 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".