[FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: cope with race map for YUV420P

2019-07-31 Thread Linjie Fu
There is a race condition for AV_PIX_FMT_YUV420P when mapping from pix_fmt
to fourcc, both VA_FOURCC_I420 and VA_FOURCC_YV12 could be find by pix_fmt.

Currently, vaapi_get_image_format will go through the query results of
pix_fmt and returned the first matched result according to the declared
order in driver.This may leads to a wrong image_format.

Modify to find image_format via fourcc.

Fix vaapi CSC to I420:
ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -f rawvideo
-pix_fmt nv12 -s:v 1280x720 -i NV12.yuv -vf
'format=nv12,hwupload,scale_vaapi=format=yuv420p,hwdownload,format=yuv420p'
-f rawvideo -vsync passthrough -vframes 10 -y aa.yuv

Signed-off-by: Linjie Fu 
---
 libavutil/hwcontext_vaapi.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index cf11764..64f14de 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -63,6 +63,7 @@ typedef struct VAAPIDevicePriv {
 typedef struct VAAPISurfaceFormat {
 enum AVPixelFormat pix_fmt;
 VAImageFormat image_format;
+unsigned int fourcc;
 } VAAPISurfaceFormat;
 
 typedef struct VAAPIDeviceContext {
@@ -171,15 +172,21 @@ static int vaapi_get_image_format(AVHWDeviceContext 
*hwdev,
   VAImageFormat **image_format)
 {
 VAAPIDeviceContext *ctx = hwdev->internal->priv;
+VAAPIFormatDescriptor *desc;
 int i;
 
+desc = vaapi_format_from_pix_fmt(pix_fmt);
+if (!desc || !image_format)
+goto fail;
+
 for (i = 0; i < ctx->nb_formats; i++) {
-if (ctx->formats[i].pix_fmt == pix_fmt) {
-if (image_format)
-*image_format = >formats[i].image_format;
+if (ctx->formats[i].fourcc == desc->fourcc) {
+*image_format = >formats[i].image_format;
 return 0;
 }
 }
+
+fail:
 return AVERROR(EINVAL);
 }
 
@@ -368,6 +375,7 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev)
 av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> %s.\n",
fourcc, av_get_pix_fmt_name(pix_fmt));
 ctx->formats[ctx->nb_formats].pix_fmt  = pix_fmt;
+ctx->formats[ctx->nb_formats].fourcc   = fourcc;
 ctx->formats[ctx->nb_formats].image_format = image_list[i];
 ++ctx->nb_formats;
 }
-- 
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] avcodec/dsddec: add slice threading support

2019-07-31 Thread David Bryant

On 7/30/19 1:43 AM, Carl Eugen Hoyos wrote:
> 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.

I can verify the greatly increased CPU load on a dual core system also. I also 
verified that the outputted audio data is correct
(identical to unmodified code) and that there are no more samples being 
processed, indicating it's probably just threading overhead.

The dsd2pcm conversion is pretty optimized and I suspect that's just way too 
fast to be worth multi-threading.

As I suggested earlier, it's the DST decompression that is worth looking into 
for threading.

-David


>
> 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 2/2] avcodec/diracdec: Check that slices are fewer than pixels

2019-07-31 Thread Michael Niedermayer
Fixes: Timeout (197sec ->144ms)
Fixes: 
15034/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5733549405110272

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

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 7b9e0099df..22ec913bf7 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -1276,7 +1276,9 @@ static int dirac_unpack_idwt_params(DiracContext *s)
 s->num_y= get_interleaved_ue_golomb(gb);
 if (s->num_x * s->num_y == 0 || s->num_x * (uint64_t)s->num_y > 
INT_MAX ||
 s->num_x * (uint64_t)s->avctx->width  > INT_MAX ||
-s->num_y * (uint64_t)s->avctx->height > INT_MAX
+s->num_y * (uint64_t)s->avctx->height > INT_MAX ||
+s->num_x > s->avctx->width ||
+s->num_y > s->avctx->height
 ) {
 av_log(s->avctx,AV_LOG_ERROR,"Invalid numx/y\n");
 s->num_x = s->num_y = 0;
-- 
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/2] avcodec/indeo2: Check remaining input more often

2019-07-31 Thread Michael Niedermayer
Fixes: Timeout (95sec -> 30ms)
Fixes: 
14765/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO2_fuzzer-5692455527120896

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpe
Signed-off-by: Michael Niedermayer 
---
 libavcodec/indeo2.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c
