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[] = {
33 };
34 
35 #if CONFIG_LIBVPX_VP9_ENCODER
36 static const enum AVPixelFormat vp9_pix_fmts_highcol[] = {
41 #if VPX_IMAGE_ABI_VERSION >= 3
43 #endif
45 };
46 
47 static const enum AVPixelFormat vp9_pix_fmts_highbd[] = {
60 #if VPX_IMAGE_ABI_VERSION >= 3
64 #endif
66 };
67 #endif
68 
70 {
71  if ( vpx_codec_version_major() < 1
72  || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
74  codec->pix_fmts = vp9_pix_fmts_def;
75 #if CONFIG_LIBVPX_VP9_ENCODER
76  if ( vpx_codec_version_major() > 1
77  || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {
78 #ifdef VPX_CODEC_CAP_HIGHBITDEPTH
79  vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
80  if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
81  codec->pix_fmts = vp9_pix_fmts_highbd;
82  else
83 #endif
84  codec->pix_fmts = vp9_pix_fmts_highcol;
85  }
86 #endif
87 }
88 #if 0
89 enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img)
90 {
91  switch (img) {
92  case VPX_IMG_FMT_RGB24: return AV_PIX_FMT_RGB24;
93  case VPX_IMG_FMT_RGB565: return AV_PIX_FMT_RGB565BE;
94  case VPX_IMG_FMT_RGB555: return AV_PIX_FMT_RGB555BE;
95  case VPX_IMG_FMT_UYVY: return AV_PIX_FMT_UYVY422;
96  case VPX_IMG_FMT_YUY2: return AV_PIX_FMT_YUYV422;
97  case VPX_IMG_FMT_YVYU: return AV_PIX_FMT_YVYU422;
98  case VPX_IMG_FMT_BGR24: return AV_PIX_FMT_BGR24;
99  case VPX_IMG_FMT_ARGB: return AV_PIX_FMT_ARGB;
100  case VPX_IMG_FMT_ARGB_LE: return AV_PIX_FMT_BGRA;
101  case VPX_IMG_FMT_RGB565_LE: return AV_PIX_FMT_RGB565LE;
102  case VPX_IMG_FMT_RGB555_LE: return AV_PIX_FMT_RGB555LE;
103  case VPX_IMG_FMT_I420: return AV_PIX_FMT_YUV420P;
104  case VPX_IMG_FMT_I422: return AV_PIX_FMT_YUV422P;
105  case VPX_IMG_FMT_I444: return AV_PIX_FMT_YUV444P;
106  case VPX_IMG_FMT_444A: return AV_PIX_FMT_YUVA444P;
107 #if VPX_IMAGE_ABI_VERSION >= 3
108  case VPX_IMG_FMT_I440: return AV_PIX_FMT_YUV440P;
109  case VPX_IMG_FMT_I42016: return AV_PIX_FMT_YUV420P16BE;
110  case VPX_IMG_FMT_I42216: return AV_PIX_FMT_YUV422P16BE;
111  case VPX_IMG_FMT_I44416: return AV_PIX_FMT_YUV444P16BE;
112 #endif
113  default: return AV_PIX_FMT_NONE;
114  }
115 }
116 
117 vpx_img_fmt_t ff_vpx_pixfmt_to_imgfmt(enum AVPixelFormat pix)
118 {
119  switch (pix) {
120  case AV_PIX_FMT_RGB24: return VPX_IMG_FMT_RGB24;
121  case AV_PIX_FMT_RGB565BE: return VPX_IMG_FMT_RGB565;
122  case AV_PIX_FMT_RGB555BE: return VPX_IMG_FMT_RGB555;
123  case AV_PIX_FMT_UYVY422: return VPX_IMG_FMT_UYVY;
124  case AV_PIX_FMT_YUYV422: return VPX_IMG_FMT_YUY2;
125  case AV_PIX_FMT_YVYU422: return VPX_IMG_FMT_YVYU;
126  case AV_PIX_FMT_BGR24: return VPX_IMG_FMT_BGR24;
127  case AV_PIX_FMT_ARGB: return VPX_IMG_FMT_ARGB;
128  case AV_PIX_FMT_BGRA: return VPX_IMG_FMT_ARGB_LE;
129  case AV_PIX_FMT_RGB565LE: return VPX_IMG_FMT_RGB565_LE;
130  case AV_PIX_FMT_RGB555LE: return VPX_IMG_FMT_RGB555_LE;
131  case AV_PIX_FMT_YUV420P: return VPX_IMG_FMT_I420;
132  case AV_PIX_FMT_YUV422P: return VPX_IMG_FMT_I422;
133  case AV_PIX_FMT_YUV444P: return VPX_IMG_FMT_I444;
134  case AV_PIX_FMT_YUVA444P: return VPX_IMG_FMT_444A;
135 #if VPX_IMAGE_ABI_VERSION >= 3
136  case AV_PIX_FMT_YUV440P: return VPX_IMG_FMT_I440;
137  case AV_PIX_FMT_YUV420P16BE: return VPX_IMG_FMT_I42016;
138  case AV_PIX_FMT_YUV422P16BE: return VPX_IMG_FMT_I42216;
139  case AV_PIX_FMT_YUV444P16BE: return VPX_IMG_FMT_I44416;
140 #endif
141  default: return VPX_IMG_FMT_NONE;
142  }
143 }
144 #endif
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:82
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:343
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:357
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: avcodec.h:1011
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:345
AVCodec.
Definition: avcodec.h:3542
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:114
#define img
#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:346
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:3561
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:344
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:3563
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:221
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:69
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:188
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:63
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:341
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:347
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:358
static enum AVPixelFormat vp9_pix_fmts_def[]
Definition: libvpx.c:30
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:342
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:348
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