From patchwork Sun Jan 17 12:38:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 24996 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 745F044B9E5 for ; Sun, 17 Jan 2021 14:46:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 50374680A25; Sun, 17 Jan 2021 14:46:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 847696804D5 for ; Sun, 17 Jan 2021 14:46:08 +0200 (EET) Received: by mail-wr1-f41.google.com with SMTP id c5so13827612wrp.6 for ; Sun, 17 Jan 2021 04:46:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=R7Zz+yCrXAiHQSvo9Wawt1iGeusaZeWv2ay1gXVEuJA=; b=KV0qwWPCkFpEmeH7V1fdFUsjmeWzHNuKSWFAPzgRqWmTgeo/tn7NWYvIc8WJVOqPAN OQxVzQb0c9RnpRVWigJqq8LNxqD4th1Q8kwNzjBOWTUpC3TTAWnQK37K6cu4tp3LOrXj IlsaPybyGf1L/dIcOfKFBdDm+SQdBGNlVsk+5f6OmA24XmBFlNKRM803ZkK2mxQeCvsZ J/07voEkP2P5HsAKI5rCCj8/oA55+aUq47Q+YwDiLvfE4RGNrpbeqKknrWVi2n8DYRYG W5Yrods4hipsJLutSoBZMkkXntmlJcO9pLYP20Jd//LcgJedYnbf/vwgyUTbitVEBJRJ AVMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R7Zz+yCrXAiHQSvo9Wawt1iGeusaZeWv2ay1gXVEuJA=; b=Jd97IK2sPoWpd+KCv10AkoEVepNfJoZmdpY5UUi5fa1OVt8fXn8N+DgUtBdBgMa1R6 uWYe55X5/thNyA50g+69TAFr0xjQPOLdvribK+XxkSdh62wamkgHo1x9xYV05zpu2uRx i1kQfBOR889U0f0yThzc1+/bMaPIqJxU9W7NLF3qeu8Elrc+BKKXalgBimNu7RbgNmQJ FGiAlcHgq6Z3SMmKfAjtnbM8amURHmxi60fRLrr4Ffjpg3gMLbGN/8Q17XiM070ac57P V4SNGx3vymxIeVLJjh1J96blrWPnUXhcROvt4CErDRhudYxHHDFSfVGCyCC5d2zEYSGa DMrQ== X-Gm-Message-State: AOAM530CQv3DSiBsDYZQPzOKLUNFSG9o9anHsMf2h1G/24e+/mxuGKdD WCvvODN+LuIZ3gXOQm/G8/JmbMUNCKA= X-Google-Smtp-Source: ABdhPJyxKw8d8euZpHOuCEDGg8kgxfnWkxOzHXdGg7CZxFxie5iVuccrVpg6jVBYQ7ZnzvOrc15DiA== X-Received: by 2002:adf:82c5:: with SMTP id 63mr21777283wrc.38.1610887101419; Sun, 17 Jan 2021 04:38:21 -0800 (PST) Received: from localhost.localdomain ([82.129.110.36]) by smtp.gmail.com with ESMTPSA id i131sm19650767wmi.25.2021.01.17.04.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 04:38:20 -0800 (PST) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Jan 2021 12:38:08 +0000 Message-Id: <20210117123808.265582-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210114135558.58119-1-derek.buitenhuis@gmail.com> References: <20210114135558.58119-1-derek.buitenhuis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2 v2] avcodec/librav1e: Pass through timestamps as opaque user data X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" avcodec has no facilities to generate timestamps properly from output frame numbers (and it would be wrong for VFR anyway), so pass through the timestamps using rav1e's opaque user data feature, which was added in v0.4.0. This bumps the minimum librav1e version to 0.4.0. Signed-off-by: Derek Buitenhuis --- configure | 2 +- libavcodec/av1dec.c | 2 +- libavcodec/librav1e.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 900505756b..54fbbd6b5f 100755 --- a/configure +++ b/configure @@ -6408,7 +6408,7 @@ enabled libopus && { } enabled libpulse && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new enabled librabbitmq && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection -enabled librav1e && require_pkg_config librav1e "rav1e >= 0.1.0" rav1e.h rav1e_context_new +enabled librav1e && require_pkg_config librav1e "rav1e >= 0.4.0" rav1e.h rav1e_context_new enabled librsvg && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo enabled librtmp && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket enabled librubberband && require_pkg_config librubberband "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append librubberband_extralibs "-lstdc++" diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index a75d6744d3..385f8bfaca 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -929,7 +929,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, s->operating_point_idc = s->raw_seq->operating_point_idc[s->operating_point]; - if (s->pix_fmt == AV_PIX_FMT_NONE) { + if (avctx->pix_fmt == AV_PIX_FMT_NONE) { ret = get_pixel_format(avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index 46071bcdac..2d5acc7d8e 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -445,10 +445,18 @@ 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) { + av_log(avctx, AV_LOG_ERROR, "Could not allocate PTS buffer.\n"); + return AVERROR(ENOMEM); + } + *pts = frame->pts; + 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); return AVERROR(ENOMEM); } @@ -460,6 +468,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); } } @@ -535,7 +544,8 @@ retry: if (rpkt->frame_type == RA_FRAME_TYPE_KEY) pkt->flags |= AV_PKT_FLAG_KEY; - pkt->pts = pkt->dts = rpkt->input_frameno * avctx->ticks_per_frame; + pkt->pts = pkt->dts = *((int64_t *) rpkt->opaque); + av_free(rpkt->opaque); rav1e_packet_unref(rpkt); if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {