[FFmpeg-devel] [PATCH, v3 2/3] fftools/ffmpeg: support variable resolution encode

2019-07-30 Thread Linjie Fu
Flush encoders when resolution change happens.

Use AV_CODEC_CAP_PARAM_CHANGE flag for encoder to indicate whether
it supports variable/dynamic resolution encoding.

Signed-off-by: Linjie Fu 
---
[v3]: use AV_CODEC_CAP_PARAM_CHANGE flag
 fftools/ffmpeg.c| 14 ++
 libavcodec/rawenc.c |  1 +
 2 files changed, 15 insertions(+)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5d52430..35b0f89 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -130,6 +130,7 @@ static void do_video_stats(OutputStream *ost, int 
frame_size);
 static BenchmarkTimeStamps get_benchmark_time_stamps(void);
 static int64_t getmaxrss(void);
 static int ifilter_has_all_input_formats(FilterGraph *fg);
+static void flush_encoders(void);
 
 static int run_as_daemon  = 0;
 static int nb_frames_dup = 0;
@@ -1067,6 +1068,19 @@ static void do_video_out(OutputFile *of,
 InputStream *ist = NULL;
 AVFilterContext *filter = ost->filter->filter;
 
+/* flush encoders in dynamic resolution encode */
+if (next_picture && (enc->width != next_picture->width ||
+ enc->height != next_picture->height)) {
+flush_encoders();
+avcodec_flush_buffers(enc);
+
+if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE)) {
+av_log(NULL, AV_LOG_ERROR, "Dynamic resolution encode "
+"is not supported by %s.\n", enc->codec->name);
+goto error;
+}
+}
+
 if (ost->source_index >= 0)
 ist = input_streams[ost->source_index];
 
diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index d181b74..9e8cb57 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -92,4 +92,5 @@ AVCodec ff_rawvideo_encoder = {
 .id = AV_CODEC_ID_RAWVIDEO,
 .init   = raw_encode_init,
 .encode2= raw_encode,
+.capabilities   = AV_CODEC_CAP_PARAM_CHANGE,
 };
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH, v2 3/3] lavc/libvpxenc: add dynamic resolution encode support for libvpx

2019-07-30 Thread Linjie Fu
According to spec, libvpx should support dynamic resolution changes.

Add dynamic resolution encoding support in libvpx.

Format change should also be supported, but I didn't test it so just
leave it open.

cmdline:
ffmpeg -noautoscale -y -i ./reinit-large_420_8-to-small_420_8.h264
 -pix_fmt yuv420p -c:v libvpx-vp9 lena.ivf

Signed-off-by: Linjie Fu 
---
[v2]: use AV_CODEC_CAP_PARAM_CHANGE flag.

 libavcodec/libvpxenc.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index feb52ea..800ba18 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1067,6 +1067,15 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 int res, coded_size;
 vpx_enc_frame_flags_t flags = 0;
 
+if (frame && (avctx->width != frame->width ||
+  avctx->height != frame->height)) {
+avctx->width  = frame->width;
+avctx->height = frame->height;
+
+avctx->codec->close(avctx);
+avctx->codec->init(avctx);
+}
+
 if (frame) {
 rawimg  = >rawimg;
 rawimg->planes[VPX_PLANE_Y] = frame->data[0];
@@ -1295,7 +1304,7 @@ AVCodec ff_libvpx_vp8_encoder = {
 .init   = vp8_init,
 .encode2= vpx_encode,
 .close  = vpx_free,
-.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS | 
AV_CODEC_CAP_PARAM_CHANGE,
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE },
 .priv_class = _vp8,
 .defaults   = defaults,
@@ -1325,7 +1334,7 @@ AVCodec ff_libvpx_vp9_encoder = {
 .init   = vp9_init,
 .encode2= vpx_encode,
 .close  = vpx_free,
-.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS | 
AV_CODEC_CAP_PARAM_CHANGE,
 .profiles   = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),
 .priv_class = _vp9,
 .defaults   = defaults,
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH, v4 1/3] fftools/ffmpeg_filter: add -autoscale to disable/enable the default scale

2019-07-30 Thread Linjie Fu
Currently, ffmpeg inserts scale filter by default in the filter graph
to force the whole decoded stream to scale into the same size with the
first frame. It's not quite make sense in resolution changing cases if
user wants the rawvideo without any scale.

Using autoscale/noautoscale to indicate whether auto inserting the scale
filter in the filter graph:
-noautoscale or -autoscale 0:
disable the default auto scale filter inserting.

Update docs.

Signed-off-by: U. Artie Eoff 
Signed-off-by: Linjie Fu 
---
[no updates]
 doc/ffmpeg.texi | 16 
 fftools/ffmpeg.c|  1 +
 fftools/ffmpeg.h|  4 
 fftools/ffmpeg_filter.c |  2 +-
 fftools/ffmpeg_opt.c|  8 
 5 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index cd35eb4..29da951 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -734,10 +734,6 @@ ffmpeg -dump_attachment:t "" -i INPUT
 Technical note -- attachments are implemented as codec extradata, so this
 option can actually be used to extract extradata from any stream, not just
 attachments.
-
-@item -noautorotate
-Disable automatically rotating video based on file metadata.
-
 @end table
 
 @section Video Options
@@ -819,6 +815,18 @@ Create the filtergraph specified by @var{filtergraph} and 
use it to
 filter the stream.
 
 This is an alias for @code{-filter:v}, see the @ref{filter_option,,-filter 
option}.
+
+@item -autorotate
+Automatically rotate the video according to file metadata. Enabled by
+default, use @option{-noautorotate} to disable it.
+
+@item -autoscale
+Automatically scale the video according to the resolution of first frame.
+Enabled by default, use @option{-noautoscale} to disable it. When autoscale is
+disabled, all output frames of filter graph might not be in the same resolution
+and may be inadequate for some encoder/muxer. Therefore, it is not recommended
+to disable it unless you really know what you are doing.
+Disable autoscale at your own risk.
 @end table
 
 @section Advanced Video options
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 01f0410..5d52430 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2133,6 +2133,7 @@ static int ifilter_send_frame(InputFilter *ifilter, 
AVFrame *frame)
 
 /* determine if the parameters for this input changed */
 need_reinit = ifilter->format != frame->format;
