FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pixfmt_best.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "libavutil/pixdesc.c"
20 
21 static const enum AVPixelFormat pixfmt_list[] = {
40 };
41 
43 {
44  enum AVPixelFormat best = AV_PIX_FMT_NONE;
45  int i;
46  for (i = 0; i < FF_ARRAY_ELEMS(pixfmt_list); i++)
47  best = av_find_best_pix_fmt_of_2(best, pixfmt_list[i],
48  pixfmt, 0, NULL);
49  return best;
50 }
51 
52 int main(void)
53 {
54  enum AVPixelFormat output;
55  int i, pass = 0, fail = 0;
56 
57 #define TEST(input, expected) do { \
58  output = find_best(input); \
59  if (output != expected) { \
60  printf("Matching %s: got %s, expected %s\n", \
61  av_get_pix_fmt_name(input), \
62  av_get_pix_fmt_name(output), \
63  av_get_pix_fmt_name(expected)); \
64  ++fail; \
65  } else \
66  ++pass; \
67  } while (0)
68 
69  // Same formats.
70  for (i = 0; i < FF_ARRAY_ELEMS(pixfmt_list); i++)
72 
73  // Formats containing the same data in different layouts.
86 
87  // Formats additionally containing alpha (here ignored).
100 
101  // Formats requiring upsampling to represent exactly.
119 
120  // Formats containing the same data in different endianness.
133 
134  // Opaque formats are least unlike each other.
136 
137  printf("%d tests passed, %d tests failed.\n", pass, fail);
138  return !!fail;
139 }
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:82
#define NULL
Definition: coverity.c:32
static enum AVPixelFormat pixfmt_list[]
Definition: pixfmt_best.c:21
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:381
int main(void)
Definition: pixfmt_best.c:52
8 bits gray, 8 bits alpha
Definition: pixfmt.h:154
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:399
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:64
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:85
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:369
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:180
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:395
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:374
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:383
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:368
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:361
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:114
#define AV_PIX_FMT_P016
Definition: pixfmt.h:425
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:362
#define AV_PIX_FMT_P010
Definition: pixfmt.h:424
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:111
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:113
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:95
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:392
Y , 10bpp, little-endian.
Definition: pixfmt.h:312
static enum AVPixelFormat find_best(enum AVPixelFormat pixfmt)
Definition: pixfmt_best.c:42
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:188
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:144
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:172
#define AV_PIX_FMT_YA16
Definition: pixfmt.h:364
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:90
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:400
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:365
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:382
#define fail()
Definition: checkasm.h:109
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:401
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:94
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
#define pass
Definition: fft_template.c:593
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:398
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:363
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:65
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:378
#define FF_ARRAY_ELEMS(a)
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:390
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:189
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:63
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:379
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
Y , 16bpp, big-endian.
Definition: pixfmt.h:98
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
Definition: pixfmt.h:209
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:385
#define TEST(input, expected)
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:376
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
Definition: pixfmt.h:148
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:371
#define AV_PIX_FMT_AYUV64
Definition: pixfmt.h:423
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:386
Y , 10bpp, big-endian.
Definition: pixfmt.h:311
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:143
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:72
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:71
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:229
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:110
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:367
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:213
enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Compute what kind of losses will occur when converting from one specific pixel format to another...
Definition: pixdesc.c:2709
Y , 16bpp, little-endian.
Definition: pixfmt.h:99
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:202
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:366
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:100
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:251
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
Definition: pixfmt.h:83
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:391
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:171