FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
libvpx.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Guillaume Martres <smarter@ubuntu.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <vpx/vpx_codec.h>
22 #include "libvpx.h"
23 #include "config.h"
24 
25 #if CONFIG_LIBVPX_VP9_ENCODER
26 #include <vpx/vpx_encoder.h>
27 #include <vpx/vp8cx.h>
28 #endif
29 
30 static const enum AVPixelFormat vp9_pix_fmts_def[] = {
34 };
35 
36 #if CONFIG_LIBVPX_VP9_ENCODER
37 static const enum AVPixelFormat vp9_pix_fmts_highcol[] = {
43 #if VPX_IMAGE_ABI_VERSION >= 3
45 #endif
47 };
48 
49 static const enum AVPixelFormat vp9_pix_fmts_highbd[] = {
63 #if VPX_IMAGE_ABI_VERSION >= 3
67 #endif
69 };
70 #endif
71 
73 {
74  if ( vpx_codec_version_major() < 1
75  || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
77  codec->pix_fmts = vp9_pix_fmts_def;
78 #if CONFIG_LIBVPX_VP9_ENCODER
79  if ( vpx_codec_version_major() > 1
80  || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {
81 #ifdef VPX_CODEC_CAP_HIGHBITDEPTH
82  vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
83  if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
84  codec->pix_fmts = vp9_pix_fmts_highbd;
85  else
86 #endif
87  codec->pix_fmts = vp9_pix_fmts_highcol;
88  }
89 #endif
90 }
91 #if 0
92 enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img)
93 {
94  switch (img) {
95  case VPX_IMG_FMT_RGB24: return AV_PIX_FMT_RGB24;
96  case VPX_IMG_FMT_RGB565: return AV_PIX_FMT_RGB565BE;
97  case VPX_IMG_FMT_RGB555: return AV_PIX_FMT_RGB555BE;
98  case VPX_IMG_FMT_UYVY: return AV_PIX_FMT_UYVY422;
99  case VPX_IMG_FMT_YUY2: return AV_PIX_FMT_YUYV422;
100  case VPX_IMG_FMT_YVYU: return AV_PIX_FMT_YVYU422;
101  case VPX_IMG_FMT_BGR24: return AV_PIX_FMT_BGR24;
102  case VPX_IMG_FMT_ARGB: return AV_PIX_FMT_ARGB;
103  case VPX_IMG_FMT_ARGB_LE: return AV_PIX_FMT_BGRA;
104  case VPX_IMG_FMT_RGB565_LE: return AV_PIX_FMT_RGB565LE;
105  case VPX_IMG_FMT_RGB555_LE: return AV_PIX_FMT_RGB555LE;
106  case VPX_IMG_FMT_I420: return AV_PIX_FMT_YUV420P;
107  case VPX_IMG_FMT_I422: return AV_PIX_FMT_YUV422P;
108  case VPX_IMG_FMT_I444: return AV_PIX_FMT_YUV444P;
109  case VPX_IMG_FMT_444A: return AV_PIX_FMT_YUVA444P;
110 #if VPX_IMAGE_ABI_VERSION >= 3
111  case VPX_IMG_FMT_I440: return AV_PIX_FMT_YUV440P;
112  case VPX_IMG_FMT_I42016: return AV_PIX_FMT_YUV420P16BE;
113  case VPX_IMG_FMT_I42216: return AV_PIX_FMT_YUV422P16BE;
114  case VPX_IMG_FMT_I44416: return AV_PIX_FMT_YUV444P16BE;
115 #endif
116  default: return AV_PIX_FMT_NONE;
117  }
118 }
119 
120 vpx_img_fmt_t ff_vpx_pixfmt_to_imgfmt(enum AVPixelFormat pix)
121 {
122  switch (pix) {
123  case AV_PIX_FMT_RGB24: return VPX_IMG_FMT_RGB24;
124  case AV_PIX_FMT_RGB565BE: return VPX_IMG_FMT_RGB565;
125  case AV_PIX_FMT_RGB555BE: return VPX_IMG_FMT_RGB555;
126  case AV_PIX_FMT_UYVY422: return VPX_IMG_FMT_UYVY;
127  case AV_PIX_FMT_YUYV422: return VPX_IMG_FMT_YUY2;
128  case AV_PIX_FMT_YVYU422: return VPX_IMG_FMT_YVYU;
129  case AV_PIX_FMT_BGR24: return VPX_IMG_FMT_BGR24;
130  case AV_PIX_FMT_ARGB: return VPX_IMG_FMT_ARGB;
131  case AV_PIX_FMT_BGRA: return VPX_IMG_FMT_ARGB_LE;
132  case AV_PIX_FMT_RGB565LE: return VPX_IMG_FMT_RGB565_LE;
133  case AV_PIX_FMT_RGB555LE: return VPX_IMG_FMT_RGB555_LE;
134  case AV_PIX_FMT_YUV420P: return VPX_IMG_FMT_I420;
135  case AV_PIX_FMT_YUV422P: return VPX_IMG_FMT_I422;
136  case AV_PIX_FMT_YUV444P: return VPX_IMG_FMT_I444;
137  case AV_PIX_FMT_YUVA444P: return VPX_IMG_FMT_444A;
138 #if VPX_IMAGE_ABI_VERSION >= 3
139  case AV_PIX_FMT_YUV440P: return VPX_IMG_FMT_I440;
140  case AV_PIX_FMT_YUV420P16BE: return VPX_IMG_FMT_I42016;
141  case AV_PIX_FMT_YUV422P16BE: return VPX_IMG_FMT_I42216;
142  case AV_PIX_FMT_YUV444P16BE: return VPX_IMG_FMT_I44416;
143 #endif
144  default: return VPX_IMG_FMT_NONE;
145  }
146 }
147 #endif
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:82
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:381
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
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:180
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:116
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:395
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: avcodec.h:1057
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:383
AVCodec.
Definition: avcodec.h:3739
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:114
#define img
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
#define av_cold
Definition: attributes.h:82
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:113
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:384
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:144
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:96
int capabilities
Codec capabilities.
Definition: avcodec.h:3758
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:142
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:382
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:93
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
Definition: avcodec.h:3760
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:222
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:65
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:140
av_cold void ff_vp9_init_static(AVCodec *codec)
Definition: libvpx.c:72
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
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:385
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:396
static enum AVPixelFormat vp9_pix_fmts_def[]
Definition: libvpx.c:30
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:115
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:386
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:100
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60