]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'cc06f7bd10c236539b4f6f87b795c459dd873770'
authorJames Almer <jamrial@gmail.com>
Fri, 13 Apr 2018 23:41:00 +0000 (20:41 -0300)
committerJames Almer <jamrial@gmail.com>
Fri, 13 Apr 2018 23:41:00 +0000 (20:41 -0300)
* commit 'cc06f7bd10c236539b4f6f87b795c459dd873770':
  libx265: Support tiny video sizes

Merged-by: James Almer <jamrial@gmail.com>
1  2 
libavcodec/libx265.c

index 3c97800ccb5a73d58efa0d98b63be9a02d28981d,8f1d60b4e5ba7b8ac1ea2cb35062cfa19cf18ed5..c208c0f2d31c3a77d25220bdae5cb9c6da4329d8
@@@ -115,11 -122,22 +115,22 @@@ static av_cold int libx265_encode_init(
      ctx->params->sourceHeight    = avctx->height;
      ctx->params->bEnablePsnr     = !!(avctx->flags & AV_CODEC_FLAG_PSNR);
  
 -    if ((avctx->color_primaries <= AVCOL_PRI_BT2020 &&
+     /* Tune the CTU size based on input resolution. */
+     if (ctx->params->sourceWidth < 64 || ctx->params->sourceHeight < 64)
+         ctx->params->maxCUSize = 32;
+     if (ctx->params->sourceWidth < 32 || ctx->params->sourceHeight < 32)
+         ctx->params->maxCUSize = 16;
+     if (ctx->params->sourceWidth < 16 || ctx->params->sourceHeight < 16) {
+         av_log(avctx, AV_LOG_ERROR, "Image size is too small (%dx%d).\n",
+                ctx->params->sourceWidth, ctx->params->sourceHeight);
+         return AVERROR(EINVAL);
+     }
 +    if ((avctx->color_primaries <= AVCOL_PRI_SMPTE432 &&
           avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) ||
 -        (avctx->color_trc <= AVCOL_TRC_BT2020_12 &&
 +        (avctx->color_trc <= AVCOL_TRC_ARIB_STD_B67 &&
           avctx->color_trc != AVCOL_TRC_UNSPECIFIED) ||
 -        (avctx->colorspace <= AVCOL_SPC_BT2020_CL &&
 +        (avctx->colorspace <= AVCOL_SPC_ICTCP &&
           avctx->colorspace != AVCOL_SPC_UNSPECIFIED)) {
  
          ctx->params->vui.bEnableVideoSignalTypePresentFlag  = 1;