+fg->autoscale = ifilter->ist->autoscale;
 
 switch (ifilter->ist->st->codecpar->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7b6f802..1602406 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -133,6 +133,8 @@ typedef struct OptionsContext {
 intnb_hwaccel_output_formats;
 SpecifierOpt *autorotate;
 intnb_autorotate;
+SpecifierOpt *autoscale;
+intnb_autoscale;
 
 /* output options */
 StreamMap *stream_maps;
@@ -285,6 +287,7 @@ typedef struct FilterGraph {
 
 AVFilterGraph *graph;
 int reconfiguration;
+int autoscale;
 
 InputFilter   **inputs;
 int  nb_inputs;
@@ -335,6 +338,7 @@ typedef struct InputStream {
 int guess_layout_max;
 
 int autorotate;
+int autoscale;
 
 int fix_sub_duration;
 struct { /* previous decoded subtitle and related variables */
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 72838de..2a2eb08 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -469,7 +469,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
OutputFilter *ofilter,
 if (ret < 0)
 return ret;
 
-if (ofilter->width || ofilter->height) {
+if ((ofilter->width || ofilter->height) && fg->autoscale) {
 char args[255];
 AVFilterContext *filter;
 AVDictionaryEntry *e = NULL;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f5ca18a..41cb676 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -742,7 +742,9 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
 
 ist->autorotate = 1;
+ist->autoscale  = 1;
 MATCH_PER_STREAM_OPT(autorotate, i, ist->autorotate, ic, st);
+MATCH_PER_STREAM_OPT(autoscale, i, ist->autoscale, ic, st);
 
 MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
 if (codec_tag) {
@@ -3640,6 +3642,12 @@ const OptionDef options[] = {
 { "autorotate",   HAS_ARG | OPT_BOOL | OPT_SPEC |
   OPT_EXPERT | OPT_INPUT,  
  { .off = OFFSET(autorotate) },
 "automatically insert correct rotate filters" },
+{ "autoscale",HAS_ARG | OPT_BOOL | OPT_SPEC |
+  OPT_EXPERT | OPT_INPUT,  
  { .off = OFFSET(autoscale) },
+"automatically insert a scale filter at the end of the filter graph if 
a resolution"
+"change is 

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread James Almer
On 7/30/2019 11:18 PM, Sun, Jing A wrote:
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> Limin Wang
> Sent: Wednesday, July 31, 2019 7:05 AM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc 
> encoder wrapper
> 
> On Tue, Jul 30, 2019 at 07:48:43PM +0200, Carl Eugen Hoyos wrote:
>> Am Di., 30. Juli 2019 um 15:20 Uhr schrieb James Almer :
>>>
>>> On 7/30/2019 2:59 AM, Limin Wang wrote:
> +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
> +EB_BUFFERHEADERTYPE *header_ptr = NULL;
> +
> +svt_ret = EbH265EncStreamHeader(svt_enc->svt_handle, 
> _ptr);
> +if (svt_ret != EB_ErrorNone) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to build stream 
> header\n");
> +goto failed_init_encoder;
> +}
> +
> +avctx->extradata_size = header_ptr->nFilledLen;
> +avctx->extradata = av_malloc(avctx->extradata_size + 
> + AV_INPUT_BUFFER_PADDING_SIZE);
 It's preferalbe to use av_mallocz
>>>
>>> He was asked to do it this way as it's faster. No need to zero the 
>>> whole buffer if it's going to be written to immediately afterwards. 
>>> Only the trailing padding bytes needs to be zeroed.
>>
>> In this case I suspect there is an unneeded cast in the next line.
> 
>> It's very confusing to allocate with extra padding size, then memcpy the 
>> actual data size, then zero the padding data.
> 
>> IMO, the padding size is used for the bitstream optimized buffer read(32 or 
>> 64 bit for minimal at least). If it's memcpy, do we need malloc with extra 
>> AV_INPUT_BUFFER_PADDING_SIZE?
> 
> Thanks for everyone's advices and I am considering on how to make this not 
> confusing. Will update the patch later.
> BTW, it's a "she" :-).
> 
> Regards,
> Sun, Jing

Simply remove the void* cast in the memset() line. "avctx->extradata +
avctx->extradata_size" is acceptable as an argument.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Sun, Jing A
> Sent: Wednesday, July 31, 2019 10:16 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Tuesday, July 30, 2019 3:49 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> > > +AVCodec ff_libsvt_hevc_encoder = {
> > > +.name   = "libsvt_hevc",
> > > +.long_name  =
> NULL_IF_CONFIG_SMALL("SVT-HEVC(Scalable
> > Video Technology for HEVC) encoder"),
> > > +.priv_data_size = sizeof(SvtContext),
> > > +.type   = AVMEDIA_TYPE_VIDEO,
> > > +.id = AV_CODEC_ID_HEVC,
> > > +.init   = eb_enc_init,
> > > +.encode2= eb_encode_frame,
> > > +.close  = eb_enc_close,
> > > +.capabilities   = AV_CODEC_CAP_DELAY |
> > AV_CODEC_CAP_AUTO_THREADS,
> >
> > The code don't support to configure thread_count, so I think you'll
> > get the same result without AV_CODEC_CAP_AUTO_THREADS.
> 
> > This was pointed out by Mark Thompson on patch V4.
> > It is a problem how comment can be well addressed and avoid to be
> pointed out again and again.
> 
> I got started based on V5 and V6 is my first submission. Thanks for showing
> me the information. I am looking into it.

It was also mentioned in svt-av1 patch 
https://patchwork.ffmpeg.org/patch/13912/:
* Expose threads setting since AV_CODEC_CAP_AUTO_THREADS declared
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Limin 
Wang
Sent: Wednesday, July 31, 2019 7:05 AM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

On Tue, Jul 30, 2019 at 07:48:43PM +0200, Carl Eugen Hoyos wrote:
> Am Di., 30. Juli 2019 um 15:20 Uhr schrieb James Almer :
> >
> > On 7/30/2019 2:59 AM, Limin Wang wrote:
> > >> +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
> > >> +EB_BUFFERHEADERTYPE *header_ptr = NULL;
> > >> +
> > >> +svt_ret = EbH265EncStreamHeader(svt_enc->svt_handle, 
> > >> _ptr);
> > >> +if (svt_ret != EB_ErrorNone) {
> > >> +av_log(avctx, AV_LOG_ERROR, "Failed to build stream 
> > >> header\n");
> > >> +goto failed_init_encoder;
> > >> +}
> > >> +
> > >> +avctx->extradata_size = header_ptr->nFilledLen;
> > >> +avctx->extradata = av_malloc(avctx->extradata_size + 
> > >> + AV_INPUT_BUFFER_PADDING_SIZE);
> > > It's preferalbe to use av_mallocz
> >
> > He was asked to do it this way as it's faster. No need to zero the 
> > whole buffer if it's going to be written to immediately afterwards. 
> > Only the trailing padding bytes needs to be zeroed.
> 
> In this case I suspect there is an unneeded cast in the next line.

> It's very confusing to allocate with extra padding size, then memcpy the 
> actual data size, then zero the padding data.

> IMO, the padding size is used for the bitstream optimized buffer read(32 or 
> 64 bit for minimal at least). If it's memcpy, do we need malloc with extra 
> AV_INPUT_BUFFER_PADDING_SIZE?

Thanks for everyone's advices and I am considering on how to make this not 
confusing. Will update the patch later.
BTW, it's a "she" :-).

Regards,
Sun, Jing

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Li, 
Zhong
Sent: Tuesday, July 30, 2019 3:49 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

> > +AVCodec ff_libsvt_hevc_encoder = {
> > +.name   = "libsvt_hevc",
> > +.long_name  = NULL_IF_CONFIG_SMALL("SVT-HEVC(Scalable
> Video Technology for HEVC) encoder"),
> > +.priv_data_size = sizeof(SvtContext),
> > +.type   = AVMEDIA_TYPE_VIDEO,
> > +.id = AV_CODEC_ID_HEVC,
> > +.init   = eb_enc_init,
> > +.encode2= eb_encode_frame,
> > +.close  = eb_enc_close,
> > +.capabilities   = AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_AUTO_THREADS,
> 
> The code don't support to configure thread_count, so I think you'll 
> get the same result without AV_CODEC_CAP_AUTO_THREADS.

> This was pointed out by Mark Thompson on patch V4. 
> It is a problem how comment can be well addressed and avoid to be pointed out 
> again and again. 

I got started based on V5 and V6 is my first submission. Thanks for showing me 
the information. I am looking into it. 

Regards,
Sun, Jing

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-07-30 Thread Juan De León
Removed AVQuantizationParamsArray to prevent ambiguous memory allocation.
For simplicity, the side data will be allocated as an array of 
AVQuantizationParams and the last element of the array will have w and h set to 
0.

Better explained in the doc.
design doc: 
https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing

Signed-off-by: Juan De León 
---
 libavutil/Makefile  |   2 +
 libavutil/frame.h   |   6 ++
 libavutil/quantization_params.c |  41 +
 libavutil/quantization_params.h | 101 
 4 files changed, 150 insertions(+)
 create mode 100644 libavutil/quantization_params.c
 create mode 100644 libavutil/quantization_params.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 8a7a44e4b5..be1a9c3a9c 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -60,6 +60,7 @@ HEADERS = adler32.h   
  \
   pixdesc.h \
   pixelutils.h  \
   pixfmt.h  \
+  quantization_params.h \
   random_seed.h \
   rc4.h \
   rational.h\
@@ -140,6 +141,7 @@ OBJS = adler32.o
\
parseutils.o \
pixdesc.o\
pixelutils.o \
+   quantization_params.o\
random_seed.o\
rational.o   \
reverse.o\
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 5d3231e7bb..b64fd9c02c 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -179,6 +179,12 @@ enum AVFrameSideDataType {
  * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.
  */
 AV_FRAME_DATA_REGIONS_OF_INTEREST,
+/**
+ * To extract quantization parameters from supported decoders.
+ * The data is stored as AVQuantizationParamsArray type, described in
+ * libavuitl/quantization_params.h
+ */
+AV_FRAME_DATA_QUANTIZATION_PARAMS,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/quantization_params.c b/libavutil/quantization_params.c
new file mode 100644
index 00..7d8b0a4526
--- /dev/null
+++ b/libavutil/quantization_params.c
@@ -0,0 +1,41 @@
+/*
+ * 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 "libavutil/quantization_params.h"
+
+static const char* const QP_NAMES_H264[] = {"qp", "qpcb", "qpcr"};
+
+static const char* const QP_NAMES_VP9[] = {"qyac", "qydc", "quvdc", "quvac",
+   "qiyac", "qiydc", "qiuvdc", 
"qiuvac"};
+
+static const char* const QP_NAMES_AV1[] = {"qyac", "qydc", "qudc", "quac", 
"qvdc", "qvac",
+  "qiyac", "qiydc", "qiudc", "qiuac", 
"qivdc", "qivac"};
+
+const char* av_get_qp_type_string(enum AVExtractQPSupportedCodecs codec_id, 
int index)
+{
+switch (codec_id) {
+case AV_EXTRACT_QP_CODEC_ID_H264:
+return index < AV_QP_ARR_SIZE_H264 ? QP_NAMES_H264[index] :NULL;
+case AV_EXTRACT_QP_CODEC_ID_VP9:
+return index < AV_QP_ARR_SIZE_VP9  ? QP_NAMES_VP9[index]  :NULL;
+case AV_EXTRACT_QP_CODEC_ID_AV1:
+return index < AV_QP_ARR_SIZE_AV1  ? QP_NAMES_AV1[index]  :NULL;
+default:
+return NULL;
+}
+}
diff --git a/libavutil/quantization_params.h b/libavutil/quantization_params.h
new file mode 100644
index 00..23f4311293
--- /dev/null
+++ b/libavutil/quantization_params.h
@@ -0,0 +1,101 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute 

Re: [FFmpeg-devel] [PATCH v3] avutil/mips: Avoid instruction exception caused by gssqc1/gslqc1.

2019-07-30 Thread Shiyou Yin
>-Original Message-
>From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
>On Behalf Of
>Reimar D?ffinger
>Sent: Tuesday, July 30, 2019 2:54 AM
>To: FFmpeg development discussions and patches
>Subject: Re: [FFmpeg-devel] [PATCH v3] avutil/mips: Avoid instruction 
>exception caused by gssqc1/gslqc1.
>
>On 29.07.2019, at 11:54, "Shiyou Yin"  wrote:
>>>
>> DECLARE_ALIGNED is defined in ' libavutil/mem.h ' and related to compiler. 
>> No matter mips or x86,
>> it's definition is ' #define DECLARE_ALIGNED(n,t,v)  t __attribute__ 
>> ((aligned (n))) v' when build
>> with gcc or clang (Specific implementation within the compiler is not 
>> considered here.).
>> In libavcodec/x86, DECLARE_ALIGNED is used to define 8/16/32-byte aligned 
>> variable too.
>
>The aligned attribute does not work reliably with stack variables in some 
>cases.
>Compare with other code, I think you need to use LOCAL_ALIGNED_16 for the 
>stack variable.
>Yes, it might work in your test even with DECLARE_ALIGNED, but it might not be 
>robust.

You are right, LOCAL_ALIGNED_16 might be more robust.
In v5 LOCAL_ALIGNED_16 is used for the stack variables .


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5] avutil/mips: Avoid instruction exception caused by gssqc1/gslqc1.

2019-07-30 Thread Shiyou Yin
Ensure the address accesed by gssqc1/gslqc1 are 16-byte aligned.
---
 libavcodec/mips/simple_idct_mmi.c | 2 +-
 libavutil/mips/mmiutils.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mips/simple_idct_mmi.c 
b/libavcodec/mips/simple_idct_mmi.c
index 7f4bb74..73d797f 100644
--- a/libavcodec/mips/simple_idct_mmi.c
+++ b/libavcodec/mips/simple_idct_mmi.c
@@ -39,7 +39,7 @@
 #define COL_SHIFT 20
 #define DC_SHIFT 3
 
-DECLARE_ALIGNED(8, const int16_t, W_arr)[46] = {
+DECLARE_ALIGNED(16, const int16_t, W_arr)[46] = {
 W4,  W2,  W4,  W6,
 W1,  W3,  W5,  W7,
 W4,  W6, -W4, -W2,
diff --git a/libavutil/mips/mmiutils.h b/libavutil/mips/mmiutils.h
index 05f6b31..8f692e8 100644
--- a/libavutil/mips/mmiutils.h
+++ b/libavutil/mips/mmiutils.h
@@ -205,7 +205,7 @@
  * backup register
  */
 #define BACKUP_REG \
-  double temp_backup_reg[8];\
+  LOCAL_ALIGNED_16(double, temp_backup_reg, [8]);   \
   if (_MIPS_SIM == _ABI64)  \
 __asm__ volatile (  \
   "gssqc1   $f25,  $f24,   0x00(%[temp])  \n\t" \
-- 
2.1.0


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Limin Wang
On Tue, Jul 30, 2019 at 07:48:43PM +0200, Carl Eugen Hoyos wrote:
> Am Di., 30. Juli 2019 um 15:20 Uhr schrieb James Almer :
> >
> > On 7/30/2019 2:59 AM, Limin Wang wrote:
> > >> +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
> > >> +EB_BUFFERHEADERTYPE *header_ptr = NULL;
> > >> +
> > >> +svt_ret = EbH265EncStreamHeader(svt_enc->svt_handle, 
> > >> _ptr);
> > >> +if (svt_ret != EB_ErrorNone) {
> > >> +av_log(avctx, AV_LOG_ERROR, "Failed to build stream 
> > >> header\n");
> > >> +goto failed_init_encoder;
> > >> +}
> > >> +
> > >> +avctx->extradata_size = header_ptr->nFilledLen;
> > >> +avctx->extradata = av_malloc(avctx->extradata_size + 
> > >> AV_INPUT_BUFFER_PADDING_SIZE);
> > > It's preferalbe to use av_mallocz
> >
> > He was asked to do it this way as it's faster. No need to zero the whole
> > buffer if it's going to be written to immediately afterwards. Only the
> > trailing padding bytes needs to be zeroed.
> 
> In this case I suspect there is an unneeded cast in the next line.

It's very confusing to allocate with extra padding size, then memcpy the
actual data size, then zero the padding data.

IMO, the padding size is used for the bitstream optimized buffer read(32 or 64
bit for minimal at least). If it's memcpy, do we need malloc with extra 
AV_INPUT_BUFFER_PADDING_SIZE?


> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Limin Wang
On Tue, Jul 30, 2019 at 07:48:43PM +0200, Carl Eugen Hoyos wrote:
> Am Di., 30. Juli 2019 um 15:20 Uhr schrieb James Almer :
> >
> > On 7/30/2019 2:59 AM, Limin Wang wrote:
> > >> +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
> > >> +EB_BUFFERHEADERTYPE *header_ptr = NULL;
> > >> +
> > >> +svt_ret = EbH265EncStreamHeader(svt_enc->svt_handle, 
> > >> _ptr);
> > >> +if (svt_ret != EB_ErrorNone) {
> > >> +av_log(avctx, AV_LOG_ERROR, "Failed to build stream 
> > >> header\n");
> > >> +goto failed_init_encoder;
> > >> +}
> > >> +
> > >> +avctx->extradata_size = header_ptr->nFilledLen;
> > >> +avctx->extradata = av_malloc(avctx->extradata_size + 
> > >> AV_INPUT_BUFFER_PADDING_SIZE);
> > > It's preferalbe to use av_mallocz
> >
> > He was asked to do it this way as it's faster. No need to zero the whole
> > buffer if it's going to be written to immediately afterwards. Only the
> > trailing padding bytes needs to be zeroed.
> 
> In this case I suspect there is an unneeded cast in the next line.

FYI:
libavcodec/avcodec.h comments for the extradata_size
  * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
  * than extradata_size to avoid problems if it is read with the bitstream 
reader.
  * The bytewise contents of extradata must not depend on the architecture 
or CPU endianness.
  * Must be allocated with the av_malloc() family of functions.


> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavfi/zmq: Avoid mem copy past the end of input buffer

2019-07-30 Thread Andriy Gelman
From: Andriy Gelman 

---
 libavfilter/f_zmq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
index 89da5bef06..744c721305 100644
--- a/libavfilter/f_zmq.c
+++ b/libavfilter/f_zmq.c
@@ -139,7 +139,7 @@ static int recv_msg(AVFilterContext *ctx, char **buf, int 
*buf_size)
 ret = AVERROR(ENOMEM);
 goto end;
 }
-memcpy(*buf, zmq_msg_data(), *buf_size);
+memcpy(*buf, zmq_msg_data(), *buf_size - 1);
 (*buf)[*buf_size-1] = 0;
 
 end:
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] libavformat: Add ZeroMQ as a protocol option

2019-07-30 Thread Andriy Gelman
Hello, 

I've been looking for a way to stream to multiple clients without using a
multicast destination address or an external server. 

I believe ZeroMQ, which is a lightweight asynchronous messaging library, is a
possible option. It is already part of ffmpeg and can be used to
forward messages to filters in a filtergraph.

I've put together an initial patch which adds ZeroMQ as a protocol option. 

To run an example, you will need to compile with the --enable-libzmq option. 

One streaming instance can be started with:
$ ./ffmpeg -i /dev/video0 -vcodec libx264 -tune zerolatency -f mpegts 
zmq:tcp://127.0.0.1:

Multiple clients can then connect with:
$ ./ffplay zmq:tcp://127.0.0.1:

I would be happy to maintain the code. 

Thanks,
Andriy
>From 366f705945f9b2c40158730ec18ac9259bca2695 Mon Sep 17 00:00:00 2001
From: Andriy Gelman 
Date: Tue, 30 Jul 2019 14:39:32 -0400
Subject: [PATCH] libavformat: Add ZeroMQ as a protocol option

Currently multiple clients are only supported by using a
multicast destination address. An alternative is to stream to a server
which re-distributes the content.

This commit adds ZeroMQ as a protocol option, which allows
multiple clients to connect to a single ffmpeg instance.
---
 configure   |   2 +
 doc/general.texi|   1 +
 doc/protocols.texi  |  37 +
 libavformat/Makefile|   1 +
 libavformat/libzmq.c| 162 
 libavformat/protocols.c |   1 +
 6 files changed, 204 insertions(+)
 create mode 100644 libavformat/libzmq.c

diff --git a/configure b/configure
index 5a4f507246..4515341b06 100755
--- a/configure
+++ b/configure
@@ -3400,6 +3400,8 @@ libsrt_protocol_deps="libsrt"
 libsrt_protocol_select="network"
 libssh_protocol_deps="libssh"
 libtls_conflict="openssl gnutls mbedtls"
+libzmq_protocol_deps="libzmq"
+libzmq_protocol_select="network"
 
 # filters
 afftdn_filter_deps="avcodec"
diff --git a/doc/general.texi b/doc/general.texi
index 3c0c803449..b8e063268c 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1329,6 +1329,7 @@ performance on systems without hardware floating point 
support).
 @item TCP  @tab X
 @item TLS  @tab X
 @item UDP  @tab X
+@item ZMQ  @tab E
 @end multitable
 
 @code{X} means that the protocol is supported.
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 3e4e7af3d4..04d0fa8101 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1728,4 +1728,41 @@ Timeout in ms.
 Create the Unix socket in listening mode.
 @end table
 
+@section libzmq
+
+ZeroMQ asynchronous messaging library.
+
+This library supports unicast streaming to multiple clients without relying on
+an external server.
+
+The required syntax for streaming or connecting to a stream is:
+@example
+zmq:tcp://hostname:port
+@end example
+
+Example:
+Create a localhost stream on port :
+@example
+ffmpeg -re -i input -f mpegts zmq:tcp://127.0.0.1:
+@end example
+
+Multiple clients may connect and view the stream using:
+@example
+ffplay zmq:tcp://127.0.0.1:
+@end example
+
+@table @option
+@item zmq_timeout
+Set timeout (milliseconds) in the socket message receive call.
+By default it is set to 0. For more details see the timeout option
+in @url{http://api.zeromq.org/3-2:zmq-poll}.
+@end table
+
+The order with which the streaming and connecting instances start does not
+matter. This is handled by the ZeroMQ library.
+
+ffmpeg must be compiled with the --enable-libzmq option to support
+this protocol. See the compilation guide 
@url{https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu}
+for an example on how this option may be set.
+
 @c man end PROTOCOLS
diff --git a/libavformat/Makefile b/libavformat/Makefile
index a434b005a4..4a535429b7 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -631,6 +631,7 @@ OBJS-$(CONFIG_LIBRTMPTE_PROTOCOL)+= librtmp.o
 OBJS-$(CONFIG_LIBSMBCLIENT_PROTOCOL) += libsmbclient.o
 OBJS-$(CONFIG_LIBSRT_PROTOCOL)   += libsrt.o
 OBJS-$(CONFIG_LIBSSH_PROTOCOL)   += libssh.o
+OBJS-$(CONFIG_LIBZMQ_PROTOCOL)  += 
libzmq.o
 
 # libavdevice dependencies
 OBJS-$(CONFIG_IEC61883_INDEV)+= dv.o
diff --git a/libavformat/libzmq.c b/libavformat/libzmq.c
new file mode 100644
index 00..a7ef7fe77c
--- /dev/null
+++ b/libavformat/libzmq.c
@@ -0,0 +1,162 @@
+/*
+ * ZMQ URLProtocol
+ *
+ * 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 

[FFmpeg-devel] [PATCH 7/7] avformat/dashenc: fix writting the AV1 codec string in mp4 mode

2019-07-30 Thread James Almer
From https://aomediacodec.github.io/av1-isobmff/#codecsparam, the parameters
sample entry 4CC, profile, level, tier, and bitDepth are all mandatory fields.
All the other fields are optional, mutually inclusive (all or none).

Fixes ticket #8049

Signed-off-by: James Almer 
---
 libavformat/dashenc.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 50eba370d9..a3d8168110 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -35,6 +35,7 @@
 #include "libavutil/time.h"
 #include "libavutil/time_internal.h"
 
+#include "av1.h"
 #include "avc.h"
 #include "avformat.h"
 #include "avio_internal.h"
@@ -389,6 +390,21 @@ static void set_codec_str(AVFormatContext *s, 
AVCodecParameters *par,
 av_strlcatf(str, size, ".%02x%02x%02x",
 extradata[1], extradata[2], extradata[3]);
 av_free(tmpbuf);
+} else if (!strcmp(str, "av01")) {
+AV1SequenceParameters seq;
+if (!par->extradata_size)
+return;
+if (ff_av1_parse_seq_header(, par->extradata, par->extradata_size) 
< 0)
+return;
+
+av_strlcatf(str, size, ".%01u.%02u%s.%02u",
+seq.profile, seq.level, seq.tier ? "H" : "M", 
seq.bitdepth);
+if (seq.color_description_present_flag)
+av_strlcatf(str, size, ".%01u.%01u%01u%01u.%02u.%02u.%02u.%01u",
+seq.monochrome,
+seq.chroma_subsampling_x, seq.chroma_subsampling_y, 
seq.chroma_sample_position,
+seq.color_primaries, seq.transfer_characteristics, 
seq.matrix_coefficients,
+seq.color_range);
 }
 }
 
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 6/7] avformat/dashenc: add missing padding to the updated extradata

2019-07-30 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/dashenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index bded260806..50eba370d9 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1476,12 +1476,13 @@ static int update_stream_extradata(AVFormatContext *s, 
OutputStream *os,
 if (!extradata_size)
 return 0;
 
-new_extradata = av_malloc(extradata_size);
+new_extradata = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (!new_extradata)
 return AVERROR(ENOMEM);
 
 memcpy(new_extradata, extradata, extradata_size);
+memset(new_extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 os->ctx->streams[0]->codecpar->extradata = new_extradata;
 os->ctx->streams[0]->codecpar->extradata_size = extradata_size;
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/7] avformat/av1: rename some AV1SequenceParameters fields

2019-07-30 Thread James Almer
Cosmetic change.

Signed-off-by: James Almer 
---
 libavformat/av1.c | 24 
 libavformat/av1.h |  6 +++---
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavformat/av1.c b/libavformat/av1.c
index cc8918e577..43e40453c8 100644
--- a/libavformat/av1.c
+++ b/libavformat/av1.c
@@ -95,10 +95,10 @@ static inline void uvlc(GetBitContext *gb)
 static int parse_color_config(AV1SequenceParameters *seq_params, GetBitContext 
*gb)
 {
 seq_params->high_bitdepth = get_bits1(gb);
-if (seq_params->seq_profile == FF_PROFILE_AV1_PROFESSIONAL && 
seq_params->high_bitdepth)
+if (seq_params->profile == FF_PROFILE_AV1_PROFESSIONAL && 
seq_params->high_bitdepth)
 seq_params->twelve_bit = get_bits1(gb);
 
-if (seq_params->seq_profile == FF_PROFILE_AV1_HIGH)
+if (seq_params->profile == FF_PROFILE_AV1_HIGH)
 seq_params->monochrome = 0;
 else
 seq_params->monochrome = get_bits1(gb);
@@ -128,10 +128,10 @@ static int parse_color_config(AV1SequenceParameters 
*seq_params, GetBitContext *
 } else {
 seq_params->color_range = get_bits1(gb);
 
-if (seq_params->seq_profile == FF_PROFILE_AV1_MAIN) {
+if (seq_params->profile == FF_PROFILE_AV1_MAIN) {
 seq_params->chroma_subsampling_x = 1;
 seq_params->chroma_subsampling_y = 1;
-} else if (seq_params->seq_profile == FF_PROFILE_AV1_HIGH) {
+} else if (seq_params->profile == FF_PROFILE_AV1_HIGH) {
 seq_params->chroma_subsampling_x = 0;
 seq_params->chroma_subsampling_y = 0;
 } else {
@@ -172,14 +172,14 @@ static int parse_sequence_header(AV1SequenceParameters 
*seq_params, const uint8_
 
 memset(seq_params, 0, sizeof(*seq_params));
 
-seq_params->seq_profile = get_bits(, 3);
+seq_params->profile = get_bits(, 3);
 
 skip_bits1(); // still_picture
 reduced_still_picture_header = get_bits1();
 
 if (reduced_still_picture_header) {
-seq_params->seq_level_idx_0 = get_bits(, 5);
-seq_params->seq_tier_0 = 0;
+seq_params->level = get_bits(, 5);
+seq_params->tier = 0;
 } else {
 int initial_display_delay_present_flag, operating_points_cnt_minus_1;
 int decoder_model_info_present_flag, buffer_delay_length_minus_1;
@@ -229,8 +229,8 @@ static int parse_sequence_header(AV1SequenceParameters 
*seq_params, const uint8_
 }
 
 if (i == 0) {
-   seq_params->seq_level_idx_0 = seq_level_idx;
-   seq_params->seq_tier_0 = seq_tier;
+   seq_params->level = seq_level_idx;
+   seq_params->tier = seq_tier;
 }
 }
 }
@@ -380,9 +380,9 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, 
int size)
 
 put_bits(, 1, 1); // marker
 put_bits(, 7, 1); // version
-put_bits(, 3, seq_params.seq_profile);
-put_bits(, 5, seq_params.seq_level_idx_0);
-put_bits(, 1, seq_params.seq_tier_0);
+put_bits(, 3, seq_params.profile);
+put_bits(, 5, seq_params.level);
+put_bits(, 1, seq_params.tier);
 put_bits(, 1, seq_params.high_bitdepth);
 put_bits(, 1, seq_params.twelve_bit);
 put_bits(, 1, seq_params.monochrome);
diff --git a/libavformat/av1.h b/libavformat/av1.h
index e3ee667eb3..c07fb740e9 100644
--- a/libavformat/av1.h
+++ b/libavformat/av1.h
@@ -26,9 +26,9 @@
 #include "avio.h"
 
 typedef struct AV1SequenceParameters {
-uint8_t seq_profile;
-uint8_t seq_level_idx_0;
-uint8_t seq_tier_0;
+uint8_t profile;
+uint8_t level;
+uint8_t tier;
 uint8_t high_bitdepth;
 uint8_t twelve_bit;
 uint8_t monochrome;
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 5/7] avformat/dashenc: update stream extradata from packet side data

2019-07-30 Thread James Almer
codecpar->extradata is not going to change between packets. New extradata
is instead propagated using packet side data.

Signed-off-by: James Almer 
---
 libavformat/dashenc.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 64e2dac77e..bded260806 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1464,25 +1464,29 @@ static void find_index_range(AVFormatContext *s, const 
char *full_path,
 }
 
 static int update_stream_extradata(AVFormatContext *s, OutputStream *os,
-   AVCodecParameters *par,
-   AVRational *frame_rate)
+   AVPacket *pkt, AVRational *frame_rate)
 {
-uint8_t *extradata;
+uint8_t *extradata, *new_extradata;
+int extradata_size;
 
-if (os->ctx->streams[0]->codecpar->extradata_size || !par->extradata_size)
+if (os->ctx->streams[0]->codecpar->extradata_size)
 return 0;
 
-extradata = av_malloc(par->extradata_size);
+extradata = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, 
_size);
+if (!extradata_size)
+return 0;
+
+new_extradata = av_malloc(extradata_size);
 
-if (!extradata)
+if (!new_extradata)
 return AVERROR(ENOMEM);
 
-memcpy(extradata, par->extradata, par->extradata_size);
+memcpy(new_extradata, extradata, extradata_size);
 
-os->ctx->streams[0]->codecpar->extradata = extradata;
-os->ctx->streams[0]->codecpar->extradata_size = par->extradata_size;
+os->ctx->streams[0]->codecpar->extradata = new_extradata;
+os->ctx->streams[0]->codecpar->extradata_size = extradata_size;
 
-set_codec_str(s, par, frame_rate, os->codec_str, sizeof(os->codec_str));
+set_codec_str(s, os->ctx->streams[0]->codecpar, frame_rate, os->codec_str, 
sizeof(os->codec_str));
 
 return 0;
 }
@@ -1700,7 +1704,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 int64_t seg_end_duration, elapsed_duration;
 int ret;
 
-ret = update_stream_extradata(s, os, st->codecpar, >avg_frame_rate);
+ret = update_stream_extradata(s, os, pkt, >avg_frame_rate);
 if (ret < 0)
 return ret;
 
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/7] avforamt/av1: combine high_bitdepth and twelve_bit into a single bitdepth value

2019-07-30 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/av1.c | 15 +--
 libavformat/av1.h |  3 +--
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavformat/av1.c b/libavformat/av1.c
index 43e40453c8..b36c5e44ba 100644
--- a/libavformat/av1.c
+++ b/libavformat/av1.c
@@ -94,9 +94,12 @@ static inline void uvlc(GetBitContext *gb)
 
 static int parse_color_config(AV1SequenceParameters *seq_params, GetBitContext 
*gb)
 {
-seq_params->high_bitdepth = get_bits1(gb);
-if (seq_params->profile == FF_PROFILE_AV1_PROFESSIONAL && 
seq_params->high_bitdepth)
-seq_params->twelve_bit = get_bits1(gb);
+int twelve_bit = 0;
+int high_bitdepth = get_bits1(gb);
+if (seq_params->profile == FF_PROFILE_AV1_PROFESSIONAL && high_bitdepth)
+twelve_bit = get_bits1(gb);
+
+seq_params->bitdepth = 8 + (high_bitdepth * 2) + (twelve_bit * 2);
 
 if (seq_params->profile == FF_PROFILE_AV1_HIGH)
 seq_params->monochrome = 0;
@@ -135,7 +138,7 @@ static int parse_color_config(AV1SequenceParameters 
*seq_params, GetBitContext *
 seq_params->chroma_subsampling_x = 0;
 seq_params->chroma_subsampling_y = 0;
 } else {
-if (seq_params->twelve_bit) {
+if (twelve_bit) {
 seq_params->chroma_subsampling_x = get_bits1(gb);
 if (seq_params->chroma_subsampling_x)
 seq_params->chroma_subsampling_y = get_bits1(gb);
@@ -383,8 +386,8 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, 
int size)
 put_bits(, 3, seq_params.profile);
 put_bits(, 5, seq_params.level);
 put_bits(, 1, seq_params.tier);
-put_bits(, 1, seq_params.high_bitdepth);
-put_bits(, 1, seq_params.twelve_bit);
+put_bits(, 1, seq_params.bitdepth > 8);
+put_bits(, 1, seq_params.bitdepth == 12);
 put_bits(, 1, seq_params.monochrome);
 put_bits(, 1, seq_params.chroma_subsampling_x);
 put_bits(, 1, seq_params.chroma_subsampling_y);
diff --git a/libavformat/av1.h b/libavformat/av1.h
index c07fb740e9..9354889afe 100644
--- a/libavformat/av1.h
+++ b/libavformat/av1.h
@@ -29,8 +29,7 @@ typedef struct AV1SequenceParameters {
 uint8_t profile;
 uint8_t level;
 uint8_t tier;
-uint8_t high_bitdepth;
-uint8_t twelve_bit;
+uint8_t bitdepth;
 uint8_t monochrome;
 uint8_t chroma_subsampling_x;
 uint8_t chroma_subsampling_y;
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/7] avformat/av1: add color config values to AV1SequenceParameters

2019-07-30 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/av1.c | 32 ++--
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/libavformat/av1.c b/libavformat/av1.c
index 5fde8df97e..bd23891d26 100644
--- a/libavformat/av1.c
+++ b/libavformat/av1.c
@@ -86,6 +86,11 @@ typedef struct AV1SequenceParameters {
 uint8_t chroma_subsampling_x;
 uint8_t chroma_subsampling_y;
 uint8_t chroma_sample_position;
+uint8_t color_description_present_flag;
+uint8_t color_primaries;
+uint8_t transfer_characteristics;
+uint8_t matrix_coefficients;
+uint8_t color_range;
 } AV1SequenceParameters;
 
 static inline void uvlc(GetBitContext *gb)
@@ -106,8 +111,6 @@ static inline void uvlc(GetBitContext *gb)
 
 static int parse_color_config(AV1SequenceParameters *seq_params, GetBitContext 
*gb)
 {
-int color_primaries, transfer_characteristics, matrix_coefficients;
-
 seq_params->high_bitdepth = get_bits1(gb);
 if (seq_params->seq_profile == FF_PROFILE_AV1_PROFESSIONAL && 
seq_params->high_bitdepth)
 seq_params->twelve_bit = get_bits1(gb);
@@ -117,29 +120,30 @@ static int parse_color_config(AV1SequenceParameters 
*seq_params, GetBitContext *
 else
 seq_params->monochrome = get_bits1(gb);
 
-if (get_bits1(gb)) { // color_description_present_flag
-color_primaries  = get_bits(gb, 8);
-transfer_characteristics = get_bits(gb, 8);
-matrix_coefficients  = get_bits(gb, 8);
+seq_params->color_description_present_flag = get_bits1(gb);
+if (seq_params->color_description_present_flag) {
+seq_params->color_primaries  = get_bits(gb, 8);
+seq_params->transfer_characteristics = get_bits(gb, 8);
+seq_params->matrix_coefficients  = get_bits(gb, 8);
 } else {
-color_primaries  = AVCOL_PRI_UNSPECIFIED;
-transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
-matrix_coefficients  = AVCOL_SPC_UNSPECIFIED;
+seq_params->color_primaries  = AVCOL_PRI_UNSPECIFIED;
+seq_params->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
+seq_params->matrix_coefficients  = AVCOL_SPC_UNSPECIFIED;
 }
 
 if (seq_params->monochrome) {
-skip_bits1(gb); // color_range
+seq_params->color_range = get_bits1(gb);
 seq_params->chroma_subsampling_x = 1;
 seq_params->chroma_subsampling_y = 1;
 seq_params->chroma_sample_position = 0;
 return 0;
-} else if (color_primaries  == AVCOL_PRI_BT709 &&
-   transfer_characteristics == AVCOL_TRC_IEC61966_2_1 &&
-   matrix_coefficients  == AVCOL_SPC_RGB) {
+} else if (seq_params->color_primaries  == AVCOL_PRI_BT709 &&
+   seq_params->transfer_characteristics == AVCOL_TRC_IEC61966_2_1 
&&
+   seq_params->matrix_coefficients  == AVCOL_SPC_RGB) {
 seq_params->chroma_subsampling_x = 0;
 seq_params->chroma_subsampling_y = 0;
 } else {
-skip_bits1(gb); // color_range
+seq_params->color_range = get_bits1(gb);
 
 if (seq_params->seq_profile == FF_PROFILE_AV1_MAIN) {
 seq_params->chroma_subsampling_x = 1;
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/7] avformat/av1: split off sequence header parsing from the av1C writing function

2019-07-30 Thread James Almer
It will be used by the dash muxer

Signed-off-by: James Almer 
---
 libavformat/av1.c | 47 ++-
 libavformat/av1.h | 29 +
 2 files changed, 59 insertions(+), 17 deletions(-)

diff --git a/libavformat/av1.c b/libavformat/av1.c
index bd23891d26..cc8918e577 100644
--- a/libavformat/av1.c
+++ b/libavformat/av1.c
@@ -76,23 +76,6 @@ int ff_av1_filter_obus_buf(const uint8_t *buf, uint8_t 
**out, int *size)
 return ret;
 }
 
-typedef struct AV1SequenceParameters {
-uint8_t seq_profile;
-uint8_t seq_level_idx_0;
-uint8_t seq_tier_0;
-uint8_t high_bitdepth;
-uint8_t twelve_bit;
-uint8_t monochrome;
-uint8_t chroma_subsampling_x;
-uint8_t chroma_subsampling_y;
-uint8_t chroma_sample_position;
-uint8_t color_description_present_flag;
-uint8_t color_primaries;
-uint8_t transfer_characteristics;
-uint8_t matrix_coefficients;
-uint8_t color_range;
-} AV1SequenceParameters;
-
 static inline void uvlc(GetBitContext *gb)
 {
 int leading_zeros = 0;
@@ -301,6 +284,36 @@ static int parse_sequence_header(AV1SequenceParameters 
*seq_params, const uint8_
 return 0;
 }
 
+int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, 
int size)
+{
+int64_t obu_size;
+int start_pos, type, temporal_id, spatial_id;
+
+if (size <= 0)
+return AVERROR_INVALIDDATA;
+
+while (size > 0) {
+int len = parse_obu_header(buf, size, _size, _pos,
+   , _id, _id);
+if (len < 0)
+return len;
+
+switch (type) {
+case AV1_OBU_SEQUENCE_HEADER:
+if (!obu_size)
+return AVERROR_INVALIDDATA;
+
+return parse_sequence_header(seq, buf + start_pos, obu_size);
+default:
+break;
+}
+size -= len;
+buf  += len;
+}
+
+return AVERROR_INVALIDDATA;
+}
+
 int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size)
 {
 AVIOContext *seq_pb = NULL, *meta_pb = NULL;
diff --git a/libavformat/av1.h b/libavformat/av1.h
index dc872e5c59..e3ee667eb3 100644
--- a/libavformat/av1.h
+++ b/libavformat/av1.h
@@ -25,6 +25,23 @@
 
 #include "avio.h"
 
+typedef struct AV1SequenceParameters {
+uint8_t seq_profile;
+uint8_t seq_level_idx_0;
+uint8_t seq_tier_0;
+uint8_t high_bitdepth;
+uint8_t twelve_bit;
+uint8_t monochrome;
+uint8_t chroma_subsampling_x;
+uint8_t chroma_subsampling_y;
+uint8_t chroma_sample_position;
+uint8_t color_description_present_flag;
+uint8_t color_primaries;
+uint8_t transfer_characteristics;
+uint8_t matrix_coefficients;
+uint8_t color_range;
+} AV1SequenceParameters;
+
 /**
  * Filter out AV1 OBUs not meant to be present in ISOBMFF sample data and write
  * the resulting bitstream to the provided AVIOContext.
@@ -55,6 +72,18 @@ int ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, 
int size);
  */
 int ff_av1_filter_obus_buf(const uint8_t *buf, uint8_t **out, int *size);
 
+/**
+ * Parses a Sequence Header from the the provided buffer.
+ *
+ * @param seq pointer to the AV1SequenceParameters where the parsed values will
+ *be written
+ * @param buf input data buffer
+ * @param size size in bytes of the input data buffer
+ *
+ * @return >= 0 in case of success, a negative AVERROR code in case of failure
+ */
+int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, 
int size);
+
 /**
  * Writes AV1 extradata (Sequence Header and Metadata OBUs) to the provided
  * AVIOContext.
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/rl2: set dimensions

2019-07-30 Thread Michael Niedermayer
On Mon, Jul 29, 2019 at 10:36:15PM +0200, Jean-Baptiste Kempf wrote:
> Yo,
> 
> On Tue, Jul 23, 2019, at 04:42, Lynne wrote:
> > Jul 23, 2019, 12:00 AM by mich...@niedermayer.cc:
> > >> Moreover, if neither the codec, nor container can change the resolution, 
> > >> then how does that make anything different?
> > >
> > >> Please, stop it with those patches. It takes energy and some worry to 
> > >> have to open up the ML and scan it for bad patches from people who 
> > >> really should know better every time.
> > >
> > > Please stop with these attacks, this is just making people become
> > > mutually more aggressive and filled with hatred.
> > 
> > Of course I'm frustrated, I've been ignored.
> 
> Frustration should not allow this tone on this mailing list.
> 
> You may have a point on technical matters, but there are better ways to 
> express those, I believe.
> Because if everyone gets pissed/frustrated, then we won't get anything done.
> 
> If you know how to fix those things in a proper way, please tell us. I am 
> sure we could even sponsor you for doing this work.

Iam happy to fix things in a "better way" if a better way is suggested.

We should keep in mind though that often different people have different goals
and may see different things as "proper" or "better". I think above all
we need a bit more understanding that whatever one sees as best is exactly
that, ones own preferred solution. And best is not a absolute but a
function of many factors.
I think with something like that in mind we should be able to find
compromises which everyone would be happy with even if it is not everyones
"best" choice. And Iam happy to implement these compromises as long as the
environment stays friendly.

Thanks

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

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-07-30 Thread Juan De León
av_get_qp_type_string now returns const char
added descriptions to QP in enum
Tell me what you think.

design doc: 
https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing

Signed-off-by: Juan De León 
---
 libavutil/Makefile  |   2 +
 libavutil/frame.h   |   6 ++
 libavutil/quantization_params.c |  41 
 libavutil/quantization_params.h | 115 
 4 files changed, 164 insertions(+)
 create mode 100644 libavutil/quantization_params.c
 create mode 100644 libavutil/quantization_params.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 8a7a44e4b5..be1a9c3a9c 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -60,6 +60,7 @@ HEADERS = adler32.h   
  \
   pixdesc.h \
   pixelutils.h  \
   pixfmt.h  \
+  quantization_params.h \
   random_seed.h \
   rc4.h \
   rational.h\
@@ -140,6 +141,7 @@ OBJS = adler32.o
\
parseutils.o \
pixdesc.o\
pixelutils.o \
+   quantization_params.o\
random_seed.o\
rational.o   \
reverse.o\
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 5d3231e7bb..b64fd9c02c 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -179,6 +179,12 @@ enum AVFrameSideDataType {
  * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.
  */
 AV_FRAME_DATA_REGIONS_OF_INTEREST,
+/**
+ * To extract quantization parameters from supported decoders.
+ * The data is stored as AVQuantizationParamsArray type, described in
+ * libavuitl/quantization_params.h
+ */
+AV_FRAME_DATA_QUANTIZATION_PARAMS,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/quantization_params.c b/libavutil/quantization_params.c
new file mode 100644
index 00..7d8b0a4526
--- /dev/null
+++ b/libavutil/quantization_params.c
@@ -0,0 +1,41 @@
+/*
+ * 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 "libavutil/quantization_params.h"
+
+static const char* const QP_NAMES_H264[] = {"qp", "qpcb", "qpcr"};
+
+static const char* const QP_NAMES_VP9[] = {"qyac", "qydc", "quvdc", "quvac",
+   "qiyac", "qiydc", "qiuvdc", 
"qiuvac"};
+
+static const char* const QP_NAMES_AV1[] = {"qyac", "qydc", "qudc", "quac", 
"qvdc", "qvac",
+  "qiyac", "qiydc", "qiudc", "qiuac", 
"qivdc", "qivac"};
+
+const char* av_get_qp_type_string(enum AVExtractQPSupportedCodecs codec_id, 
int index)
+{
+switch (codec_id) {
+case AV_EXTRACT_QP_CODEC_ID_H264:
+return index < AV_QP_ARR_SIZE_H264 ? QP_NAMES_H264[index] :NULL;
+case AV_EXTRACT_QP_CODEC_ID_VP9:
+return index < AV_QP_ARR_SIZE_VP9  ? QP_NAMES_VP9[index]  :NULL;
+case AV_EXTRACT_QP_CODEC_ID_AV1:
+return index < AV_QP_ARR_SIZE_AV1  ? QP_NAMES_AV1[index]  :NULL;
+default:
+return NULL;
+}
+}
diff --git a/libavutil/quantization_params.h b/libavutil/quantization_params.h
new file mode 100644
index 00..561216ccbd
--- /dev/null
+++ b/libavutil/quantization_params.h
@@ -0,0 +1,115 @@
+/*
+ * 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 

Re: [FFmpeg-devel] [PATCH] avcodec/scpr: Use av_memcpy_backptr() in type 17 and 33

2019-07-30 Thread Michael Niedermayer
On Tue, Jul 30, 2019 at 09:19:58AM +0200, Paul B Mahol wrote:
> On Tue, Jul 30, 2019 at 2:12 AM Michael Niedermayer 
> wrote:
> 
> > This makes the changed code-path faster.
> >
> > Change not tested except with the fuzzer testcase as I found no other
> > testcase.
> >
> 
> You can test this easily be encoding solid color frame(s).

on linux ?

The only thing i see is windows software. I havnt really done anything
on windows for quite a while and i suspect using wine wouldnt be easier
either.

Thought someone has this setup already and could generate a testfile
trivially.
But if not ill add this to my todo

Thanks

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

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

2019-07-30 Thread Carl Eugen Hoyos
Am Di., 30. Juli 2019 um 21:04 Uhr schrieb Tomas Härdin :
>
> tis 2019-07-30 klockan 15:24 +0200 skrev Carl Eugen Hoyos:
> >
> >
> > > Am 30.07.2019 um 14:02 schrieb Tomas Härdin :
> > >
> > > fre 2019-07-26 klockan 18:45 +0200 skrev Nicolas Gaullier:
> > >
> > > > diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> > > > index 52194f54ef..501c21f220 100644
> > > > --- a/libavformat/wavdec.c
> > > > +++ b/libavformat/wavdec.c
> > > > @@ -41,6 +41,7 @@
> > > > #include "riff.h"
> > > > #include "w64.h"
> > > > #include "spdif.h"
> > > > +#include "s337m.h"
> > > >
> > > > typedef struct WAVDemuxContext {
> > > > const AVClass *class;
> > > > @@ -593,6 +594,8 @@ break_loop:
> > > > } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS &&
> > > > st-
> > > > > codecpar->channels > 2) {
> > > > st->codecpar->block_align *= st->codecpar->channels;
> > > > }
> > > > +if (s->dolby_e_probe)
> > > > +s337m_probe_stream(s, );
> > >
> > > The same goes here - these codecs should have corresponding TwoCCs.
> >
> > There is definitely no TwoCCs for these kind of files, same as for
> > DTS and AC-3. (I don't know about Dolby E in mxf.)
>
> MXF has a UL registered for Dolby-E:
> urn:smpte:ul:060e2b34.04010101.04020202.03021c00
> We should continue to reject files that don't use it

Imo, we should auto-detect as much as possible as it was done in
FFmpeg for the last decade.

> > A probe function is definitely needed, it maybe should be more
> > similar to existing lavfi probe functions though.
>
> It's easy enough to probe this in .wav since it only involved reading a
> few bytes from the data chunk, even if a proper TwoCC would be highly
> preferable.

There is no TwoCC.

> Both these situation could be handled by avformat_find_stream_info() if
> there's some way to detect that a file is using AES3 in advance, and
> delay setting codec_id until the first audio packet has been inspected

First step is a demuxer, wav can then use the probe function.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

2019-07-30 Thread Tomas Härdin
tis 2019-07-30 klockan 15:24 +0200 skrev Carl Eugen Hoyos:
> 
> 
> > Am 30.07.2019 um 14:02 schrieb Tomas Härdin :
> > 
> > fre 2019-07-26 klockan 18:45 +0200 skrev Nicolas Gaullier:
> > 
> > > diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> > > index 52194f54ef..501c21f220 100644
> > > --- a/libavformat/wavdec.c
> > > +++ b/libavformat/wavdec.c
> > > @@ -41,6 +41,7 @@
> > > #include "riff.h"
> > > #include "w64.h"
> > > #include "spdif.h"
> > > +#include "s337m.h"
> > > 
> > > typedef struct WAVDemuxContext {
> > > const AVClass *class;
> > > @@ -593,6 +594,8 @@ break_loop:
> > > } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS &&
> > > st-
> > > > codecpar->channels > 2) {
> > > st->codecpar->block_align *= st->codecpar->channels;
> > > }
> > > +if (s->dolby_e_probe)
> > > +s337m_probe_stream(s, );
> > 
> > The same goes here - these codecs should have corresponding TwoCCs.
> 
> There is definitely no TwoCCs for these kind of files, same as for
> DTS and AC-3. (I don't know about Dolby E in mxf.)

MXF has a UL registered for Dolby-E:
urn:smpte:ul:060e2b34.04010101.04020202.03021c00
We should continue to reject files that don't use it

> A probe function is definitely needed, it maybe should be more
> similar to existing lavfi probe functions though.

It's easy enough to probe this in .wav since it only involved reading a
few bytes from the data chunk, even if a proper TwoCC would be highly
preferable.

Both these situation could be handled by avformat_find_stream_info() if
there's some way to detect that a file is using AES3 in advance, and
delay setting codec_id until the first audio packet has been inspected

/Tomas

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-07-30 Thread Michael Niedermayer
On Tue, Jul 30, 2019 at 10:49:00AM -0700, Juan De León wrote:
> On Mon, Jul 29, 2019 at 7:59 PM James Almer  wrote:
> 
> > Side data, or more specifically, any AVBufferRef, must be a flat array.
> > You can't have pointers to some other allocated buffer within them since
> > you can't really control their lifetime.
> >
> Here's a snippet of how I'm doing it right now:
> // mb_xy = number of blocks in the frame
> size_t buf_size = sizeof(AVQuantizationParamsArray) + mb_xy *
> sizeof(AVQuantizationParams);
> AVBufferRef *buffer = av_buffer_alloc(buf_size);
> AVQuantizationParamsArray *params = (AVQuantizationParamsArray
> *)buffer->data;
> 
> // offset memory for qp_block_array in same buffer
> params->qp_block_array = (AVQuantizationParams*) (params + 1);

iam not sure this is safe, it would be better if there are no
pointers.
This would break if the AVQuantizationParamsArray is moved in memory
or cloned and the orginal freed or cloned and the clone changed
with the expextiaiion that the original stays unchanged

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

You can kill me, but you cannot change the truth.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-07-30 Thread Juan De León
On Tue, Jul 30, 2019 at 2:20 AM Andrey Semashev 
wrote:

> Just a thought. If you need codec ids and implement codec-specific
> functionality, then this whole thing probably belongs to libavcodec, not
> libavutil.
>

My understanding is that only encoders and decoders are supposed to be in
libavcodec.
I believe this fits better in libavutil for consistency.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/mpsubdec: Remove floating point usage

2019-07-30 Thread Michael Niedermayer
This makes the code bitexact between platforms.
Intermediate timestamps between frames are preserved.
The timebase is simplified.
Rounding differs from doubles in cases where timestamps/durations
are "funny"

Suggested-by: jb
Signed-off-by: Michael Niedermayer 
---
 libavformat/mpsubdec.c  | 84 ++---
 tests/ref/fate/sub-mpsub-frames |  4 +-
 2 files changed, 69 insertions(+), 19 deletions(-)

diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c
index a8217a4a61..3d8dcb35c2 100644
--- a/libavformat/mpsubdec.c
+++ b/libavformat/mpsubdec.c
@@ -27,6 +27,8 @@
 #include "internal.h"
 #include "subtitles.h"
 
+#define TSBASE 1000
+
 typedef struct {
 FFDemuxSubtitlesQueue q;
 } MPSubContext;
@@ -51,21 +53,55 @@ static int mpsub_probe(const AVProbeData *p)
 return 0;
 }
 
+static int parse_line(const char *line, int64_t *value, int64_t *value2)
+{
+int vi, p1, p2;
+
+for (vi = 0; vi < 2; vi++) {
+long long intval, fracval;
+int n = av_sscanf(line, "%lld%n.%lld%n", , , , );
+if (n <= 0 || intval < INT64_MIN / TSBASE || intval > INT64_MAX / 
TSBASE)
+return AVERROR_INVALIDDATA;
+
+intval *= TSBASE;
+
+if (n == 2) {
+if (fracval < 0)
+return AVERROR_INVALIDDATA;
+for (;p2 - p1 < 7 + 1; p1--)
+fracval *= 10;
+for (;p2 - p1 > 7 + 1; p1++)
+fracval /= 10;
+if (intval > 0) intval += fracval;
+elseintval -= fracval;
+line += p2;
+} else
+line += p1;
+
+*value = intval;
+
+value = value2;
+}
+
+return 0;
+}
+
 static int mpsub_read_header(AVFormatContext *s)
 {
 MPSubContext *mpsub = s->priv_data;
 AVStream *st;
 AVBPrint buf;
-AVRational pts_info = (AVRational){ 100, 1 }; // ts based by default
+AVRational pts_info = (AVRational){ TSBASE, 1 }; // ts based by default
 int res = 0;
-int multiplier = 100;
-double current_pts = 0;
+int64_t current_pts = 0;
+int i;
+int common_factor = 0;
 
 av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
 
 while (!avio_feof(s->pb)) {
 char line[1024];
-double start, duration;
+int64_t start, duration;
 int fps, len = ff_get_line(s->pb, line, sizeof(line));
 
 if (!len)
@@ -75,34 +111,48 @@ static int mpsub_read_header(AVFormatContext *s)
 
 if (sscanf(line, "FORMAT=%d", ) == 1 && fps > 3 && fps < 100) {
 /* frame based timing */
-pts_info = (AVRational){ fps, 1 };
-multiplier = 1;
-} else if (sscanf(line, "%lf %lf", , ) == 2) {
+pts_info = (AVRational){ TSBASE * fps, 1 };
+} else if (parse_line(line, , ) >= 0) {
 AVPacket *sub;
 const int64_t pos = avio_tell(s->pb);
 
 ff_subtitles_read_chunk(s->pb, );
 if (buf.len) {
-double ts = current_pts + start*multiplier;
 sub = ff_subtitles_queue_insert(>q, buf.str, buf.len, 
0);
 if (!sub) {
 res = AVERROR(ENOMEM);
 goto end;
 }
-if (!isfinite(ts) || ts < INT64_MIN || ts > INT64_MAX) {
-avpriv_request_sample(s, "Invalid ts\n");
-} else
-sub->pts = (int64_t)ts;
-if (!isfinite(duration) || duration * multiplier > INT_MAX || 
duration < 0) {
-avpriv_request_sample(s, "Invalid duration\n");
-} else
-sub->duration = (int)(duration * multiplier);
-current_pts += (start + duration) * multiplier;
+if (   current_pts < 0 && start < INT64_MIN - current_pts
+|| current_pts > 0 && start > INT64_MAX - current_pts) {
+res = AVERROR_INVALIDDATA;
+goto end;
+}
+sub->pts = current_pts + start;
+if (duration < 0 || sub->pts > INT64_MAX - duration) {
+res = AVERROR_INVALIDDATA;
+goto end;
+}
+sub->duration = duration;
+
+common_factor = av_gcd(duration, common_factor);
+common_factor = av_gcd(sub->pts, common_factor);
+
+current_pts = sub->pts + duration;
 sub->pos = pos;
 }
 }
 }
 
+if (common_factor > 1) {
+common_factor = av_gcd(pts_info.num, common_factor);
+for (i = 0; i < mpsub->q.nb_subs; i++) {
+mpsub->q.subs[i].pts  /= common_factor;
+mpsub->q.subs[i].duration /= common_factor;
+}
+pts_info.num /= common_factor;
+}
+
 st = avformat_new_stream(s, NULL);
 if (!st)
 return AVERROR(ENOMEM);
diff --git a/tests/ref/fate/sub-mpsub-frames 

Re: [FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-07-30 Thread Juan De León
On Mon, Jul 29, 2019 at 7:59 PM James Almer  wrote:

> Side data, or more specifically, any AVBufferRef, must be a flat array.
> You can't have pointers to some other allocated buffer within them since
> you can't really control their lifetime.
>
Here's a snippet of how I'm doing it right now:
// mb_xy = number of blocks in the frame
size_t buf_size = sizeof(AVQuantizationParamsArray) + mb_xy *
sizeof(AVQuantizationParams);
AVBufferRef *buffer = av_buffer_alloc(buf_size);
AVQuantizationParamsArray *params = (AVQuantizationParamsArray
*)buffer->data;

// offset memory for qp_block_array in same buffer
params->qp_block_array = (AVQuantizationParams*) (params + 1);

AVFrameSideData *sd;
sd = av_frame_new_side_data_from_buf(dst,
AV_FRAME_DATA_QUANTIZATION_PARAMS, buffer);

The idea is to keep everything in the same buffer so that it can all be
freed when AVFrameSideData is freed.
Let me know if this doesn't look right to you.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Carl Eugen Hoyos
Am Di., 30. Juli 2019 um 15:20 Uhr schrieb James Almer :
>
> On 7/30/2019 2:59 AM, Limin Wang wrote:
> >> +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
> >> +EB_BUFFERHEADERTYPE *header_ptr = NULL;
> >> +
> >> +svt_ret = EbH265EncStreamHeader(svt_enc->svt_handle, _ptr);
> >> +if (svt_ret != EB_ErrorNone) {
> >> +av_log(avctx, AV_LOG_ERROR, "Failed to build stream 
> >> header\n");
> >> +goto failed_init_encoder;
> >> +}
> >> +
> >> +avctx->extradata_size = header_ptr->nFilledLen;
> >> +avctx->extradata = av_malloc(avctx->extradata_size + 
> >> AV_INPUT_BUFFER_PADDING_SIZE);
> > It's preferalbe to use av_mallocz
>
> He was asked to do it this way as it's faster. No need to zero the whole
> buffer if it's going to be written to immediately afterwards. Only the
> trailing padding bytes needs to be zeroed.

In this case I suspect there is an unneeded cast in the next line.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag

2019-07-30 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of James Almer
> Sent: Tuesday, July 30, 2019 21:27
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add
> AV_CODEC_CAP_VARIABLE_DIMENSIONS flag
> 
> On 7/30/2019 6:33 AM, Carl Eugen Hoyos wrote:
> > Am Di., 30. Juli 2019 um 11:25 Uhr schrieb Fu, Linjie :
> >>
> >>> -Original Message-
> >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >>> Of Carl Eugen Hoyos
> >>> Sent: Tuesday, July 30, 2019 16:06
> >>> To: FFmpeg development discussions and patches  >>> de...@ffmpeg.org>
> >>> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add
> >>> AV_CODEC_CAP_VARIABLE_DIMENSIONS flag
> >>>
> >>> Am Di., 30. Juli 2019 um 06:46 Uhr schrieb Linjie Fu 
> >>> :
> 
>  Add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag to indicate
>  whether encoder supports variable dimension encoding.
> >>>
> >>> Isn't this about variable (or "changing") "resolutions" instead of
> dimensions?
> >>>
> >>
> >> Comment is welcome and "variable resolutions" is good.
> >
> >> But is "dimension" not quite suitable for the meaning of "variable size"?
> >
> > It took me some time to understand that "dimension" implies resolution,
> > especially since the FFmpeg documentation mentions resolution iirc.
> >
> > Carl Eugen
> 
> We have a AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS flag to signal
> resolution
> changes, so both words seem to be used interchangeably.
> 
> This also makes me think that the existing
> AV_CODEC_CAP_PARAM_CHANGE
> codec cap can be used for this already, without the need for a new one.
> It should a matter of using AV_PKT_DATA_PARAM_CHANGE packet side
> data
> afterwards in some form.

Thanks.
Saw the modification in fe75dc8583b65612f3a94144ee090e741dc926d5,
and it seems it was designed for decoder at first, like 
"rawdec/nellymoserdec/interplayvideo".

"Also define a codec capability for codecs that can handle
 parameters changed externally between decoded packets. "

Since currently no encoder is engaged with this flag, it's good for me to reuse 
this if there is no
other concern.

- linjie

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavf/scale_qsv: change alignment to be 16 bytes

2019-07-30 Thread Zhong Li
32 bytes alignment is not needed and increases the failure possibilty of
SFC (low power scaling mode)

Signed-off-by: Zhong Li 
---
 libavfilter/vf_scale_qsv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 499534e..3cc05b6 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -201,8 +201,8 @@ static int init_out_pool(AVFilterContext *ctx,
 out_frames_hwctx = out_frames_ctx->hwctx;
 
 out_frames_ctx->format= AV_PIX_FMT_QSV;
-out_frames_ctx->width = FFALIGN(out_width,  32);
-out_frames_ctx->height= FFALIGN(out_height, 32);
+out_frames_ctx->width = FFALIGN(out_width,  16);
+out_frames_ctx->height= FFALIGN(out_height, 16);
 out_frames_ctx->sw_format = out_format;
 out_frames_ctx->initial_pool_size = 4;
 
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] build: add support for building CUDA files with clang

2019-07-30 Thread Timo Rothenpieler

On 30.07.2019 09:51, Rodger Combs wrote:

This avoids using the CUDA SDK at all; instead, we provide a minimal
reimplementation of the basic functionality that lavfi actually uses.
It generates very similar code to what NVCC produces.

The header contains no implementation code derived from the SDK.
The function and type declarations are derived from the SDK only to the
extent required to build a compatible implementation. This is generally
accepted to qualify as fair use.

Because this option does not require the proprietary SDK, it does not require
the "--enable-nonfree" flag in configure.
---
  compat/cuda/cuda_runtime.h | 131 +
  configure  |  49 +-
  ffbuild/common.mak |   3 +-
  3 files changed, 166 insertions(+), 17 deletions(-)
  create mode 100644 compat/cuda/cuda_runtime.h

diff --git a/compat/cuda/cuda_runtime.h b/compat/cuda/cuda_runtime.h
new file mode 100644
index 00..dbe50f8711
--- /dev/null
+++ b/compat/cuda/cuda_runtime.h
@@ -0,0 +1,131 @@
+/*
+ * Minimum CUDA compatibility definitions header
+ *
+ * Copyright (c) 2019 Rodger Combs
+ *
+ * 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
+ */
+
+#ifndef AV_COMPAT_CUDA_CUDA_RUNTIME_H
+#define AV_COMPAT_CUDA_CUDA_RUNTIME_H
+
+// Common macros
+#define __global__ __attribute__((global))
+#define __device__ __attribute__((device))
+#define __device_builtin__ __attribute__((device_builtin))
+#define __align__(N) __attribute__((aligned(N)))
+#define __inline__ __inline__ __attribute__((always_inline))
+
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#define abs(x) ((x) < 0 ? -(x) : (x))
+
+#define atomicAdd(a, b) (__atomic_fetch_add(a, b, __ATOMIC_SEQ_CST))
+
+// Basic typedefs
+typedef __device_builtin__ unsigned long long cudaTextureObject_t;
+
+typedef struct __device_builtin__ __align__(2) uchar2
+{
+unsigned char x, y;
+} uchar2;
+
+typedef struct __device_builtin__ __align__(4) ushort2
+{
+unsigned short x, y;
+} ushort2;
+
+typedef struct __device_builtin__ uint3
+{
+unsigned int x, y, z;
+} uint3;
+
+typedef struct uint3 dim3;
+
+typedef struct __device_builtin__ __align__(8) int2
+{
+int x, y;
+} int2;
+
+typedef struct __device_builtin__ __align__(4) uchar4
+{
+unsigned char x, y, z, w;
+} uchar4;
+
+typedef struct __device_builtin__ __align__(8) ushort4
+{
+unsigned char x, y, z, w;
+} ushort4;
+
+typedef struct __device_builtin__ __align__(16) int4
+{
+int x, y, z, w;
+} int4;
+
+// Accessors for special registers
+#define GETCOMP(reg, comp) \
+asm("mov.u32 %0, %%" #reg "." #comp ";" : "=r"(tmp)); \
+ret.comp = tmp;
+
+#define GET(name, reg) static inline __device__ uint3 name() {\
+uint3 ret; \
+unsigned tmp; \
+GETCOMP(reg, x) \
+GETCOMP(reg, y) \
+GETCOMP(reg, z) \
+return ret; \
+}
+
+GET(getBlockIdx, ctaid)
+GET(getBlockDim, ntid)
+GET(getThreadIdx, tid)
+
+// Instead of externs for these registers, we turn access to them into calls 
into trivial ASM
+#define blockIdx (getBlockIdx())
+#define blockDim (getBlockDim())
+#define threadIdx (getThreadIdx())
+
+// Basic initializers (simple macros rather than inline functions)
+#define make_uchar2(a, b) ((uchar2){.x = a, .y = b})
+#define make_ushort2(a, b) ((ushort2){.x = a, .y = b})
+#define make_uchar4(a, b, c, d) ((uchar4){.x = a, .y = b, .z = c, .w = d})
+#define make_ushort4(a, b, c, d) ((ushort4){.x = a, .y = b, .z = c, .w = d})
+
+// Conversions from the tex instruction's 4-register output to various types
+#define TEX2D(type, ret) static inline __device__ void conv(type* out, 
unsigned a, unsigned b, unsigned c, unsigned d) {*out = (ret);}
+
+TEX2D(unsigned char, a & 0xFF)
+TEX2D(unsigned short, a & 0x)
+TEX2D(uchar2, make_uchar2(a & 0xFF, b & 0xFF))
+TEX2D(ushort2, make_ushort2(a & 0x, b & 0x))
+TEX2D(uchar4, make_uchar4(a & 0xFF, b & 0xFF, c & 0xFF, d & 0xFF))
+TEX2D(ushort4, make_ushort4(a & 0x, b & 0x, c & 0x, d & 0x))
+
+// Template calling tex instruction and converting the output to the selected 
type
+template 
+static inline __device__ T tex2D(cudaTextureObject_t texObject, float x, float 
y)
+{
+  T ret;
+  unsigned ret1, ret2, ret3, ret4;
+  

Re: [FFmpeg-devel] [PATCH 1/2] build: add support for building CUDA files with clang

2019-07-30 Thread Jean-Baptiste Kempf
On Tue, Jul 30, 2019, at 09:57, Rodger Combs wrote:
> This avoids using the CUDA SDK at all; instead, we provide a minimal
> reimplementation of the basic functionality that lavfi actually uses.
> It generates very similar code to what NVCC produces.

Very very cool.


-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

2019-07-30 Thread Carl Eugen Hoyos



> Am 30.07.2019 um 14:02 schrieb Tomas Härdin :
> 
> fre 2019-07-26 klockan 18:45 +0200 skrev Nicolas Gaullier:
> 
>> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
>> index 52194f54ef..501c21f220 100644
>> --- a/libavformat/wavdec.c
>> +++ b/libavformat/wavdec.c
>> @@ -41,6 +41,7 @@
>> #include "riff.h"
>> #include "w64.h"
>> #include "spdif.h"
>> +#include "s337m.h"
>> 
>> typedef struct WAVDemuxContext {
>> const AVClass *class;
>> @@ -593,6 +594,8 @@ break_loop:
>> } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st-
>>> codecpar->channels > 2) {
>> st->codecpar->block_align *= st->codecpar->channels;
>> }
>> +if (s->dolby_e_probe)
>> +s337m_probe_stream(s, );
> 
> The same goes here - these codecs should have corresponding TwoCCs.

There is definitely no TwoCCs for these kind of files, same as for DTS and 
AC-3. (I don't know about Dolby E in mxf.)
A probe function is definitely needed, it maybe should be more similar to 
existing lavfi probe functions though.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag

2019-07-30 Thread James Almer
On 7/30/2019 6:33 AM, Carl Eugen Hoyos wrote:
> Am Di., 30. Juli 2019 um 11:25 Uhr schrieb Fu, Linjie :
>>
>>> -Original Message-
>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>>> Of Carl Eugen Hoyos
>>> Sent: Tuesday, July 30, 2019 16:06
>>> To: FFmpeg development discussions and patches >> de...@ffmpeg.org>
>>> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add
>>> AV_CODEC_CAP_VARIABLE_DIMENSIONS flag
>>>
>>> Am Di., 30. Juli 2019 um 06:46 Uhr schrieb Linjie Fu :

 Add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag to indicate
 whether encoder supports variable dimension encoding.
>>>
>>> Isn't this about variable (or "changing") "resolutions" instead of 
>>> dimensions?
>>>
>>
>> Comment is welcome and "variable resolutions" is good.
> 
>> But is "dimension" not quite suitable for the meaning of "variable size"?
> 
> It took me some time to understand that "dimension" implies resolution,
> especially since the FFmpeg documentation mentions resolution iirc.
> 
> Carl Eugen

We have a AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS flag to signal resolution
changes, so both words seem to be used interchangeably.

This also makes me think that the existing AV_CODEC_CAP_PARAM_CHANGE
codec cap can be used for this already, without the need for a new one.
It should a matter of using AV_PKT_DATA_PARAM_CHANGE packet side data
afterwards in some form.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread James Almer
On 7/30/2019 2:59 AM, Limin Wang wrote:
>> +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
>> +EB_BUFFERHEADERTYPE *header_ptr = NULL;
>> +
>> +svt_ret = EbH265EncStreamHeader(svt_enc->svt_handle, _ptr);
>> +if (svt_ret != EB_ErrorNone) {
>> +av_log(avctx, AV_LOG_ERROR, "Failed to build stream header\n");
>> +goto failed_init_encoder;
>> +}
>> +
>> +avctx->extradata_size = header_ptr->nFilledLen;
>> +avctx->extradata = av_malloc(avctx->extradata_size + 
>> AV_INPUT_BUFFER_PADDING_SIZE);
> It's preferalbe to use av_mallocz

He was asked to do it this way as it's faster. No need to zero the whole
buffer if it's going to be written to immediately afterwards. Only the
trailing padding bytes needs to be zeroed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] lavfi/vf_thumbnail_cuda: fix operator precedence bug

2019-07-30 Thread Timo Rothenpieler

applied



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

2019-07-30 Thread Tomas Härdin
fre 2019-07-26 klockan 18:45 +0200 skrev Nicolas Gaullier:
> @@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
>   * - decoding: set by user
>   */
>  int skip_estimate_duration_from_pts;
> +
> +/**
> + * Probe dolby_e in PCM streams
> + * - encoding: unused
> + * - decoding: set by user
> + */
> +int dolby_e_probe;

This probably belongs in MXFContext and WAVDemuxContext

>  } AVFormatContext;
>  
>  #if FF_API_FORMAT_GET_SET
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index bb72fb9841..5b6eb9d756 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -56,6 +56,7 @@
>  #include "avformat.h"
>  #include "internal.h"
>  #include "mxf.h"
> +#include "s337m.h"
>  
>  #define MXF_MAX_CHUNK_SIZE (32 << 20)
>  
> @@ -302,6 +303,8 @@ typedef struct MXFMetadataReadTableEntry {
>  enum MXFMetadataSetType type;
>  } MXFMetadataReadTableEntry;
>  
> +static int mxf_read_packet_init = 0;

This definitely belongs in MXFContext

> @@ -3247,6 +3250,19 @@ static int mxf_read_header(AVFormatContext *s)
>  if ((ret = mxf_parse_structural_metadata(mxf)) < 0)
>  goto fail;
>  
> +if (mxf->fc->dolby_e_probe)
> +{
> +int i;
> +AVPacket *pkt = av_packet_alloc();
> +av_init_packet(pkt);
> +mxf_read_packet_init = 1;
> +for (i = 0; i < mxf->fc->nb_streams; i++)
> +mxf_read_packet(mxf->fc, pkt);

mxf_read_packet() has a whole bunch of side effects. I'm not so sure
you want to use it here.

> @@ -3539,7 +3555,9 @@ static int mxf_read_packet(AVFormatContext *s,
> AVPacket *pkt)
>  return ret;
>  }
>  } else {
> -ret = av_get_packet(s->pb, pkt, klv.length);
> +if (mxf_read_packet_init)
> +s337m_probe_stream(mxf->fc, );
> +ret = st->codecpar->codec_id == AV_CODEC_ID_DOLBY_E
> ? s337m_read_packet(s, pkt) : av_get_packet(s->pb, pkt, klv.length);

Are you sure there's no UL for this? Did you poke the company who
created the files to have them fix their encoder?

> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> index 52194f54ef..501c21f220 100644
> --- a/libavformat/wavdec.c
> +++ b/libavformat/wavdec.c
> @@ -41,6 +41,7 @@
>  #include "riff.h"
>  #include "w64.h"
>  #include "spdif.h"
> +#include "s337m.h"
>  
>  typedef struct WAVDemuxContext {
>  const AVClass *class;
> @@ -593,6 +594,8 @@ break_loop:
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st-
> >codecpar->channels > 2) {
>  st->codecpar->block_align *= st->codecpar->channels;
>  }
> +if (s->dolby_e_probe)
> +s337m_probe_stream(s, );

The same goes here - these codecs should have corresponding TwoCCs.
Send angry emails to your vendor.

/Tomas

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/mxfenc: Remove unused function

2019-07-30 Thread Tomas Härdin
tis 2019-07-30 klockan 09:12 +0200 skrev Andreas Rheinhardt:
> klv_ber_length is unused since 9e24b98b.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/mxfenc.c | 8 
>  1 file changed, 8 deletions(-)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 2e54320cf0..0cb0617919 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -542,14 +542,6 @@ static void mxf_write_refs_count(AVIOContext
> *pb, int ref_count)
>  avio_wb32(pb, 16);
>  }
>  
> -static int klv_ber_length(uint64_t len)
> -{
> -if (len < 128)
> -return 1;
> -else
> -return (av_log2(len) >> 3) + 2;
> -}

I think it might be preferably to have klv_encode_ber_length() make use
of it instead. That way we still have it around, in case we start
running into situations where we need to compute a BER length again

/Tomas


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavd/v4l2: produce a 0 byte packet when a dequeued buffer's size is unexpected

2019-07-30 Thread Alexander Strasser
On 2019-06-25 00:08 +0200, Alexander Strasser wrote:
> On 2019-06-05 22:04 +0200, Alexander Strasser wrote:
> > From: Stephan Hilb 
> >
> > Behave like we do for V4L2_BUF_FLAG_ERROR, implemented in commit 28f20d2ff4 
> > .
> >
> > For some devices (probably also related to the V4L driver implementation)
> > it happens that when invoking the ioctl DQBUF, the returned buffer is not
> > of the expected size. Here are two examples for such occurrences:
> >
> > [video4linux2,v4l2 @ 0x258b440] Dequeued v4l2 buffer contains 609596 
> > bytes, but 614400 were expected. Flags: 0x0001.
> > /dev/video1: Invalid data found when processing input
> >
> > [video4linux2,v4l2 @ 0x225f440] Dequeued v4l2 buffer contains 609508 
> > bytes, but 614400 were expected. Flags: 0x0001.
> > /dev/video1: Invalid data found when processing input
> >
> > For the ffmpeg CLI tool this means it will stop capturing and exit.
> >
> > The described behaviour was observed at least with one OmniVision USB
> > web cam and with some stk1160 devices.
> >
> > If you search the web for the error message, you will find quite a few
> > instances of this problem. Some of them experienced on other devices.
> >
> > Probably fixes ticket #4795
> >
> > Signed-off-by: Alexander Strasser 
> > ---
> >
> > This is exactly Stephan's patch except for the commit message.
> >
> > @Stephan: I hope you are OK with my wording in the new message.
> >
> > I contacted Giorgio off-list and also put him in Bcc for this email.
> >
> > He previously reacted, but he probably doesn't have enough time. So if
> > there are no objections I intent to commit in roughly a week if no
> > more issues are found and no objections are raised.
>
> Will push soon.

Pushed.

Not quite as soon as planned, but hopefully better late than never.

[...]

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/dsfdec: set packet pts/duration/pos correctly

2019-07-30 Thread Paul B Mahol
Hi,

patch attached.


0001-avformat-dsfdec-set-packet-pts-duration-pos-correctl.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [FFmpeg-cvslog] avcodec/cfhd: add bayer support

2019-07-30 Thread Michael Niedermayer
On Mon, Jul 29, 2019 at 06:22:29PM +0200, Carl Eugen Hoyos wrote:
> Am Mo., 29. Juli 2019 um 18:07 Uhr schrieb Paul B Mahol :
> >
> > On Mon, Jul 29, 2019 at 6:05 PM Carl Eugen Hoyos  wrote:
> >
> > > Am Mo., 29. Juli 2019 um 16:35 Uhr schrieb Paul B Mahol  > > >:
> > >
> > > > +static inline void process_bayer(AVFrame *frame)
> > > > +{
> > > > +const int linesize = frame->linesize[0];
> > > > +uint16_t *r = (uint16_t *)frame->data[0];
> > > > +uint16_t *g1 = (uint16_t *)(frame->data[0] + 2);
> > > > +uint16_t *g2 = (uint16_t *)(frame->data[0] + frame->linesize[0]);
> > > > +uint16_t *b = (uint16_t *)(frame->data[0] + frame->linesize[0] + 
> > > > 2);
> > > > +const int mid = 2048;
> > > > +
> > > > +for (int y = 0; y < frame->height >> 1; y++) {
> > > > +for (int x = 0; x < frame->width; x += 2) {
> > > > +int R, G1, G2, B;
> > > > +int g, rg, bg, gd;
> > > > +
> > > > +g  = r[x];
> > > > +rg = g1[x];
> > > > +bg = g2[x];
> > > > +gd = b[x];
> > > > +gd -= mid;
> > > > +
> > > > +R  = (rg - mid) * 2 + g;
> > > > +G1 = g + gd;
> > > > +G2 = g - gd;
> > > > +B  = (bg - mid) * 2 + g;
> > > > +
> > > > +R  = av_clip_uintp2(R  * 16, 16);
> > > > +G1 = av_clip_uintp2(G1 * 16, 16);
> > > > +G2 = av_clip_uintp2(G2 * 16, 16);
> > > > +B  = av_clip_uintp2(B  * 16, 16);
> > > > +
> > > > +r[x]  = R;
> > > > +g1[x] = G1;
> > > > +g2[x] = G2;
> > > > +b[x]  = B;
> > >
> > > Doesn't this mean you have to disable direct rendering?
> > >
> >
> > Nope. Do you even know what is DR for?
> 
> The way I remembered was that there are access limitations for
> direct rendering.

Prior to 2.0 there where buffer_hints that allowed a decoder to
specify that it would not read from its buffer.

One could set FF_BUFFER_HINTS_VALID without FF_BUFFER_HINTS_READABLE
to indicate that a decoder would not need to read from a frame. (some
decoders did this IIRC)
So the allocation code could place the frame in final memory even if that
would be slow or impossible to read.
I do not know if that was actually done by any user applications but
it was supported.

Thanks

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] fate: add hls_list_size fate test case

2019-07-30 Thread Liu Steven
Ignore this patch please.

> 在 2019年7月30日,下午5:07,Steven Liu  写道:
> 
> Signed-off-by: Steven Liu 
> ---
> tests/fate/hlsenc.mak|  11 +
> tests/ref/fate/hls-list-size | 618 +++
> 2 files changed, 629 insertions(+)
> create mode 100644 tests/ref/fate/hls-list-size
> 
> diff --git a/tests/fate/hlsenc.mak b/tests/fate/hlsenc.mak
> index e81fb5411a..69aa151530 100644
> --- a/tests/fate/hlsenc.mak
> +++ b/tests/fate/hlsenc.mak
> @@ -52,3 +52,14 @@ FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER 
> MPEGTS_DEMUXER AEVALSRC_FIL
> fate-hls-segment-size: tests/data/hls_segment_size.m3u8
> fate-hls-segment-size: CMD = framecrc -flags +bitexact -i 
> $(TARGET_PATH)/tests/data/hls_segment_size.m3u8 -vf setpts=N*23
> 
> +tests/data/hls_list_size.m3u8: TAG = GEN
> +tests/data/hls_list_size.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
> + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
> + -f lavfi -i "aevalsrc=cos(2*PI*t)*sin(2*PI*(440+4*t)*t):d=20" -f hls 
> -hls_time 4 -map 0 \
> + -hls_list_size 4 -codec:a mp2fixed -hls_segment_filename 
> $(TARGET_PATH)/tests/data/hls_list_size_%d.ts \
> + $(TARGET_PATH)/tests/data/hls_list_size.m3u8 2>/dev/null
> +
> +FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
> AEVALSRC_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += fate-hls-list-size
> +fate-hls-list-size: tests/data/hls_list_size.m3u8
> +fate-hls-list-size: CMD = framecrc -flags +bitexact -i 
> $(TARGET_PATH)/tests/data/hls_list_size.m3u8 -vf setpts=N*23
> +
> diff --git a/tests/ref/fate/hls-list-size b/tests/ref/fate/hls-list-size
> new file mode 100644
> index 00..cf7fb9fe3a
> --- /dev/null
> +++ b/tests/ref/fate/hls-list-size
> @@ -0,0 +1,618 @@
> +#tb 0: 1/44100
> +#media_type 0: audio
> +#codec_id 0: pcm_s16le
> +#sample_rate 0: 44100
> +#channel_layout 0: 4
> +#channel_layout_name 0: mono
> +0,  0,  0, 1152, 2304, 0x9ce3278a
> +0,   1152,   1152, 1152, 2304, 0x5cd17b17
> +0,   2304,   2304, 1152, 2304, 0x8aec82c5
> +0,   3456,   3456, 1152, 2304, 0xe8ce8fbc
> +0,   4608,   4608, 1152, 2304, 0x262c69da
> +0,   5760,   5760, 1152, 2304, 0x6afc7ad6
> +0,   6912,   6912, 1152, 2304, 0x9f2a7370
> +0,   8064,   8064, 1152, 2304, 0x88fe7bcc
> +0,   9216,   9216, 1152, 2304, 0x228b8bab
> +0,  10368,  10368, 1152, 2304, 0xd87f8c71
> +0,  11520,  11520, 1152, 2304, 0x82989151
> +0,  12672,  12672, 1152, 2304, 0x1e0f7aae
> +0,  13824,  13824, 1152, 2304, 0xbdcc7d72
> +0,  14976,  14976, 1152, 2304, 0xa7af8875
> +0,  16128,  16128, 1152, 2304, 0xb9aa7834
> +0,  17280,  17280, 1152, 2304, 0xea8e6e76
> +0,  18432,  18432, 1152, 2304, 0x7bbe6bae
> +0,  19584,  19584, 1152, 2304, 0x2bbd817f
> +0,  20736,  20736, 1152, 2304, 0xccd46c86
> +0,  21888,  21888, 1152, 2304, 0x603178d2
> +0,  23040,  23040, 1152, 2304, 0xa2d283d7
> +0,  24192,  24192, 1152, 2304, 0xc6e97caa
> +0,  25344,  25344, 1152, 2304, 0x67e06e6d
> +0,  26496,  26496, 1152, 2304, 0x27c47d51
> +0,  27648,  27648, 1152, 2304, 0x17f47cd7
> +0,  28800,  28800, 1152, 2304, 0xbedb75b0
> +0,  29952,  29952, 1152, 2304, 0xeb1f72fd
> +0,  31104,  31104, 1152, 2304, 0x6dae79e9
> +0,  32256,  32256, 1152, 2304, 0x90e36f0e
> +0,  33408,  33408, 1152, 2304, 0xe0748431
> +0,  34560,  34560, 1152, 2304, 0xa78f6d76
> +0,  35712,  35712, 1152, 2304, 0xa9cf7cd4
> +0,  36864,  36864, 1152, 2304, 0xfa12796c
> +0,  38016,  38016, 1152, 2304, 0x73d47c88
> +0,  39168,  39168, 1152, 2304, 0xec8c74ef
> +0,  40320,  40320, 1152, 2304, 0x6eda793d
> +0,  41472,  41472, 1152, 2304, 0xd26c7e3f
> +0,  42624,  42624, 1152, 2304, 0xd7e3788d
> +0,  43776,  43776, 1152, 2304, 0x4f26748c
> +0,  44928,  44928, 1152, 2304, 0x7ce07ec0
> +0,  46080,  46080, 1152, 2304, 0x72ab7bba
> +0,  47232,  47232, 1152, 2304, 0x287b73b9
> +0,  48384,  48384, 1152, 2304, 0x78b8822b
> +0,  49536,  49536, 1152, 2304, 0x9cc46ff6
> +0,  50688,  50688, 1152, 2304, 0x2fdd7bb5
> +0,  51840,  51840, 1152, 2304, 0x03118776
> +0,  52992,  52992, 1152, 2304, 0x1f0e7403
> +0,  54144,  54144, 1152, 2304, 0xfbd97c1e
> +0,  55296,  55296, 1152, 2304, 0xcd118405
> +0,  56448,  56448, 1152, 2304, 0xb5ce78b0
> +0,  57600,  57600, 1152, 2304, 0x87b27d88
> +0,   

Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag

2019-07-30 Thread Carl Eugen Hoyos
Am Di., 30. Juli 2019 um 11:25 Uhr schrieb Fu, Linjie :
>
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Carl Eugen Hoyos
> > Sent: Tuesday, July 30, 2019 16:06
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add
> > AV_CODEC_CAP_VARIABLE_DIMENSIONS flag
> >
> > Am Di., 30. Juli 2019 um 06:46 Uhr schrieb Linjie Fu :
> > >
> > > Add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag to indicate
> > > whether encoder supports variable dimension encoding.
> >
> > Isn't this about variable (or "changing") "resolutions" instead of 
> > dimensions?
> >
>
> Comment is welcome and "variable resolutions" is good.

> But is "dimension" not quite suitable for the meaning of "variable size"?

It took me some time to understand that "dimension" implies resolution,
especially since the FFmpeg documentation mentions resolution iirc.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag

2019-07-30 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Carl Eugen Hoyos
> Sent: Tuesday, July 30, 2019 16:06
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add
> AV_CODEC_CAP_VARIABLE_DIMENSIONS flag
> 
> Am Di., 30. Juli 2019 um 06:46 Uhr schrieb Linjie Fu :
> >
> > Add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag to indicate
> > whether encoder supports variable dimension encoding.
> 
> Isn't this about variable (or "changing") "resolutions" instead of dimensions?
> 

Comment is welcome and "variable resolutions" is good.
But is "dimension" not quite suitable for the meaning of "variable size"?

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-07-30 Thread Andrey Semashev

On 7/30/19 12:11 PM, Andrey Semashev wrote:

On 7/30/19 5:39 AM, Juan De León wrote:
I tried to fix all you suggested, please have a look and let me know 
what you think.


design doc: 
https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing 



Signed-off-by: Juan De León 
---
  libavutil/Makefile  |   2 +
  libavutil/frame.h   |   6 ++
  libavutil/quantization_params.c |  42 
  libavutil/quantization_params.h | 114 
  4 files changed, 164 insertions(+)
  create mode 100644 libavutil/quantization_params.c
  create mode 100644 libavutil/quantization_params.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 8a7a44e4b5..be1a9c3a9c 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -60,6 +60,7 @@ HEADERS = 
adler32.h \

pixdesc.h \

pixelutils.h  \

pixfmt.h  \
+  
quantization_params.h \

random_seed.h \

rc4.h \

rational.h    \
@@ -140,6 +141,7 @@ OBJS = 
adler32.o    \
 
parseutils.o \
 
pixdesc.o    \
 
pixelutils.o \
+   
quantization_params.o    \
 
random_seed.o    \
 
rational.o   \
 
reverse.o    \

diff --git a/libavutil/frame.h b/libavutil/frame.h
index 5d3231e7bb..b64fd9c02c 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -179,6 +179,12 @@ enum AVFrameSideDataType {
   * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.

   */
  AV_FRAME_DATA_REGIONS_OF_INTEREST,
+    /**
+ * To extract quantization parameters from supported decoders.
+ * The data is stored as AVQuantizationParamsArray type, 
described in

+ * libavuitl/quantization_params.h
+ */
+    AV_FRAME_DATA_QUANTIZATION_PARAMS,
  };
  enum AVActiveFormatDescription {
diff --git a/libavutil/quantization_params.c 
b/libavutil/quantization_params.c

new file mode 100644
index 00..fc51b55eee
--- /dev/null
+++ b/libavutil/quantization_params.c
@@ -0,0 +1,42 @@
+/*
+ * 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 "libavutil/quantization_params.h"
+#include "libavutil/mem.h"
+
+static const char* const QP_NAMES_H264[] = {"qpy", "qpuv"};
+
+static const char* const QP_NAMES_VP9[] = {"qyac", "qydc", "quvdc", 
"quvac",
+   "qiyac", "qiydc", 
"qiuvdc", "qiuvac"};

+
+static const char* const QP_NAMES_AV1[] = {"qydc", "qyac", "qudc", 
"quac", "qvdc", "qvac",
+  "qiydc", "qiyac", "qiudc", 
"qiuac", "qivdc", "qivac"};

+
+char* av_get_qp_type_string(enum AVExtractQPSupportedCodecs codec_id, 
int index)

+{
+    switch (codec_id) {
+    case AV_EXTRACT_QP_CODEC_ID_H264:
+    return index < AV_QP_ARR_SIZE_H264 ? 
av_strdup(QP_NAMES_H264[index]) :NULL;

+    case AV_EXTRACT_QP_CODEC_ID_VP9:
+    return index < AV_QP_ARR_SIZE_VP9  ? 
av_strdup(QP_NAMES_VP9[index])  :NULL;

+    case AV_EXTRACT_QP_CODEC_ID_AV1:
+    return index < AV_QP_ARR_SIZE_AV1  ? 
av_strdup(QP_NAMES_AV1[index])  :NULL;

+    default:
+    return NULL;
+    }
+}


Why strdup here? Why not return the pointer from the static array?

If you really do intend to strdup, the function documentation should 
state clearly that the caller is supposed to av_free the returned pointer.


diff --git a/libavutil/quantization_params.h 

Re: [FFmpeg-devel] [PATCH] Extract QP from h264 encoded videos

2019-07-30 Thread Andrey Semashev

On 7/30/19 5:39 AM, Juan De León wrote:

I tried to fix all you suggested, please have a look and let me know what you 
think.

design doc: 
https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing

Signed-off-by: Juan De León 
---
  libavutil/Makefile  |   2 +
  libavutil/frame.h   |   6 ++
  libavutil/quantization_params.c |  42 
  libavutil/quantization_params.h | 114 
  4 files changed, 164 insertions(+)
  create mode 100644 libavutil/quantization_params.c
  create mode 100644 libavutil/quantization_params.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 8a7a44e4b5..be1a9c3a9c 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -60,6 +60,7 @@ HEADERS = adler32.h   
  \
pixdesc.h \
pixelutils.h  \
pixfmt.h  \
+  quantization_params.h \
random_seed.h \
rc4.h \
rational.h\
@@ -140,6 +141,7 @@ OBJS = adler32.o
\
 parseutils.o \
 pixdesc.o\
 pixelutils.o \
+   quantization_params.o\
 random_seed.o\
 rational.o   \
 reverse.o\
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 5d3231e7bb..b64fd9c02c 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -179,6 +179,12 @@ enum AVFrameSideDataType {
   * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.
   */
  AV_FRAME_DATA_REGIONS_OF_INTEREST,
+/**
+ * To extract quantization parameters from supported decoders.
+ * The data is stored as AVQuantizationParamsArray type, described in
+ * libavuitl/quantization_params.h
+ */
+AV_FRAME_DATA_QUANTIZATION_PARAMS,
  };
  
  enum AVActiveFormatDescription {

diff --git a/libavutil/quantization_params.c b/libavutil/quantization_params.c
new file mode 100644
index 00..fc51b55eee
--- /dev/null
+++ b/libavutil/quantization_params.c
@@ -0,0 +1,42 @@
+/*
+ * 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 "libavutil/quantization_params.h"
+#include "libavutil/mem.h"
+
+static const char* const QP_NAMES_H264[] = {"qpy", "qpuv"};
+
+static const char* const QP_NAMES_VP9[] = {"qyac", "qydc", "quvdc", "quvac",
+   "qiyac", "qiydc", "qiuvdc", 
"qiuvac"};
+
+static const char* const QP_NAMES_AV1[] = {"qydc", "qyac", "qudc", "quac", "qvdc", 
"qvac",
+  "qiydc", "qiyac", "qiudc", "qiuac", "qivdc", 
"qivac"};
+
+char* av_get_qp_type_string(enum AVExtractQPSupportedCodecs codec_id, int 
index)
+{
+switch (codec_id) {
+case AV_EXTRACT_QP_CODEC_ID_H264:
+return index < AV_QP_ARR_SIZE_H264 ? 
av_strdup(QP_NAMES_H264[index]) :NULL;
+case AV_EXTRACT_QP_CODEC_ID_VP9:
+return index < AV_QP_ARR_SIZE_VP9  ? 
av_strdup(QP_NAMES_VP9[index])  :NULL;
+case AV_EXTRACT_QP_CODEC_ID_AV1:
+return index < AV_QP_ARR_SIZE_AV1  ? 
av_strdup(QP_NAMES_AV1[index])  :NULL;
+default:
+return NULL;
+}
+}
diff --git a/libavutil/quantization_params.h b/libavutil/quantization_params.h
new file mode 100644
index 00..d123aade3b
--- /dev/null
+++ b/libavutil/quantization_params.h
@@ -0,0 +1,114 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the 

[FFmpeg-devel] [PATCH] FATE: add hls single file mode test case

2019-07-30 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 tests/fate/hlsenc.mak |  11 +
 tests/ref/fate/hls-segment-single | 772 ++
 2 files changed, 783 insertions(+)
 create mode 100644 tests/ref/fate/hls-segment-single

diff --git a/tests/fate/hlsenc.mak b/tests/fate/hlsenc.mak
index 98d67f96df..ff58094252 100644
--- a/tests/fate/hlsenc.mak
+++ b/tests/fate/hlsenc.mak
@@ -52,6 +52,17 @@ FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER 
MPEGTS_DEMUXER AEVALSRC_FIL
 fate-hls-segment-size: tests/data/hls_segment_size.m3u8
 fate-hls-segment-size: CMD = framecrc -flags +bitexact -i 
$(TARGET_PATH)/tests/data/hls_segment_size.m3u8 -vf setpts=N*23
 
+tests/data/hls_segment_single.m3u8: TAG = GEN
+tests/data/hls_segment_single.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
+   $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
+   -f lavfi -i "aevalsrc=cos(2*PI*t)*sin(2*PI*(440+4*t)*t):d=20" -f hls 
-hls_flags single_file -map 0 \
+   -hls_list_size 0 -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/hls_segment_single.ts \
+   $(TARGET_PATH)/tests/data/hls_segment_single.m3u8 2>/dev/null
+
+FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += fate-hls-segment-single
+fate-hls-segment-single: tests/data/hls_segment_single.m3u8
+fate-hls-segment-single: CMD = framecrc -flags +bitexact -i 
$(TARGET_PATH)/tests/data/hls_segment_single.m3u8 -vf setpts=N*23
+
 tests/data/hls_init_time.m3u8: TAG = GEN
 tests/data/hls_init_time.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
diff --git a/tests/ref/fate/hls-segment-single 
b/tests/ref/fate/hls-segment-single
new file mode 100644
index 00..ee3c7b2c62
--- /dev/null
+++ b/tests/ref/fate/hls-segment-single
@@ -0,0 +1,772 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout 0: 4
+#channel_layout_name 0: mono
+0,  0,  0, 1152, 2304, 0x907cb7fa
+0,   1152,   1152, 1152, 2304, 0xb8dc7525
+0,   2304,   2304, 1152, 2304, 0x3e7d6905
+0,   3456,   3456, 1152, 2304, 0xef47877b
+0,   4608,   4608, 1152, 2304, 0xfe916b7e
+0,   5760,   5760, 1152, 2304, 0xe3d08cde
+0,   6912,   6912, 1152, 2304, 0xff7f86cf
+0,   8064,   8064, 1152, 2304, 0x843e6f95
+0,   9216,   9216, 1152, 2304, 0x81577c26
+0,  10368,  10368, 1152, 2304, 0x04a085d5
+0,  11520,  11520, 1152, 2304, 0x1c5a76f5
+0,  12672,  12672, 1152, 2304, 0x4ee78623
+0,  13824,  13824, 1152, 2304, 0x8ec861dc
+0,  14976,  14976, 1152, 2304, 0x0ca179d8
+0,  16128,  16128, 1152, 2304, 0xc6da750f
+0,  17280,  17280, 1152, 2304, 0xf6bf79b5
+0,  18432,  18432, 1152, 2304, 0x97b88a43
+0,  19584,  19584, 1152, 2304, 0xf13c7b9c
+0,  20736,  20736, 1152, 2304, 0xdfba83af
+0,  21888,  21888, 1152, 2304, 0xc9467d4b
+0,  23040,  23040, 1152, 2304, 0xbbb58e2b
+0,  24192,  24192, 1152, 2304, 0x3a1078ea
+0,  25344,  25344, 1152, 2304, 0xe9587a5c
+0,  26496,  26496, 1152, 2304, 0xef5a8039
+0,  27648,  27648, 1152, 2304, 0x9d5f782f
+0,  28800,  28800, 1152, 2304, 0x1a548291
+0,  29952,  29952, 1152, 2304, 0x07517701
+0,  31104,  31104, 1152, 2304, 0x78127d6e
+0,  32256,  32256, 1152, 2304, 0x62e2788a
+0,  33408,  33408, 1152, 2304, 0x29397ad9
+0,  34560,  34560, 1152, 2304, 0x45da82d6
+0,  35712,  35712, 1152, 2304, 0x8ed66e51
+0,  36864,  36864, 1152, 2304, 0x660775cd
+0,  38016,  38016, 1152, 2304, 0x802c767a
+0,  39168,  39168, 1152, 2304, 0xcc055840
+0,  40320,  40320, 1152, 2304, 0x701b7eaf
+0,  41472,  41472, 1152, 2304, 0x8290749f
+0,  42624,  42624, 1152, 2304, 0x2c7b7d30
+0,  43776,  43776, 1152, 2304, 0xe4f17743
+0,  44928,  44928, 1152, 2304, 0x0e747d6e
+0,  46080,  46080, 1152, 2304, 0xbe7775a0
+0,  47232,  47232, 1152, 2304, 0xcf797673
+0,  48384,  48384, 1152, 2304, 0x29cb7800
+0,  49536,  49536, 1152, 2304, 0xfc947890
+0,  50688,  50688, 1152, 2304, 0x62757fc6
+0,  51840,  51840, 1152, 2304, 0x098876d0
+0,  52992,  52992, 1152, 2304, 0xa9567ee2
+0,  54144,  54144, 1152, 2304, 0xe3bb9173
+0,  55296,  55296, 1152, 2304, 0xcc2d6dee
+0,  56448,  56448, 1152, 2304, 0xe94591ab
+0,  57600,  57600, 1152, 2304, 0x5c7588de
+0,  

[FFmpeg-devel] [PATCH] fate: add hls_list_size fate test case

2019-07-30 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 tests/fate/hlsenc.mak|  11 +
 tests/ref/fate/hls-list-size | 618 +++
 2 files changed, 629 insertions(+)
 create mode 100644 tests/ref/fate/hls-list-size

diff --git a/tests/fate/hlsenc.mak b/tests/fate/hlsenc.mak
index e81fb5411a..69aa151530 100644
--- a/tests/fate/hlsenc.mak
+++ b/tests/fate/hlsenc.mak
@@ -52,3 +52,14 @@ FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER 
MPEGTS_DEMUXER AEVALSRC_FIL
 fate-hls-segment-size: tests/data/hls_segment_size.m3u8
 fate-hls-segment-size: CMD = framecrc -flags +bitexact -i 
$(TARGET_PATH)/tests/data/hls_segment_size.m3u8 -vf setpts=N*23
 
+tests/data/hls_list_size.m3u8: TAG = GEN
+tests/data/hls_list_size.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
+   $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
+   -f lavfi -i "aevalsrc=cos(2*PI*t)*sin(2*PI*(440+4*t)*t):d=20" -f hls 
-hls_time 4 -map 0 \
+   -hls_list_size 4 -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/hls_list_size_%d.ts \
+   $(TARGET_PATH)/tests/data/hls_list_size.m3u8 2>/dev/null
+
+FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += fate-hls-list-size
+fate-hls-list-size: tests/data/hls_list_size.m3u8
+fate-hls-list-size: CMD = framecrc -flags +bitexact -i 
$(TARGET_PATH)/tests/data/hls_list_size.m3u8 -vf setpts=N*23
+
diff --git a/tests/ref/fate/hls-list-size b/tests/ref/fate/hls-list-size
new file mode 100644
index 00..cf7fb9fe3a
--- /dev/null
+++ b/tests/ref/fate/hls-list-size
@@ -0,0 +1,618 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout 0: 4
+#channel_layout_name 0: mono
+0,  0,  0, 1152, 2304, 0x9ce3278a
+0,   1152,   1152, 1152, 2304, 0x5cd17b17
+0,   2304,   2304, 1152, 2304, 0x8aec82c5
+0,   3456,   3456, 1152, 2304, 0xe8ce8fbc
+0,   4608,   4608, 1152, 2304, 0x262c69da
+0,   5760,   5760, 1152, 2304, 0x6afc7ad6
+0,   6912,   6912, 1152, 2304, 0x9f2a7370
+0,   8064,   8064, 1152, 2304, 0x88fe7bcc
+0,   9216,   9216, 1152, 2304, 0x228b8bab
+0,  10368,  10368, 1152, 2304, 0xd87f8c71
+0,  11520,  11520, 1152, 2304, 0x82989151
+0,  12672,  12672, 1152, 2304, 0x1e0f7aae
+0,  13824,  13824, 1152, 2304, 0xbdcc7d72
+0,  14976,  14976, 1152, 2304, 0xa7af8875
+0,  16128,  16128, 1152, 2304, 0xb9aa7834
+0,  17280,  17280, 1152, 2304, 0xea8e6e76
+0,  18432,  18432, 1152, 2304, 0x7bbe6bae
+0,  19584,  19584, 1152, 2304, 0x2bbd817f
+0,  20736,  20736, 1152, 2304, 0xccd46c86
+0,  21888,  21888, 1152, 2304, 0x603178d2
+0,  23040,  23040, 1152, 2304, 0xa2d283d7
+0,  24192,  24192, 1152, 2304, 0xc6e97caa
+0,  25344,  25344, 1152, 2304, 0x67e06e6d
+0,  26496,  26496, 1152, 2304, 0x27c47d51
+0,  27648,  27648, 1152, 2304, 0x17f47cd7
+0,  28800,  28800, 1152, 2304, 0xbedb75b0
+0,  29952,  29952, 1152, 2304, 0xeb1f72fd
+0,  31104,  31104, 1152, 2304, 0x6dae79e9
+0,  32256,  32256, 1152, 2304, 0x90e36f0e
+0,  33408,  33408, 1152, 2304, 0xe0748431
+0,  34560,  34560, 1152, 2304, 0xa78f6d76
+0,  35712,  35712, 1152, 2304, 0xa9cf7cd4
+0,  36864,  36864, 1152, 2304, 0xfa12796c
+0,  38016,  38016, 1152, 2304, 0x73d47c88
+0,  39168,  39168, 1152, 2304, 0xec8c74ef
+0,  40320,  40320, 1152, 2304, 0x6eda793d
+0,  41472,  41472, 1152, 2304, 0xd26c7e3f
+0,  42624,  42624, 1152, 2304, 0xd7e3788d
+0,  43776,  43776, 1152, 2304, 0x4f26748c
+0,  44928,  44928, 1152, 2304, 0x7ce07ec0
+0,  46080,  46080, 1152, 2304, 0x72ab7bba
+0,  47232,  47232, 1152, 2304, 0x287b73b9
+0,  48384,  48384, 1152, 2304, 0x78b8822b
+0,  49536,  49536, 1152, 2304, 0x9cc46ff6
+0,  50688,  50688, 1152, 2304, 0x2fdd7bb5
+0,  51840,  51840, 1152, 2304, 0x03118776
+0,  52992,  52992, 1152, 2304, 0x1f0e7403
+0,  54144,  54144, 1152, 2304, 0xfbd97c1e
+0,  55296,  55296, 1152, 2304, 0xcd118405
+0,  56448,  56448, 1152, 2304, 0xb5ce78b0
+0,  57600,  57600, 1152, 2304, 0x87b27d88
+0,  58752,  58752, 1152, 2304, 0xebd07236
+0,  59904,  59904, 1152, 2304, 0xc27c6e08
+0,  61056,  61056, 1152, 2304, 0xe17f7b8c
+0,  62208,  62208, 1152, 2304, 0x46ac674d
+0,  

Re: [FFmpeg-devel] [PATCH] avcodec/dsddec: add slice threading support

2019-07-30 Thread Carl Eugen Hoyos
Am So., 28. Juli 2019 um 23:35 Uhr schrieb Paul B Mahol :
>
> Hi,
>
> patch attached.

As just posted on irc:
On an 8-core Intel cpu, this makes decoding slower by a factor two,
heating the cpu
ten times as much, on a multi-core powerpc, decoding is nearly two
times slower, and
heats nearly eight times as much.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] lavfi/vf_thumbnail_cuda: fix operator precedence bug

2019-07-30 Thread Philip Langdale

On 2019-07-30 15:51, Rodger Combs wrote:

Discovered via a warning when building with clang
---
 libavfilter/vf_thumbnail_cuda.cu | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_thumbnail_cuda.cu 
b/libavfilter/vf_thumbnail_cuda.cu

index c73e49fbc6..d4d4d791f6 100644
--- a/libavfilter/vf_thumbnail_cuda.cu
+++ b/libavfilter/vf_thumbnail_cuda.cu
@@ -71,7 +71,7 @@ __global__ void
Thumbnail_ushort2(cudaTextureObject_t ushort2_tex,
 {
 ushort2 pixel = tex2D(ushort2_tex, x, y);
 atomicAdd([(pixel.x + 128) >> 8], 1);
-atomicAdd([256 + (pixel.y + 128) >> 8], 1);
+atomicAdd([256 + ((pixel.y + 128) >> 8)], 1);
 }
 }


LGTM

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] build: add support for building CUDA files with clang

2019-07-30 Thread Philip Langdale

On 2019-07-30 15:51, Rodger Combs wrote:

This avoids using the CUDA SDK at all; instead, we provide a minimal
reimplementation of the basic functionality that lavfi actually uses.
It generates very similar code to what NVCC produces.

The header contains no implementation code derived from the SDK.
The function and type declarations are derived from the SDK only to the
extent required to build a compatible implementation. This is generally
accepted to qualify as fair use.

Because this option does not require the proprietary SDK, it does not 
require

the "--enable-nonfree" flag in configure.
---


This is awesome. Thanks so much for doing it. I'm not in a position to 
test, and
won't be for a couple of weeks, but I'm happy with you just pushing it - 
it's

strictly no worse than what we have today.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag

2019-07-30 Thread Carl Eugen Hoyos
Am Di., 30. Juli 2019 um 06:46 Uhr schrieb Linjie Fu :
>
> Add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag to indicate
> whether encoder supports variable dimension encoding.

Isn't this about variable (or "changing") "resolutions" instead of dimensions?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] lavfi/vf_thumbnail_cuda: fix operator precedence bug

2019-07-30 Thread Rodger Combs
Discovered via a warning when building with clang
---
 libavfilter/vf_thumbnail_cuda.cu | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_thumbnail_cuda.cu b/libavfilter/vf_thumbnail_cuda.cu
index c73e49fbc6..d4d4d791f6 100644
--- a/libavfilter/vf_thumbnail_cuda.cu
+++ b/libavfilter/vf_thumbnail_cuda.cu
@@ -71,7 +71,7 @@ __global__ void Thumbnail_ushort2(cudaTextureObject_t 
ushort2_tex,
 {
 ushort2 pixel = tex2D(ushort2_tex, x, y);
 atomicAdd([(pixel.x + 128) >> 8], 1);
-atomicAdd([256 + (pixel.y + 128) >> 8], 1);
+atomicAdd([256 + ((pixel.y + 128) >> 8)], 1);
 }
 }
 
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] build: add support for building CUDA files with clang

2019-07-30 Thread Rodger Combs
This avoids using the CUDA SDK at all; instead, we provide a minimal
reimplementation of the basic functionality that lavfi actually uses.
It generates very similar code to what NVCC produces.

The header contains no implementation code derived from the SDK.
The function and type declarations are derived from the SDK only to the
extent required to build a compatible implementation. This is generally
accepted to qualify as fair use.

Because this option does not require the proprietary SDK, it does not require
the "--enable-nonfree" flag in configure.
---
 compat/cuda/cuda_runtime.h | 131 +
 configure  |  49 +-
 ffbuild/common.mak |   3 +-
 3 files changed, 166 insertions(+), 17 deletions(-)
 create mode 100644 compat/cuda/cuda_runtime.h

diff --git a/compat/cuda/cuda_runtime.h b/compat/cuda/cuda_runtime.h
new file mode 100644
index 00..dbe50f8711
--- /dev/null
+++ b/compat/cuda/cuda_runtime.h
@@ -0,0 +1,131 @@
+/*
+ * Minimum CUDA compatibility definitions header
+ *
+ * Copyright (c) 2019 Rodger Combs
+ *
+ * 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
+ */
+
+#ifndef AV_COMPAT_CUDA_CUDA_RUNTIME_H
+#define AV_COMPAT_CUDA_CUDA_RUNTIME_H
+
+// Common macros
+#define __global__ __attribute__((global))
+#define __device__ __attribute__((device))
+#define __device_builtin__ __attribute__((device_builtin))
+#define __align__(N) __attribute__((aligned(N)))
+#define __inline__ __inline__ __attribute__((always_inline))
+
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#define abs(x) ((x) < 0 ? -(x) : (x))
+
+#define atomicAdd(a, b) (__atomic_fetch_add(a, b, __ATOMIC_SEQ_CST))
+
+// Basic typedefs
+typedef __device_builtin__ unsigned long long cudaTextureObject_t;
+
+typedef struct __device_builtin__ __align__(2) uchar2
+{
+unsigned char x, y;
+} uchar2;
+
+typedef struct __device_builtin__ __align__(4) ushort2
+{
+unsigned short x, y;
+} ushort2;
+
+typedef struct __device_builtin__ uint3
+{
+unsigned int x, y, z;
+} uint3;
+
+typedef struct uint3 dim3;
+
+typedef struct __device_builtin__ __align__(8) int2
+{
+int x, y;
+} int2;
+
+typedef struct __device_builtin__ __align__(4) uchar4
+{
+unsigned char x, y, z, w;
+} uchar4;
+
+typedef struct __device_builtin__ __align__(8) ushort4
+{
+unsigned char x, y, z, w;
+} ushort4;
+
+typedef struct __device_builtin__ __align__(16) int4
+{
+int x, y, z, w;
+} int4;
+
+// Accessors for special registers
+#define GETCOMP(reg, comp) \
+asm("mov.u32 %0, %%" #reg "." #comp ";" : "=r"(tmp)); \
+ret.comp = tmp;
+
+#define GET(name, reg) static inline __device__ uint3 name() {\
+uint3 ret; \
+unsigned tmp; \
+GETCOMP(reg, x) \
+GETCOMP(reg, y) \
+GETCOMP(reg, z) \
+return ret; \
+}
+
+GET(getBlockIdx, ctaid)
+GET(getBlockDim, ntid)
+GET(getThreadIdx, tid)
+
+// Instead of externs for these registers, we turn access to them into calls 
into trivial ASM
+#define blockIdx (getBlockIdx())
+#define blockDim (getBlockDim())
+#define threadIdx (getThreadIdx())
+
+// Basic initializers (simple macros rather than inline functions)
+#define make_uchar2(a, b) ((uchar2){.x = a, .y = b})
+#define make_ushort2(a, b) ((ushort2){.x = a, .y = b})
+#define make_uchar4(a, b, c, d) ((uchar4){.x = a, .y = b, .z = c, .w = d})
+#define make_ushort4(a, b, c, d) ((ushort4){.x = a, .y = b, .z = c, .w = d})
+
+// Conversions from the tex instruction's 4-register output to various types
+#define TEX2D(type, ret) static inline __device__ void conv(type* out, 
unsigned a, unsigned b, unsigned c, unsigned d) {*out = (ret);}
+
+TEX2D(unsigned char, a & 0xFF)
+TEX2D(unsigned short, a & 0x)
+TEX2D(uchar2, make_uchar2(a & 0xFF, b & 0xFF))
+TEX2D(ushort2, make_ushort2(a & 0x, b & 0x))
+TEX2D(uchar4, make_uchar4(a & 0xFF, b & 0xFF, c & 0xFF, d & 0xFF))
+TEX2D(ushort4, make_ushort4(a & 0x, b & 0x, c & 0x, d & 0x))
+
+// Template calling tex instruction and converting the output to the selected 
type
+template 
+static inline __device__ T tex2D(cudaTextureObject_t texObject, float x, float 
y)
+{
+  T ret;
+  unsigned ret1, ret2, ret3, ret4;
+  asm("tex.2d.v4.u32.f32 {%0, %1, %2, %3}, [%4, {%5, %6}];" :
+ 

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Li, Zhong
> > +AVCodec ff_libsvt_hevc_encoder = {
> > +.name   = "libsvt_hevc",
> > +.long_name  = NULL_IF_CONFIG_SMALL("SVT-HEVC(Scalable
> Video Technology for HEVC) encoder"),
> > +.priv_data_size = sizeof(SvtContext),
> > +.type   = AVMEDIA_TYPE_VIDEO,
> > +.id = AV_CODEC_ID_HEVC,
> > +.init   = eb_enc_init,
> > +.encode2= eb_encode_frame,
> > +.close  = eb_enc_close,
> > +.capabilities   = AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_AUTO_THREADS,
> 
> The code don't support to configure thread_count, so I think you'll get the
> same result without AV_CODEC_CAP_AUTO_THREADS.

This was pointed out by Mark Thompson on patch V4. 
It is a problem how comment can be well addressed and avoid to be pointed out 
again and again. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: fix the memory leak

2019-07-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Friday, July 26, 2019 4:00 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: fix the memory leak
> 
> av_dict_free child_device_opts to fix the memory leak.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/hwcontext_qsv.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> 59e4ed9157..0329a81ec3 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -1240,6 +1240,8 @@ static int qsv_device_create(AVHWDeviceContext
> *ctx, const char *device,
> 
>  ret = av_hwdevice_ctx_create(>child_device_ctx,
> child_device_type,
>   e ? e->value : NULL,
> child_device_opts, 0);
> +
> +av_dict_free(_device_opts);
>  if (ret < 0)
>  return ret;
> 
> --
> 2.17.1

LTGM,applied.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/scpr: Use av_memcpy_backptr() in type 17 and 33

2019-07-30 Thread Paul B Mahol
On Tue, Jul 30, 2019 at 2:12 AM Michael Niedermayer 
wrote:

> This makes the changed code-path faster.
>
> Change not tested except with the fuzzer testcase as I found no other
> testcase.
>

You can test this easily be encoding solid color frame(s).


> Improves: Timeout (136sec -> 74sec)
> Improves:
> 16040/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5705876062601216
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> ---
>  libavcodec/scpr.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c
> index 317950dafb..778b064841 100644
> --- a/libavcodec/scpr.c
> +++ b/libavcodec/scpr.c
> @@ -548,9 +548,8 @@ static int decode_frame(AVCodecContext *avctx, void
> *data, int *got_frame,
>  clr = bytestream2_get_le24(gb);
>  }
>  for (y = 0; y < avctx->height; y++) {
> -for (x = 0; x < avctx->width; x++) {
> -dst[x] = clr;
> -}
> +dst[0] = clr;
> +av_memcpy_backptr(dst+1, 4, 4*avctx->width - 4);
>  dst += s->current_frame->linesize[0] / 4;
>  }
>  } else if (type == 0 || type == 1) {
> --
> 2.22.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/mxfenc: Remove unused function

2019-07-30 Thread Andreas Rheinhardt
klv_ber_length is unused since 9e24b98b.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/mxfenc.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 2e54320cf0..0cb0617919 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -542,14 +542,6 @@ static void mxf_write_refs_count(AVIOContext *pb, int 
ref_count)
 avio_wb32(pb, 16);
 }
 
-static int klv_ber_length(uint64_t len)
-{
-if (len < 128)
-return 1;
-else
-return (av_log2(len) >> 3) + 2;
-}
-
 static int klv_encode_ber_length(AVIOContext *pb, uint64_t len)
 {
 // Determine the best BER size
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Limin Wang
On Mon, Jul 29, 2019 at 03:50:36PM +0800, Jing Sun wrote:
> Signed-off-by: Zhengxu Huang 
> Signed-off-by: Hassene Tmar 
> Signed-off-by: Jun Zhao 
> Signed-off-by: Jing Sun 
> ---
>  configure|   4 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/libsvt_hevc.c | 501 
> +++
>  libavcodec/version.h |   2 +-
>  5 files changed, 508 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/libsvt_hevc.c
> 
> diff --git a/configure b/configure
> index 7cea9d4..8f2f065 100755
> --- a/configure
> +++ b/configure
> @@ -264,6 +264,7 @@ External library support:
>--enable-libspeexenable Speex de/encoding via libspeex [no]
>--enable-libsrt  enable Haivision SRT protocol via libsrt [no]
>--enable-libssh  enable SFTP protocol via libssh [no]
> +  --enable-libsvthevc  enable HEVC encoding via svt [no]
>--enable-libtensorflow   enable TensorFlow as a DNN module backend
> for DNN based filters like sr [no]
>--enable-libtesseractenable Tesseract, needed for ocr filter [no]
> @@ -1787,6 +1788,7 @@ EXTERNAL_LIBRARY_LIST="
>  libspeex
>  libsrt
>  libssh
> +libsvthevc
>  libtensorflow
>  libtesseract
>  libtheora
> @@ -3180,6 +3182,7 @@ libshine_encoder_select="audio_frame_queue"
>  libspeex_decoder_deps="libspeex"
>  libspeex_encoder_deps="libspeex"
>  libspeex_encoder_select="audio_frame_queue"
> +libsvt_hevc_encoder_deps="libsvthevc"
>  libtheora_encoder_deps="libtheora"
>  libtwolame_encoder_deps="libtwolame"
>  libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
> @@ -6226,6 +6229,7 @@ enabled libsoxr   && require libsoxr soxr.h 
> soxr_create -lsoxr
>  enabled libssh&& require_pkg_config libssh libssh libssh/sftp.h 
> sftp_init
>  enabled libspeex  && require_pkg_config libspeex speex speex/speex.h 
> speex_decoder_init
>  enabled libsrt&& require_pkg_config libsrt "srt >= 1.3.0" 
> srt/srt.h srt_socket
> +enabled libsvthevc&& require_pkg_config libsvthevc SvtHevcEnc 
> EbApi.h EbInitHandle
>  enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h 
> TF_Version -ltensorflow
>  enabled libtesseract  && require_pkg_config libtesseract tesseract 
> tesseract/capi.h TessBaseAPICreate
>  enabled libtheora && require libtheora theora/theoraenc.h 
> th_info_init -ltheoraenc -ltheoradec -logg
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index edccd73..7eb13de 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -991,6 +991,7 @@ OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o 
> libopus.o \
>  OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
>  OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
>  OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
> +OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER)+= libsvt_hevc.o
>  OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
>  OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
>  OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index d2f9a39..d8788a7 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -707,6 +707,7 @@ extern AVCodec ff_librsvg_decoder;
>  extern AVCodec ff_libshine_encoder;
>  extern AVCodec ff_libspeex_encoder;
>  extern AVCodec ff_libspeex_decoder;
> +extern AVCodec ff_libsvt_hevc_encoder;
>  extern AVCodec ff_libtheora_encoder;
>  extern AVCodec ff_libtwolame_encoder;
>  extern AVCodec ff_libvo_amrwbenc_encoder;
> diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c
> new file mode 100644
> index 000..d9ac04c
> --- /dev/null
> +++ b/libavcodec/libsvt_hevc.c
> @@ -0,0 +1,501 @@
> +/*
> +* Scalable Video Technology for HEVC encoder library plugin
> +*
> +* Copyright (c) 2019 Intel Corporation
> +*
> +* 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 this program; if not, write to the Free Software
> +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> +*/
> +
> +#include "EbErrorCodes.h"
> +#include "EbTime.h"
> +#include "EbApi.h"
> +
> +#include "libavutil/common.h"
> +#include "libavutil/frame.h"
> +#include "libavutil/opt.h"
> +
> +#include "internal.h"
> +#include