2013-11-16 01:28:30 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Guillaume Martres <smarter@ubuntu.com>
|
|
|
|
*
|
2013-12-08 15:49:16 +03:00
|
|
|
* This file is part of FFmpeg.
|
2013-11-16 01:28:30 +03:00
|
|
|
*
|
2013-12-08 15:49:16 +03:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2013-11-16 01:28:30 +03:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2013-12-08 15:49:16 +03:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2013-11-16 01:28:30 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2013-12-08 15:49:16 +03:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2013-11-16 01:28:30 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <vpx/vpx_codec.h>
|
|
|
|
#include "libvpx.h"
|
2015-03-26 02:10:16 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#if CONFIG_LIBVPX_VP9_ENCODER
|
|
|
|
#include <vpx/vpx_encoder.h>
|
|
|
|
#include <vpx/vp8cx.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const enum AVPixelFormat vp9_pix_fmts_def[] = {
|
|
|
|
AV_PIX_FMT_YUV420P,
|
2016-07-01 01:16:31 +02:00
|
|
|
AV_PIX_FMT_YUVA420P,
|
2015-03-26 02:10:16 +02:00
|
|
|
AV_PIX_FMT_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
#if CONFIG_LIBVPX_VP9_ENCODER
|
|
|
|
static const enum AVPixelFormat vp9_pix_fmts_highcol[] = {
|
|
|
|
AV_PIX_FMT_YUV420P,
|
2016-07-01 01:16:31 +02:00
|
|
|
AV_PIX_FMT_YUVA420P,
|
2015-03-26 02:10:16 +02:00
|
|
|
AV_PIX_FMT_YUV422P,
|
2015-05-20 22:52:47 +02:00
|
|
|
AV_PIX_FMT_YUV440P,
|
2015-03-26 02:10:16 +02:00
|
|
|
AV_PIX_FMT_YUV444P,
|
2016-02-19 22:06:26 +02:00
|
|
|
#if VPX_IMAGE_ABI_VERSION >= 3
|
|
|
|
AV_PIX_FMT_GBRP,
|
|
|
|
#endif
|
2015-03-26 02:10:16 +02:00
|
|
|
AV_PIX_FMT_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
static const enum AVPixelFormat vp9_pix_fmts_highbd[] = {
|
|
|
|
AV_PIX_FMT_YUV420P,
|
2016-07-01 01:16:31 +02:00
|
|
|
AV_PIX_FMT_YUVA420P,
|
2015-03-26 02:10:16 +02:00
|
|
|
AV_PIX_FMT_YUV422P,
|
2015-05-20 22:52:47 +02:00
|
|
|
AV_PIX_FMT_YUV440P,
|
2015-03-26 02:10:16 +02:00
|
|
|
AV_PIX_FMT_YUV444P,
|
2016-02-19 22:02:42 +02:00
|
|
|
AV_PIX_FMT_YUV420P10,
|
|
|
|
AV_PIX_FMT_YUV422P10,
|
|
|
|
AV_PIX_FMT_YUV440P10,
|
|
|
|
AV_PIX_FMT_YUV444P10,
|
|
|
|
AV_PIX_FMT_YUV420P12,
|
|
|
|
AV_PIX_FMT_YUV422P12,
|
|
|
|
AV_PIX_FMT_YUV440P12,
|
|
|
|
AV_PIX_FMT_YUV444P12,
|
2016-02-19 22:06:26 +02:00
|
|
|
#if VPX_IMAGE_ABI_VERSION >= 3
|
|
|
|
AV_PIX_FMT_GBRP,
|
|
|
|
AV_PIX_FMT_GBRP10,
|
|
|
|
AV_PIX_FMT_GBRP12,
|
|
|
|
#endif
|
2015-03-26 02:10:16 +02:00
|
|
|
AV_PIX_FMT_NONE
|
|
|
|
};
|
|
|
|
#endif
|
2013-11-16 01:28:30 +03:00
|
|
|
|
2013-12-08 16:04:06 +03:00
|
|
|
av_cold void ff_vp9_init_static(AVCodec *codec)
|
2013-11-16 01:28:30 +03:00
|
|
|
{
|
2013-12-08 16:04:06 +03:00
|
|
|
if ( vpx_codec_version_major() < 1
|
|
|
|
|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
|
2015-07-27 22:21:19 +02:00
|
|
|
codec->capabilities |= AV_CODEC_CAP_EXPERIMENTAL;
|
2015-03-26 02:10:16 +02:00
|
|
|
codec->pix_fmts = vp9_pix_fmts_def;
|
|
|
|
#if CONFIG_LIBVPX_VP9_ENCODER
|
|
|
|
if ( vpx_codec_version_major() > 1
|
|
|
|
|| (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {
|
|
|
|
#ifdef VPX_CODEC_CAP_HIGHBITDEPTH
|
|
|
|
vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
|
|
|
|
if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
|
|
|
|
codec->pix_fmts = vp9_pix_fmts_highbd;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
codec->pix_fmts = vp9_pix_fmts_highcol;
|
|
|
|
}
|
|
|
|
#endif
|
2013-11-16 01:28:30 +03:00
|
|
|
}
|
2015-06-21 21:48:44 +02:00
|
|
|
#if 0
|
2015-06-11 16:56:31 +02:00
|
|
|
enum AVPixelFormat ff_vpx_imgfmt_to_pixfmt(vpx_img_fmt_t img)
|
2013-11-16 01:28:30 +03:00
|
|
|
{
|
2015-06-11 16:56:31 +02:00
|
|
|
switch (img) {
|
|
|
|
case VPX_IMG_FMT_RGB24: return AV_PIX_FMT_RGB24;
|
|
|
|
case VPX_IMG_FMT_RGB565: return AV_PIX_FMT_RGB565BE;
|
|
|
|
case VPX_IMG_FMT_RGB555: return AV_PIX_FMT_RGB555BE;
|
|
|
|
case VPX_IMG_FMT_UYVY: return AV_PIX_FMT_UYVY422;
|
|
|
|
case VPX_IMG_FMT_YUY2: return AV_PIX_FMT_YUYV422;
|
|
|
|
case VPX_IMG_FMT_YVYU: return AV_PIX_FMT_YVYU422;
|
|
|
|
case VPX_IMG_FMT_BGR24: return AV_PIX_FMT_BGR24;
|
|
|
|
case VPX_IMG_FMT_ARGB: return AV_PIX_FMT_ARGB;
|
|
|
|
case VPX_IMG_FMT_ARGB_LE: return AV_PIX_FMT_BGRA;
|
|
|
|
case VPX_IMG_FMT_RGB565_LE: return AV_PIX_FMT_RGB565LE;
|
|
|
|
case VPX_IMG_FMT_RGB555_LE: return AV_PIX_FMT_RGB555LE;
|
|
|
|
case VPX_IMG_FMT_I420: return AV_PIX_FMT_YUV420P;
|
|
|
|
case VPX_IMG_FMT_I422: return AV_PIX_FMT_YUV422P;
|
|
|
|
case VPX_IMG_FMT_I444: return AV_PIX_FMT_YUV444P;
|
|
|
|
case VPX_IMG_FMT_444A: return AV_PIX_FMT_YUVA444P;
|
2015-06-24 08:39:40 +02:00
|
|
|
#if VPX_IMAGE_ABI_VERSION >= 3
|
2015-06-11 16:56:31 +02:00
|
|
|
case VPX_IMG_FMT_I440: return AV_PIX_FMT_YUV440P;
|
|
|
|
case VPX_IMG_FMT_I42016: return AV_PIX_FMT_YUV420P16BE;
|
|
|
|
case VPX_IMG_FMT_I42216: return AV_PIX_FMT_YUV422P16BE;
|
|
|
|
case VPX_IMG_FMT_I44416: return AV_PIX_FMT_YUV444P16BE;
|
|
|
|
#endif
|
|
|
|
default: return AV_PIX_FMT_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vpx_img_fmt_t ff_vpx_pixfmt_to_imgfmt(enum AVPixelFormat pix)
|
|
|
|
{
|
|
|
|
switch (pix) {
|
|
|
|
case AV_PIX_FMT_RGB24: return VPX_IMG_FMT_RGB24;
|
|
|
|
case AV_PIX_FMT_RGB565BE: return VPX_IMG_FMT_RGB565;
|
|
|
|
case AV_PIX_FMT_RGB555BE: return VPX_IMG_FMT_RGB555;
|
|
|
|
case AV_PIX_FMT_UYVY422: return VPX_IMG_FMT_UYVY;
|
|
|
|
case AV_PIX_FMT_YUYV422: return VPX_IMG_FMT_YUY2;
|
|
|
|
case AV_PIX_FMT_YVYU422: return VPX_IMG_FMT_YVYU;
|
|
|
|
case AV_PIX_FMT_BGR24: return VPX_IMG_FMT_BGR24;
|
|
|
|
case AV_PIX_FMT_ARGB: return VPX_IMG_FMT_ARGB;
|
|
|
|
case AV_PIX_FMT_BGRA: return VPX_IMG_FMT_ARGB_LE;
|
|
|
|
case AV_PIX_FMT_RGB565LE: return VPX_IMG_FMT_RGB565_LE;
|
|
|
|
case AV_PIX_FMT_RGB555LE: return VPX_IMG_FMT_RGB555_LE;
|
|
|
|
case AV_PIX_FMT_YUV420P: return VPX_IMG_FMT_I420;
|
|
|
|
case AV_PIX_FMT_YUV422P: return VPX_IMG_FMT_I422;
|
|
|
|
case AV_PIX_FMT_YUV444P: return VPX_IMG_FMT_I444;
|
|
|
|
case AV_PIX_FMT_YUVA444P: return VPX_IMG_FMT_444A;
|
2015-06-24 08:39:40 +02:00
|
|
|
#if VPX_IMAGE_ABI_VERSION >= 3
|
2015-06-11 16:56:31 +02:00
|
|
|
case AV_PIX_FMT_YUV440P: return VPX_IMG_FMT_I440;
|
|
|
|
case AV_PIX_FMT_YUV420P16BE: return VPX_IMG_FMT_I42016;
|
|
|
|
case AV_PIX_FMT_YUV422P16BE: return VPX_IMG_FMT_I42216;
|
|
|
|
case AV_PIX_FMT_YUV444P16BE: return VPX_IMG_FMT_I44416;
|
|
|
|
#endif
|
|
|
|
default: return VPX_IMG_FMT_NONE;
|
2013-11-16 01:28:30 +03:00
|
|
|
}
|
|
|
|
}
|
2015-06-21 21:48:44 +02:00
|
|
|
#endif
|