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[] = {
42 };
43 
44 static const enum AVPixelFormat vp9_pix_fmts_highbd[] = {
58 };
59 #endif
60 
62 {
63  if ( vpx_codec_version_major() < 1
64  || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
66  codec->pix_fmts = vp9_pix_fmts_def;
67 #if CONFIG_LIBVPX_VP9_ENCODER
68  if ( vpx_codec_version_major() > 1
69  || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {
70 #ifdef VPX_CODEC_CAP_HIGHBITDEPTH
71  vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
72  if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
73  codec->pix_fmts = vp9_pix_fmts_highbd;
74  else
75 #endif
76  codec->pix_fmts = vp9_pix_fmts_highcol;
77  }
78 #endif
79 }
80 #if 0
81 enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img)
82 {
83  switch (img) {
84  case VPX_IMG_FMT_RGB24: return AV_PIX_FMT_RGB24;
85  case VPX_IMG_FMT_RGB565: return AV_PIX_FMT_RGB565BE;
86  case VPX_IMG_FMT_RGB555: return AV_PIX_FMT_RGB555BE;
87  case VPX_IMG_FMT_UYVY: return AV_PIX_FMT_UYVY422;
88  case VPX_IMG_FMT_YUY2: return AV_PIX_FMT_YUYV422;
89  case VPX_IMG_FMT_YVYU: return AV_PIX_FMT_YVYU422;
90  case VPX_IMG_FMT_BGR24: return AV_PIX_FMT_BGR24;
91  case VPX_IMG_FMT_ARGB: return AV_PIX_FMT_ARGB;
92  case VPX_IMG_FMT_ARGB_LE: return AV_PIX_FMT_BGRA;
93  case VPX_IMG_FMT_RGB565_LE: return AV_PIX_FMT_RGB565LE;
94  case VPX_IMG_FMT_RGB555_LE: return AV_PIX_FMT_RGB555LE;
95  case VPX_IMG_FMT_I420: return AV_PIX_FMT_YUV420P;
96  case VPX_IMG_FMT_I422: return AV_PIX_FMT_YUV422P;
97  case VPX_IMG_FMT_I444: return AV_PIX_FMT_YUV444P;
98  case VPX_IMG_FMT_444A: return AV_PIX_FMT_YUVA444P;
99 #if VPX_IMAGE_ABI_VERSION >= 3
100  case VPX_IMG_FMT_I440: return AV_PIX_FMT_YUV440P;
101  case VPX_IMG_FMT_I42016: return AV_PIX_FMT_YUV420P16BE;
102  case VPX_IMG_FMT_I42216: return AV_PIX_FMT_YUV422P16BE;
103  case VPX_IMG_FMT_I44416: return AV_PIX_FMT_YUV444P16BE;
104 #endif
105  default: return AV_PIX_FMT_NONE;
106  }
107 }
108 
109 vpx_img_fmt_t ff_vpx_pixfmt_to_imgfmt(enum AVPixelFormat pix)
110 {
111  switch (pix) {
112  case AV_PIX_FMT_RGB24: return VPX_IMG_FMT_RGB24;
113  case AV_PIX_FMT_RGB565BE: return VPX_IMG_FMT_RGB565;
114  case AV_PIX_FMT_RGB555BE: return VPX_IMG_FMT_RGB555;
115  case AV_PIX_FMT_UYVY422: return VPX_IMG_FMT_UYVY;
116  case AV_PIX_FMT_YUYV422: return VPX_IMG_FMT_YUY2;
117  case AV_PIX_FMT_YVYU422: return VPX_IMG_FMT_YVYU;
118  case AV_PIX_FMT_BGR24: return VPX_IMG_FMT_BGR24;
119  case AV_PIX_FMT_ARGB: return VPX_IMG_FMT_ARGB;
120  case AV_PIX_FMT_BGRA: return VPX_IMG_FMT_ARGB_LE;
121  case AV_PIX_FMT_RGB565LE: return VPX_IMG_FMT_RGB565_LE;
122  case AV_PIX_FMT_RGB555LE: return VPX_IMG_FMT_RGB555_LE;
123  case AV_PIX_FMT_YUV420P: return VPX_IMG_FMT_I420;
124  case AV_PIX_FMT_YUV422P: return VPX_IMG_FMT_I422;
125  case AV_PIX_FMT_YUV444P: return VPX_IMG_FMT_I444;
126  case AV_PIX_FMT_YUVA444P: return VPX_IMG_FMT_444A;
127 #if VPX_IMAGE_ABI_VERSION >= 3
128  case AV_PIX_FMT_YUV440P: return VPX_IMG_FMT_I440;
129  case AV_PIX_FMT_YUV420P16BE: return VPX_IMG_FMT_I42016;
130  case AV_PIX_FMT_YUV422P16BE: return VPX_IMG_FMT_I42216;
131  case AV_PIX_FMT_YUV444P16BE: return VPX_IMG_FMT_I44416;
132 #endif
133  default: return VPX_IMG_FMT_NONE;
134  }
135 }
136 #endif
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:83
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:319
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:171
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:68
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:65
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:117
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: avcodec.h:912
AVCodec.
Definition: avcodec.h:3472
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:115
#define img
#define av_cold
Definition: attributes.h:74
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:292
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:114
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:177
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:145
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:97
int capabilities
Codec capabilities.
Definition: avcodec.h:3491
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:173
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:143
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:94
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:67
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
Definition: avcodec.h:3493
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:242
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:66
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:284
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:141
av_cold void ff_vp9_init_static(AVCodec *codec)
Definition: libvpx.c:61
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:280
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:64
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:321
static enum AVPixelFormat vp9_pix_fmts_def[]
Definition: libvpx.c:30
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:116
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:63
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:288
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:101
AVPixelFormat
Pixel format.
Definition: pixfmt.h:61