From patchwork Sun Nov 27 17:03:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39572 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a05:6a11:561f:b0:33d:fc04:f431 with SMTP id rr31csp8295778pxb; Sun, 27 Nov 2022 09:09:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf6bjxNM5z8QgRwTqQna8K2TjZs6hfW6bOur1NayIVpWMGdd0Fo6rO/0VSlrRUiZhH6D6lQx X-Received: by 2002:aa7:dbc7:0:b0:45f:b80f:1fe8 with SMTP id v7-20020aa7dbc7000000b0045fb80f1fe8mr42573844edt.118.1669568981600; Sun, 27 Nov 2022 09:09:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669568981; cv=none; d=google.com; s=arc-20160816; b=oSddTAEbDjJIaFV50tcXew8WnpQyvZTeQqpXZ2zn+lG5C7cBofouqWYFLPRE8MToNs N+BivGTB2LaSTnZ0MUa5r9+qJhLMwqdm5J0Gi+DTTa6SNTfD7dCMt1FzcifA0U9AyKHp Ck7V4XgoMEzdoH30jHddKHhqfXDAYkRu+UbeiXaPitqJcwp5MJxXLLZkn/Vb0LbPiIQZ QLi+N/fiCHFFx8ENfzRhZlQ+bv8qJbUqyFqHj76xx4n+HRO0Qo2Yw+OUz5ASD2VDyhcE 5mB53h5N8sUY1HDM5qsnZ7nPB4R3eXHSi9+H1zWAaRIlvBQX51l/kxRQD4y6LL7d1lsQ Ww5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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:delivered-to; bh=FEv8wuDwktNjlLLbPTaj7QJdfMMqD5b5gZLKWlcg5F4=; b=O2fKRQ3JsIQBTPUHM2cNWWN77k7U7tnbewcc8jU9PGiITu3Uo60qNvoQLDXOXMHDAR R3uD2j4+jXn3qD42nLr+jpc0fbRdGBILnZ+XEKWT4/8zQEKSX0T18kcLdAri7K56u4Ku SuGd5m3yz+3bIZXbQlWUiyn+7HE48Ij+uBNANsCWIpgi7pnjrfZfYUkwGc1/5rZqRYfR ivnz8Sz6etpaos/E95EyEoUvB1J0vTnRcpZ8YOPa6slJFoidaMUUNLBrfEbXlXm4CeBG GSSqM0mCYUc7vy8ykbKwgkXNf5TW5IjtBiarG+G2H/U4VVIyOH2XoXDqHsqBA71XTqt7 3Shw== ARC-Authentication-Results: i=1; mx.google.com; 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 g8-20020a056402090800b0046900e66a54si9005493edz.517.2022.11.27.09.09.41; Sun, 27 Nov 2022 09:09:41 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; 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 B912F68BC81; Sun, 27 Nov 2022 19:06:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 387EC68BA53 for ; Sun, 27 Nov 2022 19:06:03 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5917A2405EC for ; Sun, 27 Nov 2022 18:06:03 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Ck-DIyo_eKR3 for ; Sun, 27 Nov 2022 18:06:02 +0100 (CET) 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 mail0.khirnov.net (Postfix) with ESMTPS id F0FC9240D20 for ; Sun, 27 Nov 2022 18:05:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D46193A25FC for ; Sun, 27 Nov 2022 18:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Nov 2022 18:03:44 +0100 Message-Id: <20221127170351.11477-23-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221127170351.11477-1-anton@khirnov.net> References: <20221127170351.11477-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/30] lavc/ffv1enc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE 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: 2cH7XGD5IhC7 Content-Length: 1647 --- libavcodec/ffv1enc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 0237ac48eb..553abb558f 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1233,7 +1233,20 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, pkt->size = buf_p - pkt->data; pkt->pts = pkt->dts = pict->pts; + pkt->duration = pict->duration; pkt->flags |= AV_PKT_FLAG_KEY * f->key_frame; + + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + pkt->opaque = pict->opaque; + if (pict->opaque_ref) { + pkt->opaque_ref = av_buffer_ref(pict->opaque_ref); + if (!pkt->opaque_ref) + return AVERROR(ENOMEM); + } + } + + avctx->reordered_opaque = pict->reordered_opaque; + *got_packet = 1; return 0; @@ -1272,7 +1285,8 @@ const FFCodec ff_ffv1_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FFV1, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | - AV_CODEC_CAP_SLICE_THREADS, + AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(FFV1Context), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame),