Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Mar 2019 00:34:14 +0000 (UTC)
From:      Jan Beich <jbeich@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r497230 - in head/multimedia/ffmpeg: . files
Message-ID:  <201903300034.x2U0YEmU077325@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jbeich
Date: Sat Mar 30 00:34:14 2019
New Revision: 497230
URL: https://svnweb.freebsd.org/changeset/ports/497230

Log:
  multimedia/ffmpeg: backport some aom/dav1d fixes

Modified:
  head/multimedia/ffmpeg/Makefile   (contents, props changed)
  head/multimedia/ffmpeg/files/patch-aom   (contents, props changed)
  head/multimedia/ffmpeg/files/patch-dav1d   (contents, props changed)

Modified: head/multimedia/ffmpeg/Makefile
==============================================================================
--- head/multimedia/ffmpeg/Makefile	Sat Mar 30 00:34:06 2019	(r497229)
+++ head/multimedia/ffmpeg/Makefile	Sat Mar 30 00:34:14 2019	(r497230)
@@ -3,6 +3,7 @@
 
 PORTNAME=	ffmpeg
 PORTVERSION=	4.1.2
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	multimedia audio ipv6 net
 MASTER_SITES=	https://ffmpeg.org/releases/

Modified: head/multimedia/ffmpeg/files/patch-aom
==============================================================================
--- head/multimedia/ffmpeg/files/patch-aom	Sat Mar 30 00:34:06 2019	(r497229)
+++ head/multimedia/ffmpeg/files/patch-aom	Sat Mar 30 00:34:14 2019	(r497230)
@@ -2,6 +2,9 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/b2
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/d12d4d4515
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/b87063c06d
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/2ddaaaf595
+https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3991a5a45
+https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/995889abbf
+https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0856c5da07
 
 --- doc/encoders.texi.orig	2018-11-05 23:22:25 UTC
 +++ doc/encoders.texi
@@ -126,25 +129,78 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/2d
  Kvazaar H.265/HEVC encoder.
 --- libavcodec/libaomenc.c.orig	2018-11-05 23:22:26 UTC
 +++ libavcodec/libaomenc.c
-@@ -79,6 +79,7 @@ typedef struct AOMEncoderContext {
+@@ -66,33 +66,69 @@ typedef struct AOMEncoderContext {
+     struct FrameListData *coded_frame_list;
+     int cpu_used;
+     int auto_alt_ref;
++    int arnr_max_frames;
++    int arnr_strength;
++    int aq_mode;
+     int lag_in_frames;
+     int error_resilient;
+     int crf;
+     int static_thresh;
+     int drop_threshold;
+-    int noise_sensitivity;
++    int denoise_noise_level;
++    int denoise_block_size;
+     uint64_t sse[4];
+     int have_sse; /**< true if we have pending sse[] */
+     uint64_t frame_number;
++    int rc_undershoot_pct;
++    int rc_overshoot_pct;
++    int minsection_pct;
++    int maxsection_pct;
++    int frame_parallel;
+     int tile_cols, tile_rows;
      int tile_cols_log2, tile_rows_log2;
      aom_superblock_size_t superblock_size;
      int uniform_tiles;
 +    int row_mt;
++    int enable_cdef;
++    int enable_global_motion;
++    int enable_intrabc;
  } AOMContext;
  
  static const char *const ctlidstr[] = {
-@@ -93,6 +94,9 @@ static const char *const ctlidstr[] = {
+     [AOME_SET_CPUUSED]          = "AOME_SET_CPUUSED",
+     [AOME_SET_CQ_LEVEL]         = "AOME_SET_CQ_LEVEL",
+     [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
++    [AOME_SET_ARNR_MAXFRAMES]   = "AOME_SET_ARNR_MAXFRAMES",
++    [AOME_SET_ARNR_STRENGTH]    = "AOME_SET_ARNR_STRENGTH",
+     [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
+     [AV1E_SET_COLOR_RANGE]      = "AV1E_SET_COLOR_RANGE",
+     [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
+     [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
+     [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
++    [AV1E_SET_AQ_MODE]          = "AV1E_SET_AQ_MODE",
++    [AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
      [AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
      [AV1E_SET_TILE_COLUMNS]     = "AV1E_SET_TILE_COLUMNS",
      [AV1E_SET_TILE_ROWS]        = "AV1E_SET_TILE_ROWS",
 +#ifdef AOM_CTRL_AV1E_SET_ROW_MT
 +    [AV1E_SET_ROW_MT]           = "AV1E_SET_ROW_MT",
 +#endif
++#ifdef AOM_CTRL_AV1E_SET_DENOISE_NOISE_LEVEL
++    [AV1E_SET_DENOISE_NOISE_LEVEL] =  "AV1E_SET_DENOISE_NOISE_LEVEL",
++#endif
++#ifdef AOM_CTRL_AV1E_SET_DENOISE_BLOCK_SIZE
++    [AV1E_SET_DENOISE_BLOCK_SIZE] =   "AV1E_SET_DENOISE_BLOCK_SIZE",
++#endif
++#ifdef AOM_CTRL_AV1E_SET_MAX_REFERENCE_FRAMES
++    [AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
++#endif
++#ifdef AOM_CTRL_AV1E_SET_ENABLE_GLOBAL_MOTION
++    [AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
++#endif
++#ifdef AOM_CTRL_AV1E_SET_ENABLE_INTRABC
++    [AV1E_SET_ENABLE_INTRABC]   = "AV1E_SET_ENABLE_INTRABC",
++#endif
++    [AV1E_SET_ENABLE_CDEF]      = "AV1E_SET_ENABLE_CDEF",
  };
  
  static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
-@@ -505,7 +509,8 @@ static av_cold int aom_init(AVCodecContext *avctx,
+@@ -505,7 +541,8 @@ static av_cold int aom_init(AVCodecContext *avctx,
      enccfg.g_h            = avctx->height;
      enccfg.g_timebase.num = avctx->time_base.num;
      enccfg.g_timebase.den = avctx->time_base.den;
@@ -154,23 +210,126 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/2d
  
      if (ctx->lag_in_frames >= 0)
          enccfg.g_lag_in_frames = ctx->lag_in_frames;
-@@ -650,6 +655,10 @@ static av_cold int aom_init(AVCodecContext *avctx,
+@@ -558,10 +595,14 @@ static av_cold int aom_init(AVCodecContext *avctx,
+ 
+     // 0-100 (0 => CBR, 100 => VBR)
+     enccfg.rc_2pass_vbr_bias_pct       = round(avctx->qcompress * 100);
+-    if (avctx->bit_rate)
++    if (ctx->minsection_pct >= 0)
++        enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
++    else if (avctx->bit_rate)
+         enccfg.rc_2pass_vbr_minsection_pct =
+             avctx->rc_min_rate * 100LL / avctx->bit_rate;
+-    if (avctx->rc_max_rate)
++    if (ctx->maxsection_pct >= 0)
++        enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
++    else if (avctx->rc_max_rate)
+         enccfg.rc_2pass_vbr_maxsection_pct =
+             avctx->rc_max_rate * 100LL / avctx->bit_rate;
+ 
+@@ -573,6 +614,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
+             avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
+     enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
+ 
++    if (ctx->rc_undershoot_pct >= 0)
++        enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
++    if (ctx->rc_overshoot_pct >= 0)
++        enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
++
+     // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
+     if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
+         enccfg.kf_min_dist = avctx->keyint_min;
+@@ -634,7 +680,12 @@ static av_cold int aom_init(AVCodecContext *avctx,
+     codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
+     if (ctx->auto_alt_ref >= 0)
+         codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
+-
++    if (ctx->arnr_max_frames >= 0)
++        codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES,   ctx->arnr_max_frames);
++    if (ctx->arnr_strength >= 0)
++        codecctl_int(avctx, AOME_SET_ARNR_STRENGTH,    ctx->arnr_strength);
++    if (ctx->enable_cdef >= 0)
++        codecctl_int(avctx, AV1E_SET_ENABLE_CDEF, ctx->enable_cdef);
+     codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
+     if (ctx->crf >= 0)
+         codecctl_int(avctx, AOME_SET_CQ_LEVEL,          ctx->crf);
+@@ -642,6 +693,10 @@ static av_cold int aom_init(AVCodecContext *avctx,
+     codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
+     codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
+     codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
++    if (ctx->aq_mode >= 0)
++        codecctl_int(avctx, AV1E_SET_AQ_MODE, ctx->aq_mode);
++    if (ctx->frame_parallel >= 0)
++        codecctl_int(avctx, AV1E_SET_FRAME_PARALLEL_DECODING, ctx->frame_parallel);
+     set_color_range(avctx);
+ 
+     codecctl_int(avctx, AV1E_SET_SUPERBLOCK_SIZE, ctx->superblock_size);
+@@ -650,6 +705,32 @@ static av_cold int aom_init(AVCodecContext *avctx,
          codecctl_int(avctx, AV1E_SET_TILE_ROWS,    ctx->tile_rows_log2);
      }
  
++#ifdef AOM_CTRL_AV1E_SET_DENOISE_NOISE_LEVEL
++    if (ctx->denoise_noise_level >= 0)
++        codecctl_int(avctx, AV1E_SET_DENOISE_NOISE_LEVEL, ctx->denoise_noise_level);
++#endif
++#ifdef AOM_CTRL_AV1E_SET_DENOISE_BLOCK_SIZE
++    if (ctx->denoise_block_size >= 0)
++        codecctl_int(avctx, AV1E_SET_DENOISE_BLOCK_SIZE, ctx->denoise_block_size);
++#endif
++#ifdef AOM_CTRL_AV1E_SET_ENABLE_GLOBAL_MOTION
++    if (ctx->enable_global_motion >= 0)
++        codecctl_int(avctx, AV1E_SET_ENABLE_GLOBAL_MOTION, ctx->enable_global_motion);
++#endif
++#ifdef AOM_CTRL_AV1E_SET_MAX_REFERENCE_FRAMES
++    if (avctx->refs >= 3) {
++        codecctl_int(avctx, AV1E_SET_MAX_REFERENCE_FRAMES, avctx->refs);
++    }
++#endif
 +#ifdef AOM_CTRL_AV1E_SET_ROW_MT
-+    codecctl_int(avctx, AV1E_SET_ROW_MT, ctx->row_mt);
++    if (ctx->row_mt >= 0)
++        codecctl_int(avctx, AV1E_SET_ROW_MT, ctx->row_mt);
 +#endif
++#ifdef AOM_CTRL_AV1E_SET_ENABLE_INTRABC
++    if (ctx->enable_intrabc >= 0)
++        codecctl_int(avctx, AV1E_SET_ENABLE_INTRABC, ctx->enable_intrabc);
++#endif
 +
      // provide dummy value to initialize wrapper, values will be updated each _encode()
      aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
                   (unsigned char*)1);
-@@ -984,10 +993,12 @@ static const AVOption options[] = {
+@@ -975,19 +1056,37 @@ static const AVOption options[] = {
+                          "frames (2-pass only)",                   OFFSET(auto_alt_ref),    AV_OPT_TYPE_INT, {.i64 = -1},      -1,      2,       VE},
+     { "lag-in-frames",   "Number of frames to look ahead at for "
+                          "alternate reference frame selection",    OFFSET(lag_in_frames),   AV_OPT_TYPE_INT, {.i64 = -1},      -1,      INT_MAX, VE},
++    { "arnr-max-frames", "altref noise reduction max frame count", OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1},      -1,      INT_MAX, VE},
++    { "arnr-strength",   "altref noise reduction filter strength", OFFSET(arnr_strength),   AV_OPT_TYPE_INT, {.i64 = -1},      -1,      6,       VE},
++    { "aq-mode",         "adaptive quantization mode",             OFFSET(aq_mode),         AV_OPT_TYPE_INT, {.i64 = -1},      -1,      4, VE, "aq_mode"},
++    { "none",            "Aq not used",         0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "aq_mode"},
++    { "variance",        "Variance based Aq",   0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "aq_mode"},
++    { "complexity",      "Complexity based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "aq_mode"},
++    { "cyclic",          "Cyclic Refresh Aq",   0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "aq_mode"},
+     { "error-resilience", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, VE, "er"},
+     { "default",         "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {.i64 = AOM_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, "er"},
+     { "crf",              "Select the quality for constant quality mode", offsetof(AOMContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE },
+     { "static-thresh",    "A change threshold on blocks below which they will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
+     { "drop-threshold",   "Frame drop threshold", offsetof(AOMContext, drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
+-    { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE},
++    { "denoise-noise-level", "Amount of noise to be removed", OFFSET(denoise_noise_level), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
++    { "denoise-block-size", "Denoise block size ", OFFSET(denoise_block_size), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE},
++    { "undershoot-pct",   "Datarate undershoot (min) target (%)", OFFSET(rc_undershoot_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE},
++    { "overshoot-pct",    "Datarate overshoot (max) target (%)", OFFSET(rc_overshoot_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1000, VE},
++    { "minsection-pct",   "GOP min bitrate (% of target)", OFFSET(minsection_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE},
++    { "maxsection-pct",   "GOP max bitrate (% of target)", OFFSET(maxsection_pct), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 5000, VE},
++    { "frame-parallel",   "Enable frame parallel decodability features", OFFSET(frame_parallel),  AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
      { "tiles",            "Tile columns x rows", OFFSET(tile_cols), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, VE },
      { "tile-columns",     "Log2 of number of tile columns to use", OFFSET(tile_cols_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
      { "tile-rows",        "Log2 of number of tile rows to use",    OFFSET(tile_rows_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
-+    { "row-mt",           "Enable row based multi-threading",      OFFSET(row_mt),         AV_OPT_TYPE_BOOL, {.i64 = 0},  0, 1, VE},
-     { NULL }
+-    { NULL }
++    { "row-mt",           "Enable row based multi-threading",      OFFSET(row_mt),         AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
++    { "enable-cdef",      "Enable CDEF filtering",                 OFFSET(enable_cdef),    AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
++    { "enable-global-motion",  "Enable global motion",             OFFSET(enable_global_motion), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
++    { "enable-intrabc",  "Enable intra block copy prediction mode", OFFSET(enable_intrabc), AV_OPT_TYPE_BOOL, {.i64 = -1},  0, 1, VE},
++    { NULL },
  };
  
  static const AVCodecDefault defaults[] = {

Modified: head/multimedia/ffmpeg/files/patch-dav1d
==============================================================================
--- head/multimedia/ffmpeg/files/patch-dav1d	Sat Mar 30 00:34:06 2019	(r497229)
+++ head/multimedia/ffmpeg/files/patch-dav1d	Sat Mar 30 00:34:14 2019	(r497230)
@@ -13,6 +13,8 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/28
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/36bb2cc200
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/38a4132132
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/f6803cfbd2
+https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/5cd60b6f2e
+https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/9e62e1a110
 
 --- configure.orig	2018-11-05 23:22:33 UTC
 +++ configure
@@ -83,7 +85,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/f6
  extern AVCodec ff_libfdk_aac_decoder;
 --- libavcodec/libdav1d.c.orig	2018-12-16 07:22:28 UTC
 +++ libavcodec/libdav1d.c
-@@ -0,0 +1,356 @@
+@@ -0,0 +1,346 @@
 +/*
 + * Copyright (c) 2018 Ronald S. Bultje <rsbultje gmail com>
 + * Copyright (c) 2018 James Almer <jamrial gmail com>
@@ -158,8 +160,10 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/f6
 +        av_buffer_pool_uninit(&dav1d->pool);
 +        // Use twice the amount of required padding bytes for aligned_ptr below.
 +        dav1d->pool = av_buffer_pool_init(ret + DAV1D_PICTURE_ALIGNMENT * 2, NULL);
-+        if (!dav1d->pool)
++        if (!dav1d->pool) {
++            dav1d->pool_size = 0;
 +            return AVERROR(ENOMEM);
++        }
 +        dav1d->pool_size = ret;
 +    }
 +    buf = av_buffer_pool_get(dav1d->pool);
@@ -233,18 +237,11 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/f6
 +    av_buffer_unref(&buf);
 +}
 +
-+static void libdav1d_frame_free(void *opaque, uint8_t *data) {
-+    Dav1dPicture *p = opaque;
-+
-+    dav1d_picture_unref(p);
-+    av_free(p);
-+}
-+
 +static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
 +{
 +    Libdav1dContext *dav1d = c->priv_data;
 +    Dav1dData *data = &dav1d->data;
-+    Dav1dPicture *p;
++    Dav1dPicture pic = { 0 }, *p = &pic;
 +    int res;
 +
 +    if (!data->sz) {
@@ -278,10 +275,6 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/f6
 +            return res;
 +    }
 +
-+    p = av_mallocz(sizeof(*p));
-+    if (!p)
-+        return AVERROR(ENOMEM);
-+
 +    res = dav1d_get_picture(dav1d->c, p);
 +    if (res < 0) {
 +        if (res == AVERROR(EINVAL))
@@ -289,17 +282,15 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/f6
 +        else if (res == AVERROR(EAGAIN) && c->internal->draining)
 +            res = AVERROR_EOF;
 +
-+        av_free(p);
 +        return res;
 +    }
 +
 +    av_assert0(p->data[0] != NULL);
 +
-+    frame->buf[0] = av_buffer_create(NULL, 0, libdav1d_frame_free,
-+                                     p, AV_BUFFER_FLAG_READONLY);
++    // This requires the custom allocator above
++    frame->buf[0] = av_buffer_ref(p->allocator_data);
 +    if (!frame->buf[0]) {
 +        dav1d_picture_unref(p);
-+        av_free(p);
 +        return AVERROR(ENOMEM);
 +    }
 +
@@ -394,6 +385,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/f6
 +
 +    res = 0;
 +fail:
++    dav1d_picture_unref(p);
 +    if (res < 0)
 +        av_frame_unref(frame);
 +    return res;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903300034.x2U0YEmU077325>