index 09cb560d8e..f367682e61 100644
--- a/libavcodec/indeo2.c
+++ b/libavcodec/indeo2.c
@@ -79,10 +79,11 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int 
height, uint8_t *dst
 
 for (j = 1; j < height; j++) {
 out = 0;
-if (get_bits_left(>gb) <= 0)
-return AVERROR_INVALIDDATA;
 while (out < width) {
-int c = ir2_get_code(>gb);
+int c;
+if (get_bits_left(>gb) <= 0)
+return AVERROR_INVALIDDATA;
+c = ir2_get_code(>gb);
 if (c >= 0x80) { /* we have a skip */
 c -= 0x7F;
 if (out + c*2 > width)
@@ -123,9 +124,9 @@ static int ir2_decode_plane_inter(Ir2Context *ctx, int 
width, int height, uint8_
 
 for (j = 0; j < height; j++) {
 out = 0;
-if (get_bits_left(>gb) <= 0)
-return AVERROR_INVALIDDATA;
 while (out < width) {
+if (get_bits_left(>gb) <= 0)
+return AVERROR_INVALIDDATA;
 c = ir2_get_code(>gb);
 if (c >= 0x80) { /* we have a skip */
 c   -= 0x7F;
-- 
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, v2 3/3] lavc/libvpxenc: add dynamic resolution encode support for libvpx

2019-07-31 Thread James Zern
Hi,

On Tue, Jul 30, 2019 at 10:06 PM Linjie Fu  wrote:
> [...]
> 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);

You shouldn't need to destroy the encoder for a resolution change,
unless I'm missing something. Take a look at resize_test.cc [1].

[1] 
https://chromium.googlesource.com/webm/libvpx/+/refs/heads/master/test/resize_test.cc#305
___
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] avformat/mpegtsenc: Remove redundant goto after malloc fail

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

---
 libavformat/mpegtsenc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..1541a7a073 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -846,10 +846,8 @@ static int mpegts_init(AVFormatContext *s)
 ts->sdt.opaque   = s;
 
 pids = av_malloc_array(s->nb_streams, sizeof(*pids));
-if (!pids) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!pids) 
+return AVERROR(ENOMEM);
 
 /* assign pids to each stream */
 for (i = 0; i < s->nb_streams; i++) {
-- 
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/2] lavfi/zmq: Avoid mem copy past the end of input buffer

2019-07-31 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".

Re: [FFmpeg-devel] libavformat/mpegtsenc: fix incorrect PCR with multiple programs [v4]

2019-07-31 Thread Andriy Gelman
Andreas,

On Mon, 29. Jul 11:11, Andreas Håkon wrote:
> Hi,
> 
> An updated version that fixes all previous bugs:
> https://patchwork.ffmpeg.org/patch/14109/
> https://patchwork.ffmpeg.org/patch/14099/
> https://patchwork.ffmpeg.org/patch/14036/
> 
> It passes the tests pointed by Michael Niedermayer (Sample_cut.ts) and
> Andriy Gelman (day_flight.mpg).
> 
> I hope this time the patch will be accepted.
> Regards.
> A.H.
> 
> ---

> From 8381febd0e881cfcd53583b0ccdd7eb2c580e422 Mon Sep 17 00:00:00 2001
> From: Andreas Hakon 
> Date: Mon, 29 Jul 2019 12:02:06 +0100
> Subject: [PATCH] libavformat/mpegtsenc: fix incorrect PCR with multiple
>  programs [v4]
> 
> The MPEG-TS muxer has a serious bug related to the use of multiple programs:
> in that case, the PCR pid selection is incomplete for all services except one.
> This patch solves this problem and select correct streams for each program.
> Furthermore, it passes all the checks and doesn't generate any regression.
> Also fully compatible with shared pids over services.
> 
> You can check it with this example command:
> 
> $ ./ffmpeg -loglevel verbose -y -f data -i /dev/zero \
>  -filter_complex "nullsrc=s=60x60,split=2[v0][v1],anullsrc[a]" \
>  -map [v0] -c:v:0 rawvideo \
>  -map [v1] -c:v:1 rawvideo \
>  -map [a]  -c:a:0 pcm_s8 \
>  -program st=0,2 -program st=1,2 -program st=2 -program st=0 -f mpegts out.ts
> 
> And you will see something like:
> 
> [mpegts @ 0x55f8452797c0] service 1 using PCR in pid=256
> [mpegts @ 0x55f8452797c0] service 2 using PCR in pid=257
> [mpegts @ 0x55f8452797c0] service 3 using PCR in pid=258
> [mpegts @ 0x55f8452797c0] service 4 using PCR in pid=256
> 
> 
> Signed-off-by: Andreas Hakon 
> ---
>  libavformat/mpegtsenc.c |  167 
> +--
>  1 file changed, 105 insertions(+), 62 deletions(-)
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index fc0ea22..6a0dd55 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -60,6 +60,7 @@ typedef struct MpegTSService {
>  int pcr_packet_count;
>  int pcr_packet_period;
>  AVProgram *program;
> +AVStream *pcr_st;
>  } MpegTSService;
>  
>  // service_type values as defined in ETSI 300 468
> @@ -774,7 +775,7 @@ static int mpegts_init(AVFormatContext *s)
>  MpegTSWrite *ts = s->priv_data;
>  MpegTSWriteStream *ts_st;
>  MpegTSService *service;
> -AVStream *st, *pcr_st = NULL;
> +AVStream *st;
>  AVDictionaryEntry *title, *provider;
>  int i, j;
>  const char *service_name;
> @@ -831,6 +832,11 @@ static int mpegts_init(AVFormatContext *s)
>  }
>  }
>  
> +for (i = 0; i < ts->nb_services; i++) {
> +service = ts->services[i];
> +service->pcr_st = NULL;
> +}
> +

If you are going to add pcr_st to MpegTSService then it would make sense to 
move the
initialization to mpegts_add_service function. 

>  ts->pat.pid  = PAT_PID;
>  /* Initialize at 15 so that it wraps and is equal to 0 for the
>   * first packet we write. */
> @@ -872,17 +878,6 @@ static int mpegts_init(AVFormatContext *s)
>  goto fail;
>  }
>  
> -program = av_find_program_from_stream(s, NULL, i);
> -if (program) {
> -for (j = 0; j < ts->nb_services; j++) {
> -if (ts->services[j]->program == program) {
> -service = ts->services[j];
> -break;
> -}
> -}
> -}
> -
> -ts_st->service = service;
>  /* MPEG pid values < 16 are reserved. Applications which set st->id 
> in
>   * this range are assigned a calculated pid. */
>  if (st->id < 16) {
> @@ -895,11 +890,6 @@ static int mpegts_init(AVFormatContext *s)
>  ret = AVERROR(EINVAL);
>  goto fail;
>  }
> -if (ts_st->pid == service->pmt.pid) {
> -av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
> -ret = AVERROR(EINVAL);
> -goto fail;
> -}
>  for (j = 0; j < i; j++) {
>  if (pids[j] == ts_st->pid) {
>  av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
> ts_st->pid);
> @@ -913,12 +903,7 @@ static int mpegts_init(AVFormatContext *s)
>  ts_st->first_pts_check = 1;
>  ts_st->cc  = 15;
>  ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
> -/* update PCR pid by using the first video stream */
> -if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> -service->pcr_pid == 0x1fff) {
> -service->pcr_pid = ts_st->pid;
> -pcr_st   = st;
> -}
> +
>  if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
>  st->codecpar->extradata_size > 0) {
>  AVStream *ast;
> @@ -949,50 +934,109 @@ static int mpegts_init(AVFormatContext *s)
>  if (st->codecpar->codec_id == 

Re: [FFmpeg-devel] libavformat/mpegtsenc: fix incorrect PCR with multiple programs [v3]

2019-07-31 Thread Marton Balint


On Sun, 28 Jul 2019, Andreas Håkon wrote:


Hi,

This last version fixes the small bug discovered by Michael Niedermayer:
https://patchwork.ffmpeg.org/patch/14099/

This version is finally clean.



From 8381febd0e881cfcd53583b0ccdd7eb2c580e422 Mon Sep 17 00:00:00 2001
From: Andreas Hakon 
Date: Mon, 29 Jul 2019 12:02:06 +0100
Subject: [PATCH] libavformat/mpegtsenc: fix incorrect PCR with multiple
 programs [v4]

The MPEG-TS muxer has a serious bug related to the use of multiple programs:
in that case, the PCR pid selection is incomplete for all services except one.
This patch solves this problem and select correct streams for each program.
Furthermore, it passes all the checks and doesn't generate any regression.
Also fully compatible with shared pids over services.

You can check it with this example command:

$ ./ffmpeg -loglevel verbose -y -f data -i /dev/zero \
 -filter_complex "nullsrc=s=60x60,split=2[v0][v1],anullsrc[a]" \
 -map [v0] -c:v:0 rawvideo \
 -map [v1] -c:v:1 rawvideo \
 -map [a]  -c:a:0 pcm_s8 \
 -program st=0,2 -program st=1,2 -program st=2 -program st=0 -f mpegts out.ts

And you will see something like:

[mpegts @ 0x55f8452797c0] service 1 using PCR in pid=256
[mpegts @ 0x55f8452797c0] service 2 using PCR in pid=257
[mpegts @ 0x55f8452797c0] service 3 using PCR in pid=258
[mpegts @ 0x55f8452797c0] service 4 using PCR in pid=256


Signed-off-by: Andreas Hakon 
---
 libavformat/mpegtsenc.c |  167 +--
 1 file changed, 105 insertions(+), 62 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea22..6a0dd55 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -60,6 +60,7 @@ typedef struct MpegTSService {
 int pcr_packet_count;
 int pcr_packet_period;
 AVProgram *program;
+AVStream *pcr_st;
 } MpegTSService;

 // service_type values as defined in ETSI 300 468
@@ -774,7 +775,7 @@ static int mpegts_init(AVFormatContext *s)
 MpegTSWrite *ts = s->priv_data;
 MpegTSWriteStream *ts_st;
 MpegTSService *service;
-AVStream *st, *pcr_st = NULL;
+AVStream *st;
 AVDictionaryEntry *title, *provider;
 int i, j;
 const char *service_name;
@@ -831,6 +832,11 @@ static int mpegts_init(AVFormatContext *s)
 }
 }

