[FFmpeg-devel] [PATCH 4/5 v2] mlpenc: improve lpc filtering

2019-07-09 Thread Jai Luthra
* fix a possible memory leak (apply_filter returned before freeing)
* use apply_filters in process_major_frame
* revert back to checking bounds with 24 bitdepth, as huff offset takes
care of it

Signed-off-by: Jai Luthra 
---

v2: remove unused variables in process_major_frame

---
 libavcodec/mlpenc.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 41030f6f07..3c2a57d81a 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1799,7 +1799,7 @@ static void determine_bits(MLPEncodeContext *ctx)
 
 /** Applies the filter to the current samples, and saves the residual back
  *  into the samples buffer. If the filter is too bad and overflows the
- *  maximum amount of bits allowed (16 or 24), the samples buffer is left as 
is and
+ *  maximum amount of bits allowed (24), the samples buffer is left as is and
  *  the function returns -1.
  */
 static int apply_filter(MLPEncodeContext *ctx, unsigned int channel)
@@ -1812,7 +1812,7 @@ static int apply_filter(MLPEncodeContext *ctx, unsigned 
int channel)
 unsigned int number_of_samples = ctx->number_of_samples;
 unsigned int filter_shift = fp[FIR]->shift;
 int filter;
-int i;
+int i, ret = 0;
 
 for (i = 0; i < NUM_FILTERS; i++) {
 unsigned int size = ctx->number_of_samples;
@@ -1835,7 +1835,7 @@ static int apply_filter(MLPEncodeContext *ctx, unsigned 
int channel)
 int32_t sample = *sample_buffer;
 unsigned int order;
 int64_t accum = 0;
-int32_t residual;
+int64_t residual;
 
 for (filter = 0; filter < NUM_FILTERS; filter++) {
 int32_t *fcoeff = ctx->cur_channel_params[channel].coeff[filter];
@@ -1847,11 +1847,13 @@ static int apply_filter(MLPEncodeContext *ctx, unsigned 
int channel)
 accum  >>= filter_shift;
 residual = sample - (accum & mask);
 
-if (residual < SAMPLE_MIN(ctx->wordlength) || residual > 
SAMPLE_MAX(ctx->wordlength))
-return -1;
+if (residual < SAMPLE_MIN(24) || residual > SAMPLE_MAX(24)) {
+ret = -1;
+goto free_and_return;
+}
 
 filter_state_buffer[FIR][i] = sample;
-filter_state_buffer[IIR][i] = residual;
+filter_state_buffer[IIR][i] = (int32_t) residual;
 
 sample_buffer += ctx->num_channels;
 }
@@ -1863,11 +1865,12 @@ static int apply_filter(MLPEncodeContext *ctx, unsigned 
int channel)
 sample_buffer += ctx->num_channels;
 }
 
+free_and_return:
 for (i = 0; i < NUM_FILTERS; i++) {
 av_freep(_state_buffer[i]);
 }
 
-return 0;
+return ret;
 }
 
 static void apply_filters(MLPEncodeContext *ctx)
@@ -2198,9 +2201,6 @@ static void process_major_frame(MLPEncodeContext *ctx)
 ctx->number_of_samples = ctx->major_frame_size;
 
 for (substr = 0; substr < ctx->num_substreams; substr++) {
-RestartHeader *rh = ctx->cur_restart_header;
-unsigned int channel;
-
 ctx->cur_restart_header = >restart_header[substr];
 
 ctx->cur_decoding_params = >major_decoding_params[1][substr];
@@ -2209,8 +2209,7 @@ static void process_major_frame(MLPEncodeContext *ctx)
 generate_2_noise_channels(ctx);
 rematrix_channels(ctx);
 
-for (channel = rh->min_channel; channel <= rh->max_channel; channel++)
-apply_filter(ctx, channel);
+apply_filters(ctx);
 }
 }
 
-- 
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 1/5] mlpenc: fix lossless check error in number_sbits

2019-07-09 Thread Jai Luthra

On Wed, Jul 10, 2019 at 12:14:56AM +0200, Lynne wrote:

Jul 9, 2019, 9:18 PM by m...@jailuthra.in:


we need two bits instead of one bit to represent -1 in bitstream

Signed-off-by: Jai Luthra 
---
 libavcodec/mlpenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index deb171645c..f4948451f1 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -466,7 +466,7 @@ static void default_decoding_params(MLPEncodeContext *ctx,
 */
 static int inline number_sbits(int number)
 {
-if (number < 0)
+if (number < -1)
 number++;



This is different from the first patch's version. Sure its correct now?


Yep. Previous patch produced valid bitstream too, but this provides better 
compression [1] by representing numbers of the form -2^x with one less bit for 
x >= 1.


This makes more sense, as we can represent -2 in two-bit twos-complement 
notation as `10` so output should be 2 bits (instead of 3 by previous patch). 
(similarly for -4, -8, -16, ...)


The lossless errors were being caused when a block of samples were all either 
-1 or 0. This function implied all samples could be represented as single bit 
each, but down the pipeline after huff vlc calculations, the encoder pushed 
 on the bitstream for all samples, which was always interpreted as 0 
by the decoder and never -1.


NB: One can argue -1 and 0 in fact can be represented in a single bit as two's 
complement, 0 being `0` and -1 being `1`. But imho, single bit two's 
complement is a weird boundary case, and not considering it solves the issue 
here. If someone has a better idea pls suggest.


[1]: tested using both patches on 
https://samples.ffmpeg.org/flac/When%20I%20Grow%20Up.flac. Previous patch 
compressed it to 28788216 byte MLP stream, this one compresses it to 28787834 
byte MLP stream. Both streams are valid and decode to lossless bit-exact 
output.


thx

--
jlut
___
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] lavc/videotoolboxenc: add hdr10, linear, hlg color transfer function for videotoolboxenc

2019-07-09 Thread Dennis Mungai
On Wed, Jul 10, 2019, 03:05 Aman Gupta  wrote:

> On Wed, Jun 26, 2019 at 4:25 AM  wrote:
>
> > From: Limin Wang 
> >
> > Below is the testing ffmpeg command for the setting:
> > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > -colorspace bt2020_ncl -color_trc linear linear.ts
> > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
> >
>
> Patch looks reasonable to me. Will commit in a few days if no one else
> comments.
>
> Aman
>
>
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  configure|  6 ++
> >  libavcodec/videotoolboxenc.c | 16 
> >  2 files changed, 22 insertions(+)
> >
> > diff --git a/configure b/configure
> > index 7cea9d4d73..0a5e940c0c 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
> >  TYPES_LIST="
> >  kCMVideoCodecType_HEVC
> >  kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> > +kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> > +kCVImageBufferTransferFunction_ITU_R_2100_HLG
> > +kCVImageBufferTransferFunction_Linear
> >  socklen_t
> >  struct_addrinfo
> >  struct_group_source_req
> > @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
> >  check_lib coreservices CoreServices/CoreServices.h
> > UTGetOSTypeFromString "-framework CoreServices"
> >  check_func_headers CoreMedia/CMFormatDescription.h
> > kCMVideoCodecType_HEVC "-framework CoreMedia"
> >  check_func_headers CoreVideo/CVPixelBuffer.h
> > kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
> > +check_func_headers CoreVideo/CVImageBuffer.h
> > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
> > +check_func_headers CoreVideo/CVImageBuffer.h
> > kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
> > +check_func_headers CoreVideo/CVImageBuffer.h
> > kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
> >  }
> >
> >  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> > index f8ccdea52d..0dc6eb4cf4 100644
> > --- a/libavcodec/videotoolboxenc.c
> > +++ b/libavcodec/videotoolboxenc.c
> > @@ -915,6 +915,22 @@ static int get_cv_transfer_function(AVCodecContext
> > *avctx,
> >  *transfer_fnc =
> > kCVImageBufferTransferFunction_SMPTE_240M_1995;
> >  break;
> >
> > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> > +case AVCOL_TRC_SMPTE2084:
> > +*transfer_fnc =
> > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> > +break;
> > +#endif
> > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> > +case AVCOL_TRC_LINEAR:
> > +*transfer_fnc = kCVImageBufferTransferFunction_Linear;
> > +break;
> > +#endif
> > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> > +case AVCOL_TRC_ARIB_STD_B67:
> > +*transfer_fnc =
> kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> > +break;
> > +#endif
> > +
> >  case AVCOL_TRC_GAMMA22:
> >  gamma = 2.2;
> >  *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
> > --
> > 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".
>

A while back, a similar patch was rejected for NVENC (from the same author)
on the basis of such functionality not being suitably placed as an encoder
feature.

Looking back at other implementations, eg hevc_vaapi, the same is indeed
allowed, where SEI metadata retention for HDR is present.

To the OP: If the patch for NVENC were refactored in a manner similar to
this, abstracting details such as master display info for HDR (something
that was specifically flagged as not suitable as an encoder feature), it
might pass the patch review and be merged.

Are there specific limitations (as implemented) that block such a feature
in NVENC? Perhaps the initial patch with mastering display controls for HDR
was written that way to circumvent such a limitation.

Regards,

Dennis

>
___
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] avcodec/utils, avcodec_open2: close codec on failure

2019-07-09 Thread James Zern
after a successful init if the function fails for another reason close
the codec without requiring FF_CODEC_CAP_INIT_CLEANUP which is meant to
cover init failures themselves. fixes a memory leak in those cases.

BUG=oss-fuzz:15529

Signed-off-by: James Zern 
---
 libavcodec/utils.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1b1feca38c..9ff9628f7f 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -542,6 +542,7 @@ int attribute_align_arg 
ff_codec_open2_recursive(AVCodecContext *avctx, const AV
 int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec 
*codec, AVDictionary **options)
 {
 int ret = 0;
+int codec_init_ok = 0;
 AVDictionary *tmp = NULL;
 const AVPixFmtDescriptor *pixdesc;
 
@@ -935,6 +936,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (ret < 0) {
 goto free_and_end;
 }
+codec_init_ok = 1;
 }
 
 ret=0;
@@ -1023,7 +1025,8 @@ end:
 return ret;
 free_and_end:
 if (avctx->codec &&
-(avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP))
+(codec_init_ok ||
+ (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)))
 avctx->codec->close(avctx);
 
 if (codec->priv_class && codec->priv_data_size)
-- 
2.22.0.410.gd8fdbe21b5-goog

___
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] avfilter: add rawdump filter

2019-07-09 Thread U. Artie Eoff
This filter enables raw frames to be dumped to a
file before they are sent through the auto-inserted
scaler filter and useful when you want unscaled
raw frames in an output file.

Signed-off-by: U. Artie Eoff 
---
 Changelog|   1 +
 doc/filters.texi |  20 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   4 +-
 libavfilter/vf_rawdump.c | 157 +++
 6 files changed, 182 insertions(+), 2 deletions(-)
 create mode 100644 libavfilter/vf_rawdump.c

diff --git a/Changelog b/Changelog
index 86167b76a13c..7fdd3789f26d 100644
--- a/Changelog
+++ b/Changelog
@@ -35,6 +35,7 @@ version :
 - IFV demuxer
 - derain filter
 - deesser filter
+- rawdump filter
 
 
 version 4.1:
diff --git a/doc/filters.texi b/doc/filters.texi
index b0c49265e296..710100486e14 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14631,6 +14631,26 @@ less than @code{0}, the filter will try to use a good 
random seed on a
 best effort basis.
 @end table
 
