From patchwork Wed Jan 25 16:55:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40109 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546422pzj; Wed, 25 Jan 2023 08:56:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXuUchhjmctx3mDBCZbMiCeIcSY6Yr+UKk99sIf4L2KZVRs1XCsjkWsyrgZKdq+QzIY/4+/7 X-Received: by 2002:a05:6402:10c4:b0:48e:94ec:b7ac with SMTP id p4-20020a05640210c400b0048e94ecb7acmr31158470edu.7.1674665814195; Wed, 25 Jan 2023 08:56:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665814; cv=none; d=google.com; s=arc-20160816; b=RIWZEDc4E6OwxRTesUi1hbaE+1giN+JK+T9X3xh9I40C2mb91S45B8nZls1eJnDkoR A3RMzNFVzXDaxHKFltkBB/XSiHxPQ0QUOzzMsUrtQoBTdyFhXfhLIwL9vYkh6NswG1AF nSvT6a2Srro2p7I8loBMQzym4jbOVgy3zhNL2Wt2eYn38zXTLg8Rc93AoeCxYM/gxati INQnEUpKgCJ93+EFgrWUhnHFLwbOZ9/Um3347dTALEmI7gAU4OAlbxJhsSFYdAKDkqs7 mPRwHWh5lZhr0iCfZSHwhLx+I6urKZuo7x5Ok4Kw1/hLZT1U5m5+/C8qgjvA/7nNvwTG RXwA== 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:message-id:date:to:from :delivered-to; bh=F6FQGtVBrcCNhfndonWoi5lDu/I99PUj/9qDcpj1YX4=; b=vvIGXrNv2MTzYh9Lgp3Yx8l1ic7LQHz/QSrX1lHB65shjn0YsZhSbBac1BWpg5iXX6 7M9k86BlNrfMSBd1+KehBj5y4/HG1h9k2Z935u4PP+d9L3TX7UMwBKWvlBSU8Am59d9b B9uCvy3a8kyvBAQ4YBd8RepJDMR3SG2Po21lla6wJVkOr8fCCmJS5uRskPpiAmXUwYrr Gi0PIhVhyFXV5boTIKeGNSpvrhws07/sMsT0gpDKFvZ/QoLZOqIjQ86Cp+IvItP2zksO E6nnwTcGVs2HRUDUkrUXiGN1ZTc1H74LHR9GiuDzhaVIN91grviOyI5JcNQwe6i920sE ykOA== 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 p17-20020aa7cc91000000b0048475139291si6506957edt.590.2023.01.25.08.56.53; Wed, 25 Jan 2023 08:56:54 -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 05B1D68BD7C; Wed, 25 Jan 2023 18:56: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 D927D68BBEB for ; Wed, 25 Jan 2023 18:56:14 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9E8FF2404F8 for ; Wed, 25 Jan 2023 17:56:14 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 5O0WSnRxMISl for ; Wed, 25 Jan 2023 17:56:12 +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 F3CAB2404F5 for ; Wed, 25 Jan 2023 17:56:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 7F4963A02AF for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:19 +0100 Message-Id: <20230125165537.5371-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/19] lavc/avcodec: improve enc/dec API doxy 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: PylYXZxSOeRu Change return value descriptions into proper lists. --- libavcodec/avcodec.h | 81 +++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0ac581d660..f3ca41f126 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2605,17 +2605,18 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, * still has frames buffered, it will return them after sending * a flush packet. * - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): input is not accepted in the current state - user - * must read output with avcodec_receive_frame() (once - * all output is read, the packet should be resent, and - * the call will not fail with EAGAIN). - * AVERROR_EOF: the decoder has been flushed, and no new packets can - * be sent to it (also returned if more than 1 flush - * packet is sent) - * AVERROR(EINVAL): codec not opened, it is an encoder, or requires flush - * AVERROR(ENOMEM): failed to add packet to internal queue, or similar - * other errors: legitimate decoding errors + * @return + * - 0: success + * - AVERROR(EAGAIN): input is not accepted in the current state - user must + * read output with avcodec_receive_frame() (once all + * output is read, the packet should be resent, and the + * call will not fail with EAGAIN). + * - AVERROR_EOF: the decoder has been flushed, and no new packets can be + * sent to it (also returned if more than 1 flush packet is + * sent) + * - AVERROR(EINVAL): codec not opened, it is an encoder, or requires flush + * - AVERROR(ENOMEM): failed to add packet to internal queue, or similar + * - other errors: legitimate decoding errors */ int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); @@ -2630,17 +2631,17 @@ int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); * av_frame_unref(frame) before doing anything else. * * @return - * 0: success, a frame was returned - * AVERROR(EAGAIN): output is not available in this state - user must try - * to send new input - * AVERROR_EOF: the codec has been fully flushed, and there will be - * no more output frames - * AVERROR(EINVAL): codec not opened, or it is an encoder without - * the AV_CODEC_FLAG_RECON_FRAME flag enabled - * AVERROR_INPUT_CHANGED: current decoded frame has changed parameters - * with respect to first decoded frame. Applicable - * when flag AV_CODEC_FLAG_DROPCHANGED is set. - * other negative values: legitimate decoding errors + * - 0: success, a frame was returned + * - AVERROR(EAGAIN): output is not available in this state - user must + * try to send new input + * - AVERROR_EOF: the codec has been fully flushed, and there will be + * no more output frames + * - AVERROR(EINVAL): codec not opened, or it is an encoder without the + * AV_CODEC_FLAG_RECON_FRAME flag enabled + * - AVERROR_INPUT_CHANGED: current decoded frame has changed parameters with + * respect to first decoded frame. Applicable when flag + * AV_CODEC_FLAG_DROPCHANGED is set. + * - other negative values: legitimate decoding errors */ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); @@ -2667,16 +2668,17 @@ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); * If it is not set, frame->nb_samples must be equal to * avctx->frame_size for all frames except the last. * The final frame may be smaller than avctx->frame_size. - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): input is not accepted in the current state - user - * must read output with avcodec_receive_packet() (once - * all output is read, the packet should be resent, and - * the call will not fail with EAGAIN). - * AVERROR_EOF: the encoder has been flushed, and no new frames can - * be sent to it - * AVERROR(EINVAL): codec not opened, it is a decoder, or requires flush - * AVERROR(ENOMEM): failed to add packet to internal queue, or similar - * other errors: legitimate encoding errors + * @return + * - 0: success + * - AVERROR(EAGAIN): input is not accepted in the current state - user must + * read output with avcodec_receive_packet() (once all + * output is read, the packet should be resent, and the + * call will not fail with EAGAIN). + * - AVERROR_EOF: the encoder has been flushed, and no new frames can + * be sent to it + * - AVERROR(EINVAL): codec not opened, it is a decoder, or requires flush + * - AVERROR(ENOMEM): failed to add packet to internal queue, or similar + * - other errors: legitimate encoding errors */ int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); @@ -2687,13 +2689,14 @@ int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); * @param avpkt This will be set to a reference-counted packet allocated by the * encoder. Note that the function will always call * av_packet_unref(avpkt) before doing anything else. - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): output is not available in the current state - user - * must try to send input - * AVERROR_EOF: the encoder has been fully flushed, and there will be - * no more output packets - * AVERROR(EINVAL): codec not opened, or it is a decoder - * other errors: legitimate encoding errors + * @return + * - 0: success + * - AVERROR(EAGAIN): output is not available in the current state - user must + * try to send input + * - AVERROR_EOF: the encoder has been fully flushed, and there will be no + * more output packets + * - AVERROR(EINVAL): codec not opened, or it is a decoder + * - other errors: legitimate encoding errors */ int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt); From patchwork Wed Jan 25 16:55:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40106 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546167pzj; Wed, 25 Jan 2023 08:56:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtvE160KKJCRtPyVqGPDUP4aTdaex+YlfiRmcjuBdwUPvjYjVdpwwJPKtTC3lxc5M7NgoFp X-Received: by 2002:a17:906:7e14:b0:86e:2c11:9bce with SMTP id e20-20020a1709067e1400b0086e2c119bcemr34731525ejr.38.1674665786261; Wed, 25 Jan 2023 08:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665786; cv=none; d=google.com; s=arc-20160816; b=Q6IL8jYMBmTFCkEmyxFgKFJEgHlwpvL45yE1L89R+jLUaP7tgmgdlOyjxzlZ9zHNkT ZQxzMIpeOoGLiuK53gNvInHRcBsG3A+T+e11ygP/9venqRSmyXXPe/8WJtA59ZbS+OJe GqGllW+OyTI5xEBZS1mZiYaOo96OorKaFG/a/VH91mT6/qiymmHUZD4mCWXJeGovF0Hh fdsnz+jgR2Aj7OK67sRednfXU+amDnnMVK1cY5Ol11QhiTLrhtOT11pz5EyY2tYA5q3P QvLOr91CcHFY5PNi/c4sq9onkGs9GlAAboX2i7xGTmlEqDtJ+doHbTlIKGbZ3NQSKDiP bUOQ== 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=Yv06mY/V4dxnCi7qAg5+9gfT9tSlHSWvhyY5rNRBvF8=; b=O2sl262mz7c/w8v0nF0AJkaxkP/XQjoFqvQuzZg+MaRA4MbqLCXNkyTULQiTAbmbr5 gccd9iiIsgZhQAIuXsDagfJSZQRPlyELk2o3Lr3JqUgzakvwDuqa8G4/evO4pfvKKvkB G/jaFiyafrKl9aJC1D/YB2gOvzmD7jtlDirqRJL7K9q0YCnFFoD3cYTsV8Jq8xXUKuER tqwnv1kysh5CD7VITLSR5se7O2Uj0tXRh3EeKi1M2h9d28HdjfQqiET91N1CRxceSAcT +qhTVOZTHUN3mGHf8ONBfSDchwe9ym2g0uiMntdkgKjuREPLoZQNRIjhphw4Hj3g6GkI KB8g== 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 up10-20020a170907cc8a00b0087189500087si6192221ejc.47.2023.01.25.08.56.25; Wed, 25 Jan 2023 08:56:26 -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 C5EA568BD1E; Wed, 25 Jan 2023 18:56:20 +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 D137068BAEB for ; Wed, 25 Jan 2023 18:56:13 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9A419240D1A for ; Wed, 25 Jan 2023 17:56:12 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Kvn5IU2xyOax for ; Wed, 25 Jan 2023 17:56:05 +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 F1C122404EC for ; Wed, 25 Jan 2023 17:56:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8D48D3A0344 for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:20 +0100 Message-Id: <20230125165537.5371-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/19] lavc/avcodec: improve AV_CODEC_FLAG_RECON_FRAME doxy 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: F6ddsIxJC+p8 Do not break a sentence on a period after "i.e.". Link to the definition of AV_CODEC_CAP_ENCODER_RECON_FRAME. --- libavcodec/avcodec.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index f3ca41f126..e11e0ae3ee 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -232,13 +232,13 @@ typedef struct RcOverride{ */ #define AV_CODEC_FLAG_DROPCHANGED (1 << 5) /** - * Request the encoder to output reconstructed frames, i.e. frames that would be - * produced by decoding the encoded bistream. These frames may be retrieved by - * calling avcodec_receive_frame() immediately after a successful call to + * Request the encoder to output reconstructed frames, i.e.\ frames that would + * be produced by decoding the encoded bistream. These frames may be retrieved + * by calling avcodec_receive_frame() immediately after a successful call to * avcodec_receive_packet(). * * Should only be used with encoders flagged with the - * AV_CODEC_CAP_ENCODER_RECON_FRAME capability. + * @ref AV_CODEC_CAP_ENCODER_RECON_FRAME capability. */ #define AV_CODEC_FLAG_RECON_FRAME (1 << 6) /** From patchwork Wed Jan 25 16:55:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40107 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546263pzj; Wed, 25 Jan 2023 08:56:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXsepI6+45U7QGIpQJggejAK6Y8qZ+but4IZQvmh2QwK+mUiz/Xddg0MyoVPWNaQAFPYAmjR X-Received: by 2002:a17:906:ca16:b0:877:6a03:9ad4 with SMTP id jt22-20020a170906ca1600b008776a039ad4mr26362752ejb.56.1674665796647; Wed, 25 Jan 2023 08:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665796; cv=none; d=google.com; s=arc-20160816; b=RTe48aqV7c95tak33BiifZa5O2awnmtGG12EBOfPREKafdmvZRp/Fc8pAEvGgeIr6B yfjJnwE2D2/8qyJwffNiI8D6ZV7hT7kC8mwDerEDc6JbGLcXODimc5UNLIveAWWv4ZPU 5uiVurW8rkGMKDexcwe2KiOsweuTomnxmpoju86DoKZdQgHr9kKAUVQ83ppKhsoxXeFf dyBeuE+3ocnkX3x23FBEhlDxfYwU9Q1MEra/WCCbAYQqW6onzSLSsywFEc9FMOW2DnSY VHusa6JRXwOlZdQV+He2IvXyO1Jvfe4U2i9Si4GfMa0G+X+O26/MPfBxCTl6SpFW5Wpv qZ6A== 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=cb35MBkDAGdGiw3BQqY54Ic1ao+W7kB81lVikjYy+5A=; b=iGfdVmdeZBWA8o/3X7ZHdOP3Ujb5+ZtoVZ6AOxM3U3DlNPFI0p+8Z44fAfZ6x9XFET NvLSOX2L3SY+DULeCe+ttV1RgkiCHnWfqjRcx3u9b2dIyv97sqZS/tXKKqDgbZMxdNa+ FczC6GFpSmNpEVnAmWO31GbRAxCFsOyek+bwfZys62R4twOHwc8FkvYBScsswbrfjBNZ KyBOnZ+I8qxpGyhUHlWCO6IYGZ604ukIaMLSvgvE/mYLPr8Gn0Uz/NMQiJw7ndITdl84 HJ6vqHmWzpitlGnsegZPpOAPZ6hXSEU7GcVWylKSXdczyBKB7mGflG6EdJbRJo4hyWn3 Lx3g== 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 y15-20020a170906518f00b0087852bdea4csi100974ejk.839.2023.01.25.08.56.36; Wed, 25 Jan 2023 08:56:36 -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 0475368B440; Wed, 25 Jan 2023 18:56:22 +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 D4A8168BBEB for ; Wed, 25 Jan 2023 18:56:13 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7369B2404EC for ; Wed, 25 Jan 2023 17:56:13 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 2rBdiawGB2qn for ; Wed, 25 Jan 2023 17:56:05 +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 EE2B1240178 for ; Wed, 25 Jan 2023 17:56:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 98A7D3A034A for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:21 +0100 Message-Id: <20230125165537.5371-3-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/19] lavc: add a private cap for fake-delay encoders 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: GujWUeEg4jOs Some encoders (ffv1, flac, adx) are marked with AV_CODEC_CAP_DELAY onky in order to be flushed at the end, otherwise they behave as no-delay encoders. Add a capability to mark these encoders. Use it for setting pts generically. --- libavcodec/adxenc.c | 3 +-- libavcodec/codec_internal.h | 8 ++++++++ libavcodec/encode.c | 6 ++++-- libavcodec/ffv1enc.c | 4 +--- libavcodec/flacenc.c | 7 ++----- libavcodec/tests/avcodec.c | 4 ++++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index 153c91b852..6e12a58b16 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -183,8 +183,6 @@ static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, dst += BLOCK_SIZE; } - avpkt->pts = frame->pts; - avpkt->duration = frame->nb_samples; *got_packet_ptr = 1; return 0; } @@ -200,4 +198,5 @@ const FFCodec ff_adpcm_adx_encoder = { FF_CODEC_ENCODE_CB(adx_encode_frame), .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_EOF_FLUSH, }; diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index e3b77e6dea..130a7dc3cd 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -80,6 +80,14 @@ * Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE). */ #define FF_CODEC_CAP_ICC_PROFILES (1 << 9) +/** + * The encoder has AV_CODEC_CAP_DELAY set, but does not actually have delay - it + * only wants to be flushed at the end to update some context variables (e.g. + * 2pass stats) or produce a trailing packet. Besides that it immediately + * produces exactly one output packet per each input frame, just as no-delay + * encoders do. + */ +#define FF_CODEC_CAP_EOF_FLUSH (1 << 10) /** * FFCodec.codec_tags termination value diff --git a/libavcodec/encode.c b/libavcodec/encode.c index fbe2c97cd6..e0b3e43840 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -211,7 +211,8 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, // set the timestamps for the simple no-delay case // encoders with delay have to set the timestamps themselves - if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || + (frame && (codec->caps_internal & FF_CODEC_CAP_EOF_FLUSH))) { if (avpkt->pts == AV_NOPTS_VALUE) avpkt->pts = frame->pts; @@ -225,7 +226,8 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, // dts equals pts unless there is reordering // there can be no reordering if there is no encoder delay if (!(avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) || - !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) + !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || + (codec->caps_internal & FF_CODEC_CAP_EOF_FLUSH)) avpkt->dts = avpkt->pts; } else { unref: diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 0237ac48eb..6649ec7e88 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1231,8 +1231,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, f->picture_number++; pkt->size = buf_p - pkt->data; - pkt->pts = - pkt->dts = pict->pts; pkt->flags |= AV_PKT_FLAG_KEY * f->key_frame; *got_packet = 1; @@ -1301,5 +1299,5 @@ const FFCodec ff_ffv1_encoder = { }, .p.priv_class = &ffv1_class, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_EOF_FLUSH, }; diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 8aacc93e28..9a9835dfa6 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1690,10 +1690,7 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (out_bytes < s->min_framesize) s->min_framesize = out_bytes; - avpkt->pts = frame->pts; - avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); - - s->next_pts = avpkt->pts + avpkt->duration; + s->next_pts = frame->pts + ff_samples_to_time_base(avctx, frame->nb_samples); av_shrink_packet(avpkt, out_bytes); @@ -1766,5 +1763,5 @@ const FFCodec ff_flac_encoder = { AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, .p.priv_class = &flac_encoder_class, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_EOF_FLUSH, }; diff --git a/libavcodec/tests/avcodec.c b/libavcodec/tests/avcodec.c index 3288a85f64..4c1730425d 100644 --- a/libavcodec/tests/avcodec.c +++ b/libavcodec/tests/avcodec.c @@ -158,6 +158,10 @@ int main(void){ if (codec->capabilities & AV_CODEC_CAP_FRAME_THREADS && codec->capabilities & AV_CODEC_CAP_DELAY) ERR("Frame-threaded encoder %s claims to have delay\n"); + + if (codec2->caps_internal & FF_CODEC_CAP_EOF_FLUSH && + !(codec->capabilities & AV_CODEC_CAP_DELAY)) + ERR("EOF_FLUSH encoder %s is not marked as having delay\n"); } else { if ((codec->type == AVMEDIA_TYPE_SUBTITLE) != (codec2->cb_type == FF_CODEC_CB_TYPE_DECODE_SUB)) ERR("Subtitle decoder %s does not implement decode_sub callback\n"); From patchwork Wed Jan 25 16:55:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40108 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546360pzj; Wed, 25 Jan 2023 08:56:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXs6HMoCB3tVGp4lo4ixCG8uoSramPZwG556pOZdlVypbaKSXS4j5S+ZRy8js6eVzDQGrZKl X-Received: by 2002:a17:907:8d18:b0:7c0:d6b6:1ee9 with SMTP id tc24-20020a1709078d1800b007c0d6b61ee9mr38195700ejc.11.1674665806143; Wed, 25 Jan 2023 08:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665806; cv=none; d=google.com; s=arc-20160816; b=GkT32CSjiZUSBiRF0y2KtMwoMYnYHQ0D8C2qt+uDad24PLvLME5dH9Vcl89n/iKRyJ kFza/FgepGQoArbtw+ICNsrKOpWkgMee/BylBgOEBmkxSKLmnQ2K2D4GVkTTAHb7eoIa umUJZSwjZznTxA11VdoYrAz1hPphPld9CV+arvnCBddFnWy5VIewfbXjc7H2v6Tr/vqk EiY8Hnoglej+nKLIPUlbDPXuEVSgXhr7jdaVDScXGVJfRelbLLppkwpyJNJZbCeR2tcK 4mSnzStqgRZwQnZnmLghYjlSc41VeYQSTvZMkU2Tn4SMEEGOFcFigqxwX63wBUrzKhy2 LbuA== 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=lPfcw7BZdArBLUsvj9+TBWPwvz0COmxeYMELup7ZfvA=; b=wYCzUEcdEU8y9bY78qm9l11OsDZTwsp/XMFc0/XV1LyCmMAyqUMjfBy3fJNXnCwvGn ElwsKxWjDfowrkZi6ViNXsxj2nQ+hvN1C+0nIjA1mFsMmW+fIhCL2qPNRSOMfBBlajix TKtDJ9xXAfUjK4iD4UqqyELKNL7t/GZXgtIcrHaBUaMes2Kt8gxAB9JvGlRKSf2kg6kj 3Y2eaIVUzWbjXzVUwltOyB9h0zQFog/9ASl2BZCC+2VDJMVGXcTfQ5s61qvwvBi7DQrD G31k2VFf3APsNItS6FoD/LQTsJ1DBPHcVKCL/7zTiYLWPzSKZxY96MhC1ejhSEzYi0hc 1hnA== 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 29-20020a170906025d00b007c08bfea555si7544797ejl.121.2023.01.25.08.56.45; Wed, 25 Jan 2023 08:56:46 -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 13DD368BD50; Wed, 25 Jan 2023 18:56:23 +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 ADF6268BBEB for ; Wed, 25 Jan 2023 18:56:14 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6AF3A240178 for ; Wed, 25 Jan 2023 17:56:14 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id rXLBVMUe95-u for ; Wed, 25 Jan 2023 17:56:13 +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 027552404F8 for ; Wed, 25 Jan 2023 17:56:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A49433A034C for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:22 +0100 Message-Id: <20230125165537.5371-4-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/19] lavc: add a codec flag for propagating opaque from frames to packets 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: NcVe3IGV3hHA This is intended to be a more convenient replacement for reordered_opaque. Add support for it in the two encoders that offer AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE: libx264 and libx265. Other encoders will be supported in future commits. --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 26 +++++++++++++++++++++++ libavcodec/encode.c | 7 +++++++ libavcodec/libx264.c | 29 ++++++++++++++++++++++++++ libavcodec/libx265.c | 42 ++++++++++++++++++++++++++++---------- libavcodec/options_table.h | 1 + libavcodec/version.h | 2 +- 7 files changed, 98 insertions(+), 12 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index a11acadecd..f52337990f 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2023-01-xx - xxxxxxxxxx - lavc 59.57.100 - avcodec.h + Add AV_CODEC_FLAG_COPY_OPAQUE. + 2023-01-13 - xxxxxxxxxx - lavu 57.44.100 - ambient_viewing_environment.h frame.h Adds a new structure for holding H.274 Ambient Viewing Environment metadata, AVAmbientViewingEnvironment. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e11e0ae3ee..54ab7b81f9 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -241,6 +241,32 @@ typedef struct RcOverride{ * @ref AV_CODEC_CAP_ENCODER_RECON_FRAME capability. */ #define AV_CODEC_FLAG_RECON_FRAME (1 << 6) +/** + * Request the encoder to propagate each frame's AVFrame.opaque and + * AVFrame.opaque_ref values to its corresponding output AVPacket. + * + * May only be set on encoders that have the + * @ref AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability flag. + * + * @note + * While in typical cases one input frame produces exactly one output packet + * (perhaps after a delay), in general the mapping of frames to packets is + * M-to-N, so + * - Any number of input frames may be associated with any given output packet. + * This includes zero - e.g. some encoders may output packets that carry only + * metadata about the whole stream. + * - A given input frame may be associated with any number of output packets. + * Again this includes zero - e.g. some encoders may drop frames under certain + * conditions. + * . + * This implies that when using this flag, the caller must NOT assume that + * - a given input frame's opaques will necessarily appear on some output packet; + * - every output packet will have some non-NULL opaque value. + * . + * When an output packet contains multiple frames, the opaque values will be + * taken from the first of those. + */ +#define AV_CODEC_FLAG_COPY_OPAQUE (1 << 7) /** * Use internal 2pass ratecontrol in first pass mode. */ diff --git a/libavcodec/encode.c b/libavcodec/encode.c index e0b3e43840..d6c73dc044 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -636,6 +636,13 @@ int ff_encode_preinit(AVCodecContext *avctx) return AVERROR(EINVAL); } + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE && + !(avctx->codec->capabilities & AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE)) { + av_log(avctx, AV_LOG_ERROR, "The copy_opaque flag is set, but the " + "encoder does not support it.\n"); + return AVERROR(EINVAL); + } + switch (avctx->codec_type) { case AVMEDIA_TYPE_VIDEO: ret = encode_preinit_video(avctx); break; case AVMEDIA_TYPE_AUDIO: ret = encode_preinit_audio(avctx); break; diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 2bbd9044b6..6d22a1726e 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -21,6 +21,7 @@ #include "config_components.h" +#include "libavutil/buffer.h" #include "libavutil/eval.h" #include "libavutil/internal.h" #include "libavutil/opt.h" @@ -51,6 +52,9 @@ typedef struct X264Opaque { int64_t reordered_opaque; int64_t wallclock; + + void *frame_opaque; + AVBufferRef *frame_opaque_ref; } X264Opaque; typedef struct X264Context { @@ -133,6 +137,11 @@ static void X264_log(void *p, int level, const char *fmt, va_list args) av_vlog(p, level_map[level], fmt, args); } +static void opaque_uninit(X264Opaque *o) +{ + av_buffer_unref(&o->frame_opaque_ref); + memset(o, 0, sizeof(*o)); +} static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, const x264_nal_t *nals, int nnal) @@ -440,6 +449,15 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, pic->i_pts = frame->pts; + opaque_uninit(opaque); + + if (ctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + opaque->frame_opaque = frame->opaque; + ret = av_buffer_replace(&opaque->frame_opaque_ref, frame->opaque_ref); + if (ret < 0) + goto fail; + } + opaque->reordered_opaque = frame->reordered_opaque; opaque->wallclock = wallclock; if (ctx->export_side_data & AV_CODEC_EXPORT_DATA_PRFT) @@ -594,6 +612,14 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, out_opaque < &x4->reordered_opaque[x4->nb_reordered_opaque]) { ctx->reordered_opaque = out_opaque->reordered_opaque; wallclock = out_opaque->wallclock; + + if (ctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + pkt->opaque = out_opaque->frame_opaque; + pkt->opaque_ref = out_opaque->frame_opaque_ref; + out_opaque->frame_opaque_ref = NULL; + } + + opaque_uninit(out_opaque); } else { // Unexpected opaque pointer on picture output av_log(ctx, AV_LOG_ERROR, "Unexpected opaque pointer; " @@ -634,6 +660,9 @@ static av_cold int X264_close(AVCodecContext *avctx) X264Context *x4 = avctx->priv_data; av_freep(&x4->sei); + + for (int i = 0; i < x4->nb_reordered_opaque; i++) + opaque_uninit(&x4->reordered_opaque[i]); av_freep(&x4->reordered_opaque); #if X264_BUILD >= 161 diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 25de3c669b..a71f1f76d3 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -28,6 +28,7 @@ #include #include "libavutil/avassert.h" +#include "libavutil/buffer.h" #include "libavutil/internal.h" #include "libavutil/common.h" #include "libavutil/opt.h" @@ -43,6 +44,9 @@ typedef struct ReorderedData { int64_t reordered_opaque; + void *frame_opaque; + AVBufferRef *frame_opaque_ref; + int in_use; } ReorderedData; @@ -121,7 +125,7 @@ static int rd_get(libx265Context *ctx) static void rd_release(libx265Context *ctx, int idx) { av_assert0(idx >= 0 && idx < ctx->nb_rd); - + av_buffer_unref(&ctx->rd[idx].frame_opaque_ref); memset(&ctx->rd[idx], 0, sizeof(ctx->rd[idx])); } @@ -132,6 +136,8 @@ static av_cold int libx265_encode_close(AVCodecContext *avctx) ctx->api->param_free(ctx->params); av_freep(&ctx->sei_data); + for (int i = 0; i < ctx->nb_rd; i++) + rd_release(ctx, i); av_freep(&ctx->rd); if (ctx->encoder) @@ -582,6 +588,9 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, sei->numPayloads = 0; if (pic) { + ReorderedData *rd; + int rd_idx; + for (i = 0; i < 3; i++) { x265pic.planes[i] = pic->data[i]; x265pic.stride[i] = pic->linesize[i]; @@ -600,21 +609,26 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (ret < 0) return ret; - if (pic->reordered_opaque) { - ReorderedData *rd; - int rd_idx = rd_get(ctx); + rd_idx = rd_get(ctx); + if (rd_idx < 0) { + free_picture(ctx, &x265pic); + return rd_idx; + } + rd = &ctx->rd[rd_idx]; - if (rd_idx < 0) { + rd->reordered_opaque = pic->reordered_opaque; + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + rd->frame_opaque = pic->opaque; + ret = av_buffer_replace(&rd->frame_opaque_ref, pic->opaque_ref); + if (ret < 0) { + rd_release(ctx, rd_idx); free_picture(ctx, &x265pic); - return rd_idx; + return ret; } - - x265pic.userData = (void*)(intptr_t)(rd_idx + 1); - - rd = &ctx->rd[rd_idx]; - rd->reordered_opaque = pic->reordered_opaque; } + x265pic.userData = (void*)(intptr_t)(rd_idx + 1); + if (ctx->a53_cc) { void *sei_data; size_t sei_size; @@ -742,6 +756,12 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, avctx->reordered_opaque = rd->reordered_opaque; + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + pkt->opaque = rd->frame_opaque; + pkt->opaque_ref = rd->frame_opaque_ref; + rd->frame_opaque_ref = NULL; + } + rd_release(ctx, idx); } else avctx->reordered_opaque = 0; diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 7924ca6144..4b38c42043 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -58,6 +58,7 @@ static const AVOption avcodec_options[] = { {"loop", "use loop filter", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"}, {"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"}, {"recon_frame", "export reconstructed frames", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_RECON_FRAME}, .unit = "flags"}, +{"copy_opaque", "propagate opaque values", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_COPY_OPAQUE}, .unit = "flags"}, {"pass1", "use internal 2-pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, {"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, {"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 6b8a1dbb79..dfd3d5d7e5 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 56 +#define LIBAVCODEC_VERSION_MINOR 57 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Wed Jan 25 16:55:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40120 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp547252pzj; Wed, 25 Jan 2023 08:58:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXu1altjepRd7LwyO+4ynld5WsjW/8u67zR72WXrIgRquQIlSi14YMuZ7Tl7mDQ6nHFXmP8P X-Received: by 2002:a17:907:1248:b0:84d:45db:b203 with SMTP id wc8-20020a170907124800b0084d45dbb203mr28718022ejb.12.1674665911477; Wed, 25 Jan 2023 08:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665911; cv=none; d=google.com; s=arc-20160816; b=s4GJY7fsvaa+ISK4ZTXG4ZEAGW+albTKGfsN2nfn0rWPB+54gWaLAYURRMjpBvZ5eV A73Z0BRiADgxPgywfc8T17k266OYkpz/a7eI1Kwt/5/+Uo09QK6XM7zZGDpuITd5bAZ8 ird0GiVkMNAHserJARjOwOuWqUOWaHp3XiwtMLNtJgdRWVOJyTJIRoG67OU6mVDEcPcp GnMAucaUPnfvEeiCTZZ2jquYKJUuL6w7mfOg55DGTfRrWlebsK1D+/w35JoWLUimEjPc rqZa+2LVEGWKz3098mHHHlFNN5yaUYpnqiVaLwsdEsg8IGnR2a4rKMFyhZdo2UWJjfs3 3rqw== 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=JcIUCcgAhq1WeEfGV1KHWSZPWm0fLl1phEx7/gDL9so=; b=CoZmh9uLZq+xVO7FyXpRWjrnWrIIL7OEtMWN4HmnjoujLYIP7il5zIanHfTWgbRBpZ gmH4TaN0JvQnXuga3vZWi0IRZB4bXEWuW8G1ss+o1Y7FLFuoTDu6kitGqNy9/PUXZDs4 +LuI046r8c4RfeQIgtI5aRqwgsLM+kOfgoeFIHufcNkGNimk7It6GATX3XodzwmPwYQ8 Zugnw1LMqhTYVFUmypR+R9MeFOSAlh4IDyLgV/YKTn/Ww9nfSXtDPQpc997mEIJ+YCJ+ QXXDz4R1Ftt/qF1ZXPjG/qz1ooAUKU1gtcs1UmrWnttJu0tIQiBgbcLHT1c7ij0voPt1 lnwQ== 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 fm23-20020a1709072ad700b0085f373499afsi6304322ejc.196.2023.01.25.08.58.31; Wed, 25 Jan 2023 08:58:31 -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 55E4168BE1E; Wed, 25 Jan 2023 18:56:35 +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 406A668BD90 for ; Wed, 25 Jan 2023 18:56:19 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 1EE922405B5 for ; Wed, 25 Jan 2023 17:56:17 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id x0Beo2kitZsV for ; Wed, 25 Jan 2023 17:56:14 +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 0397C240591 for ; Wed, 25 Jan 2023 17:56:04 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id B116B3A0354 for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:23 +0100 Message-Id: <20230125165537.5371-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/19] lavc: support AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE in all no-delay encoders 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: IkaCEql33gbd Including fake-delay encoders marked with FF_CODEC_CAP_EOF_FLUSH. --- libavcodec/ac3enc_fixed.c | 2 +- libavcodec/ac3enc_float.c | 2 +- libavcodec/adpcmenc.c | 3 ++- libavcodec/adxenc.c | 3 ++- libavcodec/alacenc.c | 3 ++- libavcodec/aliaspixenc.c | 2 +- libavcodec/aptxenc.c | 4 ++-- libavcodec/asvenc.c | 4 ++-- libavcodec/avuienc.c | 3 ++- libavcodec/bitpacked_enc.c | 3 ++- libavcodec/bmpenc.c | 2 +- libavcodec/cfhdenc.c | 3 ++- libavcodec/cinepakenc.c | 2 +- libavcodec/cljrenc.c | 2 +- libavcodec/cngenc.c | 2 +- libavcodec/dcaenc.c | 3 ++- libavcodec/dfpwmenc.c | 3 ++- libavcodec/dnxhdenc.c | 2 +- libavcodec/dvenc.c | 3 ++- libavcodec/eac3enc.c | 2 +- libavcodec/encode.c | 19 +++++++++++++++++++ libavcodec/encode.h | 6 ++++++ libavcodec/exrenc.c | 3 ++- libavcodec/ffv1enc.c | 3 ++- libavcodec/fitsenc.c | 2 +- libavcodec/flacenc.c | 3 ++- libavcodec/flashsv2enc.c | 2 +- libavcodec/flashsvenc.c | 2 +- libavcodec/flvenc.c | 1 + libavcodec/g722enc.c | 3 ++- libavcodec/g723_1enc.c | 2 +- libavcodec/g726.c | 6 ++++-- libavcodec/gif.c | 2 +- libavcodec/h261enc.c | 1 + libavcodec/hapenc.c | 3 ++- libavcodec/hdrenc.c | 3 ++- libavcodec/huffyuvenc.c | 6 ++++-- libavcodec/ituh263enc.c | 3 ++- libavcodec/j2kenc.c | 2 +- libavcodec/jpeglsenc.c | 3 ++- libavcodec/lclenc.c | 3 ++- libavcodec/libcodec2.c | 3 ++- libavcodec/libgsmenc.c | 4 ++-- libavcodec/libilbc.c | 2 +- libavcodec/libjxlenc.c | 3 ++- libavcodec/libopenh264enc.c | 3 ++- libavcodec/libopenjpegenc.c | 3 ++- libavcodec/libvo-amrwbenc.c | 3 ++- libavcodec/libwebpenc.c | 2 +- libavcodec/libxvid.c | 2 +- libavcodec/ljpegenc.c | 3 ++- libavcodec/magicyuvenc.c | 3 ++- libavcodec/mjpegenc.c | 4 +++- libavcodec/mpegaudioenc_fixed.c | 2 +- libavcodec/mpegaudioenc_float.c | 2 +- libavcodec/msmpeg4enc.c | 3 +++ libavcodec/msvideo1enc.c | 1 + libavcodec/pamenc.c | 2 +- libavcodec/pcm-blurayenc.c | 2 +- libavcodec/pcm-dvdenc.c | 3 ++- libavcodec/pcm.c | 3 ++- libavcodec/pcxenc.c | 2 +- libavcodec/pngenc.c | 3 ++- libavcodec/pnmenc.c | 12 ++++++------ libavcodec/proresenc_anatoliy.c | 6 ++++-- libavcodec/proresenc_kostya.c | 3 ++- libavcodec/qoienc.c | 3 ++- libavcodec/qtrleenc.c | 2 +- libavcodec/r210enc.c | 6 +++--- libavcodec/rawenc.c | 3 ++- libavcodec/roqvideoenc.c | 2 +- libavcodec/rpzaenc.c | 2 +- libavcodec/rv10enc.c | 1 + libavcodec/rv20enc.c | 1 + libavcodec/s302menc.c | 3 ++- libavcodec/sbcenc.c | 3 ++- libavcodec/sgienc.c | 2 +- libavcodec/smcenc.c | 2 +- libavcodec/snowenc.c | 2 +- libavcodec/sonic.c | 6 ++++-- libavcodec/speedhqenc.c | 1 + libavcodec/sunrastenc.c | 2 +- libavcodec/svq1enc.c | 2 +- libavcodec/targaenc.c | 2 +- libavcodec/tiffenc.c | 3 ++- libavcodec/ttaenc.c | 3 ++- libavcodec/utvideoenc.c | 3 ++- libavcodec/v210enc.c | 3 ++- libavcodec/v308enc.c | 2 +- libavcodec/v408enc.c | 4 ++-- libavcodec/v410enc.c | 2 +- libavcodec/vaapi_encode_mjpeg.c | 3 ++- libavcodec/vbnenc.c | 3 ++- libavcodec/vc2enc.c | 3 ++- libavcodec/wavpackenc.c | 3 ++- libavcodec/wbmpenc.c | 3 ++- libavcodec/wmaenc.c | 4 ++-- libavcodec/wmv2enc.c | 1 + libavcodec/wrapped_avframe.c | 1 + libavcodec/xbmenc.c | 2 +- libavcodec/xfaceenc.c | 2 +- libavcodec/xwdenc.c | 2 +- libavcodec/y41penc.c | 2 +- libavcodec/yuv4enc.c | 2 +- libavcodec/zmbvenc.c | 2 +- 105 files changed, 198 insertions(+), 110 deletions(-) diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index 5a5f1cc2e9..88dfd66b91 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -112,7 +112,7 @@ const FFCodec ff_ac3_fixed_encoder = { CODEC_LONG_NAME("ATSC A/52A (AC-3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AC3, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(AC3EncodeContext), .init = ac3_fixed_encode_init, FF_CODEC_ENCODE_CB(ff_ac3_fixed_encode_frame), diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 4c4d18ce56..ae351a535e 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -116,7 +116,7 @@ const FFCodec ff_ac3_encoder = { CODEC_LONG_NAME("ATSC A/52A (AC-3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AC3, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(AC3EncodeContext), .init = ff_ac3_float_encode_init, FF_CODEC_ENCODE_CB(ff_ac3_float_encode_frame), diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 57709b19a1..63afffc58f 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -1003,7 +1003,8 @@ const FFCodec ff_ ## name_ ## _encoder = { \ .p.id = id_, \ .p.sample_fmts = sample_fmts_, \ .p.ch_layouts = ch_layouts, \ - .p.capabilities = capabilities_ | AV_CODEC_CAP_DR1, \ + .p.capabilities = capabilities_ | AV_CODEC_CAP_DR1 | \ + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, \ .p.priv_class = &adpcm_encoder_class, \ .priv_data_size = sizeof(ADPCMEncodeContext), \ .init = adpcm_encode_init, \ diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index 6e12a58b16..796efdab63 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -192,7 +192,8 @@ const FFCodec ff_adpcm_adx_encoder = { CODEC_LONG_NAME("SEGA CRI ADX ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_ADX, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(ADXContext), .init = adx_encode_init, FF_CODEC_ENCODE_CB(adx_encode_frame), diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 0f685d71d6..9598e5861e 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -653,7 +653,8 @@ const FFCodec ff_alac_encoder = { CODEC_LONG_NAME("ALAC (Apple Lossless Audio Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ALAC, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(AlacEncodeContext), .p.priv_class = &alacenc_class, .init = alac_encode_init, diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c index 6593d3f047..90d2a63319 100644 --- a/libavcodec/aliaspixenc.c +++ b/libavcodec/aliaspixenc.c @@ -106,7 +106,7 @@ const FFCodec ff_alias_pix_encoder = { CODEC_LONG_NAME("Alias/Wavefront PIX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ALIAS_PIX, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c index 5fc0378f5d..6deebaf2cb 100644 --- a/libavcodec/aptxenc.c +++ b/libavcodec/aptxenc.c @@ -271,7 +271,7 @@ const FFCodec ff_aptx_encoder = { CODEC_LONG_NAME("aptX (Audio Processing Technology for Bluetooth)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(AptXEncContext), .init = aptx_encode_init, FF_CODEC_ENCODE_CB(aptx_encode_frame), @@ -290,7 +290,7 @@ const FFCodec ff_aptx_hd_encoder = { CODEC_LONG_NAME("aptX HD (Audio Processing Technology for Bluetooth)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX_HD, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(AptXEncContext), .init = aptx_encode_init, FF_CODEC_ENCODE_CB(aptx_encode_frame), diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c index 9da7cbb986..4a14bcf8fa 100644 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@ -362,7 +362,7 @@ const FFCodec ff_asv1_encoder = { CODEC_LONG_NAME("ASUS V1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ASV1, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(ASVEncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), @@ -377,7 +377,7 @@ const FFCodec ff_asv2_encoder = { CODEC_LONG_NAME("ASUS V2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ASV2, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(ASVEncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c index 0b82848cb3..8a093d3d19 100644 --- a/libavcodec/avuienc.c +++ b/libavcodec/avuienc.c @@ -96,7 +96,8 @@ const FFCodec ff_avui_encoder = { CODEC_LONG_NAME("Avid Meridien Uncompressed"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVUI, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_UYVY422, AV_PIX_FMT_NONE }, .init = avui_encode_init, FF_CODEC_ENCODE_CB(avui_encode_frame), diff --git a/libavcodec/bitpacked_enc.c b/libavcodec/bitpacked_enc.c index ca4d5c887d..3c4e11293d 100644 --- a/libavcodec/bitpacked_enc.c +++ b/libavcodec/bitpacked_enc.c @@ -110,7 +110,8 @@ const FFCodec ff_bitpacked_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BITPACKED, .priv_data_size = sizeof(struct BitpackedContext), - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P10, diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index abf644bd99..3e3ca324ea 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -161,7 +161,7 @@ const FFCodec ff_bmp_encoder = { CODEC_LONG_NAME("BMP (Windows and OS/2 bitmap)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BMP, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = bmp_encode_init, FF_CODEC_ENCODE_CB(bmp_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c index 29fb56f25a..f447438491 100644 --- a/libavcodec/cfhdenc.c +++ b/libavcodec/cfhdenc.c @@ -859,7 +859,8 @@ const FFCodec ff_cfhd_encoder = { CODEC_LONG_NAME("GoPro CineForm HD"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CFHD, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(CFHDEncContext), .p.priv_class = &cfhd_class, .init = cfhd_encode_init, diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c index c05449e89c..f15325ad0d 100644 --- a/libavcodec/cinepakenc.c +++ b/libavcodec/cinepakenc.c @@ -1219,7 +1219,7 @@ const FFCodec ff_cinepak_encoder = { CODEC_LONG_NAME("Cinepak"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CINEPAK, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(CinepakEncContext), .init = cinepak_encode_init, FF_CODEC_ENCODE_CB(cinepak_encode_frame), diff --git a/libavcodec/cljrenc.c b/libavcodec/cljrenc.c index c1f8810a5a..d658931520 100644 --- a/libavcodec/cljrenc.c +++ b/libavcodec/cljrenc.c @@ -113,7 +113,7 @@ const FFCodec ff_cljr_encoder = { CODEC_LONG_NAME("Cirrus Logic AccuPak"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CLJR, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(CLJRContext), FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c index ff40017f0d..596d6f8c2a 100644 --- a/libavcodec/cngenc.c +++ b/libavcodec/cngenc.c @@ -101,7 +101,7 @@ const FFCodec ff_comfortnoise_encoder = { CODEC_LONG_NAME("RFC 3389 comfort noise generator"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_COMFORT_NOISE, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(CNGContext), .init = cng_encode_init, FF_CODEC_ENCODE_CB(cng_encode_frame), diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index 4cab54ef1b..c731d79381 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -1315,7 +1315,8 @@ const FFCodec ff_dca_encoder = { CODEC_LONG_NAME("DCA (DTS Coherent Acoustics)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DTS, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(DCAEncContext), .init = encode_init, .close = encode_close, diff --git a/libavcodec/dfpwmenc.c b/libavcodec/dfpwmenc.c index 7f465a446e..5318b04a39 100644 --- a/libavcodec/dfpwmenc.c +++ b/libavcodec/dfpwmenc.c @@ -116,5 +116,6 @@ const FFCodec ff_dfpwm_encoder = { .init = dfpwm_enc_init, FF_CODEC_ENCODE_CB(dfpwm_enc_frame), .p.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_NONE}, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, }; diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index b7dc54f86a..176bf972d8 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1359,7 +1359,7 @@ const FFCodec ff_dnxhd_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DNXHD, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | - AV_CODEC_CAP_SLICE_THREADS, + AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(DNXHDEncContext), .init = dnxhd_encode_init, FF_CODEC_ENCODE_CB(dnxhd_encode_picture), diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 4c747ef71f..8f5fa050b0 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -1239,7 +1239,8 @@ const FFCodec ff_dvvideo_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DVVIDEO, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | - AV_CODEC_CAP_SLICE_THREADS, + AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(DVEncContext), .init = dvvideo_encode_init, FF_CODEC_ENCODE_CB(dvvideo_encode_frame), diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 78d4f1399a..ab9eda261f 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -254,7 +254,7 @@ const FFCodec ff_eac3_encoder = { CODEC_LONG_NAME("ATSC A/52 E-AC-3"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_EAC3, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(AC3EncodeContext), .init = ff_ac3_float_encode_init, FF_CODEC_ENCODE_CB(ff_ac3_float_encode_frame), diff --git a/libavcodec/encode.c b/libavcodec/encode.c index d6c73dc044..555bd3ff96 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -190,6 +190,21 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame) return 0; } +int ff_encode_reordered_opaque(AVCodecContext *avctx, + AVPacket *pkt, const AVFrame *frame) +{ + avctx->reordered_opaque = frame->reordered_opaque; + + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + int ret = av_buffer_replace(&pkt->opaque_ref, frame->opaque_ref); + if (ret < 0) + return ret; + pkt->opaque = frame->opaque; + } + + return 0; +} + int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, AVFrame *frame, int *got_packet) { @@ -221,6 +236,10 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); } + + ret = ff_encode_reordered_opaque(avctx, avpkt, frame); + if (ret < 0) + goto unref; } // dts equals pts unless there is reordering diff --git a/libavcodec/encode.h b/libavcodec/encode.h index 81d18d6ead..26a3304045 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -69,6 +69,12 @@ int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame); */ int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size); +/** + * Propagate user opaque values from the frame to avctx/pkt as needed. + */ +int ff_encode_reordered_opaque(AVCodecContext *avctx, + AVPacket *pkt, const AVFrame *frame); + /* * Perform encoder initialization and validation. * Called when opening the encoder, before the FFCodec.init() call. diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c index 10ed876888..36327f498c 100644 --- a/libavcodec/exrenc.c +++ b/libavcodec/exrenc.c @@ -547,7 +547,8 @@ const FFCodec ff_exr_encoder = { .p.priv_class = &exr_class, .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_EXR, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .close = encode_close, diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 6649ec7e88..fb12776cc2 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1270,7 +1270,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), diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c index ac910499e5..12952278ac 100644 --- a/libavcodec/fitsenc.c +++ b/libavcodec/fitsenc.c @@ -114,7 +114,7 @@ const FFCodec ff_fits_encoder = { CODEC_LONG_NAME("Flexible Image Transport System"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FITS, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(fits_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRAP16BE, AV_PIX_FMT_GBRP16BE, diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 9a9835dfa6..a449b73235 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1754,7 +1754,8 @@ const FFCodec ff_flac_encoder = { .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_FLAC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | - AV_CODEC_CAP_SMALL_LAST_FRAME, + AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(FlacEncodeContext), .init = flac_encode_init, FF_CODEC_ENCODE_CB(flac_encode_frame), diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index 668ca6a85f..46e24a9c1e 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -915,7 +915,7 @@ const FFCodec ff_flashsv2_encoder = { CODEC_LONG_NAME("Flash Screen Video Version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLASHSV2, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(FlashSV2Context), .init = flashsv2_encode_init, FF_CODEC_ENCODE_CB(flashsv2_encode_frame), diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 3a35876d9c..6192bc25db 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -251,7 +251,7 @@ const FFCodec ff_flashsv_encoder = { CODEC_LONG_NAME("Flash Screen Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLASHSV, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(FlashSVContext), .init = flashsv_encode_init, FF_CODEC_ENCODE_CB(flashsv_encode_frame), diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index b49ca2e0d5..1ebe6e8736 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -105,4 +105,5 @@ const FFCodec ff_flv_encoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, }; diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c index bc08211b1d..47811cee4d 100644 --- a/libavcodec/g722enc.c +++ b/libavcodec/g722enc.c @@ -375,7 +375,8 @@ const FFCodec ff_adpcm_g722_encoder = { CODEC_LONG_NAME("G.722 ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_G722, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(G722Context), .init = g722_encode_init, .close = g722_encode_close, diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c index 8466067185..be80153130 100644 --- a/libavcodec/g723_1enc.c +++ b/libavcodec/g723_1enc.c @@ -1241,7 +1241,7 @@ const FFCodec ff_g723_1_encoder = { CODEC_LONG_NAME("G.723.1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_G723_1, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(G723_1_Context), .init = g723_1_encode_init, FF_CODEC_ENCODE_CB(g723_1_encode_frame), diff --git a/libavcodec/g726.c b/libavcodec/g726.c index 7bbb7f900c..6c5638760d 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -405,7 +405,8 @@ const FFCodec ff_adpcm_g726_encoder = { CODEC_LONG_NAME("G.726 ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_G726, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(G726Context), .init = g726_encode_init, FF_CODEC_ENCODE_CB(g726_encode_frame), @@ -422,7 +423,8 @@ const FFCodec ff_adpcm_g726le_encoder = { CODEC_LONG_NAME("G.726 little endian ADPCM (\"right-justified\")"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_G726LE, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(G726Context), .init = g726_encode_init, FF_CODEC_ENCODE_CB(g726_encode_frame), diff --git a/libavcodec/gif.c b/libavcodec/gif.c index 7e717d8220..e17ead0f82 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -553,7 +553,7 @@ const FFCodec ff_gif_encoder = { CODEC_LONG_NAME("GIF (Graphics Interchange Format)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_GIF, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(GIFContext), .init = gif_encode_init, FF_CODEC_ENCODE_CB(gif_encode_frame), diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index e8ea357cbb..6c80809bca 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -413,4 +413,5 @@ const FFCodec ff_h261_encoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, }; diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c index a890dc6492..7de7358e3d 100644 --- a/libavcodec/hapenc.c +++ b/libavcodec/hapenc.c @@ -351,7 +351,8 @@ const FFCodec ff_hap_encoder = { CODEC_LONG_NAME("Vidvox Hap"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HAP, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(HapContext), .p.priv_class = &hapenc_class, .init = hap_init, diff --git a/libavcodec/hdrenc.c b/libavcodec/hdrenc.c index d8c3111c93..40d283ee61 100644 --- a/libavcodec/hdrenc.c +++ b/libavcodec/hdrenc.c @@ -177,7 +177,8 @@ const FFCodec ff_hdr_encoder = { .priv_data_size = sizeof(HDREncContext), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RADIANCE_HDR, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = hdr_encode_init, FF_CODEC_ENCODE_CB(hdr_encode_frame), .close = hdr_encode_close, diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index db274e37ad..72d6246ebe 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -1082,7 +1082,8 @@ const FFCodec ff_huffyuv_encoder = { CODEC_LONG_NAME("Huffyuv / HuffYUV"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HUFFYUV, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(HYuvEncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), @@ -1101,7 +1102,8 @@ const FFCodec ff_ffvhuff_encoder = { CODEC_LONG_NAME("Huffyuv FFmpeg variant"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FFVHUFF, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(HYuvEncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 22e5a8368d..719effa41d 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -903,6 +903,7 @@ const FFCodec ff_h263_encoder = { .p.id = AV_CODEC_ID_H263, .p.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, .p.priv_class = &h263_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .priv_data_size = sizeof(MpegEncContext), .init = ff_mpv_encode_init, @@ -933,7 +934,7 @@ const FFCodec ff_h263p_encoder = { .p.id = AV_CODEC_ID_H263P, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .p.priv_class = &h263p_class, - .p.capabilities = AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .priv_data_size = sizeof(MpegEncContext), .init = ff_mpv_encode_init, diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index e883d5deb7..6406f90ac2 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -1835,7 +1835,7 @@ const FFCodec ff_jpeg2000_encoder = { CODEC_LONG_NAME("JPEG 2000"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEG2000, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(Jpeg2000EncoderContext), .init = j2kenc_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index 5ee39ac2d6..53394102df 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -476,7 +476,8 @@ const FFCodec ff_jpegls_encoder = { CODEC_LONG_NAME("JPEG-LS"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEGLS, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(JPEGLSContext), .p.priv_class = &jpegls_class, .init = encode_jpegls_init, diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c index 2c9add5215..dd5eed9d63 100644 --- a/libavcodec/lclenc.c +++ b/libavcodec/lclenc.c @@ -156,7 +156,8 @@ const FFCodec ff_zlib_encoder = { CODEC_LONG_NAME("LCL (LossLess Codec Library) ZLIB"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ZLIB, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(LclEncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index 5728d915c2..83f68e85c7 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -197,7 +197,8 @@ const FFCodec ff_libcodec2_encoder = { CODEC_LONG_NAME("codec2 encoder using libcodec2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_CODEC2, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.supported_samplerates = (const int[]){ 8000, 0 }, .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, { 0 } }, diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c index bd3b1420aa..640954491a 100644 --- a/libavcodec/libgsmenc.c +++ b/libavcodec/libgsmenc.c @@ -122,7 +122,7 @@ const FFCodec ff_libgsm_encoder = { CODEC_LONG_NAME("libgsm GSM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_GSM, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = libgsm_encode_init, FF_CODEC_ENCODE_CB(libgsm_encode_frame), .close = libgsm_encode_close, @@ -141,7 +141,7 @@ const FFCodec ff_libgsm_ms_encoder = { CODEC_LONG_NAME("libgsm GSM Microsoft variant"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_GSM_MS, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = libgsm_encode_init, FF_CODEC_ENCODE_CB(libgsm_encode_frame), .close = libgsm_encode_close, diff --git a/libavcodec/libilbc.c b/libavcodec/libilbc.c index 9ef6e16bc5..9ca90bf0c6 100644 --- a/libavcodec/libilbc.c +++ b/libavcodec/libilbc.c @@ -205,7 +205,7 @@ const FFCodec ff_libilbc_encoder = { CODEC_LONG_NAME("iLBC (Internet Low Bitrate Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ILBC, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, .priv_data_size = sizeof(ILBCEncContext), .init = ilbc_encode_init, diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c index 0793ed251b..06581b268d 100644 --- a/libavcodec/libjxlenc.c +++ b/libavcodec/libjxlenc.c @@ -467,7 +467,8 @@ const FFCodec ff_libjxl_encoder = { .init = libjxl_encode_init, FF_CODEC_ENCODE_CB(libjxl_encode_frame), .close = libjxl_encode_close, - .p.capabilities = AV_CODEC_CAP_OTHER_THREADS, + .p.capabilities = AV_CODEC_CAP_OTHER_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES, diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index bbd6969568..6934fd481c 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -456,7 +456,8 @@ const FFCodec ff_libopenh264_encoder = { CODEC_LONG_NAME("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SVCContext), .init = svc_encode_init, FF_CODEC_ENCODE_CB(svc_encode_frame), diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 6f77780391..009c7a4377 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -763,7 +763,8 @@ const FFCodec ff_libopenjpeg_encoder = { .priv_data_size = sizeof(LibOpenJPEGContext), .init = libopenjpeg_encode_init, FF_CODEC_ENCODE_CB(libopenjpeg_encode_frame), - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64, AV_PIX_FMT_GBR24P, diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index 76a6b69994..02b8941a6d 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -144,7 +144,8 @@ const FFCodec ff_libvo_amrwbenc_encoder = { CODEC_LONG_NAME("Android VisualOn AMR-WB (Adaptive Multi-Rate Wide-Band)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_WB, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.priv_class = &amrwb_class, .p.wrapper_name = "libvo_amrwbenc", .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, diff --git a/libavcodec/libwebpenc.c b/libavcodec/libwebpenc.c index ee5795f041..d6edd86603 100644 --- a/libavcodec/libwebpenc.c +++ b/libavcodec/libwebpenc.c @@ -92,7 +92,7 @@ const FFCodec ff_libwebp_encoder = { CODEC_LONG_NAME("libwebp WebP image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WEBP, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = ff_libwebpenc_pix_fmts, .p.priv_class = &ff_libwebpenc_class, .p.wrapper_name = "libwebp", diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index 4e04b3c098..aba875b6b8 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -902,7 +902,7 @@ const FFCodec ff_libxvid_encoder = { CODEC_LONG_NAME("libxvidcore MPEG-4 part 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG4, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(struct xvid_context), .init = xvid_encode_init, FF_CODEC_ENCODE_CB(xvid_encode_frame), diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 81c52a7c78..aa62beac71 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -316,7 +316,8 @@ const FFCodec ff_ljpeg_encoder = { CODEC_LONG_NAME("Lossless JPEG"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_LJPEG, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(LJpegEncContext), .p.priv_class = &ljpeg_class, .init = ljpeg_encode_init, diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c index 7f9ff72834..9e41c1b0fe 100644 --- a/libavcodec/magicyuvenc.c +++ b/libavcodec/magicyuvenc.c @@ -569,7 +569,8 @@ const FFCodec ff_magicyuv_encoder = { CODEC_LONG_NAME("MagicYUV video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MAGICYUV, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(MagicYUVContext), .p.priv_class = &magicyuv_class, .init = magy_encode_init, diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index eafe7130e2..508772987f 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -651,7 +651,8 @@ const FFCodec ff_mjpeg_encoder = { .init = ff_mpv_encode_init, FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), .close = mjpeg_encode_close, - .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, @@ -685,5 +686,6 @@ const FFCodec ff_amv_encoder = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE }, .p.priv_class = &amv_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, }; #endif diff --git a/libavcodec/mpegaudioenc_fixed.c b/libavcodec/mpegaudioenc_fixed.c index afbffe766b..a523b5d533 100644 --- a/libavcodec/mpegaudioenc_fixed.c +++ b/libavcodec/mpegaudioenc_fixed.c @@ -28,7 +28,7 @@ const FFCodec ff_mp2fixed_encoder = { CODEC_LONG_NAME("MP2 fixed point (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(MpegAudioContext), .init = MPA_encode_init, FF_CODEC_ENCODE_CB(MPA_encode_frame), diff --git a/libavcodec/mpegaudioenc_float.c b/libavcodec/mpegaudioenc_float.c index 212709c291..6a13d09573 100644 --- a/libavcodec/mpegaudioenc_float.c +++ b/libavcodec/mpegaudioenc_float.c @@ -29,7 +29,7 @@ const FFCodec ff_mp2_encoder = { CODEC_LONG_NAME("MP2 (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(MpegAudioContext), .init = MPA_encode_init, FF_CODEC_ENCODE_CB(MPA_encode_frame), diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 9b6e5efa0c..737a7f7dce 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -684,6 +684,7 @@ const FFCodec ff_msmpeg4v2_encoder = { .p.id = AV_CODEC_ID_MSMPEG4V2, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .p.priv_class = &ff_mpv_enc_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .priv_data_size = sizeof(MSMPEG4EncContext), .init = ff_mpv_encode_init, @@ -698,6 +699,7 @@ const FFCodec ff_msmpeg4v3_encoder = { .p.id = AV_CODEC_ID_MSMPEG4V3, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .p.priv_class = &ff_mpv_enc_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .priv_data_size = sizeof(MSMPEG4EncContext), .init = ff_mpv_encode_init, @@ -712,6 +714,7 @@ const FFCodec ff_wmv1_encoder = { .p.id = AV_CODEC_ID_WMV1, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, .p.priv_class = &ff_mpv_enc_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .priv_data_size = sizeof(MSMPEG4EncContext), .init = ff_mpv_encode_init, diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c index a349b42ca0..36cfd39a85 100644 --- a/libavcodec/msvideo1enc.c +++ b/libavcodec/msvideo1enc.c @@ -307,6 +307,7 @@ const FFCodec ff_msvideo1_encoder = { CODEC_LONG_NAME("Microsoft Video-1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSVIDEO1, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(Msvideo1EncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c index 7d01e89f74..45ec29ccb3 100644 --- a/libavcodec/pamenc.c +++ b/libavcodec/pamenc.c @@ -133,7 +133,7 @@ const FFCodec ff_pam_encoder = { CODEC_LONG_NAME("PAM (Portable AnyMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PAM, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(pam_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, diff --git a/libavcodec/pcm-blurayenc.c b/libavcodec/pcm-blurayenc.c index 62e86e722f..bfbfa91d7a 100644 --- a/libavcodec/pcm-blurayenc.c +++ b/libavcodec/pcm-blurayenc.c @@ -304,5 +304,5 @@ const FFCodec ff_pcm_bluray_encoder = { { 0 } }, .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, }; diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c index 011d0a2f00..a2e5cbdc2e 100644 --- a/libavcodec/pcm-dvdenc.c +++ b/libavcodec/pcm-dvdenc.c @@ -176,7 +176,8 @@ const FFCodec ff_pcm_dvd_encoder = { CODEC_LONG_NAME("PCM signed 16|20|24-bit big-endian for DVD media"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_PCM_DVD, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(PCMDVDContext), .init = pcm_dvd_encode_init, FF_CODEC_ENCODE_CB(pcm_dvd_encode_frame), diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index ee36a364c8..23955ba2dd 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -553,7 +553,8 @@ const FFCodec ff_ ## name_ ## _encoder = { \ CODEC_LONG_NAME(long_name_), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = AV_CODEC_ID_ ## id_, \ - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \ + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE | \ + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, \ .init = pcm_encode_init, \ FF_CODEC_ENCODE_CB(pcm_encode_frame), \ .p.sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \ diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index 509158ba0f..cf9b41b752 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -197,7 +197,7 @@ const FFCodec ff_pcx_encoder = { CODEC_LONG_NAME("PC Paintbrush PCX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PCX, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(pcx_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index ca1a186ca8..d1448bd0cd 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -1196,7 +1196,8 @@ const FFCodec ff_png_encoder = { CODEC_LONG_NAME("PNG (Portable Network Graphics) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PNG, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(PNGEncContext), .init = png_enc_init, .close = png_enc_close, diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index 4bdd2e032f..9e1b11382b 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -229,7 +229,7 @@ const FFCodec ff_pgm_encoder = { CODEC_LONG_NAME("PGM (Portable GrayMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PGM, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(pnm_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE @@ -243,7 +243,7 @@ const FFCodec ff_pgmyuv_encoder = { CODEC_LONG_NAME("PGMYUV (Portable GrayMap YUV) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PGMYUV, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(pnm_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_NONE @@ -257,7 +257,7 @@ const FFCodec ff_ppm_encoder = { CODEC_LONG_NAME("PPM (Portable PixelMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PPM, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(pnm_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_NONE @@ -271,7 +271,7 @@ const FFCodec ff_pbm_encoder = { CODEC_LONG_NAME("PBM (Portable BitMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PBM, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(pnm_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE }, @@ -284,7 +284,7 @@ const FFCodec ff_pfm_encoder = { CODEC_LONG_NAME("PFM (Portable FloatMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PFM, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(pnm_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_GBRPF32LE, AV_PIX_FMT_GRAYF32LE, @@ -309,7 +309,7 @@ const FFCodec ff_phm_encoder = { CODEC_LONG_NAME("PHM (Portable HalfFloatMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PHM, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(PHMEncContext), .init = phm_enc_init, FF_CODEC_ENCODE_CB(pnm_encode_frame), diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index bd1b70cc5d..09196c7aa1 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -944,7 +944,8 @@ const FFCodec ff_prores_aw_encoder = { CODEC_LONG_NAME("Apple ProRes"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = pix_fmts, .priv_data_size = sizeof(ProresContext), .init = prores_encode_init, @@ -960,7 +961,8 @@ const FFCodec ff_prores_encoder = { CODEC_LONG_NAME("Apple ProRes"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = pix_fmts, .priv_data_size = sizeof(ProresContext), .init = prores_encode_init, diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c index 5b38437d0a..1940e0378a 100644 --- a/libavcodec/proresenc_kostya.c +++ b/libavcodec/proresenc_kostya.c @@ -1428,7 +1428,8 @@ const FFCodec ff_prores_ks_encoder = { .init = encode_init, .close = encode_close, FF_CODEC_ENCODE_CB(encode_frame), - .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_NONE diff --git a/libavcodec/qoienc.c b/libavcodec/qoienc.c index 6d574e0da9..b9efdc2fa5 100644 --- a/libavcodec/qoienc.c +++ b/libavcodec/qoienc.c @@ -131,7 +131,8 @@ const FFCodec ff_qoi_encoder = { CODEC_LONG_NAME("QOI (Quite OK Image format) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QOI, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(qoi_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB24, diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 855494d3df..3d51fcf843 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -404,7 +404,7 @@ const FFCodec ff_qtrle_encoder = { CODEC_LONG_NAME("QuickTime Animation (RLE) video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QTRLE, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(QtrleEncContext), .init = qtrle_encode_init, FF_CODEC_ENCODE_CB(qtrle_encode_frame), diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c index d87f42ce4a..91e3452874 100644 --- a/libavcodec/r210enc.c +++ b/libavcodec/r210enc.c @@ -96,7 +96,7 @@ const FFCodec ff_r210_encoder = { CODEC_LONG_NAME("Uncompressed RGB 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_R210, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = pix_fmt, @@ -108,7 +108,7 @@ const FFCodec ff_r10k_encoder = { CODEC_LONG_NAME("AJA Kona 10-bit RGB Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_R10K, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = pix_fmt, @@ -120,7 +120,7 @@ const FFCodec ff_avrp_encoder = { CODEC_LONG_NAME("Avid 1:1 10-bit RGB Packer"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVRP, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = pix_fmt, diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c index c2643e6d80..8c577006d9 100644 --- a/libavcodec/rawenc.c +++ b/libavcodec/rawenc.c @@ -86,7 +86,8 @@ const FFCodec ff_rawvideo_encoder = { CODEC_LONG_NAME("raw video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RAWVIDEO, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = raw_encode_init, FF_CODEC_ENCODE_CB(raw_encode), }; diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index 273686a147..c25aa39b73 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -1122,7 +1122,7 @@ const FFCodec ff_roq_encoder = { CODEC_LONG_NAME("id RoQ video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ROQ, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(RoqEncContext), .init = roq_encode_init, FF_CODEC_ENCODE_CB(roq_encode_frame), diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c index 1ea579d2d3..da9500e424 100644 --- a/libavcodec/rpzaenc.c +++ b/libavcodec/rpzaenc.c @@ -873,7 +873,7 @@ const FFCodec ff_rpza_encoder = { CODEC_LONG_NAME("QuickTime video (RPZA)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RPZA, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(RpzaContext), .p.priv_class = &rpza_class, .init = rpza_encode_init, diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index d0704c5a4b..d19d693e18 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -71,6 +71,7 @@ const FFCodec ff_rv10_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RV10, .p.priv_class = &ff_mpv_enc_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(MpegEncContext), .init = ff_mpv_encode_init, FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index a6bacacb48..c7149fb267 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -68,6 +68,7 @@ const FFCodec ff_rv20_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RV20, .p.priv_class = &ff_mpv_enc_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(MpegEncContext), .init = ff_mpv_encode_init, FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c index 3bd657f945..4b8996f9ac 100644 --- a/libavcodec/s302menc.c +++ b/libavcodec/s302menc.c @@ -176,7 +176,8 @@ const FFCodec ff_s302m_encoder = { .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_S302M, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | - AV_CODEC_CAP_VARIABLE_FRAME_SIZE, + AV_CODEC_CAP_VARIABLE_FRAME_SIZE | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(S302MEncContext), .init = s302m_encode_init, FF_CODEC_ENCODE_CB(s302m_encode2_frame), diff --git a/libavcodec/sbcenc.c b/libavcodec/sbcenc.c index 721c97e1ea..fccb0e3ea3 100644 --- a/libavcodec/sbcenc.c +++ b/libavcodec/sbcenc.c @@ -348,7 +348,8 @@ const FFCodec ff_sbc_encoder = { CODEC_LONG_NAME("SBC (low-complexity subband codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SBC, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SBCEncContext), .init = sbc_encode_init, FF_CODEC_ENCODE_CB(sbc_encode_frame), diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c index 901e0a74f9..5bbb72c03a 100644 --- a/libavcodec/sgienc.c +++ b/libavcodec/sgienc.c @@ -275,7 +275,7 @@ const FFCodec ff_sgi_encoder = { CODEC_LONG_NAME("SGI image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SGI, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SgiContext), .p.priv_class = &sgi_class, .init = encode_init, diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c index e3ea7e5e9f..3e8b5afcf6 100644 --- a/libavcodec/smcenc.c +++ b/libavcodec/smcenc.c @@ -595,7 +595,7 @@ const FFCodec ff_smc_encoder = { CODEC_LONG_NAME("QuickTime Graphics (SMC)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SMC, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SMCContext), .init = smc_encode_init, FF_CODEC_ENCODE_CB(smc_encode_frame), diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 7fad95b69a..749c8067d2 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1935,7 +1935,7 @@ const FFCodec ff_snow_encoder = { CODEC_LONG_NAME("Snow"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SNOW, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SnowContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 77bdb418a7..62e6193ac6 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -1096,7 +1096,8 @@ const FFCodec ff_sonic_encoder = { CODEC_LONG_NAME("Sonic"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SONIC, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SonicContext), .init = sonic_encode_init, FF_CODEC_ENCODE_CB(sonic_encode_frame), @@ -1112,7 +1113,8 @@ const FFCodec ff_sonic_ls_encoder = { CODEC_LONG_NAME("Sonic lossless"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SONIC_LS, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SonicContext), .init = sonic_encode_init, FF_CODEC_ENCODE_CB(sonic_encode_frame), diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 7269e345d3..5b4ff4c139 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -288,6 +288,7 @@ const FFCodec ff_speedhq_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SPEEDHQ, .p.priv_class = &ff_mpv_enc_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SpeedHQEncContext), .init = ff_mpv_encode_init, FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c index 9b82f9921a..b2d57f7235 100644 --- a/libavcodec/sunrastenc.c +++ b/libavcodec/sunrastenc.c @@ -213,7 +213,7 @@ const FFCodec ff_sunrast_encoder = { CODEC_LONG_NAME("Sun Rasterfile image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SUNRAST, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SUNRASTContext), .init = sunrast_encode_init, FF_CODEC_ENCODE_CB(sunrast_encode_frame), diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 8f09e634a5..e3ea0c1e47 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -752,7 +752,7 @@ const FFCodec ff_svq1_encoder = { CODEC_LONG_NAME("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SVQ1, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(SVQ1EncContext), .p.priv_class = &svq1enc_class, .init = svq1_encode_init, diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c index bb3cb93187..d9c500b97d 100644 --- a/libavcodec/targaenc.c +++ b/libavcodec/targaenc.c @@ -207,7 +207,7 @@ const FFCodec ff_targa_encoder = { CODEC_LONG_NAME("Truevision Targa image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TARGA, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(TargaContext), .p.priv_class = &targa_class, .init = targa_encode_init, diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index 6dfbdaeb40..06d7dcc99d 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -574,7 +574,8 @@ const FFCodec ff_tiff_encoder = { CODEC_LONG_NAME("TIFF image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TIFF, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(TiffEncoderContext), .init = encode_init, .close = encode_close, diff --git a/libavcodec/ttaenc.c b/libavcodec/ttaenc.c index d41d2e6fa5..db79c38b43 100644 --- a/libavcodec/ttaenc.c +++ b/libavcodec/ttaenc.c @@ -204,7 +204,8 @@ const FFCodec ff_tta_encoder = { CODEC_LONG_NAME("TTA (True Audio)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TTA, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(TTAEncContext), .init = tta_encode_init, .close = tta_encode_close, diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index d4388da8ba..6e87bbc2b6 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -648,7 +648,8 @@ const FFCodec ff_utvideo_encoder = { CODEC_LONG_NAME("Ut Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_UTVIDEO, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(UtvideoContext), .p.priv_class = &utvideo_class, .init = utvideo_encode_init, diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index abbbf4ff9d..2a30ed77da 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -112,7 +112,8 @@ const FFCodec ff_v210_encoder = { CODEC_LONG_NAME("Uncompressed 4:2:2 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V210, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(V210EncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c index 78e33c0a8a..68f9c3310b 100644 --- a/libavcodec/v308enc.c +++ b/libavcodec/v308enc.c @@ -75,7 +75,7 @@ const FFCodec ff_v308_encoder = { CODEC_LONG_NAME("Uncompressed packed 4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V308, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = v308_encode_init, FF_CODEC_ENCODE_CB(v308_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c index 514f41be4e..1faac7cc36 100644 --- a/libavcodec/v408enc.c +++ b/libavcodec/v408enc.c @@ -94,7 +94,7 @@ const FFCodec ff_ayuv_encoder = { CODEC_LONG_NAME("Uncompressed packed MS 4:4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AYUV, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = v408_encode_init, FF_CODEC_ENCODE_CB(v408_encode_frame), .p.pix_fmts = pix_fmt, @@ -107,7 +107,7 @@ const FFCodec ff_v408_encoder = { CODEC_LONG_NAME("Uncompressed packed QT 4:4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V408, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = v408_encode_init, FF_CODEC_ENCODE_CB(v408_encode_frame), .p.pix_fmts = pix_fmt, diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c index bad13c371a..89ee3a7278 100644 --- a/libavcodec/v410enc.c +++ b/libavcodec/v410enc.c @@ -79,7 +79,7 @@ const FFCodec ff_v410_encoder = { CODEC_LONG_NAME("Uncompressed 4:4:4 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V410, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = v410_encode_init, FF_CODEC_ENCODE_CB(v410_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE }, diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index 5ef93cd102..cb7588b94b 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -574,7 +574,8 @@ const FFCodec ff_mjpeg_vaapi_encoder = { FF_CODEC_RECEIVE_PACKET_CB(&ff_vaapi_encode_receive_packet), .close = &vaapi_encode_mjpeg_close, .p.priv_class = &vaapi_encode_mjpeg_class, - .p.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .defaults = vaapi_encode_mjpeg_defaults, diff --git a/libavcodec/vbnenc.c b/libavcodec/vbnenc.c index 45101382a3..7ce91863d7 100644 --- a/libavcodec/vbnenc.c +++ b/libavcodec/vbnenc.c @@ -153,7 +153,8 @@ const FFCodec ff_vbn_encoder = { CODEC_LONG_NAME("Vizrt Binary Image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VBN, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.priv_class = &vbnenc_class, .init = vbn_init, FF_CODEC_ENCODE_CB(vbn_encode), diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index 82d11462aa..d978c67a3b 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -1228,7 +1228,8 @@ const FFCodec ff_vc2_encoder = { CODEC_LONG_NAME("SMPTE VC-2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DIRAC, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .priv_data_size = sizeof(VC2EncContext), .init = vc2_encode_init, diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c index bdb536382f..3d2d45360d 100644 --- a/libavcodec/wavpackenc.c +++ b/libavcodec/wavpackenc.c @@ -2963,7 +2963,8 @@ const FFCodec ff_wavpack_encoder = { CODEC_LONG_NAME("WavPack"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WAVPACK, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(WavPackEncodeContext), .p.priv_class = &wavpack_encoder_class, .init = wavpack_encode_init, diff --git a/libavcodec/wbmpenc.c b/libavcodec/wbmpenc.c index 25fac746fc..abb66b4ca9 100644 --- a/libavcodec/wbmpenc.c +++ b/libavcodec/wbmpenc.c @@ -80,7 +80,8 @@ const FFCodec ff_wbmp_encoder = { CODEC_LONG_NAME("WBMP (Wireless Application Protocol Bitmap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WBMP, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(wbmp_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_MONOBLACK, diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index 2c647af13b..80ff696be6 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -440,7 +440,7 @@ const FFCodec ff_wmav1_encoder = { CODEC_LONG_NAME("Windows Media Audio 1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAV1, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(WMACodecContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_superframe), @@ -456,7 +456,7 @@ const FFCodec ff_wmav2_encoder = { CODEC_LONG_NAME("Windows Media Audio 2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAV2, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(WMACodecContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_superframe), diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 05f993525d..6d991909fb 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -242,6 +242,7 @@ const FFCodec ff_wmv2_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WMV2, .p.priv_class = &ff_mpv_enc_class, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(WMV2EncContext), .init = wmv2_encode_init, FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c index c9579848e6..0278ea42ba 100644 --- a/libavcodec/wrapped_avframe.c +++ b/libavcodec/wrapped_avframe.c @@ -109,6 +109,7 @@ const FFCodec ff_wrapped_avframe_encoder = { CODEC_LONG_NAME("AVFrame to AVPacket passthrough"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WRAPPED_AVFRAME, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(wrapped_avframe_encode), }; diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index 664c6599bf..cd8b73afa3 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -82,7 +82,7 @@ const FFCodec ff_xbm_encoder = { CODEC_LONG_NAME("XBM (X BitMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XBM, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(xbm_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE }, diff --git a/libavcodec/xfaceenc.c b/libavcodec/xfaceenc.c index 7125f1f085..4998d42ea5 100644 --- a/libavcodec/xfaceenc.c +++ b/libavcodec/xfaceenc.c @@ -216,7 +216,7 @@ const FFCodec ff_xface_encoder = { CODEC_LONG_NAME("X-face image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XFACE, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE }, .priv_data_size = sizeof(XFaceContext), FF_CODEC_ENCODE_CB(xface_encode_frame), diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c index 6c588f3acc..08554d8632 100644 --- a/libavcodec/xwdenc.c +++ b/libavcodec/xwdenc.c @@ -216,7 +216,7 @@ const FFCodec ff_xwd_encoder = { CODEC_LONG_NAME("XWD (X Window Dump) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XWD, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(xwd_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGRA, AV_PIX_FMT_RGBA, diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c index d3ef88c2ce..e86769da66 100644 --- a/libavcodec/y41penc.c +++ b/libavcodec/y41penc.c @@ -82,7 +82,7 @@ const FFCodec ff_y41p_encoder = { CODEC_LONG_NAME("Uncompressed YUV 4:1:1 12-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_Y41P, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .init = y41p_encode_init, FF_CODEC_ENCODE_CB(y41p_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c index 27e786dd54..8123260d5d 100644 --- a/libavcodec/yuv4enc.c +++ b/libavcodec/yuv4enc.c @@ -64,7 +64,7 @@ const FFCodec ff_yuv4_encoder = { CODEC_LONG_NAME("Uncompressed packed 4:2:0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_YUV4, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, FF_CODEC_ENCODE_CB(yuv4_encode_frame), }; diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index c12f783d5a..d20330568d 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -416,7 +416,7 @@ const FFCodec ff_zmbv_encoder = { CODEC_LONG_NAME("Zip Motion Blocks Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ZMBV, - .p.capabilities = AV_CODEC_CAP_DR1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(ZmbvEncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), From patchwork Wed Jan 25 16:55:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40117 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp547109pzj; Wed, 25 Jan 2023 08:58:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXskyuuNFeuhFH8oNz7sHe0qgSmZg7KjPoBAf1X2e2CgnR+4EDfpXYJ9IUyaTTia1Pffizhn X-Received: by 2002:a17:906:6844:b0:86e:f478:f598 with SMTP id a4-20020a170906684400b0086ef478f598mr33371403ejs.44.1674665893468; Wed, 25 Jan 2023 08:58:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665893; cv=none; d=google.com; s=arc-20160816; b=CiL7OpP0hmX09PXw31aFdTTBimTqcC5HzXBk2eEoCRfe6m6z5U1UyGK0dE/LWL9M4L UocL7MlKm01faWexAY9cuPt7G+QxCO96B6/6Ge++qKr+E0hCWo26XwzarpAyPRH6ZNP4 TWk+V2CWOSPxL7tuCTqdDawabSRbA58ivTiopJ1MEhTv/CvaCCjDBPxsEwtlUaq4qFix qXJecUn9djDv4yFssyKLiQpjyZtv3zbcd9P7tatfwSteV6b3f6nGxGg0rsgW8HIp8jjS GY0kpd5pmUcd51/KlDEOrVDjIsENP+vM/sb9aGcO8o8bYAytMFASiNxH+7tMqqQ5J9pN xjPQ== 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=D47lTmOhBjtjQsF4/YIoN8JR4QqwzNQ5euahBionK/Q=; b=I1ZX8HfWEOCS2Z+BozjYcrVM18xcgKR5fYqwmpFNENlQLyCTPhai30ARXbRKk8mXCh aSdHZKpa1Z4sNKkabqk2SS3cA6IBpShEfO5rMoWWbXwrbGpAmIw3jg39cZwuLiT6oiPX QQZOCaf4sRCPZjBWu2tvnEl4i5obufvI1Wtd9Lua0OWqlDZkt4oFUjH/joA2brJIkjNT PMvWvTDX66kCZxKp+NArAI2qqJoJwaSQHKPq+VgbJlI73raE0qVJovBzYdLRB0hWvA7n W9A94zn5LijOiXfEZXxbb5ARb7KaPYxwjJSDT6VuWXDUTv9Ld7L4BNyQkQSk+Ey/y5uA 7Xvg== 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 uj42-20020a170907c9aa00b0087345b10ebfsi5782982ejc.14.2023.01.25.08.58.13; Wed, 25 Jan 2023 08:58:13 -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 5CB8F68BE0B; Wed, 25 Jan 2023 18:56:33 +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 33B6468BD81 for ; Wed, 25 Jan 2023 18:56:19 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D4E612405EC for ; Wed, 25 Jan 2023 17:56:16 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6jXul-suJQ_K for ; Wed, 25 Jan 2023 17:56:16 +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 0F2962405B5 for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BEBD53A035B for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:24 +0100 Message-Id: <20230125165537.5371-6-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/19] lavc/encode: pass through frame durations to encoded packets 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: bgtOZy99TuZv The generic code can only handle the no-delay case. Encoders with delay need to be handled individually, which will be done in the following commits. --- doc/APIchanges | 2 +- libavcodec/avcodec.h | 7 +++++++ libavcodec/encode.c | 14 ++++++++++++-- libavcodec/options_table.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f52337990f..a20a899365 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,7 +15,7 @@ libavutil: 2021-04-27 API changes, most recent first: 2023-01-xx - xxxxxxxxxx - lavc 59.57.100 - avcodec.h - Add AV_CODEC_FLAG_COPY_OPAQUE. + Add AV_CODEC_FLAG_COPY_OPAQUE and AV_CODEC_FLAG_FRAME_DURATION. 2023-01-13 - xxxxxxxxxx - lavu 57.44.100 - ambient_viewing_environment.h frame.h Adds a new structure for holding H.274 Ambient Viewing Environment metadata, diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 54ab7b81f9..1daa1106aa 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -267,6 +267,13 @@ typedef struct RcOverride{ * taken from the first of those. */ #define AV_CODEC_FLAG_COPY_OPAQUE (1 << 7) +/** + * Signal to the encoder that the values of AVFrame.duration are valid and + * should be used (typically for transferring them to output packets). + * + * If this flag is not set, frame durations are ignored. + */ +#define AV_CODEC_FLAG_FRAME_DURATION (1 << 8) /** * Use internal 2pass ratecontrol in first pass mode. */ diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 555bd3ff96..c92beaf8e1 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -231,10 +231,13 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, if (avpkt->pts == AV_NOPTS_VALUE) avpkt->pts = frame->pts; - if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { - if (!avpkt->duration) + if (!avpkt->duration) { + if (frame->duration) + avpkt->duration = frame->duration; + else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); + } } ret = ff_encode_reordered_opaque(avctx, avpkt, frame); @@ -463,6 +466,13 @@ FF_ENABLE_DEPRECATION_WARNINGS return ret; } + // unset frame duration unless AV_CODEC_FLAG_FRAME_DURATION is set, + // since otherwise we cannot be sure that whatever value it has is in the + // right timebase, so we would produce an incorrect value, which is worse + // than none at all + if (!(avctx->flags & AV_CODEC_FLAG_FRAME_DURATION)) + dst->duration = 0; + return 0; } diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 4b38c42043..322ec7a156 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -59,6 +59,7 @@ static const AVOption avcodec_options[] = { {"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"}, {"recon_frame", "export reconstructed frames", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_RECON_FRAME}, .unit = "flags"}, {"copy_opaque", "propagate opaque values", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_COPY_OPAQUE}, .unit = "flags"}, +{"frame_duration", "use frame durations", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_FRAME_DURATION}, .unit = "flags"}, {"pass1", "use internal 2-pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, {"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, {"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, From patchwork Wed Jan 25 16:55:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40114 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546801pzj; Wed, 25 Jan 2023 08:57:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXuO60NNvMZMNZBg2G9TS5Oy6MgjFnG8Bt31MCaixxeowdHW6AHZLG2k/cnzLixvnlAGGrE7 X-Received: by 2002:a17:906:a393:b0:7c1:1fcf:266c with SMTP id k19-20020a170906a39300b007c11fcf266cmr34136493ejz.14.1674665859262; Wed, 25 Jan 2023 08:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665859; cv=none; d=google.com; s=arc-20160816; b=dY5+WCW6gJp8RTBvGNgbHPOSbMBwdJc/1CzGIRpzz9EIsbuDD0OPPOT8IlcLhSlsyV WK5y9WABTeBKDeGkRsP3iTZeqx1dTidHPN2iDKYSaxaQqcHjhIF5/FGeFTAPaZybtmqx cMwvFgA8GCp7IfwPJI8S2g8wz+V0F3+F9kg3qKwcvHtlGtOvkB7gv5qvly2ZkS7eq9Hi 9a4Y25VlrGxp0iOw47k+lNoeFkOO5ExZxsSsJG5LZEH92huhrbcc3vcclN927mI1NlP4 89dn8yPW9UY9QJtkeNX7ngrCH9s1jzwqKHmNCMKa/hpW2bZ+kLhvxHqodo0mTXbk9hkh 10EQ== 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=ldfWmBqhsg0yyXreIYXZOSy2ANxflO8IQoeUC4LF5y8=; b=uLmcPu5MSEAqHykMd04bYLzEuqBIU3uOfjJyOGT1E2Be4Eg+jMRYS6xJLQ+TSWeHd2 xNXWjwKjaUJxLVks/dapPs8xMtb7+SdmgrH1q89D6a7AEuREDAvL0V4ni+zq8XbNG0wf 6ZZ0l4ejH46q2r1GBQ0/8d5PtApdijTHn9DKuTJIO/25fMobga3sJYlrPv7Jdfe0s3Z/ YrpKZnwPRqRBBpmpkzmGR025u/D8l8ABKYx+j/YjGNxBZd4gorX6nyJJWmKKOT1a9Pf9 dWYpCttq7+ScxIfKbbGpwcQvnPUNEAB3MrAKTWPzOIejwpldqoXer+nkC5n2ks5Rv/qp KM/Q== 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 10-20020a170906020a00b0087766403eb7si7379739ejd.818.2023.01.25.08.57.38; Wed, 25 Jan 2023 08:57:39 -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 47BD668BD60; Wed, 25 Jan 2023 18:56:29 +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 5B36F68BD36 for ; Wed, 25 Jan 2023 18:56:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 21E72240178 for ; Wed, 25 Jan 2023 17:56:21 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pfRKscgFmwU2 for ; Wed, 25 Jan 2023 17:56:19 +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 39B412406CD for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id CAAD33A03D9 for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:25 +0100 Message-Id: <20230125165537.5371-7-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/19] lavc/librav1e: 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: povye0Cs5HL2 --- libavcodec/librav1e.c | 61 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index 3481b7637d..00d69328fb 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -22,6 +22,7 @@ #include +#include "libavutil/buffer.h" #include "libavutil/internal.h" #include "libavutil/avassert.h" #include "libavutil/base64.h" @@ -53,6 +54,15 @@ typedef struct librav1eContext { int tile_cols; } librav1eContext; +typedef struct FrameData { + int64_t pts; + int64_t duration; + int64_t reordered_opaque; + + void *frame_opaque; + AVBufferRef *frame_opaque_ref; +} FrameData; + static inline RaPixelRange range_map(enum AVPixelFormat pix_fmt, enum AVColorRange range) { switch (pix_fmt) { @@ -419,11 +429,23 @@ end: return ret; } +static void frame_data_free(void *data) +{ + FrameData *fd = data; + + if (!fd) + return; + + av_buffer_unref(&fd->frame_opaque_ref); + av_free(data); +} + static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt) { librav1eContext *ctx = avctx->priv_data; RaFrame *rframe = ctx->rframe; RaPacket *rpkt = NULL; + FrameData *fd; int ret; if (!rframe) { @@ -436,18 +458,30 @@ static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt) if (frame->buf[0]) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); - int64_t *pts = av_malloc(sizeof(int64_t)); - if (!pts) { + fd = av_mallocz(sizeof(*fd)); + if (!fd) { av_log(avctx, AV_LOG_ERROR, "Could not allocate PTS buffer.\n"); return AVERROR(ENOMEM); } - *pts = frame->pts; + fd->pts = frame->pts; + fd->duration = frame->duration; + fd->reordered_opaque = frame->reordered_opaque; + + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + fd->frame_opaque = frame->opaque; + ret = av_buffer_replace(&fd->frame_opaque_ref, frame->opaque_ref); + if (ret < 0) { + frame_data_free(fd); + av_frame_unref(frame); + return ret; + } + } rframe = rav1e_frame_new(ctx->ctx); if (!rframe) { av_log(avctx, AV_LOG_ERROR, "Could not allocate new rav1e frame.\n"); av_frame_unref(frame); - av_freep(&pts); + frame_data_free(fd); return AVERROR(ENOMEM); } @@ -459,7 +493,7 @@ static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt) frame->linesize[i], bytes); } av_frame_unref(frame); - rav1e_frame_set_opaque(rframe, pts, av_free); + rav1e_frame_set_opaque(rframe, fd, frame_data_free); } } @@ -535,8 +569,18 @@ retry: if (rpkt->frame_type == RA_FRAME_TYPE_KEY) pkt->flags |= AV_PKT_FLAG_KEY; - pkt->pts = pkt->dts = *((int64_t *) rpkt->opaque); - av_free(rpkt->opaque); + fd = rpkt->opaque; + pkt->pts = pkt->dts = fd->pts; + pkt->duration = fd->duration; + avctx->reordered_opaque = fd->reordered_opaque; + + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + pkt->opaque = fd->frame_opaque; + pkt->opaque_ref = fd->frame_opaque_ref; + fd->frame_opaque_ref = NULL; + } + + frame_data_free(fd); if (avctx->flags & AV_CODEC_FLAG_RECON_FRAME) { AVCodecInternal *avci = avctx->internal; @@ -626,7 +670,8 @@ const FFCodec ff_librav1e_encoder = { .defaults = librav1e_defaults, .p.pix_fmts = librav1e_pix_fmts, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | - AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_RECON_FRAME, + AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_RECON_FRAME | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .p.wrapper_name = "librav1e", From patchwork Wed Jan 25 16:55:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40110 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546487pzj; Wed, 25 Jan 2023 08:57:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWrxGiqGYzbctQHYbIHdBx+8yKYVmwwgU+rqQoOOIYzXqT4WMEZy7+X+Jld3Hf5cOsUgx2 X-Received: by 2002:a17:907:1710:b0:86f:64bb:47eb with SMTP id le16-20020a170907171000b0086f64bb47ebmr35392116ejc.3.1674665822319; Wed, 25 Jan 2023 08:57:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665822; cv=none; d=google.com; s=arc-20160816; b=W/62ptp/HTj9UR3sJnN5O67+hbOLIrtghcf1fJsf4i7i7Xf6UCNv5k+knmYgKWF9xv 9yLf0f4pt3l/5fIqyDV4yK0+3hwybiUX3tBxZpyxnFnsmC3+fa/CDyr+9m7/xf3cyM6G wXaMpxa+ZFrhmUrDxzSQhF9dkVF0kI//I+5lFoASTacGEgbe/ciIU71eU4IYOg94BzQK 1bTmsFb0ZzBRg3VZPM1UPA5Wbr0k1NjRrkv50mDiD19atIj+8dgqdYQl5LL34dVzTk7x 0PGJo+Ur+QhuN3L5BQ1uhfCZMFg42U0lePTGsI3Y0JnSn+PmzZ78TE6uoPoMsj3xSdUL /t/A== 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=ZpQY0dXpLG17d0LJvJhRbEMB1obfvMwUFF3vUO2RINA=; b=hqdGOVLUSB/T6uiH7gA/TIYLcz6blxqhMyR2dx8mPuQ1QX8tnLWzs3TQ7ud2q5QXM4 kCAINAytlwdPXpC5VBM5eiQFhcugevnVLwEIZoj1x17+/IToO42D+7r2KA9j+CVX8aVG JKrV7kA6Qqbw5NaWstYqlcR+DRciVhuOw9rSTnHWgKoZeQ8ylW5qU98O7QZ4VKmFS+TX 9Mqi5Yvu6fOG+gBrIDvrf7jRTAAIsJBm4aqK0Zyn1yXN2houZEufyJbTUzqPbxddsb/l M5tDePoEq9rWfmEtnPDvIK/7lTJhBSNNMH+3bOqre7SQ0utDi6brpFS2nggPAx8963rD /bVQ== 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 vf5-20020a170907238500b007a953d421bbsi5824692ejb.322.2023.01.25.08.57.02; Wed, 25 Jan 2023 08:57:02 -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 F34D268BDA5; Wed, 25 Jan 2023 18:56: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 892EF68BD1E for ; Wed, 25 Jan 2023 18:56:15 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4F2C52404F5 for ; Wed, 25 Jan 2023 17:56:15 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ULb1ASaW01ov for ; Wed, 25 Jan 2023 17:56:14 +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 1CB0B2406CA for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D63733A03EF for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:26 +0100 Message-Id: <20230125165537.5371-8-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/19] lavc/nvenc: 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: 9q1rlhkAU87A --- libavcodec/nvenc.c | 102 ++++++++++++++++++++++++++++++++-------- libavcodec/nvenc.h | 2 +- libavcodec/nvenc_av1.c | 3 +- libavcodec/nvenc_h264.c | 3 +- libavcodec/nvenc_hevc.c | 3 +- 5 files changed, 89 insertions(+), 24 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index f6df7cb6ac..ab42dc9690 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -28,6 +28,7 @@ #include "av1.h" #endif +#include "libavutil/buffer.h" #include "libavutil/hwcontext_cuda.h" #include "libavutil/hwcontext.h" #include "libavutil/cuda_check.h" @@ -162,6 +163,23 @@ static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err, return ret; } +typedef struct FrameData { + int64_t pts; + int64_t duration; + int64_t reordered_opaque; + + void *frame_opaque; + AVBufferRef *frame_opaque_ref; +} FrameData; + +static void reorder_queue_flush(AVFifo *queue) +{ + FrameData fd; + + while (av_fifo_read(queue, &fd, 1) >= 0) + av_buffer_unref(&fd.frame_opaque_ref); +} + typedef struct GUIDTuple { const GUID guid; int flags; @@ -1748,8 +1766,8 @@ static av_cold int nvenc_setup_surfaces(AVCodecContext *avctx) if (!ctx->surfaces) return AVERROR(ENOMEM); - ctx->timestamp_list = av_fifo_alloc2(ctx->nb_surfaces, sizeof(int64_t), 0); - if (!ctx->timestamp_list) + ctx->reorder_queue = av_fifo_alloc2(ctx->nb_surfaces, sizeof(FrameData), 0); + if (!ctx->reorder_queue) return AVERROR(ENOMEM); ctx->unused_surface_queue = av_fifo_alloc2(ctx->nb_surfaces, sizeof(NvencSurface*), 0); @@ -1833,7 +1851,8 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) p_nvenc->nvEncEncodePicture(ctx->nvencoder, ¶ms); } - av_fifo_freep2(&ctx->timestamp_list); + reorder_queue_flush(ctx->reorder_queue); + av_fifo_freep2(&ctx->reorder_queue); av_fifo_freep2(&ctx->output_surface_ready_queue); av_fifo_freep2(&ctx->output_surface_queue); av_fifo_freep2(&ctx->unused_surface_queue); @@ -2177,18 +2196,45 @@ static void nvenc_codec_specific_pic_params(AVCodecContext *avctx, } } -static inline void timestamp_queue_enqueue(AVFifo *queue, int64_t timestamp) +static void reorder_queue_enqueue(AVFifo *queue, const AVCodecContext *avctx, + const AVFrame *frame, AVBufferRef **opaque_ref) { - av_fifo_write(queue, ×tamp, 1); + FrameData fd; + + fd.pts = frame->pts; + fd.duration = frame->duration; + fd.reordered_opaque = frame->reordered_opaque; + fd.frame_opaque = frame->opaque; + fd.frame_opaque_ref = *opaque_ref; + + *opaque_ref = NULL; + + av_fifo_write(queue, &fd, 1); } -static inline int64_t timestamp_queue_dequeue(AVFifo *queue) +static int64_t reorder_queue_dequeue(AVFifo *queue, AVCodecContext *avctx, + AVPacket *pkt) { - int64_t timestamp = AV_NOPTS_VALUE; + FrameData fd; + // The following call might fail if the queue is empty. - av_fifo_read(queue, ×tamp, 1); + if (av_fifo_read(queue, &fd, 1) < 0) + return AV_NOPTS_VALUE; + + if (pkt) { + avctx->reordered_opaque = fd.reordered_opaque; + pkt->duration = fd.duration; + + if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + pkt->opaque = fd.frame_opaque; + pkt->opaque_ref = fd.frame_opaque_ref; + fd.frame_opaque_ref = NULL; + } + } + + av_buffer_unref(&fd.frame_opaque_ref); - return timestamp; + return fd.pts; } static int nvenc_set_timestamp(AVCodecContext *avctx, @@ -2196,12 +2242,14 @@ static int nvenc_set_timestamp(AVCodecContext *avctx, AVPacket *pkt) { NvencContext *ctx = avctx->priv_data; + int64_t dts; pkt->pts = params->outputTimeStamp; + dts = reorder_queue_dequeue(ctx->reorder_queue, avctx, pkt); + if (avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) { - pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list); - pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1); + pkt->dts = dts - FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1); } else { pkt->dts = pkt->pts; } @@ -2298,7 +2346,7 @@ static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSur return 0; error: - timestamp_queue_dequeue(ctx->timestamp_list); + reorder_queue_dequeue(ctx->reorder_queue, avctx, NULL); error2: return res; @@ -2528,6 +2576,8 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) int sei_count = 0; int i; + AVBufferRef *opaque_ref = NULL; + NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; @@ -2595,9 +2645,17 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS; } + // make a reference for enqueing in the reorder queue here, + // so that reorder_queue_enqueue() cannot fail + if (frame && frame->opaque_ref && avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + opaque_ref = av_buffer_ref(frame->opaque_ref); + if (!opaque_ref) + return AVERROR(ENOMEM); + } + res = nvenc_push_context(avctx); if (res < 0) - return res; + goto opaque_ref_fail; nv_status = p_nvenc->nvEncEncodePicture(ctx->nvencoder, &pic_params); @@ -2606,17 +2664,17 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) res = nvenc_pop_context(avctx); if (res < 0) - return res; + goto opaque_ref_fail; if (nv_status != NV_ENC_SUCCESS && - nv_status != NV_ENC_ERR_NEED_MORE_INPUT) - return nvenc_print_error(avctx, nv_status, "EncodePicture failed!"); + nv_status != NV_ENC_ERR_NEED_MORE_INPUT) { + res = nvenc_print_error(avctx, nv_status, "EncodePicture failed!"); + goto opaque_ref_fail; + } if (frame && frame->buf[0]) { av_fifo_write(ctx->output_surface_queue, &in_surf, 1); - - if (avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) - timestamp_queue_enqueue(ctx->timestamp_list, frame->pts); + reorder_queue_enqueue(ctx->reorder_queue, avctx, frame, &opaque_ref); } /* all the pending buffers are now ready for output */ @@ -2626,6 +2684,10 @@ static int nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame) } return 0; + +opaque_ref_fail: + av_buffer_unref(&opaque_ref); + return res; } int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt) @@ -2684,5 +2746,5 @@ av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx) NvencContext *ctx = avctx->priv_data; nvenc_send_frame(avctx, NULL); - av_fifo_reset2(ctx->timestamp_list); + reorder_queue_flush(ctx->reorder_queue); } diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 05a7ac48b1..411c83aa94 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -171,7 +171,7 @@ typedef struct NvencContext AVFifo *unused_surface_queue; AVFifo *output_surface_queue; AVFifo *output_surface_ready_queue; - AVFifo *timestamp_list; + AVFifo *reorder_queue; NV_ENC_SEI_PAYLOAD *sei_data; int sei_data_size; diff --git a/libavcodec/nvenc_av1.c b/libavcodec/nvenc_av1.c index 2ed99d948b..2b349c7b61 100644 --- a/libavcodec/nvenc_av1.c +++ b/libavcodec/nvenc_av1.c @@ -181,7 +181,8 @@ const FFCodec ff_av1_nvenc_encoder = { .defaults = defaults, .p.pix_fmts = ff_nvenc_pix_fmts, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | - AV_CODEC_CAP_ENCODER_FLUSH | AV_CODEC_CAP_DR1, + AV_CODEC_CAP_ENCODER_FLUSH | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .p.wrapper_name = "nvenc", diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index a69358b03b..5dc2961c3b 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -232,7 +232,8 @@ const FFCodec ff_h264_nvenc_encoder = { .p.priv_class = &h264_nvenc_class, .defaults = defaults, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | - AV_CODEC_CAP_ENCODER_FLUSH | AV_CODEC_CAP_DR1, + AV_CODEC_CAP_ENCODER_FLUSH | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .p.pix_fmts = ff_nvenc_pix_fmts, diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index 5ad423444a..1362a927c8 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -214,7 +214,8 @@ const FFCodec ff_hevc_nvenc_encoder = { .defaults = defaults, .p.pix_fmts = ff_nvenc_pix_fmts, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | - AV_CODEC_CAP_ENCODER_FLUSH | AV_CODEC_CAP_DR1, + AV_CODEC_CAP_ENCODER_FLUSH | AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .p.wrapper_name = "nvenc", From patchwork Wed Jan 25 16:55:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40116 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp547048pzj; Wed, 25 Jan 2023 08:58:04 -0800 (PST) X-Google-Smtp-Source: AK7set8Us8p2Iz/n9IXfSJ7mMJoClt2B7LA76MdDOVZCEV+bi40TdoyM/6ANkTH9dC9jdez6Q1nX X-Received: by 2002:a05:6402:320c:b0:4a0:b756:cfba with SMTP id g12-20020a056402320c00b004a0b756cfbamr249725eda.32.1674665884527; Wed, 25 Jan 2023 08:58:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665884; cv=none; d=google.com; s=arc-20160816; b=CcVzAV1xcRzzDYOKI/J/r5y9oY+pViRvk82z9Esku6Z4GU6OrF772xGXgvcrRUmdA1 vQw6Ee2vf6Ev94vEl2mPHHeu2wYtB3KKhzwe7X9mTAEShD+KD7K7jHnA6+2kDcOyl0fy J/6ungPO0vsQY+m+o2Z36smiFkv5L9KDBOvjERoAILTbUMHmxLXJcrEtifnCoa6v95on XytxCbYyFY/VEFbLce0ExHuBuvnUtyV8JEwvdelA20vnexMGNItG5Y2hEohodOVUcqqC 5SFMefNAbw95MH/kDJdb1LI+8nOcadkIwR9wxRuPVySaujARQTamKubaX6tE2n2sS5Qi cNBA== 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=v6gXOR1JF9cMDcYny1ahzPyyLdCXq8jfH5x9pWgEU5c=; b=MKp8/x7vo4lxCH0dsR9BGb+my+bEZ72SHMke5+1PxezZTMu1p2XBVNJGmDbBszZxvh 6BswxP+1hzKqFw9M51OeEUBYUEBNqtv6AyGh869fRYdF6BGo0vkw/v+pNjKHgd3o64MO ApwK/22bwX/Igdhxi6DxKMNDtX9YzGWGaVtmw0VE1vPBz3klD6GX5y6nukoajk1kGGc5 Unb2rHq+M6QnpNXf8yJKJFpFwfo26f7WCi46CUyUiydaQRbsg+klCFsKRrRs+xCHVwff +wPQhJlfKbNBsKSxq55+SvdzcrFXlhJdkYkdEpXiJoCkTIlqslA4Ie4nsa66iz1P4XBb fLWQ== 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 n22-20020aa7c456000000b0049cd6204bf4si7023030edr.432.2023.01.25.08.58.04; Wed, 25 Jan 2023 08:58:04 -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 67C6D68BE10; Wed, 25 Jan 2023 18:56:32 +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 307A768BD7E for ; Wed, 25 Jan 2023 18:56:19 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B557E2406CA for ; Wed, 25 Jan 2023 17:56:15 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Xo-2Wfvc0fq6 for ; Wed, 25 Jan 2023 17:56:15 +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 1C6842405F9 for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E1C463A03F2 for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:27 +0100 Message-Id: <20230125165537.5371-9-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/19] lavc/pngenc: 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: EjIvRFlP8uZA --- libavcodec/pngenc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index d1448bd0cd..3738df297e 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -977,6 +977,11 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt, memcpy(pkt->data, s->last_frame_packet, s->last_frame_packet_size); pkt->pts = pkt->dts = s->last_frame->pts; + pkt->duration = s->last_frame->duration; + + ret = ff_encode_reordered_opaque(avctx, pkt, s->last_frame); + if (ret < 0) + return ret; } if (pict) { @@ -1219,7 +1224,8 @@ const FFCodec ff_apng_encoder = { CODEC_LONG_NAME("APNG (Animated Portable Network Graphics) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_APNG, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(PNGEncContext), .init = png_enc_init, .close = png_enc_close, From patchwork Wed Jan 25 16:55:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40119 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp547163pzj; Wed, 25 Jan 2023 08:58:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXtSmY8eFEmc6wHmh8ifqQasTpRuyfYcOtvBjoHZrTQQ/ypaNoWVXXvRVwTpjnq/b+gC4HsP X-Received: by 2002:a17:907:76b0:b0:7c0:d609:6f9b with SMTP id jw16-20020a17090776b000b007c0d6096f9bmr26050189ejc.27.1674665902267; Wed, 25 Jan 2023 08:58:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665902; cv=none; d=google.com; s=arc-20160816; b=bDnwhWrO2aOdd6I1YBkj7SOLAC027gl/n01+t/OKehhK/SaKlg1wofxcy5bsCVcCqG ippIprN8OD+7hcqv9CCXzZ85f3P+gytnKVb2T+oPFfppPDUs1YjIGrsxFIjrb0rI5X75 Aap6MBlx5Foxps2MjP0fWhRUvnQAroN6KIYAILEbi+KkHZ2hMuuVXCxwJI9/aRwdZEp/ KtOB+9TlPDmDNTz9KJNTgT86OS3DlV8Th+5fc/BETHGHZkuwZyuBSWpJRjg0644e8mCs 3ctzz80ILKJWMNt/8hJWKRv9J8bTKBB33TwvsFTCgAEJRNXo49OZ8/AOPX22+30zm/Nx s7Iw== 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=pwYuMYgBz/4bj0C88FO1VQ3fn5jOg7RAnE1pPQCc1zY=; b=aKYg2dJoQWBoyN6qIZNW5umijnyJIac+qbigaSmuzExuOOBvxj1rjrutbywq6oR6cP v6Ij8SQjhzRzTO5ns+qM2cBZEql1pwgbYnZhWgDIKlfr15Hp/kRrgkanVzam2IOSQFuf ep8+fMUz7l09klA6IL4vJ4XGd0gZV+g6wPGMgaunLJiviH6stm8Ppwz+LnQJB8n5raeW SbXzleQTQNT8hDZIkZOaqdLGo9ITy8PG0Nohdxbtj87+iADO8Wm5eXyyinb1yefzx1W0 EgPusRL3DsdQcqdml2vtgUiZqLpojF3d73CNgEYK35+akYIsPwdULnRNvQonrLh6PRJg 97PQ== 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 y20-20020aa7ccd4000000b0049e19019995si6907581edt.237.2023.01.25.08.58.21; Wed, 25 Jan 2023 08:58:22 -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 68E9168BDCB; Wed, 25 Jan 2023 18:56:34 +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 39AA868BD87 for ; Wed, 25 Jan 2023 18:56:19 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 31B3F2405F9 for ; Wed, 25 Jan 2023 17:56:16 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Q8AezCSHlBwH for ; Wed, 25 Jan 2023 17:56:15 +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 1BF9D2405EC for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id ED7EA3A03F5 for ; Wed, 25 Jan 2023 17:55:58 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:28 +0100 Message-Id: <20230125165537.5371-10-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/19] lavc/pngenc: stop setting dts unnecessarily for APNG 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: N7Rk9Pbuamf8 APNG is not marked as supporting reordering, so dts will be set from pts by the generic code. --- libavcodec/pngenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 3738df297e..4392220fbb 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -976,7 +976,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt, return ret; memcpy(pkt->data, s->last_frame_packet, s->last_frame_packet_size); - pkt->pts = pkt->dts = s->last_frame->pts; + pkt->pts = s->last_frame->pts; pkt->duration = s->last_frame->duration; ret = ff_encode_reordered_opaque(avctx, pkt, s->last_frame); From patchwork Wed Jan 25 16:55:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40112 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546653pzj; Wed, 25 Jan 2023 08:57:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXuR9pK/JiUVlpdekEkWNBLxebhrtq3ARqtdKPPiZbrUsR6yEczJExf/NJS2JhZywzZnK2dR X-Received: by 2002:a17:906:a08:b0:877:6177:309c with SMTP id w8-20020a1709060a0800b008776177309cmr27561950ejf.31.1674665841583; Wed, 25 Jan 2023 08:57:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665841; cv=none; d=google.com; s=arc-20160816; b=fT3eqQX6tVtJGeZDtTgG/rBFzWLC5xmzXoJNXqWk6CN6MaMkIsqwNDks9Y037sc2gR cguA1Z+dM+oKVXZgDERMh27pOX9OnGG2uqEb0bjwIwjHXf/of3TlarLWxpVVIR6hDU+c shuFgJVfYzg0XmXry2sa+inh+uDOyHGuUr6E7dzZaHnBBMU5vS/y5TlsIJNyNCzXNPMr 3iANc8dezqkE0cUQ4RIXlJYGu+KcftLQiHUxGK0HgprWO4U1bRt9Br2gXM0atUIA6o3P xy9fbj87p0msFtvPM35Bw7fTk/aGxSEEXINJcj+Qshsvkb8Kc2XC7yc8/jIjW1DJf/Ro wGtA== 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=6EQ9sTCHkaYxQhFtgbxpAk+bQR9t7CUop9v0+/mysV0=; b=KnywcCox6oas5Skx+nA1S5bN+ENPURimdlv013GOoVhgv/byGtRaOOb/hvp428Uwu0 h7/4w4DFk3oiRps2KB+c9hoXJIrWS48D5un+cyOBCZf2VW2sQoCL8uMVg3eVUCLHcLHf 4cEyaxdqlHEMCd3T44nyrGGNJHwTf69lFRYcfb6PLHd/uVepDwRlqR4cRUIzp8Wr+cp4 3nWeO1Hb3YMIZebJXdRb3CCSkKtHuII7CQ17yTw2tBn4ZngzY8ry5vanFLkNWI2aVOmy q5O/zwn33i+riuo7ZxuVF6/gaaLhWjXdzG/VHMylHPP3bz2I7fIyLWhJkwGhqVdJK0hy mnGA== 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 ab14-20020a170907340e00b0086fd54a8f19si6739487ejc.63.2023.01.25.08.57.20; Wed, 25 Jan 2023 08:57:21 -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 2A07768BDEA; Wed, 25 Jan 2023 18:56:27 +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 DDAA468BD2C for ; Wed, 25 Jan 2023 18:56:20 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0D580240178 for ; Wed, 25 Jan 2023 17:56:20 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id aIENV8SSvMNj for ; Wed, 25 Jan 2023 17:56:18 +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 3D28E2406D0 for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 058223A043F for ; Wed, 25 Jan 2023 17:55:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:29 +0100 Message-Id: <20230125165537.5371-11-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/19] lavc/libtheoraenc: 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: ZzI+cnNvonq+ --- libavcodec/libtheoraenc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index da16c6372e..73295e22b9 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -347,6 +347,12 @@ static int encode_frame(AVCodecContext* avc_context, AVPacket *pkt, // HACK: assumes no encoder delay, this is true until libtheora becomes // multithreaded (which will be disabled unless explicitly requested) pkt->pts = pkt->dts = frame->pts; + pkt->duration = frame->duration; + + ret = ff_encode_reordered_opaque(avc_context, pkt, frame); + if (ret < 0) + return ret; + if (!(o_packet.granulepos & h->keyframe_mask)) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; @@ -373,7 +379,9 @@ const FFCodec ff_libtheora_encoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_THEORA, .p.capabilities = AV_CODEC_CAP_DR1 | - AV_CODEC_CAP_DELAY /* for statsfile summary */, + /* for statsfile summary */ + AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, .priv_data_size = sizeof(TheoraContext), .init = encode_init, From patchwork Wed Jan 25 16:55:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40111 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546571pzj; Wed, 25 Jan 2023 08:57:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXs3GGfAP5wUmVb/BzlsJus6uvM48lC1DJ4VLFZoHS4f0L89WKzc0Hcl3e7j05w8S9rvz8wc X-Received: by 2002:a17:907:2a56:b0:84d:35e1:2781 with SMTP id fe22-20020a1709072a5600b0084d35e12781mr41361854ejc.46.1674665831597; Wed, 25 Jan 2023 08:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665831; cv=none; d=google.com; s=arc-20160816; b=EcCQs6cilhJIljbX191T/ZHNcFwwrq6O0dfQaWkmjl+sMa83oG2D90Um5rursEr/7s X2JGeYcbrHyiNJC2dnSSos+GBaXWRTxeIt2hf+PQ0BOk+q8XWYNQ3LYJLS9wvKp24iM1 o0wg3IjIVTTRcB1IyDXhvSIfKgVfYHIRqKlQgDrCgmQ+2IUzc3m5AXihlzRtUqTj5biw UBNFIlu67jzxOi65Q8KQ5nttPMmQb1BcW0UPkuWDV9WMkX37vj5mKpZ5X0ZCe9+bmQRO FwZ+PIe/SjIrruuZn+7bHF8r9DkWIawYlsWYpw3AIAxWebKntk6ocurJODMfaV+o5xp2 HYag== 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=NYWRT5DIpJDdmz5eN1i2kc0DzXnpUQHgBbTcJd14swE=; b=BhDZwTdj+QjVysQetM31s/THtFcAb9MB0q4jJfdMDTt8y9o3e7W2t8dhRv1TdCQh4a kN3JiMVMcyxEqNp2yV48dsgLvipF/u/Ub7M1b/+zkLe6rFv1dLPJeANt2lgELxmTUoLt QBhV+96jxMJLsz4YMfdsJJ8Y4C1p+bwSRMn2xgH6JbgjkUp8+hl+iaOSIOIR+IpULTWk DGFJKDAjL92dHjvsO/Kn1h2pL95eRCw3RwfsRUNvfB1j528CLEueSFfrPGO4icIw5Ulq pbM8kHpJVQPPuLr7EfbM7xbCLWSRnXzCKiKSRuyMVkpAOAnKEKSfdTnbdoDOAvPKClOz YerQ== 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 cm17-20020a170907939100b00877dde5ec9dsi5912137ejc.761.2023.01.25.08.57.11; Wed, 25 Jan 2023 08:57:11 -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 0DFFB68BC41; Wed, 25 Jan 2023 18:56:26 +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 CC39468BD26 for ; Wed, 25 Jan 2023 18:56:20 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7341D2406CC for ; Wed, 25 Jan 2023 17:56:19 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id vtfwTUHJCL9f for ; Wed, 25 Jan 2023 17:56:19 +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 458C5240706 for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1120D3A044E for ; Wed, 25 Jan 2023 17:55:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:30 +0100 Message-Id: <20230125165537.5371-12-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/19] lavc/libtheoraenc: stop setting dts unnecessarily 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: GgIBk/X+EY92 Theora is not marked as supporting reordering, so dts will be set from pts by the generic code. --- libavcodec/libtheoraenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index 73295e22b9..06eeaae006 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -346,7 +346,7 @@ static int encode_frame(AVCodecContext* avc_context, AVPacket *pkt, // HACK: assumes no encoder delay, this is true until libtheora becomes // multithreaded (which will be disabled unless explicitly requested) - pkt->pts = pkt->dts = frame->pts; + pkt->pts = frame->pts; pkt->duration = frame->duration; ret = ff_encode_reordered_opaque(avc_context, pkt, frame); From patchwork Wed Jan 25 16:55:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40113 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546716pzj; Wed, 25 Jan 2023 08:57:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXuEnUuEguocuO44n5h0A3+s8b9CF36fTodg5u9u4jm+EX7qO0jHSp6Cb1TVtXOWbSuytNFm X-Received: by 2002:a17:906:4d0a:b0:84d:3e38:2f0c with SMTP id r10-20020a1709064d0a00b0084d3e382f0cmr47729216eju.67.1674665849590; Wed, 25 Jan 2023 08:57:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665849; cv=none; d=google.com; s=arc-20160816; b=ios7JjgMl2tPaUy0QOMbHStqbJTbqdkeFyvWIpynVN/SSVGDoCLVGYNIYf3WJq1vXY LFaNlkwEeHll3AeQ9zSn9EsosZzwbGPj4d4lGE9HUwXWoRip64lW/qb3X9l8J2FIXUno 7dp1ydiCg/Ye27HQKFjrPUPchwI2uJOpuX2GrKTcEbrVRcFZIiv7BD/i3poc0zw8wJlq 0p6EjG3xtqJ6rm4HuM34+oTDLSDL//X6Ahm5pDYJ8c1XD2GWM9TiAqFZ6RKtw4IXhjrj i+A5Ou9mgyTrxEz7NO+F+J3uDBsWn0MnpNpd3jBsIlSCRidBcFBk15QQHj5Ff/CvZt3+ /jBQ== 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=HI3gSL14zEJi8AE+FVJidEgj49HbyS4/UaAy+tv/+Bc=; b=wpz/v0mhqi8+oPYNnccb+bQTNrkRYTxZlPiKiwYx00HOE6G4p7F+C3pI5XQiS3G54a HUhNyRaQEImLaQIQ7DHhjvC+CwHQ1jEMyMbcdWFdLRekmxAO5hysaAaJN9e0ds78V+5H MEVq+iGeNj4aOGuBx1z/hS13hW5GkSQcng4Gk9qo9So8S20XChaQqOVNcu4/bbWuRtbk 5ONX/jeMv2uJPGm9trVkgc0H1pTyZ9MBm+IclABG5vHIWjdWsvPx5nwZFfHqp1+6jKfy AaWw9XvK/swgqY+xO1/JJaXXj2G31miFVYSLdERfLJAZ1GLKkN8upFrGtJV54IpxLoUm z20Q== 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 mz9-20020a1709071b8900b008776869fbfbsi6230962ejc.27.2023.01.25.08.57.29; Wed, 25 Jan 2023 08:57:29 -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 408C968BD0F; Wed, 25 Jan 2023 18:56:28 +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 2C30368BD36 for ; Wed, 25 Jan 2023 18:56:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A5D7D2404F5 for ; Wed, 25 Jan 2023 17:56:20 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id BHwAKd-IDJST for ; Wed, 25 Jan 2023 17:56:20 +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 40869240705 for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1C8D13A0455 for ; Wed, 25 Jan 2023 17:55:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:31 +0100 Message-Id: <20230125165537.5371-13-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/19] lavc/mpegvideo_enc: 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: VSIT/YwtwY5M For delay-capable encoders, i.e. mpeg12 and mpeg4video. Generic code in encode.c already handles this for all other mpegvideo encoders. --- libavcodec/mpeg12enc.c | 6 ++++-- libavcodec/mpeg4videoenc.c | 3 ++- libavcodec/mpegvideo_enc.c | 9 +++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 3ad1cd84a1..ff3d737e2a 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -1246,7 +1246,8 @@ const FFCodec ff_mpeg1video_encoder = { .p.supported_framerates = ff_mpeg12_frame_rate_tab + 1, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.priv_class = &mpeg1_class, }; @@ -1264,7 +1265,8 @@ const FFCodec ff_mpeg2video_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.priv_class = &mpeg2_class, }; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index a2a14afbd0..f7d48490f9 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1403,7 +1403,8 @@ const FFCodec ff_mpeg4_encoder = { FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), .close = ff_mpv_encode_end, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.priv_class = &mpeg4enc_class, }; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 9b11c5c05a..e77d5bcd57 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1952,6 +1952,7 @@ vbv_retry: s->total_bits += s->frame_bits; pkt->pts = s->current_picture.f->pts; + pkt->duration = s->current_picture.f->duration; if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) { if (!s->current_picture.f->coded_picture_number) pkt->dts = pkt->pts - s->dts_delta; @@ -1960,6 +1961,14 @@ vbv_retry: s->reordered_pts = pkt->pts; } else pkt->dts = pkt->pts; + + // the no-delay case is handled in generic code + if (avctx->codec->capabilities & AV_CODEC_CAP_DELAY) { + ret = ff_encode_reordered_opaque(avctx, pkt, s->current_picture.f); + if (ret < 0) + return ret; + } + if (s->current_picture.f->key_frame) pkt->flags |= AV_PKT_FLAG_KEY; if (s->mb_info) From patchwork Wed Jan 25 16:55:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40115 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp546884pzj; Wed, 25 Jan 2023 08:57:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXvlbIZOPZ3Bra2CPo8AJoMvo5VxrGlQC0gJ3OoC5nbcaKp+M17HhTcwBD4tusSk2tlU0TIJ X-Received: by 2002:a17:906:7c3:b0:870:95b6:94a4 with SMTP id m3-20020a17090607c300b0087095b694a4mr33012689ejc.48.1674665866937; Wed, 25 Jan 2023 08:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665866; cv=none; d=google.com; s=arc-20160816; b=R20JSCHTgVMmUhxIHbW9rclNhB5PApN+MXmSF9159iEOoOP88fF8w98Y6RXHYdOpy6 xj5frjTAGtki7xtMtByV76/0cKtCjCGnqC8Q4DWh/4OidxbsmxDA/4rw0Gl2w0aeoDwD t21R/b9sJx+JF0EqHMVtyOTqOx6d1Sgvn6+Qq9aFGN57zV9gN46OpT91/s+OlzVZl2xH E7OZZ5JbcZKZA9bAhX3A6v2suIHFGpRG6rCCGUEDL945KEFSzp9om9DcX2W9Cak33mm0 62gFDX5yguwkJopNZ7sz9ZVWchX5MHubkuzJ64Xep9piaGWS1wZ2vIXS9P25YqCDWFTU BFOg== 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=rvCm1FJoI+4wMC0Ui8mdXRsEAj5kbYpQR/46qmjRKGg=; b=WA98acjkrJRBPZAY2til6T/ftHqtcPRgSeWhDDVJ3st0zb74SbT3juGUb3db3vyLom C9zM9ApRNX8awEHIo4BAHndzzVCXmNgmWBQD5sgnIrm9G2vIaHfKwflEM/CRXvrx6v+6 pXPG/ahLWj6z9/eH6hruh4fGBYhyW7+2nm7p+iiDQFtLSBJ3P9REPaYIYzSBN9LYpojH kTK+05Zeu/3TqQ2ZUFcZct36bhAtpMI+d4Qt8r+tMC2hGAslFYrD2kPmf05DGerHj55c Ll9eSD7rGRMEG+2XGLtMpXCpjX36aDhRxrVzp99vVeTw08/MKvGxI8agydAm0s8YAtAM gG3A== 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 fx36-20020a1709069ea400b0087752be1da1si6574817ejc.791.2023.01.25.08.57.46; Wed, 25 Jan 2023 08:57:46 -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 48A5268BDF2; Wed, 25 Jan 2023 18:56:30 +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 C9A8068BD50 for ; Wed, 25 Jan 2023 18:56:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 93D23240178 for ; Wed, 25 Jan 2023 17:56:21 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id hLCTj-kXl-8f for ; Wed, 25 Jan 2023 17:56:21 +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 5281A240D03 for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 33F703A04C3 for ; Wed, 25 Jan 2023 17:55:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:33 +0100 Message-Id: <20230125165537.5371-15-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/19] lavc/libwebpenc_animencoder: stop setting dts unnecessarily 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: jxN5AmjhifCl WebP does not have reordering, so dts=pts is set by the generic code. --- libavcodec/libwebpenc_animencoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c index 0f2c190c8c..977f880d6c 100644 --- a/libavcodec/libwebpenc_animencoder.c +++ b/libavcodec/libwebpenc_animencoder.c @@ -77,7 +77,7 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt, memcpy(pkt->data, assembled_data.bytes, assembled_data.size); WebPDataClear(&assembled_data); s->done = 1; - pkt->pts = pkt->dts = s->first_frame_pts; + pkt->pts = s->first_frame_pts; *got_packet = 1; return 0; } else { From patchwork Wed Jan 25 16:55:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40121 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp547347pzj; Wed, 25 Jan 2023 08:58:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXsPQvInVsf5rzca3VS4t+ZKokKdQLh6WtGvgkZyaB16/LjHex8SjjmS8gfGnMyP+pOTHegy X-Received: by 2002:a17:906:774f:b0:870:94e:13f9 with SMTP id o15-20020a170906774f00b00870094e13f9mr34888626ejn.0.1674665920595; Wed, 25 Jan 2023 08:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665920; cv=none; d=google.com; s=arc-20160816; b=jv0ZSkHMCW00NWR1mKeTKwDXAMh3fXGJgdHoR8v/l7r1rLnjKuQmXH2NDqHO/rroBr 0+zQQuPMIbDtINbINXukVa6Q+ZqVIelEgoQm89Ieb4nMawVEPa3cwG/oObwzvwIvzCS8 dUiVYMDH803LJzsK4/HlNfJv/SgEcSvstfY5e+csnNPCxG6LJX9Hejdhkc2XooU9ayGj 2foEfqR+NvHAm/4cA48H38YzNWVQmC7/7v2zRkxI7hiMONXaoSeTS3Rp32HGzSQ2hPZY TYB+gy4nUtGvGDAeGCLkOt2mUiYo+BS3SCY0KC5mNp7jUkNb8bvnnAJeJ3p04yjKzJZO Frfg== 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=P7g0wrN75/iE4/5JerJWKg0gnfV7jlvbqIzSaUtr0rs=; b=rxtrESJPrzcSEIGZtEaPLkAzp2UsYABI9Lo/afSdD7/HqH14p/zvn4aqcSVIpI8T0a 2665OB1+WLUSiFp+ODQtbpzTEMJEbluW+ON0SK3xVZRNHnu+zlss9iajQCL1eyH+fsBm NSlpw99fwDthneuVeMChcG1TmOB8vXPsYB94pfGPC8qMg/Bgac8k5MyR50oDU2C6Yces YfwxVdrFupGcvjnpjHnIuvyebcFeeCvl/Vv9W4b3oVwlJtXUNDk4iBwE0KMTeroEcEFb w/UOfQ4QrWS7c6s4t2R55u0JRL2ZLl7jxl6HHGE/zX9w2UX3VYLi8KMgixvKGo8iz5nw mDww== 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 j9-20020a170906534900b0087814312d0csi3149034ejo.900.2023.01.25.08.58.40; Wed, 25 Jan 2023 08:58:40 -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 3D38668BD90; Wed, 25 Jan 2023 18:56:36 +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 EFC2168BDCB for ; Wed, 25 Jan 2023 18:56:19 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E32312406CB for ; Wed, 25 Jan 2023 17:56:17 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id EzOkaI1FXykT for ; Wed, 25 Jan 2023 17:56:17 +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 39F632406CE for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 575C53A0505 for ; Wed, 25 Jan 2023 17:55:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:36 +0100 Message-Id: <20230125165537.5371-18-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/19] lavc/libx265: pass through frame durations to encoded packets 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: Ng1yQCRSrUDy --- libavcodec/libx265.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index a71f1f76d3..6fc189f1b5 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -43,6 +43,7 @@ typedef struct ReorderedData { int64_t reordered_opaque; + int64_t duration; void *frame_opaque; AVBufferRef *frame_opaque_ref; @@ -616,6 +617,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } rd = &ctx->rd[rd_idx]; + rd->duration = pic->duration; rd->reordered_opaque = pic->reordered_opaque; if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { rd->frame_opaque = pic->opaque; @@ -755,6 +757,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, ReorderedData *rd = &ctx->rd[idx]; avctx->reordered_opaque = rd->reordered_opaque; + pkt->duration = rd->duration; if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) { pkt->opaque = rd->frame_opaque; From patchwork Wed Jan 25 16:55:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40118 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp547142pzj; Wed, 25 Jan 2023 08:58:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLKURywBcLuMeCH5z8SkOJIWNYKJd01S3T2VbOMGT1agjYWOdReKthv0JYElWM67NPMcC0 X-Received: by 2002:a50:fe87:0:b0:49b:7416:e3f9 with SMTP id d7-20020a50fe87000000b0049b7416e3f9mr35418497edt.35.1674665899326; Wed, 25 Jan 2023 08:58:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674665899; cv=none; d=google.com; s=arc-20160816; b=ePUBCTehlQyZO8jDdf1115vh4Jxy6b82ehf83UUsho6v2P6jdtiPSW/qUuidp2e0q0 QYhR/hB/6yMYgWCZ0pQ3my6zfUG71JlaYYl/tjNiOcvAdR5nzGhsAcYcSUe5p3/RcS/t 5rY+M5vAmw8oYlM7UzVPmoWNbvzLVG6ZOUXEbXt8rQUNVGRbEXEc84YLDjId/4DnTH7e Q1i6n5GVwAZsH7WSB2E1EzADSIowBe54IH931SsOLOikanTMCojrEChV57xI5WWBoVH5 fhN17cej5HEMoQKTz1Lr13sS4ZBseeBxngjqfw/9xUUvvAzYKTXoXXa6SajQDyH5pYDy D5HA== 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=N6ak7J3LRZt0OpwHg7nD7XkEMzRYMI1prM75oLvRa20=; b=p/tTv2//6A3UN7iC7u10ePoWvMcyAPhVXmjtLuqamjelk5oLT99aupnrkXSyb8ZQT5 Wn5fgAeIFPH7X55BFRDWHnb0WOoEt/r4At3Jtt+bHx/2lVjFpOXiIlXrZjzZ0Yna+BKG SM9h0hiJvV1zB6ESGvOnvGM5UsSYDJaY3JzWB20ebiDdI3F0YxhQjAoslPgTQQw0iJPM NcTjKLN0EQjyCpq3rBcy7rJ1nPXGaX+Mt79Rd2C40JrGNGRUBjf3NGMciXenPdhSh13F 2cqXDJmUEJW7G9IuuJukkoIGad3rulNtWLucHZPV/TVMd+GVMDEys2XeQfxXVyEovTek dIhw== 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 m11-20020a50ef0b000000b0049b5322126dsi6842177eds.425.2023.01.25.08.57.55; Wed, 25 Jan 2023 08:58:19 -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 5F3C468BDF0; Wed, 25 Jan 2023 18:56:31 +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 878C268BAEB for ; Wed, 25 Jan 2023 18:56:22 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3DBD1240178 for ; Wed, 25 Jan 2023 17:56:22 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id E2j1LCUOLwFh for ; Wed, 25 Jan 2023 17:56:20 +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 54FAD240D0E for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 630903A0528 for ; Wed, 25 Jan 2023 17:55:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:37 +0100 Message-Id: <20230125165537.5371-19-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/19] lavc/libaomenc: pass through frame durations to encoded packets 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: Q6VAP9wKSJ89 --- libavcodec/libaomenc.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index bd576fdd3a..0b88102c77 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -23,6 +23,8 @@ * AV1 encoder support via libaom */ +#include + #define AOM_DISABLE_CTRL_TYPECHECKS 1 #include #include @@ -1094,6 +1096,7 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, } memcpy(pkt->data, cx_frame->buf, pkt->size); pkt->pts = pkt->dts = cx_frame->pts; + pkt->duration = cx_frame->duration; if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) { pkt->flags |= AV_PKT_FLAG_KEY; @@ -1275,6 +1278,7 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, AOMContext *ctx = avctx->priv_data; struct aom_image *rawimg = NULL; int64_t timestamp = 0; + unsigned long duration = 0; int res, coded_size; aom_enc_frame_flags_t flags = 0; @@ -1287,6 +1291,13 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, rawimg->stride[AOM_PLANE_U] = frame->linesize[1]; rawimg->stride[AOM_PLANE_V] = frame->linesize[2]; timestamp = frame->pts; + + if (frame->duration > ULONG_MAX) { + av_log(avctx, AV_LOG_WARNING, + "Frame duration too large: %"PRId64"\n", frame->duration); + } else + duration = frame->duration ? frame->duration : avctx->ticks_per_frame; + switch (frame->color_range) { case AVCOL_RANGE_MPEG: rawimg->range = AOM_CR_STUDIO_RANGE; @@ -1300,8 +1311,7 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, flags |= AOM_EFLAG_FORCE_KF; } - res = aom_codec_encode(&ctx->encoder, rawimg, timestamp, - avctx->ticks_per_frame, flags); + res = aom_codec_encode(&ctx->encoder, rawimg, timestamp, duration, flags); if (res != AOM_CODEC_OK) { log_encoder_error(avctx, "Error encoding frame"); return AVERROR_INVALIDDATA;