Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jan 2019 00:39:23 +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: r489841 - in head/multimedia/ffmpeg: . files
Message-ID:  <201901100039.x0A0dN2d098550@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jbeich
Date: Thu Jan 10 00:39:22 2019
New Revision: 489841
URL: https://svnweb.freebsd.org/changeset/ports/489841

Log:
  multimedia/ffmpeg: backport fixes for libaom/libdav1d

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

Modified: head/multimedia/ffmpeg/Makefile
==============================================================================
--- head/multimedia/ffmpeg/Makefile	Wed Jan  9 23:06:06 2019	(r489840)
+++ head/multimedia/ffmpeg/Makefile	Thu Jan 10 00:39:22 2019	(r489841)
@@ -3,7 +3,7 @@
 
 PORTNAME=	ffmpeg
 PORTVERSION=	4.1
-PORTREVISION=	3
+PORTREVISION=	4
 PORTEPOCH=	1
 CATEGORIES=	multimedia audio ipv6 net
 MASTER_SITES=	https://ffmpeg.org/releases/

Added: head/multimedia/ffmpeg/files/patch-aom
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/multimedia/ffmpeg/files/patch-aom	Thu Jan 10 00:39:22 2019	(r489841)
@@ -0,0 +1,180 @@
+https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/b2ea757f68
+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
+
+--- doc/encoders.texi.orig	2018-11-05 23:22:25 UTC
++++ doc/encoders.texi
+@@ -1370,6 +1370,118 @@ makes it possible to store non-rgb pix_fmts.
+ 
+ @end table
+ 
++@section libaom-av1
++
++libaom AV1 encoder wrapper.
++
++Requires the presence of the libaom headers and library during
++configuration.  You need to explicitly configure the build with
++@code{--enable-libaom}.
++
++@subsection Options
++
++The wrapper supports the following standard libavcodec options:
++
++@table @option
++
++@item b
++Set bitrate target in bits/second.  By default this will use
++variable-bitrate mode.  If @option{maxrate} and @option{minrate} are
++also set to the same value then it will use constant-bitrate mode,
++otherwise if @option{crf} is set as well then it will use
++constrained-quality mode.
++
++@item g keyint_min
++Set key frame placement.  The GOP size sets the maximum distance between
++key frames; if zero the output stream will be intra-only.  The minimum
++distance is ignored unless it is the same as the GOP size, in which case
++key frames will always appear at a fixed interval.  Not set by default,
++so without this option the library has completely free choice about
++where to place key frames.
++
++@item qmin qmax
++Set minimum/maximum quantisation values.  Valid range is from 0 to 63
++(warning: this does not match the quantiser values actually used by AV1
++- divide by four to map real quantiser values to this range).  Defaults
++to min/max (no constraint).
++
++@item minrate maxrate bufsize rc_init_occupancy
++Set rate control buffering parameters.  Not used if not set - defaults
++to unconstrained variable bitrate.
++
++@item threads
++Set the number of threads to use while encoding.  This may require the
++@option{tiles} or @option{row-mt} options to also be set to actually
++use the specified number of threads fully. Defaults to the number of
++hardware threads supported by the host machine.
++
++@item profile
++Set the encoding profile.  Defaults to using the profile which matches
++the bit depth and chroma subsampling of the input.
++
++@end table
++
++The wrapper also has some specific options:
++
++@table @option
++
++@item cpu-used
++Set the quality/encoding speed tradeoff.  Valid range is from 0 to 8,
++higher numbers indicating greater speed and lower quality.  The default
++value is 1, which will be slow and high quality.
++
++@item auto-alt-ref
++Enable use of alternate reference frames.  Defaults to the internal
++default of the library.
++
++@item lag-in-frames
++Set the maximum number of frames which the encoder may keep in flight
++at any one time for lookahead purposes.  Defaults to the internal
++default of the library.
++
++@item error-resilience
++Enable error resilience features:
++@table @option
++@item default
++Improve resilience against losses of whole frames.
++@end table
++Not enabled by default.
++
++@item crf
++Set the quality/size tradeoff for constant-quality (no bitrate target)
++and constrained-quality (with maximum bitrate target) modes. Valid
++range is 0 to 63, higher numbers indicating lower quality and smaller
++output size.  Only used if set; by default only the bitrate target is
++used.
++
++@item static-thresh
++Set a change threshold on blocks below which they will be skipped by
++the encoder.  Defined in arbitrary units as a nonnegative integer,
++defaulting to zero (no blocks are skipped).
++
++@item drop-threshold
++Set a threshold for dropping frames when close to rate control bounds.
++Defined as a percentage of the target buffer - when the rate control
++buffer falls below this percentage, frames will be dropped until it
++has refilled above the threshold.  Defaults to zero (no frames are
++dropped).
++
++@item tiles
++Set the number of tiles to encode the input video with, as colums x
++rows.  Larger numbers allow greater parallelism in both encoding and
++decoding, but may decrease coding efficiency.  Defaults to the minimum
++number of tiles required by the size of the input video (this is 1x1
++(that is, a single tile) for sizes up to and including 4K).
++
++@item tile-columns tile-rows
++Set the number of tiles as log2 of the number of tile rows and columns.
++Provided for compatibility with libvpx/VP9.
++
++@item row-mt (Requires libaom >= 1.0.0-759-g90a15f4f2)
++Enable row based multi-threading. Disabled by default.
++
++@end table
++
+ @section libkvazaar
+ 
+ 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 {
+     int tile_cols_log2, tile_rows_log2;
+     aom_superblock_size_t superblock_size;
+     int uniform_tiles;
++    int row_mt;
+ } AOMContext;
+ 
+ static const char *const ctlidstr[] = {
+@@ -93,6 +94,9 @@ static const char *const ctlidstr[] = {
+     [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
+ };
+ 
+ static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
+@@ -505,7 +509,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;
+-    enccfg.g_threads      = avctx->thread_count ? avctx->thread_count : av_cpu_count();
++    enccfg.g_threads      =
++        FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 64);
+ 
+     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,
+         codecctl_int(avctx, AV1E_SET_TILE_ROWS,    ctx->tile_rows_log2);
+     }
+ 
++#ifdef AOM_CTRL_AV1E_SET_ROW_MT
++    codecctl_int(avctx, AV1E_SET_ROW_MT, ctx->row_mt);
++#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[] = {
+     { "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 }
+ };
+ 
+ static const AVCodecDefault defaults[] = {
++    { "b",          "256*1000" },
+     { "qmin",             "-1" },
+     { "qmax",             "-1" },
+     { "g",                "-1" },

Modified: head/multimedia/ffmpeg/files/patch-dav1d
==============================================================================
--- head/multimedia/ffmpeg/files/patch-dav1d	Wed Jan  9 23:06:06 2019	(r489840)
+++ head/multimedia/ffmpeg/files/patch-dav1d	Thu Jan 10 00:39:22 2019	(r489841)
@@ -6,6 +6,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/3c
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0fca2f60da
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e695b0beba
 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0e833f615b
+https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/10931a0661
 
 --- configure.orig	2018-11-05 23:22:33 UTC
 +++ configure
@@ -76,7 +77,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0e
  extern AVCodec ff_libfdk_aac_decoder;
 --- libavcodec/libdav1d.c.orig	2018-12-16 07:22:28 UTC
 +++ libavcodec/libdav1d.c
-@@ -0,0 +1,246 @@
+@@ -0,0 +1,251 @@
 +/*
 + * Copyright (c) 2018 Ronald S. Bultje <rsbultje gmail com>
 + * Copyright (c) 2018 James Almer <jamrial gmail com>
@@ -151,11 +152,10 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0e
 +}
 +
 +static void libdav1d_frame_free(void *opaque, uint8_t *data) {
-+    Dav1dPicture p = { 0 };
++    Dav1dPicture *p = opaque;
 +
-+    p.ref = opaque;
-+    p.data[0] = (void *) 0x1; // this has to be non-NULL
-+    dav1d_picture_unref(&p);
++    dav1d_picture_unref(p);
++    av_free(p);
 +}
 +
 +static const enum AVPixelFormat pix_fmt[][3] = {
@@ -169,7 +169,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0e
 +{
 +    Libdav1dContext *dav1d = c->priv_data;
 +    Dav1dData *data = &dav1d->data;
-+    Dav1dPicture p = { 0 };
++    Dav1dPicture *p;
 +    int res;
 +
 +    if (!data->sz) {
@@ -203,43 +203,49 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0e
 +            return res;
 +    }
 +
-+    res = dav1d_get_picture(dav1d->c, &p);
++    p = av_mallocz(sizeof(*p));
++    if (!p)
++        return AVERROR(ENOMEM);
++
++    res = dav1d_get_picture(dav1d->c, p);
 +    if (res < 0) {
 +        if (res == -EINVAL)
 +            res = AVERROR_INVALIDDATA;
 +        else if (res == -EAGAIN && c->internal->draining)
 +            res = AVERROR_EOF;
 +
++        av_free(p);
 +        return res;
 +    }
 +
-+    av_assert0(p.data[0] != NULL);
++    av_assert0(p->data[0] != NULL);
 +
 +    frame->buf[0] = av_buffer_create(NULL, 0, libdav1d_frame_free,
-+                                     p.ref, AV_BUFFER_FLAG_READONLY);
++                                     p, AV_BUFFER_FLAG_READONLY);
 +    if (!frame->buf[0]) {
-+        dav1d_picture_unref(&p);
++        dav1d_picture_unref(p);
++        av_free(p);
 +        return AVERROR(ENOMEM);
 +    }
 +
-+    frame->data[0] = p.data[0];
-+    frame->data[1] = p.data[1];
-+    frame->data[2] = p.data[2];
-+    frame->linesize[0] = p.stride[0];
-+    frame->linesize[1] = p.stride[1];
-+    frame->linesize[2] = p.stride[1];
++    frame->data[0] = p->data[0];
++    frame->data[1] = p->data[1];
++    frame->data[2] = p->data[2];
++    frame->linesize[0] = p->stride[0];
++    frame->linesize[1] = p->stride[1];
++    frame->linesize[2] = p->stride[1];
 +
-+    c->profile = p.seq_hdr->profile;
-+    frame->format = c->pix_fmt = pix_fmt[p.p.layout][p.seq_hdr->hbd];
-+    frame->width = p.p.w;
-+    frame->height = p.p.h;
-+    if (c->width != p.p.w || c->height != p.p.h) {
-+        res = ff_set_dimensions(c, p.p.w, p.p.h);
++    c->profile = p->seq_hdr->profile;
++    frame->format = c->pix_fmt = pix_fmt[p->p.layout][p->seq_hdr->hbd];
++    frame->width = p->p.w;
++    frame->height = p->p.h;
++    if (c->width != p->p.w || c->height != p->p.h) {
++        res = ff_set_dimensions(c, p->p.w, p->p.h);
 +        if (res < 0)
 +            return res;
 +    }
 +
-+    switch (p.seq_hdr->chr) {
++    switch (p->seq_hdr->chr) {
 +    case DAV1D_CHR_VERTICAL:
 +        frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_LEFT;
 +        break;
@@ -247,25 +253,25 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/0e
 +        frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
 +        break;
 +    }
-+    frame->colorspace = c->colorspace = (enum AVColorSpace) p.seq_hdr->mtrx;
-+    frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p.seq_hdr->pri;
-+    frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p.seq_hdr->trc;
-+    frame->color_range = c->color_range = p.seq_hdr->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
++    frame->colorspace = c->colorspace = (enum AVColorSpace) p->seq_hdr->mtrx;
++    frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p->seq_hdr->pri;
++    frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p->seq_hdr->trc;
++    frame->color_range = c->color_range = p->seq_hdr->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
 +
 +    // match timestamps and packet size
-+    frame->pts = frame->best_effort_timestamp = p.m.timestamp;
++    frame->pts = frame->best_effort_timestamp = p->m.timestamp;
 +#if FF_API_PKT_PTS
 +FF_DISABLE_DEPRECATION_WARNINGS
-+    frame->pkt_pts = p.m.timestamp;
++    frame->pkt_pts = p->m.timestamp;
 +FF_ENABLE_DEPRECATION_WARNINGS
 +#endif
-+    frame->pkt_dts = p.m.timestamp;
-+    frame->pkt_pos = p.m.offset;
-+    frame->pkt_size = p.m.size;
-+    frame->pkt_duration = p.m.duration;
-+    frame->key_frame = p.frame_hdr->frame_type == DAV1D_FRAME_TYPE_KEY;
++    frame->pkt_dts = p->m.timestamp;
++    frame->pkt_pos = p->m.offset;
++    frame->pkt_size = p->m.size;
++    frame->pkt_duration = p->m.duration;
++    frame->key_frame = p->frame_hdr->frame_type == DAV1D_FRAME_TYPE_KEY;
 +
-+    switch (p.frame_hdr->frame_type) {
++    switch (p->frame_hdr->frame_type) {
 +    case DAV1D_FRAME_TYPE_KEY:
 +    case DAV1D_FRAME_TYPE_INTRA:
 +        frame->pict_type = AV_PICTURE_TYPE_I;



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