From patchwork Sun Jan 21 14:18:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Zheng X-Patchwork-Id: 45686 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a402:b0:199:de12:6fa6 with SMTP id z2csp943614pzk; Sun, 21 Jan 2024 06:19:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGLnzs4F3OW1WX4TEIfj6dlzGRS9lArpmpLZaPez/uOA7nfCi6b8/nQI9Qu+ES4+EW002d X-Received: by 2002:a17:906:9c93:b0:a30:685:7c56 with SMTP id fj19-20020a1709069c9300b00a3006857c56mr919103ejc.0.1705846754621; Sun, 21 Jan 2024 06:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705846754; cv=none; d=google.com; s=arc-20160816; b=vTll2F4QwrUi0Zk4lotZeWpAwbMTm54LOYnApigP7ZgwLjW6kOOkXqh3gC8tXtaFY8 btiKQcEVFqVtNZOCUMoZFkPY7wWHbVXlWF7bQC4HxP8UCE0Mi0W8Q2ijUIjxxW3xk8lO PTL3LzV0er9DIn7QfcU0d2kRehR/kPebxK9H9Z68PG+tsyQXNUvRyqcGQ3iCeIyYH+13 8CQSBO8IpwafXITSoP+2ctbt9wZbIwRy7rT5Amsxq+ZuKieOloY7hFQkUnrnJG1U0zY0 qDFDG1/g68l/kMKbVRxj2x/vQkTe1b3hezgTZ62LzU9kIt7rJogwocqRzTPfHB3IG62p VcZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=nTzopak6v6MG5x/oUrpKBs1mOAvrTVqcj22T0QNygoM=; fh=iiAW4vjlCGdXV3Yszi/eNCPr6t9/oDQbs1mdNL59KvI=; b=RAu5xWTRjJO2GScGEzwqPr1ySefVKyooKjbf6mmNkCUoUDV+32nMpvcl01YJrzzmTz IQn9+hZELv6HzO7RrLrK2EIQ/3MrG/NmZVfhdRfsC79ofGumF469JqlNCwMlAhFyhC23 aByzhQTrY1/5PEA1VMaXCv2HY1lN0nEM6StFmd+tU3D8oZVRgwS1AmfikdvN6C/T5DAm pp6/RheWpIQLuLAbATLTLJuzsTv54OVj2gyg5wBpQxE7B1CsrzEIb086nzxOzwQpR5X5 duZRXzPtGEMMnzFRdOoRedIfsJFBOiNt9c8X9gD7J4rEh1QC7NyXTkP3cybm4k2LGDmi K7CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=cOedrLxj; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ox5-20020a170907100500b00a2a637bfe68si9274288ejb.335.2024.01.21.06.19.14; Sun, 21 Jan 2024 06:19:14 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=cOedrLxj; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C19FD68CFDD; Sun, 21 Jan 2024 16:19:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 819B168CBFD for ; Sun, 21 Jan 2024 16:19:03 +0200 (EET) Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5cdf76cde78so952255a12.1 for ; Sun, 21 Jan 2024 06:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705846741; x=1706451541; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BEH7AsBHyzY0rXianDZvQgFBhPZGdCQZE4lkFzoNyh0=; b=cOedrLxj1fl/3OFAUTI44HDww9TmnUe6hDBk43fFPkQshhiKNIBAa5ouM9pSJiT+dT qMFHo2vc8Zxbl2rbAJSZNN2uv7BEkH8Z43luY3QE74Et6xunZDsg5IcfIvGiMEaIB92c 5gKg3uV3KWx/7A1mzm6sF5IFA8bB8ywMzXGB8ZFgdW87+CEAkDBtx9JQQ1PdRIjxETyl CP5oMH0CSti8S0f74Nxfhluu2Y5yWnMsOi7glVDmIwrfXKY8Om1SCVWXafjPqiLF19sI OQSoOh0y2DZHi5oIGRQDM7SN0nxNRKJCPXKzN2q6IbRFrnXz6YkPfL9uWmw/jcUJC1eY r/lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705846741; x=1706451541; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BEH7AsBHyzY0rXianDZvQgFBhPZGdCQZE4lkFzoNyh0=; b=ONcFF+2CnywJ2akrwD2debd4bD1w6nS2rvl7lyZQjYwuywpmQrhwn8cluJ+fDUJCcz EJGZwPlOCSaTC//kEFZ0YPW/SvZS0j3YSeglgWG+1uP5v66NF0eTQ+CoVcmfKBp8WRes n5xu9JmZ+jfSLRIMa/M0dHPhDNZVt0nJRYqJ2skR/4kjjOX0aIDZdk+HB6ca9HXxPRJ9 aJUp83W1JQmE/cgb21Fg8aGtOTh01XSvoiEWyCxJBmiRmVwicoD7yAMXoF4gDBrGr/7c 58ZTZTlODWehvFCsZAYT/jUzq1g0AAouKe1MSUnWxme4AtRTV/Be4Eg90nUyEsmbCa9d fBow== X-Gm-Message-State: AOJu0YwsDEbZesW0Ikg0pJQ/rzbNSrzTObvL+64tYsLrl7bG/zVJpPq3 /3pO+5IE9NvxASqcK6jtv0Ygnsz030g/+i+DaWxmYh3L7rEEU72cCiWiIRUBAWspbw== X-Received: by 2002:a17:902:82cb:b0:1d6:96b:5de with SMTP id u11-20020a17090282cb00b001d6096b05demr1270737plz.51.1705846741103; Sun, 21 Jan 2024 06:19:01 -0800 (PST) Received: from localhost.localdomain ([183.242.63.6]) by smtp.gmail.com with ESMTPSA id bg4-20020a1709028e8400b001d4b73f60e4sm5840726plb.149.2024.01.21.06.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 06:19:00 -0800 (PST) From: "jianfeng.zheng" X-Google-Original-From: "jianfeng.zheng" To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Jan 2024 22:18:40 +0800 Message-Id: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [vaapi-cavs 1/7] cavs: add cavs profile defs 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 Cc: "jianfeng.zheng" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BarG8h+1Zn3A Signed-off-by: jianfeng.zheng --- libavcodec/defs.h | 3 +++ libavcodec/profiles.c | 6 ++++++ libavcodec/profiles.h | 1 + 3 files changed, 10 insertions(+) diff --git a/libavcodec/defs.h b/libavcodec/defs.h index 00d840ec19..d59816a70f 100644 --- a/libavcodec/defs.h +++ b/libavcodec/defs.h @@ -192,6 +192,9 @@ #define AV_PROFILE_EVC_BASELINE 0 #define AV_PROFILE_EVC_MAIN 1 +#define AV_PROFILE_CAVS_JIZHUN 0x20 +#define AV_PROFILE_CAVS_GUANGDIAN 0x48 + #define AV_LEVEL_UNKNOWN -99 diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c index 5bb8f150e6..b312f12281 100644 --- a/libavcodec/profiles.c +++ b/libavcodec/profiles.c @@ -200,4 +200,10 @@ const AVProfile ff_evc_profiles[] = { { AV_PROFILE_UNKNOWN }, }; +const AVProfile ff_cavs_profiles[] = { + { AV_PROFILE_CAVS_JIZHUN, "Jizhun" }, + { AV_PROFILE_CAVS_GUANGDIAN, "Guangdian" }, + { AV_PROFILE_UNKNOWN }, +}; + #endif /* !CONFIG_SMALL */ diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h index 270430a48b..9a2b348ad4 100644 --- a/libavcodec/profiles.h +++ b/libavcodec/profiles.h @@ -75,5 +75,6 @@ extern const AVProfile ff_prores_profiles[]; extern const AVProfile ff_mjpeg_profiles[]; extern const AVProfile ff_arib_caption_profiles[]; extern const AVProfile ff_evc_profiles[]; +extern const AVProfile ff_cavs_profiles[]; #endif /* AVCODEC_PROFILES_H */ From patchwork Sun Jan 21 14:18:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Zheng X-Patchwork-Id: 45687 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a402:b0:199:de12:6fa6 with SMTP id z2csp943677pzk; Sun, 21 Jan 2024 06:19:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGph0XU1jc8rohj/4/ymJljebDwctbfSijSLoF1I8yFTLuUHdI/o9wjAKkfwQ25vCa3u3hj X-Received: by 2002:a17:907:c314:b0:a30:393e:410b with SMTP id tl20-20020a170907c31400b00a30393e410bmr263642ejc.185.1705846763974; Sun, 21 Jan 2024 06:19:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705846763; cv=none; d=google.com; s=arc-20160816; b=u96YZIYXAYwOso4tkgiu04IAcI/CPa7jeJlKJh5OeGnA+/UofGlb5nOHF71vlXbmau 7fbVJEmudUByyazO+K0c0WH+FP/OUrTGfUcEt0iJcgNJjZJdX4CATJi933L/vSON6PLe QV29irE7qh3YX6Rs/vSNw4mhsa+6s89XWm2iL/uTBRaJAxCtb8Z9h827qJEVZCaZs/45 nR4yK84mAhj6L5jrYt4fCLcA5NvYR1EvQWQh975ngMLVGaY2YpBKvVWHFCin6kS2389g /TbQ4T+3FZQZvhqiPB0ajqN+vtdWZfDAOpTYVtIx8AhcbtZ6Dfb/1gVbKn4WmQ3w2SL5 8Cfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:dkim-signature:delivered-to; bh=t7pR37odR26sKiEIykXXnPywDpm3alFuzvq9k+pnWPU=; fh=iiAW4vjlCGdXV3Yszi/eNCPr6t9/oDQbs1mdNL59KvI=; b=yX3Imtu3PGDohpvdzyaW+XDD4mGEb6uxHNsYcOytpFjMPFsTptONLPgaJoNAwZqX0P mZV2Dje89R6RPiJtQV5FAGGzwd4JIqRgQxtbh9BB7+d8y26SUpjQUU3jWccze7XRDnli OylxO7aq0TURPXlxYVhN/ib+9PF1NE4lbrZIzGn+VOWdyf7YezgNui0SuJ3bT+eSRX5+ 60Ow2r3VTAUHo4R2VOnQuDt9Ov17g6HAbw3rcbkXn4p3ShAvI938/AgBlPqZRx6jhf/b mWEr0ngc3kAvw5b1zhw+VfqQxv6LMQa4B89KBsbcHEPq6f5KFczXZqcklSb9ELBxoqL/ gYzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=RcLDsmMS; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e3-20020a17090681c300b00a2f0df863aesi3871902ejx.450.2024.01.21.06.19.23; Sun, 21 Jan 2024 06:19:23 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=RcLDsmMS; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DEFCE68D033; Sun, 21 Jan 2024 16:19:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 79E4568D033 for ; Sun, 21 Jan 2024 16:19:11 +0200 (EET) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5ceb3fe708eso925723a12.3 for ; Sun, 21 Jan 2024 06:19:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705846749; x=1706451549; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K4JYsrgC2PjbtzY9Vs/RAN3nvulMwAmwSNEl/2WGHrY=; b=RcLDsmMSDu0t/u0F62LfkjsuNRo4AOx+0IX8wIuYIRuVAY+b7ShWRwIi7DDgxh23/Q wa7RBdF4WY5pOIw0kqrcqDPMPuUkhsmvrMh9ESSauhvFilT0yFMWMX7/+PVX5nS7sBJC YqbDgizqUsvXwcRyUVQzODDsqATgSk8A5zg3wA2nIgroDf3OzQEsWJ9wRGmM3Jz1ApNZ sZZT7aIISgIkhclll5+VtzAbEZK+yH+sODL+18lqLg0Bea6ANKHzFcEzGIrBHgIGnt32 FCYhm8GQjahxAH9gHcpPrENP49sJz0niK2DHnfSq7OXhUc8wO1WbMu3dGqOLU1A1RI1c pZVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705846749; x=1706451549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K4JYsrgC2PjbtzY9Vs/RAN3nvulMwAmwSNEl/2WGHrY=; b=KblbU0GV1acLU0wWnCYi1wX9lB4OMatFXcquwul7nd9wePd0rfmOY3fewyB3G3nzo5 YRaSaKxdeFLTbHHQFOrfjUp1uE59KW/44jxRr5v1PVAHKlEZYjEuchaXQmGovMueRz3/ 5q5ShaxsAg2qunPuodtvom5+0+lGk8J/j67BAX4s65cZAjWQwLWq+RwP2ebg5hP5LwHt xKEm+dk/zf2mKPYlsXosMbLd2avo6EhKrAMgWEyTw51Ay2ODgg8UuPB2tcK2fLDVXTeG RflV+Ny1O0/gKKqmvl7OXkSKOwu5Hrlcv+NmXAv8qmbusNxsQpwG/kqjVvMA7PS7pJfA JEuw== X-Gm-Message-State: AOJu0YyZxlBoLKlNn2VXXczCMrEIqHiRgFax0ojrHIkxVT1930mFVbk6 W27zGcKDkqn+5MXXdXVU2KeENbn9z7dYNGNdxcsRuXTRkysQmPh6TAE1VHdH0cU= X-Received: by 2002:a17:902:d48e:b0:1d7:683:5a31 with SMTP id c14-20020a170902d48e00b001d706835a31mr1376232plg.133.1705846749302; Sun, 21 Jan 2024 06:19:09 -0800 (PST) Received: from localhost.localdomain ([183.242.63.6]) by smtp.gmail.com with ESMTPSA id bg4-20020a1709028e8400b001d4b73f60e4sm5840726plb.149.2024.01.21.06.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 06:19:08 -0800 (PST) From: "jianfeng.zheng" X-Google-Original-From: "jianfeng.zheng" To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Jan 2024 22:18:41 +0800 Message-Id: <20240121141846.4077778-2-jianfeng.zheng@mthreads.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> References: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [vaapi-cavs 2/7] cavs: skip bits between pic header and slc header 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 Cc: "jianfeng.zheng" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: tgSYDyZ7Ba1a Signed-off-by: jianfeng.zheng --- libavcodec/cavs.h | 2 + libavcodec/cavsdec.c | 87 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h index 244c322b35..ad49abff92 100644 --- a/libavcodec/cavs.h +++ b/libavcodec/cavs.h @@ -39,8 +39,10 @@ #define EXT_START_CODE 0x000001b5 #define USER_START_CODE 0x000001b2 #define CAVS_START_CODE 0x000001b0 +#define VIDEO_SEQ_END_CODE 0x000001b1 #define PIC_I_START_CODE 0x000001b3 #define PIC_PB_START_CODE 0x000001b6 +#define VIDEO_EDIT_CODE 0x000001b7 #define A_AVAIL 1 #define B_AVAIL 2 diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index b356da0b04..9742bd1011 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -954,6 +954,80 @@ static inline int decode_slice_header(AVSContext *h, GetBitContext *gb) return 0; } +/** + * skip stuffing bits before next start code "0x000001" + * @return '0' no stuffing bits placed at h->gb being skip, else '1'. + */ +static inline int skip_stuffing_bits(AVSContext *h) +{ + GetBitContext gb0 = h->gb; + GetBitContext *gb = &h->gb; + const uint8_t *start; + const uint8_t *ptr; + const uint8_t *end; + int align; + int stuffing_zeros; + + /** + * According to spec, there should be one stuffing_bit '1' and + * 0~7 stuffing_bit '0'. But seems not all the stream follow + * "next_start_code()" strictly. + */ + align = (-get_bits_count(gb)) & 7; + if (align == 0 && show_bits_long(gb, 8) == 0x80) { + skip_bits_long(gb, 8); + } + + /** + * skip leading zero bytes before 0x 00 00 01 stc + */ + ptr = start = align_get_bits(gb); + end = gb->buffer_end; + while (ptr < end && *ptr == 0) + ptr++; + + if ((ptr >= end) || (*ptr == 1 && ptr - start >= 2)) { + stuffing_zeros = (ptr >= end ? end - start : ptr - start - 2); + if (stuffing_zeros > 0) + av_log(h->avctx, AV_LOG_DEBUG, "Skip 0x%x stuffing zeros @0x%x.\n", + stuffing_zeros, (int)(start - gb->buffer)); + skip_bits_long(gb, stuffing_zeros * 8); + return 1; + } else { + av_log(h->avctx, AV_LOG_DEBUG, "No next_start_code() found @0x%x.\n", + (int)(start - gb->buffer)); + goto restore_get_bits; + } + +restore_get_bits: + h->gb = gb0; + return 0; +} + +static inline int skip_extension_and_user_data(AVSContext *h) +{ + int stc = -1; + const uint8_t *start = align_get_bits(&h->gb); + const uint8_t *end = h->gb.buffer_end; + const uint8_t *ptr, *next; + + for (ptr = start; ptr + 4 < end; ptr = next) { + stc = show_bits_long(&h->gb, 32); + if (stc != EXT_START_CODE && stc != USER_START_CODE) { + break; + } + next = avpriv_find_start_code(ptr + 4, end, &stc); + if (next < end) { + next -= 4; + } + skip_bits(&h->gb, (next - ptr) * 8); + av_log(h->avctx, AV_LOG_DEBUG, "skip %d byte ext/user data\n", + (int)(next - ptr)); + } + + return ptr > start; +} + static inline int check_for_slice(AVSContext *h) { GetBitContext *gb = &h->gb; @@ -1019,6 +1093,8 @@ static int decode_pic(AVSContext *h) h->stream_revision = 1; if (h->stream_revision > 0) skip_bits(&h->gb, 1); //marker_bit + + av_log(h->avctx, AV_LOG_DEBUG, "stream_revision: %d\n", h->stream_revision); } if (get_bits_left(&h->gb) < 23) @@ -1096,6 +1172,11 @@ static int decode_pic(AVSContext *h) h->alpha_offset = h->beta_offset = 0; } + if (h->stream_revision > 0) { + skip_stuffing_bits(h); + skip_extension_and_user_data(h); + } + ret = 0; if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) { do { @@ -1309,6 +1390,12 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, case USER_START_CODE: //mpeg_decode_user_data(avctx, buf_ptr, input_size); break; + case VIDEO_EDIT_CODE: + av_log(h->avctx, AV_LOG_WARNING, "Skip video_edit_code\n"); + break; + case VIDEO_SEQ_END_CODE: + av_log(h->avctx, AV_LOG_WARNING, "Skip video_sequence_end_code\n"); + break; default: if (stc <= SLICE_MAX_START_CODE) { init_get_bits(&h->gb, buf_ptr, input_size); From patchwork Sun Jan 21 14:18:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Zheng X-Patchwork-Id: 45688 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a402:b0:199:de12:6fa6 with SMTP id z2csp943740pzk; Sun, 21 Jan 2024 06:19:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IELDwW9lzHNst4xD8SmOYsLag+f3t3MzHrAFPCKRJuhnTeUUtQlnpQ6LwNaI5pBNH0Q8piU X-Received: by 2002:a17:906:5256:b0:a23:36f7:4918 with SMTP id y22-20020a170906525600b00a2336f74918mr1358895ejm.72.1705846772809; Sun, 21 Jan 2024 06:19:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705846772; cv=none; d=google.com; s=arc-20160816; b=jQT7uFnvAurkBluJ4Rbo5E6XGPhqZNnzOieRzLM6bEAt1l75Rl8b3U6JfxlnUw20ZN jB5d2sTc1lJqpx7IuZsJBP9fj05WX95e6UXE4i/ev1zYpOO+Tju7DNYO7tbCyHtnxETn ROpRHRmZkkJcdq6ieoc7jEr+15UHJn0PVupRE29Q+Fb2Z/PvaDGcFmSWP5+1ZR2Fbymk 4MRCPT7FeBn0GRF1b+seU1VVDvd5O70Q8IsXSfEHjebCmLBSGYYZXOvWJWptsimM65ia DFhXX/lx+N7SgtSWgyr/Q2JSD2d7g0jbaxkt1EzkgFvuVPiaIbvZTGZYrBwqlZGuvo/e 5XFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:dkim-signature:delivered-to; bh=Q+wHlncoMYbyAdX+KnL85m77Xp+E8jAUuxGlEpOVKq0=; fh=iiAW4vjlCGdXV3Yszi/eNCPr6t9/oDQbs1mdNL59KvI=; b=t0KGyfEtbGsuAlsUvHfsO27Xuk9pVmB1vupTYWhEJdzQHFW5S3ADnhAv6bWSPDj9cH 51CDm1V9z8Rv5QubShCQvg7C5qYCt8gY5JTUj/7pF15fQ7+1lGBBWcnON/7mHJMALcaT MRm07eSK/w1TKYEQOevbK0IZyhyrh2CVT3FMrRNVMu9CeKcL0IbIYH1ZAa5IZcdnZ/aY CuUqqyxRl8y/u6NI3GgV1+3bcCym4IT0LjVg6qafEVLwovPd2w7iUJTutz2CAQPH5vMf q4dj3cj7bx+x+S+JP5ntR1ScTi0aOGmBt7OKcII7cnS2IIaUbHuKTG8mAeUDaIYXrN6b ByTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=WGexcPGl; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bq4-20020a170906d0c400b00a2d0868cde6si8221053ejb.1051.2024.01.21.06.19.32; Sun, 21 Jan 2024 06:19:32 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=WGexcPGl; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2099768D0AD; Sun, 21 Jan 2024 16:19:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 021AB68D097 for ; Sun, 21 Jan 2024 16:19:13 +0200 (EET) Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so1854807a12.1 for ; Sun, 21 Jan 2024 06:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705846752; x=1706451552; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WYZafPBqdMDof8dD2/PJZMnQ3SPjhkOUNZiBrki1PTM=; b=WGexcPGltdNW96RxAq0OD5fbqFkq2J1tkiMBtoT/S8f0LwrHQd5BVWoJz928W0Pi2S 7MJDT2915wRKE8S8ex5eKfAVinisTyM9osgq9Cfqv4/5KL2XMt7UzbkpHZO289ftKwep PF/t9QUrxIqkqPhksyLgMtu5rm4UlAA9gBy5sAXTIWMwvh7+6os06pr4gK6rd4CdeoPv u2Zak2HRtHv3XZ3DLOF9WRluUB7MAUDwpbmauCP9YINdI5WDr058LvMsOXI5hLIpgjav RVGvZJhCZUqeQxPGwdHpHbekrstad1CvldXVsWodv+N6upVs6pIChZGkZhUOZwnE2EOK XzFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705846752; x=1706451552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WYZafPBqdMDof8dD2/PJZMnQ3SPjhkOUNZiBrki1PTM=; b=ZZRPdtVtWaf8FgzbhtaBKZdGk+8Jk4F9IGQ43NnEIP/87XjnwqPnTveDYNui9GD57Y BycOuj6BwsAffQPTvLm7YXBAADYw7Au5Yqfbg+VC0o7/J37buetHLuB5cmYuaZVNx+yW gjHcY3PwaRHsrKzEa6ZuR2pOs4e8u2zWh/mvIQ3k2oqm0QClnGYIKWwa/x8tn7LJGi44 6IDEHfoJGx41Rl0U72kL3QMNi8Gbc1hVrKDTEhzH6ShO30ltk53O3aQoar8YGJpfxng9 E1gwsyg4VZoMScpKWfrmJFavIRa7yL7TlYrbXTWKi+tkEsM6AeyhXiIdsct1kjBHajPq kxFw== X-Gm-Message-State: AOJu0YwM0VTZl82/Nc9o2y5fSHxLTm2MPuhJBJ/4cgHeAFmRKv1tsP/i VvQ2lkWpCpWid80OCgsKtn7JBWsdkw2Ys3KxaBuh8fvnRYxwWuZvVDZm7qdhRF0= X-Received: by 2002:a17:902:b494:b0:1d7:307c:a65a with SMTP id y20-20020a170902b49400b001d7307ca65amr2597819plr.52.1705846751987; Sun, 21 Jan 2024 06:19:11 -0800 (PST) Received: from localhost.localdomain ([183.242.63.6]) by smtp.gmail.com with ESMTPSA id bg4-20020a1709028e8400b001d4b73f60e4sm5840726plb.149.2024.01.21.06.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 06:19:11 -0800 (PST) From: "jianfeng.zheng" X-Google-Original-From: "jianfeng.zheng" To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Jan 2024 22:18:42 +0800 Message-Id: <20240121141846.4077778-3-jianfeng.zheng@mthreads.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> References: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [vaapi-cavs 3/7] cavs: time code debug 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 Cc: "jianfeng.zheng" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: j4BQYBF33ne5 Signed-off-by: jianfeng.zheng --- libavcodec/cavsdec.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 9742bd1011..9ad0f29b01 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -1061,6 +1061,7 @@ static int decode_pic(AVSContext *h) int ret; int skip_count = -1; enum cavs_mb mb_type; + char tc[4]; if (!h->top_qp) { av_log(h->avctx, AV_LOG_ERROR, "No sequence header decoded yet\n"); @@ -1082,8 +1083,16 @@ static int decode_pic(AVSContext *h) return AVERROR_INVALIDDATA; } else { h->cur.f->pict_type = AV_PICTURE_TYPE_I; - if (get_bits1(&h->gb)) - skip_bits(&h->gb, 24);//time_code + if (get_bits1(&h->gb)) { //time_code + skip_bits(&h->gb, 1); + tc[0] = get_bits(&h->gb, 5); + tc[1] = get_bits(&h->gb, 6); + tc[2] = get_bits(&h->gb, 6); + tc[3] = get_bits(&h->gb, 6); + av_log(h->avctx, AV_LOG_DEBUG, "timecode: %d:%d:%d.%d\n", + tc[0], tc[1], tc[2], tc[3]); + } + /* old sample clips were all progressive and no low_delay, bump stream revision if detected otherwise */ if (h->low_delay || !(show_bits(&h->gb, 9) & 1)) From patchwork Sun Jan 21 14:18:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Zheng X-Patchwork-Id: 45689 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a402:b0:199:de12:6fa6 with SMTP id z2csp943800pzk; Sun, 21 Jan 2024 06:19:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5BWvAIrC7ggpa4lN4nhsZ73abvdyA7Z/jdGfAFe54sOjiGUfIBHxgYDYt1kO7QskKRyba X-Received: by 2002:a05:600c:3ba2:b0:40e:6707:b758 with SMTP id n34-20020a05600c3ba200b0040e6707b758mr1424508wms.178.1705846781384; Sun, 21 Jan 2024 06:19:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705846781; cv=none; d=google.com; s=arc-20160816; b=SPNAcN9UCHMB0nH2xgvxsASNu4h0nHvlmvluVZVAd6yheP/z2uIKAYn5Efr5zulfTI UJRI3MoxfwvNqKvCDCa3TJVl3ncUk0FFMfoHIw4iCCQJsm9f1AAPPy2+rg7MhOKelM+8 pAIeyIzwbLcqZIAV6qoieKDyC9tPX6jXYyEEdWgXXl6NbzD6pFztXnS1oLmJjEmORSlf lyddStxCHvT0ZFVDAvCFKzUGmVvhALwvMW+mE1ipX/btCHF/O8SzNnIC/hh10X34aAo8 I6rXzJyjOe5pbjL95p1aJ2x3IXNK5kP0xJMaNeRQKXTvdmo7PrnQe7FhHWfaoa/dlRTx 3C6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:dkim-signature:delivered-to; bh=ot5JykD3caer4UPbkwHqCGUrB+XcQjX50cFRNYbl96g=; fh=iiAW4vjlCGdXV3Yszi/eNCPr6t9/oDQbs1mdNL59KvI=; b=m5Le8L9kKSKC/498XGLdS44EGbGufSENdKt5aoXlgzKyFb48PhXceZI13NretH/y+l 0p4xhzxL+B0cedwALCJuksRwXT3Bl2r/aWqBvSj/zeQg+weDH1qhId9OALfGGlB5NjrO Fx1moXMRTKqJDswPOYLTN/ESvjp/ELTx6Xp9HLcBdsqDX/cfvtQ420eeEXGNj+mLGlU3 VN4FIf94NFzFRauC4cTuNrPlMQWGtm9erV9I6XiaxPmCkQMI9m3ht+JI4slmq8uK77RH 3LIJ3zprCCKAwJeb18YLIgzMkis/j1KBpHo9TlJi2NQZULZ4PHHVX6YQRaJoeKjKhJp+ Wr+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=I5nggDvV; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q4-20020a056402248400b0055872d16f9asi10681380eda.116.2024.01.21.06.19.40; Sun, 21 Jan 2024 06:19:41 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=I5nggDvV; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4375368CFAA; Sun, 21 Jan 2024 16:19:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2086D68CBFD for ; Sun, 21 Jan 2024 16:19:17 +0200 (EET) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d70696b6faso20636235ad.3 for ; Sun, 21 Jan 2024 06:19:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705846755; x=1706451555; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KNBkGSne5WCsI0mJWlh0m6IY59bx9aN219RNZMYrzX0=; b=I5nggDvVgH0NopaHu2/k9cUaZ59t6gM1yVgdqs81WKv3eknZz7h8eXQasGdCU+LCQp 7UaNSIJr9040YK87HxJkKJHLl5yLt0ZpauPkVJzmk8rThQDEjUk83pivp0N7kKDS3iFm VHH2qC4iCrS0OQNbKtatai8R+NkbpVRRMk/tdWWESrzlM0KK7qj2KqB/u/p5NaMy3fUI KUR+zO18ngxAKs/R8DzpH3Jcrciq0LjZjDj/WS3R/7QycxrVXUNQ9r4j4jfGo5k6uQqC fwAcUT/wjAcYH2FFUFUboC7BACk7BESfswmDGyztREF6aeqJ8QoV+S3TuemVxIftd5zq fQCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705846755; x=1706451555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KNBkGSne5WCsI0mJWlh0m6IY59bx9aN219RNZMYrzX0=; b=JNxvemeNAaaGSVvAtSJd0nqlRzxmbzvv6jeOQ9k1iyUkh6ym7/3bWLEMVeRqU/mkW/ DSl29wC4CwR87tCWDVhT1BQKA5QVwftbxk7z5kVC0OtOTUPnekJnggGjJsRg7xEivXlO z5n39qzB51vGJqH0H65g0D6+gg2zOQk+K3/xyk6YdWnzXBOxdhbbJynWDPsSUoQhj5CX pKIKNrUPAF8kZMJi4dtqHkK4LZAltnsci/ea+cNsQErpIDbn8zb4kGWCy+ZDLGSYZbOW Wu88EfWG3zxdTSirJjuGICK7ctwfqz/e5tCFajIxwWXVH1n27dl3CPEN07TTnezfF9Rt b2tQ== X-Gm-Message-State: AOJu0Yz6UxHQIhta8ZnrlpIU5LP439hQzuu2mXW+INJAPMJ4iHC9JFiE UBSYG7tGccqSn0aRoEhtsbpsxl/7y/D//csIymSWMJjoMy86YJHgOdkAqv8zw8s= X-Received: by 2002:a17:902:7046:b0:1d4:dddc:d38e with SMTP id h6-20020a170902704600b001d4dddcd38emr2982811plt.61.1705846754705; Sun, 21 Jan 2024 06:19:14 -0800 (PST) Received: from localhost.localdomain ([183.242.63.6]) by smtp.gmail.com with ESMTPSA id bg4-20020a1709028e8400b001d4b73f60e4sm5840726plb.149.2024.01.21.06.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 06:19:14 -0800 (PST) From: "jianfeng.zheng" X-Google-Original-From: "jianfeng.zheng" To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Jan 2024 22:18:43 +0800 Message-Id: <20240121141846.4077778-4-jianfeng.zheng@mthreads.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> References: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [vaapi-cavs 4/7] cavs: fix dpb reorder issues when 'low_delay' is varied 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 Cc: "jianfeng.zheng" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1dSuBiMSz12X Consider multi sequences in one stream, 'low_delay' may change between sequences. Signed-off-by: jianfeng.zheng --- libavcodec/cavs.c | 12 +++++ libavcodec/cavs.h | 2 + libavcodec/cavsdec.c | 105 +++++++++++++++++++++++++++++++++---------- 3 files changed, 95 insertions(+), 24 deletions(-) diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index fdd577f7fb..ed7b278336 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -810,6 +810,14 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) return AVERROR(ENOMEM); + h->out[0].f = av_frame_alloc(); + h->out[1].f = av_frame_alloc(); + h->out[2].f = av_frame_alloc(); + if (!h->out[0].f || !h->out[1].f || !h->out[2].f) { + ff_cavs_end(avctx); + return AVERROR(ENOMEM); + } + h->luma_scan[0] = 0; h->luma_scan[1] = 8; h->intra_pred_l[INTRA_L_VERT] = intra_pred_vert; @@ -840,6 +848,10 @@ av_cold int ff_cavs_end(AVCodecContext *avctx) av_frame_free(&h->DPB[0].f); av_frame_free(&h->DPB[1].f); + av_frame_free(&h->out[0].f); + av_frame_free(&h->out[1].f); + av_frame_free(&h->out[2].f); + av_freep(&h->top_qp); av_freep(&h->top_mv[0]); av_freep(&h->top_mv[1]); diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h index ad49abff92..f490657959 100644 --- a/libavcodec/cavs.h +++ b/libavcodec/cavs.h @@ -166,6 +166,7 @@ struct dec_2dvlc { typedef struct AVSFrame { AVFrame *f; int poc; + int outputed; } AVSFrame; typedef struct AVSContext { @@ -177,6 +178,7 @@ typedef struct AVSContext { GetBitContext gb; AVSFrame cur; ///< currently decoded frame AVSFrame DPB[2]; ///< reference frames + AVSFrame out[3]; ///< output queue, size 2 maybe enough int dist[2]; ///< temporal distances from current frame to ref frames int low_delay; int profile, level; diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 9ad0f29b01..6f462d861c 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -1056,6 +1056,44 @@ static inline int check_for_slice(AVSContext *h) * ****************************************************************************/ +/** + * @brief remove frame out of dpb + */ +static void cavs_frame_unref(AVSFrame *frame) +{ + /* frame->f can be NULL if context init failed */ + if (!frame->f || !frame->f->buf[0]) + return; + + av_frame_unref(frame->f); +} + +static int output_one_frame(AVSContext *h, AVFrame *data, int *got_frame) +{ + if (h->out[0].f->buf[0]) { + av_log(h->avctx, AV_LOG_DEBUG, "output frame: poc=%d\n", h->out[0].poc); + av_frame_move_ref(data, h->out[0].f); + *got_frame = 1; + + // out[0] <- out[1] <- out[2] <- out[0] + cavs_frame_unref(&h->out[2]); + FFSWAP(AVSFrame, h->out[0], h->out[2]); + FFSWAP(AVSFrame, h->out[0], h->out[1]); + + return 1; + } + + return 0; +} + +static void queue_one_frame(AVSContext *h, AVSFrame *out) +{ + int idx = !h->out[0].f->buf[0] ? 0 : (!h->out[1].f->buf[0] ? 1 : 2); + av_log(h->avctx, AV_LOG_DEBUG, "queue in out[%d]: poc=%d\n", idx, out->poc); + av_frame_ref(h->out[idx].f, out->f); + h->out[idx].poc = out->poc; +} + static int decode_pic(AVSContext *h) { int ret; @@ -1068,7 +1106,7 @@ static int decode_pic(AVSContext *h) return AVERROR_INVALIDDATA; } - av_frame_unref(h->cur.f); + cavs_frame_unref(&h->cur); skip_bits(&h->gb, 16);//bbv_dwlay if (h->stc == PIC_PB_START_CODE) { @@ -1077,10 +1115,13 @@ static int decode_pic(AVSContext *h) av_log(h->avctx, AV_LOG_ERROR, "illegal picture type\n"); return AVERROR_INVALIDDATA; } + /* make sure we have the reference frames we need */ - if (!h->DPB[0].f->data[0] || - (!h->DPB[1].f->data[0] && h->cur.f->pict_type == AV_PICTURE_TYPE_B)) + if (!h->DPB[0].f->buf[0] || + (!h->DPB[1].f->buf[0] && h->cur.f->pict_type == AV_PICTURE_TYPE_B)) { + av_log(h->avctx, AV_LOG_ERROR, "Invalid reference frame\n"); return AVERROR_INVALIDDATA; + } } else { h->cur.f->pict_type = AV_PICTURE_TYPE_I; if (get_bits1(&h->gb)) { //time_code @@ -1124,6 +1165,8 @@ static int decode_pic(AVSContext *h) if ((ret = ff_cavs_init_pic(h)) < 0) return ret; h->cur.poc = get_bits(&h->gb, 8) * 2; + av_log(h->avctx, AV_LOG_DEBUG, "poc=%d, type=%d\n", + h->cur.poc, h->cur.f->pict_type); /* get temporal distances and MV scaling factors */ if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) { @@ -1137,6 +1180,8 @@ static int decode_pic(AVSContext *h) if (h->cur.f->pict_type == AV_PICTURE_TYPE_B) { h->sym_factor = h->dist[0] * h->scale_den[1]; if (FFABS(h->sym_factor) > 32768) { + av_log(h->avctx, AV_LOG_ERROR, "poc=%d/%d/%d, dist=%d/%d\n", + h->DPB[1].poc, h->DPB[0].poc, h->cur.poc, h->dist[0], h->dist[1]); av_log(h->avctx, AV_LOG_ERROR, "sym_factor %d too large\n", h->sym_factor); return AVERROR_INVALIDDATA; } @@ -1250,11 +1295,6 @@ static int decode_pic(AVSContext *h) } while (ff_cavs_next_mb(h)); } emms_c(); - if (ret >= 0 && h->cur.f->pict_type != AV_PICTURE_TYPE_B) { - av_frame_unref(h->DPB[1].f); - FFSWAP(AVSFrame, h->cur, h->DPB[1]); - FFSWAP(AVSFrame, h->DPB[0], h->DPB[1]); - } return ret; } @@ -1337,11 +1377,12 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const uint8_t *buf_ptr; int frame_start = 0; - if (buf_size == 0) { - if (!h->low_delay && h->DPB[0].f->data[0]) { - *got_frame = 1; - av_frame_move_ref(rframe, h->DPB[0].f); + if (avpkt->size == 0) { + if (h->DPB[0].f->buf[0] && !h->DPB[0].outputed) { + queue_one_frame(h, &h->DPB[0]); + cavs_frame_unref(&h->DPB[0]); } + output_one_frame(h, rframe, got_frame); return 0; } @@ -1364,8 +1405,8 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, break; case PIC_I_START_CODE: if (!h->got_keyframe) { - av_frame_unref(h->DPB[0].f); - av_frame_unref(h->DPB[1].f); + cavs_frame_unref(&h->DPB[0]); + cavs_frame_unref(&h->DPB[1]); h->got_keyframe = 1; } case PIC_PB_START_CODE: @@ -1375,23 +1416,39 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, if (*got_frame) av_frame_unref(rframe); *got_frame = 0; - if (!h->got_keyframe) + if (!h->got_keyframe) { + av_log(avctx, AV_LOG_ERROR, "No keyframe decoded before P/B frame.\n"); break; + } init_get_bits(&h->gb, buf_ptr, input_size); h->stc = stc; - if (decode_pic(h)) - break; - *got_frame = 1; + if ((ret = decode_pic(h)) < 0) + return ret; + buf_ptr = align_get_bits(&h->gb); + + h->cur.outputed = 0; if (h->cur.f->pict_type != AV_PICTURE_TYPE_B) { - if (h->DPB[!h->low_delay].f->data[0]) { - if ((ret = av_frame_ref(rframe, h->DPB[!h->low_delay].f)) < 0) - return ret; - } else { - *got_frame = 0; + // at most one delay + if (h->DPB[0].f->buf[0] && !h->DPB[0].outputed) { + queue_one_frame(h, &h->DPB[0]); + h->DPB[0].outputed = 1; } + + if (h->low_delay) { + queue_one_frame(h, &h->cur); + h->cur.outputed = 1; + } + + // null -> curr -> DPB[0] -> DPB[1] + cavs_frame_unref(&h->DPB[1]); + FFSWAP(AVSFrame, h->cur, h->DPB[1]); + FFSWAP(AVSFrame, h->DPB[0], h->DPB[1]); } else { - av_frame_move_ref(rframe, h->cur.f); + queue_one_frame(h, &h->cur); + cavs_frame_unref(&h->cur); } + + output_one_frame(h, rframe, got_frame); break; case EXT_START_CODE: //mpeg_decode_extension(avctx, buf_ptr, input_size); From patchwork Sun Jan 21 14:18:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Zheng X-Patchwork-Id: 45690 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a402:b0:199:de12:6fa6 with SMTP id z2csp943859pzk; Sun, 21 Jan 2024 06:19:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfMpGEsX1PPEU1+Eg/SZn0J4E0q60nxX1upD2ppb6xMPZhdBD3hnSr9vslNenB+9uFiM6C X-Received: by 2002:a5d:56c2:0:b0:339:2bf5:7efa with SMTP id m2-20020a5d56c2000000b003392bf57efamr2128834wrw.6.1705846790313; Sun, 21 Jan 2024 06:19:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705846790; cv=none; d=google.com; s=arc-20160816; b=F9p0+x+mlVmZTScqqazfDYkg0M8z8H4PrP2Q2kiYhzOQF3e4Xt5aj/kfKNRRGr1N2M SgVNia6UP9nAOyS+opQrGnwcfUe9fJwqlG3eFVEuzeI4T1jjnJaxvRqFAsLT7FHeyilD YETGYe7MCeYtqLngXMJRckpoKOsDjD6crV4w8cXKbLhxKognzPku4o/5MMNDLZzBEBtR 7nFRS/xcwcvFxDQyK5aZRdFHlNcNBmm8XhJ7RNxvfJGI7AYRxKwJvGnq+R28vQ1eTLy9 Vu5toC2ZGSWvjGjO3RA9tUXHi096m1tEB1pZONVBFxGosml7OJs1RdrfFXI3puLpRBKA iEKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:dkim-signature:delivered-to; bh=hFoNwueKXp/vKwZNfM6EyzLdpL/oAc9617NsIqCiR2Y=; fh=iiAW4vjlCGdXV3Yszi/eNCPr6t9/oDQbs1mdNL59KvI=; b=rn9D3hLBK7n250j6BgGRsBK8lLJOOedTFHVmGEB8vAikM0YYZqklXMFAXlWNVJPARZ eKTlfWMobHo8uRa4FuDZOWBHxFiHnbgHRJEjSgBnYIVhgt7OYfqFYy4bI2z8qSGMElGC uGlU8Jru6cTHyjg0gCoCR8/dnor9XK4tZ4VTOGcKcyp/VMt3DIhExpcHYN66kPzOu7sa 6zwLHuiNjMMph8U9cK6KxsuBezqtwQaeH46/bnEG7+YeHtUUfrAtNuI013z26S3ukYns 0OvdS68fioAn1lLYwZWC4XppHcHZ9DwjL+AZhImQiDB47NKcQgeg6bZE58dlbRBwC0pk tA9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=GAj53RGB; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n17-20020a170906119100b00a2cd76d079fsi8697528eja.773.2024.01.21.06.19.50; Sun, 21 Jan 2024 06:19:50 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=GAj53RGB; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D82868D0BA; Sun, 21 Jan 2024 16:19:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D580968CBFD for ; Sun, 21 Jan 2024 16:19:19 +0200 (EET) Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-5ceb3fe708eso925740a12.3 for ; Sun, 21 Jan 2024 06:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705846758; x=1706451558; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iFPuLOLB2v4JBf6SNnr2wuhaR8jMdEL9C7VTl0UVBv4=; b=GAj53RGBZtpCdpNUE/bSoHL4wLrVSX1Qjrxy345Nyl+R0C7aG9yWaHobdHIwG70caL TmqnqSrKG178OFZk5TYCp1IooZEr1WmyK3Z2CEZIgHT6YvZzyfNSxf8RGfADV21xAVkK 2Bqx6Juc3m3KiEwrlXmVYbkfJ2ifb31WldqlxNkAes59zRJeGnJ+cP7oBfhTWvClVob0 IHtzZp5/BoUaIUpNy4AARaGJPxKy/3bTX97gVRulKO9XVqst3e/xT/GYyt7kF3P7v1j/ hKilEGQ11s2mrefFHDGO7Twe/sSp2DOY+NZJ5KX8dziGa5A/sqyNLzftTM6uiERsKfxl iKWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705846758; x=1706451558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iFPuLOLB2v4JBf6SNnr2wuhaR8jMdEL9C7VTl0UVBv4=; b=viaS/h9j2gqV507BzMGqvuZIqdNiKzb/gSKMkfggg3iPR/moZLXbCXBzbI9mQBWwUv BOXLfM17U3Nbp4cMHnQExLJOmadYCdCBtjPQN6KC6q0y1UV1BNd7pczAS8YE5sUer7bn xUI0R2S32uezg0kqwMrmEqoxhS343Zu3IAl3KkEXTtZmiBeMsSaydwM7Z5C1GrRks9W0 wrJpzw7LasKV6lzkl6bm8crk+yYFVYfojGbvhDDaHAe+qcy6ZU7NaJ60zvtZaMtv29CY 6vkBFFYEctoOcpZipB3kPLeKpKfTvKUwq7MYzAIzwgT5DonrXphgJiiuALwvRSS16X71 iCJg== X-Gm-Message-State: AOJu0YzJivHjuKUVlSs8R65Gl/zfyZ2nJg8qtkhoyVJwhG2oVeR1ZBdn hwUW/dXoantv0M3BiL6qnYG2uy3km1jwNErj2rhEXBxsCJC5YX0YRILnyskY/oA= X-Received: by 2002:a17:902:7448:b0:1d4:47d4:82b4 with SMTP id e8-20020a170902744800b001d447d482b4mr1038899plt.15.1705846757653; Sun, 21 Jan 2024 06:19:17 -0800 (PST) Received: from localhost.localdomain ([183.242.63.6]) by smtp.gmail.com with ESMTPSA id bg4-20020a1709028e8400b001d4b73f60e4sm5840726plb.149.2024.01.21.06.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 06:19:17 -0800 (PST) From: "jianfeng.zheng" X-Google-Original-From: "jianfeng.zheng" To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Jan 2024 22:18:44 +0800 Message-Id: <20240121141846.4077778-5-jianfeng.zheng@mthreads.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> References: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [vaapi-cavs 5/7] cavs: decode wqm and slice weighting for future usage 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 Cc: "jianfeng.zheng" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IlHpyUsWsZmX Signed-off-by: jianfeng.zheng --- libavcodec/cavs.h | 26 +++++++- libavcodec/cavsdec.c | 142 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 147 insertions(+), 21 deletions(-) diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h index f490657959..33ef10e850 100644 --- a/libavcodec/cavs.h +++ b/libavcodec/cavs.h @@ -186,12 +186,36 @@ typedef struct AVSContext { int mb_width, mb_height; int width, height; int stream_revision; ///<0 for samples from 2006, 1 for rm52j encoder - int progressive; + int progressive_seq; + int progressive_frame; int pic_structure; int skip_mode_flag; ///< select between skip_count or one skip_flag per MB int loop_filter_disable; int alpha_offset, beta_offset; int ref_flag; + + /** \defgroup guangdian profile + * @{ + */ + int aec_flag; + int weight_quant_flag; + int chroma_quant_param_delta_cb; + int chroma_quant_param_delta_cr; + uint8_t wqm_8x8[64]; + /**@}*/ + + /** \defgroup slice weighting + * FFmpeg don't support slice weighting natively, but maybe needed for HWaccel. + * @{ + */ + uint32_t slice_weight_pred_flag : 1; + uint32_t mb_weight_pred_flag : 1; + uint8_t luma_scale[4]; + int8_t luma_shift[4]; + uint8_t chroma_scale[4]; + int8_t chroma_shift[4]; + /**@}*/ + int mbx, mby, mbidx; ///< macroblock coordinates int flags; ///< availability flags of neighbouring macroblocks int stc; ///< last start code diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 6f462d861c..8d3ba530a6 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "get_bits.h" #include "golomb.h" +#include "profiles.h" #include "cavs.h" #include "codec_internal.h" #include "decode.h" @@ -37,6 +38,43 @@ #include "mpeg12data.h" #include "startcode.h" +static const uint8_t default_wq_param[4][6] = { + {128, 98, 106, 116, 116, 128}, + {135, 143, 143, 160, 160, 213}, + {128, 98, 106, 116, 116, 128}, + {128, 128, 128, 128, 128, 128}, +}; +static const uint8_t wq_model_2_param[4][64] = { + { + 0, 0, 0, 4, 4, 4, 5, 5, + 0, 0, 3, 3, 3, 3, 5, 5, + 0, 3, 2, 2, 1, 1, 5, 5, + 4, 3, 2, 2, 1, 5, 5, 5, + 4, 3, 1, 1, 5, 5, 5, 5, + 4, 3, 1, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + }, { + 0, 0, 0, 4, 4, 4, 5, 5, + 0, 0, 4, 4, 4, 4, 5, 5, + 0, 3, 2, 2, 2, 1, 5, 5, + 3, 3, 2, 2, 1, 5, 5, 5, + 3, 3, 2, 1, 5, 5, 5, 5, + 3, 3, 1, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + }, { + 0, 0, 0, 4, 4, 3, 5, 5, + 0, 0, 4, 4, 3, 2, 5, 5, + 0, 4, 4, 3, 2, 1, 5, 5, + 4, 4, 3, 2, 1, 5, 5, 5, + 4, 3, 2, 1, 5, 5, 5, 5, + 3, 2, 1, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + } +}; + static const uint8_t mv_scan[4] = { MV_FWD_X0, MV_FWD_X1, MV_FWD_X2, MV_FWD_X3 @@ -927,7 +965,11 @@ static int decode_mb_b(AVSContext *h, enum cavs_mb mb_type) static inline int decode_slice_header(AVSContext *h, GetBitContext *gb) { - if (h->stc > 0xAF) + int i, nref; + + av_log(h->avctx, AV_LOG_TRACE, "slice start code 0x%02x\n", h->stc); + + if (h->stc > SLICE_MAX_START_CODE) av_log(h->avctx, AV_LOG_ERROR, "unexpected start code 0x%02x\n", h->stc); if (h->stc >= h->mb_height) { @@ -946,11 +988,29 @@ static inline int decode_slice_header(AVSContext *h, GetBitContext *gb) } /* inter frame or second slice can have weighting params */ if ((h->cur.f->pict_type != AV_PICTURE_TYPE_I) || - (!h->pic_structure && h->mby >= h->mb_width / 2)) - if (get_bits1(gb)) { //slice_weighting_flag + (!h->pic_structure && h->mby >= h->mb_height / 2)) { + h->slice_weight_pred_flag = get_bits1(gb); + if (h->slice_weight_pred_flag) { + nref = h->cur.f->pict_type == AV_PICTURE_TYPE_I ? 1 : (h->pic_structure ? 2 : 4); + for (i = 0; i < nref; i++) { + h->luma_scale[i] = get_bits(gb, 8); + h->luma_shift[i] = get_sbits(gb, 8); + skip_bits1(gb); + h->chroma_scale[i] = get_bits(gb, 8); + h->chroma_shift[i] = get_sbits(gb, 8); + skip_bits1(gb); + } + h->mb_weight_pred_flag = get_bits1(gb); + if (!h->avctx->hwaccel) { av_log(h->avctx, AV_LOG_ERROR, "weighted prediction not yet supported\n"); } + } + } + if (h->aec_flag) { + align_get_bits(gb); + } + return 0; } @@ -1108,7 +1168,11 @@ static int decode_pic(AVSContext *h) cavs_frame_unref(&h->cur); - skip_bits(&h->gb, 16);//bbv_dwlay + skip_bits(&h->gb, 16);//bbv_delay + if (h->profile == AV_PROFILE_CAVS_GUANGDIAN) { + skip_bits(&h->gb, 8);//bbv_dwlay_extension + } + if (h->stc == PIC_PB_START_CODE) { h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I; if (h->cur.f->pict_type > AV_PICTURE_TYPE_B) { @@ -1192,9 +1256,9 @@ static int decode_pic(AVSContext *h) if (h->low_delay) get_ue_golomb(&h->gb); //bbv_check_times - h->progressive = get_bits1(&h->gb); + h->progressive_frame = get_bits1(&h->gb); h->pic_structure = 1; - if (!h->progressive) + if (!h->progressive_frame) h->pic_structure = get_bits1(&h->gb); if (!h->pic_structure && h->stc == PIC_PB_START_CODE) skip_bits1(&h->gb); //advanced_pred_mode_disable @@ -1203,9 +1267,11 @@ static int decode_pic(AVSContext *h) h->pic_qp_fixed = h->qp_fixed = get_bits1(&h->gb); h->qp = get_bits(&h->gb, 6); + h->skip_mode_flag = 0; + h->ref_flag = 0; if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) { - if (!h->progressive && !h->pic_structure) - skip_bits1(&h->gb);//what is this? + if (!h->progressive_frame && !h->pic_structure) + h->skip_mode_flag = get_bits1(&h->gb); skip_bits(&h->gb, 4); //reserved bits } else { if (!(h->cur.f->pict_type == AV_PICTURE_TYPE_B && h->pic_structure == 1)) @@ -1220,12 +1286,46 @@ static int decode_pic(AVSContext *h) if ( h->alpha_offset < -64 || h->alpha_offset > 64 || h-> beta_offset < -64 || h-> beta_offset > 64) { h->alpha_offset = h->beta_offset = 0; + av_log(h->avctx, AV_LOG_ERROR, "invalid loop filter params\n"); return AVERROR_INVALIDDATA; } } else { h->alpha_offset = h->beta_offset = 0; } + h->weight_quant_flag = 0; + if (h->profile == AV_PROFILE_CAVS_GUANGDIAN) { + h->weight_quant_flag = get_bits1(&h->gb); + if (h->weight_quant_flag) { + int wq_param[6] = {128, 128, 128, 128, 128, 128}; + int i, wqp_index, wq_model; + const uint8_t *m2p; + + skip_bits1(&h->gb); + if (!get_bits1(&h->gb)) { + h->chroma_quant_param_delta_cb = get_se_golomb(&h->gb); + h->chroma_quant_param_delta_cr = get_se_golomb(&h->gb); + } + wqp_index = get_bits(&h->gb, 2); + wq_model = get_bits(&h->gb, 2); + m2p = wq_model_2_param[wq_model]; + + for (i = 0; i < 6; i++) { + int delta = (wqp_index == 1 || wqp_index == 2) ? get_se_golomb(&h->gb) : 0; + wq_param[i] = default_wq_param[wqp_index][i] + delta; + av_log(h->avctx, AV_LOG_DEBUG, "wqp[%d]=%d\n", i, wq_param[i]); + } + for (i = 0; i < 64; i++) { + h->wqm_8x8[i] = wq_param[ m2p[i] ]; + } + } else { + memset(h->wqm_8x8, 128, sizeof(h->wqm_8x8)); + } + h->aec_flag = get_bits1(&h->gb); + av_log(h->avctx, AV_LOG_DEBUG, "wq_flag=%d, aec_flag=%d\n", + h->weight_quant_flag, h->aec_flag); + } + if (h->stream_revision > 0) { skip_stuffing_bits(h); skip_extension_and_user_data(h); @@ -1311,13 +1411,8 @@ static int decode_seq_header(AVSContext *h) int ret; h->profile = get_bits(&h->gb, 8); - if (h->profile != 0x20) { - avpriv_report_missing_feature(h->avctx, - "only supprt JiZhun profile"); - return AVERROR_PATCHWELCOME; - } h->level = get_bits(&h->gb, 8); - skip_bits1(&h->gb); //progressive sequence + h->progressive_seq = get_bits1(&h->gb); width = get_bits(&h->gb, 14); height = get_bits(&h->gb, 14); @@ -1344,6 +1439,9 @@ static int decode_seq_header(AVSContext *h) skip_bits1(&h->gb); //marker_bit skip_bits(&h->gb, 12); //bit_rate_upper h->low_delay = get_bits1(&h->gb); + av_log(h->avctx, AV_LOG_DEBUG, + "seq: profile=0x%02x, level=0x%02x, size=%dx%d, low_delay=%d\n", + h->profile, h->level, width, height, h->low_delay); ret = ff_set_dimensions(h->avctx, width, height); if (ret < 0) @@ -1369,8 +1467,6 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt) { AVSContext *h = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; uint32_t stc = -1; int input_size, ret; const uint8_t *buf_end; @@ -1388,16 +1484,18 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, h->stc = 0; - buf_ptr = buf; - buf_end = buf + buf_size; - for(;;) { + buf_ptr = avpkt->data; + buf_end = avpkt->data + avpkt->size; + for(; buf_ptr < buf_end;) { buf_ptr = avpriv_find_start_code(buf_ptr, buf_end, &stc); if ((stc & 0xFFFFFE00) || buf_ptr == buf_end) { if (!h->stc) av_log(h->avctx, AV_LOG_WARNING, "no frame decoded\n"); - return FFMAX(0, buf_ptr - buf); + return FFMAX(0, buf_ptr - avpkt->data); } input_size = (buf_end - buf_ptr) * 8; + av_log(h->avctx, AV_LOG_TRACE, "Found start code 0x%04x, sz=%d\n", + stc, input_size / 8); switch (stc) { case CAVS_START_CODE: init_get_bits(&h->gb, buf_ptr, input_size); @@ -1464,12 +1562,16 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, break; default: if (stc <= SLICE_MAX_START_CODE) { + h->stc = stc & 0xff; init_get_bits(&h->gb, buf_ptr, input_size); decode_slice_header(h, &h->gb); + } else { + av_log(h->avctx, AV_LOG_WARNING, "Skip unsupported start code 0x%04X\n", stc); } break; } } + return (buf_ptr - avpkt->data); } const FFCodec ff_cavs_decoder = { From patchwork Sun Jan 21 14:18:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Zheng X-Patchwork-Id: 45692 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a402:b0:199:de12:6fa6 with SMTP id z2csp943983pzk; Sun, 21 Jan 2024 06:20:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFhqDXYc2bAwSTgXVRvNOjZJ7IjgbC8z0FA2m71y3GMbLEEydelRCJb0mtBuQRTk3ssfZ0 X-Received: by 2002:a05:6402:31f5:b0:553:7065:e7c2 with SMTP id dy21-20020a05640231f500b005537065e7c2mr898426edb.113.1705846808125; Sun, 21 Jan 2024 06:20:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705846808; cv=none; d=google.com; s=arc-20160816; b=xVPyQaggqITO6hpsE6m2WL9KW8haZDUVUBGq8OiozPfbfH0+5UKzpO+wpOJ6okFOUh fnMl4HHNRto6OMVEeTjGquXZwBmrKrRqvJbMEVTp5ctoXdhKDP2l2sAezqS2oef6eEHZ RDQRItqe5I7OzVtxMj8TAM1A1Vz8zOeYH5pmXAuS4fpNoe4EsnlPe7bAq4u/oR8fGih9 ehtbz4CIqsyU5EeYWCnZsRqJ72oX5LzAIqm1y6TTb/KOgCvlQDQ4/qBoZNGwXI80EWdx DJCTq0WUptaHWrA4733+AayIyc/YXxRfFh0nG2yoZ3jHHkzTm8AWIQp3E4O05yzHAuaD uTBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:dkim-signature:delivered-to; bh=/HeJf1H8knddRxLGCvueDDaZISd5dg+lz4a8TuE/Zrg=; fh=iiAW4vjlCGdXV3Yszi/eNCPr6t9/oDQbs1mdNL59KvI=; b=tuXEoLAFMMHpVLVbDdBmbxdQJSUAJ+9AeU/LQ0+yq24au7iNpkuPsP0VshR7SfMgkp W/bcjYa642QB/OTZ2q5QW3pmguaTvXlkQfn41z8ImUw/m9NLJtqRAaZ4fbJmgqmIaj7U yEi79+++HwhI4sP1t47sAPtWgXH5gj4uT3avz5my9Dz4wv4inKWWbDb3mAc5iZJf0F8S 4uQ/WxWH54bJRKFkSgGS8/hQ51/cGZ5bHDxeBHabkkwC7qBXMdJvP8hMHHFUKTZ68X0o oXcW5BgODhVR+wn308Ol8wu8DBFvMiJrgvFYlBk2ckrHgI8yzgJ5bdq9bcS37LwPEolp S63g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=jfrM52Vk; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fk3-20020a056402398300b0055a9009c58asi1689532edb.17.2024.01.21.06.20.07; Sun, 21 Jan 2024 06:20:08 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=jfrM52Vk; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C9A9468D0D3; Sun, 21 Jan 2024 16:19:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 831B168D0C8 for ; Sun, 21 Jan 2024 16:19:22 +0200 (EET) Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-5cfa71498feso2136907a12.1 for ; Sun, 21 Jan 2024 06:19:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705846760; x=1706451560; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XrvrpFEzt9V2KvAKeN/CcRCalrmpjk1WoFXgG3qgOw8=; b=jfrM52Vk29ZDay/A+lzkiF7AvNI8XJQGXm0AzREj6dPK9uwuiOBfZh9+hrCeWYRer6 LcE582AQWdoumVC0xsYwseajk1FKrxmmOicugHM4Lh4I7MyOZGFu7zmj5X9iIk1tDARC 6BgN1IrNo5SxreLA+jJu+EKy9RG7TLmLT3yt0ZJtkg2AfNXGBfWGYvenmHrCHTvZ6Rl/ BH6awtdms9h75aRJo8fsub3PlgRjWq/IEH1BPKu6kwbP+zFJYDQymDjH6EI6fJDEYU11 TSwajpULlW0BegTmRdm797xaBJJw77ec9Yv/ysKu+qTlpg1Rmvo3Ot2wYAwWgEClIWCB wfPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705846760; x=1706451560; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XrvrpFEzt9V2KvAKeN/CcRCalrmpjk1WoFXgG3qgOw8=; b=a1D5/odzexedhcBXmFV7BWZj7PilHbGD9ajhdxMNU4eh9KPPUc/URUyjjEASl98YlL fwCQT0hTD19sg0gg/PE7jFysddHjFB5o3Sh5f9FdGQDdVuOEK22mMF7eKQ4yGMXP2rvz zss4owvbj9sSoNXQmz0+2guItHmxuZWuWsz4qu3/2VvVtAW2G+g3028gRbPA3KHK5awr 7SOuHyRF75SYTssgW+SbuY591NDnZow/rYPt9i3W7Q/pvJOxj45GOsVXBm1anwU4KTTq qAmJ3IKAxrALIdRxbn5wuf3iBbjZqsoyTDHmAMTFfA6IxjPApL/mJ/CnO1WLaWFXKmfl a8LA== X-Gm-Message-State: AOJu0Yx5VYzA36tJS21icS6inBKLW6HkMmV4YKVrYmdGgV8vYnkMD7fQ 3Wawvs076dk2WPw/xwVzuz4PmYSyc8zASoHlq1TmmwJiT3eLrbhK3PphJuc+gWs= X-Received: by 2002:a17:902:82c9:b0:1d7:105a:53da with SMTP id u9-20020a17090282c900b001d7105a53damr3355940plz.27.1705846760471; Sun, 21 Jan 2024 06:19:20 -0800 (PST) Received: from localhost.localdomain ([183.242.63.6]) by smtp.gmail.com with ESMTPSA id bg4-20020a1709028e8400b001d4b73f60e4sm5840726plb.149.2024.01.21.06.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 06:19:20 -0800 (PST) From: "jianfeng.zheng" X-Google-Original-From: "jianfeng.zheng" To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Jan 2024 22:18:45 +0800 Message-Id: <20240121141846.4077778-6-jianfeng.zheng@mthreads.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> References: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [vaapi-cavs 6/7] cavs: set profile & level for AVCodecContext 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 Cc: "jianfeng.zheng" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ymy+cnZy4pyK Signed-off-by: jianfeng.zheng --- libavcodec/cavsdec.c | 5 ++++- tests/ref/fate/cavs-demux | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 format|filename=bunny.mp4|nb_streams=1|nb_programs=0|format_name=cavsvideo|start_time=N/A|duration=N/A|size=177752|bit_rate=N/A|probe_score=51 diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 8d3ba530a6..5036ef50f7 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -1499,7 +1499,10 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, switch (stc) { case CAVS_START_CODE: init_get_bits(&h->gb, buf_ptr, input_size); - decode_seq_header(h); + if ((ret = decode_seq_header(h)) < 0) + return ret; + avctx->profile = h->profile; + avctx->level = h->level; break; case PIC_I_START_CODE: if (!h->got_keyframe) { diff --git a/tests/ref/fate/cavs-demux b/tests/ref/fate/cavs-demux index 000b32ab05..6381f2075b 100644 --- a/tests/ref/fate/cavs-demux +++ b/tests/ref/fate/cavs-demux @@ -58,5 +58,5 @@ packet|codec_type=video|stream_index=0|pts=2280000|pts_time=1.900000|dts=2280000 packet|codec_type=video|stream_index=0|pts=2320000|pts_time=1.933333|dts=2320000|dts_time=1.933333|duration=40000|duration_time=0.033333|size=67|pos=172185|flags=K__|data_hash=CRC32:42484449 packet|codec_type=video|stream_index=0|pts=2360000|pts_time=1.966667|dts=2360000|dts_time=1.966667|duration=40000|duration_time=0.033333|size=83|pos=172252|flags=K__|data_hash=CRC32:a941bdf0 packet|codec_type=video|stream_index=0|pts=2400000|pts_time=2.000000|dts=2400000|dts_time=2.000000|duration=40000|duration_time=0.033333|size=5417|pos=172335|flags=K__|data_hash=CRC32:9d0d503b -stream|index=0|codec_name=cavs|profile=unknown|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|width=1280|height=720|coded_width=1280|coded_height=720|closed_captions=0|film_grain=0|has_b_frames=0|sample_aspect_ratio=N/A|display_aspect_ratio=N/A|pix_fmt=yuv420p|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|refs=1|id=N/A|r_frame_rate=30/1|avg_frame_rate=25/1|time_base=1/1200000|start_pts=N/A|start_time=N/A|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=60|extradata_size=18|extradata_hash=CRC32:1255d52e|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbna ils=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 +stream|index=0|codec_name=cavs|profile=32|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|width=1280|height=720|coded_width=1280|coded_height=720|closed_captions=0|film_grain=0|has_b_frames=0|sample_aspect_ratio=N/A|display_aspect_ratio=N/A|pix_fmt=yuv420p|level=64|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|refs=1|id=N/A|r_frame_rate=30/1|avg_frame_rate=25/1|time_base=1/1200000|start_pts=N/A|start_time=N/A|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=60|extradata_size=18|extradata_hash=CRC32:1255d52e|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0| From patchwork Sun Jan 21 14:18:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jianfeng Zheng X-Patchwork-Id: 45691 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a402:b0:199:de12:6fa6 with SMTP id z2csp943909pzk; Sun, 21 Jan 2024 06:19:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnzPj0hkCgw7F8FPxuH7y/nqzKMIO9wkj5JK+QiDFreR8u5noliCJGnS014b5wKDZGTKgF X-Received: by 2002:ac2:4e0f:0:b0:50e:4509:ef76 with SMTP id e15-20020ac24e0f000000b0050e4509ef76mr1280047lfr.83.1705846799344; Sun, 21 Jan 2024 06:19:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705846799; cv=none; d=google.com; s=arc-20160816; b=rmKXLJeS+3+LBPBWK+f7mWzUf3SCrcWTRDfDqOQyCemuQSAt8AEzkvFY3S8fTPMo9Y n18Rwtre2P+9KqyuXTSNaC2eDjTB3ixSwz1UlPglACy505YSwLjffJqhMrjBfcCMl5r1 3xxVUoSUT6eHOG3iQjX9R02+M2rw4BdqyfAsqCXQ9YmgCisnIwAOICqRLxARLxauRNta UZvLhdumJlcdOV6uVM2YmskCctrp3J3ISjgMGfWF4XNbv+c0YP/CpgnvwD1TqwxooL+J Fuz+tBvDFWDlELdT0dHIa6rZBjRCglxj1mS6YGAals0tP0FE72D7TKAj/o6uJfibHQUT 7rPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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 :dkim-signature:delivered-to; bh=lZ2vIiD5yOxSyYW57YeLfh2twGUPgaY0/l+krDn47eY=; fh=iiAW4vjlCGdXV3Yszi/eNCPr6t9/oDQbs1mdNL59KvI=; b=crQcmCCH5lwLRj+xRcr9IuS8XE2HaEJd+w76/ztjIMUN6eC0ScSJbYpD6wtigKH0n8 Q2ZdgBrxsskAdSGNqXOz/lwV0IXiRh6A8ZLPb5OPrbwExjLFK1K5gEX1GXFiwioY1tDR m4Fi2V5L/U1Kn5igsyvI9TOWxtI14v1AvQRJ95e1B2ElzeCqmTW7hLxDtZTA7tmNM9jx /RIB+oSCy8OfW/cFNjIWcnu5pJrAEvZXkl41o4FYCFdZuhmDHl75MXOt0jnPb18uM42G 7Hr7PpLuQ9PhZSvhV7Sh26A6hF+AiB7OFJjketeO1hLbccIvKVJ1VoZCutmX2tlU0d7Z Gfug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=fqPKlCWl; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z23-20020a170906241700b00a2d3b4b794fsi8258792eja.185.2024.01.21.06.19.58; Sun, 21 Jan 2024 06:19:59 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=fqPKlCWl; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B043C68D0C8; Sun, 21 Jan 2024 16:19:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A6B2968D0A5 for ; Sun, 21 Jan 2024 16:19:25 +0200 (EET) Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2907a17fa34so528819a91.1 for ; Sun, 21 Jan 2024 06:19:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705846763; x=1706451563; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hF6iqGARoFgQUGMtyT/wzKgen42Ko2SWZNAbUx8gmmk=; b=fqPKlCWl1aMfkHAdKt5CVLEnjgBkq86jFHdmLOeZHwWkmAvrb+9bffie/92/NvfyPL 5KvdoLCAXimzF1WlKJtWuwPvXquonPyM2evF3suOu7NqVFRzHU5wOWiTsQ7I/B8571fl n5KO1UCViv/yF2wVNwS7KSKMNGYYGfgRYkFaiUzeCNRVpYsIOgeFZJt1enHkMOs1Flx6 eCkek1PtUZJkjZyqgtyZmChFwKPx9loxJsbNq7lfQmvlHAJfoIkixHMeAV3PbLouhqT6 5fDudlJlaIqRpnceOoPKa78q9NytoI6n+xmgJrQ9bS1ferYMWpMAbuug9MvPCCZW/3X7 H2CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705846763; x=1706451563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hF6iqGARoFgQUGMtyT/wzKgen42Ko2SWZNAbUx8gmmk=; b=rdcArd+Q1iaxM4eEJDa5LreeOSU8m2jU0vuWbG5hg/WMhBnr7I2r4Q/wetDjkNPp0E 4/y0mHfi4mI+zRUV0rGnGLVGXtWunvhSNLkUULkhzTMnE6aDoiIe/1i/Swp73kwtj4YL b9CR7fyJhCFfItLSmf/nNdQZ3+dLu/o4apeVo2xAgcw/goQdJaxLMwECJP7mZtmW2nTB AAU//Uo+M7JHuuFnfPBhEuBzJyQUw17SU78m3TZ1wFqqgD1a5oytxFp4PUIEd4to++p8 tOn28Dwp5f/ayACPHA9FxYZ4PanIVDAX+ovcgR9CEc+K8CwE7oxhJcEZaYx1hiBQquGo zfLg== X-Gm-Message-State: AOJu0YyVY4ALIZh5y2ecNgWarOiKqqV17MGhcp7WCKbGi0BskIOv/fwu wBIeDXGZxdIccpPwWGiB3/GagSrFtDplBe8WCxaNZftyoUAaIQ/9JutVhefF514= X-Received: by 2002:a17:90a:bc84:b0:28c:90e:1b4c with SMTP id x4-20020a17090abc8400b0028c090e1b4cmr947032pjr.5.1705846763125; Sun, 21 Jan 2024 06:19:23 -0800 (PST) Received: from localhost.localdomain ([183.242.63.6]) by smtp.gmail.com with ESMTPSA id bg4-20020a1709028e8400b001d4b73f60e4sm5840726plb.149.2024.01.21.06.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 06:19:22 -0800 (PST) From: "jianfeng.zheng" X-Google-Original-From: "jianfeng.zheng" To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Jan 2024 22:18:46 +0800 Message-Id: <20240121141846.4077778-7-jianfeng.zheng@mthreads.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> References: <20240121141846.4077778-1-jianfeng.zheng@mthreads.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [vaapi-cavs 7/7] cavs: support vaapi hwaccel decoding 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 Cc: "jianfeng.zheng" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bRgs8BhcJ8K3 see https://github.com/intel/libva/pull/738 Signed-off-by: jianfeng.zheng --- configure | 14 ++++ libavcodec/Makefile | 1 + libavcodec/cavs.h | 4 + libavcodec/cavsdec.c | 101 +++++++++++++++++++++-- libavcodec/hwaccels.h | 1 + libavcodec/vaapi_cavs.c | 164 ++++++++++++++++++++++++++++++++++++++ libavcodec/vaapi_decode.c | 4 + 7 files changed, 284 insertions(+), 5 deletions(-) create mode 100644 libavcodec/vaapi_cavs.c diff --git a/configure b/configure index c8ae0a061d..89759eda5d 100755 --- a/configure +++ b/configure @@ -2463,6 +2463,7 @@ HAVE_LIST=" xmllint zlib_gzip openvino2 + va_profile_avs " # options emitted with CONFIG_ prefix but not available on the command line @@ -3202,6 +3203,7 @@ wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" wmv3_nvdec_hwaccel_select="vc1_nvdec_hwaccel" wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" +cavs_vaapi_hwaccel_deps="vaapi va_profile_avs VAPictureParameterBufferAVS" # hardware-accelerated codecs mediafoundation_deps="mftransform_h MFCreateAlignedMemoryBuffer" @@ -7175,6 +7177,18 @@ if enabled vaapi; then check_type "va/va.h va/va_enc_vp8.h" "VAEncPictureParameterBufferVP8" check_type "va/va.h va/va_enc_vp9.h" "VAEncPictureParameterBufferVP9" check_type "va/va.h va/va_enc_av1.h" "VAEncPictureParameterBufferAV1" + + # + # Using 'VA_CHECK_VERSION' in source codes make things easy. But we have to wait + # until newly added VAProfile being distributed by VAAPI released version. + # + # Before or after that, we can use auto-detection to keep version compatibility. + # It always works. + # + disable va_profile_avs && + test_code cc va/va.h "VAProfile p1 = VAProfileAVSJizhun, p2 = VAProfileAVSGuangdian;" && + enable va_profile_avs + enabled va_profile_avs && check_type "va/va.h va/va_dec_avs.h" "VAPictureParameterBufferAVS" fi if enabled_all opencl libdrm ; then diff --git a/libavcodec/Makefile b/libavcodec/Makefile index bb42095165..7d92375fed 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1055,6 +1055,7 @@ OBJS-$(CONFIG_VP9_VAAPI_HWACCEL) += vaapi_vp9.o OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL) += videotoolbox_vp9.o OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o +OBJS-$(CONFIG_CAVS_VAAPI_HWACCEL) += vaapi_cavs.o # Objects duplicated from other libraries for shared builds SHLIBOBJS += log2_tab.o reverse.o diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h index 33ef10e850..4a0918da5a 100644 --- a/libavcodec/cavs.h +++ b/libavcodec/cavs.h @@ -167,10 +167,14 @@ typedef struct AVSFrame { AVFrame *f; int poc; int outputed; + + AVBufferRef *hwaccel_priv_buf; + void *hwaccel_picture_private; } AVSFrame; typedef struct AVSContext { AVCodecContext *avctx; + int got_pix_fmt; BlockDSPContext bdsp; H264ChromaContext h264chroma; VideoDSPContext vdsp; diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 5036ef50f7..5ca021c098 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -25,11 +25,14 @@ * @author Stefan Gehrer */ +#include "config_components.h" #include "libavutil/avassert.h" #include "libavutil/emms.h" #include "avcodec.h" #include "get_bits.h" #include "golomb.h" +#include "hwaccel_internal.h" +#include "hwconfig.h" #include "profiles.h" #include "cavs.h" #include "codec_internal.h" @@ -1002,9 +1005,9 @@ static inline int decode_slice_header(AVSContext *h, GetBitContext *gb) } h->mb_weight_pred_flag = get_bits1(gb); if (!h->avctx->hwaccel) { - av_log(h->avctx, AV_LOG_ERROR, - "weighted prediction not yet supported\n"); - } + av_log(h->avctx, AV_LOG_ERROR, + "weighted prediction not yet supported\n"); + } } } if (h->aec_flag) { @@ -1115,6 +1118,46 @@ static inline int check_for_slice(AVSContext *h) * frame level * ****************************************************************************/ +static int hwaccel_pic(AVSContext *h) +{ + int ret = 0; + int stc = -1; + const uint8_t *frm_start = align_get_bits(&h->gb); + const uint8_t *frm_end = h->gb.buffer_end; + const uint8_t *slc_start = frm_start; + const uint8_t *slc_end = frm_end; + GetBitContext gb = h->gb; + const FFHWAccel *hwaccel = ffhwaccel(h->avctx->hwaccel); + + ret = hwaccel->start_frame(h->avctx, NULL, 0); + if (ret < 0) + return ret; + + for (slc_start = frm_start; slc_start + 4 < frm_end; slc_start = slc_end) { + slc_end = avpriv_find_start_code(slc_start + 4, frm_end, &stc); + if (slc_end < frm_end) { + slc_end -= 4; + } + + init_get_bits(&h->gb, slc_start, (slc_end - slc_start) * 8); + if (!check_for_slice(h)) { + break; + } + + ret = hwaccel->decode_slice(h->avctx, slc_start, slc_end - slc_start); + if (ret < 0) { + break; + } + } + + h->gb = gb; + skip_bits(&h->gb, (slc_start - frm_start) * 8); + + if (ret < 0) + return ret; + + return hwaccel->end_frame(h->avctx); +} /** * @brief remove frame out of dpb @@ -1125,6 +1168,9 @@ static void cavs_frame_unref(AVSFrame *frame) if (!frame->f || !frame->f->buf[0]) return; + av_buffer_unref(&frame->hwaccel_priv_buf); + frame->hwaccel_picture_private = NULL; + av_frame_unref(frame->f); } @@ -1219,6 +1265,17 @@ static int decode_pic(AVSContext *h) if (ret < 0) return ret; + if (h->avctx->hwaccel) { + const FFHWAccel *hwaccel = ffhwaccel(h->avctx->hwaccel); + av_assert0(!h->cur.hwaccel_picture_private); + if (hwaccel->frame_priv_data_size) { + h->cur.hwaccel_priv_buf = av_buffer_allocz(hwaccel->frame_priv_data_size); + if (!h->cur.hwaccel_priv_buf) + return AVERROR(ENOMEM); + h->cur.hwaccel_picture_private = h->cur.hwaccel_priv_buf->data; + } + } + if (!h->edge_emu_buffer) { int alloc_size = FFALIGN(FFABS(h->cur.f->linesize[0]) + 32, 32); h->edge_emu_buffer = av_mallocz(alloc_size * 2 * 24); @@ -1247,7 +1304,9 @@ static int decode_pic(AVSContext *h) av_log(h->avctx, AV_LOG_ERROR, "poc=%d/%d/%d, dist=%d/%d\n", h->DPB[1].poc, h->DPB[0].poc, h->cur.poc, h->dist[0], h->dist[1]); av_log(h->avctx, AV_LOG_ERROR, "sym_factor %d too large\n", h->sym_factor); - return AVERROR_INVALIDDATA; + + if (!h->avctx->hwaccel) + return AVERROR_INVALIDDATA; } } else { h->direct_den[0] = h->dist[0] ? 16384 / h->dist[0] : 0; @@ -1332,7 +1391,9 @@ static int decode_pic(AVSContext *h) } ret = 0; - if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) { + if (h->avctx->hwaccel) { + ret = hwaccel_pic(h); + } else if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) { do { check_for_slice(h); ret = decode_mb_i(h, 0); @@ -1503,6 +1564,20 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, return ret; avctx->profile = h->profile; avctx->level = h->level; + if (!h->got_pix_fmt) { + h->got_pix_fmt = 1; + ret = ff_get_format(avctx, avctx->codec->pix_fmts); + if (ret < 0) + return ret; + + avctx->pix_fmt = ret; + + if (h->profile == AV_PROFILE_CAVS_GUANGDIAN && !avctx->hwaccel) { + av_log(avctx, AV_LOG_ERROR, "Your platform doesn't suppport hardware" + " accelerated for CAVS Guangdian Profile decoding.\n"); + return AVERROR(ENOTSUP); + } + } break; case PIC_I_START_CODE: if (!h->got_keyframe) { @@ -1577,6 +1652,14 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, return (buf_ptr - avpkt->data); } +static const enum AVPixelFormat cavs_hwaccel_pixfmt_list_420[] = { +#if CONFIG_CAVS_VAAPI_HWACCEL + AV_PIX_FMT_VAAPI, +#endif + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_NONE +}; + const FFCodec ff_cavs_decoder = { .p.name = "cavs", CODEC_LONG_NAME("Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile)"), @@ -1589,4 +1672,12 @@ const FFCodec ff_cavs_decoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .flush = cavs_flush, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .p.pix_fmts = cavs_hwaccel_pixfmt_list_420, + .hw_configs = (const AVCodecHWConfigInternal *const []) { +#if CONFIG_CAVS_VAAPI_HWACCEL + HWACCEL_VAAPI(cavs), +#endif + NULL + }, + .p.profiles = NULL_IF_CONFIG_SMALL(ff_cavs_profiles), }; diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 5171e4c7d7..a1a973b460 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -89,5 +89,6 @@ extern const struct FFHWAccel ff_wmv3_dxva2_hwaccel; extern const struct FFHWAccel ff_wmv3_nvdec_hwaccel; extern const struct FFHWAccel ff_wmv3_vaapi_hwaccel; extern const struct FFHWAccel ff_wmv3_vdpau_hwaccel; +extern const struct FFHWAccel ff_cavs_vaapi_hwaccel; #endif /* AVCODEC_HWACCELS_H */ diff --git a/libavcodec/vaapi_cavs.c b/libavcodec/vaapi_cavs.c new file mode 100644 index 0000000000..4a7a9b95ad --- /dev/null +++ b/libavcodec/vaapi_cavs.c @@ -0,0 +1,164 @@ +/* + * AVS (Chinese GY/T 257.1—2012) HW decode acceleration through VA-API + * Copyright (c) 2022 JianfengZheng + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "hwconfig.h" +#include "hwaccel_internal.h" +#include "vaapi_decode.h" +#include "cavs.h" + +/** + * @file + * This file implements the glue code between FFmpeg's and VA-API's + * structures for AVS (Chinese GY/T 257.1—2012) decoding. + */ + +static int vaapi_avs_pic_type_cvt(int pict_type) +{ + switch (pict_type) + { + case AV_PICTURE_TYPE_I: return VA_AVS_I_IMG; + case AV_PICTURE_TYPE_P: return VA_AVS_P_IMG; + case AV_PICTURE_TYPE_B: return VA_AVS_B_IMG; + default: return VA_AVS_I_IMG; + } +} + +static void vaapi_avs_fill_pic(VAPictureAVS *va_pic, const AVSFrame *frame) +{ + va_pic->surface_id = ff_vaapi_get_surface_id(frame->f); + va_pic->poc = frame->poc / 2; +} + +/** Initialize and start decoding a frame with VA API. */ +static int vaapi_avs_start_frame(AVCodecContext *avctx, + av_unused const uint8_t *buffer, + av_unused uint32_t size) +{ + int i, err; + AVSContext *h = avctx->priv_data; + VAPictureParameterBufferAVS pic_param = {}; + VAAPIDecodePicture *vapic = h->cur.hwaccel_picture_private; + vapic->output_surface = ff_vaapi_get_surface_id(h->cur.f); + + pic_param = (VAPictureParameterBufferAVS) { + .width = h->width, + .height = h->height, + .picture_type = vaapi_avs_pic_type_cvt(h->cur.f->pict_type), + .progressive_seq_flag = h->progressive_seq, + .progressive_frame_flag = h->progressive_frame, + .picture_structure_flag = h->pic_structure, + .fixed_pic_qp_flag = h->qp_fixed, + .picture_qp = h->qp, + .loop_filter_disable_flag = h->loop_filter_disable, + .alpha_c_offset = h->alpha_offset, + .beta_offset = h->beta_offset, + .skip_mode_flag_flag = h->skip_mode_flag, + .picture_reference_flag = h->ref_flag, + }; + + if (h->profile == 0x48) { + pic_param.guangdian_fields.guangdian_flag = 1; + pic_param.guangdian_fields.aec_flag = h->aec_flag; + pic_param.guangdian_fields.weight_quant_flag = h->weight_quant_flag; + pic_param.guangdian_fields.chroma_quant_param_delta_cb = h->chroma_quant_param_delta_cb; + pic_param.guangdian_fields.chroma_quant_param_delta_cr = h->chroma_quant_param_delta_cr; + memcpy(pic_param.guangdian_fields.wqm_8x8, h->wqm_8x8, 64); + } + + vaapi_avs_fill_pic(&pic_param.curr_pic, &h->cur); + for (i = 0; i < 2; i++) { + vaapi_avs_fill_pic(&pic_param.ref_list[i], &h->DPB[i]); + } + + err = ff_vaapi_decode_make_param_buffer(avctx, vapic, + VAPictureParameterBufferType, + &pic_param, sizeof(pic_param)); + if (err < 0) + goto fail; + + return 0; +fail: + ff_vaapi_decode_cancel(avctx, vapic); + return err; +} + +/** End a hardware decoding based frame. */ +static int vaapi_avs_end_frame(AVCodecContext *avctx) +{ + AVSContext *h = avctx->priv_data; + VAAPIDecodePicture *vapic = h->cur.hwaccel_picture_private; + return ff_vaapi_decode_issue(avctx, vapic); +} + +/** Decode the given H.264 slice with VA API. */ +static int vaapi_avs_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + int err; + AVSContext *h = avctx->priv_data; + VAAPIDecodePicture *vapic = h->cur.hwaccel_picture_private; + VASliceParameterBufferAVS slice_param; + slice_param = (VASliceParameterBufferAVS) { + .slice_data_size = size, + .slice_data_offset = 0, + .slice_data_flag = VA_SLICE_DATA_FLAG_ALL, + .mb_data_bit_offset = get_bits_count(&h->gb), + .slice_vertical_pos = h->stc, + .fixed_slice_qp_flag = h->qp_fixed, + .slice_qp = h->qp, + .slice_weight_pred_flag = h->slice_weight_pred_flag, + .mb_weight_pred_flag = h->mb_weight_pred_flag, + }; + + *((uint32_t *)slice_param.luma_scale) = *((uint32_t *)h->luma_scale); + *((uint32_t *)slice_param.luma_shift) = *((uint32_t *)h->luma_shift); + *((uint32_t *)slice_param.chroma_scale) = *((uint32_t *)h->chroma_scale); + *((uint32_t *)slice_param.chroma_shift) = *((uint32_t *)h->chroma_shift); + + err = ff_vaapi_decode_make_slice_buffer(avctx, vapic, + &slice_param, sizeof(slice_param), + buffer, size); + if (err < 0) + goto fail; + + return 0; + +fail: + ff_vaapi_decode_cancel(avctx, vapic); + return err; +} + +const FFHWAccel ff_cavs_vaapi_hwaccel = { + .p.name = "cavs_vaapi", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_CAVS, + .p.pix_fmt = AV_PIX_FMT_VAAPI, + .start_frame = &vaapi_avs_start_frame, + .end_frame = &vaapi_avs_end_frame, + .decode_slice = &vaapi_avs_decode_slice, + .frame_priv_data_size = sizeof(VAAPIDecodePicture), + .init = &ff_vaapi_decode_init, + .uninit = &ff_vaapi_decode_uninit, + .frame_params = &ff_vaapi_common_frame_params, + .priv_data_size = sizeof(VAAPIDecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index ceac769c52..13a3f6aa42 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -408,6 +408,10 @@ static const struct { H264ConstrainedBaseline), MAP(H264, H264_MAIN, H264Main ), MAP(H264, H264_HIGH, H264High ), +#if HAVE_VA_PROFILE_AVS + MAP(CAVS, CAVS_JIZHUN, AVSJizhun ), + MAP(CAVS, CAVS_GUANGDIAN, AVSGuangdian), +#endif #if VA_CHECK_VERSION(0, 37, 0) MAP(HEVC, HEVC_MAIN, HEVCMain ), MAP(HEVC, HEVC_MAIN_10, HEVCMain10 ),