+for (i = 0; i < ts->nb_services; i++) {
+service = ts->services[i];
+service->pcr_st = NULL;
+}
+


This loop is not needed as far as I see. service is already initialized 
and service->pcr_st is zero initialized so you don't need to set it to 
NULL explicitly.



 ts->pat.pid  = PAT_PID;
 /* Initialize at 15 so that it wraps and is equal to 0 for the
  * first packet we write. */
@@ -872,17 +878,6 @@ static int mpegts_init(AVFormatContext *s)
 goto fail;
 }

-program = av_find_program_from_stream(s, NULL, i);
-if (program) {
-for (j = 0; j < ts->nb_services; j++) {
-if (ts->services[j]->program == program) {
-service = ts->services[j];
-break;
-}
-}
-}
-
-ts_st->service = service;
 /* MPEG pid values < 16 are reserved. Applications which set st->id in
  * this range are assigned a calculated pid. */
 if (st->id < 16) {
@@ -895,11 +890,6 @@ static int mpegts_init(AVFormatContext *s)
 ret = AVERROR(EINVAL);
 goto fail;
 }
-if (ts_st->pid == service->pmt.pid) {
-av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid);
-ret = AVERROR(EINVAL);
-goto fail;
-}
 for (j = 0; j < i; j++) {
 if (pids[j] == ts_st->pid) {
 av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", 
ts_st->pid);
@@ -913,12 +903,7 @@ static int mpegts_init(AVFormatContext *s)
 ts_st->first_pts_check = 1;
 ts_st->cc  = 15;
 ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
-/* update PCR pid by using the first video stream */
-if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
-service->pcr_pid == 0x1fff) {
-service->pcr_pid = ts_st->pid;
-pcr_st   = st;
-}
+
 if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
 st->codecpar->extradata_size > 0) {
 AVStream *ast;
@@ -949,50 +934,109 @@ static int mpegts_init(AVFormatContext *s)
 if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
 ts_st->opus_pending_trim_start = st->codecpar->initial_padding * 48000 / 
st->codecpar->sample_rate;
 }
+
+/* program service checks */
+program = av_find_program_from_stream(s, NULL, i);
+do {
+for (j = 0; j < ts->nb_services; j++) {
+if (program) {
+/* search for the services corresponding to this program */
+if 

Re: [FFmpeg-devel] [PATCH] h264_mp4toannexb: Remove unnecessary check

2019-07-31 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> There can be at most 31 SPS and 255 PPS in the mp4/Matroska extradata.
> Given that each has a size of at most 2^16-1, the length of the output
> derived from these parameter sets can never overflow an ordinary 32 bit
> integer. So use a simple uint32_t instead of uint64_t and replace the
> unnecessary check with an av_assert1.
> 
> Signed-off-by: Andreas Rheinhardt 

I decided to reimplement h264_mp4toannexb via bytestreams (it's simply
so ugly right now). So you can ignore this patchset.

- Andreas
___
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/3] avcodec/vc1_pred: Fix invalid shift in scaleforsame()

2019-07-31 Thread Michael Niedermayer
On Thu, Jul 11, 2019 at 02:29:18PM +0200, Michael Niedermayer wrote:
> Fixes: left shift of negative value -1
> Fixes: 
> 15531/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5759556258365440
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1_pred.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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] avcodec/vc1_block: Fix integer overflow in ff_vc1_pred_dc()

2019-07-31 Thread Michael Niedermayer
On Fri, Jul 05, 2019 at 01:28:34AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 32796 * 65536 cannot be represented in type 
> 'int'
> Fixes: 
> 15430/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5735424087031808
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1_block.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

will apply

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

Avoid a single point of failure, be that a person or equipment.


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

2019-07-31 Thread Michael Niedermayer
On Tue, Jul 09, 2019 at 06:00:00PM +0200, Michael Niedermayer wrote:
> 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(-)

will apply


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

What does censorship reveal? It reveals fear. -- Julian Assange


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 1/3] avcodec/apedec: Fix multiple integer overflows and undefined behaviorin filter_3800()

2019-07-31 Thread Michael Niedermayer
On Sun, Jul 21, 2019 at 11:14:44AM +0200, Michael Niedermayer wrote:
> Fixes: left shift of negative value -4
> Fixes: signed integer overflow: -15091694 * 167 cannot be represented in type 
> 'int'
> Fixes: signed integer overflow: 1898547155 + 453967445 cannot be represented 
> in type 'int'
> Fixes: 
> 15258/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5759095564402688
> Fixes: signed integer overflow: 962196438 * 31 cannot be represented in type 
> 'int'
> Fixes: 
> 15364/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5718799845687296
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/apedec.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)

will apply patchset

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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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/2] avformat/mpc: deallocate frames array on errors

2019-07-31 Thread Michael Niedermayer
On Wed, Jul 24, 2019 at 11:35:38PM +0200, Michael Niedermayer wrote:
> Fixes: memleak on error path
> Fixes: 
> 15984/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5679918412726272
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mpc.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)

