Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
31928212
Commit
31928212
authored
Jul 06, 2017
by
Mark Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pixdesc: Add a test for av_find_best_pix_fmt_of_2()
parent
8a442d7a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
0 deletions
+131
-0
Makefile
libavutil/Makefile
+1
-0
pixfmt_best.c
libavutil/tests/pixfmt_best.c
+125
-0
libavutil.mak
tests/fate/libavutil.mak
+4
-0
pixfmt_best
tests/ref/fate/pixfmt_best
+1
-0
No files found.
libavutil/Makefile
View file @
31928212
...
...
@@ -218,6 +218,7 @@ TESTPROGS = adler32 \
parseutils
\
pixdesc
\
pixelutils
\
pixfmt_best
\
random_seed
\
rational
\
ripemd
\
...
...
libavutil/tests/pixfmt_best.c
0 → 100644
View file @
31928212
/*
* 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 "libavutil/pixdesc.c"
static
const
enum
AVPixelFormat
pixfmt_list
[]
=
{
AV_PIX_FMT_MONOWHITE
,
AV_PIX_FMT_GRAY8
,
AV_PIX_FMT_GRAY10
,
AV_PIX_FMT_GRAY16
,
AV_PIX_FMT_YUV420P
,
AV_PIX_FMT_YUV420P10
,
AV_PIX_FMT_YUV420P16
,
AV_PIX_FMT_YUV422P
,
AV_PIX_FMT_YUV422P10
,
AV_PIX_FMT_YUV422P16
,
AV_PIX_FMT_YUV444P
,
AV_PIX_FMT_YUV444P10
,
AV_PIX_FMT_YUV444P16
,
AV_PIX_FMT_RGB565
,
AV_PIX_FMT_RGB24
,
AV_PIX_FMT_RGB48
,
AV_PIX_FMT_VDPAU
,
AV_PIX_FMT_VAAPI
,
};
static
enum
AVPixelFormat
find_best
(
enum
AVPixelFormat
pixfmt
)
{
enum
AVPixelFormat
best
=
AV_PIX_FMT_NONE
;
int
i
;
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
pixfmt_list
);
i
++
)
best
=
av_find_best_pix_fmt_of_2
(
best
,
pixfmt_list
[
i
],
pixfmt
,
0
,
NULL
);
return
best
;
}
int
main
(
void
)
{
enum
AVPixelFormat
output
;
int
i
,
pass
=
0
,
fail
=
0
;
#define TEST(input, expected) do { \
output = find_best(input); \
if (output != expected) { \
printf("Matching %s: got %s, expected %s\n", \
av_get_pix_fmt_name(input), \
av_get_pix_fmt_name(output), \
av_get_pix_fmt_name(expected)); \
++fail; \
} else \
++pass; \
} while (0)
// Same formats.
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
pixfmt_list
);
i
++
)
TEST
(
pixfmt_list
[
i
],
pixfmt_list
[
i
]);
// Formats containing the same data in different layouts.
TEST
(
AV_PIX_FMT_MONOBLACK
,
AV_PIX_FMT_MONOWHITE
);
TEST
(
AV_PIX_FMT_NV12
,
AV_PIX_FMT_YUV420P
);
TEST
(
AV_PIX_FMT_P010
,
AV_PIX_FMT_YUV420P10
);
TEST
(
AV_PIX_FMT_P016
,
AV_PIX_FMT_YUV420P16
);
TEST
(
AV_PIX_FMT_NV16
,
AV_PIX_FMT_YUV422P
);
TEST
(
AV_PIX_FMT_YUYV422
,
AV_PIX_FMT_YUV422P
);
TEST
(
AV_PIX_FMT_UYVY422
,
AV_PIX_FMT_YUV422P
);
TEST
(
AV_PIX_FMT_BGR565
,
AV_PIX_FMT_RGB565
);
TEST
(
AV_PIX_FMT_BGR24
,
AV_PIX_FMT_RGB24
);
TEST
(
AV_PIX_FMT_GBRP
,
AV_PIX_FMT_RGB24
);
TEST
(
AV_PIX_FMT_0RGB
,
AV_PIX_FMT_RGB24
);
TEST
(
AV_PIX_FMT_GBRP16
,
AV_PIX_FMT_RGB48
);
// Formats additionally containing alpha (here ignored).
TEST
(
AV_PIX_FMT_YA8
,
AV_PIX_FMT_GRAY8
);
TEST
(
AV_PIX_FMT_YA16
,
AV_PIX_FMT_GRAY16
);
TEST
(
AV_PIX_FMT_YUVA420P
,
AV_PIX_FMT_YUV420P
);
TEST
(
AV_PIX_FMT_YUVA422P
,
AV_PIX_FMT_YUV422P
);
TEST
(
AV_PIX_FMT_YUVA444P
,
AV_PIX_FMT_YUV444P
);
TEST
(
AV_PIX_FMT_AYUV64
,
AV_PIX_FMT_YUV444P16
);
TEST
(
AV_PIX_FMT_RGBA
,
AV_PIX_FMT_RGB24
);
TEST
(
AV_PIX_FMT_ABGR
,
AV_PIX_FMT_RGB24
);
TEST
(
AV_PIX_FMT_GBRAP
,
AV_PIX_FMT_RGB24
);
TEST
(
AV_PIX_FMT_RGBA64
,
AV_PIX_FMT_RGB48
);
TEST
(
AV_PIX_FMT_BGRA64
,
AV_PIX_FMT_RGB48
);
TEST
(
AV_PIX_FMT_GBRAP16
,
AV_PIX_FMT_RGB48
);
// Formats requiring upsampling to represent exactly.
TEST
(
AV_PIX_FMT_GRAY12
,
AV_PIX_FMT_GRAY16
);
TEST
(
AV_PIX_FMT_YUV410P
,
AV_PIX_FMT_YUV420P
);
TEST
(
AV_PIX_FMT_YUV411P
,
AV_PIX_FMT_YUV422P
);
TEST
(
AV_PIX_FMT_UYYVYY411
,
AV_PIX_FMT_YUV422P
);
TEST
(
AV_PIX_FMT_YUV440P
,
AV_PIX_FMT_YUV444P
);
TEST
(
AV_PIX_FMT_YUV440P10
,
AV_PIX_FMT_YUV444P10
);
TEST
(
AV_PIX_FMT_YUV440P12
,
AV_PIX_FMT_YUV444P16
);
TEST
(
AV_PIX_FMT_YUV420P9
,
AV_PIX_FMT_YUV420P10
);
TEST
(
AV_PIX_FMT_YUV420P12
,
AV_PIX_FMT_YUV420P16
);
TEST
(
AV_PIX_FMT_YUV444P9
,
AV_PIX_FMT_YUV444P10
);
TEST
(
AV_PIX_FMT_YUV444P12
,
AV_PIX_FMT_YUV444P16
);
TEST
(
AV_PIX_FMT_BGR4
,
AV_PIX_FMT_RGB565
);
TEST
(
AV_PIX_FMT_RGB444
,
AV_PIX_FMT_RGB565
);
TEST
(
AV_PIX_FMT_RGB555
,
AV_PIX_FMT_RGB565
);
TEST
(
AV_PIX_FMT_GBRP10
,
AV_PIX_FMT_RGB48
);
TEST
(
AV_PIX_FMT_GBRAP10
,
AV_PIX_FMT_RGB48
);
TEST
(
AV_PIX_FMT_GBRAP12
,
AV_PIX_FMT_RGB48
);
// Opaque formats are least unlike each other.
TEST
(
AV_PIX_FMT_DXVA2_VLD
,
AV_PIX_FMT_VDPAU
);
printf
(
"%d tests passed, %d tests failed.
\n
"
,
pass
,
fail
);
return
!!
fail
;
}
tests/fate/libavutil.mak
View file @
31928212
...
...
@@ -115,6 +115,10 @@ FATE_LIBAVUTIL-$(CONFIG_PIXELUTILS) += fate-pixelutils
fate-pixelutils: libavutil/tests/pixelutils$(EXESUF)
fate-pixelutils: CMD = run libavutil/tests/pixelutils
FATE_LIBAVUTIL += fate-pixfmt_best
fate-pixfmt_best: libavutil/tests/pixfmt_best$(EXESUF)
fate-pixfmt_best: CMD = run libavutil/tests/pixfmt_best
FATE_LIBAVUTIL += fate-display
fate-display: libavutil/tests/display$(EXESUF)
fate-display: CMD = run libavutil/tests/display
...
...
tests/ref/fate/pixfmt_best
0 → 100644
View file @
31928212
60 tests passed, 0 tests failed.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment