Re: [FFmpeg-devel] [PATCH] doc/ffmpeg - rewrite Stream Selection chapter

2018-05-26 Thread Gyan Doshi



On 27-05-2018 02:37 AM, Lou Logan wrote:

On Sat, May 26, 2018, at 12:33 AM, Gyan Doshi wrote:


Part of the ugliness is due to how the code fragments are rendered: with
vertical margins, creating uneven line spacing. Do you mind if I reduce
or eliminate those margins?


Which file sets those margins? The ugly justified text in the HTML doc that I was 
referring to before appears to be due to "body {text-align: justify;}" in 
style.min.css. I don't see any value to that at the moment, but maybe I'll take a closer 
look some other time and we can save this discussion for later since it should be dealt 
with separately from this patch.


v2 attached.

I was talking about the vertical margins appled to the 'code' element.


Regards,
Gyan
From 60ed76348e70f1b0a25eadde8d886d47be3fca69 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Thu, 24 May 2018 19:11:00 +0530
Subject: [PATCH v2] doc/ffmpeg - rewrite Stream Selection chapter

Flesh out with details and examples to show quirks and limitations.
---
 doc/ffmpeg.texi | 187 +---
 1 file changed, 177 insertions(+), 10 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 88dbdeb95a..803490ce7b 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -216,16 +216,183 @@ filters is obviously also impossible, since filters work 
on uncompressed data.
 @chapter Stream selection
 @c man begin STREAM SELECTION
 
-By default, @command{ffmpeg} includes only one stream of each type (video, 
audio, subtitle)
-present in the input files and adds them to each output file.  It picks the
-"best" of each based upon the following criteria: for video, it is the stream
-with the highest resolution, for audio, it is the stream with the most 
channels, for
-subtitles, it is the first subtitle stream. In the case where several streams 
of
-the same type rate equally, the stream with the lowest index is chosen.
-
-You can disable some of those defaults by using the @code{-vn/-an/-sn/-dn} 
options. For
-full manual control, use the @code{-map} option, which disables the defaults 
just
-described.
+@command{ffmpeg} provides the @code{-map} option for manual control of stream 
selection in each
+output file. Users can skip @code{-map} and let ffmpeg perform automatic 
stream selection as
+described below.
+
+@section Description
+@subsection Automatic stream selection
+
+In the absence of any map options for a particular output file, ffmpeg 
inspects the output
+format to check which type of streams can be included in it, viz. video, audio 
and/or
+subtitles. For each acceptable stream type, ffmpeg will pick one stream, when 
available,
+from among all the inputs.
+
+It will select that stream based upon the following criteria:
+@*
+@*for video, it is the stream with the highest resolution,
+@*for audio, it is the stream with the most channels,
+@*for subtitles, it is the first subtitle stream found but there's a caveat.
+The output format's default subtitle encoder may be text-based or image-based, 
and only a
+subtitle stream of the same type can be chosen.
+
+Data or attachment streams are not automatically selected and can only be 
included
+using @code{-map}.
+
+In the case where several streams of the same type rate equally, the stream 
with the lowest
+index is chosen.
+
+The @code{-vn}, @code{-an}, @code{-sn} options can be used to skip automatic 
stream selection
+for video, audio, and subtitle streams respectively.
+
+@subsection Manual stream selection
+
+When @code{-map} is used, only user-mapped streams are included in that output 
file,
+with one possible exception for filtergraph outputs described below.
+
+@subsection Complex filtergraphs
+
+If there are any complex filtergraph output streams with unlabeled pads, they 
will be added
+to the first output file. This will lead to a fatal error if the stream type 
is not supported
+by the output format. In the absence of the map option, the inclusion of these 
streams leads
+to the automatic stream selection of their types being skipped. If map options 
are present,
+these filtergraph streams are included in addition to the mapped streams.
+
+Complex filtergraph output streams with labeled pads must be mapped once and 
exactly once.
+
+@subsection Stream handling
+
+Stream handling is independent of stream selection, with an exception for 
subtitles described
+below. Stream handling is set via the @code{-codec} option addressed to 
streams within a
+specific @emph{output} file. In particular, codec options are applied by 
ffmpeg after the
+stream selection process and thus do not influence the latter. An exception 
exists for subtitles.
+If a subtitle encoder is specified for an output file, the first subtitle 
stream found, of type
+text or image, will be included. ffmpeg does not validate if the specified 
encoder can convert
+the selected stream or if the converted stream is acceptable within the output 
format. This
+applies generally as 

[FFmpeg-devel] [PATCH v2 1/2] cmdutils: print missing caps in print_codec().

2018-05-26 Thread Jun Zhao
print full caps type in print_codec().

Signed-off-by: Jun Zhao 
---
 fftools/cmdutils.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 8ffc9d2..70234b8 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1414,6 +1414,16 @@ static void print_codec(const AVCodec *c)
AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_AUTO_THREADS))
 printf("threads ");
+if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
+printf("avoidprobe ");
+if (c->capabilities & AV_CODEC_CAP_INTRA_ONLY)
+printf("intraonly ");
+if (c->capabilities & AV_CODEC_CAP_LOSSLESS)
+printf("lossless ");
+if (c->capabilities & AV_CODEC_CAP_HARDWARE)
+printf("hardware ");
+if (c->capabilities & AV_CODEC_CAP_HYBRID)
+printf("hybrid ");
 if (!c->capabilities)
 printf("none");
 printf("\n");
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 0/2] dump more codec information

2018-05-26 Thread Jun Zhao
V2: - fix the alignment as Reto Kromer's comment
- improve the characterization as Mark's comments

Jun Zhao (2):
  cmdutils: print missing caps in print_codec().
  cmdutils: dump supported hardware devices in print_codec()

 fftools/cmdutils.c | 21 +
 1 file changed, 21 insertions(+)

-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/2] cmdutils: dump supported hardware devices in print_codec()

2018-05-26 Thread Jun Zhao
dump the supported hardware devices for codec when use the command
like ./ffmpeg -h decoder=h264.

Signed-off-by: Jun Zhao 
---
 fftools/cmdutils.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 70234b8..844f433 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1444,6 +1444,17 @@ static void print_codec(const AVCodec *c)
 printf("\n");
 }
 
+if (avcodec_get_hw_config(c, 0)) {
+printf("Supported hardware devices: ");
+for (int i = 0;; i++) {
+const AVCodecHWConfig *config = avcodec_get_hw_config(c, i);
+if (!config)
+break;
+printf("%s ", av_hwdevice_get_type_name(config->device_type));
+}
+printf("\n");
+}
+
 if (c->supported_framerates) {
 const AVRational *fps = c->supported_framerates;
 
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] v4l2_m2m: Mark V4L2 M2M decoders as unsuitable for probing

2018-05-26 Thread Michael Niedermayer
On Sat, May 26, 2018 at 05:16:10PM +0100, Mark Thompson wrote:
> ---
>  libavcodec/v4l2_m2m_dec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

LGTM


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] doc/ffmpeg - rewrite Stream Selection chapter

2018-05-26 Thread Lou Logan
On Sat, May 26, 2018, at 12:33 AM, Gyan Doshi wrote:
>
> Part of the ugliness is due to how the code fragments are rendered: with 
> vertical margins, creating uneven line spacing. Do you mind if I reduce 
> or eliminate those margins?

Which file sets those margins? The ugly justified text in the HTML doc that I 
was referring to before appears to be due to "body {text-align: justify;}" in 
style.min.css. I don't see any value to that at the moment, but maybe I'll take 
a closer look some other time and we can save this discussion for later since 
it should be dealt with separately from this patch.

So disregarding the "ugly rendering" for now if you provide an updated patch 
with your local changes I'll take another look on Monday or Tuesday.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter: add anlmeans audio filter

2018-05-26 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile  |   1 +
 libavfilter/af_anlmeans.c | 282 ++
 libavfilter/allfilters.c  |   1 +
 3 files changed, 284 insertions(+)
 create mode 100644 libavfilter/af_anlmeans.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index c68ef05fdc..ac7e205b75 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -54,6 +54,7 @@ OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o
 OBJS-$(CONFIG_AMETADATA_FILTER)  += f_metadata.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
 OBJS-$(CONFIG_ANEQUALIZER_FILTER)+= af_anequalizer.o
+OBJS-$(CONFIG_ANLMEANS_FILTER)   += af_anlmeans.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
 OBJS-$(CONFIG_APAD_FILTER)   += af_apad.o
 OBJS-$(CONFIG_APERMS_FILTER) += f_perms.o
diff --git a/libavfilter/af_anlmeans.c b/libavfilter/af_anlmeans.c
new file mode 100644
index 00..01c4ca3239
--- /dev/null
+++ b/libavfilter/af_anlmeans.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * 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.
+ *
+ * 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/avassert.h"
+#include "libavutil/audio_fifo.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "formats.h"
+
+#define SQR(x) ((x) * (x))
+
+typedef struct AudioNLMeansContext {
+const AVClass *class;
+
+double g;
+double B;
+double h;
+double a;
+double m;
+int n;
+int K;
+int S;
+
+int N;
+int hop_size;
+
+AVFrame *in;
+
+double *kernel;
+
+int64_t pts;
+uint64_t nb_samples;
+int samples_left;
+
+AVAudioFifo *fifo;
+} AudioNLMeansContext;
+
+#define OFFSET(x) offsetof(AudioNLMeansContext, x)
+#define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption anlmeans_options[] = {
+{ "n", "set number of patches", OFFSET(n), AV_OPT_TYPE_INT,{.i64=1},   
 1, 4, AF },
+{ "K", "set patch radius",  OFFSET(K), AV_OPT_TYPE_INT,{.i64=32},  
 0,  4096, AF },
+{ "S", "set research radius",   OFFSET(S), AV_OPT_TYPE_INT,{.i64=64},  
 1,  4096, AF },
+{ "h", "set strength",  OFFSET(h), AV_OPT_TYPE_DOUBLE, {.dbl=1},   
 1,   FLT_MAX, AF },
+{ "m", "set max allowed diff",  OFFSET(m), AV_OPT_TYPE_DOUBLE, {.dbl=0.1}, 
 0, 2, AF },
+{ "a", "set denoising amount",  OFFSET(a), AV_OPT_TYPE_DOUBLE, {.dbl=1},   
 1,   FLT_MAX, AF },
+{ "B", "set smooth factor", OFFSET(B), AV_OPT_TYPE_DOUBLE, {.dbl=1},   
 1,   FLT_MAX, AF },
+{ "g", "set output gain",   OFFSET(g), AV_OPT_TYPE_DOUBLE, {.dbl=1},   
 0,10, AF },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(anlmeans);
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterFormats *formats = NULL;
+AVFilterChannelLayouts *layouts = NULL;
+static const enum AVSampleFormat sample_fmts[] = {
+AV_SAMPLE_FMT_FLTP,
+AV_SAMPLE_FMT_NONE
+};
+int ret;
+
+formats = ff_make_format_list(sample_fmts);
+if (!formats)
+return AVERROR(ENOMEM);
+ret = ff_set_common_formats(ctx, formats);
+if (ret < 0)
+return ret;
+
+layouts = ff_all_channel_counts();
+if (!layouts)
+return AVERROR(ENOMEM);
+
+ret = ff_set_common_channel_layouts(ctx, layouts);
+if (ret < 0)
+return ret;
+
+formats = ff_all_samplerates();
+return ff_set_common_samplerates(ctx, formats);
+}
+
+static void compute_kernel(double *kernel, int K, double B2)
+{
+int k;
+
+for (k = 0; k <= 2 * K; k++) {
+double kk = k - K;
+
+kernel[k] = exp(-(kk * kk) / B2);
+}
+}
+
+static int config_output(AVFilterLink *outlink)
+{
+AVFilterContext *ctx = outlink->src;
+AudioNLMeansContext *s = ctx->priv;
+
+s->m = SQR(s->m * 65536.);
+s->pts = AV_NOPTS_VALUE;
+s->N = s->n * s->K * 2 + 1 + (s->K + s->S) * 2;
+s->hop_size = s->n * s->K * 2 + 1;
+
+av_frame_free(>in);
+s->in = ff_get_audio_buffer(outlink, s->N);
+if (!s->in)
+return AVERROR(ENOMEM);
+
+s->fifo = 

Re: [FFmpeg-devel] [PATCH] libavformat: add mbedTLS based TLS

2018-05-26 Thread Reino Wijnsma
On 23-5-2018 2:11, Reino Wijnsma  wrote:
> On 22-4-2018 14:47, Thomas Volkert  wrote:
>> +enabled mbedtls   && { check_pkg_config mbedtls mbedtls 
>> mbedtls/x509_crt.h mbedtls_x509_crt_init ||
>> +   check_pkg_config mbedtls mbedtls 
>> mbedtls/ssl.h mbedtls_ssl_init ||
>> +   check_lib mbedtls mbedtls/ssl.h 
>> mbedtls_ssl_init -lmbedtls ||
>> +   die "ERROR: mbedTLS not found"; }
> Now that James Almer has pushed this patch I decided to have a look as well. 
> I wanted to see if mbedtls would work for me too.
> I haven't made a FFmpeg build yet to test, because the excerpt above (in 
> 'configure') doesn't look right and configuring FFmpeg returns lots of 
> undefined references.
>
> First of all, there's no pkg-config file at all. Almost 3 years ago someone 
> requested it (https://github.com/ARMmbed/mbedtls/issues/228), but as far as I 
> can see it hasn't been implemented yet. So, I really don't understand why you 
> added the 2 check_pkg_config lines.
> Secondly, the check_lib line also needs -lmbedx509 and -lmbedcrypto!
>
> -lmbedtls, the most important one obviously, prevents a "undefined reference 
> to `mbedtls_ssl_init'", but...
> -lmbedx509 is also needed, because otherwise you'd get "undefined reference 
> to `mbedtls_x509_crt_init'" and several "undefined reference to 
> `mbedtls_x509_crt_[...]'".
> -lmbedcrypto is also needed, because otherwise you'd get LOTS of "undefined 
> reference to `mbedtls_[...]'"; from "undefined reference to 
> `mbedtls_sha256_init'" to "undefined reference to `mbedtls_pem_init'"!
>
> The following patch works for me:
>
> diff --git a/configure b/configure
> index 09ff0c5..6014e03 100755
> --- a/configure
> +++ b/configure
> @@ -6111,9 +6111,7 @@ enabled libzvbi   && require_pkg_config libzvbi 
> zvbi-0.2 libzvbi.h vbi_d
>   { test_cpp_condition libzvbi.h 
> "VBI_VERSION_MAJOR > 0 || VBI_VERSION_MINOR > 2 || VBI_VERSION_MINOR == 2 && 
> VBI_VERSION_MICRO >= 28" ||
> enabled gpl || die "ERROR: libzvbi requires 
> version 0.2.28 or --enable-gpl."; }
>  enabled libxml2   && require_pkg_config libxml2 libxml-2.0 
> libxml2/libxml/xmlversion.h xmlCheckVersion
> -enabled mbedtls   && { check_pkg_config mbedtls mbedtls 
> mbedtls/x509_crt.h mbedtls_x509_crt_init ||
> -   check_pkg_config mbedtls mbedtls 
> mbedtls/ssl.h mbedtls_ssl_init ||
> -   check_lib mbedtls mbedtls/ssl.h 
> mbedtls_ssl_init -lmbedtls ||
> +enabled mbedtls   && { check_lib mbedtls mbedtls/ssl.h 
> mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto ||
> die "ERROR: mbedTLS not found"; }
>  enabled mediacodec&& { enabled jni || die "ERROR: mediacodec 
> requires --enable-jni"; }
>  enabled mmal  && { check_lib mmal interface/mmal/mmal.h 
> mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ||
>
> Also note that the order is important, because with -lmbedtls -lmbedcrypto 
> -lmbedx509 you'd get: "undefined reference to `mbedtls_pk_parse_subpubkey'" 
> and "undefined reference to `mbedtls_pk_load_file'".
>
> (If it matters, I'm cross-compiling on Windows using Cygwin, MinGW and GCC).
>
> -- Reino
*Ping* at Thomas Volkert, or anyone else responsible for this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc,lavf: add libxavs2 encoder

2018-05-26 Thread Moritz Barsnick
On Sat, May 26, 2018 at 14:08:56 +0800, hwren wrote:
> Add Chinese AVS2 video encoder, FFmpeg can make use of the libxavs2 library 
> for AVS2 encoding.
[...]
> +.long_name = NULL_IF_CONFIG_SMALL("raw Chinese AVS2 (2nd Audio 
> Video Standard)"),

Is that really the name of the codec? Otherwise, "Chinese" seems
awkward to me. (Same for the decoder.)

> +Go to @url{https://github.com/pkuvcl/xavs2} and follow the instructions for
> +installing the library. Then pass @code{--enable-libxavs2} to configure to
> +enable it.

Proper documentation of the encoder's options would be appreciated!

One more important thing: libdavs2 and libxavs2 are licensed under
GPL2, not LGPL. You therefore need a handful of extra boilerplate in
configure (such as EXTERNAL_LIBRARY_GPL_LIST, and adding "gpl" as a
dependency), as far as I understand.

Cheers,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [INFO]AMD D3D11 to OpenCL interop extension for NV12 and P010 textures - split planes

2018-05-26 Thread Mark Thompson
On 24/05/18 15:26, Mironov, Mikhail wrote:
> AMD has published OpenCL extension which allows split D3D11 texture interoped 
> as a single 2D image into two 2D images representing Y and UV planes.
> https://www.khronos.org/registry/OpenCL/extensions/amd/cl_amd_planar_yuv.txt

Nice!  That looks like exactly what we want :)

Is there any timeline for when this will be available in released drivers?

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] libavfilter/vf_nlmeans: add amount parameter

2018-05-26 Thread Paul B Mahol
On 5/18/18, Clement Boesch  wrote:
> On Sat, May 12, 2018 at 10:24:35PM +0200, Paul B Mahol wrote:
>> For better control of denoising.
>>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  doc/filters.texi | 4 
>>  libavfilter/vf_nlmeans.c | 5 -
>>  2 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index d77c67eb10..60ce18298b 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -11420,6 +11420,10 @@ Set research size.
>>  Same as @option{r} but for chroma planes.
>>
>>  The default value is @var{0} and means automatic.
>> +
>> +@item a
>> +Set denoising amount. Lower values reduces blurring.
>> +Default value is @var{1.0} and means full denoising.
>
> I'm not so fond of adding another semantically identical option to
> "strength". Do you have some literature on such an option?

It is not identical, you need certain math skills to get it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavc/hevcdec: Treat clean random access nals as keyframes for -skip_frame

2018-05-26 Thread Mark Thompson
On 24/05/18 17:57, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #7227 here, -skip_frame nokey shows no
> warnings on decoding with this change and still decodes less frames
> than -skip_frame nointra (which shows many warnings).
> 
> Please comment, Carl Eugen
> 
> 
> From ea5cf5aab2a9360971f5291fce19e5daae833de0 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos 
> Date: Thu, 24 May 2018 18:53:16 +0200
> Subject: [PATCH] lavc/hevcdec: Treat clean random access nals as keyframes
>  for -skip_frame.
> 
> Fixes ticket #7227.
> ---
>  libavcodec/hevcdec.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> index c887762..dd7675a 100644
> --- a/libavcodec/hevcdec.c
> +++ b/libavcodec/hevcdec.c
> @@ -2919,7 +2919,7 @@ static int decode_nal_unit(HEVCContext *s, const 
> H2645NAL *nal)
>  if (
>  (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == 
> HEVC_SLICE_B) ||
>  (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type 
> != HEVC_SLICE_I) ||
> -(s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s))) {
> +(s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s) && 
> s->nal_unit_type != HEVC_NAL_CRA_NUT)) {

I think "!IS_IRAP(s)" would be simpler and perhaps more consistent?  (Compared 
to what you have here it adds BLA NAL units as well, which will be equivalent 
to CRA for this purpose.)

>  break;
>  }
>  
> -- 
> 1.7.10.4
> 

Should be fine with or without that change.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] ffmpeg: Use the colour properties from the input stream when doing transcode

2018-05-26 Thread Mark Thompson
On 25/05/18 07:57, Tobias Rapp wrote:
> On 25.05.2018 07:58, Xiang, Haihao wrote:
>> On Thu, 2018-05-24 at 11:15 +0100, Mark Thompson wrote:
>>>
>>> For example:
>>>
>>> ffmpeg -i bt709_input.mkv -vf colorspace=bt2020 bt2020_output.mkv
>>>
>>> will have the output file marked as BT.709 after this patch, where 
>>> previously
>>> it was "unspecified".  (Explicitly setting -color_primaries/-color_trc/-
>>> colorspace on the output works in both cases.)
>>
>> I agree with you it's not worse than before as we don't get the expected 
>> result
>> in both cases.
> 
> Not quite: When a file says "I don't know this property value" you have a 
> chance to lookup the value somewhere else or use a default. When it says "I 
> know the value" and gives a wrong value, you completely loose trust.

Right, that is a compelling argument.  I agree with you, so I definitely won't 
apply the patch in this form.

> So in my opinion this patch should not be applied, as it possibly makes 
> ffmpeg generate files with wrong information where it just had no information 
> before. The correct approach would be to set the encoder properties from 
> output frame data and only write a header once the encoders have been 
> initialized completely.

Passing the information through libavfilter should be equivalent, but yeah.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 11/26] vaapi_encode: Add common options between all encoders

2018-05-26 Thread Mark Thompson
On 25/05/18 07:01, Xiang, Haihao wrote:
> 
> Hi Mark
> 
> Do you plan to merge this commit any time soon?

There are quite a few changes throughout the set, I'll resend it soon.

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] v4l2_m2m: Mark V4L2 M2M decoders as unsuitable for probing

2018-05-26 Thread Mark Thompson
---
 libavcodec/v4l2_m2m_dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index bca45be148..598dc10781 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -221,7 +221,8 @@ AVCodec ff_ ## NAME ## _v4l2m2m_decoder = { \
 .receive_frame  = v4l2_receive_frame,\
 .close  = ff_v4l2_m2m_codec_end,\
 .bsfs   = bsf_name, \
-.capabilities   = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \
+.capabilities   = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | \
+  AV_CODEC_CAP_AVOID_PROBING, \
 .wrapper_name   = "v4l2m2m", \
 };
 
-- 
2.16.3
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] cmdutils: dump HWAccel type in print_codec()

2018-05-26 Thread Mark Thompson
On 26/05/18 14:14, Jun Zhao wrote:
> dump the hwaccel type for codec when use the command like
> ./ffmpeg -h decoder=h264.
> 
> Signed-off-by: Jun Zhao 
> ---
>  fftools/cmdutils.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
> index 4f2e0a2..14b 100644
> --- a/fftools/cmdutils.c
> +++ b/fftools/cmdutils.c
> @@ -1444,6 +1444,17 @@ static void print_codec(const AVCodec *c)
>  printf("\n");
>  }
>  
> +if (avcodec_get_hw_config(c, 0)) {
> +printf("HWAccel devices: ");

These aren't necessarily for hwaccel, they can be hardware-only too.

Perhaps "Supported hardware devices:"?

> +for (int i = 0;; i++) {
> +const AVCodecHWConfig *config = avcodec_get_hw_config(c, i);
> +if (!config)
> +break;
> +printf("%s ", av_hwdevice_get_type_name(config->device_type));
> +}
> +printf("\n");
> +}
> +
>  if (c->supported_framerates) {
>  const AVRational *fps = c->supported_framerates;
>  
> 

Otherwise looks fine - good idea to make it show this information.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] cmdutils: print missing caps in print_codec().

2018-05-26 Thread Mark Thompson
On 26/05/18 14:14, Jun Zhao wrote:
> print full caps type in print_codec().
> 
> Signed-off-by: Jun Zhao 
> ---
>  fftools/cmdutils.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
> index 8ffc9d2..4f2e0a2 100644
> --- a/fftools/cmdutils.c
> +++ b/fftools/cmdutils.c
> @@ -1414,6 +1414,16 @@ static void print_codec(const AVCodec *c)
> AV_CODEC_CAP_SLICE_THREADS |
> AV_CODEC_CAP_AUTO_THREADS))
>  printf("threads ");
> +if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
> +printf("avoidprob ");

I think make it "avoidprobe" or "avoidprobing"?  "prob" doesn't make it obvious 
what it's short for.

> +if (c->capabilities & AV_CODEC_CAP_INTRA_ONLY)
> +printf("intraonly ");
> + if (c->capabilities & AV_CODEC_CAP_LOSSLESS)
> +printf("lossless ");
> +if (c->capabilities & AV_CODEC_CAP_HARDWARE)
> +printf("hardware ");
> +if (c->capabilities & AV_CODEC_CAP_HYBRID)
> +printf("hybrid ");
>  if (!c->capabilities)
>  printf("none");
>  printf("\n");
> 

Otherwise looks fine.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavcodec/cedrus264: h264 hardware encoding for Allwinner H2/H3

2018-05-26 Thread James Almer
On 5/26/2018 10:51 AM, daniel.kuc...@gmail.com wrote:
> From: Daniel Kucera 
> 
> Signed-off-by: Daniel Kucera 
> ---
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +

>  libavcodec/arm/sunxi/cedar_ve.h  |  79 ++
>  libavcodec/arm/sunxi/ion.h   | 377 ++
>  libavcodec/arm/sunxi/ion_sunxi.h | 108 
>  libavcodec/arm/sunxi/ve.c| 552 
> +++
>  libavcodec/arm/sunxi/ve.h| 193 ++

This stuff does not belong in libavcodec. And much less in the arch
specific assembly code folder.

>  libavcodec/cedrus264.c   | 402 
>  8 files changed, 1713 insertions(+)
>  create mode 100644 libavcodec/arm/sunxi/cedar_ve.h
>  create mode 100644 libavcodec/arm/sunxi/ion.h
>  create mode 100644 libavcodec/arm/sunxi/ion_sunxi.h
>  create mode 100755 libavcodec/arm/sunxi/ve.c
>  create mode 100755 libavcodec/arm/sunxi/ve.h
>  create mode 100755 libavcodec/cedrus264.c

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavcodec/cedrus264: h264 hardware encoding for Allwinner H2/H3

2018-05-26 Thread Mark Thompson
On 26/05/18 14:51, daniel.kuc...@gmail.com wrote:
> From: Daniel Kucera 
> 
> Signed-off-by: Daniel Kucera 
> ---
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/arm/sunxi/cedar_ve.h  |  79 ++
>  libavcodec/arm/sunxi/ion.h   | 377 ++
>  libavcodec/arm/sunxi/ion_sunxi.h | 108 
>  libavcodec/arm/sunxi/ve.c| 552 
> +++
>  libavcodec/arm/sunxi/ve.h| 193 ++
>  libavcodec/cedrus264.c   | 402 
>  8 files changed, 1713 insertions(+)
>  create mode 100644 libavcodec/arm/sunxi/cedar_ve.h
>  create mode 100644 libavcodec/arm/sunxi/ion.h
>  create mode 100644 libavcodec/arm/sunxi/ion_sunxi.h
>  create mode 100755 libavcodec/arm/sunxi/ve.c
>  create mode 100755 libavcodec/arm/sunxi/ve.h
>  create mode 100755 libavcodec/cedrus264.c
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 3ab071a..f3821af 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -987,6 +987,7 @@ OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
>  OBJS-$(CONFIG_LIBXAVS_ENCODER)+= libxavs.o
>  OBJS-$(CONFIG_LIBXVID_ENCODER)+= libxvid.o
>  OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER)   += libzvbi-teletextdec.o ass.o
> +OBJS-$(CONFIG_CEDRUS264_ENCODER)  += cedrus264.o arm/sunxi/ve.o
>  
>  # parsers
>  OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 7b7a8c7..a153576 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -66,6 +66,7 @@ extern AVCodec ff_c93_decoder;
>  extern AVCodec ff_cavs_decoder;
>  extern AVCodec ff_cdgraphics_decoder;
>  extern AVCodec ff_cdxl_decoder;
> +extern AVCodec ff_cedrus264_encoder;

This needs to go further down the list so that it isn't picked by default for 
H.264 encoding everywhere.

>  extern AVCodec ff_cfhd_decoder;
>  extern AVCodec ff_cinepak_encoder;
>  extern AVCodec ff_cinepak_decoder;


> diff --git a/libavcodec/arm/sunxi/cedar_ve.h b/libavcodec/arm/sunxi/cedar_ve.h

This file looks copied.  Where did it come from?  What licence is it used under?

> diff --git a/libavcodec/arm/sunxi/ion.h b/libavcodec/arm/sunxi/ion.h
> diff --git a/libavcodec/arm/sunxi/ion_sunxi.h 
> b/libavcodec/arm/sunxi/ion_sunxi.h

These are Linux (/Android?) header files.  They should be included from there, 
not pasted into libavcodec.

> diff --git a/libavcodec/arm/sunxi/ve.c b/libavcodec/arm/sunxi/ve.c
> diff --git a/libavcodec/arm/sunxi/ve.h b/libavcodec/arm/sunxi/ve.h

These files expose an interface to map and talk to the device.  They might work 
better as an external library?  If not, they need to be rewritten to conform to 
the FFmpeg style and interfaces.


> diff --git a/libavcodec/cedrus264.c b/libavcodec/cedrus264.c
> new file mode 100755
> index 000..5e62361
> --- /dev/null
> +++ b/libavcodec/cedrus264.c
> @@ -0,0 +1,402 @@
> +/*
> + * Cedrus 264 Video Encoder
> + * Copyright (c) 2014 Julien Folly
> + *
> + * This file is part of Libav.

Is it?

> + *
> + * Libav 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,
> + * 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
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * Cedrus 264 Encoder
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "libavutil/internal.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/mem.h"
> +#include "libavutil/pixdesc.h"
> +#include "avcodec.h"
> +#include "internal.h"
> +
> +#include "arm/sunxi/ve.h"
> +
> +/* byte stream utils from:
> + * https://github.com/jemk/cedrus/tree/master/h264enc

This link indicates that the source is GPL2?  If you have copied any GPL2 code 
then this is also GPL2, and that needs to be noted in configure.

> + */
> +static void put_bits(void* regs, uint32_t x, int num)
> +{
> + writel(x, (uint8_t *)regs + VE_AVC_BASIC_BITS);
> + writel(0x1 | ((num & 0x1f) << 8), (uint8_t *)regs + VE_AVC_TRIGGER);
> + // again the problem, how to check for finish?
> +}
> +
> +static void put_ue(void* regs, uint32_t x)
> +{
> + x++;
> + put_bits(regs, x, (32 - __builtin_clz(x)) * 2 - 1);
> +}
> +
> +static void put_se(void* regs, 

Re: [FFmpeg-devel] [PATCH] lavc,lavf: add libxavs2 encoder

2018-05-26 Thread Mark Thompson
On 26/05/18 07:08, hwren wrote:
> Add Chinese AVS2 video encoder, FFmpeg can make use of the libxavs2 library 
> for AVS2 encoding.
> 
> Signed-off-by: hwren 
> ---
>  Changelog|   2 +-
>  configure|   6 +
>  doc/general.texi |   8 ++
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/libxavs2.c| 347 
> +++
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/rawenc.c |  13 ++
>  9 files changed, 379 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/libxavs2.c
> 
> diff --git a/Changelog b/Changelog
> index 0f97679..87751d9 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -9,7 +9,7 @@ version :
>  - aderivative and aintegral audio filters
>  - pal75bars and pal100bars video filter sources
>  - support mbedTLS based TLS
> -- AVS2 video decoder
> +- AVS2 video encoder and decoder

Note the library used.

>  
>  
>  version 4.0:
> diff --git a/configure b/configure
> index 9aec00d..44c7b60 100755
> --- a/configure
> +++ b/configure
> @@ -276,6 +276,7 @@ External library support:
>--enable-libx264 enable H.264 encoding via x264 [no]
>--enable-libx265 enable HEVC encoding via x265 [no]
>--enable-libxavs enable AVS encoding via xavs [no]
> +  --enable-libxavs2enable AVS2 encoding via xavs2 [no]
>--enable-libdavs2enable AVS2 decoding via davs2 [no]
>--enable-libxcb  enable X11 grabbing using XCB [autodetect]
>--enable-libxcb-shm  enable X11 grabbing shm communication [autodetect]
> @@ -1642,6 +1643,7 @@ EXTERNAL_LIBRARY_GPL_LIST="
>  libx264
>  libx265
>  libxavs
> +libxavs2
>  libdavs2
>  libxvid
>  "
> @@ -3097,6 +3099,7 @@ libx264rgb_encoder_deps="libx264 x264_csp_bgr"
>  libx264rgb_encoder_select="libx264_encoder"
>  libx265_encoder_deps="libx265"
>  libxavs_encoder_deps="libxavs"
> +libxavs2_encoder_deps="libxavs2"
>  libdavs2_decoder_deps="libdavs2"
>  libxvid_encoder_deps="libxvid"
>  libzvbi_teletext_decoder_deps="libzvbi"
> @@ -6107,6 +6110,9 @@ enabled libx264   && { check_pkg_config libx264 
> x264 "stdint.h x264.h" x
>  enabled libx265   && require_pkg_config libx265 x265 x265.h 
> x265_api_get &&
>   require_cpp_condition x265.h "X265_BUILD >= 68"
>  enabled libxavs   && require libxavs "stdint.h xavs.h" 
> xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
> +enabled libxavs2  && require_pkg_config libxavs2 xavs2 "stdint.h 
> xavs2.h" xavs2_api_get &&
> +  { check_cpp_condition xavs2 xavs2.h "XAVS2_BUILD 
> >= 12" ||
> +die "ERROR: xavs2 version must be >= 12." ; }

Same comments as on libdavs2 - stdint.h, version from pkgconfig?

>  enabled libdavs2  && require_pkg_config libdavs2 davs2 "stdint.h 
> davs2.h" davs2_decoder_decode &&
>{ check_cpp_condition davs2 davs2.h "DAVS2_BUILD 
> >= 12" ||
>  die "ERROR: libdavs2 version must be >= 12." ; }
> diff --git a/doc/general.texi b/doc/general.texi
> index d3c1503..c80d610 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -25,6 +25,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
> instructions for
>  installing the library. Then pass @code{--enable-libdavs2} to configure to
>  enable it.
>  
> +@section libxavs2
> +
> +FFmpeg can make use of the libxavs2 library for AVS2 encoding.
> +
> +Go to @url{https://github.com/pkuvcl/xavs2} and follow the instructions for
> +installing the library. Then pass @code{--enable-libxavs2} to configure to
> +enable it.
> +
>  @section Alliance for Open Media libaom
>  
>  FFmpeg can make use of the libaom library for AV1 decoding.
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index e85b74c..88b7b84 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -985,6 +985,7 @@ OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
>  OBJS-$(CONFIG_LIBX264_ENCODER)+= libx264.o
>  OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
>  OBJS-$(CONFIG_LIBXAVS_ENCODER)+= libxavs.o
> +OBJS-$(CONFIG_LIBXAVS2_ENCODER)   += libxavs2.o
>  OBJS-$(CONFIG_LIBDAVS2_DECODER)   += libdavs2.o
>  OBJS-$(CONFIG_LIBXVID_ENCODER)+= libxvid.o
>  OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER)   += libzvbi-teletextdec.o ass.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 6103081..ca776b0 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -705,6 +705,7 @@ extern AVCodec ff_libx264_encoder;
>  extern AVCodec ff_libx264rgb_encoder;
>  extern AVCodec ff_libx265_encoder;
>  extern AVCodec ff_libxavs_encoder;
> +extern AVCodec ff_libxavs2_encoder;
>  extern AVCodec ff_libdavs2_decoder;
>  extern AVCodec ff_libxvid_encoder;
>  extern 

Re: [FFmpeg-devel] [PATCH] lavc,lavf: add libdavs2 decoder

2018-05-26 Thread Mark Thompson
On 26/05/18 05:41, hwren wrote:
> Add Chinese AVS2 video decoder, FFmpeg can make use of the libdavs2 library 
> for AVS2 decoding.
> 
> Signed-off-by: hwren 
> ---
>  Changelog   |   1 +
>  configure   |   6 ++
>  doc/general.texi|   8 ++
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/codec_desc.c |   7 ++
>  libavcodec/libdavs2.c   | 216 
> 
>  libavformat/riff.c  |   1 +
>  9 files changed, 242 insertions(+)
>  create mode 100644 libavcodec/libdavs2.c
> 
> diff --git a/Changelog b/Changelog
> index 3d25564..0f97679 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -9,6 +9,7 @@ version :
>  - aderivative and aintegral audio filters
>  - pal75bars and pal100bars video filter sources
>  - support mbedTLS based TLS
> +- AVS2 video decoder

Note the library that is used here.  (This isn't a native decoder, it requires 
an external library.)

>  
>  
>  version 4.0:
> diff --git a/configure b/configure
> index 09ff0c5..9aec00d 100755
> --- a/configure
> +++ b/configure
> @@ -276,6 +276,7 @@ External library support:
>--enable-libx264 enable H.264 encoding via x264 [no]
>--enable-libx265 enable HEVC encoding via x265 [no]
>--enable-libxavs enable AVS encoding via xavs [no]
> +  --enable-libdavs2enable AVS2 decoding via davs2 [no]

This list should stay in alphabetical order.

>--enable-libxcb  enable X11 grabbing using XCB [autodetect]
>--enable-libxcb-shm  enable X11 grabbing shm communication [autodetect]
>--enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
> @@ -1641,6 +1642,7 @@ EXTERNAL_LIBRARY_GPL_LIST="
>  libx264
>  libx265
>  libxavs
> +libdavs2

Likewise this one, and more below.

>  libxvid
>  "
>  
> @@ -3095,6 +3097,7 @@ libx264rgb_encoder_deps="libx264 x264_csp_bgr"
>  libx264rgb_encoder_select="libx264_encoder"
>  libx265_encoder_deps="libx265"
>  libxavs_encoder_deps="libxavs"
> +libdavs2_decoder_deps="libdavs2"
>  libxvid_encoder_deps="libxvid"
>  libzvbi_teletext_decoder_deps="libzvbi"
>  vapoursynth_demuxer_deps="vapoursynth"
> @@ -6104,6 +6107,9 @@ enabled libx264   && { check_pkg_config libx264 
> x264 "stdint.h x264.h" x
>  enabled libx265   && require_pkg_config libx265 x265 x265.h 
> x265_api_get &&
>   require_cpp_condition x265.h "X265_BUILD >= 68"
>  enabled libxavs   && require libxavs "stdint.h xavs.h" 
> xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
> +enabled libdavs2  && require_pkg_config libdavs2 davs2 "stdint.h 
> davs2.h" davs2_decoder_decode &&

That shouldn't need stdint.h?  If it does, then the library should probably be 
fixed to include it correctly.

> +  { check_cpp_condition davs2 davs2.h "DAVS2_BUILD 
> >= 12" ||
> +die "ERROR: libdavs2 version must be >= 12." ; }

Can you check the version with pkgconfig instead?

>  enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
>  enabled libzimg   && require_pkg_config libzimg "zimg >= 2.7.0" 
> zimg.h zimg_get_api_version
>  enabled libzmq&& require_pkg_config libzmq libzmq zmq.h 
> zmq_ctx_new
> diff --git a/doc/general.texi b/doc/general.texi
> index 2583006..d3c1503 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -17,6 +17,14 @@ for more formats. None of them are used by default, their 
> use has to be
>  explicitly requested by passing the appropriate flags to
>  @command{./configure}.
>  
> +@section libdavs2
> +
> +FFmpeg can make use of the libdavs2 library for AVS2 decoding.
> +
> +Go to @url{https://github.com/pkuvcl/davs2} and follow the instructions for
> +installing the library. Then pass @code{--enable-libdavs2} to configure to
> +enable it.
> +
>  @section Alliance for Open Media libaom
>  
>  FFmpeg can make use of the libaom library for AV1 decoding.
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 3ab071a..e85b74c 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -985,6 +985,7 @@ OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
>  OBJS-$(CONFIG_LIBX264_ENCODER)+= libx264.o
>  OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
>  OBJS-$(CONFIG_LIBXAVS_ENCODER)+= libxavs.o
> +OBJS-$(CONFIG_LIBDAVS2_DECODER)   += libdavs2.o
>  OBJS-$(CONFIG_LIBXVID_ENCODER)+= libxvid.o
>  OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER)   += libzvbi-teletextdec.o ass.o
>  
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 7b7a8c7..6103081 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -705,6 +705,7 @@ extern AVCodec ff_libx264_encoder;
>  extern AVCodec ff_libx264rgb_encoder;
>  extern AVCodec ff_libx265_encoder;
>  extern AVCodec 

Re: [FFmpeg-devel] [PATCH 1/2] cmdutils: print missing caps in print_codec().

2018-05-26 Thread Reto Kromer
Jun Zhao wrote:

>print full caps type in print_codec().
>
>Signed-off-by: Jun Zhao 
>---
> fftools/cmdutils.c | 10 ++
> 1 file changed, 10 insertions(+)
>
>diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
>index 8ffc9d2..4f2e0a2 100644
>--- a/fftools/cmdutils.c
>+++ b/fftools/cmdutils.c
>@@ -1414,6 +1414,16 @@ static void print_codec(const AVCodec *c)
>AV_CODEC_CAP_SLICE_THREADS |
>AV_CODEC_CAP_AUTO_THREADS))
> printf("threads ");
>+if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
>+printf("avoidprob ");
>+if (c->capabilities & AV_CODEC_CAP_INTRA_ONLY)
>+printf("intraonly ");
>+ if (c->capabilities & AV_CODEC_CAP_LOSSLESS)
>+printf("lossless ");

nit: alignment

>+if (c->capabilities & AV_CODEC_CAP_HARDWARE)
>+printf("hardware ");
>+if (c->capabilities & AV_CODEC_CAP_HYBRID)
>+printf("hybrid ");
> if (!c->capabilities)
> printf("none");
> printf("\n");

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libavcodec/cedrus264: h264 hardware encoding for Allwinner H2/H3

2018-05-26 Thread daniel . kucera
From: Daniel Kucera 

Signed-off-by: Daniel Kucera 
---
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/arm/sunxi/cedar_ve.h  |  79 ++
 libavcodec/arm/sunxi/ion.h   | 377 ++
 libavcodec/arm/sunxi/ion_sunxi.h | 108 
 libavcodec/arm/sunxi/ve.c| 552 +++
 libavcodec/arm/sunxi/ve.h| 193 ++
 libavcodec/cedrus264.c   | 402 
 8 files changed, 1713 insertions(+)
 create mode 100644 libavcodec/arm/sunxi/cedar_ve.h
 create mode 100644 libavcodec/arm/sunxi/ion.h
 create mode 100644 libavcodec/arm/sunxi/ion_sunxi.h
 create mode 100755 libavcodec/arm/sunxi/ve.c
 create mode 100755 libavcodec/arm/sunxi/ve.h
 create mode 100755 libavcodec/cedrus264.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3ab071a..f3821af 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -987,6 +987,7 @@ OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
 OBJS-$(CONFIG_LIBXAVS_ENCODER)+= libxavs.o
 OBJS-$(CONFIG_LIBXVID_ENCODER)+= libxvid.o
 OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER)   += libzvbi-teletextdec.o ass.o
+OBJS-$(CONFIG_CEDRUS264_ENCODER)  += cedrus264.o arm/sunxi/ve.o
 
 # parsers
 OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 7b7a8c7..a153576 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -66,6 +66,7 @@ extern AVCodec ff_c93_decoder;
 extern AVCodec ff_cavs_decoder;
 extern AVCodec ff_cdgraphics_decoder;
 extern AVCodec ff_cdxl_decoder;
+extern AVCodec ff_cedrus264_encoder;
 extern AVCodec ff_cfhd_decoder;
 extern AVCodec ff_cinepak_encoder;
 extern AVCodec ff_cinepak_decoder;
diff --git a/libavcodec/arm/sunxi/cedar_ve.h b/libavcodec/arm/sunxi/cedar_ve.h
new file mode 100644
index 000..92faf59
--- /dev/null
+++ b/libavcodec/arm/sunxi/cedar_ve.h
@@ -0,0 +1,79 @@
+#ifndef _CEDAR_VE_H_
+#define _CEDAR_VE_H_
+
+enum IOCTL_CMD {
+   IOCTL_UNKOWN = 0x100,
+   IOCTL_GET_ENV_INFO,
+   IOCTL_WAIT_VE_DE,
+   IOCTL_WAIT_VE_EN,
+   IOCTL_RESET_VE,
+   IOCTL_ENABLE_VE,
+   IOCTL_DISABLE_VE,
+   IOCTL_SET_VE_FREQ,
+
+   IOCTL_CONFIG_AVS2 = 0x200,
+   IOCTL_GETVALUE_AVS2 ,
+   IOCTL_PAUSE_AVS2 ,
+   IOCTL_START_AVS2 ,
+   IOCTL_RESET_AVS2 ,
+   IOCTL_ADJUST_AVS2,
+   IOCTL_ENGINE_REQ,
+   IOCTL_ENGINE_REL,
+   IOCTL_ENGINE_CHECK_DELAY,
+   IOCTL_GET_IC_VER,
+   IOCTL_ADJUST_AVS2_ABS,
+   IOCTL_FLUSH_CACHE,
+   IOCTL_SET_REFCOUNT,
+
+   IOCTL_READ_REG = 0x300,
+   IOCTL_WRITE_REG,
+
+   IOCTL_SET_VOL = 0x400,
+
+#if defined CONFIG_ARCH_SUN8IW8P1
+   IOCTL_WAIT_JPEG_DEC = 0x500,
+#endif
+};
+
+struct cedarv_env_infomation{
+   unsigned int phymem_start;
+   int  phymem_total_size;
+   unsigned int  address_macc;
+};
+
+struct cedarv_cache_range{
+   long start;
+   long end;
+};
+
+/*struct __cedarv_task {
+   int task_prio;
+   int ID;
+   unsigned long timeout;
+   unsigned int frametime;
+   unsigned int block_mode;
+};
+
+struct cedarv_engine_task {
+   struct __cedarv_task t;
+   struct list_head list;
+   struct task_struct *task_handle;
+   unsigned int status;
+   unsigned int running;
+   unsigned int is_first_task;
+};
+
+struct cedarv_engine_task_info {
+   int task_prio;
+   unsigned int frametime;
+   unsigned int total_time;
+};*/
+
+struct cedarv_regop {
+unsigned int addr;
+unsigned int value;
+};
+/**/
+
+
+#endif
diff --git a/libavcodec/arm/sunxi/ion.h b/libavcodec/arm/sunxi/ion.h
new file mode 100644
index 000..e777c69
--- /dev/null
+++ b/libavcodec/arm/sunxi/ion.h
@@ -0,0 +1,377 @@
+/*
+ * include/linux/ion.h
+ *
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program 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 General Public License for more details.
+ *
+ */
+
+#ifndef _LINUX_ION_H
+#define _LINUX_ION_H
+
+#include 
+#include 
+
+struct ion_handle;
+/**
+ * enum ion_heap_types - list of all possible types of heaps
+ * @ION_HEAP_TYPE_SYSTEM:   memory allocated via vmalloc
+ * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc
+ * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved
+ *  carveout heap, allocations are physically
+ *  

Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-26 Thread Jonathan Morley
Attaching again from another mail client.

On Sat, May 26, 2018 at 12:23 AM, Marton Balint  wrote:

>
>
> On Fri, 25 May 2018, Jonathan Morley wrote:
>
> Attached are the two patches to address your feedback, Marton. Please
>> advise.
>>
>>
> Your mail contains no attachments as far as I see.
>
>
> Regards,
> Marton
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


0001-lavd-decklink_common-Move-DECKLINK_-string-functions.patch
Description: Binary data


0002-lavd-decklink-Capture-first-valid-timecode-to-metadata.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 0/2] dump more codec information

2018-05-26 Thread Jun Zhao
- print full capabilities
- dump hwaccel type support by codec

Jun Zhao (2):
  cmdutils: print missing caps in print_codec().
  cmdutils: dump HWAccel type in print_codec()

 fftools/cmdutils.c | 21 +
 1 file changed, 21 insertions(+)

-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] cmdutils: dump HWAccel type in print_codec()

2018-05-26 Thread Jun Zhao
dump the hwaccel type for codec when use the command like
./ffmpeg -h decoder=h264.

Signed-off-by: Jun Zhao 
---
 fftools/cmdutils.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 4f2e0a2..14b 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1444,6 +1444,17 @@ static void print_codec(const AVCodec *c)
 printf("\n");
 }
 
+if (avcodec_get_hw_config(c, 0)) {
+printf("HWAccel devices: ");
+for (int i = 0;; i++) {
+const AVCodecHWConfig *config = avcodec_get_hw_config(c, i);
+if (!config)
+break;
+printf("%s ", av_hwdevice_get_type_name(config->device_type));
+}
+printf("\n");
+}
+
 if (c->supported_framerates) {
 const AVRational *fps = c->supported_framerates;
 
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] cmdutils: print missing caps in print_codec().

2018-05-26 Thread Jun Zhao
print full caps type in print_codec().

Signed-off-by: Jun Zhao 
---
 fftools/cmdutils.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 8ffc9d2..4f2e0a2 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1414,6 +1414,16 @@ static void print_codec(const AVCodec *c)
AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_AUTO_THREADS))
 printf("threads ");
+if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
+printf("avoidprob ");
+if (c->capabilities & AV_CODEC_CAP_INTRA_ONLY)
+printf("intraonly ");
+ if (c->capabilities & AV_CODEC_CAP_LOSSLESS)
+printf("lossless ");
+if (c->capabilities & AV_CODEC_CAP_HARDWARE)
+printf("hardware ");
+if (c->capabilities & AV_CODEC_CAP_HYBRID)
+printf("hybrid ");
 if (!c->capabilities)
 printf("none");
 printf("\n");
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mxf: fix NTSC 59.94 samples per frame layout

2018-05-26 Thread Tomas Härdin
tor 2018-05-24 klockan 22:27 +0200 skrev Marton Balint:
> FFmbc uses this.
> bmx uses this.
> XAVC MXF Mapping and Operating Points prefers this.
> Basic rounding rules also yields these numbers.
> 
> > Signed-off-by: Marton Balint 
> ---
>  libavformat/mxf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/mxf.c b/libavformat/mxf.c
> index a909401f08..c8b57f7f0b 100644
> --- a/libavformat/mxf.c
> +++ b/libavformat/mxf.c
> @@ -134,7 +134,7 @@ static const MXFSamplesPerFrame mxf_spf[] = {
>  { { 1001, 24000 }, { 2002, 0,0,0,0,0 } }, // FILM 23.976
>  { { 1, 24},{ 2000, 0,0,0,0,0 } }, // FILM 24
>  { { 1001, 3 }, { 1602, 1601, 1602, 1601, 1602, 0 } }, // NTSC 29.97
> -{ { 1001, 6 }, { 801,  801,  801,  801,  800,  0 } }, // NTSC 59.94
> +{ { 1001, 6 }, { 801,  801,  800,  801,  801,  0 } }, // NTSC 59.94
>  { { 1, 25 },   { 1920, 0,0,0,0,0 } }, // PAL 25
>  { { 1, 50 },   { 960,  0,0,0,0,0 } }, // PAL 50
>  { { 1, 60 },   { 800,  0,0,0,0,0 } },

Looks OK

/Tomas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] doc/ffmpeg - rewrite Stream Selection chapter

2018-05-26 Thread Gyan Doshi

Hi Lou,

Most sectioning and formatting suggestions applied locally.

On 26-05-2018 03:50 AM, Lou Logan wrote:


Examples are often * itemized by convention, but the resulting text
justification such verbose examples makes them hard to read in HTML
format. I would ditch the itemization.


Part of the ugliness is due to how the code fragments are rendered: with 
vertical margins, creating uneven line spacing. Do you mind if I reduce 
or eliminate those margins?


Regards,
Gyan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-26 Thread Marton Balint



On Fri, 25 May 2018, Jonathan Morley wrote:


Attached are the two patches to address your feedback, Marton. Please advise.



Your mail contains no attachments as far as I see.

Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/mpegtsenc: add support for AVS2

2018-05-26 Thread hwren
Signed-off-by: hwren 
---
 libavformat/mpegtsenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 3339e26..8b4f730 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -344,6 +344,9 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 case AV_CODEC_ID_CAVS:
 stream_type = STREAM_TYPE_VIDEO_CAVS;
 break;
+case AV_CODEC_ID_AVS2:
+stream_type = STREAM_TYPE_VIDEO_AVS2;
+break;
 case AV_CODEC_ID_DIRAC:
 stream_type = STREAM_TYPE_VIDEO_DIRAC;
 break;
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/mpegts: add support for AVS2

2018-05-26 Thread hwren
Signed-off-by: hwren 
---
 libavformat/mpegts.c | 1 +
 libavformat/mpegts.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 5f53f77..6674cd0 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -735,6 +735,7 @@ static const StreamType ISO_types[] = {
 { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000   },
 { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC   },
 { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS   },
+{ 0xd2, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_AVS2   },
 { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC  },
 { 0xea, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1},
 { 0 },
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 272e2be..b37db3c 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -55,6 +55,7 @@
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
 #define STREAM_TYPE_VIDEO_CAVS  0x42
+#define STREAM_TYPE_VIDEO_AVS2  0xd2
 #define STREAM_TYPE_VIDEO_VC1   0xea
 #define STREAM_TYPE_VIDEO_DIRAC 0xd1
 
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc,lavf: add libxavs2 encoder

2018-05-26 Thread hwren
Add Chinese AVS2 video encoder, FFmpeg can make use of the libxavs2 library for 
AVS2 encoding.

Signed-off-by: hwren 
---
 Changelog|   2 +-
 configure|   6 +
 doc/general.texi |   8 ++
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libxavs2.c| 347 +++
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/rawenc.c |  13 ++
 9 files changed, 379 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libxavs2.c

diff --git a/Changelog b/Changelog
index 0f97679..87751d9 100644
--- a/Changelog
+++ b/Changelog
@@ -9,7 +9,7 @@ version :
 - aderivative and aintegral audio filters
 - pal75bars and pal100bars video filter sources
 - support mbedTLS based TLS
-- AVS2 video decoder
+- AVS2 video encoder and decoder
 
 
 version 4.0:
diff --git a/configure b/configure
index 9aec00d..44c7b60 100755
--- a/configure
+++ b/configure
@@ -276,6 +276,7 @@ External library support:
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
   --enable-libxavs enable AVS encoding via xavs [no]
+  --enable-libxavs2enable AVS2 encoding via xavs2 [no]
   --enable-libdavs2enable AVS2 decoding via davs2 [no]
   --enable-libxcb  enable X11 grabbing using XCB [autodetect]
   --enable-libxcb-shm  enable X11 grabbing shm communication [autodetect]
@@ -1642,6 +1643,7 @@ EXTERNAL_LIBRARY_GPL_LIST="
 libx264
 libx265
 libxavs
+libxavs2
 libdavs2
 libxvid
 "
@@ -3097,6 +3099,7 @@ libx264rgb_encoder_deps="libx264 x264_csp_bgr"
 libx264rgb_encoder_select="libx264_encoder"
 libx265_encoder_deps="libx265"
 libxavs_encoder_deps="libxavs"
+libxavs2_encoder_deps="libxavs2"
 libdavs2_decoder_deps="libdavs2"
 libxvid_encoder_deps="libxvid"
 libzvbi_teletext_decoder_deps="libzvbi"
@@ -6107,6 +6110,9 @@ enabled libx264   && { check_pkg_config libx264 
x264 "stdint.h x264.h" x
 enabled libx265   && require_pkg_config libx265 x265 x265.h 
x265_api_get &&
  require_cpp_condition x265.h "X265_BUILD >= 68"
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
+enabled libxavs2  && require_pkg_config libxavs2 xavs2 "stdint.h 
xavs2.h" xavs2_api_get &&
+  { check_cpp_condition xavs2 xavs2.h "XAVS2_BUILD >= 
12" ||
+die "ERROR: xavs2 version must be >= 12." ; }
 enabled libdavs2  && require_pkg_config libdavs2 davs2 "stdint.h 
davs2.h" davs2_decoder_decode &&
   { check_cpp_condition davs2 davs2.h "DAVS2_BUILD >= 
12" ||
 die "ERROR: libdavs2 version must be >= 12." ; }
diff --git a/doc/general.texi b/doc/general.texi
index d3c1503..c80d610 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -25,6 +25,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the 
instructions for
 installing the library. Then pass @code{--enable-libdavs2} to configure to
 enable it.
 
+@section libxavs2
+
+FFmpeg can make use of the libxavs2 library for AVS2 encoding.
+
+Go to @url{https://github.com/pkuvcl/xavs2} and follow the instructions for
+installing the library. Then pass @code{--enable-libxavs2} to configure to
+enable it.
+
 @section Alliance for Open Media libaom
 
 FFmpeg can make use of the libaom library for AV1 decoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e85b74c..88b7b84 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -985,6 +985,7 @@ OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
 OBJS-$(CONFIG_LIBX264_ENCODER)+= libx264.o
 OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
 OBJS-$(CONFIG_LIBXAVS_ENCODER)+= libxavs.o
+OBJS-$(CONFIG_LIBXAVS2_ENCODER)   += libxavs2.o
 OBJS-$(CONFIG_LIBDAVS2_DECODER)   += libdavs2.o
 OBJS-$(CONFIG_LIBXVID_ENCODER)+= libxvid.o
 OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER)   += libzvbi-teletextdec.o ass.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 6103081..ca776b0 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -705,6 +705,7 @@ extern AVCodec ff_libx264_encoder;
 extern AVCodec ff_libx264rgb_encoder;
 extern AVCodec ff_libx265_encoder;
 extern AVCodec ff_libxavs_encoder;
+extern AVCodec ff_libxavs2_encoder;
 extern AVCodec ff_libdavs2_decoder;
 extern AVCodec ff_libxvid_encoder;
 extern AVCodec ff_libzvbi_teletext_decoder;
diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
new file mode 100644
index 000..b9197ce
--- /dev/null
+++ b/libavcodec/libxavs2.c
@@ -0,0 +1,347 @@
+/*
+ * AVS2 encoding using the xavs2 library
+ *
+ * Copyright (C) 2018 Yiqun Xu, 
+ *Falei Luo, 
+ *