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 5EA4C4639A for ; Mon, 15 May 2023 21:45:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7A12968BFB7; Tue, 16 May 2023 00:45:20 +0300 (EEST) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 63A8368BF80 for ; Tue, 16 May 2023 00:45:14 +0300 (EEST) Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3942bcf62f3so2231047b6e.2 for ; Mon, 15 May 2023 14:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684187112; x=1686779112; 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=1mPvgaRXEzEV1Ucp62pybOsqcrj9+q6mHulwfJxX2v4=; b=nGaK8IuHP2oQgOkrLJLC9naL9jREonSPf20/jYt1NK/1DPbThjon8CjMfL3JrMWZ2j b/eXsXOdQ301/4uOXQZPMDw4/1Xkv2aeiFwoTx4hX9McMusYe5zEc8wBpyrlpZlLXliW g/bEpPV/1XFkmqKVlpx+oBs6uXAScorrBe+SaChyNlcBqp9tMKfR1RY7eQjOeFm7nNtd rJ5iW0msPBClV4E7w7MpeKOqyNilfZoBwzoWSaTtjBSRaUXU9CbVKYh1GcolD8qJYLwM IAjqNTjuBUw2S8FsY93ccQSgA1IXuuNqfHFpFglYhR0xZ9GyW9wnTa3gP7evQYpq3dQb WIpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684187112; x=1686779112; 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=1mPvgaRXEzEV1Ucp62pybOsqcrj9+q6mHulwfJxX2v4=; b=CJjxS/rsaiJAnrRYUCtgm1iTRopCt8MYIEozba+EXTnsyUsvV5MSSIuSnz4cdTkmSr nNBERVI2b6m2+GzONXklIDPuSVnZ5pjzEmXBnnd4cjVWCD8YiQvM4qK1lJCh19LwY53z fUgwOSSgW9nRoYj1LgDK0BSvJig2nBIi5jf8uUGqmhEDN3LEXTo89yeJR6F8kFjFwab4 xXEDerFMtxheZQjf+QMxyLH90sSVaT12G3f3EktZvpSWr1Gt0IqAttdC2/KMnYhMPlDv 7+QkJybKyB9ALMTa8D1Hcj2k/BuvKwZ9AmIfQYBXqgsiX+fGFvisEojQOHiI8yTgENDk FSQQ== X-Gm-Message-State: AC+VfDzfkfFxSkoF0xLiYsiPbi2dibmilddTwlYtUi2HWeXcTiqE6b9T TtKcTceWFA/Mipo9fSTVcchU9g1K1Oo= X-Google-Smtp-Source: ACHHUZ5rCQ81pZee92G79sioBQuHKA7Ua1RKMfTSlYJuo0nLWa8660savFEybLO1koyUyTDYv0fpYQ== X-Received: by 2002:a05:6808:1888:b0:396:e69:c624 with SMTP id bi8-20020a056808188800b003960e69c624mr2553661oib.33.1684187112338; Mon, 15 May 2023 14:45:12 -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 k2-20020acaba02000000b0039604194114sm1828624oif.13.2023.05.15.14.45.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 May 2023 14:45:03 -0700 (PDT) Message-ID: Date: Mon, 15 May 2023 18:45:08 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] avfilter/src_movie: dr support 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: > From 6fddad6ea2abf91a7378fb367a439441ef8f32b4 Mon Sep 17 00:00:00 2001 > From: Paul B Mahol > Date: Mon, 15 May 2023 21:54:25 +0200 > Subject: [PATCH 2/3] avfilter/src_movie: dr support > > Signed-off-by: Paul B Mahol > --- > libavfilter/src_movie.c | 32 ++++++++++++++++++++++++++++++-- > 1 file changed, 30 insertions(+), 2 deletions(-) > > diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c > index a7d7c188e6..0629030f91 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 > */ > > @@ -158,6 +157,31 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) > return found; > } > > +static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) > +{ > + AVFrame *new; > + > + if (flags & AV_GET_BUFFER_FLAG_REF) > + return avcodec_default_get_buffer2(avctx, frame, flags); Why? The frames returned by ff_get_{audio,video}_buffer() are refcounted and writable. You should however use avcodec_default_get_buffer2() for non AV_CODEC_CAP_DR1 decoders. Also, you need to use avcodec_align_dimensions2() to get the correct dimensions. > + > + switch (avctx->codec_type) { > + case AVMEDIA_TYPE_VIDEO: > + new = ff_get_video_buffer(frame->opaque, frame->width, frame->height); > + break; > + case AVMEDIA_TYPE_AUDIO: > + new = ff_get_audio_buffer(frame->opaque, frame->nb_samples); > + break; > + default: > + return -1; > + } > + > + av_frame_unref(frame); The documentation for get_buffer2() says: > * The following fields will be set in the frame before this callback is > * called: > * - format > * - width, height (video only) > * - sample_rate, channel_layout, nb_samples (audio only) > * Their values may differ from the corresponding values in > * AVCodecContext. This callback must use the frame values, not the codec > * context values, to calculate the required buffer size. So you're not really supposed to touch anything else than data, buf, extended_data, extended_buf, and linesize, which an unref call will do. But as long as the necessary values in the AVFilterLink match those in the frame, i guess it should be ok. > + av_frame_move_ref(frame, new); > + av_frame_free(&new); > + > + return 0; > +} > + > static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) > { > const AVCodec *codec; > @@ -173,6 +197,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; > @@ -480,8 +506,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".