+@anchor{rawdump}
+@section rawdump
+
+Dump raw video frames to a file.
+
+The filter is especially useful when you want to dump raw frames to a file
+before scaling is applied by the auto-inserted scaler in the graph (e.g. for
+multi-resolution input streams).
+
+The input must be in non-hardware format.  It may be necessary to insert an
+additional @option{format} filter immediately preceding in the graph to get
+the input in a supported format for dumping to the file.
+
+The following parameters are required:
+
+@table @option
+@item file @var{filename}
+Specify the filename to dump the data to.
+@end table
+
 @section readeia608
 
 Read closed captioning (EIA-608) information from the top lines of a video 
frame.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 455c809b151e..f8e02f382af9 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -334,6 +334,7 @@ OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o 
framesync.o
 OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
 OBJS-$(CONFIG_QP_FILTER) += vf_qp.o
 OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o
+OBJS-$(CONFIG_RAWDUMP_FILTER)+= vf_rawdump.o
 OBJS-$(CONFIG_READEIA608_FILTER) += vf_readeia608.o
 OBJS-$(CONFIG_READVITC_FILTER)   += vf_readvitc.o
 OBJS-$(CONFIG_REALTIME_FILTER)   += f_realtime.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 04a3df7d56d6..565e2a73cc82 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -317,6 +317,7 @@ extern AVFilter ff_vf_psnr;
 extern AVFilter ff_vf_pullup;
 extern AVFilter ff_vf_qp;
 extern AVFilter ff_vf_random;
