Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/libx265.c')
-rw-r--r--libavcodec/libx265.c66
1 files changed, 50 insertions, 16 deletions
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index f5d3d0f3c0..d25be70ffd 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -3,20 +3,20 @@
*
* Copyright (c) 2013-2014 Derek Buitenhuis
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* 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
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -82,14 +82,6 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
if (!ctx->api)
ctx->api = x265_api_get(0);
- if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL &&
- !av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_w) {
- av_log(avctx, AV_LOG_ERROR,
- "4:2:2 and 4:4:4 support is not fully defined for HEVC yet. "
- "Set -strict experimental to encode anyway.\n");
- return AVERROR(ENOSYS);
- }
-
ctx->params = ctx->api->param_alloc();
if (!ctx->params) {
av_log(avctx, AV_LOG_ERROR, "Could not allocate x265 param structure.\n");
@@ -154,16 +146,34 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV420P10:
+ case AV_PIX_FMT_YUV420P12:
ctx->params->internalCsp = X265_CSP_I420;
break;
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV422P10:
+ case AV_PIX_FMT_YUV422P12:
ctx->params->internalCsp = X265_CSP_I422;
break;
+ case AV_PIX_FMT_GBRP:
+ case AV_PIX_FMT_GBRP10:
+ case AV_PIX_FMT_GBRP12:
+ ctx->params->vui.matrixCoeffs = AVCOL_SPC_RGB;
+ ctx->params->vui.bEnableVideoSignalTypePresentFlag = 1;
+ ctx->params->vui.bEnableColorDescriptionPresentFlag = 1;
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV444P10:
+ case AV_PIX_FMT_YUV444P12:
ctx->params->internalCsp = X265_CSP_I444;
break;
+ case AV_PIX_FMT_GRAY8:
+ if (ctx->api->api_build_number < 85) {
+ av_log(avctx, AV_LOG_ERROR,
+ "libx265 version is %d, must be at least 85 for gray encoding.\n",
+ ctx->api->api_build_number);
+ return AVERROR_INVALIDDATA;
+ }
+ ctx->params->internalCsp = X265_CSP_I400;
+ break;
}
if (ctx->crf >= 0) {
@@ -272,7 +282,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal,
pic ? &x265pic : NULL, &x265pic_out);
if (ret < 0)
- return AVERROR_UNKNOWN;
+ return AVERROR_EXTERNAL;
if (!nnal)
return 0;
@@ -323,6 +333,21 @@ static const enum AVPixelFormat x265_csp_eight[] = {
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUV422P,
AV_PIX_FMT_YUV444P,
+ AV_PIX_FMT_GBRP,
+ AV_PIX_FMT_GRAY8,
+ AV_PIX_FMT_NONE
+};
+
+static const enum AVPixelFormat x265_csp_ten[] = {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_YUV422P,
+ AV_PIX_FMT_YUV444P,
+ AV_PIX_FMT_GBRP,
+ AV_PIX_FMT_YUV420P10,
+ AV_PIX_FMT_YUV422P10,
+ AV_PIX_FMT_YUV444P10,
+ AV_PIX_FMT_GBRP10,
+ AV_PIX_FMT_GRAY8,
AV_PIX_FMT_NONE
};
@@ -330,18 +355,27 @@ static const enum AVPixelFormat x265_csp_twelve[] = {
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUV422P,
AV_PIX_FMT_YUV444P,
+ AV_PIX_FMT_GBRP,
AV_PIX_FMT_YUV420P10,
AV_PIX_FMT_YUV422P10,
AV_PIX_FMT_YUV444P10,
+ AV_PIX_FMT_GBRP10,
+ AV_PIX_FMT_YUV420P12,
+ AV_PIX_FMT_YUV422P12,
+ AV_PIX_FMT_YUV444P12,
+ AV_PIX_FMT_GBRP12,
+ AV_PIX_FMT_GRAY8,
AV_PIX_FMT_NONE
};
static av_cold void libx265_encode_init_csp(AVCodec *codec)
{
- if (x265_max_bit_depth == 8)
- codec->pix_fmts = x265_csp_eight;
- else if (x265_max_bit_depth == 12)
+ if (x265_api_get(12))
codec->pix_fmts = x265_csp_twelve;
+ else if (x265_api_get(10))
+ codec->pix_fmts = x265_csp_ten;
+ else if (x265_api_get(8))
+ codec->pix_fmts = x265_csp_eight;
}
#define OFFSET(x) offsetof(libx265Context, x)