will apply

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

Democracy is the form of government in which you can choose your dictator


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-31 Thread Tomas Härdin
tis 2019-07-30 klockan 21:07 +0200 skrev 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.

I actually worded this a bit incorrectly; the file *is* PCM, so
everything is fine as far as mxfdec is concerned. See below

I also notice this UL is already in mxf.c, but added commented out by
Baptiste back in 2006..

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

It demuxes just fine. It's PCM audio in an AES-BWF essence container.

Probing is not what you want, at least not automatic probing. A generic
lavf format option is needed, because Dolby-E can be contained in any
format that supports 16-bit PCM. Which is pretty much all formats.
Nicolas is on the right track, and my gut feeling about per-format
options was wrong.

FFmpeg has no way of knowing the user's intent without options. You'll
have the outer product of at least these cases:

* a file contains PCM data, which does not probe as Dolby-E
* a file contains PCM data, which probes as Dolby-E
* a file contains Dolby-E data, tagged as such (with UL or TwoCC)

* the user has the computer FFmpeg is running on hooked up to another
machine via mini tele or RCA connectors
* the user has the computer FFmpeg is running on hooked up to another
machine via S/PDIF

* the other machine has a Dolby-E decoder, and it should be used
* the other machine has a Dolby-E decoder, and it should not be used
* the other machine has no Dolby-E decoder

So, a general solution is needed. When the user knows the audio is
Dolby-E then they can obviously just override the decoder, if they want
(not always). Another typical case is "if you think the audio is Dolby-
E, automatically decode it so I don't blow my speakers!". An option
could allow avformat_find_stream_info() to wait for the first audio
packet and probe it, and not take what the demuxer says at face value.

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

[FFmpeg-devel] [PATCH 2/3] tools/target_dec_fuzzer: Assert that max pixels is not violated

2019-07-31 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 0c398da95b..a3c735e339 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -259,6 +259,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 av_frame_unref(frame);
 int ret = decode_handler(ctx, frame, _frame, );
 
+av_assert0(ctx->width * ctx->height <= maxpixels_per_frame);
+
 ec_pixels += ctx->width * ctx->height;
 if (it > 20 || ec_pixels > 4 * ctx->max_pixels)
 ctx->error_concealment = 0;
-- 
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/3] tools/target_dec_fuzzer: Print max_pixels and iterations at the end

2019-07-31 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index a3c735e339..56a8a40e68 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -287,6 +287,8 @@ maximums_reached:
 decode_handler(ctx, frame, _frame, );
 } while (got_frame == 1 && it++ < maxiteration);
 
+fprintf(stderr, "pixels decoded: %"PRId64", iterations: %d\n", ec_pixels, 
it);
+
 av_frame_free();
 avcodec_free_context();
 avcodec_free_context(_avctx);
-- 
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/3] tools/target_dec_fuzzer: Limit number off all pixels decoded

2019-07-31 Thread Michael Niedermayer
This should reduces the number of uninteresting timeouts encountered

Signed-off-by: Michael Niedermayer 
---
 tools/target_dec_fuzzer.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 8ba25b4e8a..0c398da95b 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -128,6 +128,8 @@ static void FDBPrepare(FuzzDataBuffer *FDB, AVPacket *dst, 
const uint8_t *data,
 
 // Ensure we don't loop forever
 const uint32_t maxiteration = 8096;
+const uint64_t maxpixels_per_frame = 4096 * 4096;
+const uint64_t maxpixels   = maxpixels_per_frame * maxiteration / 8;
 
 static const uint64_t FUZZ_TAG = 0x4741542D5A5A5546ULL;
 
@@ -171,7 +173,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 if (!ctx || !parser_avctx)
 error("Failed memory allocation");
 
-ctx->max_pixels = 4096 * 4096; //To reduce false positive OOM and hangs
+ctx->max_pixels = maxpixels_per_frame; //To reduce false positive OOM and 
hangs
 
 if (size > 1024) {
 GetByteContext gbc;
@@ -260,6 +262,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 ec_pixels += ctx->width * ctx->height;
 if (it > 20 || ec_pixels > 4 * ctx->max_pixels)
 ctx->error_concealment = 0;
+if (ec_pixels > maxpixels)
+goto maximums_reached;
 
 if (ret <= 0 || ret > avpkt.size)
break;
@@ -270,6 +274,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
   }
 }
 }
+maximums_reached:
 
 av_init_packet();
 avpkt.data = NULL;
-- 
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 v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-31 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of James 
Almer
Sent: Wednesday, July 31, 2019 11:40 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

> Simply remove the void* cast in the memset() line. "avctx->extradata +
> avctx->extradata_size" is acceptable as an argument.

Thanks James! It's modified and submitted as V16.

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 v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-31 Thread Jing Sun
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 5a4f507..3a6cab7 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]
@@ -1788,6 +1789,7 @@ EXTERNAL_LIBRARY_LIST="
 libspeex
 libsrt
 libssh
+libsvthevc
 libtensorflow
 libtesseract
 libtheora
