From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4ACF844F12 for ; Thu, 8 Dec 2022 16:31:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9B0BF68BB38; Thu, 8 Dec 2022 18:31:18 +0200 (EET) Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9A0A2689993 for ; Thu, 8 Dec 2022 18:31:12 +0200 (EET) Received: by mail-oo1-f46.google.com with SMTP id j6-20020a4ab1c6000000b004809a59818cso299335ooo.0 for ; Thu, 08 Dec 2022 08:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=AHq+rB8+HRd7T9uSlim1uWc/TUB4dHMKMcBFVi5PhOg=; b=CVkxzo5OX1bPoKGwhp3FYSN9XyMB/3zqUscLZGI8Q7TRMdAc4XTj626n9oL8GJKHTZ 9+xpM3o2w5nBiA2EZNTuTvTQX1pjsYtjUjpFeD7jWRHf85z31ueP8ch87V9fpK4RBt2o C5sJpDeIy1WMcWhue5MqS1X+4V0lDNEz0J+todajdZSc/jgpnDn5tbDXdPuVUKkxV7/1 j1MKPJMj/6yU06nDjFdO7+VDoGZ1SnZkXU/UwgTbDvZWPv+LwS0QYjlqpAK5HkPDi9QN Ih15wLk9xwM/EGcP+r9u6QTJuHCHZv7ngAK/BZVqZyj8Y2/zdcVWwg2OUh+BH2BKvfvh /hAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AHq+rB8+HRd7T9uSlim1uWc/TUB4dHMKMcBFVi5PhOg=; b=HuVBFN+Rlg9BCT2/rdko0UfPRrKjj3RFGSx09VOA5nZPT4bEoxDgz6/aeNQSWn7CLO +FbHspWKLccR7js/EuiBQSU7W7SNvp/QAZgWEgSSb+2cl+zvDoJcrNGfkT2sdMfASi+y D58PelkveZmTQGdzaFN18+/bX3qQiPUWfrryPOjqC5OjJvVXlmN3pA5DIR3cVyEGdMAY VOoFCi4b04pUz/Cz7YJYE2dFHxEJFaxv5f5XDd9HP4284GvrLO4jmfcw/Jc562qQnAJs Ohz2vQ6DCaFpU9y6HMOn7CiaNJXA7I+q0BkbhwNDaIgyLoUZ3wrTYUEchhvwPv+3dxwO VyYw== X-Gm-Message-State: ANoB5plBeYSUrHEUc2W6gLHkf1G9N/YlTne5UoWc4xEEYLmYZHwR+mBr VATp0WchgSnCDVmicfYf4CeQG/re0kM= X-Google-Smtp-Source: AA0mqf4QTXm0QQqXHrGzdBCRqUmnZM9h3VD18AtYNxsysPgg3at4n/h4Ql4M9McD8CcGN/uHrGZR6g== X-Received: by 2002:a4a:e090:0:b0:4a0:caa6:466a with SMTP id w16-20020a4ae090000000b004a0caa6466amr1060625oos.3.1670517070539; Thu, 08 Dec 2022 08:31:10 -0800 (PST) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id v188-20020a4a7cc5000000b004a066f9a7b4sm10119013ooc.34.2022.12.08.08.31.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 08:31:09 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Dec 2022 13:31:01 -0300 Message-Id: <20221208163101.4139-1-jamrial@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/libdav1d: honor the requested skip_frame level 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This supports dropping non-intra, non-key, or all frames. Signed-off-by: James Almer --- libavcodec/libdav1d.c | 51 +++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 028929404e..2f83a963e9 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -369,6 +369,37 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) return res; } +#if FF_DAV1D_VERSION_AT_LEAST(5,1) + dav1d_get_event_flags(dav1d->c, &event_flags); + if (c->pix_fmt == AV_PIX_FMT_NONE || + event_flags & DAV1D_EVENT_FLAG_NEW_SEQUENCE) +#endif + libdav1d_init_params(c, p->seq_hdr); + if (c->width != p->p.w || c->height != p->p.h) { + res = ff_set_dimensions(c, p->p.w, p->p.h); + if (res < 0) { + dav1d_picture_unref(p); + return 0; + } + } + + av_reduce(&c->sample_aspect_ratio.num, + &c->sample_aspect_ratio.den, + p->p.h * (int64_t)p->frame_hdr->render_width, + p->p.w * (int64_t)p->frame_hdr->render_height, + INT_MAX); + ff_set_sar(c, c->sample_aspect_ratio); + + if ((c->skip_frame >= AVDISCARD_NONINTRA && + (p->frame_hdr->frame_type != DAV1D_FRAME_TYPE_KEY && + p->frame_hdr->frame_type != DAV1D_FRAME_TYPE_INTRA)) || + (c->skip_frame >= AVDISCARD_NONKEY && + p->frame_hdr->frame_type != DAV1D_FRAME_TYPE_KEY) || + c->skip_frame >= AVDISCARD_ALL) { + dav1d_picture_unref(p); + return 0; + } + av_assert0(p->data[0] && p->allocator_data); // This requires the custom allocator above @@ -385,30 +416,12 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) frame->linesize[1] = p->stride[1]; frame->linesize[2] = p->stride[1]; -#if FF_DAV1D_VERSION_AT_LEAST(5,1) - dav1d_get_event_flags(dav1d->c, &event_flags); - if (c->pix_fmt == AV_PIX_FMT_NONE || - event_flags & DAV1D_EVENT_FLAG_NEW_SEQUENCE) -#endif - libdav1d_init_params(c, p->seq_hdr); res = ff_decode_frame_props(c, frame); if (res < 0) goto fail; frame->width = p->p.w; frame->height = p->p.h; - if (c->width != p->p.w || c->height != p->p.h) { - res = ff_set_dimensions(c, p->p.w, p->p.h); - if (res < 0) - goto fail; - } - - av_reduce(&frame->sample_aspect_ratio.num, - &frame->sample_aspect_ratio.den, - frame->height * (int64_t)p->frame_hdr->render_width, - frame->width * (int64_t)p->frame_hdr->render_height, - INT_MAX); - ff_set_sar(c, frame->sample_aspect_ratio); if (p->m.user_data.data) memcpy(&frame->reordered_opaque, p->m.user_data.data, sizeof(frame->reordered_opaque)); @@ -595,7 +608,7 @@ const FFCodec ff_libdav1d_decoder = { FF_CODEC_RECEIVE_FRAME_CB(libdav1d_receive_frame), .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | - FF_CODEC_CAP_AUTO_THREADS, + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_AUTO_THREADS, .p.priv_class = &libdav1d_class, .p.wrapper_name = "libdav1d", }; -- 2.38.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".