FFmpeg
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.
87 
88  // Formats additionally containing alpha (here ignored).
101 
102  // Formats requiring upsampling to represent exactly.
120 
121  // Formats containing the same data in different endianness.
134 
135  // Opaque formats are least unlike each other.
137 
138  printf("%d tests passed, %d tests failed.\n", pass, fail);
139  return !!fail;
140 }
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:81
#define NULL
Definition: coverity.c:32
static enum AVPixelFormat pixfmt_list[]
Definition: pixfmt_best.c:21
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:389
int main(void)
Definition: pixfmt_best.c:52
8 bits gray, 8 bits alpha
Definition: pixfmt.h:143
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:407
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:84
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:377
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:403
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:382
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:391
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:376
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:368
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:106
#define AV_PIX_FMT_P016
Definition: pixfmt.h:437
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:369
#define AV_PIX_FMT_P010
Definition: pixfmt.h:436
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
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:103
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:105
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:400
Y , 10bpp, little-endian.
Definition: pixfmt.h:298
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:176
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:136
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:161
#define AV_PIX_FMT_YA16
Definition: pixfmt.h:372
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:89
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:408
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:373
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:390
#define fail()
Definition: checkasm.h:122
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:409
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
#define pass
Definition: fft_template.c:619
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:348
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:406
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:371
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:386
#define FF_ARRAY_ELEMS(a)
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:398
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:387
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
Y , 16bpp, big-endian.
Definition: pixfmt.h:97
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
Definition: pixfmt.h:197
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:393
#define TEST(input, expected)
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:384
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
Definition: pixfmt.h:137
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:379
#define AV_PIX_FMT_AYUV64
Definition: pixfmt.h:435
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:388
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:394
Y , 10bpp, big-endian.
Definition: pixfmt.h:297
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:135
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:76
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
Y , 8bpp.
Definition: pixfmt.h:74
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:75
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
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:102
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:375
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:201
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:2811
printf("static const uint8_t my_array[100] = {\n")
Y , 16bpp, little-endian.
Definition: pixfmt.h:98
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:202
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:374
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:237
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
Definition: pixfmt.h:82
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:399
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:160