Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Neal Gompa <ngompa13@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: fei.w.wang@intel.com
Subject: Re: [FFmpeg-devel] [PATCH v5 8/8] lavc/av1: Add unit test for level handling
Date: Tue, 19 Sep 2023 20:47:19 -0400
Message-ID: <CAEg-Je-yTh5=kt_5y-=E-xKHT-jv4hcCA0hbDSQXFvZqc=hpyQ@mail.gmail.com> (raw)
In-Reply-To: <20230911075232.797886-8-fei.w.wang@intel.com>

On Mon, Sep 11, 2023 at 3:54 AM <fei.w.wang-at-intel.com@ffmpeg.org> wrote:
>
> From: Fei Wang <fei.w.wang@intel.com>
>
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>  libavcodec/tests/.gitignore   |   1 +
>  libavcodec/tests/av1_levels.c | 126 ++++++++++++++++++++++++++++++++++
>  tests/fate/libavcodec.mak     |   5 ++
>  3 files changed, 132 insertions(+)
>  create mode 100644 libavcodec/tests/av1_levels.c
>
> diff --git a/libavcodec/tests/.gitignore b/libavcodec/tests/.gitignore
> index 2acfc4e804..5e0ccc5838 100644
> --- a/libavcodec/tests/.gitignore
> +++ b/libavcodec/tests/.gitignore
> @@ -1,3 +1,4 @@
> +/av1_levels
>  /avcodec
>  /avfft
>  /avpacket
> diff --git a/libavcodec/tests/av1_levels.c b/libavcodec/tests/av1_levels.c
> new file mode 100644
> index 0000000000..e862d197d2
> --- /dev/null
> +++ b/libavcodec/tests/av1_levels.c
> @@ -0,0 +1,126 @@
> +/*
> + * Copyright (c) 2023 Intel Corporation
> + *
> + * 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 <stddef.h>
> +#include <inttypes.h>
> +#include "libavutil/log.h"
> +#include "libavcodec/av1_levels.h"
> +
> +static const struct {
> +    int width;
> +    int height;
> +    float framerate;
> +    int level_idx;
> +} test_sizes[] = {
> +    {  426,  240,  30.0,  0 },
> +    {  640,  360,  30.0,  1 },
> +    {  854,  480,  30.0,  4 },
> +    { 1280,  720,  30.0,  5 },
> +    { 1920, 1080,  30.0,  8 },
> +    { 1920, 1080,  60.0,  9 },
> +    { 3840, 2160,  30.0, 12 },
> +    { 3840, 2160,  60.0, 13 },
> +    { 3840, 2160, 120.0, 14 },
> +    { 7680, 4320,  30.0, 16 },
> +    { 7680, 4320,  60.0, 17 },
> +    { 7680, 4320, 120.0, 18 },
> +};
> +
> +static const struct {
> +    int64_t bitrate;
> +    int tier;
> +    int level_idx;
> +} test_bitrate[] = {
> +    {   1500000, 0,  0 },
> +    {   3000000, 0,  1 },
> +    {   6000000, 0,  4 },
> +    {  10000000, 0,  5 },
> +    {  12000000, 0,  8 },
> +    {  30000000, 1,  8 },
> +    {  20000000, 0,  9 },
> +    {  50000000, 1,  9 },
> +    {  30000000, 0, 12 },
> +    { 100000000, 1, 12 },
> +    {  40000000, 0, 13 },
> +    { 160000000, 1, 13 },
> +    {  60000000, 0, 14 },
> +    { 240000000, 1, 14 },
> +    { 100000000, 0, 17 },
> +    { 480000000, 1, 17 },
> +    { 160000000, 0, 18 },
> +    { 800000000, 1, 18 },
> +};
> +
> +static const struct {
> +    int tiles;
> +    int tile_cols;
> +    int level_idx;
> +} test_tiles[] = {
> +    {    8,  4,  0 },
> +    {   16,  6,  4 },
> +    {   32,  8,  8 },
> +    {   64,  8, 12 },
> +    {  128, 16, 16 },
> +};
> +
> +int main(void)
> +{
> +    const AV1LevelDescriptor *level;
> +    int i;
> +
> +#define CHECK(expected, format, ...) do { \
> +        if (level ? (level->level_idx != expected) \
> +                     : !level) { \
> +            av_log(NULL, AV_LOG_ERROR, "Incorrect level for " \
> +                   format ": expected %d, got %d.\n", __VA_ARGS__, \
> +                   expected, level ? level->level_idx : -1); \
> +            return 1; \
> +        } \
> +    } while (0)
> +
> +    for (i = 0; i < FF_ARRAY_ELEMS(test_sizes); i++) {
> +        level = ff_av1_guess_level(0, 0,
> +                                   test_sizes[i].width,
> +                                   test_sizes[i].height,
> +                                   0, 0, test_sizes[i].framerate);
> +        CHECK(test_sizes[i].level_idx, "size %dx%d, framerate %f",
> +              test_sizes[i].width, test_sizes[i].height, test_sizes[i].framerate);
> +    }
> +
> +    for (i = 0; i < FF_ARRAY_ELEMS(test_bitrate); i++) {
> +        level = ff_av1_guess_level(test_bitrate[i].bitrate,
> +                                   test_bitrate[i].tier,
> +                                   0, 0, 0, 0, 0);
> +        CHECK(test_bitrate[i].level_idx, "bitrate %"PRId64" tier %d",
> +              test_bitrate[i].bitrate, test_bitrate[i].tier);
> +    }
> +
> +    for (i = 0; i < FF_ARRAY_ELEMS(test_tiles); i++) {
> +        level = ff_av1_guess_level(0, 0, 0, 0,
> +                                   test_tiles[i].tiles,
> +                                   test_tiles[i].tile_cols,
> +                                   0);
> +        CHECK(test_tiles[i].level_idx, "tiles %d, tile cols %d",
> +              test_tiles[i].tiles,
> +              test_tiles[i].tile_cols);
> +    }
> +
> +    return 0;
> +}
> diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
> index 8f56fae3a8..1a5694fa5f 100644
> --- a/tests/fate/libavcodec.mak
> +++ b/tests/fate/libavcodec.mak
> @@ -1,3 +1,8 @@
> +FATE_LIBAVCODEC-$(CONFIG_AV1_VAAPI_ENCODER) += fate-av1-levels
> +fate-av1-levels: libavcodec/tests/av1_levels$(EXESUF)
> +fate-av1-levels: CMD = run libavcodec/tests/av1_levels$(EXESUF)
> +fate-av1-levels: REF = /dev/null
> +
>  FATE_LIBAVCODEC-yes += fate-avpacket
>  fate-avpacket: libavcodec/tests/avpacket$(EXESUF)
>  fate-avpacket: CMD = run libavcodec/tests/avpacket$(EXESUF)
> --
> 2.25.1
>

LGTM.

Reviewed-by: Neal Gompa <ngompa13@gmail.com>



-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
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".

  reply	other threads:[~2023-09-20  0:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11  7:52 [FFmpeg-devel] [PATCH v5 1/8] avcodec/cbs_av1: Add tx mode enum values fei.w.wang-at-intel.com
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 2/8] cbs: Make tracing more general fei.w.wang-at-intel.com
2023-09-20  0:41   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 3/8] avcodec/cbs_av1: Allow specifying obu size byte length fei.w.wang-at-intel.com
2023-09-20  0:41   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 4/8] lavc/vaapi_encode: Init pic at the beginning of API fei.w.wang-at-intel.com
2023-09-20  0:43   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 5/8] lavc/vaapi_encode: Extract set output pkt property function fei.w.wang-at-intel.com
2023-09-20  0:44   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 6/8] lavc/vaapi_encode: Separate reference frame into previous/future list fei.w.wang-at-intel.com
2023-09-20  0:45   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 7/8] lavc/vaapi_encode: Add VAAPI AV1 encoder fei.w.wang-at-intel.com
2023-09-20  0:46   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 8/8] lavc/av1: Add unit test for level handling fei.w.wang-at-intel.com
2023-09-20  0:47   ` Neal Gompa [this message]
2023-09-20  0:40 ` [FFmpeg-devel] [PATCH v5 1/8] avcodec/cbs_av1: Add tx mode enum values Neal Gompa
2023-09-20  0:42   ` Neal Gompa
2023-09-20  2:21   ` Xiang, Haihao
2023-09-22  5:33     ` Xiang, Haihao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEg-Je-yTh5=kt_5y-=E-xKHT-jv4hcCA0hbDSQXFvZqc=hpyQ@mail.gmail.com' \
    --to=ngompa13@gmail.com \
    --cc=fei.w.wang@intel.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git