From patchwork Sun Nov 27 17:03:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39499 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp6959835pzb; Sun, 27 Nov 2022 09:07:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf4TaLEEbt3AQTWT/9bm4BwvX5a4pCQ5svG808x5kYDbqKNPzQEWJkf6rLe5gU6AYEuw9P+i X-Received: by 2002:a05:6402:530c:b0:462:df63:5ec5 with SMTP id eo12-20020a056402530c00b00462df635ec5mr44283527edb.147.1669568829305; Sun, 27 Nov 2022 09:07:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669568829; cv=none; d=google.com; s=arc-20160816; b=0yIsRAPWgiccG3SbsF865i5RmbHOI82AHozrSW9AFZk0P1c1m0HxNeuASGdPy2s5Ly jr34tpSB/Y7ElSOMbg1XgaXcZCtB3Tc6BnBRze9G0gakTGGSwzHzXG3HSsVjm5fcyKVX /EoTlq59LseYptPHRxu/7/0uzJAmcx/MspVtB7NbzuyedQs2qKvk9IGXhY2zqFurgKZy uCteMe7lOH8U+2FSA2QYCpd8YclauPezBA8N4byEvCLpoy2JTZt699/JlW/1nV4xYgRz lntDc3a+dKwcUJwB5oEGcx1dDphzBnfSry8Uau/RrgR79bk7gFG2BNEZb52EA9yP03KO 7UJA== 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=QvzDuwJrWZ23vHN/XUiur+iswVCUEp/D4yYUg8e3UK0=; b=yTzcmJ28hgwtQ9Eal8hVBqNjy+XDUa0WnFeHJUDbh1VBKeMp3jD34nWJJsvp7mKTvX YdmXNskIbN+hzax/vrlVIrwVDoL8I5qgGZBj5a6SZxqx1wEGJ7YHDCYWZDkGdkTM7s6b FXcydCXTVLDmLag9cFiPQ5odTpvtv+JNCa6cjPpg/FxZJhcd2o0HtjUInVL8PK8HWvHz G07ZutHMBeeyWTLVTkdZa7La+ym8cZCsByzXsoBgQeL+Ha8fdE9c+gqiKAGLQBnjB2Dt vEzsS6yu3YvwU7Id4OLY1jgbpjizIQcujrPo/5RS+ShVra1WA+n5dqplj+NNfcnr7pPv QyBQ== 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 qa41-20020a17090786a900b007771bc8dbb4si8617930ejc.781.2022.11.27.09.07.08; Sun, 27 Nov 2022 09:07:09 -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 2F42C68BABF; Sun, 27 Nov 2022 19:06:06 +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 8F09F68B6F0 for ; Sun, 27 Nov 2022 19:05:59 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3909E2406D1 for ; Sun, 27 Nov 2022 18:05:58 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id gWkcK0HZMEgw for ; Sun, 27 Nov 2022 18:05:57 +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 D654D240706 for ; Sun, 27 Nov 2022 18:05:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 036453A25FF for ; Sun, 27 Nov 2022 18:05:47 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Nov 2022 18:03:47 +0100 Message-Id: <20221127170351.11477-26-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221127170351.11477-1-anton@khirnov.net> References: <20221127170351.11477-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 26/30] 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: Ewx/D3g2ESsJ --- libavcodec/libtheoraenc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index da16c6372e..9b8404ce31 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -347,6 +347,19 @@ 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; + + if (avc_context->flags & AV_CODEC_FLAG_COPY_OPAQUE) { + pkt->opaque = frame->opaque; + if (frame->opaque_ref) { + pkt->opaque_ref = av_buffer_ref(frame->opaque_ref); + if (!pkt->opaque_ref) + return AVERROR(ENOMEM); + } + } + + avc_context->reordered_opaque = frame->reordered_opaque; + if (!(o_packet.granulepos & h->keyframe_mask)) pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; @@ -373,7 +386,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,