+extern AVFilter ff_vf_rawdump;
 extern AVFilter ff_vf_readeia608;
 extern AVFilter ff_vf_readvitc;
 extern AVFilter ff_vf_realtime;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 5bf37fa8b407..cc5b23b70bbe 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,8 +30,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  56
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MINOR  57
+#define LIBAVFILTER_VERSION_MICRO 100
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_rawdump.c b/libavfilter/vf_rawdump.c
new file mode 100644
index ..fe8a8a692603
--- /dev/null
+++ b/libavfilter/vf_rawdump.c
@@ -0,0 +1,157 @@
+/*
+ * 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/buffer.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct RawDumpContext {
+const AVClass *class;
+FILE *rawdump_file;
+char *rawdump_file_str;
+} RawDumpContext;
+
+static int rawdump_query_formats(AVFilterContext *avctx)
+{
+AVFilterFormats *formats = NULL;
+const AVPixFmtDescriptor *desc;
+int err;
+
+for (desc = av_pix_fmt_desc_next(NULL); desc;
+ desc = av_pix_fmt_desc_next(desc)) {
+if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
+continue;
+err = 

Re: [FFmpeg-devel] [PATCH] lavc/videotoolboxenc: add hdr10, linear, hlg color transfer function for videotoolboxenc

2019-07-09 Thread Aman Gupta
On Wed, Jun 26, 2019 at 4:25 AM  wrote:

> From: Limin Wang 
>
> Below is the testing ffmpeg command for the setting:
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> -colorspace bt2020_ncl -color_trc linear linear.ts
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
>

Patch looks reasonable to me. Will commit in a few days if no one else
comments.

Aman


>
> Signed-off-by: Limin Wang 
> ---
>  configure|  6 ++
>  libavcodec/videotoolboxenc.c | 16 
>  2 files changed, 22 insertions(+)
>
> diff --git a/configure b/configure
> index 7cea9d4d73..0a5e940c0c 100755
> --- a/configure
> +++ b/configure
> @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
>  TYPES_LIST="
>  kCMVideoCodecType_HEVC
>  kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> +kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> +kCVImageBufferTransferFunction_ITU_R_2100_HLG
> +kCVImageBufferTransferFunction_Linear
>  socklen_t
>  struct_addrinfo
>  struct_group_source_req
> @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
>  check_lib coreservices CoreServices/CoreServices.h
> UTGetOSTypeFromString "-framework CoreServices"
>  check_func_headers CoreMedia/CMFormatDescription.h
> kCMVideoCodecType_HEVC "-framework CoreMedia"
>  check_func_headers CoreVideo/CVPixelBuffer.h
> kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
> +check_func_headers CoreVideo/CVImageBuffer.h
> kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
> +check_func_headers CoreVideo/CVImageBuffer.h
> kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
> +check_func_headers CoreVideo/CVImageBuffer.h
> kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
>  }
>
>  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index f8ccdea52d..0dc6eb4cf4 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -915,6 +915,22 @@ static int get_cv_transfer_function(AVCodecContext
> *avctx,
>  *transfer_fnc =
> kCVImageBufferTransferFunction_SMPTE_240M_1995;
>  break;
>
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> +case AVCOL_TRC_SMPTE2084:
> +*transfer_fnc =
> kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> +break;
> +#endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> +case AVCOL_TRC_LINEAR:
> +*transfer_fnc = kCVImageBufferTransferFunction_Linear;
> +break;
> +#endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> +case AVCOL_TRC_ARIB_STD_B67:
> +*transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> +break;
> +#endif
> +
>  case AVCOL_TRC_GAMMA22:
>  gamma = 2.2;
>  *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
> --
> 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 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/mpegts: respect program number when merging streams

2019-07-09 Thread Aman Gupta
On Tue, Jul 9, 2019 at 2:07 PM Marton Balint  wrote:

> merge_pmt_versions was not usable if multiple programs were present because
> when it was searching for candidate streams it did not make sure that the
> PMT was
> of the same program. This caused the streams of all programs to get merged
> into
> a single (garbled) program.
>
> This patch makes sure that the program number (service ID) is also matching
> with the old streams when parsing the PMT making the feature useful for
> multi
> program streams.
>
> This change might cause issues for single program streams if the program
> number
> changes as well, but I think it is acceptable because the goal of the
> option is
> to make the parsing resilient to PID changes, and that is still working as
> expected.
>

Patch looks good to me. Thanks for catching this!

Aman


>
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mpegts.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 8a84e5cc19..47d8d5f877 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2130,7 +2130,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc,
> AVStream *st, int stream_type
>  return 0;
>  }
>
> -static AVStream *find_matching_stream(MpegTSContext *ts, int pid,
> +static AVStream *find_matching_stream(MpegTSContext *ts, int pid,
> unsigned int programid,
>int stream_identifier, int
> pmt_stream_idx)
>  {
>  AVFormatContext *s = ts->stream;
> @@ -2139,6 +2139,8 @@ static AVStream *find_matching_stream(MpegTSContext
> *ts, int pid,
>
>  for (i = 0; i < s->nb_streams; i++) {
>  AVStream *st = s->streams[i];
> +if (st->program_num != programid)
> +continue;
>  if (stream_identifier != -1) { /* match based on "stream
> identifier descriptor" if present */
>  if (st->stream_identifier == stream_identifier+1) {
>  found = st;
> @@ -2309,7 +2311,7 @@ static void pmt_cb(MpegTSFilter *filter, const
> uint8_t *section, int section_len
>  if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) {
>  pes = ts->pids[pid]->u.pes_filter.opaque;
>  if (ts->merge_pmt_versions && !pes->st) {
> -st = find_matching_stream(ts, pid, stream_identifier, i);
> +st = find_matching_stream(ts, pid, h->id,
> stream_identifier, i);
>  if (st) {
>  pes->st = st;
>  pes->stream_type = stream_type;
> @@ -2331,7 +2333,7 @@ static void pmt_cb(MpegTSFilter *filter, const
> uint8_t *section, int section_len
>  mpegts_close_filter(ts, ts->pids[pid]); // wrongly added
> sdt filter probably
>  pes = add_pes_stream(ts, pid, pcr_pid);
>  if (ts->merge_pmt_versions && pes && !pes->st) {
> -st = find_matching_stream(ts, pid, stream_identifier, i);
> +st = find_matching_stream(ts, pid, h->id,
> stream_identifier, i);
>  if (st) {
>  pes->st = st;
>  pes->stream_type = stream_type;
> @@ -2353,7 +2355,7 @@ static void pmt_cb(MpegTSFilter *filter, const
> uint8_t *section, int section_len
>  st = ts->stream->streams[idx];
>  }
>  if (ts->merge_pmt_versions && !st) {
> -st = find_matching_stream(ts, pid, stream_identifier, i);
> +st = find_matching_stream(ts, pid, h->id,
> stream_identifier, i);
>  }
>  if (!st) {
>  st = avformat_new_stream(ts->stream, NULL);
> --
> 2.16.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 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/5] mlpenc: fix lossless check error in number_sbits

2019-07-09 Thread Lynne
Jul 9, 2019, 9:18 PM by m...@jailuthra.in:

> we need two bits instead of one bit to represent -1 in bitstream
>
> Signed-off-by: Jai Luthra 
> ---
>  libavcodec/mlpenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
> index deb171645c..f4948451f1 100644
> --- a/libavcodec/mlpenc.c
> +++ b/libavcodec/mlpenc.c
> @@ -466,7 +466,7 @@ static void default_decoding_params(MLPEncodeContext *ctx,
>  */
>  static int inline number_sbits(int number)
>  {
> -if (number < 0)
> +if (number < -1)
>  number++; 
>

This is different from the first patch's version. Sure its correct now?
___
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] avformat/rpl: Replace strcpy with av_strlcpy

2019-07-09 Thread Cameron Cawley
The second use of strcpy() that this patch fixes was added in
commit 0e9c01f.

Regards
Cameron

On Fri, 5 Jul 2019 at 17:47, Michael Niedermayer 
wrote:

> On Sun, Jun 30, 2019 at 12:00:43AM +0100, Cameron Cawley wrote:
> > ---
> >  libavformat/rpl.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/rpl.c b/libavformat/rpl.c
> > index b4859320f4..579ab4f57e 100644
> > --- a/libavformat/rpl.c
> > +++ b/libavformat/rpl.c
> > @@ -192,7 +192,7 @@ static int rpl_read_header(AVFormatContext *s)
> >  // samples, though. This code will ignore additional tracks.
> >  error |= read_line(pb, line, sizeof(line));
> >  audio_format = read_int(line, , );  // audio format ID
> > -strcpy(audio_codec, endptr);
> > +av_strlcpy(audio_codec, endptr, RPL_LINE_LENGTH);
> >  if (audio_format) {
> >  ast = avformat_new_stream(s, NULL);
> >  if (!ast)
> > @@ -203,7 +203,7 @@ static int rpl_read_header(AVFormatContext *s)
> >  ast->codecpar->channels= read_line_and_int(pb,
> );  // number of audio channels
> >  error |= read_line(pb, line, sizeof(line));
> >  ast->codecpar->bits_per_coded_sample = read_int(line, ,
> );  // audio bits per sample
> > -strcpy(audio_type, endptr);
> > +av_strlcpy(audio_type, endptr, RPL_LINE_LENGTH);
> >  // At least one sample uses 0 for ADPCM, which is really 4 bits
> >  // per sample.
> >  if (ast->codecpar->bits_per_coded_sample == 0)
>
> please include this in the patch that adds the strcpy()
>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
> ___
> 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 v2] avcodec/cbs_h265: add support for Alpha Channel Info SEI messages

2019-07-09 Thread James Almer
As defined in sections F.14.2.8 and F.14.3.8

Signed-off-by: James Almer 
---
 libavcodec/cbs_h2645.c|  1 +
 libavcodec/cbs_h265.h | 12 +++
 libavcodec/cbs_h265_syntax_template.c | 29 +++
 libavcodec/hevc_sei.h |  1 +
 4 files changed, 43 insertions(+)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index da4927ca8e..5bd03805be 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -529,6 +529,7 @@ static void cbs_h265_free_sei_payload(H265RawSEIPayload 
*payload)
 case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
 case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
 case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
+case HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO:
 break;
 case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
 av_buffer_unref(>payload.user_data_registered.data_ref);
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index c9bc90187b..ad746bf35f 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -679,6 +679,17 @@ typedef struct 
H265RawSEIAlternativeTransferCharacteristics {
 uint8_t preferred_transfer_characteristics;
 } H265RawSEIAlternativeTransferCharacteristics;
 
+typedef struct H265RawSEIAlphaChannelInfo {
+uint8_t  alpha_channel_cancel_flag;
+uint8_t  alpha_channel_use_idc;
+uint8_t  alpha_channel_bit_depth_minus8;
+uint16_t alpha_transparent_value;
+uint16_t alpha_opaque_value;
+uint8_t  alpha_channel_incr_flag;
+uint8_t  alpha_channel_clip_flag;
+uint8_t  alpha_channel_clip_type_flag;
+} H265RawSEIAlphaChannelInfo;
+
 typedef struct H265RawSEIPayload {
 uint32_t payload_type;
 uint32_t payload_size;
@@ -697,6 +708,7 @@ typedef struct H265RawSEIPayload {
 H265RawSEIContentLightLevelInfo content_light_level;
 H265RawSEIAlternativeTransferCharacteristics
 alternative_transfer_characteristics;
+H265RawSEIAlphaChannelInfo alpha_channel_info;
 struct {
 uint8_t *data;
 size_t data_length;
diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index f279d283d9..54570929ec 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -2028,6 +2028,34 @@ static int 
FUNC(sei_alternative_transfer_characteristics)(CodedBitstreamContext
 return 0;
 }
 
+static int FUNC(sei_alpha_channel_info)(CodedBitstreamContext *ctx,
+RWContext *rw,
+H265RawSEIAlphaChannelInfo *current)
+{
+int err, length;
+
+HEADER("Alpha Channel Information");
+
+flag(alpha_channel_cancel_flag);
+if (!current->alpha_channel_cancel_flag) {
+ub(3, alpha_channel_use_idc);
+ub(3, alpha_channel_bit_depth_minus8);
+length = current->alpha_channel_bit_depth_minus8 + 9;
+ub(length, alpha_transparent_value);
+ub(length, alpha_opaque_value);
+flag(alpha_channel_incr_flag);
+flag(alpha_channel_clip_flag);
+if (current->alpha_channel_clip_flag)
+flag(alpha_channel_clip_type_flag);
+} else {
+   infer(alpha_channel_use_idc,   2);
+   infer(alpha_channel_incr_flag, 0);
+   infer(alpha_channel_clip_flag, 0);
+}
+
+return 0;
+}
+
 static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw,
  H265RawSEIPayload *current, int prefix)
 {
@@ -2080,6 +2108,7 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, 
RWContext *rw,
 SEI_TYPE_N(CONTENT_LIGHT_LEVEL_INFO, 1, 0, content_light_level);
 SEI_TYPE_N(ALTERNATIVE_TRANSFER_CHARACTERISTICS,
  1, 0, 
alternative_transfer_characteristics);
+SEI_TYPE_N(ALPHA_CHANNEL_INFO,   1, 0, alpha_channel_info);
 
 #undef SEI_TYPE
 default:
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 2fec00ace0..f6516ae982 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -56,6 +56,7 @@ typedef enum {
 HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO   = 137,
 HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
 HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147,
+HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO   = 165,
 } HEVC_SEI_Type;
 
 typedef struct HEVCSEIPictureHash {
-- 
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] [PATCHv4] avcodec: Add librav1e encoder

2019-07-09 Thread James Almer
On 7/9/2019 3:34 PM, Derek Buitenhuis wrote:
> Port to the new send/receive API by: James Almer .
> 
> Signed-off-by: Derek Buitenhuis 
> ---
> Lots of stuff happened since v3!
> 
> * The C API / library is now in rav1e's main repo, and officially supported.
> * rav1e will bump the soname and pkg-config version on any breaking changes.
> * C API is now as fast as the Rust API.
> * Added two pass support.
> * Added min quantizer support.
> * Added tiles / speed to AVOptions.
> * Mapped min/max keyint.
> * Applied all the fixes requested in the last round.
> ---
>  configure  |   4 +
>  doc/encoders.texi  |  37 +++
>  doc/general.texi   |   7 +
>  libavcodec/Makefile|   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/librav1e.c  | 578 +
>  6 files changed, 628 insertions(+)
>  create mode 100644 libavcodec/librav1e.c
> 
> diff --git a/configure b/configure
> index 4005987409..7e93812824 100755
> --- a/configure
> +++ b/configure
> @@ -254,6 +254,7 @@ External library support:
>--enable-libopenmpt  enable decoding tracked files via libopenmpt [no]
>--enable-libopus enable Opus de/encoding via libopus [no]
>--enable-libpulseenable Pulseaudio input via libpulse [no]
> +  --enable-librav1eenable AV1 encoding via rav1e [no]
>--enable-librsvg enable SVG rasterization via librsvg [no]
>--enable-librubberband   enable rubberband needed for rubberband filter 
> [no]
>--enable-librtmp enable RTMP[E] support via librtmp [no]
> @@ -1778,6 +1779,7 @@ EXTERNAL_LIBRARY_LIST="
>  libopenmpt
>  libopus
>  libpulse
> +librav1e
>  librsvg
>  librtmp
>  libshine
> @@ -3174,6 +3176,7 @@ libopenmpt_demuxer_deps="libopenmpt"
>  libopus_decoder_deps="libopus"
>  libopus_encoder_deps="libopus"
>  libopus_encoder_select="audio_frame_queue"
> +librav1e_encoder_deps="librav1e"

Needs to enable extract_extradata_bsf with a _select line as well.

>  librsvg_decoder_deps="librsvg"
>  libshine_encoder_deps="libshine"
>  libshine_encoder_select="audio_frame_queue"
> @@ -6215,6 +6218,7 @@ enabled libopus   && {
>  }
>  }
>  enabled libpulse  && require_pkg_config libpulse libpulse 
> pulse/pulseaudio.h pa_context_new
> +enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.1.0" 
> rav1e.h rav1e_context_new
>  enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
> librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
>  enabled librtmp   && require_pkg_config librtmp librtmp 
> librtmp/rtmp.h RTMP_Socket
>  enabled librubberband && require_pkg_config librubberband "rubberband >= 
> 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
> librubberband_extralibs "-lstdc++"
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index eefd124751..f316725409 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1378,6 +1378,43 @@ makes it possible to store non-rgb pix_fmts.
>  
>  @end table
>  
> +@section librav1e
> +
> +rav1e AV1 encoder wrapper.
> +
> +Requires the presence of the rav1e headers and library during configuration.
> +You need to explicitly configure the build with @code{--enable-librav1e}.
> +
> +@subsection Options
> +
> +@table @option
> +@item qmax
> +Sets the maximum quantizer (floor) to use when using bitrate mode.
> +
> +@item qmin
> +Sets the minimum quantizer (ceiling) to use when in bitrate mdoe.
> +
> +@item qp
> +Uses quantizer mode to encode at the given quantizer.
> +
> +@item speed
> +Selects the speed preset (0-9) to encode with.
> +
> +@item tiles
> +Selects how many tiles to encode with.
> +
> +@item rav1e-params
> +Set rav1e options using a list of @var{key}=@var{value} pairs separated
> +by ":". See @command{rav1e --help} for a list of options.
> +
> +For example to specify librav1e encoding options with @option{-rav1e-params}:
> +
> +@example
> +ffmpeg -i input -c:v librav1e -b:v 500K -rav1e-params 
> speed=5:low_latency=true output.mp4
> +@end example
> +
> +@end table
> +
>  @section libaom-av1
>  
>  libaom AV1 encoder wrapper.
> diff --git a/doc/general.texi b/doc/general.texi
> index 3c0c803449..72a6d73f33 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -243,6 +243,13 @@ FFmpeg can use the OpenJPEG libraries for 
> decoding/encoding J2K videos.  Go to
>  instructions.  To enable using OpenJPEG in FFmpeg, pass 
> @code{--enable-libopenjpeg} to
>  @file{./configure}.
>  
> +@section rav1e
> +
> +FFmpeg can make use of rav1e (Rust AV1 Encoder) via its C bindings to encode 
> videos.
> +Go to @url{https://github.com/lu-zero/crav1e/} and follow the instructions 
> to build
> +the C library. To enable using rav1e in FFmpeg, pass @code{--enable-librav1e}
> +to @file{./configure}.
> +
>  @section TwoLAME
>  
>  FFmpeg can make use of the TwoLAME library for MP2 encoding.
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 

[FFmpeg-devel] [PATCH] avformat/mpegts: respect program number when merging streams

2019-07-09 Thread Marton Balint
merge_pmt_versions was not usable if multiple programs were present because
when it was searching for candidate streams it did not make sure that the PMT 
was
of the same program. This caused the streams of all programs to get merged into
a single (garbled) program.

This patch makes sure that the program number (service ID) is also matching
with the old streams when parsing the PMT making the feature useful for multi
program streams.

This change might cause issues for single program streams if the program number
changes as well, but I think it is acceptable because the goal of the option is
to make the parsing resilient to PID changes, and that is still working as
expected.

Signed-off-by: Marton Balint 
---
 libavformat/mpegts.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8a84e5cc19..47d8d5f877 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2130,7 +2130,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 return 0;
 }
 
-static AVStream *find_matching_stream(MpegTSContext *ts, int pid,
+static AVStream *find_matching_stream(MpegTSContext *ts, int pid, unsigned int 
programid,
   int stream_identifier, int 
pmt_stream_idx)
 {
 AVFormatContext *s = ts->stream;
@@ -2139,6 +2139,8 @@ static AVStream *find_matching_stream(MpegTSContext *ts, 
int pid,
 
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
+if (st->program_num != programid)
+continue;
 if (stream_identifier != -1) { /* match based on "stream identifier 
descriptor" if present */
 if (st->stream_identifier == stream_identifier+1) {
 found = st;
@@ -2309,7 +2311,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) {
 pes = ts->pids[pid]->u.pes_filter.opaque;
 if (ts->merge_pmt_versions && !pes->st) {
-st = find_matching_stream(ts, pid, stream_identifier, i);
+st = find_matching_stream(ts, pid, h->id, stream_identifier, 
i);
 if (st) {
 pes->st = st;
 pes->stream_type = stream_type;
@@ -2331,7 +2333,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 mpegts_close_filter(ts, ts->pids[pid]); // wrongly added sdt 
filter probably
 pes = add_pes_stream(ts, pid, pcr_pid);
 if (ts->merge_pmt_versions && pes && !pes->st) {
-st = find_matching_stream(ts, pid, stream_identifier, i);
+st = find_matching_stream(ts, pid, h->id, stream_identifier, 
i);
 if (st) {
 pes->st = st;
 pes->stream_type = stream_type;
@@ -2353,7 +2355,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 st = ts->stream->streams[idx];
 }
 if (ts->merge_pmt_versions && !st) {
-st = find_matching_stream(ts, pid, stream_identifier, i);
+st = find_matching_stream(ts, pid, h->id, stream_identifier, 
i);
 }
 if (!st) {
 st = avformat_new_stream(ts->stream, NULL);
-- 
2.16.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] mlpenc: fix lossless failures, add sanity checks

2019-07-09 Thread Jai Luthra

On Tue, Jul 09, 2019 at 08:26:19PM +0200, Carl Eugen Hoyos wrote:


Please split the patch into self-contained changes with appropriate commit 
messages.

Thank you, Carl Eugen


Cool, I've done more fixes will send a new patch set as a separate thread

thx
___
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] [PATCHv4] avcodec: Add librav1e encoder

2019-07-09 Thread Moritz Barsnick
Hi,

On Tue, Jul 09, 2019 at 19:34:33 +0100, Derek Buitenhuis wrote:
> Port to the new send/receive API by: James Almer .

Two nits:

> +Sets the minimum quantizer (ceiling) to use when in bitrate mdoe.

Typo -> "mode"

> +av_log(avctx, AV_LOG_ERROR, "Unknown return code from 
> rav1e_send_frame.\n");
> +return AVERROR_UNKNOWN;

Feel free to include the error code in the message, as you did in
librav1e_receive_packet().

Moritz
___
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/5] mlpenc: prevent negative lsb_bits lshift

2019-07-09 Thread Jai Luthra
Fixes Coverity CID 1396239.

Signed-off-by: Jai Luthra 
---
 libavcodec/mlpenc.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 1cee38c82f..41030f6f07 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1,6 +1,7 @@
 /**
  * MLP encoder
  * Copyright (c) 2008 Ramiro Polla
+ * Copyright (c) 2016-2019 Jai Luthra
  *
  * This file is part of FFmpeg.
  *
@@ -1562,7 +1563,7 @@ static void no_codebook_bits_offset(MLPEncodeContext *ctx,
 BestOffset *bo)
 {
 DecodingParams *dp = ctx->cur_decoding_params;
-int32_t unsign;
+int32_t unsign = 0;
 int lsb_bits;
 
 min -= offset;
@@ -1572,7 +1573,8 @@ static void no_codebook_bits_offset(MLPEncodeContext *ctx,
 
 lsb_bits += !!lsb_bits;
 
-unsign = 1 << (lsb_bits - 1);
+if (lsb_bits > 0)
+unsign = 1 << (lsb_bits - 1);
 
 bo->offset   = offset;
 bo->lsb_bits = lsb_bits;
@@ -1591,7 +1593,7 @@ static void no_codebook_bits(MLPEncodeContext *ctx,
 {
 DecodingParams *dp = ctx->cur_decoding_params;
 int16_t offset;
-int32_t unsign;
+int32_t unsign = 0;
 uint32_t diff;
 int lsb_bits;
 
@@ -1607,7 +1609,8 @@ static void no_codebook_bits(MLPEncodeContext *ctx,
 
 lsb_bits = number_sbits(diff) - 1;
 
-unsign = 1 << (lsb_bits - 1);
+if (lsb_bits > 0)
+unsign = 1 << (lsb_bits - 1);
 
 /* If all samples are the same (lsb_bits == 0), offset must be
  * adjusted because of sign_shift. */
-- 
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/5] mlpenc: improve lpc filtering

2019-07-09 Thread Jai Luthra
* fix a possible memory leak (apply_filter returned before freeing)
* use apply_filters in process_major_frame
* revert back to checking bounds with 24 bitdepth, as huff offset takes
care of it

Signed-off-by: Jai Luthra 
---
 libavcodec/mlpenc.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 41030f6f07..9805e7ff23 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1799,7 +1799,7 @@ static void determine_bits(MLPEncodeContext *ctx)
 
 /** Applies the filter to the current samples, and saves the residual back
  *  into the samples buffer. If the filter is too bad and overflows the
- *  maximum amount of bits allowed (16 or 24), the samples buffer is left as 
is and
+ *  maximum amount of bits allowed (24), the samples buffer is left as is and
  *  the function returns -1.
  */
 static int apply_filter(MLPEncodeContext *ctx, unsigned int channel)
@@ -1812,7 +1812,7 @@ static int apply_filter(MLPEncodeContext *ctx, unsigned 
int channel)
 unsigned int number_of_samples = ctx->number_of_samples;
 unsigned int filter_shift = fp[FIR]->shift;
 int filter;
-int i;
+int i, ret = 0;
 
 for (i = 0; i < NUM_FILTERS; i++) {
 unsigned int size = ctx->number_of_samples;
@@ -1835,7 +1835,7 @@ static int apply_filter(MLPEncodeContext *ctx, unsigned 
int channel)
 int32_t sample = *sample_buffer;
 unsigned int order;
 int64_t accum = 0;
-int32_t residual;
+int64_t residual;
 
 for (filter = 0; filter < NUM_FILTERS; filter++) {
 int32_t *fcoeff = ctx->cur_channel_params[channel].coeff[filter];
@@ -1847,11 +1847,13 @@ static int apply_filter(MLPEncodeContext *ctx, unsigned 
int channel)
 accum  >>= filter_shift;
 residual = sample - (accum & mask);
 
-if (residual < SAMPLE_MIN(ctx->wordlength) || residual > 
SAMPLE_MAX(ctx->wordlength))
-return -1;
+if (residual < SAMPLE_MIN(24) || residual > SAMPLE_MAX(24)) {
+ret = -1;
+goto free_and_return;
+}
 
 filter_state_buffer[FIR][i] = sample;
-filter_state_buffer[IIR][i] = residual;
+filter_state_buffer[IIR][i] = (int32_t) residual;
 
 sample_buffer += ctx->num_channels;
 }
@@ -1863,11 +1865,12 @@ static int apply_filter(MLPEncodeContext *ctx, unsigned 
int channel)
 sample_buffer += ctx->num_channels;
 }
 
+free_and_return:
 for (i = 0; i < NUM_FILTERS; i++) {
 av_freep(_state_buffer[i]);
 }
 
-return 0;
+return ret;
 }
 
 static void apply_filters(MLPEncodeContext *ctx)
@@ -2209,8 +2212,7 @@ static void process_major_frame(MLPEncodeContext *ctx)
 generate_2_noise_channels(ctx);
 rematrix_channels(ctx);
 
-for (channel = rh->min_channel; channel <= rh->max_channel; channel++)
-apply_filter(ctx, channel);
+apply_filters(ctx);
 }
 }
 
-- 
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/5] mlpenc: clean up and enable 24-bit encoding

2019-07-09 Thread Jai Luthra
Signed-off-by: Jai Luthra 
---
 libavcodec/mlpenc.c | 34 --
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 9805e7ff23..4124df6d8f 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -94,8 +94,8 @@ typedef struct BestOffset {
 int16_t max;
 } BestOffset;
 
-#define HUFF_OFFSET_MIN-16384
-#define HUFF_OFFSET_MAX 16383
+#define HUFF_OFFSET_MIN(-16384)
+#define HUFF_OFFSET_MAX( 16383)
 
 /** Number of possible codebooks (counting "no codebooks") */
 #define NUM_CODEBOOKS   4
@@ -808,7 +808,7 @@ static void write_major_sync(MLPEncodeContext *ctx, uint8_t 
*buf, int buf_size)
 static void write_restart_header(MLPEncodeContext *ctx, PutBitContext *pb)
 {
 RestartHeader *rh = ctx->cur_restart_header;
-int32_t lossless_check = xor_32_to_8(rh->lossless_check_data);
+uint8_t lossless_check = xor_32_to_8(rh->lossless_check_data);
 unsigned int start_count = put_bits_count(pb);
 PutBitContext tmpb;
 uint8_t checksum;
@@ -1017,12 +1017,10 @@ static void write_block_data(MLPEncodeContext *ctx, 
PutBitContext *pb)
 codebook_index  [ch] = cp->codebook  - 1;
 sign_huff_offset[ch] = cp->huff_offset;
 
-sign_shift = lsb_bits[ch] - 1;
+sign_shift = lsb_bits[ch] + (cp->codebook ? 2 - cp->codebook : -1);
 
-if (cp->codebook > 0) {
+if (cp->codebook > 0)
 sign_huff_offset[ch] -= 7 << lsb_bits[ch];
-sign_shift += 3 - cp->codebook;
-}
 
 /* Unsign if needed. */
 if (sign_shift >= 0)
@@ -1032,7 +1030,6 @@ static void write_block_data(MLPEncodeContext *ctx, 
PutBitContext *pb)
 for (i = 0; i < dp->blocksize; i++) {
 for (ch = rh->min_channel; ch <= rh->max_channel; ch++) {
 int32_t sample = *sample_buffer++ >> dp->quant_step_size[ch];
-
 sample -= sign_huff_offset[ch];
 
 if (codebook_index[ch] >= 0) {
@@ -1252,7 +1249,7 @@ static void input_data_internal(MLPEncodeContext *ctx, 
const uint8_t *samples,
 uint32_t abs_sample;
 int32_t sample;
 
-sample = is24 ? *samples_32++ >> 8 : *samples_16++ << 8;
+sample = is24 ? *samples_32++ >> 8 : *samples_16++ * 256U;
 
 /* TODO Find out if number_sbits can be used for negative 
values. */
 abs_sample = FFABS(sample);
@@ -1795,7 +1792,7 @@ static void determine_bits(MLPEncodeContext *ctx)
 #define SAMPLE_MAX(bitdepth) ((1 << (bitdepth - 1)) - 1)
 #define SAMPLE_MIN(bitdepth) (~SAMPLE_MAX(bitdepth))
 
-#define MSB_MASK(bits)  (-1u << bits)
+#define MSB_MASK(bits)  (-(1u << (bits)))
 
 /** Applies the filter to the current samples, and saves the residual back
  *  into the samples buffer. If the filter is too bad and overflows the
@@ -1899,8 +1896,8 @@ static void generate_2_noise_channels(MLPEncodeContext 
*ctx)
 
 for (i = 0; i < ctx->number_of_samples; i++) {
 uint16_t seed_shr7 = seed >> 7;
-*sample_buffer++ = ((int8_t)(seed >> 15)) << rh->noise_shift;
-*sample_buffer++ = ((int8_t) seed_shr7)   << rh->noise_shift;
+*sample_buffer++ = ((int8_t)(seed >> 15)) * (1 << rh->noise_shift);
+*sample_buffer++ = ((int8_t) seed_shr7)   * (1 << rh->noise_shift);
 
 seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5);
 
@@ -2071,9 +2068,10 @@ static void set_best_codebook(MLPEncodeContext *ctx)
 best_codebook = *best_path++ - ZERO_PATH;
 cur_bo = >best_offset[index][channel][best_codebook];
 
-cp->huff_offset = cur_bo->offset;
-cp->huff_lsbs   = cur_bo->lsb_bits + dp->quant_step_size[channel];
-cp->codebook= best_codebook;
+cp->huff_offset  = cur_bo->offset;
+cp->sign_huff_offset = -(1 << 23);
+cp->huff_lsbs= cur_bo->lsb_bits + 
dp->quant_step_size[channel];
+cp->codebook = best_codebook;
 }
 }
 }
@@ -2278,7 +2276,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 if (restart_frame) {
 set_major_params(ctx);
 if (ctx->min_restart_interval != ctx->max_restart_interval)
-process_major_frame(ctx);
+process_major_frame(ctx);
 }
 
 if (ctx->min_restart_interval == ctx->max_restart_interval)
@@ -2392,7 +2390,7 @@ AVCodec ff_mlp_encoder = {
 .encode2= mlp_encode_frame,
 .close  = mlp_encode_close,
 .capabilities   = AV_CODEC_CAP_SMALL_LAST_FRAME | 
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_EXPERIMENTAL,
-.sample_fmts= (const enum AVSampleFormat[]) 
{AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE},
+.sample_fmts= (const enum AVSampleFormat[]) 
{AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE},
 .supported_samplerates  = (const int[]) {44100, 48000, 88200, 96000, 
176400, 192000, 0},
 

[FFmpeg-devel] [PATCH 1/5] mlpenc: fix lossless check error in number_sbits

2019-07-09 Thread Jai Luthra
we need two bits instead of one bit to represent -1 in bitstream

Signed-off-by: Jai Luthra 
---
 libavcodec/mlpenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index deb171645c..f4948451f1 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -466,7 +466,7 @@ static void default_decoding_params(MLPEncodeContext *ctx,
  */
 static int inline number_sbits(int number)
 {
-if (number < 0)
+if (number < -1)
 number++;
 
 return av_log2(FFABS(number)) + 1 + !!number;
-- 
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/5] mlpenc: fix huff offset calculation

2019-07-09 Thread Jai Luthra
huff offset wasn't always within the bounds before, which lead to
corrupt encoding that didn't always trigger lossless check failures

Signed-off-by: Jai Luthra 
---
 libavcodec/mlpenc.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index f4948451f1..1cee38c82f 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1699,7 +1699,7 @@ static inline void codebook_bits(MLPEncodeContext *ctx,
 offset_min = FFMAX(min, HUFF_OFFSET_MIN);
 offset_max = FFMIN(max, HUFF_OFFSET_MAX);
 
-for (;;) {
+while (offset <= offset_max && offset >= offset_min) {
 BestOffset temp_bo;
 
 codebook_bits_offset(ctx, channel, codebook,
@@ -1718,12 +1718,8 @@ static inline void codebook_bits(MLPEncodeContext *ctx,
 
 if (direction) {
 offset = temp_bo.max + 1;
-if (offset > offset_max)
-break;
 } else {
 offset = temp_bo.min - 1;
-if (offset < offset_min)
-break;
 }
 }
 }
-- 
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] [PATCHv2] avformat/movenc: use unspecified language by default

2019-07-09 Thread Marton Balint
English was used before.

Signed-off-by: Marton Balint 
---
 Changelog  | 1 +
 libavformat/movenc.c   | 2 +-
 libavformat/version.h  | 2 +-
 tests/ref/acodec/alac  | 2 +-
 tests/ref/acodec/pcm-s16be | 2 +-
 tests/ref/acodec/pcm-s24be | 2 +-
 tests/ref/acodec/pcm-s32be | 2 +-
 tests/ref/acodec/pcm-s8| 2 +-
 tests/ref/fate/adtstoasc_ticket3715| 2 +-
 tests/ref/lavf/mov | 6 +++---
 tests/ref/lavf/mov_rtphint | 2 +-
 tests/ref/vsynth/vsynth1-avui  | 2 +-
 tests/ref/vsynth/vsynth1-dnxhd-1080i   | 2 +-
 tests/ref/vsynth/vsynth1-dnxhd-1080i-10bit | 2 +-
 tests/ref/vsynth/vsynth1-dnxhd-1080i-colr  | 2 +-
 tests/ref/vsynth/vsynth1-dnxhd-hr-hq-mov   | 2 +-
 tests/ref/vsynth/vsynth1-dnxhd-hr-lb-mov   | 2 +-
 tests/ref/vsynth/vsynth1-dnxhd-hr-sq-mov   | 2 +-
 tests/ref/vsynth/vsynth1-mov-bgr24 | 2 +-
 tests/ref/vsynth/vsynth1-mov-bpp15 | 2 +-
 tests/ref/vsynth/vsynth1-mov-bpp16 | 2 +-
 tests/ref/vsynth/vsynth1-prores| 2 +-
 tests/ref/vsynth/vsynth1-prores_444| 2 +-
 tests/ref/vsynth/vsynth1-prores_444_int| 2 +-
 tests/ref/vsynth/vsynth1-prores_int| 2 +-
 tests/ref/vsynth/vsynth1-prores_ks | 2 +-
 tests/ref/vsynth/vsynth1-qtrle | 2 +-
 tests/ref/vsynth/vsynth1-qtrlegray | 2 +-
 tests/ref/vsynth/vsynth1-svq1  | 2 +-
 tests/ref/vsynth/vsynth1-vc2-420p  | 2 +-
 tests/ref/vsynth/vsynth1-vc2-420p10| 2 +-
 tests/ref/vsynth/vsynth1-vc2-420p12| 2 +-
 tests/ref/vsynth/vsynth1-vc2-422p  | 2 +-
 tests/ref/vsynth/vsynth1-vc2-422p10| 2 +-
 tests/ref/vsynth/vsynth1-vc2-422p12| 2 +-
 tests/ref/vsynth/vsynth1-vc2-444p  | 2 +-
 tests/ref/vsynth/vsynth1-vc2-444p10| 2 +-
 tests/ref/vsynth/vsynth1-vc2-444p12| 2 +-
 tests/ref/vsynth/vsynth1-vc2-t5_3  | 2 +-
 tests/ref/vsynth/vsynth1-vc2-thaar | 2 +-
 tests/ref/vsynth/vsynth2-avui  | 2 +-
 tests/ref/vsynth/vsynth2-dnxhd-1080i   | 2 +-
 tests/ref/vsynth/vsynth2-dnxhd-1080i-10bit | 2 +-
 tests/ref/vsynth/vsynth2-dnxhd-1080i-colr  | 2 +-
 tests/ref/vsynth/vsynth2-dnxhd-hr-hq-mov   | 2 +-
 tests/ref/vsynth/vsynth2-dnxhd-hr-lb-mov   | 2 +-
 tests/ref/vsynth/vsynth2-dnxhd-hr-sq-mov   | 2 +-
 tests/ref/vsynth/vsynth2-mov-bgr24 | 2 +-
 tests/ref/vsynth/vsynth2-mov-bpp15 | 2 +-
 tests/ref/vsynth/vsynth2-mov-bpp16 | 2 +-
 tests/ref/vsynth/vsynth2-prores| 2 +-
 tests/ref/vsynth/vsynth2-prores_444| 2 +-
 tests/ref/vsynth/vsynth2-prores_444_int| 2 +-
 tests/ref/vsynth/vsynth2-prores_int| 2 +-
 tests/ref/vsynth/vsynth2-prores_ks | 2 +-
 tests/ref/vsynth/vsynth2-qtrle | 2 +-
 tests/ref/vsynth/vsynth2-qtrlegray | 2 +-
 tests/ref/vsynth/vsynth2-svq1  | 2 +-
 tests/ref/vsynth/vsynth2-vc2-420p  | 2 +-
 tests/ref/vsynth/vsynth2-vc2-420p10| 2 +-
 tests/ref/vsynth/vsynth2-vc2-420p12| 2 +-
 tests/ref/vsynth/vsynth2-vc2-422p  | 2 +-
 tests/ref/vsynth/vsynth2-vc2-422p10| 2 +-
 tests/ref/vsynth/vsynth2-vc2-422p12| 2 +-
 tests/ref/vsynth/vsynth2-vc2-444p  | 2 +-
 tests/ref/vsynth/vsynth2-vc2-444p10| 2 +-
 tests/ref/vsynth/vsynth2-vc2-444p12| 2 +-
 tests/ref/vsynth/vsynth2-vc2-t5_3  | 2 +-
 tests/ref/vsynth/vsynth2-vc2-thaar | 2 +-
 tests/ref/vsynth/vsynth3-dnxhd-1080i-10bit | 2 +-
 tests/ref/vsynth/vsynth3-dnxhd-1080i-colr  | 2 +-
 tests/ref/vsynth/vsynth3-dnxhd-hr-hq-mov   | 2 +-
 tests/ref/vsynth/vsynth3-dnxhd-hr-lb-mov   | 2 +-
 tests/ref/vsynth/vsynth3-dnxhd-hr-sq-mov   | 2 +-
 tests/ref/vsynth/vsynth3-mov-bgr24 | 2 +-
 tests/ref/vsynth/vsynth3-mov-bpp15 | 2 +-
 tests/ref/vsynth/vsynth3-mov-bpp16 | 2 +-
 tests/ref/vsynth/vsynth3-prores| 2 +-
 tests/ref/vsynth/vsynth3-prores_444| 2 +-
 tests/ref/vsynth/vsynth3-prores_444_int| 2 +-
 tests/ref/vsynth/vsynth3-prores_int| 2 +-
 tests/ref/vsynth/vsynth3-prores_ks | 2 +-
 tests/ref/vsynth/vsynth3-qtrle | 2 +-
 tests/ref/vsynth/vsynth3-svq1  | 2 +-
 tests/ref/vsynth/vsynth_lena-avui  | 2 +-
 tests/ref/vsynth/vsynth_lena-dnxhd-1080i   | 2 +-
 tests/ref/vsynth/vsynth_lena-dnxhd-1080i-10bit | 2 +-
 tests/ref/vsynth/vsynth_lena-dnxhd-1080i-colr  | 2 +-
 tests/ref/vsynth/vsynth_lena-dnxhd-hr-hq-mov   | 2 +-
 

Re: [FFmpeg-devel] [PATCHv4] avcodec: Add librav1e encoder

2019-07-09 Thread Derek Buitenhuis
On 09/07/2019 19:34, Derek Buitenhuis wrote:
> * Added two pass support.

As a side note, I really dislike the stats_out/stats_in API, since it requires
the whole stats be held in memory. This my become problematic when rav1e adds
temporal RDO (think mbtree) and the stats files grow a lot.

- Derek
___
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] [PATCHv4] avcodec: Add librav1e encoder

2019-07-09 Thread Derek Buitenhuis
On 09/07/2019 19:34, Derek Buitenhuis wrote:
> +Go to @url{https://github.com/lu-zero/crav1e/} and follow the instructions 
> to build
> +the C library. To enable using rav1e in FFmpeg, pass @code{--enable-librav1e}
> +to @file{./configure}.

Eugh. This is supposed to point to https://github.com/xiph/rav1e/. Woops.

Amended locally.

- Derek
___
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] [PATCHv4] avcodec: Add librav1e encoder

2019-07-09 Thread Derek Buitenhuis
Port to the new send/receive API by: James Almer .

Signed-off-by: Derek Buitenhuis 
---
Lots of stuff happened since v3!

* The C API / library is now in rav1e's main repo, and officially supported.
* rav1e will bump the soname and pkg-config version on any breaking changes.
* C API is now as fast as the Rust API.
* Added two pass support.
* Added min quantizer support.
* Added tiles / speed to AVOptions.
* Mapped min/max keyint.
* Applied all the fixes requested in the last round.
---
 configure  |   4 +
 doc/encoders.texi  |  37 +++
 doc/general.texi   |   7 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/librav1e.c  | 578 +
 6 files changed, 628 insertions(+)
 create mode 100644 libavcodec/librav1e.c

diff --git a/configure b/configure
index 4005987409..7e93812824 100755
--- a/configure
+++ b/configure
@@ -254,6 +254,7 @@ External library support:
   --enable-libopenmpt  enable decoding tracked files via libopenmpt [no]
   --enable-libopus enable Opus de/encoding via libopus [no]
   --enable-libpulseenable Pulseaudio input via libpulse [no]
+  --enable-librav1eenable AV1 encoding via rav1e [no]
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
   --enable-librtmp enable RTMP[E] support via librtmp [no]
@@ -1778,6 +1779,7 @@ EXTERNAL_LIBRARY_LIST="
 libopenmpt
 libopus
 libpulse
+librav1e
 librsvg
 librtmp
 libshine
@@ -3174,6 +3176,7 @@ libopenmpt_demuxer_deps="libopenmpt"
 libopus_decoder_deps="libopus"
 libopus_encoder_deps="libopus"
 libopus_encoder_select="audio_frame_queue"
+librav1e_encoder_deps="librav1e"
 librsvg_decoder_deps="librsvg"
 libshine_encoder_deps="libshine"
 libshine_encoder_select="audio_frame_queue"
@@ -6215,6 +6218,7 @@ enabled libopus   && {
 }
 }
 enabled libpulse  && require_pkg_config libpulse libpulse 
pulse/pulseaudio.h pa_context_new
+enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.1.0" 
rav1e.h rav1e_context_new
 enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
 enabled librtmp   && require_pkg_config librtmp librtmp librtmp/rtmp.h 
RTMP_Socket
 enabled librubberband && require_pkg_config librubberband "rubberband >= 
1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
librubberband_extralibs "-lstdc++"
diff --git a/doc/encoders.texi b/doc/encoders.texi
index eefd124751..f316725409 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1378,6 +1378,43 @@ makes it possible to store non-rgb pix_fmts.
 
 @end table
 
+@section librav1e
+
+rav1e AV1 encoder wrapper.
+
+Requires the presence of the rav1e headers and library during configuration.
+You need to explicitly configure the build with @code{--enable-librav1e}.
+
+@subsection Options
+
+@table @option
+@item qmax
+Sets the maximum quantizer (floor) to use when using bitrate mode.
+
+@item qmin
+Sets the minimum quantizer (ceiling) to use when in bitrate mdoe.
+
+@item qp
+Uses quantizer mode to encode at the given quantizer.
+
+@item speed
+Selects the speed preset (0-9) to encode with.
+
+@item tiles
+Selects how many tiles to encode with.
+
+@item rav1e-params
+Set rav1e options using a list of @var{key}=@var{value} pairs separated
+by ":". See @command{rav1e --help} for a list of options.
+
+For example to specify librav1e encoding options with @option{-rav1e-params}:
+
+@example
+ffmpeg -i input -c:v librav1e -b:v 500K -rav1e-params speed=5:low_latency=true 
output.mp4
+@end example
+
+@end table
+
 @section libaom-av1
 
 libaom AV1 encoder wrapper.
diff --git a/doc/general.texi b/doc/general.texi
index 3c0c803449..72a6d73f33 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -243,6 +243,13 @@ FFmpeg can use the OpenJPEG libraries for 
decoding/encoding J2K videos.  Go to
 instructions.  To enable using OpenJPEG in FFmpeg, pass 
@code{--enable-libopenjpeg} to
 @file{./configure}.
 
+@section rav1e
+
+FFmpeg can make use of rav1e (Rust AV1 Encoder) via its C bindings to encode 
videos.
+Go to @url{https://github.com/lu-zero/crav1e/} and follow the instructions to 
build
+the C library. To enable using rav1e in FFmpeg, pass @code{--enable-librav1e}
+to @file{./configure}.
+
 @section TwoLAME
 
 FFmpeg can make use of the TwoLAME library for MP2 encoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..cebc9d2ebc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -988,6 +988,7 @@ OBJS-$(CONFIG_LIBOPUS_DECODER)+= libopusdec.o 
libopus.o \
  vorbis_data.o
 OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o libopus.o \
  vorbis_data.o
+OBJS-$(CONFIG_LIBRAV1E_ENCODER)  

Re: [FFmpeg-devel] [PATCH] mlpenc: fix lossless failures, add sanity checks

2019-07-09 Thread Carl Eugen Hoyos



> Am 09.07.2019 um 19:23 schrieb Jai Luthra :
> 
> Signed-off-by: Jai Luthra 
> ---
> libavcodec/mlpenc.c | 72 +++--
> 1 file changed, 37 insertions(+), 35 deletions(-)
> 
> diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
> index deb171645c..09a8336b47 100644
> --- a/libavcodec/mlpenc.c
> +++ b/libavcodec/mlpenc.c
> @@ -1,6 +1,7 @@
> /**
>  * MLP encoder
>  * Copyright (c) 2008 Ramiro Polla
> + * Copyright (c) 2016-2019 Jai Luthra
>  *
>  * This file is part of FFmpeg.
>  *
> @@ -26,6 +27,7 @@
> #include "libavutil/crc.h"
> #include "libavutil/avstring.h"
> #include "libavutil/samplefmt.h"
> +#include "libavutil/avassert.h"
> #include "mlp.h"
> #include "lpc.h"
> 
> @@ -93,8 +95,8 @@ typedef struct BestOffset {
> int16_t max;
> } BestOffset;
> 
> -#define HUFF_OFFSET_MIN-16384
> -#define HUFF_OFFSET_MAX 16383
> +#define HUFF_OFFSET_MIN(-16384)
> +#define HUFF_OFFSET_MAX( 16383)

Please split the patch into self-contained changes with appropriate commit 
messages.

Thank you, 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] mlpenc: fix lossless failures, add sanity checks

2019-07-09 Thread Jai Luthra
Signed-off-by: Jai Luthra 
---
 libavcodec/mlpenc.c | 72 +++--
 1 file changed, 37 insertions(+), 35 deletions(-)

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index deb171645c..09a8336b47 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1,6 +1,7 @@
 /**
  * MLP encoder
  * Copyright (c) 2008 Ramiro Polla
+ * Copyright (c) 2016-2019 Jai Luthra
  *
  * This file is part of FFmpeg.
  *
@@ -26,6 +27,7 @@
 #include "libavutil/crc.h"
 #include "libavutil/avstring.h"
 #include "libavutil/samplefmt.h"
+#include "libavutil/avassert.h"
 #include "mlp.h"
 #include "lpc.h"
 
@@ -93,8 +95,8 @@ typedef struct BestOffset {
 int16_t max;
 } BestOffset;
 
-#define HUFF_OFFSET_MIN-16384
-#define HUFF_OFFSET_MAX 16383
+#define HUFF_OFFSET_MIN(-16384)
+#define HUFF_OFFSET_MAX( 16383)
 
 /** Number of possible codebooks (counting "no codebooks") */
 #define NUM_CODEBOOKS   4
@@ -466,9 +468,6 @@ static void default_decoding_params(MLPEncodeContext *ctx,
  */
 static int inline number_sbits(int number)
 {
-if (number < 0)
-number++;
-
 return av_log2(FFABS(number)) + 1 + !!number;
 }
 
@@ -807,7 +806,7 @@ static void write_major_sync(MLPEncodeContext *ctx, uint8_t 
*buf, int buf_size)
 static void write_restart_header(MLPEncodeContext *ctx, PutBitContext *pb)
 {
 RestartHeader *rh = ctx->cur_restart_header;
-int32_t lossless_check = xor_32_to_8(rh->lossless_check_data);
+uint8_t lossless_check = xor_32_to_8(rh->lossless_check_data);
 unsigned int start_count = put_bits_count(pb);
 PutBitContext tmpb;
 uint8_t checksum;
@@ -1016,12 +1015,10 @@ static void write_block_data(MLPEncodeContext *ctx, 
PutBitContext *pb)
 codebook_index  [ch] = cp->codebook  - 1;
 sign_huff_offset[ch] = cp->huff_offset;
 
-sign_shift = lsb_bits[ch] - 1;
+sign_shift = lsb_bits[ch] + (cp->codebook ? 2 - cp->codebook : -1);
 
-if (cp->codebook > 0) {
+if (cp->codebook > 0)
 sign_huff_offset[ch] -= 7 << lsb_bits[ch];
-sign_shift += 3 - cp->codebook;
-}
 
 /* Unsign if needed. */
 if (sign_shift >= 0)
@@ -1031,7 +1028,6 @@ static void write_block_data(MLPEncodeContext *ctx, 
PutBitContext *pb)
 for (i = 0; i < dp->blocksize; i++) {
 for (ch = rh->min_channel; ch <= rh->max_channel; ch++) {
 int32_t sample = *sample_buffer++ >> dp->quant_step_size[ch];
-
 sample -= sign_huff_offset[ch];
 
 if (codebook_index[ch] >= 0) {
@@ -1251,7 +1247,7 @@ static void input_data_internal(MLPEncodeContext *ctx, 
const uint8_t *samples,
 uint32_t abs_sample;
 int32_t sample;
 
-sample = is24 ? *samples_32++ >> 8 : *samples_16++ << 8;
+sample = is24 ? *samples_32++ >> 8 : *samples_16++ * 256U;
 
 /* TODO Find out if number_sbits can be used for negative 
values. */
 abs_sample = FFABS(sample);
@@ -1591,7 +1587,7 @@ static void no_codebook_bits(MLPEncodeContext *ctx,
 {
 DecodingParams *dp = ctx->cur_decoding_params;
 int16_t offset;
-int32_t unsign;
+int32_t unsign = 0;
 uint32_t diff;
 int lsb_bits;
 
@@ -1607,7 +1603,8 @@ static void no_codebook_bits(MLPEncodeContext *ctx,
 
 lsb_bits = number_sbits(diff) - 1;
 
-unsign = 1 << (lsb_bits - 1);
+if (lsb_bits > 0)
+unsign = 1 << (lsb_bits - 1);
 
 /* If all samples are the same (lsb_bits == 0), offset must be
  * adjusted because of sign_shift. */
@@ -1699,7 +1696,7 @@ static inline void codebook_bits(MLPEncodeContext *ctx,
 offset_min = FFMAX(min, HUFF_OFFSET_MIN);
 offset_max = FFMIN(max, HUFF_OFFSET_MAX);
 
-for (;;) {
+while (offset <= offset_max && offset >= offset_min) {
 BestOffset temp_bo;
 
 codebook_bits_offset(ctx, channel, codebook,
@@ -1709,6 +1706,7 @@ static inline void codebook_bits(MLPEncodeContext *ctx,
 if (temp_bo.bitcount < previous_count) {
 if (temp_bo.bitcount < bo->bitcount)
 *bo = temp_bo;
+av_assert0(bo->offset <= HUFF_OFFSET_MAX && bo->offset >= 
HUFF_OFFSET_MIN);
 
 is_greater = 0;
 } else if (++is_greater >= ctx->max_codebook_search)
@@ -1718,12 +1716,8 @@ static inline void codebook_bits(MLPEncodeContext *ctx,
 
 if (direction) {
 offset = temp_bo.max + 1;
-if (offset > offset_max)
-break;
 } else {
 offset = temp_bo.min - 1;
-if (offset < offset_min)
-break;
 }
 }
 }
@@ -1796,11 +1790,11 @@ static void determine_bits(MLPEncodeContext *ctx)
 #define SAMPLE_MAX(bitdepth) ((1 << (bitdepth - 1)) - 1)
 #define SAMPLE_MIN(bitdepth) (~SAMPLE_MAX(bitdepth))
 
-#define MSB_MASK(bits)  (-1u << bits)
+#define MSB_MASK(bits)  (-(1u << (bits)))
 
 /** Applies the filter to the current 

Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: fix video frame lost sync for the dual input ts files with audio

2019-07-09 Thread Michael Niedermayer
On Mon, Jul 08, 2019 at 06:34:12PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> How to reproduce the problem(use two ts files with audio stream):
> ffmpeg -i left_w_a.ts -i right_w_a.ts -filter_complex "hstack=inputs=2" -f 
> null -
> 
> With above command, the audio stream of the second input will be discarded 
> default, however the start_time is 
> initalized from the audio stream, so the old code will try to correct the ts 
> offset in the condition which will
> cause the video frame out of sync and report some dts error like below:
> [null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
> increasing dts to muxer in stream 0: 43 >= 43
> [null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
> increasing dts to muxer in stream 0: 44 >= 44
> [null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
> increasing dts to muxer in stream 0: 45 >= 45
> [null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
> increasing dts to muxer in stream 0: 46 >= 46
> [null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
> increasing dts to muxer in stream 0: 47 >= 47
> 
> Or you can try with below command to reproduce the issue:
> ffmpeg -i input_w_a.ts -i input_w_a.ts -filter_complex "ssim=f=ssim.log" -f 
> null -
> 
> You'll get below ssim result which isn't expected result for the two input is 
> same, the SSIM should be 1.0
> SSIM Y:0.777353 (6.523822) U:0.964087 (14.447539) V:0.966739 (14.780661) 
> All:0.840039 (7.959872)
> 
> With the patch applied, the above testing command can get expected result.
> 
> other solution are: use the setpts=PTS-STARTPTS filter or skip all audio 
> stream to avoid the timestamp adjustment.
> 
> Signed-off-by: Limin Wang 
> ---
>  fftools/ffmpeg.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

this breaks fate-mpeg2-ticket186

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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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] avcodec/truemotion2: Fix several integer overflows in tm2_motion_block()

2019-07-09 Thread Michael Niedermayer
Fixes: 
15524/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-5173148372172800
Fixes: signed integer overflow: 13701388 - -2134868270 cannot be represented in 
type 'int'

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/truemotion2.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index a86dd16e0f..5d6dfc24c3 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -764,10 +764,10 @@ static inline void tm2_motion_block(TM2Context *ctx, 
AVFrame *pic, int bx, int b
 }
 /* calculate deltas */
 Y -= Ystride * 4;
-ctx->D[0] = Y[3] - last[3];
-ctx->D[1] = Y[3 + Ystride] - Y[3];
-ctx->D[2] = Y[3 + Ystride * 2] - Y[3 + Ystride];
-ctx->D[3] = Y[3 + Ystride * 3] - Y[3 + Ystride * 2];
+ctx->D[0] = (unsigned)Y[3] - last[3];
+ctx->D[1] = (unsigned)Y[3 + Ystride] - Y[3];
+ctx->D[2] = (unsigned)Y[3 + Ystride * 2] - Y[3 + Ystride];
+ctx->D[3] = (unsigned)Y[3 + Ystride * 3] - Y[3 + Ystride * 2];
 for (i = 0; i < 4; i++)
 last[i] = Y[i + Ystride * 3];
 }
-- 
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] MIPS: replace addi with addiu

2019-07-09 Thread Shiyou Yin
>-Original Message-
>From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
>On Behalf Of
>YunQiang Su
>Sent: Tuesday, July 2, 2019 11:53 AM
>To: ffmpeg-devel@ffmpeg.org
>Cc: YunQiang Su
>Subject: [FFmpeg-devel] [PATCH] MIPS: replace addi with addiu
>
>addi/daddi are deprecated by MIPS for years, and MIPS r6 remove
>them.
>
>They should be replace with addiu:
>   ADDIU performs the same arithmetic operation but
>   does not trap on overflow.
>---
> libavcodec/mips/cabac.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/libavcodec/mips/cabac.h b/libavcodec/mips/cabac.h
>index 82cee29..2a05e5a 100644
>--- a/libavcodec/mips/cabac.h
>+++ b/libavcodec/mips/cabac.h
>@@ -72,7 +72,7 @@ static av_always_inline int get_cabac_inline(CABACContext *c,
>
> "and  %[tmp0],   %[c_low],   %[cabac_mask] \n\t"
> "bnez %[tmp0],   1f\n\t"
>-PTR_ADDI "%[tmp0],   %[c_low],   -0X01 \n\t"
>+PTR_ADDIU"%[tmp0],   %[c_low],   -0x01 \n\t"
> "xor  %[tmp0],   %[c_low],   %[tmp0]   \n\t"
> PTR_SRA  "%[tmp0],   %[tmp0],0x0f  \n\t"
> PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
>--
>2.20.1
>

good suggestion.


___
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] libavformat/hlsenc.c Accurrate time output in program_date_time (corrected)

2019-07-09 Thread myp...@gmail.com
On Tue, Jul 9, 2019 at 7:42 PM Pavel Pilar  wrote:
>
> ---
>  libavformat/hlsenc.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 00c725af18..94fd713834 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -2653,6 +2653,9 @@ static int hls_init(AVFormatContext *s)
>  char *p = NULL;
>  int vtt_basename_size = 0;
>  int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;
> +#ifdef _POSIX_TIMERS
> +struct timespec now_accurate;
> +#endif
>
>  hls->has_default_key = 0;
>  hls->has_video_m3u8 = 0;
> @@ -2742,14 +2745,13 @@ static int hls_init(AVFormatContext *s)
>  }
>
>  if (hls->flags & HLS_PROGRAM_DATE_TIME) {
> -#ifdef _POSIX_TIMERS
> -struct timespec now0;
> -clock_gettime(CLOCK_MONOTONIC, );
> -vs->initial_prog_date_time = now0.tv_sec + now0.tv_nsec / 1e9;
> -#else
>  time_t now0;
>  time();
>  vs->initial_prog_date_time = now0;
> +#ifdef _POSIX_TIMERS
> +if (clock_gettime(CLOCK_REALTIME, _accurate) == 0) {
> +vs->initial_prog_date_time = now_accurate.tv_sec + 
> now_accurate.tv_nsec / 1e9;
> +}
>  #endif
>  }
>  if (hls->format_options_str) {
> --
> 2.17.1
As my comments before, av_gettime or av_gettime_relative can be used
in this case,
these functions better handle cross-platform issues like check #ifdef
_POSIX_TIMERS
___
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] avutil/mips: optimize UNPCK macros with MSA2.0 instruction.

2019-07-09 Thread Shiyou Yin
Loongson 3A4000 and 2k1000 has supported MSA2.0.
This patch optimized SAD_UB2_UH,UNPCK_R_SH_SW,UNPCK_SB_SH and UNPCK_SH_SW with 
MSA2.0 instruction.
---
 configure   |  5 +
 libavutil/mips/generic_macros_msa.h | 42 ++---
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 4005987..5a4f507 100755
--- a/configure
+++ b/configure
@@ -441,6 +441,7 @@ Optimization options (experts only):
   --disable-mipsdspdisable MIPS DSP ASE R1 optimizations
   --disable-mipsdspr2  disable MIPS DSP ASE R2 optimizations
   --disable-msadisable MSA optimizations
+  --disable-msa2   disable MSA2 optimizations
   --disable-mipsfpudisable floating point MIPS optimizations
   --disable-mmidisable Loongson SIMD optimizations
   --disable-fast-unaligned consider unaligned accesses slow
@@ -1999,6 +2000,7 @@ ARCH_EXT_LIST_MIPS="
 mipsdsp
 mipsdspr2
 msa
+msa2
 "
 
 ARCH_EXT_LIST_LOONGSON="
@@ -2527,6 +2529,7 @@ mipsdsp_deps="mips"
 mipsdspr2_deps="mips"
 mmi_deps="mips"
 msa_deps="mipsfpu"
+msa2_deps="msa"
 
 cpunop_deps="i686"
 x86_64_select="i686"
@@ -5753,6 +5756,7 @@ elif enabled mips; then
 enabled mipsfpu && enabled msa && check_inline_asm_flags msa '"addvi.b 
$w0, $w1, 1"' '-mmsa' && check_headers msa.h || disable msa
 enabled mipsdsp && check_inline_asm_flags mipsdsp '"addu.qb $t0, $t1, 
$t2"' '-mdsp'
 enabled mipsdspr2 && check_inline_asm_flags mipsdspr2 '"absq_s.qb $t0, 
$t1"' '-mdspr2'
+enabled msa && enabled msa2 && check_inline_asm_flags msa2 '"nxbits.any.b 
$w0, $w0"' '-mmsa2' && check_headers msa2.h || disable msa2
 
 if enabled bigendian && enabled msa; then
 disable msa
@@ -7128,6 +7132,7 @@ if enabled mips; then
 echo "MIPS DSP R1 enabled   ${mipsdsp-no}"
 echo "MIPS DSP R2 enabled   ${mipsdspr2-no}"
 echo "MIPS MSA enabled  ${msa-no}"
+echo "MIPS MSA2 enabled ${msa2-no}"
 echo "LOONGSON MMI enabled  ${mmi-no}"
 fi
 if enabled ppc; then
diff --git a/libavutil/mips/generic_macros_msa.h 
b/libavutil/mips/generic_macros_msa.h
index 6a46704..a377428 100644
--- a/libavutil/mips/generic_macros_msa.h
+++ b/libavutil/mips/generic_macros_msa.h
@@ -23,6 +23,11 @@
 
 #include 
 #include 
+#include 
+
+#if HAVE_MSA2
+#include 
+#endif
 
 #define ALIGNMENT   16
 #define ALLOC_ALIGNED(align) __attribute__ ((aligned((align) << 1)))
@@ -1234,6 +1239,15 @@
  unsigned absolute diff values, even-odd pairs are added
  together to generate 8 halfword results.
 */
+#if HAVE_MSA2
+#define SAD_UB2_UH(in0, in1, ref0, ref1) \
+( {  \
+v8u16 sad_m = { 0 }; \
+sad_m += __builtin_msa2_sad_adj2_u_w2x_b((v16u8) in0, (v16u8) ref0); \
+sad_m += __builtin_msa2_sad_adj2_u_w2x_b((v16u8) in1, (v16u8) ref1); \
+sad_m;   \
+} )
+#else
 #define SAD_UB2_UH(in0, in1, ref0, ref1)\
 ( { \
 v16u8 diff0_m, diff1_m; \
@@ -1247,6 +1261,7 @@
 \
 sad_m;  \
 } )
+#endif // #if HAVE_MSA2
 
 /* Description : Insert specified word elements from input vectors to 1
  destination vector
@@ -2287,6 +2302,12 @@
  extracted and interleaved with same vector 'in0' to generate
  4 word elements keeping sign intact
 */
+#if HAVE_MSA2
+#define UNPCK_R_SH_SW(in, out)   \
+{\
+out = (v4i32) __builtin_msa2_w2x_lo_s_h((v8i16) in); \
+}
+#else
 #define UNPCK_R_SH_SW(in, out)   \
 {\
 v8i16 sign_m;\
@@ -2294,6 +2315,7 @@
 sign_m = __msa_clti_s_h((v8i16) in, 0);  \
 out = (v4i32) __msa_ilvr_h(sign_m, (v8i16) in);  \
 }
+#endif // #if HAVE_MSA2
 
 /* Description : Sign extend byte elements from input vector and return
  halfword results in pair of vectors
@@ -2306,6 +2328,13 @@
  Then interleaved left with same vector 'in0' to
  generate 8 signed halfword elements in 'out1'
 */
+#if HAVE_MSA2
+#define UNPCK_SB_SH(in, out0, out1)   \
+{ \
+out0 = (v4i32) __builtin_msa2_w2x_lo_s_b((v16i8) in); \
+out1 = (v4i32) __builtin_msa2_w2x_hi_s_b((v16i8) in); \
+}
+#else
 #define UNPCK_SB_SH(in, out0, out1)  \
 { 

[FFmpeg-devel] [PATCH] libavformat/hlsenc.c Accurrate time output in program_date_time (corrected)

2019-07-09 Thread Pavel Pilar
---
 libavformat/hlsenc.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 00c725af18..94fd713834 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2653,6 +2653,9 @@ static int hls_init(AVFormatContext *s)
 char *p = NULL;
 int vtt_basename_size = 0;
 int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;
+#ifdef _POSIX_TIMERS  
+struct timespec now_accurate;
+#endif
 
 hls->has_default_key = 0;
 hls->has_video_m3u8 = 0;
@@ -2742,14 +2745,13 @@ static int hls_init(AVFormatContext *s)
 }
 
 if (hls->flags & HLS_PROGRAM_DATE_TIME) {
-#ifdef _POSIX_TIMERS   
-struct timespec now0;
-clock_gettime(CLOCK_MONOTONIC, );
-vs->initial_prog_date_time = now0.tv_sec + now0.tv_nsec / 1e9;
-#else
 time_t now0;
 time();
 vs->initial_prog_date_time = now0;
+#ifdef _POSIX_TIMERS   
+if (clock_gettime(CLOCK_REALTIME, _accurate) == 0) {
+vs->initial_prog_date_time = now_accurate.tv_sec + 
now_accurate.tv_nsec / 1e9;
+}
 #endif
 }
 if (hls->format_options_str) {
-- 
2.17.1

___
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 v3] libavcodec/vp9: fix ref-frame size judging method

2019-07-09 Thread Paul B Mahol
On 7/9/19, Ronald S. Bultje  wrote:
> Hi,
>
> On Mon, Jul 8, 2019 at 6:23 PM Yan Cen  wrote:
>
>> From: yancen 
>>
>> There is no need all reference frame demension is valid in libvpx.
>>
>
> Haven't we discussed this before? Anyway, it seems you're really eager to
> get this in, so I'll drop my objection. (I still think this could cause
> issues in HW decoders.)

Sorry but patch quality is unacceptable.

>
> -if (!s->s.refs[s->s.h.refidx[0]].f->buf[0] ||
>> -!s->s.refs[s->s.h.refidx[1]].f->buf[0] ||
>> -!s->s.refs[s->s.h.refidx[2]].f->buf[0]) {
>> -av_log(avctx, AV_LOG_ERROR, "Not all references are
>> available\n");
>> -return AVERROR_INVALIDDATA;
>> +if (0 == sizeof(s->s.refs[s->s.h.refidx[0]])) {
>> +if (0 == sizeof(s->s.refs[s->s.h.refidx[1]].f->buf[0])) {
>> +if (0 == s->s.refs[s->s.h.refidx[2]].f->buf[0]) {
>> +av_log(avctx, AV_LOG_ERROR, "All references are
>> unavailable\n");
>> +return AVERROR_INVALIDDATA;
>> +} else {
>> +
>> av_frame_copy(s->s.refs[s->s.h.refidx[1]].f,s->s.refs[s->s.h.refidx[2]].f);
>> +
>> av_frame_copy(s->s.refs[s->s.h.refidx[0]].f,s->s.refs[s->s.h.refidx[2]].f);
>> +}
>>
> [..]
>
> This is concealment code for missing references and is unrelated to the ref
> frame size judgement patch. Could you please split this off in a separate
> patch? Also, we don't use 0 == sizeof(..) or 0 == .. in ffmpeg, we just use
> !.., please adjust that style.
>
> Ronald
> ___
> 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 v3] libavcodec/vp9: fix ref-frame size judging method

2019-07-09 Thread Ronald S. Bultje
Hi,

On Mon, Jul 8, 2019 at 6:23 PM Yan Cen  wrote:

> From: yancen 
>
> There is no need all reference frame demension is valid in libvpx.
>

Haven't we discussed this before? Anyway, it seems you're really eager to
get this in, so I'll drop my objection. (I still think this could cause
issues in HW decoders.)

-if (!s->s.refs[s->s.h.refidx[0]].f->buf[0] ||
> -!s->s.refs[s->s.h.refidx[1]].f->buf[0] ||
> -!s->s.refs[s->s.h.refidx[2]].f->buf[0]) {
> -av_log(avctx, AV_LOG_ERROR, "Not all references are
> available\n");
> -return AVERROR_INVALIDDATA;
> +if (0 == sizeof(s->s.refs[s->s.h.refidx[0]])) {
> +if (0 == sizeof(s->s.refs[s->s.h.refidx[1]].f->buf[0])) {
> +if (0 == s->s.refs[s->s.h.refidx[2]].f->buf[0]) {
> +av_log(avctx, AV_LOG_ERROR, "All references are
> unavailable\n");
> +return AVERROR_INVALIDDATA;
> +} else {
> +
> av_frame_copy(s->s.refs[s->s.h.refidx[1]].f,s->s.refs[s->s.h.refidx[2]].f);
> +
> av_frame_copy(s->s.refs[s->s.h.refidx[0]].f,s->s.refs[s->s.h.refidx[2]].f);
> +}
>
[..]

This is concealment code for missing references and is unrelated to the ref
frame size judgement patch. Could you please split this off in a separate
patch? Also, we don't use 0 == sizeof(..) or 0 == .. in ffmpeg, we just use
!.., please adjust that style.

Ronald
___
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/6] truehd_core: Disable 16-channel presentation

2019-07-09 Thread Paul B Mahol
On 7/6/19, Andreas Rheinhardt  wrote:
> The most serious bit of the substream_info header field (in a mayor sync
> packet) indicates whether a 16-channel presentation is present in the
> bitstream. If set, the extended_substream_info header field contains
> information about the 16-channel presentation. This presentation always
> uses substream 3, a substream that is discarded by truehd_core. So
> substream_info needs to be changed to no longer indicate the presence
> of a 16-channel presentation in order for truehd_core's output to be
> consistent. This is implemented in this commit.
>
> This change also makes MediaInfo no longer display the presence of Atmos
> in the output of truehd_core.
>
> Also, set the (now irrelevant) extended_substream_info field to zero as
> this seems to be the common value for ordinary TrueHD.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
> The info this patchset relies on can be found in Dolby's TrueHD (MLP)
> high-level bitstream description [1]. See sections 4.2.8 and 4.2.9 for
> this commit. Thanks to Hendrik Leppkes for the link.
>
> [1]:
> https://developer.dolby.com/globalassets/technology/dolby-truehd/dolbytruehdhighlevelbitstreamdescription.pdf

LGTM
___
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 3/6] truehd_core: Return error in case of error

2019-07-09 Thread Paul B Mahol
On 7/6/19, Andreas Rheinhardt  wrote:
> Several checks (e.g. when the size of the input packet is too small)
> simply used "goto fail", but didn't set the return value appropriately
> for an error.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/truehd_core_bsf.c | 14 ++
>  1 file changed, 10 insertions(+), 4 deletions(-)
>

LGTM
___
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] accurrate time output in program_date_time

2019-07-09 Thread myp...@gmail.com
On Tue, Jul 9, 2019 at 4:43 PM Pavel Pilar  wrote:
>
> ---
>  libavformat/hlsenc.c | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 057134f410..00c725af18 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -23,6 +23,7 @@
>  #include "config.h"
>  #include 
>  #include  i
> +#include 
>  #if HAVE_UNISTD_H
>  #include 
>  #endif
> @@ -2741,9 +2742,15 @@ static int hls_init(AVFormatContext *s)
>  }
>
>  if (hls->flags & HLS_PROGRAM_DATE_TIME) {
> +#ifdef _POSIX_TIMERS
> +struct timespec now0;
> +clock_gettime(CLOCK_MONOTONIC, );
> +vs->initial_prog_date_time = now0.tv_sec + now0.tv_nsec / 1e9;
> +#else
I think you can use av_gettime() in this case
>  time_t now0;
>  time();
>  vs->initial_prog_date_time = now0;
> +#endif
>  }
>  if (hls->format_options_str) {
>  ret = av_dict_parse_string(>format_options, 
> hls->format_options_str, "=", ":", 0);
> --
> 2.17.1
>
> ___
> 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".



-- 
===
Jun zhao/赵军
+++
___
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/audiotoolboxdec: Fix decoding 24 Bit ALAC

2019-07-09 Thread myp...@gmail.com
On Tue, Jul 9, 2019 at 12:37 AM Davis  wrote:
>
> "avctx->bits_per_raw_sample" always returns 0.
> Tested with 24 Bit ALAC. The result is bit-perfect.
> Fix #7287.
> ---
>  libavcodec/audiotoolboxdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
> index 5c0a9de8f6..95bf9acc42 100644
> --- a/libavcodec/audiotoolboxdec.c
> +++ b/libavcodec/audiotoolboxdec.c
> @@ -302,7 +302,7 @@ static av_cold int ffat_create_decoder(AVCodecContext 
> *avctx, AVPacket *pkt)
>  OSStatus status;
>  int i;
>
> -enum AVSampleFormat sample_fmt = (avctx->bits_per_raw_sample == 32) ?
> +enum AVSampleFormat sample_fmt = (avctx->bits_per_coded_sample > 16) ?
LGTM
>   AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16;
>
>  AudioStreamBasicDescription in_format = {
> --
___
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] accurrate time output in program_date_time

2019-07-09 Thread Pavel Pilar
---
 libavformat/hlsenc.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 057134f410..00c725af18 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -23,6 +23,7 @@
 #include "config.h"
 #include 
 #include 
+#include 
 #if HAVE_UNISTD_H
 #include 
 #endif
@@ -2741,9 +2742,15 @@ static int hls_init(AVFormatContext *s)
 }
 
 if (hls->flags & HLS_PROGRAM_DATE_TIME) {
+#ifdef _POSIX_TIMERS   
+struct timespec now0;
+clock_gettime(CLOCK_MONOTONIC, );
+vs->initial_prog_date_time = now0.tv_sec + now0.tv_nsec / 1e9;
+#else
 time_t now0;
 time();
 vs->initial_prog_date_time = now0;
+#endif
 }
 if (hls->format_options_str) {
 ret = av_dict_parse_string(>format_options, 
hls->format_options_str, "=", ":", 0);
-- 
2.17.1

___
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".