@@ -3183,6 +3185,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"
@@ -6230,6 +6233,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 3cd73fb..d39f568 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..57843ef
--- /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 "avcodec.h"
+
+typedef enum eos_status {
+EOS_NOT_REACHED = 0,
+EOS_SENT,
+EOS_RECEIVED
+}EOS_STATUS;
+
+typedef struct SvtContext {
+AVClass *class;
+
+EB_H265_ENC_CONFIGURATION enc_params;
+EB_COMPONENTTYPE *svt_handle;
+EB_BUFFERHEADERTYPE in_buf;
+EOS_STATUS eos_flag;

[FFmpeg-devel] [PATCH v16 2/2] doc: Add libsvt_hevc encoder docs

2019-07-31 Thread Jing Sun
Add docs for libsvt_hevc encoder in encoders.texi and general.texi

Signed-off-by: Jun Zhao 
Signed-off-by: Zhengxu Huang 
Signed-off-by: Hassene Tmar 
Signed-off-by: Jing Sun 
---
 doc/encoders.texi | 149 ++
 doc/general.texi  |   8 +++
 2 files changed, 157 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index eefd124..aa5bcda 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1640,6 +1640,155 @@ Set maximum NAL size in bytes.
 Allow skipping frames to hit the target bitrate if set to 1.
 @end table
 
+@section libsvt_hevc
+
+Scalable Video Technology for HEVC (SVT-HEVC) encoder wrapper.
+
+This encoder requires the presence of the headers and
+library during configuration. You need to explicitly configure the
+build with @code{--enable-libsvthevc}. The library is detected using
+@command{pkg-config}.
+
+For more information about the library see
+@url{https://github.com/intel/SVT-HEVC.git}.
+
+@subsection Options
+
+The following FFmpeg global options affect the configurations of the
+libsvt_hevc encoder:
+
+@table @option
+@item b  (@emph{bitrate})
+Set the bitrate (as a number of bits per second). Default is 7M.
+
+@item g  / @option{gop_size}
+Set the GOP size. Default is -2 (unspecified).
+
+@item flags +cgop
+Enable closed GOP.
+
+@item qmin (@emph{min-q})
+Default is 10
+
+@item qmax (@emph{max-q})
+Default is 48
+
+Set minimum/maximum quantisation values.  Valid range is from 0 to 51
+(Only used when bit rate control mode @option{rc} is set to 1(vbr) mode.
+It is required that qmax >= qmin).
+
+@item profile (@emph{profile})
+Set profile restrictions. Can assume one of the following possible values:
+
+@table @samp
+@item main
+main profile
+@item main10
+main10 profile
+@item rext
+rext profile
+@end table
+
+Default is 1 (main).
+
+@item level (@emph{level})
+
+@option{level} sets the value of @emph{level}.
+Set level (level_idc). Default is 0 (to be determined by the encoder).
+
+@end table
+
+The encoder also has its own specific options:
+
+@table @option
+@item aud (@emph{aud})
+Enable use of access unit delimiters when set to 1. Default is 0 (Off).
+
+@item hielevel
+Set hierarchical levels. Can assume one of the following possible values:
+
+@table @samp
+@item flat
+flat more
+@item 1 level
+Minigop size is 2^1
+@item 2 level
+Minigop size is 2^2
+@item 3 level
+Minigop size is 2^3
+@end table
+
+Default is 3 level.
+
+@item la_depth
+Set look-ahead depth, depending on @option{rc}: for @var{vbr}, it's recommended
+to unset it and use the default value (the intra period); for @var{cqp}, better
+specify the look-ahead depth.
+
+The range is @var{-1-256}. Default is -1 (unset and the default value to be 
used).
+
+@item preset
+Set the quality vs density tradeoff point at which the encoding is to be 
performed.
+Higher perset value, higher density and lower quality.
+
+The range is @var{0-12}. Default is 9.
+
+@item tier
+Set @emph{general_tier_flag}.  This may affect the level chosen for the stream
+if it is not explicitly specified. Can assume one of the following possible 
values:
+
+@table @samp
+@item main
+main tier
+@item high
+high tier
+@end table
+
+Default is 1 (main).
+
+@item rc
+Set bit rate control mode. Can assume one of the following possible values:
+
+@table @samp
+@item cqp
+Constant QP (CQP) mode
+@item vbr
+Variable Bit Rate (VBR) mode
+@end table
+
+Default is 0 (cqp).
+
+@item forced_idr
+Force keyframes to be IDR if set to >=0 (the value sets headers insertion 
interval). Default is -1 (CRA).
+
+@item asm_type
+Auto select highest supported asm if set to 1 or C only if 0. Default is 1.
+
+@item qp
+Initial quantization parameter for the intra pictures used when
+@option{rc} is cqp mode. The range is from @var{0-51}. Default is 32.
+
+@item sc_detection
+Enables or disables the scene change detection algorithm. Default is 0 
(disabled).
+
+@item tune
+Set quality tuning mode. Can assume one of the following possible values:
+
+@table @samp
+@item sq
+Visually optimized mode
+@item oq
+PSNR / SSIM optimized mode
+@item vmaf
+VMAF optimized mode
+@end table
+
+Default is 1 (oq).
+
+@item bl_mode
+Enables or disables Random Access Prediction. Default is 0 (disabled).
+@end table
+
 @section libtheora
 
 libtheora Theora encoder wrapper.
diff --git a/doc/general.texi b/doc/general.texi
index 3c0c803..fa9cd31 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -243,6 +243,14 @@ 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 Scalable Video Technology for HEVC
+
+FFmpeg can make use of the SVT-HEVC library for HEVC encoding.
+
+Go to @url{https://github.com/intel/SVT-HEVC.git} and follow the instructions
+for installing the library. Pass @code{--enable-libsvthevc} to configure to
+enable it.
+
 @section TwoLAME
 
 FFmpeg can make use of the 

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

2019-07-31 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Li, 
Zhong
Sent: Wednesday, July 31, 2019 11:33 AM
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 
>___



I checked out the history in https://patchwork.ffmpeg.org/patch/11347/:

Mark's remarks:
> +.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
Threads aren't actually mentioned at all above.  Does that mean the encoder 
will always make as many threads as it wants, and the user has no separate 
control?

And from the macro definition:
/**
 * Codec supports avctx->thread_count == 0 (auto).
 */
#define AV_CODEC_CAP_AUTO_THREADS(1 << 15)

static void validate_thread_parameters(AVCodecContext *avctx)
{
...
} else if (!(avctx->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS)) {
avctx->thread_count   = 1;
avctx->active_thread_type = 0;
}
...
}

I think it's right to declare the codec with that capability as long as the 
codec indeed supports the auto thread count. It's not wrong that we have 
declared that. And to Mark's question, the answer is "Yes, the SVT HEVC encoder 
always makes as many threads as it wants". It checks the CPU cores and decides 
the count of working threads based on the number of cores to ensure the best 
performance, and by now users have no separate control on it.

We have been considering if we shall add such a controlling interface to SVT 
HEVC lib and how. The code lines of handling avctx->thread_count in this 
avcodec is possible to get added in the future. Right now, adding an empty 
interface without implementation supported by SVT HEVC lib makes no sense.
 
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 v2] avformat/hlsenc: merge mpegts and fmp4 workflow to one workflow

2019-07-31 Thread Steven Liu
write mpegts or fmp4 context into buffer, and flush the buffer into
output file when split fragment. merge two format split workflow into
one workflow

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 200 ---
 1 file changed, 92 insertions(+), 108 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 51310fb528..543ad4e7df 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -459,6 +459,7 @@ static int flush_dynbuf(VariantStream *vs, int 
*range_length)
 
 // write out to file
 *range_length = avio_close_dyn_buf(ctx->pb, );
+vs->video_lastpos = 0;
 ctx->pb = NULL;
 avio_write(vs->out, buffer, *range_length);
 av_free(buffer);
@@ -815,7 +816,7 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 vs->start_pos = 0;
 vs->new_start = 1;
 
-if (hls->segment_type == SEGMENT_TYPE_FMP4) {
+if (hls->segment_type == SEGMENT_TYPE_FMP4 && hls->max_seg_size > 0) {
 if (hls->http_persistent > 0) {
 //TODO: Support fragment fmp4 for http persistent in HLS muxer.
 av_log(s, AV_LOG_WARNING, "http persistent mode is currently 
unsupported for fragment mp4 in the HLS muxer.\n");
@@ -824,34 +825,38 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 av_log(s, AV_LOG_WARNING, "Multi-file byterange mode is currently 
unsupported in the HLS muxer.\n");
 return AVERROR_PATCHWELCOME;
 }
+}
 
-vs->packets_written = 0;
-vs->init_range_length = 0;
-set_http_options(s, , hls);
-if ((ret = avio_open_dyn_buf(>pb)) < 0)
-return ret;
+vs->packets_written = 0;
+vs->init_range_length = 0;
+set_http_options(s, , hls);
+if ((ret = avio_open_dyn_buf(>pb)) < 0)
+return ret;
 
+if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 if (byterange_mode) {
 ret = hlsenc_io_open(s, >out, vs->basename, );
 } else {
 ret = hlsenc_io_open(s, >out, vs->base_output_dirname, 
);
 }
-av_dict_free();
+}
+av_dict_free();
+if (ret < 0) {
+av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
vs->fmp4_init_filename);
+return ret;
+}
+
+if (hls->format_options_str) {
+ret = av_dict_parse_string(>format_options, 
hls->format_options_str, "=", ":", 0);
 if (ret < 0) {
-av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
vs->fmp4_init_filename);
+av_log(s, AV_LOG_ERROR, "Could not parse format options list 
'%s'\n",
+   hls->format_options_str);
 return ret;
 }
+}
 
-if (hls->format_options_str) {
-ret = av_dict_parse_string(>format_options, 
hls->format_options_str, "=", ":", 0);
-if (ret < 0) {
-av_log(s, AV_LOG_ERROR, "Could not parse format options list 
'%s'\n",
-   hls->format_options_str);
-return ret;
-}
-}
-
-av_dict_copy(, hls->format_options, 0);
+av_dict_copy(, hls->format_options, 0);
+if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 av_dict_set(, "fflags", "-autobsf", 0);
 av_dict_set(, "movflags", "+frag_custom+dash+delay_moov", 
AV_DICT_APPEND);
 ret = avformat_init_output(oc, );
@@ -862,9 +867,9 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 av_dict_free();
 return AVERROR(EINVAL);
 }
