From patchwork Mon Sep 23 15:01:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51762 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2523253vqb; Mon, 23 Sep 2024 08:09:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUCkdjTtetSK1+Fb/t/TBk3Wj38UUjCYbCkI5CBsrD+yMYCdPFt2fwGmBuqDOIqFRRncvaKda8DIqOPGRYLH6Pr@gmail.com X-Google-Smtp-Source: AGHT+IFcISnUQAyPfKW+Lxn7xQ8Cj0WH+c8U3R2zTl6ChidhEuvzy2bzlHjQQz3GxnaGWqct+Gy0 X-Received: by 2002:a2e:bc06:0:b0:2f1:75f4:a6c1 with SMTP id 38308e7fff4ca-2f7cb2fbb68mr20736381fa.3.1727104177944; Mon, 23 Sep 2024 08:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727104177; cv=none; d=google.com; s=arc-20240605; b=URLUkhmEy1ToaysCrN5qSBqzBFH7INVhlKHjiQpRhTa0j//34u4a9uGS1lLEH3zaa9 dzayD9ExRYt5/p/+Jhc1xHdIGKTMM7wtLbtk9gm0oWNb8JTg3jT2r7e03RKs5c8EJ5G7 8ezRTgClrxo1YYvYrGDESAwOyK2X4VMjBnQJL4Zef7Pm1wdCHs8qbnMFNWRIDUChoMyI DSnszutQ3GefCHkyLwvYxVWLcDjYqfYoK1hIPstwOsIOemTxVIzXrlNqpiWsAfqyVOWf YHaUwRSLtc624qhSnpu5C4HB0ubUZUeKnc+ZI6Upm/C7qaNr7hyk63woEqY58CpRsx1+ 7N1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=XPgMaJ7JzkKW5PVWksQAZ8iB43/n0pizBHPtsL4aVKk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=TPd7pK3A9wuI/Ah9OkzdLrRBEuNRi9NqO6aua0XXjghlE19tUoBNjgx2cu0ijxwBX9 TJeC51TKPqIYwfJbFseXGyNMnq8t9QzOj8coqulkhJhkKjBD6M0ev9cTSyZNnESgundW 0LDiZCRLyvTFCMJ36yC03ut8yIjqWK1NRnq5p20jLUvQSVyFbCkBpj58Ou2PRwcQ+kFp /c6UVXZrkPv/28DYSyINXBRkcTX9NKkXufgShZmsTuR60DXg7bwHixc04OqiFpUUPhNK uV33ucKICim1XHDt4U7lqtXhD5/LMOE8QO90jAGfJ/cZgL/56mBhwWuluo41J2TVpL4b YoRQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=XKXcKYdF; 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 38308e7fff4ca-2f79d37959fsi60091221fa.357.2024.09.23.08.09.37; Mon, 23 Sep 2024 08:09:37 -0700 (PDT) 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=@khirnov.net header.s=mail header.b=XKXcKYdF; 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 8B9C968DC75; Mon, 23 Sep 2024 18:02:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F052768DB97 for ; Mon, 23 Sep 2024 18:02:06 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=XKXcKYdF; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 8D6A14DEE for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 3ZeJVzBJXAKi for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727103724; bh=am4urxokhIzp8JlufQwPNZVE2bmaCmEfCxL5tVM3QLI=; h=From:To:Subject:Date:From; b=XKXcKYdFwBuB+jQVrJWOTI+aT4+8aYVGhPCnl6VFi5GcbbLtZ25DP0PP3tcMZZ8P0 RiZHDG/wTmlVkc4Xcavv8olfpdDbJgq9fyxNhTSGHrwTTMnDzvUD+nzv2s6Yp0kZyo es+Z0RB1cq/AOOR0CRLToKA8UhRc+gcvvL58KTjPXThb5AXt9PtQdTnrMWdwKhKmkL TlAIl6u/C3FOC4oHs/I5xaG1hrnddnlhV1nM3GtJ/PnzgApNJ6lG+aV903xiYM7+Yp v1r5b0dQArJeI9PE41xoackMfmNImfkeVftz8iJDDSQBzLpHhGTC2s7Mnjl01KOOz9 D/bQBB5/4WbmQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 5AB861F8 for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 300793A03CA for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Sep 2024 17:01:39 +0200 Message-ID: <20240923150146.31693-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/7] lavfi/buffersink: set AVFrame.time_base 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RtQmUOOZDZ6P So the caller does not need to call av_buffersink_get_time_base() separately. --- doc/APIchanges | 3 +++ doc/examples/transcode.c | 1 - fftools/ffmpeg_filter.c | 2 -- fftools/ffplay.c | 10 ++-------- libavdevice/lavfi.c | 4 ++-- libavfilter/buffersink.c | 21 ++++++++++++++++----- libavfilter/version.h | 2 +- tools/uncoded_frame.c | 2 +- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 2273c3bce7..b392c756d7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-09-xx - xxxxxxxxxx - lavfi 10.4.100 + Buffersink now sets AVFrame.time_base on the frames it outputs. + 2024-09-23 - xxxxxxxxxx - lavc 61.18.100 - avcodec.h Add a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c index cbe5088ef6..07d9ee9152 100644 --- a/doc/examples/transcode.c +++ b/doc/examples/transcode.c @@ -500,7 +500,6 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index) break; } - filter->filtered_frame->time_base = av_buffersink_get_time_base(filter->buffersink_ctx);; filter->filtered_frame->pict_type = AV_PICTURE_TYPE_NONE; ret = encode_write_frame(stream_index, 0); av_frame_unref(filter->filtered_frame); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 529e631781..81c4911b03 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2487,8 +2487,6 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, return 0; } - frame->time_base = av_buffersink_get_time_base(filter); - if (debug_ts) av_log(ofp, AV_LOG_INFO, "filter_raw -> pts:%s pts_time:%s time_base:%d/%d\n", av_ts2str(frame->pts), av_ts2timestr(frame->pts, &frame->time_base), diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 60d8874eab..4ea48e11bb 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2076,7 +2076,6 @@ static int audio_thread(void *arg) int last_serial = -1; int reconfigure; int got_frame = 0; - AVRational tb; int ret = 0; if (!frame) @@ -2087,8 +2086,6 @@ static int audio_thread(void *arg) goto the_end; if (got_frame) { - tb = (AVRational){1, frame->sample_rate}; - reconfigure = cmp_audio_fmts(is->audio_filter_src.fmt, is->audio_filter_src.ch_layout.nb_channels, frame->format, frame->ch_layout.nb_channels) || @@ -2121,11 +2118,10 @@ static int audio_thread(void *arg) while ((ret = av_buffersink_get_frame_flags(is->out_audio_filter, frame, 0)) >= 0) { FrameData *fd = frame->opaque_ref ? (FrameData*)frame->opaque_ref->data : NULL; - tb = av_buffersink_get_time_base(is->out_audio_filter); if (!(af = frame_queue_peek_writable(&is->sampq))) goto the_end; - af->pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(tb); + af->pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(frame->time_base); af->pos = fd ? fd->pkt_pos : -1; af->serial = is->auddec.pkt_serial; af->duration = av_q2d((AVRational){frame->nb_samples, frame->sample_rate}); @@ -2164,7 +2160,6 @@ static int video_thread(void *arg) double pts; double duration; int ret; - AVRational tb = is->video_st->time_base; AVRational frame_rate = av_guess_frame_rate(is->ic, is->video_st, NULL); AVFilterGraph *graph = NULL; @@ -2242,9 +2237,8 @@ static int video_thread(void *arg) is->frame_last_filter_delay = av_gettime_relative() / 1000000.0 - is->frame_last_returned_time; if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0) is->frame_last_filter_delay = 0; - tb = av_buffersink_get_time_base(filt_out); duration = (frame_rate.num && frame_rate.den ? av_q2d((AVRational){frame_rate.den, frame_rate.num}) : 0); - pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(tb); + pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(frame->time_base); ret = queue_picture(is, frame, pts, duration, fd ? fd->pkt_pos : -1, is->viddec.pkt_serial); av_frame_unref(frame); if (is->videoq.serial != is->viddec.pkt_serial) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index ce10d61f8a..3b77a7396a 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -384,7 +384,6 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) /* iterate through all the graph sinks. Select the sink with the * minimum PTS */ for (i = 0; i < lavfi->nb_sinks; i++) { - AVRational tb = av_buffersink_get_time_base(lavfi->sinks[i]); double d; if (lavfi->sink_eof[i]) @@ -398,7 +397,8 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) continue; } else if (ret < 0) goto fail; - d = av_rescale_q_rnd(frame->pts, tb, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); + d = av_rescale_q_rnd(frame->pts, frame->time_base, AV_TIME_BASE_Q, + AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); ff_dlog(avctx, "sink_idx:%d time:%f\n", i, d); av_frame_unref(frame); diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 5811720c61..575075ff47 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -69,18 +69,29 @@ int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *f return av_buffersink_get_frame_flags(ctx, frame, 0); } -static int return_or_keep_frame(BufferSinkContext *buf, AVFrame *out, AVFrame *in, int flags) +static int return_or_keep_frame(AVFilterContext *ctx, AVFrame *out, AVFrame *in, + int flags) { + BufferSinkContext *buf = ctx->priv; + if ((flags & AV_BUFFERSINK_FLAG_PEEK)) { buf->peeked_frame = in; - return out ? av_frame_ref(out, in) : 0; + if (out) { + int ret = av_frame_ref(out, in); + if (ret < 0) + return ret; + } } else { av_assert1(out); buf->peeked_frame = NULL; av_frame_move_ref(out, in); av_frame_free(&in); - return 0; } + + if (out) + out->time_base = ctx->inputs[0]->time_base; + + return 0; } static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, int samples) @@ -93,7 +104,7 @@ static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i int64_t pts; if (buf->peeked_frame) - return return_or_keep_frame(buf, frame, buf->peeked_frame, flags); + return return_or_keep_frame(ctx, frame, buf->peeked_frame, flags); while (1) { ret = samples ? ff_inlink_consume_samples(inlink, samples, samples, &cur_frame) : @@ -102,7 +113,7 @@ static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i return ret; } else if (ret) { /* TODO return the frame instead of copying it */ - return return_or_keep_frame(buf, frame, cur_frame, flags); + return return_or_keep_frame(ctx, frame, cur_frame, flags); } else if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { return status; } else if ((flags & AV_BUFFERSINK_FLAG_NO_REQUEST)) { diff --git a/libavfilter/version.h b/libavfilter/version.h index 7e0eb9af97..4d8f28e512 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFILTER_VERSION_MINOR 3 +#define LIBAVFILTER_VERSION_MINOR 4 #define LIBAVFILTER_VERSION_MICRO 100 diff --git a/tools/uncoded_frame.c b/tools/uncoded_frame.c index 447bfc8b0d..a17d406417 100644 --- a/tools/uncoded_frame.c +++ b/tools/uncoded_frame.c @@ -237,7 +237,7 @@ int main(int argc, char **argv) } if (frame->pts != AV_NOPTS_VALUE) frame->pts = av_rescale_q(frame->pts, - av_buffersink_get_time_base(st->sink), + frame->time_base, st->stream->time_base); ret = av_interleaved_write_uncoded_frame(st->mux, st->stream->index, From patchwork Mon Sep 23 15:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51755 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2516780vqb; Mon, 23 Sep 2024 08:02:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVE6+a1i7VMsk1GB/KsaFFa+7jlmm3OEn8Ss6L03cBd/vdiivMMABqWvXKQ7Diiu/OYal/uOGCJs0xa/92sTr9D@gmail.com X-Google-Smtp-Source: AGHT+IFYJK9LLxnD5MBLqys96V1wNk7+vXb9bOajCJDvgitgX9nP+MK2qW/q4folApQZDos6lp44 X-Received: by 2002:a17:907:1ca0:b0:a90:17fc:3f60 with SMTP id a640c23a62f3a-a90d5052578mr477685466b.8.1727103738140; Mon, 23 Sep 2024 08:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727103738; cv=none; d=google.com; s=arc-20240605; b=aOP7NSh2tgjGzfjRZyb2TIPGL6R6VmgTHGb5Fi2Grqta8Q9NSJlhO6f9k1SFTM10k6 0tNVwrGRHhyjXjP0rmSGhu3MXix4qp2YJWNuQC+ePhO8jGJPYSYD84rhPYn+Y7WAtpPY dmAytDv4aNSXeKAvNvfuR6ZFtUL1Q0MZoS0JI9YKIjbjpdl32v+Fu3RCj5WWmO0JMT/E LdEbKoUa2B046I+41eWgvx2Qh4amK9i4oJXLPsKwVQbS1zfV0KAPW8+a4C2nF/v6u6iB rvROsdkzI00w1nGLdPdjRlrRtLqvnXGhvhRmI0JlPMPHkzNfqwdVZYhFjTkLXE3zv5Gj iBaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding: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=klWONip6+pEA73In7g8NtYynYCKbUx3r2TKZ038SMrw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=EwwToq2dIhR3PD33AQB5rqYx6iMF/OI6fPK59qh4RD/rBtpv4oulrnrXJNj2aFiVRK 7LHSRcAeSNzW4h/Rt+A74En3bYh9yVA83cZSakfsdrvkPc2jYi5cylHUWAm7+O/tEFe5 LZ/dLfgOUJRDPBzg9rQqnEjXn5T1/oOvf/LvYEmXAl0yqkD4h+R8aDSzXJMCn/Qvk7d3 DnMpF//UzZGUvzKeVN6U2dSyj4olvi68H3eeckoF4QxXrCjKRKN5bPoEVzcIpNyvb2y0 bmNsbcNPwYd76NTDPzpKurQyhAuhnB9odTEa39qBz29lxePNcjzXqIeu3BIRjO3jICLW qEIQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b="Cj6Q/G0C"; 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 a640c23a62f3a-a90613879c6si1413306566b.1037.2024.09.23.08.02.17; Mon, 23 Sep 2024 08:02:18 -0700 (PDT) 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=@khirnov.net header.s=mail header.b="Cj6Q/G0C"; 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 9763A68DC28; Mon, 23 Sep 2024 18:02:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 80FEE68D841 for ; Mon, 23 Sep 2024 18:02:06 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=Cj6Q/G0C; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id AFDDA4E08 for ; Mon, 23 Sep 2024 17:02:05 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Sp068QtOJUkx for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727103724; bh=NLoZvY3Lqnk5RWsHskV1b5srnt5R/7+3cKYnGmUzDaU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Cj6Q/G0C8KfGTVPjAkIbZiZGelnVMlBWGuDJvydJYPADc1T5yu5GoFV7+ipoZ5vnE /u26zXtWw4pN9QWbJ4RH2qHFPLW6+kRxznb1obAbShcMNYUx2loGjDuynW8vezXku9 1Rn10OVS3hAyJY47i4xu+ROgDZ3XqyXGIhAOesq6Krn3IuIJjpTa+qeZa+gXB2cWju F02enrloXVawGP5zjnrjqh2HuioYoMAtI+eg6Svw636wP1QOzDr7OIoq/t7vjNjWrR uz0vxEhwDZvq1+x/iSyMoq/bcd+5sq6rjjSszX5mfEclJstCT0sVSmBgCx4CguObtw Lm8VQoDQYYWbg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 5D4CD4DD7 for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3CF213A086F for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Sep 2024 17:01:40 +0200 Message-ID: <20240923150146.31693-2-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240923150146.31693-1-anton@khirnov.net> References: <20240923150146.31693-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/7] lavfi/buffersink: add a flag for retrieving stream parameters 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: f+EdVe7j1yQv This way, av_buffersink_get_frame_flags() can replace almost all av_buffersink_get_*(), including some future parameters we will want to export. --- doc/APIchanges | 1 + libavfilter/buffersink.c | 47 ++++++++++++++++++++++++++++++++++++++++ libavfilter/buffersink.h | 16 ++++++++++++-- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index b392c756d7..5ddd7189f8 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -4,6 +4,7 @@ API changes, most recent first: 2024-09-xx - xxxxxxxxxx - lavfi 10.4.100 Buffersink now sets AVFrame.time_base on the frames it outputs. + Add AV_BUFFERSINK_FLAG_PARAMS. 2024-09-23 - xxxxxxxxxx - lavc 61.18.100 - avcodec.h Add a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 575075ff47..d9cd074f17 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -128,8 +128,55 @@ static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i } } +static int get_frame_params(AVFilterContext *ctx, AVFrame *frame) +{ + FilterLink *l = ff_filter_link(ctx->inputs[0]); + int ret = 0; + + frame->time_base = l->pub.time_base; + frame->format = l->pub.format; + + switch (l->pub.type) { + case AVMEDIA_TYPE_AUDIO: + ret = av_channel_layout_copy(&frame->ch_layout, &l->pub.ch_layout); + if (ret < 0) + goto fail; + + frame->sample_rate = l->pub.sample_rate; + break; + case AVMEDIA_TYPE_VIDEO: + frame->width = l->pub.w; + frame->height = l->pub.h; + frame->sample_aspect_ratio = l->pub.sample_aspect_ratio; + frame->colorspace = l->pub.colorspace; + frame->color_range = l->pub.color_range; + break; + default: av_assert0(0); + } + + if (l->hw_frames_ctx) { + frame->hw_frames_ctx = av_buffer_ref(l->hw_frames_ctx); + if (!frame->hw_frames_ctx) { + ret = AVERROR(ENOMEM); + goto fail; + } + } + + return 0; +fail: + av_frame_unref(frame); + return ret; +} + int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags) { + if (flags & AV_BUFFERSINK_FLAG_PARAMS) { + if (flags & ~AV_BUFFERSINK_FLAG_PARAMS) + return AVERROR(EINVAL); + + return get_frame_params(ctx, frame); + } + return get_frame_internal(ctx, frame, flags, ff_filter_link(ctx->inputs[0])->min_samples); } diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index 361d603679..9c4468af5b 100644 --- a/libavfilter/buffersink.h +++ b/libavfilter/buffersink.h @@ -87,14 +87,26 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flag * reference, but not remove it from the buffer. This is useful if you * need only to read a video/samples buffer, without to fetch it. */ -#define AV_BUFFERSINK_FLAG_PEEK 1 +#define AV_BUFFERSINK_FLAG_PEEK (1 << 0) /** * Tell av_buffersink_get_buffer_ref() not to request a frame from its input. * If a frame is already buffered, it is read (and removed from the buffer), * but if no frame is present, return AVERROR(EAGAIN). */ -#define AV_BUFFERSINK_FLAG_NO_REQUEST 2 +#define AV_BUFFERSINK_FLAG_NO_REQUEST (1 << 1) + +/** + * Retrieve stream parameters rather than frame data. + * + * When this flag is set, av_buffersink_get_frame_flags() fills the non-data + * fields of the supplied frame without causing any filtergraph activity. + * + * @note While frame data will be NULL, certain other allocated fields may be + * filled (e.g. ch_layout, hw_frames_ctx), so the frame should still be + * unreffed before reuse. + */ +#define AV_BUFFERSINK_FLAG_PARAMS (1 << 2) /** * Set the frame size for an audio buffer sink. From patchwork Mon Sep 23 15:01:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51756 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2517198vqb; Mon, 23 Sep 2024 08:02:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWS5K2FnVGKwXrenhySj2x8hs+tNR/bjiM1ZFaPGLDXxmcP7Z1Gr8RDj+yhOEKs18QnCX++JsqisA3BsdT7W5pN@gmail.com X-Google-Smtp-Source: AGHT+IFbwGTHAjDYbvNHsU3PGh8d7bQ/+GY7qxh2FQI9eDHitiSU33UJMkGRPLNKPp8iu6S0y46d X-Received: by 2002:a2e:bea6:0:b0:2f7:5777:cf14 with SMTP id 38308e7fff4ca-2f7cb367b08mr77707771fa.35.1727103763733; Mon, 23 Sep 2024 08:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727103763; cv=none; d=google.com; s=arc-20240605; b=UwEKcCcrOA/wMBPwgNJzXe9lbnDJjZrMNu+Z/QQBkOOcCwgZQSePCWbhFnL58AMidz d8bBGWbWUwmyTMb5TdVdG3XA1RjTWcK4IpcXS+zLw54rvf0BhXxxLD+BOAkQjA/e3L4T qxphKv+hauL9r11nW98a3YrIIWqCh/llRU2484jyy5A4c0pofZ3ewCtkkfND8LSbHRyf 6hyzJ+GcV+1E9NNZvQTVTUtpqlV9DCCDZHOfF8WrhY5Mcyi4333+0VnC5gHnJkIpjtA7 Cg0NKqDWsb7KWIQECVQo8g1t5QHMuNQf0Ck+UO/dm1Hdi+2jOzI9zDcrzyL41RviPXjw jUQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding: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=SQb8xdCPA3NczY9yUBiIsNRVyQdN2qYLE/2QFcTiteo=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Rrt5sr9R7aFuE8JMBVirzgURE0loTi/r2XI/ySOjX8/Sp6qjJlz97HkYnZ/tVeHW9A ZyrFP6IQX6QgyUMLB5rijMZjh4dJAdiwd7PqvfGo9W5d+japaskstalPicUGF5aqqXBi +/3iUAbrG4+YmS//Qlpq3ZS5BF4irkzzzvEpoBdVo/MK2qbSKdUTlodbsppol3cKcWsp R0gi5CeEaKOk3L4ZwfbkCTHHZjA1Sw4vSjdisRtz1Au6wEvpj4BioE8Kc8I8ifecAOjq HfK8yphEXG0bDYMbXj7mxNpell+DFLMgvU5aWm0RvO8kd99UDHQI34DLeYhm34VOrPiA 5t/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=kfkMkmWV; 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 a640c23a62f3a-a9061373381si1380386466b.1022.2024.09.23.08.02.43; Mon, 23 Sep 2024 08:02:43 -0700 (PDT) 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=@khirnov.net header.s=mail header.b=kfkMkmWV; 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 332AB68DC4B; Mon, 23 Sep 2024 18:02:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8864768DB97 for ; Mon, 23 Sep 2024 18:02:06 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=kfkMkmWV; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id A62514E0F for ; Mon, 23 Sep 2024 17:02:05 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id vXoINKwIuCXA for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727103724; bh=hA8pMmLi2MTOpbtAfV6nonWixI2Bc7i/T0yPVVRe+3g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kfkMkmWVwszkGhdn179wpgN4ejV0zjO4mPrlxnyTsQaXUmZtfRKGGUvGWGbSXIkk6 fYBOt+uWd8lCgX9eOVfiMRdcRnFwn/8ZRKWWeA51keyL38H7eM80r6YMS9dMHyOhv9 wDCC+QP00l26Gm3BbRRXiK1+59Rr+qTPlA1BmvU9VZznbVtwsQqkwcT7p4k50WYPua FuxcKZRir9LIG1uixh8XIIIDhv1rC2Ow+ipse7mgWGWNBlWhLI5pAsbO2Lp5tjJ93p u/W+D/u0TvHzEhVTQxQ1kAV+hxmoJLjOGYspgzrZYleeRwqv21b9m2bLeHly2fT7xW YlucJPxgQitlQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 5F78B4DEE for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 48A3E3A0998 for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Sep 2024 17:01:41 +0200 Message-ID: <20240923150146.31693-3-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240923150146.31693-1-anton@khirnov.net> References: <20240923150146.31693-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7] fftools/ffmpeg_filter: use AV_BUFFERSINK_FLAG_PARAMS 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RrfAsGUhWAd4 --- fftools/ffmpeg_filter.c | 96 ++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 81c4911b03..b4c0876fa6 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -197,13 +197,8 @@ typedef struct OutputFilterPriv { AVFilterContext *filter; - /* desired output stream properties */ - int format; - int width, height; - int sample_rate; - AVChannelLayout ch_layout; - enum AVColorSpace color_space; - enum AVColorRange color_range; + /* frame holding desired output stream parameters */ + AVFrame *params; // time base in which the output is sent to our downstream // does not need to match the filtersink's timebase @@ -212,8 +207,6 @@ typedef struct OutputFilterPriv { // to our downstream, so it cannot change anymore int tb_out_locked; - AVRational sample_aspect_ratio; - AVDictionary *sws_opts; AVDictionary *swr_opts; @@ -373,11 +366,11 @@ static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \ static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \ { \ - if (ofp->var == none && !ofp->supported_list) \ + if (ofp->params->var == none && !ofp->supported_list) \ return; \ av_bprintf(bprint, #name "="); \ - if (ofp->var != none) { \ - av_bprintf(bprint, printf_format, get_name(ofp->var)); \ + if (ofp->params->var != none) { \ + av_bprintf(bprint, printf_format, get_name(ofp->params->var)); \ } else { \ const type *p; \ \ @@ -399,7 +392,7 @@ DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats, DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0, "%d", ) -DEF_CHOOSE_FORMAT(color_spaces, enum AVColorSpace, color_space, color_spaces, +DEF_CHOOSE_FORMAT(color_spaces, enum AVColorSpace, colorspace, color_spaces, AVCOL_SPC_UNSPECIFIED, "%s", av_color_space_name); DEF_CHOOSE_FORMAT(color_ranges, enum AVColorRange, color_range, color_ranges, @@ -407,9 +400,9 @@ DEF_CHOOSE_FORMAT(color_ranges, enum AVColorRange, color_range, color_ranges, static void choose_channel_layouts(OutputFilterPriv *ofp, AVBPrint *bprint) { - if (av_channel_layout_check(&ofp->ch_layout)) { + if (av_channel_layout_check(&ofp->params->ch_layout)) { av_bprintf(bprint, "channel_layouts="); - av_channel_layout_describe_bprint(&ofp->ch_layout, bprint); + av_channel_layout_describe_bprint(&ofp->params->ch_layout, bprint); } else if (ofp->ch_layouts) { const AVChannelLayout *p; @@ -643,14 +636,15 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg, enum AVMediaType type) if (!ofp) return NULL; + ofp->params = av_frame_alloc(); + if (!ofp->params) + return NULL; + ofilter = &ofp->ofilter; ofilter->class = &ofilter_class; ofp->log_parent = fg; ofilter->graph = fg; ofilter->type = type; - ofp->format = -1; - ofp->color_space = AVCOL_SPC_UNSPECIFIED; - ofp->color_range = AVCOL_RANGE_UNSPECIFIED; ofp->index = fg->nb_outputs - 1; snprintf(ofp->log_name, sizeof(ofp->log_name), "%co%d", @@ -747,7 +741,7 @@ static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layout if (layout_requested->order != AV_CHANNEL_ORDER_UNSPEC) { /* Pass the layout through for all orders but UNSPEC */ - err = av_channel_layout_copy(&f->ch_layout, layout_requested); + err = av_channel_layout_copy(&f->params->ch_layout, layout_requested); if (err < 0) return err; return 0; @@ -757,7 +751,7 @@ static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layout if (!layouts_allowed) { /* Use the default native layout for the requested amount of channels when the encoder doesn't have a list of supported layouts */ - av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels); + av_channel_layout_default(&f->params->ch_layout, layout_requested->nb_channels); return 0; } /* Encoder has a list of supported layouts. Pick the first layout in it with the @@ -768,14 +762,14 @@ static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layout } if (layouts_allowed[i].nb_channels) { /* Use it if one is found */ - err = av_channel_layout_copy(&f->ch_layout, &layouts_allowed[i]); + err = av_channel_layout_copy(&f->params->ch_layout, &layouts_allowed[i]); if (err < 0) return err; return 0; } /* If no layout for the amount of channels requested was found, use the default native layout for it. */ - av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels); + av_channel_layout_default(&f->params->ch_layout, layout_requested->nb_channels); return 0; } @@ -827,20 +821,20 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, switch (ofilter->type) { case AVMEDIA_TYPE_VIDEO: - ofp->width = opts->width; - ofp->height = opts->height; + ofp->params->width = opts->width; + ofp->params->height = opts->height; if (opts->format != AV_PIX_FMT_NONE) { - ofp->format = opts->format; + ofp->params->format = opts->format; } else ofp->formats = opts->formats; if (opts->color_space != AVCOL_SPC_UNSPECIFIED) - ofp->color_space = opts->color_space; + ofp->params->colorspace = opts->color_space; else ofp->color_spaces = opts->color_spaces; if (opts->color_range != AVCOL_RANGE_UNSPECIFIED) - ofp->color_range = opts->color_range; + ofp->params->color_range = opts->color_range; else ofp->color_ranges = opts->color_ranges; @@ -865,12 +859,12 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, break; case AVMEDIA_TYPE_AUDIO: if (opts->format != AV_SAMPLE_FMT_NONE) { - ofp->format = opts->format; + ofp->params->format = opts->format; } else { ofp->formats = opts->formats; } if (opts->sample_rate) { - ofp->sample_rate = opts->sample_rate; + ofp->params->sample_rate = opts->sample_rate; } else ofp->sample_rates = opts->sample_rates; if (opts->ch_layout.nb_channels) { @@ -1012,6 +1006,7 @@ void fg_free(FilterGraph **pfg) OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); av_frame_free(&ofp->fps.last_frame); + av_frame_free(&ofp->params); av_dict_free(&ofp->sws_opts); av_dict_free(&ofp->swr_opts); @@ -1019,7 +1014,6 @@ void fg_free(FilterGraph **pfg) av_freep(&ofilter->name); av_freep(&ofilter->apad); av_freep(&ofp->name); - av_channel_layout_uninit(&ofp->ch_layout); av_freep(&fg->outputs[j]); } av_freep(&fg->outputs); @@ -1484,13 +1478,14 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, if (ret < 0) return ret; - if ((ofp->width || ofp->height) && (ofp->flags & OFILTER_FLAG_AUTOSCALE)) { + if ((ofp->params->width || ofp->params->height) && + (ofp->flags & OFILTER_FLAG_AUTOSCALE)) { char args[255]; AVFilterContext *filter; const AVDictionaryEntry *e = NULL; snprintf(args, sizeof(args), "%d:%d", - ofp->width, ofp->height); + ofp->params->width, ofp->params->height); while ((e = av_dict_iterate(ofp->sws_opts, e))) { av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value); @@ -1508,7 +1503,7 @@ static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, } av_assert0(!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT) || - ofp->format != AV_PIX_FMT_NONE || !ofp->formats); + ofp->params->format != AV_PIX_FMT_NONE || !ofp->formats); av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); choose_pix_fmts(ofp, &bprint); choose_color_spaces(ofp, &bprint); @@ -1931,12 +1926,11 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); AVFilterContext *sink = ofp->filter; - ofp->format = av_buffersink_get_format(sink); - - ofp->width = av_buffersink_get_w(sink); - ofp->height = av_buffersink_get_h(sink); - ofp->color_space = av_buffersink_get_colorspace(sink); - ofp->color_range = av_buffersink_get_color_range(sink); + av_frame_unref(ofp->params); + ret = av_buffersink_get_frame_flags(sink, ofp->params, + AV_BUFFERSINK_FLAG_PARAMS); + if (ret < 0) + return ret; // If the timing parameters are not locked yet, get the tentative values // here but don't lock them. They will only be used if no output frames @@ -1946,15 +1940,8 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) if (ofp->fps.framerate.num <= 0 && ofp->fps.framerate.den <= 0 && fr.num > 0 && fr.den > 0) ofp->fps.framerate = fr; - ofp->tb_out = av_buffersink_get_time_base(sink); + ofp->tb_out = ofp->params->time_base; } - ofp->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink); - - ofp->sample_rate = av_buffersink_get_sample_rate(sink); - av_channel_layout_uninit(&ofp->ch_layout); - ret = av_buffersink_get_ch_layout(sink, &ofp->ch_layout); - if (ret < 0) - goto fail; } for (int i = 0; i < fg->nb_inputs; i++) { @@ -2339,15 +2326,16 @@ static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt) FrameData *fd; frame->time_base = ofp->tb_out; - frame->format = ofp->format; - frame->width = ofp->width; - frame->height = ofp->height; - frame->sample_aspect_ratio = ofp->sample_aspect_ratio; + frame->format = ofp->params->format; - frame->sample_rate = ofp->sample_rate; - if (ofp->ch_layout.nb_channels) { - ret = av_channel_layout_copy(&frame->ch_layout, &ofp->ch_layout); + frame->width = ofp->params->width; + frame->height = ofp->params->height; + frame->sample_aspect_ratio = ofp->params->sample_aspect_ratio; + + frame->sample_rate = ofp->params->sample_rate; + if (ofp->params->ch_layout.nb_channels) { + ret = av_channel_layout_copy(&frame->ch_layout, &ofp->params->ch_layout); if (ret < 0) return ret; } From patchwork Mon Sep 23 15:01:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51763 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2523265vqb; Mon, 23 Sep 2024 08:09:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDtE2ifzn2QzTyguw62G8QAa0v/uN1wrLhE7ciTr+4ftBVSyzGbdr4BoTa9LykTbTBZ0Art84xr8NC397dSH9t@gmail.com X-Google-Smtp-Source: AGHT+IGN/o+stxOS9MiRxKQ6lEs33Kd7EQESaTrb9D7vInCRB/9gHC4dHiyQfdawBPRa/4dg0zhC X-Received: by 2002:a05:6512:e93:b0:531:5b03:b1f7 with SMTP id 2adb3069b0e04-536a563658dmr5444203e87.10.1727104178914; Mon, 23 Sep 2024 08:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727104178; cv=none; d=google.com; s=arc-20240605; b=VCKMcG/cGcm7PmvxZ30tKKnQc+XoF9Nx2rIzhRU8/d3IkWrOYVJaCBcrXuDa8XP7GT hsxqGh03PjiIDSdg9xPnV291sbPkt3inwUxS07iIBbwU6YN0j/xF9OaW+9GIFIvnfRC8 IR90FXyVwyJDnyeLLlEqLwBeAbQQ9UJ5v52Us9KICNPbqhVyctFsGglgtnv0aMIX0qhh kjF0082cq68ApBbzNAh9Ymi39QjgUxpo/zSxeyvr/8efQMMMzh//riGK6qorI9GeXfDQ w07rtiCtIfaxnpnXBBlbx7l52IGl5w2Rkl9dQ8Y7718OTl7+qZwJRD45JYw8rvv5Kpf7 RXCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding: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=TaCR1MkqGMaBwAunUbmzklippLS84apDTFdAqHfizfo=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=cuyMIHDn1pPD0Cl0RREzD8P95QmHr1oeBIj+EIVyhRufSX5oj0TkaJEgi4YCJKnNIk gbFick21ACij5SyXuBsdJRNIEtUFKteDCs4DmqxgY6DpPEhgfbhLkizP0lIfGz9kNctF lwknKM9Bo5asdsZkipeNyiS4pCRYIOi57xXRZs9ILaNND0W7sOYdRGi0/nZFbhwD4KSf PUNhNCgxeDVf7SWRX3OeQ+BC0XIb3MTt+NDV4Cls7tcdzpMNEK7gONBbAjsuY04XKGdj /JgHypiTEnSFCgWVe9qgFmDgUgZMJkng6jMArN0/YSiQuIqEGCra18DeoNr50wC2pk4m 2/cw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=QvmTmNPP; 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 2adb3069b0e04-5368708df2dsi7227822e87.325.2024.09.23.08.09.38; Mon, 23 Sep 2024 08:09:38 -0700 (PDT) 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=@khirnov.net header.s=mail header.b=QvmTmNPP; 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 E9DC068DC2C; Mon, 23 Sep 2024 18:02:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8570F68DB6A for ; Mon, 23 Sep 2024 18:02:06 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=QvmTmNPP; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 24C924DD7 for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id jUcmrxo2u2PH for ; Mon, 23 Sep 2024 17:02:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727103724; bh=G2iGT2Cn4hIUPQ7wv/BFs8lycynHp9MedLTFiz0JOcY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QvmTmNPPCJP4AVyExEkXmiOExcUHtBgzNESipfUAySCZgLUf2t2fmpk6kozRWO42i jiB2P6+a8tBSF7x3s2zK9TYqqrU6CdrXf495TxQNEiD8QTZG8iM3TzrBoMntSDmgaS go26QA4UnSQcIB/8mNS/LD/CUIjoAV32/HJivK+ZG6uXzUUPWcmzb+ndhRGOcCASQZ D4RMvO+xWeE0cYMt2GBsjqokkweXiUMA9804yIXnkU5asEPDrssP/b3sd1ud98HFqv XQaq5Jen0y0t2iccscCmqVA/BiCiuj8USG/gSYS/1vfeAuk4sW5evTns+liGEUSAvM f51MKAm/7V03Q== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 6ADA94DF1 for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 544033A0F02 for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Sep 2024 17:01:42 +0200 Message-ID: <20240923150146.31693-4-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240923150146.31693-1-anton@khirnov.net> References: <20240923150146.31693-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/7] lavd/lavfi: use AV_BUFFERSINK_FLAG_PARAMS 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IN25DacYHERG --- libavdevice/lavfi.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 3b77a7396a..ef7d1fef1a 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -102,6 +102,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) LavfiContext *lavfi = avctx->priv_data; AVFilterInOut *input_links = NULL, *output_links = NULL, *inout; const AVFilter *buffersink, *abuffersink; + AVFrame *params = NULL; enum AVMediaType type; int ret = 0, i, n; @@ -287,33 +288,39 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) } } + params = av_frame_alloc(); + if (!params) + FAIL(AVERROR(ENOMEM)); + /* fill each stream with the information in the corresponding sink */ for (i = 0; i < lavfi->nb_sinks; i++) { AVFilterContext *sink = lavfi->sinks[lavfi->stream_sink_map[i]]; - AVRational time_base = av_buffersink_get_time_base(sink); AVRational frame_rate = av_buffersink_get_frame_rate(sink); AVStream *st = avctx->streams[i]; AVCodecParameters *const par = st->codecpar; - avpriv_set_pts_info(st, 64, time_base.num, time_base.den); + + av_frame_unref(params); + ret = av_buffersink_get_frame_flags(sink, params, AV_BUFFERSINK_FLAG_PARAMS); + if (ret < 0) + goto end; + + avpriv_set_pts_info(st, 64, params->time_base.num, params->time_base.den); par->codec_type = av_buffersink_get_type(sink); + par->format = params->format; if (par->codec_type == AVMEDIA_TYPE_VIDEO) { par->codec_id = AV_CODEC_ID_WRAPPED_AVFRAME; - par->format = av_buffersink_get_format(sink); - par->width = av_buffersink_get_w(sink); - par->height = av_buffersink_get_h(sink); + par->width = params->width; + par->height = params->height; avctx->probesize = FFMAX(avctx->probesize, sizeof(AVFrame) * 30); st ->sample_aspect_ratio = - par->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink); + par->sample_aspect_ratio = params->sample_aspect_ratio; if (frame_rate.num > 0 && frame_rate.den > 0) { st->avg_frame_rate = frame_rate; st->r_frame_rate = frame_rate; } } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) { - par->sample_rate = av_buffersink_get_sample_rate(sink); - ret = av_buffersink_get_ch_layout(sink, &par->ch_layout); - if (ret < 0) - goto end; - par->format = av_buffersink_get_format(sink); + par->sample_rate = params->sample_rate; + FFSWAP(AVChannelLayout, par->ch_layout, params->ch_layout); par->codec_id = av_get_pcm_codec(par->format, -1); if (par->codec_id == AV_CODEC_ID_NONE) av_log(avctx, AV_LOG_ERROR, @@ -326,6 +333,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) goto end; end: + av_frame_free(¶ms); avfilter_inout_free(&input_links); avfilter_inout_free(&output_links); return ret; From patchwork Mon Sep 23 15:01:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51761 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2523222vqb; Mon, 23 Sep 2024 08:09:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4uId7oe/CrrZMkmoXfRl/Mltwg2Q6BHedQRxwHv8Zq2coTPQnz0LfmZux/p598Xj19laHyAThSkiYJYYWqzoC@gmail.com X-Google-Smtp-Source: AGHT+IGqwJPK+feyBI5jwXZLHqvweQFJcZByLzYH3s9VISlhCurEvU1hhtmdYPMubnHd7+yGe+fO X-Received: by 2002:a17:907:e246:b0:a90:d1e1:eeb3 with SMTP id a640c23a62f3a-a90d50d0521mr1109611566b.44.1727104176062; Mon, 23 Sep 2024 08:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727104176; cv=none; d=google.com; s=arc-20240605; b=A3KMd9kZOkM5Wa4VZVWSI1h5lEWZoUEr1clsqPeFne1t8Z6o0bZLOmFHhfbOBUQ1Ka 6zh8WE3fJqqt2bKLwQzUBLMMBxyPxWYaf8+7AoQwBLGcdUs9jCgqj94CCSH+XxzfNK9S 5bdsV2qCWSRj7qWLghQ6AMLsgPfdQMFB1MYXZQJaXSkbDTJvP2jSgxVwq2lFoSgASVIO RIR4PbY8kCn2N/1qdPyudvtwGG5mkDh3FgcQTRicAH6kOtl6jcgj/wm+FByV/zGlSduB bicVTb9GIwhAvN/anBs9tRJgzqgtwFxJivYaJ9uQPEtEv5wT7vItSkuHYXBom5ixZRsG 1+lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding: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=xFRbxv+3HV9RowTSaAqMJRafP74f1RXGn6i3lnjKLvE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=B7dhKx4YxlFKcQIWeYmC66fbBJQzribJbxQltN4105REgJsR356PADeSXupAY8m8sG jJkZGtVqzB8m5ZYCtiFP8MGt2SdMdeNioKnSEYhuj21TfV36nugHMk62dXxrps3wTqei PA3JfkkrgUWlGmE0VRiROMCElyyhfYqAFWX4yXldzQPBDC19cEnstq8V2sPi/a/EcJRe NQ5IUSMtQ1dXSqOS+02kZgTltmhtdZgqgFC6lbU2jrgsc2P2mTWBrQYiWJGHiWzqQZkL kVL13YVeUMRPAQQwm6/+l2JPee2dVGx7Myi6EEoA/PPEFhoXMVLHR+oNoRKKBijpNHgj 7rpQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=dGuCh+ql; 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 a640c23a62f3a-a906109a74bsi1434576566b.38.2024.09.23.08.09.35; Mon, 23 Sep 2024 08:09:36 -0700 (PDT) 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=@khirnov.net header.s=mail header.b=dGuCh+ql; 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 047DF68DBCF; Mon, 23 Sep 2024 18:02:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DDFBA68DC55 for ; Mon, 23 Sep 2024 18:02:11 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=dGuCh+ql; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id C779D1F8 for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Q2Ks3vyCtLzU for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727103724; bh=t3QYQIhgETLYVbJt7SjsppQAt5GN6lhxnGMjugVhjxc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dGuCh+qloF+OkcORE90+TRaEN/2KpAzuRcVorNyxy7es86X4JHEqYxdW9/nNTJGta QGHtjvu66prhuAhTCI+ituDlaqBVD5m71AuKGEvygNdjrkhR8kFim1HR+anPBRjYUX LAWz7FSpwszHZYx7+sW34vqfxxMF7ba/dwMklcZgaMhN88lKqFeYv0pALtBSEbC+aU IDS8xRVEj+8heiVF7E6h2IAcOmqxcl/OfZsPrzJjduZchSIhqZhID6sMyRtlSwhDnj Ka0ZP7X/oc3izdz+RQP/IX0yAkmm0z7MKWkJ5BoM5JyOtMRdjODYX14Wo4ecrlAx7n rJmVWKhKyM85g== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 74D454DF5 for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5EF793A0F41 for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Sep 2024 17:01:43 +0200 Message-ID: <20240923150146.31693-5-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240923150146.31693-1-anton@khirnov.net> References: <20240923150146.31693-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/7] fftools/ffplay: use AV_BUFFERSINK_FLAG_PARAMS 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: eKKWgA0/KETT --- fftools/ffplay.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 4ea48e11bb..ef45f12906 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2702,6 +2702,7 @@ static int stream_component_open(VideoState *is, int stream_index) case AVMEDIA_TYPE_AUDIO: { AVFilterContext *sink; + AVFrame *params = NULL; is->audio_filter_src.freq = avctx->sample_rate; ret = av_channel_layout_copy(&is->audio_filter_src.ch_layout, &avctx->ch_layout); @@ -2711,10 +2712,23 @@ static int stream_component_open(VideoState *is, int stream_index) if ((ret = configure_audio_filters(is, afilters, 0)) < 0) goto fail; sink = is->out_audio_filter; - sample_rate = av_buffersink_get_sample_rate(sink); - ret = av_buffersink_get_ch_layout(sink, &ch_layout); - if (ret < 0) + + params = av_frame_alloc(); + if (!params) { + ret = AVERROR(ENOMEM); goto fail; + } + + ret = av_buffersink_get_frame_flags(sink, params, AV_BUFFERSINK_FLAG_PARAMS); + if (ret < 0) { + av_frame_free(¶ms); + goto fail; + } + + sample_rate = params->sample_rate; + FFSWAP(AVChannelLayout, ch_layout, params->ch_layout); + + av_frame_free(¶ms); } /* prepare audio output */ From patchwork Mon Sep 23 15:01:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51757 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2517513vqb; Mon, 23 Sep 2024 08:03:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXULjGUZ2rIjzoGuLwPlXQbNWtByo89HhYxD2Qwf3UUBcdWwAgl1JceMWIZSEyDcKp1YkpwXDRE6e4W5hwnC5Ob@gmail.com X-Google-Smtp-Source: AGHT+IGH6k1w8PhmkPZ5rVmA7GFgArvq8M+3izsra+1jHA7iSWL/MQlXt7pAD7UossCS8OJoZZ0h X-Received: by 2002:a05:6512:39d4:b0:535:3dae:a14b with SMTP id 2adb3069b0e04-536ac2d6610mr5169856e87.2.1727103781334; Mon, 23 Sep 2024 08:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727103781; cv=none; d=google.com; s=arc-20240605; b=cMh9DGfP343Q83J508D/LpZ1P3NzkP7zVmUJ/jhGLSqF/gftDaNKksqxh6slQmkREq +8LkqRCo4bvMnm/MBQxHLpxOMYrOaRdYYeGbgZJz0tf2eK8sHKFR8R6g4buLjaJfedGz nymJSvExQxgXV2sY7G34rD4263Xr5Vnnw0UTdI2dDXQctyqyNDMB/jfkfgStSRQqwGMg mUDTwdhlMRssNmPRBD82NK3BAepxOYJShzrWVTnwMAs3ooxHYlVTS6+n4Cf9cdAZtkaE PgCMm3TmgtPj1V0fH4XeK3iHzqdjvQli1VBXW0sINJsUwbvvlQnyi5rVUjcMaFgr+lOW xUFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding: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=PoKjYo/gmXLGgW8phU2Ek3yfJC/0TzDdvfDfWgBi8IM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=gw3jQcGZGNliDmJx3lZJ/Ar0rNGGBw8e5ZrEHyE+MccFYw1edAqmei3G3kKZ9aOFMD gvBZSwWffP+aq7RZqbP+Db6wbU8dmQw+GOnHXDfHugJdz1tZsA9aj/bfAg8zn0nLbbCI 1NcTXeHZKJDI+Di7IZore0Glm0Iu/WDTNNaW5inxDg/Z5Vp+1HEb09WGGuw17PjZO8D6 Y5wagI1G6TXmCXl0MWF4RfTTEOoC39i1IzY1st8t4pmHbu9Oys5bK43cqKK8ARMq67BQ lngDk9MoaDoOoxoUdOOo9E6mcYWoRCIl2YiY7gO79i4Dm75ZDtbzdKAb1Kk6Ute078V8 44tw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=PPZfFcVq; 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 2adb3069b0e04-536870bc334si6914155e87.588.2024.09.23.08.02.57; Mon, 23 Sep 2024 08:03:01 -0700 (PDT) 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=@khirnov.net header.s=mail header.b=PPZfFcVq; 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 6C54A68DC65; Mon, 23 Sep 2024 18:02:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D7C6F68DB6A for ; Mon, 23 Sep 2024 18:02:06 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=PPZfFcVq; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 7D50E4E0C for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id jdRJvRRXpD3y for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727103724; bh=1l8xfLVeZfqsxnE/QdN7JrwNlXDljzVd6VAYjNbg+D8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PPZfFcVqnaxO0G+xLUheiYQZUBMApIKroTcrl2bwStrjD+/2nkDa2xjl+TcWSZsFH tlx3f/g+HE6MwgabZqO1RSDNdlZ2cBYU7B98VfGparfI8Jp0CDYjsKrifufaBGgsxl cYztrlMvgQ+oF4yNQwHQkSC9Em/1XtbdL6yIQTqT9TC8XjoH5cQo4ktEbGTsjK+DES SpKIJLrsuyrXIAfX7RmZ2SbIE/jbrATzaletd5vweZcWTYaBv542V1FvMlBadDFIgt 3rpyZoEfHoEBH9c5BiJ2dtls1NRuU8fU9RyfLK4N6abPkfKxwK0Dl7FyoQWWrjcH5V eWaGupyoSbobg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 7C9524DF6 for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 69BA63A0F6F for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Sep 2024 17:01:44 +0200 Message-ID: <20240923150146.31693-6-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240923150146.31693-1-anton@khirnov.net> References: <20240923150146.31693-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/7] tools/uncoded_frame: use AV_BUFFERSINK_FLAG_PARAMS 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: o+YGqa/8IKQx --- tools/uncoded_frame.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/tools/uncoded_frame.c b/tools/uncoded_frame.c index a17d406417..39818963d0 100644 --- a/tools/uncoded_frame.c +++ b/tools/uncoded_frame.c @@ -153,6 +153,13 @@ int main(int argc, char **argv) for (; i < nb_streams; i++) streams[i].mux = streams[0].mux; + frame = av_frame_alloc(); + if (!frame) { + ret = AVERROR(ENOMEM); + av_log(NULL, AV_LOG_ERROR, "Could not allocate frame\n"); + goto fail; + } + /* Create output device streams */ for (i = 0; i < nb_streams; i++) { st = &streams[i]; @@ -161,29 +168,34 @@ int main(int argc, char **argv) av_log(NULL, AV_LOG_ERROR, "Failed to create output stream\n"); goto fail; } + + ret = av_buffersink_get_frame_flags(st->sink, frame, AV_BUFFERSINK_FLAG_PARAMS); + if (ret < 0) + goto fail; + st->stream->codecpar->codec_type = av_buffersink_get_type(st->sink); - st->stream->time_base = av_buffersink_get_time_base(st->sink); + st->stream->time_base = frame->time_base; switch (av_buffersink_get_type(st->sink)) { case AVMEDIA_TYPE_VIDEO: st->stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; st->stream->avg_frame_rate = st->stream-> r_frame_rate = av_buffersink_get_frame_rate(st->sink); - st->stream->codecpar->width = av_buffersink_get_w(st->sink); - st->stream->codecpar->height = av_buffersink_get_h(st->sink); - st->stream->codecpar->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(st->sink); - st->stream->codecpar->format = av_buffersink_get_format(st->sink); + st->stream->codecpar->width = frame->width; + st->stream->codecpar->height = frame->height; + st->stream->codecpar->sample_aspect_ratio = frame->sample_aspect_ratio; + st->stream->codecpar->format = frame->format; break; case AVMEDIA_TYPE_AUDIO: - ret = av_buffersink_get_ch_layout(st->sink, &st->stream->codecpar->ch_layout); - if (ret < 0) - goto fail; - st->stream->codecpar->sample_rate = av_buffersink_get_sample_rate(st->sink); - st->stream->codecpar->format = av_buffersink_get_format(st->sink); + FFSWAP(AVChannelLayout, st->stream->codecpar->ch_layout, frame->ch_layout); + st->stream->codecpar->sample_rate = frame->sample_rate; + st->stream->codecpar->format = frame->format; st->stream->codecpar->codec_id = av_get_pcm_codec(st->stream->codecpar->format, -1); break; default: av_assert0(!"reached"); } + + av_frame_unref(frame); } /* Init output devices */ @@ -222,11 +234,6 @@ int main(int argc, char **argv) for (i = 0; i < nb_streams; i++) { st = &streams[i]; while (1) { - if (!frame && !(frame = av_frame_alloc())) { - ret = AVERROR(ENOMEM); - av_log(NULL, AV_LOG_ERROR, "Could not allocate frame\n"); - goto fail; - } ret = av_buffersink_get_frame_flags(st->sink, frame, AV_BUFFERSINK_FLAG_NO_REQUEST); if (ret < 0) { From patchwork Mon Sep 23 15:01:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51758 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2522995vqb; Mon, 23 Sep 2024 08:09:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWy1wkg2/7AFASHyCX4neBnfpZCu0S3fvzUZHF7CuxGCRd6YpVi7qNP3adYDx4yY2M3+AKBNb6NgahlcFjErPjJ@gmail.com X-Google-Smtp-Source: AGHT+IFU50bcL7vh6X22wadS12WYd/XBHDdmo8OBTXiS8c9YfQe3/zo5eDX22suvgWxem2hEoEcU X-Received: by 2002:a17:907:9708:b0:a83:8591:7505 with SMTP id a640c23a62f3a-a90d5167dc8mr1408500066b.59.1727104158373; Mon, 23 Sep 2024 08:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727104158; cv=none; d=google.com; s=arc-20240605; b=MZ++4WLf6xeljW+M6GiFSBgtf8NxM1joHHv3lTgo5dmRBXx0zt4lITFuW2/EY0Nr8M /xdq/YJuMfE6G3WiVKwkVqWWHfNQTxXWMZqdgFgW2XXBnVrg9GbbSLhyWzGIzlRGmgpI dzSR3pIOxGdVtVJ2zoKcva3TXYqSJBMxp1FHh5CmD5PKnKK9+m5HDlbRh5PCUAe9eqHj E9ETT6tCO4fPHt7rWswqZbkQ55XCIRO1FQDRYKnsGGz6Jv4Vf1S6+vIvTmO/DM79CLrT eqewSeBSG76ShCunRpGf/5PuQxaJ9qe5Yzjb/SOH5uP8g5CSAHCykjQdBzIrd0cdbaa5 OCbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding: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=3rOkmATwEZDRgFDw2yVDtZwDAwox+XD9cvnvd5z+QSY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Wpbu2X86RHwJzj5azhnpWJVG5xCMGNHx2C3MFP9mk/0Xu5tnRja4zB/1yWCY/3UbSl HK2/r5OFpSGWRhRw6gfchQWLUlOfkcOd9sxekNAIBXIyMon7YbsBXNkb1rwanI0Yt0Wy xhB5eXL2cuwomBGSFywwBODnwYGjl7dB4sxo7vbOmS1DQKzD2eljZRARW7T0y2393tie efCgjKKJf/QFBhU9g4PMP6VAtrIdsITrd1Y6lyXP6inN6vNAxkRDqGRsm37pF1aAvd4T sZsRietjwRkx0wq8Jp4mTGW24tldI85TAfBDdCP2YXGxLo7/pC84ruq2p7buuBRKQ6bw zJlw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=c5wdmmYJ; 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 a640c23a62f3a-a906133a224si1369568466b.820.2024.09.23.08.09.18; Mon, 23 Sep 2024 08:09:18 -0700 (PDT) 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=@khirnov.net header.s=mail header.b=c5wdmmYJ; 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 535D668D9FD; Mon, 23 Sep 2024 18:02:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF5D568DC59 for ; Mon, 23 Sep 2024 18:02:11 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=c5wdmmYJ; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id F39AB4DF1 for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id EgtXt_J7cOzS for ; Mon, 23 Sep 2024 17:02:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727103724; bh=ydQRzTHD6KvUa4CWbJvQgpFY57IrrPx5xHoC3FwvDAk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=c5wdmmYJQVmxAp41LJ6gT9MHs1qqTyfjzr1ep0IRA4r3RkP8u/hJoTZCEHyh5oRt4 gGKYKJXAFsNg0lZCersE7fC4/GUQZw8UTZNePOsY92erECXJAMLJwSZP/9EchSmUBm PRftt86R29MdTgKLCz5HoYW0vIMoSdNeuPjk5ct0xcL8B0SGfqE3K4w9JSS4dJyYrB vledlUSLEboy2jhUfLraU7GpBq2ywXhcIRD9H9RYrwaHESs7CNPcfALjmuflAa8eal z5q51MbRn6NAesDnorE9uKhqvOAZUIyU2l7EBMK8l9hgqRfnCXjOM4WTLEJ/VIceML KnAGoNDofGPFw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 992B04E0A for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 747B63A164C for ; Mon, 23 Sep 2024 17:02:04 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Sep 2024 17:01:45 +0200 Message-ID: <20240923150146.31693-7-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240923150146.31693-1-anton@khirnov.net> References: <20240923150146.31693-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/7] lavfi/buffersink: deprecate functions obsoleted by AV_BUFFERSINK_FLAG_PARAMS 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: j9gUtBT0d/h5 That is all av_buffersink_get_*() except type and frame_rate, for which AVFrame does not currently have fields. --- doc/APIchanges | 12 +++++++++++- libavfilter/buffersink.c | 4 ++++ libavfilter/buffersink.h | 19 ++++++++++++++++++- libavfilter/version_major.h | 1 + 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5ddd7189f8..971750bfe7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -4,7 +4,17 @@ API changes, most recent first: 2024-09-xx - xxxxxxxxxx - lavfi 10.4.100 Buffersink now sets AVFrame.time_base on the frames it outputs. - Add AV_BUFFERSINK_FLAG_PARAMS. + Add AV_BUFFERSINK_FLAG_PARAMS; deprecate + - av_buffersink_get_time_base() + - av_buffersink_get_w() + - av_buffersink_get_h() + - av_buffersink_get_sample_aspect_ratio() + - av_buffersink_get_colorspace() + - av_buffersink_get_color_range() + - av_buffersink_get_channels() + - av_buffersink_get_channel_layout() + - av_buffersink_get_sample_rate() + - av_buffersink_get_hw_frames_ctx() 2024-09-23 - xxxxxxxxxx - lavc 61.18.100 - avcodec.h Add a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index d9cd074f17..e0c32d5f10 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -234,6 +234,7 @@ type av_buffersink_get_##field(const AVFilterContext *ctx) { \ } MAKE_AVFILTERLINK_ACCESSOR(enum AVMediaType , type ) +#if FF_API_BUFFERSINK_GET MAKE_AVFILTERLINK_ACCESSOR(AVRational , time_base ) MAKE_AVFILTERLINK_ACCESSOR(int , format ) @@ -244,6 +245,7 @@ MAKE_AVFILTERLINK_ACCESSOR(enum AVColorSpace, colorspace) MAKE_AVFILTERLINK_ACCESSOR(enum AVColorRange, color_range) MAKE_AVFILTERLINK_ACCESSOR(int , sample_rate ) +#endif AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx) { @@ -252,6 +254,7 @@ AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx) return l->frame_rate; } +#if FF_API_BUFFERSINK_GET AVBufferRef* av_buffersink_get_hw_frames_ctx(const AVFilterContext *ctx) { FilterLink *l = ff_filter_link(ctx->inputs[0]); @@ -277,6 +280,7 @@ int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out *out = ch_layout; return 0; } +#endif #define CHECK_LIST_SIZE(field) \ if (buf->field ## _size % sizeof(*buf->field)) { \ diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index 9c4468af5b..ef5aae8857 100644 --- a/libavfilter/buffersink.h +++ b/libavfilter/buffersink.h @@ -124,22 +124,39 @@ void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size); */ enum AVMediaType av_buffersink_get_type (const AVFilterContext *ctx); +AVRational av_buffersink_get_frame_rate (const AVFilterContext *ctx); + +#if FF_API_BUFFERSINK_GET +/** + * @deprecated Use av_buffersink_get_frame_flags() with AV_BUFFERSINK_FLAG_PARAMS + */ +attribute_deprecated AVRational av_buffersink_get_time_base (const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_format (const AVFilterContext *ctx); -AVRational av_buffersink_get_frame_rate (const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_w (const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_h (const AVFilterContext *ctx); +attribute_deprecated AVRational av_buffersink_get_sample_aspect_ratio (const AVFilterContext *ctx); +attribute_deprecated enum AVColorSpace av_buffersink_get_colorspace (const AVFilterContext *ctx); +attribute_deprecated enum AVColorRange av_buffersink_get_color_range (const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_channels (const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_ch_layout (const AVFilterContext *ctx, AVChannelLayout *ch_layout); +attribute_deprecated int av_buffersink_get_sample_rate (const AVFilterContext *ctx); +attribute_deprecated AVBufferRef * av_buffersink_get_hw_frames_ctx (const AVFilterContext *ctx); +#endif /** @} */ diff --git a/libavfilter/version_major.h b/libavfilter/version_major.h index c5e660eeda..0ca3b0e358 100644 --- a/libavfilter/version_major.h +++ b/libavfilter/version_major.h @@ -36,5 +36,6 @@ */ #define FF_API_LINK_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11) +#define FF_API_BUFFERSINK_GET (LIBAVFILTER_VERSION_MAJOR < 11) #endif /* AVFILTER_VERSION_MAJOR_H */