-avio_flush(oc->pb);
-av_dict_free();
 }
+avio_flush(oc->pb);
+av_dict_free();
 return 0;
 }
 
@@ -1435,7 +1440,6 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 {
 HLSContext *hls = s->priv_data;
 HLSSegment *en;
-AVFormatContext *oc = vs->avf;
 int target_duration = 0;
 int ret = 0;
 char temp_filename[MAX_URL_SIZE];
@@ -1471,7 +1475,7 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 
 set_http_options(s, , hls);
 snprintf(temp_filename, sizeof(temp_filename), use_temp_file ? "%s.tmp" : 
"%s", vs->m3u8_name);
-if ((ret = hlsenc_io_open(s, (byterange_mode || hls->segment_type == 
SEGMENT_TYPE_FMP4) ? >m3u8_out : >pb, temp_filename, )) < 0) {
+if ((ret = hlsenc_io_open(s, (byterange_mode || hls->segment_type == 
SEGMENT_TYPE_FMP4) ? >m3u8_out : >out, temp_filename, )) < 0) {
 if (hls->ignore_io_errors)
 ret = 0;
 goto fail;
@@ -1483,33 +1487,33 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 }
 
 vs->discontinuity_set = 0;
-ff_hls_write_playlist_header((byterange_mode || hls->segment_type == 
SEGMENT_TYPE_FMP4) ? hls->m3u8_out : oc->pb, hls->version, hls->allowcache,
+ff_hls_write_playlist_header((byterange_mode || hls->segment_type == 
SEGMENT_TYPE_FMP4) ? hls->m3u8_out : vs->out, hls->version, hls->allowcache,

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: merge mpegts and fmp4 workflow to one workflow

2019-07-31 Thread Liu Steven
ignore this patch please, i will resend the v2 version.

> 在 2019年7月31日,下午2:38,Steven Liu  写道:
> 
> write mpegts or fmp4 context into buffer, and flush the buffer into
> output file when split fragment. merge two format split workflow into
> one workflow
> 
> Signed-off-by: Steven Liu 
> ---
> libavformat/hlsenc.c | 207 ---
> 1 file changed, 95 insertions(+), 112 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 51310fb528..68d9201a5e 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -815,7 +815,7 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
> *vs)
> vs->start_pos = 0;
> vs->new_start = 1;
> 
> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> +if (hls->segment_type == SEGMENT_TYPE_FMP4 && hls->max_seg_size > 0) {
> if (hls->http_persistent > 0) {
> //TODO: Support fragment fmp4 for http persistent in HLS muxer.
> av_log(s, AV_LOG_WARNING, "http persistent mode is currently 
> unsupported for fragment mp4 in the HLS muxer.\n");
> @@ -824,34 +824,38 @@ static int hls_mux_init(AVFormatContext *s, 
> VariantStream *vs)
> av_log(s, AV_LOG_WARNING, "Multi-file byterange mode is currently 
> unsupported in the HLS muxer.\n");
> return AVERROR_PATCHWELCOME;
> }
> +}
> 
> -vs->packets_written = 0;
> -vs->init_range_length = 0;
> -set_http_options(s, , hls);
> -if ((ret = avio_open_dyn_buf(>pb)) < 0)
> -return ret;
> +vs->packets_written = 0;
> +vs->init_range_length = 0;
> +set_http_options(s, , hls);
> +if ((ret = avio_open_dyn_buf(>pb)) < 0)
> +return ret;
> 
> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> if (byterange_mode) {
> ret = hlsenc_io_open(s, >out, vs->basename, );
> } else {
> ret = hlsenc_io_open(s, >out, vs->base_output_dirname, 
> );
> }
> -av_dict_free();
> +}
> +av_dict_free();
> +if (ret < 0) {
> +av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
> vs->fmp4_init_filename);
> +return ret;
> +}
> +
> +if (hls->format_options_str) {
> +ret = av_dict_parse_string(>format_options, 
> hls->format_options_str, "=", ":", 0);
> if (ret < 0) {
> -av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
> vs->fmp4_init_filename);
> +av_log(s, AV_LOG_ERROR, "Could not parse format options list 
> '%s'\n",
> +   hls->format_options_str);
> return ret;
> }
> +}
> 
> -if (hls->format_options_str) {
> -ret = av_dict_parse_string(>format_options, 
> hls->format_options_str, "=", ":", 0);
> -if (ret < 0) {
> -av_log(s, AV_LOG_ERROR, "Could not parse format options list 
> '%s'\n",
> -   hls->format_options_str);
> -return ret;
> -}
> -}
> -
> -av_dict_copy(, hls->format_options, 0);
> +av_dict_copy(, hls->format_options, 0);
> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> av_dict_set(, "fflags", "-autobsf", 0);
> av_dict_set(, "movflags", "+frag_custom+dash+delay_moov", 
> AV_DICT_APPEND);
> ret = avformat_init_output(oc, );
> @@ -862,9 +866,9 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
> *vs)
> av_dict_free();
> return AVERROR(EINVAL);
> }
> -avio_flush(oc->pb);
> -av_dict_free();
> }
> +avio_flush(oc->pb);
> +av_dict_free();
> return 0;
> }
> 
> @@ -1435,7 +1439,6 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> {
> HLSContext *hls = s->priv_data;
> HLSSegment *en;
> -AVFormatContext *oc = vs->avf;
> int target_duration = 0;
> int ret = 0;
> char temp_filename[MAX_URL_SIZE];
> @@ -1471,7 +1474,7 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> 
> set_http_options(s, , hls);
> snprintf(temp_filename, sizeof(temp_filename), use_temp_file ? "%s.tmp" : 
> "%s", vs->m3u8_name);
> -if ((ret = hlsenc_io_open(s, (byterange_mode || hls->segment_type == 
> SEGMENT_TYPE_FMP4) ? >m3u8_out : >pb, temp_filename, )) < 0) 
> {
> +if ((ret = hlsenc_io_open(s, (byterange_mode || hls->segment_type == 
> SEGMENT_TYPE_FMP4) ? >m3u8_out : >out, temp_filename, )) < 
> 0) {
> if (hls->ignore_io_errors)
> ret = 0;
> goto fail;
> @@ -1483,33 +1486,33 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> }
> 
> vs->discontinuity_set = 0;
> -ff_hls_write_playlist_header((byterange_mode || hls->segment_type == 
> SEGMENT_TYPE_FMP4) ? hls->m3u8_out : oc->pb, hls->version, hls->allowcache,
> +ff_hls_write_playlist_header((byterange_mode || hls->segment_type == 
> SEGMENT_TYPE_FMP4) ? hls->m3u8_out : vs->out, 

Re: [FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()

2019-07-31 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Paul B Mahol
> Sent: Wednesday, July 17, 2019 8:42 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD
> for filter_3x3()
> 
> On 7/15/19, Song, Ruiling  wrote:
> >> -Original Message-
> >> From: Song, Ruiling
> >> Sent: Tuesday, July 9, 2019 9:15 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Cc: Song, Ruiling 
> >> Subject: [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()
> >>
> >> Tested using a simple command (apply edge enhance):
> >> ./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
> >>  -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0
> >> 0:0 0 0 -1 1 0 0
> >> 0 0:5:1:1:1:0:128:128:128" \
> >>  -an -vframes 1000 -f null /dev/null
> >>
> >> The fps increase from 151 to 270 on my local machine.
> >>
> >> Signed-off-by: Ruiling Song 
> > Ping?
> 
> Should be fine IFF output is exact with C version (under different
> parameters).
Thanks Paul, after fixing a bug in scalar code path, the v2 produces exact 
result as C version.
Have tested against many different parameters. Will apply in a few days.

Thanks!
Ruiling

> ___
> 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] avfilter/vf_convolution: add x86 SIMD for filter_3x3()

2019-07-31 Thread Ruiling Song
Tested using a simple command (apply edge enhance):
./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
 -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 
0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128" \
 -an -vframes 1000 -f null /dev/null

The fps increase from 151 to 270 on my local machine.

Signed-off-by: Ruiling Song 
---
v2:
  fix a bug in scalar code path.
  Use macro PROCESS_V/S for the first tap to simplify code.

 libavfilter/convolution.h |  64 +++
 libavfilter/vf_convolution.c  |  41 +--
 libavfilter/x86/Makefile  |   2 +
 libavfilter/x86/vf_convolution.asm| 156 ++
 libavfilter/x86/vf_convolution_init.c |  46 
 5 files changed, 271 insertions(+), 38 deletions(-)
 create mode 100644 libavfilter/convolution.h
 create mode 100644 libavfilter/x86/vf_convolution.asm
 create mode 100644 libavfilter/x86/vf_convolution_init.c

diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h
new file mode 100644
index 00..fc6aad58fd
--- /dev/null
+++ b/libavfilter/convolution.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012-2013 Oka Motofumi (chikuzen.mo at gmail dot com)
+ * Copyright (c) 2015 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef AVFILTER_CONVOLUTION_H
+#define AVFILTER_CONVOLUTION_H
+#include "avfilter.h"
+
+enum MatrixMode {
+MATRIX_SQUARE,
+MATRIX_ROW,
+MATRIX_COLUMN,
+MATRIX_NBMODES,
+};
+
+typedef struct ConvolutionContext {
+const AVClass *class;
+
+char *matrix_str[4];
+float rdiv[4];
+float bias[4];
+int mode[4];
+float scale;
+float delta;
+int planes;
+
+int size[4];
+int depth;
+int max;
+int bpc;
+int nb_planes;
+int nb_threads;
+int planewidth[4];
+int planeheight[4];
+int matrix[4][49];
+int matrix_length[4];
+int copy[4];
+
+void (*setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int 
stride,
+ int x, int width, int y, int height, int bpc);
+void (*filter[4])(uint8_t *dst, int width,
+  float rdiv, float bias, const int *const matrix,
+  const uint8_t *c[], int peak, int radius,
+  int dstride, int stride);
+} ConvolutionContext;
+
+void ff_convolution_init_x86(ConvolutionContext *s);
+#endif
diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 1305569c88..e3bf1df79f 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -25,48 +25,11 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
+#include "convolution.h"
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
 
-enum MatrixMode {
-MATRIX_SQUARE,
-MATRIX_ROW,
-MATRIX_COLUMN,
-MATRIX_NBMODES,
-};
-
-typedef struct ConvolutionContext {
-const AVClass *class;
-
-char *matrix_str[4];
-float rdiv[4];
-float bias[4];
-int mode[4];
-float scale;
-float delta;
-int planes;
-
-int size[4];
-int depth;
-int max;
-int bpc;
-int nb_planes;
-int nb_threads;
-int planewidth[4];
-int planeheight[4];
-int matrix[4][49];
-int matrix_length[4];
-int copy[4];
-
-void (*setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int 
stride,
- int x, int width, int y, int height, int bpc);
-void (*filter[4])(uint8_t *dst, int width,
-  float rdiv, float bias, const int *const matrix,
-  const uint8_t *c[], int peak, int radius,
-  int dstride, int stride);
-} ConvolutionContext;
-
 #define OFFSET(x) offsetof(ConvolutionContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
@@ -625,6 +588,8 @@ static int config_input(AVFilterLink *inlink)
 s->filter[p] = filter16_7x7;
 }
 }
+if (ARCH_X86_64)
+ff_convolution_init_x86(s);
 } else if (!strcmp(ctx->filter->name, "prewitt")) {
 if (s->depth > 8)
 for (p = 0; p < s->nb_planes; p++)
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index 

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

2019-07-31 Thread Reimar Döffinger
Looks good to me

On 31.07.2019, at 03:30, Shiyou Yin  wrote:

> 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".
___
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/hlsenc: merge mpegts and fmp4 workflow to one workflow

2019-07-31 Thread Steven Liu
write mpegts or fmp4 context into buffer, and flush the buffer into
output file when split fragment. merge two format split workflow into
one workflow

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 207 ---
 1 file changed, 95 insertions(+), 112 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 51310fb528..68d9201a5e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -815,7 +815,7 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 vs->start_pos = 0;
 vs->new_start = 1;
 
-if (hls->segment_type == SEGMENT_TYPE_FMP4) {
+if (hls->segment_type == SEGMENT_TYPE_FMP4 && hls->max_seg_size > 0) {
 if (hls->http_persistent > 0) {
 //TODO: Support fragment fmp4 for http persistent in HLS muxer.
 av_log(s, AV_LOG_WARNING, "http persistent mode is currently 
unsupported for fragment mp4 in the HLS muxer.\n");
@@ -824,34 +824,38 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 av_log(s, AV_LOG_WARNING, "Multi-file byterange mode is currently 
unsupported in the HLS muxer.\n");
 return AVERROR_PATCHWELCOME;
 }
+}
 
-vs->packets_written = 0;
-vs->init_range_length = 0;
-set_http_options(s, , hls);
-if ((ret = avio_open_dyn_buf(>pb)) < 0)
-return ret;
+vs->packets_written = 0;
+vs->init_range_length = 0;
+set_http_options(s, , hls);
+if ((ret = avio_open_dyn_buf(>pb)) < 0)
+return ret;
 
+if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 if (byterange_mode) {
 ret = hlsenc_io_open(s, >out, vs->basename, );
 } else {
 ret = hlsenc_io_open(s, >out, vs->base_output_dirname, 
);
 }
-av_dict_free();
+}
+av_dict_free();
+if (ret < 0) {
+av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
vs->fmp4_init_filename);
+return ret;
+}
+
+if (hls->format_options_str) {
+ret = av_dict_parse_string(>format_options, 
hls->format_options_str, "=", ":", 0);
 if (ret < 0) {
-av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
vs->fmp4_init_filename);
+av_log(s, AV_LOG_ERROR, "Could not parse format options list 
'%s'\n",
+   hls->format_options_str);
 return ret;
 }
+}
 
-if (hls->format_options_str) {
-ret = av_dict_parse_string(>format_options, 
hls->format_options_str, "=", ":", 0);
-if (ret < 0) {
-av_log(s, AV_LOG_ERROR, "Could not parse format options list 
'%s'\n",
-   hls->format_options_str);
-return ret;
-}
-}
-
-av_dict_copy(, hls->format_options, 0);
+av_dict_copy(, hls->format_options, 0);
+if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 av_dict_set(, "fflags", "-autobsf", 0);
 av_dict_set(, "movflags", "+frag_custom+dash+delay_moov", 
AV_DICT_APPEND);
 ret = avformat_init_output(oc, );
@@ -862,9 +866,9 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 av_dict_free();
 return AVERROR(EINVAL);
 }
-avio_flush(oc->pb);
-av_dict_free();
 }
+avio_flush(oc->pb);
+av_dict_free();
 return 0;
 }
 
@@ -1435,7 +1439,6 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 {
 HLSContext *hls = s->priv_data;
 HLSSegment *en;
-AVFormatContext *oc = vs->avf;
 int target_duration = 0;
 int ret = 0;
 char temp_filename[MAX_URL_SIZE];
@@ -1471,7 +1474,7 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 
 set_http_options(s, , hls);
 snprintf(temp_filename, sizeof(temp_filename), use_temp_file ? "%s.tmp" : 
"%s", vs->m3u8_name);
-if ((ret = hlsenc_io_open(s, (byterange_mode || hls->segment_type == 
SEGMENT_TYPE_FMP4) ? >m3u8_out : >pb, temp_filename, )) < 0) {
+if ((ret = hlsenc_io_open(s, (byterange_mode || hls->segment_type == 
SEGMENT_TYPE_FMP4) ? >m3u8_out : >out, temp_filename, )) < 0) {
 if (hls->ignore_io_errors)
 ret = 0;
 goto fail;
@@ -1483,33 +1486,33 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 }
 
 vs->discontinuity_set = 0;
-ff_hls_write_playlist_header((byterange_mode || hls->segment_type == 
SEGMENT_TYPE_FMP4) ? hls->m3u8_out : oc->pb, hls->version, hls->allowcache,
+ff_hls_write_playlist_header((byterange_mode || hls->segment_type == 
SEGMENT_TYPE_FMP4) ? hls->m3u8_out : vs->out, hls->version, hls->allowcache,
  target_duration, sequence, hls->pl_type, 
hls->flags & HLS_I_FRAMES_ONLY);
 
 if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
vs->discontinuity_set==0 ){
-avio_printf((byterange_mode || hls->segment_type == 

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

2019-07-31 Thread Michael Niedermayer
On Tue, Jul 30, 2019 at 10:27:10AM -0300, James Almer wrote:
> 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.

if AV_PKT_DATA_PARAM_CHANGE is used then other parameters would need to
be handled too i think.
For example pixel format changes alongside width and height.
And it leaves some areas of uncertanity which may require more flags
like does a aspect ratio change or a change of one of the colorspace
parameters need a encoder "flush/restart". (the flush is done from
outside the encoder in the patch so the code would need to know)

Also for symmetry, if AV_PKT_DATA_PARAM_CHANGE expects sidedata on
the input side of the decoder, something should produce matching
side data on the encoder side.

encoder -> decoder should continue working. So only a demuxer
generating the side data could be a problem.

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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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