Re: [FFmpeg-devel] [PATCH 1/4] avformat/mpegtsenc: fix incorrect PCR selection with multiple programs

2019-08-02 Thread Andriy Gelman
On Sat, 03. Aug 00:37, Marton Balint wrote:
> The MPEG-TS muxer had a serious bug related to the use of multiple programs:
> in that case, the PCR pid selection was incomplete for all services except 
> one.
> This patch solves this problem and selects a stream to become PCR for each
> service, preferably the video stream.
> 
> This patch also moves pcr calculation attributes to MpegTSWriteStream from
> MpegTSService. PCR is a per-stream and not per-service thing, so it was
> misleading to refer to it as something that is per-service.
> 
> Also remove *service from MpegTSWriteStream because a stream can belong to
> multiple services so it was misleading to select one for each stream.
> 
> You can check the result with this example command:
> 
> ./ffmpeg -loglevel verbose -y -f lavfi -i \
>   
> "testsrc=s=64x64:d=10,split=2[out0][tmp1];[tmp1]vflip[out1];sine=d=10,asetnsamples=1152[out2]"
>  \
>   -flags +bitexact -fflags +bitexact -sws_flags +accurate_rnd+bitexact  \
>   -codec:v libx264 -codec:a mp2 -pix_fmt yuv420p \
>   -map '0:v:0' \
>   -map '0:v:1' \
>   -map '0:a:0'  \
>   -program st=0:st=2 -program st=1:st=2 -program st=2 -program st=0 -f mpegts 
> out.ts
> 
> You should now see this:
> 
> [mpegts @ 0x37505c0] service 1 using PCR in pid=256
> [mpegts @ 0x37505c0] service 2 using PCR in pid=257
> [mpegts @ 0x37505c0] service 3 using PCR in pid=258
> [mpegts @ 0x37505c0] service 4 using PCR in pid=256
> 
> Fixed ticket #8039.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mpegtsenc.c | 145 
> +++-
>  1 file changed, 82 insertions(+), 63 deletions(-)
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index fc0ea225c6..1446d8e2e4 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -57,8 +57,6 @@ typedef struct MpegTSService {
>  uint8_t name[256];
>  uint8_t provider_name[256];
>  int pcr_pid;
> -int pcr_packet_count;
> -int pcr_packet_period;
>  AVProgram *program;
>  } MpegTSService;
>  
> @@ -228,7 +226,6 @@ static int mpegts_write_section1(MpegTSSection *s, int 
> tid, int id,
>  #define PCR_RETRANS_TIME 20
>  
>  typedef struct MpegTSWriteStream {
> -struct MpegTSService *service;
>  int pid; /* stream associated pid */
>  int cc;
>  int discontinuity;
> @@ -242,6 +239,9 @@ typedef struct MpegTSWriteStream {
>  AVFormatContext *amux;
>  AVRational user_tb;
>  
> +int pcr_packet_count;
> +int pcr_packet_period;
> +
>  /* For Opus */
>  int opus_queued_samples;
>  int opus_pending_trim_start;
> @@ -769,12 +769,76 @@ static void section_write_packet(MpegTSSection *s, 
> const uint8_t *packet)
>  avio_write(ctx->pb, packet, TS_PACKET_SIZE);
>  }
>  
> +static void enable_pcr_generation_for_stream(AVFormatContext *s, AVStream 
> *pcr_st)
> +{
> +MpegTSWrite *ts = s->priv_data;
> +MpegTSWriteStream *ts_st = pcr_st->priv_data;
> +
> +if (ts->mux_rate > 1) {
> +ts_st->pcr_packet_period   = (int64_t)ts->mux_rate * ts->pcr_period /
> + (TS_PACKET_SIZE * 8 * 1000);
> +} else {
> +if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
> +int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 
> 0);
> +if (!frame_size) {
> +av_log(s, AV_LOG_WARNING, "frame size not set\n");
> +ts_st->pcr_packet_period =
> +pcr_st->codecpar->sample_rate / (10 * 512);
> +} else {
> +ts_st->pcr_packet_period =
> +pcr_st->codecpar->sample_rate / (10 * frame_size);
> +}
> +} else {
> +// max delta PCR 0.1s
> +// TODO: should be avg_frame_rate
> +ts_st->pcr_packet_period =
> +ts_st->user_tb.den / (10 * ts_st->user_tb.num);
> +}
> +if (!ts_st->pcr_packet_period)
> +ts_st->pcr_packet_period = 1;
> +}
> +
> +// output a PCR as soon as possible
> +ts_st->pcr_packet_count = ts_st->pcr_packet_period;
> +}
> +
> +static void select_pcr_streams(AVFormatContext *s)
> +{
> +MpegTSWrite *ts = s->priv_data;
> +
> +for (int i = 0; i < ts->nb_services; i++) {
> +MpegTSService *service = ts->services[i];
> +AVStream *pcr_st = NULL;
> +
> +if (service->program) {
> +for (int j = 0; j < service->program->nb_stream_indexes; j++) {
> +AVStream *st = s->streams[service->program->stream_index[j]];
> +if (!pcr_st ||
> +pcr_st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO && 
> st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
> +{
> +pcr_st = st;
> +}
> +}
> +} else {

> +if (s->nb_streams > 0)
> +pcr_st = s->streams[0];

This slightly changes the behaviour in comparison to original code. 

Re: [FFmpeg-devel] [PATCH 3/6] avcodec/pictordec: Optimize picmemset() for single plane full lines

2019-08-02 Thread Peter Ross
On Sat, Aug 03, 2019 at 01:49:54AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (72sec -> 1sec)
> Fixes: 
> 15512/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-5663942342344704
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/pictordec.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
> index 2e6fcdca52..5beb03cd5d 100644
> --- a/libavcodec/pictordec.c
> +++ b/libavcodec/pictordec.c
> @@ -66,6 +66,7 @@ static void picmemset(PicContext *s, AVFrame *frame, 
> unsigned value, int run,
>  int xl = *x;
>  int yl = *y;
>  int planel = *plane;
> +int pixels_per_value = 8/bits_per_plane;
>  value   <<= shift;
>  
>  d = frame->data[0] + yl * frame->linesize[0];
> @@ -74,7 +75,7 @@ static void picmemset(PicContext *s, AVFrame *frame, 
> unsigned value, int run,
>  for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
>  d[xl] |= (value >> j) & mask;
>  xl += 1;
> -if (xl == s->width) {
> +while (xl == s->width) {
>  yl -= 1;
>  xl = 0;
>  if (yl < 0) {
> @@ -86,6 +87,19 @@ static void picmemset(PicContext *s, AVFrame *frame, 
> unsigned value, int run,
> mask  <<= bits_per_plane;
>  }
>  d = frame->data[0] + yl * frame->linesize[0];
> +if (s->nb_planes == 1 &&
> +run*pixels_per_value >= s->width &&
> +pixels_per_value < s->width) {
> +int j;
> +for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {

suggest naming it 'k' to avoid confusion with earlier for loop.

> +d[xl] |= (value >> j) & mask;
> +xl += 1;
> +}
> +av_assert0(xl == pixels_per_value);

ok.

> +av_memcpy_backptr(d+xl, pixels_per_value, s->width - xl);
> +run -= (s->width + pixels_per_value - 1) / 
> pixels_per_value;
> +xl = s->width;
> +}
>  }
>  }
>  run--;
> -- 
> 2.22.0

otherwise patch is good.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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/6] avcodec/vp3: Check for end of input in vp4_unpack_vlcs()

2019-08-02 Thread Peter Ross
On Sat, Aug 03, 2019 at 01:49:52AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (too long -> 1sec)
> Fixes: 
> 15232/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5769583086010368
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vp3.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 6ce901eda9..28ed0461c7 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -1403,6 +1403,8 @@ static int vp4_unpack_vlcs(Vp3DecodeContext *s, 
> GetBitContext *gb,
>  int eob_run;
>  
>  while (!eob_tracker[coeff_i]) {
> +if (get_bits_left(gb) < 1)
> +return AVERROR_INVALIDDATA;
>  
>  token = get_vlc2(gb, vlc_tables[coeff_i]->table, 11, 3);
>  

approve.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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/5] avcodec/vp8: do vp7_fade_frame() later

2019-08-02 Thread Peter Ross
On Fri, Aug 02, 2019 at 07:19:11PM +0200, Michael Niedermayer wrote:
> On Fri, Aug 02, 2019 at 10:46:04PM +1000, Peter Ross wrote:
> > On Thu, Aug 01, 2019 at 11:44:39PM +0200, Michael Niedermayer wrote:
> > > Fixes: Timeout (100sec -> 5sec)
> > > Fixes: 
> > > 15073/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5649257362620416
> > > 
> > > Untested as none of the vp7 samples i found executes this codepath
> > 
> > see attached. its all i can find :(
> 
> iam not sure iam making a mistake but these 2 files dont seem to execute
> it

you are right michael. the samples attached have alpha/beta fade bits, but
they are both set to zero, therefore fade() is never called.

i dug up my old vp7-dev branch, and found alpha/beta were forced to specifically
test the fade path with those samples. e.g.:

  int alpha = (int8_t) vp8_rac_get_uint(c, 8) + 1;
  int beta  = (int8_t) vp8_rac_get_uint(c, 8) + 1;

all my other vp7 samples stop before the alpha/beta frame bits.


also, this sample has alpha/beta set to non-zero, but was generated through
fuzzing and produces no video.
https://trac.ffmpeg.org/attachment/ticket/3501/vp7_1_f.avi

cheers,

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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 3/6] avcodec/pictordec: Optimize picmemset() for single plane full lines

2019-08-02 Thread Michael Niedermayer
Fixes: Timeout (72sec -> 1sec)
Fixes: 
15512/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-5663942342344704

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

diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
index 2e6fcdca52..5beb03cd5d 100644
--- a/libavcodec/pictordec.c
+++ b/libavcodec/pictordec.c
@@ -66,6 +66,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned 
value, int run,
 int xl = *x;
 int yl = *y;
 int planel = *plane;
+int pixels_per_value = 8/bits_per_plane;
 value   <<= shift;
 
 d = frame->data[0] + yl * frame->linesize[0];
@@ -74,7 +75,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned 
value, int run,
 for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
 d[xl] |= (value >> j) & mask;
 xl += 1;
-if (xl == s->width) {
+while (xl == s->width) {
 yl -= 1;
 xl = 0;
 if (yl < 0) {
@@ -86,6 +87,19 @@ static void picmemset(PicContext *s, AVFrame *frame, 
unsigned value, int run,
mask  <<= bits_per_plane;
 }
 d = frame->data[0] + yl * frame->linesize[0];
+if (s->nb_planes == 1 &&
+run*pixels_per_value >= s->width &&
+pixels_per_value < s->width) {
+int j;
+for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
+d[xl] |= (value >> j) & mask;
+xl += 1;
+}
+av_assert0(xl == pixels_per_value);
+av_memcpy_backptr(d+xl, pixels_per_value, s->width - xl);
+run -= (s->width + pixels_per_value - 1) / 
pixels_per_value;
+xl = s->width;
+}
 }
 }
 run--;
-- 
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/6] avcodec/hnm4video: Optimize postprocess_current_frame()

2019-08-02 Thread Michael Niedermayer
Improves: Timeout (220sec -> 108sec)
Improves: 
15570/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HNM4_VIDEO_fuzzer-5085482213441536

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

diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c
index 9e1ac49ddc..68d0baef6d 100644
--- a/libavcodec/hnm4video.c
+++ b/libavcodec/hnm4video.c
@@ -117,14 +117,17 @@ static void unpack_intraframe(AVCodecContext *avctx, 
uint8_t *src,
 static void postprocess_current_frame(AVCodecContext *avctx)
 {
 Hnm4VideoContext *hnm = avctx->priv_data;
-uint32_t x, y, src_x, src_y;
+uint32_t x, y, src_y;
+int width = hnm->width;
 
 for (y = 0; y < hnm->height; y++) {
+uint8_t *dst = hnm->processed + y * width;
+const uint8_t *src = hnm->current;
 src_y = y - (y % 2);
-src_x = src_y * hnm->width + (y % 2);
-for (x = 0; x < hnm->width; x++) {
-hnm->processed[(y * hnm->width) + x] = hnm->current[src_x];
-src_x += 2;
+src += src_y * width + (y % 2);
+for (x = 0; x < width; x++) {
+dst[x] = *src;
+src += 2;
 }
 }
 }
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 6/6] avcodec/mss1: check for overread and forward errors

2019-08-02 Thread Michael Niedermayer
Fixes: Timeout (106sec -> 14ms)
Fixes: 
15576/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSS1_fuzzer-5688080461201408

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mss1.c  |  3 +++
 libavcodec/mss12.c | 12 
 libavcodec/mss12.h |  2 ++
 libavcodec/mss2.c  |  1 +
 4 files changed, 18 insertions(+)

diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c
index a579d9d9a4..84b7a37007 100644
--- a/libavcodec/mss1.c
+++ b/libavcodec/mss1.c
@@ -56,6 +56,8 @@ static void arith_normalise(ArithCoder *c)
 c->low   <<= 1;
 c->high  <<= 1;
 c->high   |= 1;
+if (get_bits_left(c->gbc.gb) < 1)
+c->overread++;
 c->value  |= get_bits1(c->gbc.gb);
 }
 }
@@ -112,6 +114,7 @@ static void arith_init(ArithCoder *c, GetBitContext *gb)
 c->low   = 0;
 c->high  = 0x;
 c->value = get_bits(gb, 16);
+c->overread  = 0;
 c->gbc.gb= gb;
 c->get_model_sym = arith_get_model_sym;
 c->get_number= arith_get_number;
diff --git a/libavcodec/mss12.c b/libavcodec/mss12.c
index 3b1a3029e0..5a5bd9a91b 100644
--- a/libavcodec/mss12.c
+++ b/libavcodec/mss12.c
@@ -161,6 +161,8 @@ static av_always_inline int decode_pixel(ArithCoder 
*acoder, PixContext *pctx,
 {
 int i, val, pix;
 
+if (acoder->overread > MAX_OVERREAD)
+return AVERROR_INVALIDDATA;
 val = acoder->get_model_sym(acoder, >cache_model);
 if (val < pctx->num_syms) {
 if (any_ngb) {
@@ -306,6 +308,8 @@ static int decode_region(ArithCoder *acoder, uint8_t *dst, 
uint8_t *rgb_pic,
 else
 p = decode_pixel_in_context(acoder, pctx, dst + i, stride,
 i, j, width - i - 1);
+if (p < 0)
+return p;
 dst[i] = p;
 
 if (rgb_pic)
@@ -398,6 +402,8 @@ static int decode_region_masked(MSS12Context const *c, 
ArithCoder *acoder,
 else
 p = decode_pixel_in_context(acoder, pctx, dst + i, stride,
 i, j, width - i - 1);
+if (p < 0)
+return p;
 dst[i] = p;
 if (c->rgb_pic)
 AV_WB24(rgb_dst + i * 3, c->pal[p]);
@@ -473,6 +479,8 @@ static int decode_region_intra(SliceContext *sc, ArithCoder 
*acoder,
 uint8_t *rgb_dst = c->rgb_pic + x * 3 + y * rgb_stride;
 
 pix = decode_pixel(acoder, >intra_pix_ctx, NULL, 0, 0);
+if (pix < 0)
+return pix;
 rgb_pix = c->pal[pix];
 for (i = 0; i < height; i++, dst += stride, rgb_dst += rgb_stride) {
 memset(dst, pix, width);
@@ -499,6 +507,8 @@ static int decode_region_inter(SliceContext *sc, ArithCoder 
*acoder,
 
 if (!mode) {
 mode = decode_pixel(acoder, >inter_pix_ctx, NULL, 0, 0);
+if (mode < 0)
+return mode;
 
 if (c->avctx->err_recognition & AV_EF_EXPLODE &&
 ( c->rgb_pic && mode != 0x01 && mode != 0x02 && mode != 0x04 ||
@@ -530,6 +540,8 @@ int ff_mss12_decode_rect(SliceContext *sc, ArithCoder 
*acoder,
  int x, int y, int width, int height)
 {
 int mode, pivot;
+if (acoder->overread > MAX_OVERREAD)
+return AVERROR_INVALIDDATA;
 
 mode = acoder->get_model_sym(acoder, >split_mode);
 
diff --git a/libavcodec/mss12.h b/libavcodec/mss12.h
index 45c4074652..6f68fc3db6 100644
--- a/libavcodec/mss12.h
+++ b/libavcodec/mss12.h
@@ -47,6 +47,8 @@ typedef struct Model {
 
 typedef struct ArithCoder {
 int low, high, value;
+int overread;
+#define MAX_OVERREAD 16
 union {
 GetBitContext *gb;
 GetByteContext *gB;
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 2eb366ee78..29897cea2e 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -152,6 +152,7 @@ static void arith2_init(ArithCoder *c, GetByteContext *gB)
 c->low   = 0;
 c->high  = 0xFF;
 c->value = bytestream2_get_be24(gB);
+c->overread  = 0;
 c->gbc.gB= gB;
 c->get_model_sym = arith2_get_model_sym;
 c->get_number= arith2_get_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 1/6] avcodec/vp3: Check for end of input in vp4_unpack_vlcs()

2019-08-02 Thread Michael Niedermayer
Fixes: Timeout (too long -> 1sec)
Fixes: 
15232/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5769583086010368

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

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 6ce901eda9..28ed0461c7 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -1403,6 +1403,8 @@ static int vp4_unpack_vlcs(Vp3DecodeContext *s, 
GetBitContext *gb,
 int eob_run;
 
 while (!eob_tracker[coeff_i]) {
+if (get_bits_left(gb) < 1)
+return AVERROR_INVALIDDATA;
 
 token = get_vlc2(gb, vlc_tables[coeff_i]->table, 11, 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".

[FFmpeg-devel] [PATCH 5/6] avcodec/hnm4video: Forward errors of decode_interframe_v4()

2019-08-02 Thread Michael Niedermayer
Fixes: Timeout (108sec -> 160ms)
Fixes: 
15570/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HNM4_VIDEO_fuzzer-5085482213441536

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

diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c
index 68d0baef6d..177ce1d47a 100644
--- a/libavcodec/hnm4video.c
+++ b/libavcodec/hnm4video.c
@@ -146,7 +146,7 @@ static void copy_processed_frame(AVCodecContext *avctx, 
AVFrame *frame)
 }
 }
 
-static void decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t 
size)
+static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t 
size)
 {
 Hnm4VideoContext *hnm = avctx->priv_data;
 GetByteContext gb;
@@ -165,7 +165,7 @@ static void decode_interframe_v4(AVCodecContext *avctx, 
uint8_t *src, uint32_t s
 if (tag == 0) {
 if (writeoffset + 2 > hnm->width * hnm->height) {
 av_log(avctx, AV_LOG_ERROR, "writeoffset out of bounds\n");
-break;
+return AVERROR_INVALIDDATA;
 }
 hnm->current[writeoffset++] = bytestream2_get_byte();
 hnm->current[writeoffset++] = bytestream2_get_byte();
@@ -179,7 +179,7 @@ static void decode_interframe_v4(AVCodecContext *avctx, 
uint8_t *src, uint32_t s
 count = bytestream2_get_byte() * 2;
 if (writeoffset + count > hnm->width * hnm->height) {
 av_log(avctx, AV_LOG_ERROR, "writeoffset out of bounds\n");
-break;
+return AVERROR_INVALIDDATA;
 }
 while (count > 0) {
 hnm->current[writeoffset++] = bytestream2_peek_byte();
@@ -191,7 +191,7 @@ static void decode_interframe_v4(AVCodecContext *avctx, 
uint8_t *src, uint32_t s
 }
 if (writeoffset > hnm->width * hnm->height) {
 av_log(avctx, AV_LOG_ERROR, "writeoffset out of bounds\n");
-break;
+return AVERROR_INVALIDDATA;
 }
 } else {
 previous = bytestream2_peek_byte() & 0x20;
@@ -207,24 +207,25 @@ static void decode_interframe_v4(AVCodecContext *avctx, 
uint8_t *src, uint32_t s
 
 if (!backward && offset + 2*count > hnm->width * hnm->height) {
 av_log(avctx, AV_LOG_ERROR, "Attempting to read out of 
bounds\n");
-break;
+return AVERROR_INVALIDDATA;
 } else if (backward && offset + 1 >= hnm->width * hnm->height) {
 av_log(avctx, AV_LOG_ERROR, "Attempting to read out of 
bounds\n");
-break;
+return AVERROR_INVALIDDATA;
 } else if (writeoffset + 2*count > hnm->width * hnm->height) {
 av_log(avctx, AV_LOG_ERROR,
"Attempting to write out of bounds\n");
-break;
+return AVERROR_INVALIDDATA;
+
 }
 if(backward) {
 if (offset < (!!backline)*(2 * hnm->width - 1) + 2*(left-1)) {
 av_log(avctx, AV_LOG_ERROR, "Attempting to read out of 
bounds\n");
-break;
+return AVERROR_INVALIDDATA;
 }
 } else {
 if (offset < (!!backline)*(2 * hnm->width - 1)) {
 av_log(avctx, AV_LOG_ERROR, "Attempting to read out of 
bounds\n");
-break;
+return AVERROR_INVALIDDATA;
 }
 }
 
@@ -271,6 +272,7 @@ static void decode_interframe_v4(AVCodecContext *avctx, 
uint8_t *src, uint32_t s
 }
 }
 }
+return 0;
 }
 
 static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
@@ -438,7 +440,9 @@ static int hnm_decode_frame(AVCodecContext *avctx, void 
*data,
 decode_interframe_v4a(avctx, avpkt->data + 8, avpkt->size - 8);
 memcpy(hnm->processed, hnm->current, hnm->width * hnm->height);
 } else {
-decode_interframe_v4(avctx, avpkt->data + 8, avpkt->size - 8);
+int ret = decode_interframe_v4(avctx, avpkt->data + 8, avpkt->size 
- 8);
+if (ret < 0)
+return ret;
 postprocess_current_frame(avctx);
 }
 copy_processed_frame(avctx, frame);
-- 
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/6] avcodec/loco: Check for end of input in pixel decode

2019-08-02 Thread Michael Niedermayer
Fixes: Timeout (100sec -> 5sec)
Fixes: 
15509/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LOCO_fuzzer-5724297261219840

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

diff --git a/libavcodec/loco.c b/libavcodec/loco.c
index e8c62b8178..5fb414b411 100644
--- a/libavcodec/loco.c
+++ b/libavcodec/loco.c
@@ -88,6 +88,8 @@ static inline int loco_get_rice(RICEContext *r)
 loco_update_rice_param(r, 0);
 return 0;
 }
+if (get_bits_left(>gb) < 1)
+return INT_MIN;
 v = get_ur_golomb_jpegls(>gb, loco_get_rice_param(r), INT_MAX, 0);
 loco_update_rice_param(r, (v + 1) >> 1);
 if (!v) {
@@ -163,6 +165,8 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, 
int width, int heigh
 /* restore all other pixels */
 for (i = 1; i < width; i++) {
 val = loco_get_rice();
+if (val == INT_MIN)
+return -1;
 data[i] = loco_predict([i], stride) + val;
 }
 data += stride;
-- 
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/4] avformat/mpegtsenc: use increasing numbers in default service names

2019-08-02 Thread Marton Balint
Maybe we should use service ID instead of increasing numbers?

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

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index f32f99114a..c30f13670c 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -218,7 +218,7 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, 
int id,
 /* mpegts writer */
 
 #define DEFAULT_PROVIDER_NAME   "FFmpeg"
-#define DEFAULT_SERVICE_NAME"Service01"
+#define DEFAULT_SERVICE_NAME"Service"
 
 /* we retransmit the SI info at this rate */
 #define SDT_RETRANS_TIME 500
@@ -749,13 +749,15 @@ static MpegTSService *mpegts_add_service(AVFormatContext 
*s, int sid,
 MpegTSWrite *ts = s->priv_data;
 MpegTSService *service;
 AVDictionaryEntry *title, *provider;
+char default_service_name[32];
 const char *service_name;
 const char *provider_name;
 
 title = av_dict_get(metadata, "service_name", NULL, 0);
 if (!title)
 title = av_dict_get(metadata, "title", NULL, 0);
-service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
+snprintf(default_service_name, sizeof(default_service_name), "%s%02d", 
DEFAULT_SERVICE_NAME, ts->nb_services + 1);
+service_name  = title ? title->value : default_service_name;
 provider  = av_dict_get(metadata, "service_provider", NULL, 0);
 provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
 
-- 
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] [PATCH 3/4] avformat/mpegtsenc: remove section_write_packet forward declaration

2019-08-02 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 50 -
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index a2adcc0022..f32f99114a 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -717,7 +717,30 @@ invalid:
 return 0;
 }
 
-static void section_write_packet(MpegTSSection *s, const uint8_t *packet);
+static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
+{
+return av_rescale(avio_tell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
+   ts->first_pcr;
+}
+
+static void mpegts_prefix_m2ts_header(AVFormatContext *s)
+{
+MpegTSWrite *ts = s->priv_data;
+if (ts->m2ts_mode) {
+int64_t pcr = get_pcr(s->priv_data, s->pb);
+uint32_t tp_extra_header = pcr % 0x3fff;
+tp_extra_header = AV_RB32(_extra_header);
+avio_write(s->pb, (unsigned char *) _extra_header,
+   sizeof(tp_extra_header));
+}
+}
+
+static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
+{
+AVFormatContext *ctx = s->opaque;
+mpegts_prefix_m2ts_header(ctx);
+avio_write(ctx->pb, packet, TS_PACKET_SIZE);
+}
 
 static MpegTSService *mpegts_add_service(AVFormatContext *s, int sid,
  const AVDictionary *metadata,
@@ -762,31 +785,6 @@ fail:
 return NULL;
 }
 
-static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
-{
-return av_rescale(avio_tell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
-   ts->first_pcr;
-}
-
-static void mpegts_prefix_m2ts_header(AVFormatContext *s)
-{
-MpegTSWrite *ts = s->priv_data;
-if (ts->m2ts_mode) {
-int64_t pcr = get_pcr(s->priv_data, s->pb);
-uint32_t tp_extra_header = pcr % 0x3fff;
-tp_extra_header = AV_RB32(_extra_header);
-avio_write(s->pb, (unsigned char *) _extra_header,
-   sizeof(tp_extra_header));
-}
-}
-
-static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
-{
-AVFormatContext *ctx = s->opaque;
-mpegts_prefix_m2ts_header(ctx);
-avio_write(ctx->pb, packet, TS_PACKET_SIZE);
-}
-
 static void enable_pcr_generation_for_stream(AVFormatContext *s, AVStream 
*pcr_st)
 {
 MpegTSWrite *ts = s->priv_data;
-- 
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] [PATCH 2/4] avformat/mpegtsenc: factorize setting up services

2019-08-02 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 66 +++--
 1 file changed, 25 insertions(+), 41 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 1446d8e2e4..a2adcc0022 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -717,12 +717,24 @@ invalid:
 return 0;
 }
 
+static void section_write_packet(MpegTSSection *s, const uint8_t *packet);
+
 static MpegTSService *mpegts_add_service(AVFormatContext *s, int sid,
- const char *provider_name,
- const char *name)
+ const AVDictionary *metadata,
+ AVProgram *program)
 {
 MpegTSWrite *ts = s->priv_data;
 MpegTSService *service;
+AVDictionaryEntry *title, *provider;
+const char *service_name;
+const char *provider_name;
+
+title = av_dict_get(metadata, "service_name", NULL, 0);
+if (!title)
+title = av_dict_get(metadata, "title", NULL, 0);
+service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
+provider  = av_dict_get(metadata, "service_provider", NULL, 0);
+provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
 
 service = av_mallocz(sizeof(MpegTSService));
 if (!service)
@@ -731,13 +743,19 @@ static MpegTSService *mpegts_add_service(AVFormatContext 
*s, int sid,
 service->sid   = sid;
 service->pcr_pid   = 0x1fff;
 if (encode_str8(service->provider_name, provider_name) < 0 ||
-encode_str8(service->name, name) < 0) {
+encode_str8(service->name, service_name) < 0) {
 av_log(s, AV_LOG_ERROR, "Too long service or provider name\n");
 goto fail;
 }
 if (av_dynarray_add_nofree(>services, >nb_services, service) < 0)
 goto fail;
 
+service->pmt.write_packet = section_write_packet;
+service->pmt.opaque   = s;
+service->pmt.cc   = 15;
+service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
+service->program  = program;
+
 return service;
 fail:
 av_free(service);
@@ -836,13 +854,7 @@ static void select_pcr_streams(AVFormatContext *s)
 static int mpegts_init(AVFormatContext *s)
 {
 MpegTSWrite *ts = s->priv_data;
-MpegTSWriteStream *ts_st;
-MpegTSService *service;
-AVStream *st;
-AVDictionaryEntry *title, *provider;
 int i, j;
-const char *service_name;
-const char *provider_name;
 int *pids;
 int ret;
 
@@ -856,42 +868,13 @@ static int mpegts_init(AVFormatContext *s)
 ts->onid = ts->original_network_id;
 if (!s->nb_programs) {
 /* allocate a single DVB service */
-title = av_dict_get(s->metadata, "service_name", NULL, 0);
-if (!title)
-title = av_dict_get(s->metadata, "title", NULL, 0);
-service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
-provider  = av_dict_get(s->metadata, "service_provider", NULL, 0);
-provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
-service   = mpegts_add_service(s, ts->service_id,
-   provider_name, service_name);
-
-if (!service)
+if (!mpegts_add_service(s, ts->service_id, s->metadata, NULL))
 return AVERROR(ENOMEM);
-
-service->pmt.write_packet = section_write_packet;
-service->pmt.opaque   = s;
-service->pmt.cc   = 15;
-service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
 } else {
 for (i = 0; i < s->nb_programs; i++) {
 AVProgram *program = s->programs[i];
-title = av_dict_get(program->metadata, "service_name", NULL, 0);
-if (!title)
-title = av_dict_get(program->metadata, "title", NULL, 0);
-service_name  = title ? title->value : DEFAULT_SERVICE_NAME;
-provider  = av_dict_get(program->metadata, "service_provider", 
NULL, 0);
-provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
-service   = mpegts_add_service(s, program->id,
-   provider_name, service_name);
-
-if (!service)
+if (!mpegts_add_service(s, program->id, program->metadata, 
program))
 return AVERROR(ENOMEM);
-
-service->pmt.write_packet = section_write_packet;
-service->pmt.opaque   = s;
-service->pmt.cc   = 15;
-service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
-service->program  = program;
 }
 }
 
@@ -917,7 +900,8 @@ static int mpegts_init(AVFormatContext *s)
 
 /* assign pids to each stream */
 for (i = 0; i < s->nb_streams; i++) {
-st = s->streams[i];
+AVStream *st = s->streams[i];
+

[FFmpeg-devel] [PATCH 1/4] avformat/mpegtsenc: fix incorrect PCR selection with multiple programs

2019-08-02 Thread Marton Balint
The MPEG-TS muxer had a serious bug related to the use of multiple programs:
in that case, the PCR pid selection was incomplete for all services except one.
This patch solves this problem and selects a stream to become PCR for each
service, preferably the video stream.

This patch also moves pcr calculation attributes to MpegTSWriteStream from
MpegTSService. PCR is a per-stream and not per-service thing, so it was
misleading to refer to it as something that is per-service.

Also remove *service from MpegTSWriteStream because a stream can belong to
multiple services so it was misleading to select one for each stream.

You can check the result with this example command:

./ffmpeg -loglevel verbose -y -f lavfi -i \
  
"testsrc=s=64x64:d=10,split=2[out0][tmp1];[tmp1]vflip[out1];sine=d=10,asetnsamples=1152[out2]"
 \
  -flags +bitexact -fflags +bitexact -sws_flags +accurate_rnd+bitexact  \
  -codec:v libx264 -codec:a mp2 -pix_fmt yuv420p \
  -map '0:v:0' \
  -map '0:v:1' \
  -map '0:a:0'  \
  -program st=0:st=2 -program st=1:st=2 -program st=2 -program st=0 -f mpegts 
out.ts

You should now see this:

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

Fixed ticket #8039.

Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 145 +++-
 1 file changed, 82 insertions(+), 63 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..1446d8e2e4 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -57,8 +57,6 @@ typedef struct MpegTSService {
 uint8_t name[256];
 uint8_t provider_name[256];
 int pcr_pid;
-int pcr_packet_count;
-int pcr_packet_period;
 AVProgram *program;
 } MpegTSService;
 
@@ -228,7 +226,6 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, 
int id,
 #define PCR_RETRANS_TIME 20
 
 typedef struct MpegTSWriteStream {
-struct MpegTSService *service;
 int pid; /* stream associated pid */
 int cc;
 int discontinuity;
@@ -242,6 +239,9 @@ typedef struct MpegTSWriteStream {
 AVFormatContext *amux;
 AVRational user_tb;
 
+int pcr_packet_count;
+int pcr_packet_period;
+
 /* For Opus */
 int opus_queued_samples;
 int opus_pending_trim_start;
@@ -769,12 +769,76 @@ static void section_write_packet(MpegTSSection *s, const 
uint8_t *packet)
 avio_write(ctx->pb, packet, TS_PACKET_SIZE);
 }
 
+static void enable_pcr_generation_for_stream(AVFormatContext *s, AVStream 
*pcr_st)
+{
+MpegTSWrite *ts = s->priv_data;
+MpegTSWriteStream *ts_st = pcr_st->priv_data;
+
+if (ts->mux_rate > 1) {
+ts_st->pcr_packet_period   = (int64_t)ts->mux_rate * ts->pcr_period /
+ (TS_PACKET_SIZE * 8 * 1000);
+} else {
+if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
+if (!frame_size) {
+av_log(s, AV_LOG_WARNING, "frame size not set\n");
+ts_st->pcr_packet_period =
+pcr_st->codecpar->sample_rate / (10 * 512);
+} else {
+ts_st->pcr_packet_period =
+pcr_st->codecpar->sample_rate / (10 * frame_size);
+}
+} else {
+// max delta PCR 0.1s
+// TODO: should be avg_frame_rate
+ts_st->pcr_packet_period =
+ts_st->user_tb.den / (10 * ts_st->user_tb.num);
+}
+if (!ts_st->pcr_packet_period)
+ts_st->pcr_packet_period = 1;
+}
+
+// output a PCR as soon as possible
+ts_st->pcr_packet_count = ts_st->pcr_packet_period;
+}
+
+static void select_pcr_streams(AVFormatContext *s)
+{
+MpegTSWrite *ts = s->priv_data;
+
+for (int i = 0; i < ts->nb_services; i++) {
+MpegTSService *service = ts->services[i];
+AVStream *pcr_st = NULL;
+
+if (service->program) {
+for (int j = 0; j < service->program->nb_stream_indexes; j++) {
+AVStream *st = s->streams[service->program->stream_index[j]];
+if (!pcr_st ||
+pcr_st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO && 
st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+{
+pcr_st = st;
+}
+}
+} else {
+if (s->nb_streams > 0)
+pcr_st = s->streams[0];
+}
+
+if (pcr_st) {
+MpegTSWriteStream *ts_st = pcr_st->priv_data;
+service->pcr_pid = ts_st->pid;
+enable_pcr_generation_for_stream(s, pcr_st);
+av_log(s, AV_LOG_VERBOSE, "service %i using PCR in pid=%i\n", 
service->sid, service->pcr_pid);
+}
+}
+}
+
 static int mpegts_init(AVFormatContext *s)
 {
 

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

2019-08-02 Thread Steven Liu


> 在 2019年8月2日,18:46,Michael Niedermayer  写道:
> 
> On Wed, Jul 31, 2019 at 04:07:22PM +0800, Steven Liu wrote:
>> 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(-)
> 
> make -j5 ffmpeg && ./ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags 
> delete_segments -hls_key_info_file file.keyinfo -t 2 /tmp/file-hlsencry.m3u8
> ...
> Output #0, hls, to '/tmp/file-hlsencry.m3u8':
>  Metadata:
>encoder : Lavf58.30.100
>Stream #0:0: Video: h264 (libx264), yuv444p, 320x240 [SAR 1:1 DAR 4:3], 
> q=-1--1, 25 fps, 90k tbn, 25 tbc
>Metadata:
>  encoder : Lavc58.56.100 libx264
>Side data:
>  cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
> [hls @ 0x24a1800] Opening '/tmp/file-hlsencry0.ts' for writingA speed=   0x   
>  
> *** Error in `./ffmpeg': free(): invalid size: 0x02b4aa50 ***
> Aborted (core dumped)
> 
> 
> [hls @ 0x25662840] Opening '/tmp/file-hlsencry0.ts' for writing speed=   0x   
>  
> ==13307== Invalid read of size 8
> ==13307==at 0x6BD2FE: avio_close_dyn_buf (in ffmpeg/ffmpeg_g)
> ==13307==by 0x6F5742: hls_write_trailer (in ffmpeg/ffmpeg_g)
> ==13307==by 0x763E0A: av_write_trailer (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4D390A: transcode (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4B1E1C: main (in ffmpeg/ffmpeg_g)
> ==13307==  Address 0x3dcc6f50 is 8 bytes after a block of size 8 alloc'd
> ==13307==at 0x4C2A6C5: memalign (vg_replace_malloc.c:727)
> ==13307==by 0x4C2A760: posix_memalign (vg_replace_malloc.c:876)
> ==13307==by 0x116963F: av_mallocz (in ffmpeg/ffmpeg_g)
> ==13307==by 0x6BBA37: ffio_open_whitelist (in ffmpeg/ffmpeg_g)
> ==13307==by 0x78B1E9: io_open_default (in ffmpeg/ffmpeg_g)
> ==13307==by 0x6F353D: hls_start (in ffmpeg/ffmpeg_g)
> ==13307==by 0x6F7312: hls_init (in ffmpeg/ffmpeg_g)
> ==13307==by 0x761D12: avformat_init_output (in ffmpeg/ffmpeg_g)
> ==13307==by 0x762434: avformat_write_header (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4C9D58: check_init_output_file (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4CB23D: init_output_stream.constprop.23 (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4D079F: reap_filters (in ffmpeg/ffmpeg_g)
> ==13307== 
> [hls @ 0x25662840] Opening '/tmp/file-hlsencry.m3u8.tmp' for writing
> 
> if you cannot reproduce, tell me and ill rebuild and provide better
> debug info


Yes, i have fix it locally, and will send a V3 patch next monday.
> 
> Thanks
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Its not that you shouldnt use gotos but rather that you should write
> readable code and code with gotos often but not always is less readable
> ___
> 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".

Thanks
Steven





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

2019-08-02 Thread Steven Liu


> 在 2019年8月2日,22:46,Ian Klassen  写道:
> 
> On Fri, Aug 2, 2019 at 5:46 AM Michael Niedermayer 
> wrote:
> 
>> On Wed, Jul 31, 2019 at 04:07:22PM +0800, Steven Liu wrote:
>>> 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(-)
>> 
>> make -j5 ffmpeg && ./ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags
>> delete_segments -hls_key_info_file file.keyinfo -t 2 /tmp/file-hlsencry.m3u8
>> ...
>> Output #0, hls, to '/tmp/file-hlsencry.m3u8':
>>  Metadata:
>>encoder : Lavf58.30.100
>>Stream #0:0: Video: h264 (libx264), yuv444p, 320x240 [SAR 1:1 DAR
>> 4:3], q=-1--1, 25 fps, 90k tbn, 25 tbc
>>Metadata:
>>  encoder : Lavc58.56.100 libx264
>>Side data:
>>  cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
>> [hls @ 0x24a1800] Opening '/tmp/file-hlsencry0.ts' for writingA speed=
>> 0x
>> *** Error in `./ffmpeg': free(): invalid size: 0x02b4aa50 ***
>> Aborted (core dumped)
>> 
>> 
>> [hls @ 0x25662840] Opening '/tmp/file-hlsencry0.ts' for writing speed=
>> 0x
>> ==13307== Invalid read of size 8
>> ==13307==at 0x6BD2FE: avio_close_dyn_buf (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x6F5742: hls_write_trailer (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x763E0A: av_write_trailer (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x4D390A: transcode (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x4B1E1C: main (in ffmpeg/ffmpeg_g)
>> ==13307==  Address 0x3dcc6f50 is 8 bytes after a block of size 8 alloc'd
>> ==13307==at 0x4C2A6C5: memalign (vg_replace_malloc.c:727)
>> ==13307==by 0x4C2A760: posix_memalign (vg_replace_malloc.c:876)
>> ==13307==by 0x116963F: av_mallocz (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x6BBA37: ffio_open_whitelist (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x78B1E9: io_open_default (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x6F353D: hls_start (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x6F7312: hls_init (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x761D12: avformat_init_output (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x762434: avformat_write_header (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x4C9D58: check_init_output_file (in ffmpeg/ffmpeg_g)
>> ==13307==by 0x4CB23D: init_output_stream.constprop.23 (in
>> ffmpeg/ffmpeg_g)
>> ==13307==by 0x4D079F: reap_filters (in ffmpeg/ffmpeg_g)
>> ==13307==
>> [hls @ 0x25662840] Opening '/tmp/file-hlsencry.m3u8.tmp' for writing
>> 
>> if you cannot reproduce, tell me and ill rebuild and provide better
>> debug info
>> 
>> Thanks
>> 
>> [...]
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>> 
>> Its not that you shouldnt use gotos but rather that you should write
>> readable code and code with gotos often but not always is less readable
>> ___
>> 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".
> 
> 
> Is this patch to address bug #7975? https://trac.ffmpeg.org/ticket/7975

No,

Just merge two workflow into one workflow,
fix 7975 next step, just modify the code block at hlsenc_io_open->flush buffer 
data->hlsenc_io_close.
modify to hlsenc_io_open->flush buffer data->check status-> reopen 
(hlsenc_io_open)->reflush data(option retry times)->hlsenc_io_close.
> 
> I tested it on Windows and it still crashes when attempting to write to a
> http server that doesn't support persistent connections:
> 
> [http @ 029C0EBAD080] URL read error: End of file
> [http @ 029C0D410740] Opening 'http://127.0.0.1/stream2.ts' for writing
> [http @ 029C0EBAD080] URL read error: Error number -10053 occurred
> [http @ 029C0D410740] Opening 'http://127.0.0.1/stream.m3u8' for writing
> av_interleaved_write_frame(): Unknown error
> ___
> 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".

Thanks
Steven





___
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] libavcodec/iff: Use unsigned to avoid undefined behaviour

2019-08-02 Thread Andreas Rheinhardt
The initialization of the uint32_t plane32_lut matrix uses left shifts
of the form 1 << plane; plane can be as big as 31 which means that this
is undefined behaviour as 1 will be simply an int. So make it unsigned
to avoid this.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/iff.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 7f1c589d7c..fc7bfad731 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -111,23 +111,23 @@ static const uint64_t plane8_lut[8][256] = {
 LUT8(4), LUT8(5), LUT8(6), LUT8(7),
 };
 
-#define LUT32(plane) {\
- 0,  0,  0,  0,   \
- 0,  0,  0, 1 << plane,   \
- 0,  0, 1 << plane,  0,   \
- 0,  0, 1 << plane, 1 << plane,   \
- 0, 1 << plane,  0,  0,   \
- 0, 1 << plane,  0, 1 << plane,   \
- 0, 1 << plane, 1 << plane,  0,   \
- 0, 1 << plane, 1 << plane, 1 << plane,   \
-1 << plane,  0,  0,  0,   \
-1 << plane,  0,  0, 1 << plane,   \
-1 << plane,  0, 1 << plane,  0,   \
-1 << plane,  0, 1 << plane, 1 << plane,   \
-1 << plane, 1 << plane,  0,  0,   \
-1 << plane, 1 << plane,  0, 1 << plane,   \
-1 << plane, 1 << plane, 1 << plane,  0,   \
-1 << plane, 1 << plane, 1 << plane, 1 << plane,   \
+#define LUT32(plane) {\
+  0,   0,   0,   0,   \
+  0,   0,   0, 1U << plane,   \
+  0,   0, 1U << plane,   0,   \
+  0,   0, 1U << plane, 1U << plane,   \
+  0, 1U << plane,   0,   0,   \
+  0, 1U << plane,   0, 1U << plane,   \
+  0, 1U << plane, 1U << plane,   0,   \
+  0, 1U << plane, 1U << plane, 1U << plane,   \
+1U << plane,   0,   0,   0,   \
+1U << plane,   0,   0, 1U << plane,   \
+1U << plane,   0, 1U << plane,   0,   \
+1U << plane,   0, 1U << plane, 1U << plane,   \
+1U << plane, 1U << plane,   0,   0,   \
+1U << plane, 1U << plane,   0, 1U << plane,   \
+1U << plane, 1U << plane, 1U << plane,   0,   \
+1U << plane, 1U << plane, 1U << plane, 1U << plane,   \
 }
 
 // 32 planes * 4-bit mask * 4 lookup tables each
-- 
2.21.0

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

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

Re: [FFmpeg-devel] Issues while encoding a ts file to m3u8

2019-08-02 Thread James Darnley
On 2019-08-02 15:55, Ramana Jajula wrote:
> Hi,
> 
> I am trying to encode my ts file m3u8 using my customised ffmpeg of version
> 4.1. I used below command to do encoding.
> 
> ffmpeg -re -threads 8 -i /videos/input.ts -vcodec libx264 -s 320x240 -b:v
> 512000 -maxrate 512000 -acodec libfdk_aac -b:a 32000 -ac 2 -ar 48000
> -force_key_frames 'expr:gte(t,n_forced*3)' -hls_flags single_file
> -hls_list_size 0 -hls_time 3 -fsize 400x222 -frames /frames/my_frames/
> -index /mpegindex/my_index.idx  -y /encoded/test/output.m3u8
> 
> My encoding was bad. The output printed to console is
>   libavutil  56. 22.100 / 56. 22.100
>   libavcodec 58. 35.100 / 58. 35.100
>   libavformat58. 20.100 / 58. 20.100
>   libavdevice58.  5.100 / 58.  5.100
>   libavfilter 7. 40.101 /  7. 40.101
>   libavresample   4.  0.  0 /  4.  0.  0
>   libswscale  5.  3.100 /  5.  3.100
>   libswresample   3.  3.100 /  3.  3.100
>   libpostproc55.  3.100 / 55.  3.100
> /videos/input.ts FPS 25.00 0
> Input #0, mpegts, from '/videos/.input.ts':
>   Duration: 00:04:05.97, start: 85837.091689, bitrate: 1769 kb/s
>   Program 1
> Stream #0:0[0x105]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
> yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn,
> 50 tbc
> Stream #0:1[0x106]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
> stereo, fltp, 128 kb/s
> [libx264 @ 0x564a2f7cc480] VBV maxrate specified, but no bufsize, ignored
> [libx264 @ 0x564a2f7cc480] using SAR=4/3
> [libx264 @ 0x564a2f7cc480] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2
> [libx264 @ 0x564a2f7cc480] profile High, level 2.0
> [libx264 @ 0x564a2f7cc480] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC
> codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options:
> cabac=1 ref=3 debloc
> k=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1
> me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11
> fast_pskip=1 chroma_qp_offset
> =-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
> interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
> b_adapt=1 b_bias=0 direct=1 wei
> ghtb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40
> intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=512 ratetol=1.0
> qcomp=0.60 qpmin=0 qpmax=69 qpst
> ep=4 ip_ratio=1.40 aq=1:1.00
> [hls @ 0x564a2f7ccc40] Using AVStream.codec to pass codec parameters to
> muxers is deprecated, use AVStream.codecpar instead.
> Last message repeated 1 times
> [hls @ 0x564a2f7ccc40] Opening '/encodedt/input.ts' for writing
> Output #0, hls, to '/encoded/output.m3u8':
>   Metadata:
> encoder : Lavf58.20.100
> Stream #0:0: Video: h264 (libx264), yuv420p, 320x240 [SAR 4:3 DAR
> 16:9], q=-1--1, 512 kb/s, 25 fps, 90k tbn, 25 tbc
> Metadata:
>   encoder : Lavc58.35.100 libx264
> Side data:
>   cpb: bitrate max/min/avg: 512000/0/512000 buffer size: 0 vbv_delay: -1
> Stream #0:1: Audio: aac (libfdk_aac), 48000 Hz, stereo, s16, 32 kb/s
> Metadata:
>   encoder : Lavc58.35.100 libfdk_aac
> Stream mapping:
>   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
>   Stream #0:1 -> #0:1 (ac3 (native) -> aac (libfdk_aac))
> Press [q] to stop, [?] for help
> frame=   34 fps=0.1 q=0.0 size=N/A time=00:05:02.11 bitrate=N/A dup=29
> drop=0 speed=0.567x
> [hls @ 0x564a2f7ccc40] Packets poorly interleaved, failed to avoid negative
> timestamp -3360 in stream 0.0.567x
> Try -max_interleave_delta 0 as a possible workaround.
> 
> Since the encoding speed is too slow I had to cancel the encoding process.
> I killed it,
> 
> What is the reason for this slow encoding process?
> 
> PS: My input file is of 1 hour duration.
> 

1 - Wrong mailing list.  This should probably be on ffmpeg-user.

2 - What configure options did you use for ffmpeg?  Why did you remove them?

3 - What "modifications" have you made"?

4 - What CPU do you have?  One without AVX is either old, or limited
(like Celerons and Pentiums)

5 - Why are you using an x264 from 2016?  Have you "modified" it too?

Next time just press 'q' to end encoding so we can see some stats.

___
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] avcodec/vp8: do vp7_fade_frame() later

2019-08-02 Thread Michael Niedermayer
On Fri, Aug 02, 2019 at 10:46:04PM +1000, Peter Ross wrote:
> On Thu, Aug 01, 2019 at 11:44:39PM +0200, Michael Niedermayer wrote:
> > Fixes: Timeout (100sec -> 5sec)
> > Fixes: 
> > 15073/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5649257362620416
> > 
> > Untested as none of the vp7 samples i found executes this codepath
> 
> see attached. its all i can find :(

iam not sure iam making a mistake but these 2 files dont seem to execute
it

Tested with: AB is always 0 0 abort() is not reached
./ffmpeg -i vp7digimona_frame32.avi -f null -

--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -506,7 +506,7 @@ static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c)
 int alpha = (int8_t) vp8_rac_get_uint(c, 8);
 int beta  = (int8_t) vp8_rac_get_uint(c, 8);
 int ret;
-
+av_log(0,0, "AB %d %d\n", alpha, beta);
 if (c->end <= c->buffer && c->bits >= 0)
 return AVERROR_INVALIDDATA;
 
@@ -514,7 +514,7 @@ static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c)
 int width  = s->mb_width * 16;
 int height = s->mb_height * 16;
 AVFrame *src, *dst;
-
+abort();
 if (!s->framep[VP56_FRAME_PREVIOUS] ||
 !s->framep[VP56_FRAME_GOLDEN]) {
 av_log(s->avctx, AV_LOG_WARNING, "Discarding interframe without a 
prior keyframe!\n");


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

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri


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 v5] avutil/mips: Avoid instruction exception caused by gssqc1/gslqc1.

2019-08-02 Thread Reimar Döffinger
On Wed, Jul 31, 2019 at 09:30:01AM +0800, Shiyou Yin wrote:
> Ensure the address accesed by gssqc1/gslqc1 are 16-byte aligned.

Pushed, thanks.
___
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] Fixing HW accelerated decoders hanging or throwing error in h263dec

2019-08-02 Thread Timo Rothenpieler

On 02.08.2019 11:18, Stefan Schoenefeld wrote:

Hi all,

Recently we encountered an issue when decoding a h.263 file:

FFmpeg will freeze when decoding h.263 video with NVDEC. Turns out this is not 
directly related to NVDEC but is a problem that shows with several other HW 
decoders like VDPAU, though the exact kind of error is different (either error 
messages or freezing[1]). The root cause is that ff_thread_finish_setup() is 
called twice per frame from ff_h263_decode_frame(). This is not supported by 
ff_thread_finish_setup() and specifically checked for and warned against in the 
functions code. The issue is also specific to hw accelerated decoding only as 
the second call to ff_thread_finish_setup() is only issued when hw acceleration 
is on. The fix is simple: add a check that the first call is only send when hw 
acceleration is off, and the second call only when hw acceleration is on (see 
attached patch). This works fine as far as I was able to test with vdpau and 
nvdec/nvcuvid hw decoding. The patch also adds NVDEC to the hw config list if 
available.

I also noticed a secondary issue when browsing through the code which is that, 
according to documentation, ff_thread_finish_setup() should only be called if 
the codec implements update_thread_context(), which h263dec does not. The patch 
does not address this and I'm not sure any action needs to be taken here at all.

Thanks,
Stefan

[1] This is depending on whether or not the hw decoder sets the  
HWACCEL_CAPS_ASYNC_SAFE flag

 From 0620ee777a8ba98145bb4781e30a77687c97dbf8 Mon Sep 17 00:00:00 2001
From: Stefan Schoenefeld 
Date: Fri, 2 Aug 2019 10:52:22 +0200
Subject: [PATCH] Fixing HW accelerated decoders hanging or throwing error
messages in h263dec

---
libavcodec/h263dec.c | 5 -
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 6f001f6..8ee844e 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -614,7 +614,7 @@ retry:
  if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
  return ret;
-if (!s->divx_packed)
+if (!s->divx_packed && !avctx->hwaccel)
  ff_thread_finish_setup(avctx);


This seems correct to me, but I'd like another pair of eyes to look over it.


  if (avctx->hwaccel) {
@@ -747,6 +747,9 @@ const AVCodecHWConfigInternal *ff_h263_hw_config_list[] = {
#if CONFIG_H263_VAAPI_HWACCEL
  HWACCEL_VAAPI(h263),
#endif
+#if CONFIG_MPEG4_NVDEC_HWACCEL
+HWACCEL_NVDEC(mpeg4),
+#endif


Probably cleaner to split this into its own patch, but otherwise OK.


#if CONFIG_MPEG4_VDPAU_HWACCEL
  HWACCEL_VDPAU(mpeg4),
#endif
--
2.7.4





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

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

Re: [FFmpeg-devel] [PATCH] lavu/tx: add support for double precision FFT and MDCT

2019-08-02 Thread Lynne
Aug 1, 2019, 4:54 PM by d...@lynne.ee:

> Jul 27, 2019, 7:29 PM by d...@lynne.ee:
>
>> Simply moves and templates the actual transforms to support an
>> additional data type.
>> Unlike the float version, which is equal or better than libfftw3f,
>> double precision output is bit identical with libfftw3.
>>
>
> Planning to push attached version soon.
> Just some minor changes (moved the radix permute to tx_priv, added if guards).
>

Pushed.
Still working on the SIMD.

___
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] lavu/tx: don't compile double precision transforms on CONFIG_SMALL

2019-08-02 Thread Lynne
They'll likely only be used in not so small filters, so for embedded users it 
makes sense to not compile them in.

>From bafb404153641a84224d88598659d554cfdf9543 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Fri, 2 Aug 2019 16:58:27 +0100
Subject: [PATCH] lavu/tx: don't compile double precision transforms on
 CONFIG_SMALL

They'll likely only be used in not so small filters, so for embedded users
it makes sense to not compile them in.
---
 libavutil/Makefile | 5 +++--
 libavutil/tx.c | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 57e6e3d7e8..b3f11fc7dc 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -161,8 +161,9 @@ OBJS = adler32.o\
xtea.o   \
tea.o\
tx.o \
-   tx_float.o   \
-   tx_double.o
+   tx_float.o
+
+OBJS-$(!CONFIG_SMALL)   += tx_double.o
 
 OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o
 OBJS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.o
diff --git a/libavutil/tx.c b/libavutil/tx.c
index b8683b416b..2547c9f363 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -16,6 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "tx_priv.h"
 
 /* Calculates the modular multiplicative inverse, not fast, replace */
@@ -123,11 +124,13 @@ av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type,
 if ((err = ff_tx_init_mdct_fft_float(s, tx, type, inv, len, scale, flags)))
 goto fail;
 break;
+#if !CONFIG_SMALL
 case AV_TX_DOUBLE_FFT:
 case AV_TX_DOUBLE_MDCT:
 if ((err = ff_tx_init_mdct_fft_double(s, tx, type, inv, len, scale, flags)))
 goto fail;
 break;
+#endif
 default:
 err = AVERROR(EINVAL);
 goto fail;
-- 
2.23.0.rc0

___
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] Fixes compiler bug - replace vec_lvsl/vec_perm with vec_xl

2019-08-02 Thread ckerchne
A bug exist with the gcc compilers for Power in versions 6.x and 7.x 
(verified with 6.3 and 7.4). It was fixed in version 8.x (verified with 
8.3). I was using a Power 9 ppc64le machine for building and testing.

This is to address ticket #7124.

It appears the compiler is generating the wrong code for little endian 
machines for the vec_lvsl/vec_perm instruction combos in some cases. If 
these instructions are replaced with vec_xl, the problem goes away for 
all versions of the compilers.diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
index c1e2852adb..536545293d 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -305,9 +305,6 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,  \
 vector signed short R1, G1, B1;   \
 vector unsigned char R, G, B; \
   \
-const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;  \
-vector unsigned char align_perm;  \
-  \
 vector signed short lCY   = c->CY;\
 vector signed short lOY   = c->OY;\
 vector signed short lCRV  = c->CRV;   \
@@ -338,26 +335,13 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,  \
 vec_dstst(oute, (0x0202 | (((w * 3 + 32) / 32) << 16)), 1);   \
   \
 for (j = 0; j < w / 16; j++) {\
-y1ivP = (const vector unsigned char *) y1i;   \
-y2ivP = (const vector unsigned char *) y2i;   \
-uivP  = (const vector unsigned char *) ui;\
-vivP  = (const vector unsigned char *) vi;\
-  \
-align_perm = vec_lvsl(0, y1i);\
-y0 = (vector unsigned char)   \
- vec_perm(y1ivP[0], y1ivP[1], align_perm);\
+y0 = vec_xl(0, y1i);  \
   \
-align_perm = vec_lvsl(0, y2i);\
-y1 = (vector unsigned char)   \
- vec_perm(y2ivP[0], y2ivP[1], align_perm);\
+y1 = vec_xl(0, y2i);  \
   \
-align_perm = vec_lvsl(0, ui); \
-u = (vector signed char)  \
-vec_perm(uivP[0], uivP[1], align_perm);   \
+u = (vector signed char) vec_xl(0, ui);   \
   \
-align_perm = vec_lvsl(0, vi); \
-v = (vector signed char)  \
-vec_perm(vivP[0], vivP[1], align_perm);   \
+v = (vector signed char) vec_xl(0, vi);   \
   \
 u = (vector signed char)  \
 vec_sub(u,\
___
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 6/7] avformat/dashenc: add missing padding to the updated extradata

2019-08-02 Thread Andreas Rheinhardt
James Almer:
> On 8/2/2019 11:46 AM, Andreas Rheinhardt wrote:
>> James Almer:
>>> Signed-off-by: James Almer 
>>> ---
>>>  libavformat/dashenc.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>>> index bded260806..50eba370d9 100644
>>> --- a/libavformat/dashenc.c
>>> +++ b/libavformat/dashenc.c
>>> @@ -1476,12 +1476,13 @@ static int update_stream_extradata(AVFormatContext 
>>> *s, OutputStream *os,
>>>  if (!extradata_size)
>>>  return 0;
>>>  
>>> -new_extradata = av_malloc(extradata_size);
>>> +new_extradata = av_malloc(extradata_size + 
>>> AV_INPUT_BUFFER_PADDING_SIZE);
>>>  
>>>  if (!new_extradata)
>>>  return AVERROR(ENOMEM);
>>>  
>>>  memcpy(new_extradata, extradata, extradata_size);
>>> +memset(new_extradata + extradata_size, 0, 
>>> AV_INPUT_BUFFER_PADDING_SIZE);
>>>  
>>>  os->ctx->streams[0]->codecpar->extradata = new_extradata;
>>>  os->ctx->streams[0]->codecpar->extradata_size = extradata_size;
>>>
>> Is there a reason you are not using ff_alloc_extradata?
>>
>> - Andreas
> 
> Not really. I can replace this patch with one implementing
> ff_alloc_extradata().

I have no strong feelings about this. Proceed as you wish.

- 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 6/7] avformat/dashenc: add missing padding to the updated extradata

2019-08-02 Thread James Almer
On 8/2/2019 11:46 AM, Andreas Rheinhardt wrote:
> James Almer:
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/dashenc.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index bded260806..50eba370d9 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -1476,12 +1476,13 @@ static int update_stream_extradata(AVFormatContext 
>> *s, OutputStream *os,
>>  if (!extradata_size)
>>  return 0;
>>  
>> -new_extradata = av_malloc(extradata_size);
>> +new_extradata = av_malloc(extradata_size + 
>> AV_INPUT_BUFFER_PADDING_SIZE);
>>  
>>  if (!new_extradata)
>>  return AVERROR(ENOMEM);
>>  
>>  memcpy(new_extradata, extradata, extradata_size);
>> +memset(new_extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>>  
>>  os->ctx->streams[0]->codecpar->extradata = new_extradata;
>>  os->ctx->streams[0]->codecpar->extradata_size = extradata_size;
>>
> Is there a reason you are not using ff_alloc_extradata?
> 
> - Andreas

Not really. I can replace this patch with one implementing
ff_alloc_extradata().
___
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] avformat/hlsenc: merge mpegts and fmp4 workflow to one workflow

2019-08-02 Thread Ian Klassen
On Fri, Aug 2, 2019 at 5:46 AM Michael Niedermayer 
wrote:

> On Wed, Jul 31, 2019 at 04:07:22PM +0800, Steven Liu wrote:
> > 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(-)
>
> make -j5 ffmpeg && ./ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags
> delete_segments -hls_key_info_file file.keyinfo -t 2 /tmp/file-hlsencry.m3u8
> ...
> Output #0, hls, to '/tmp/file-hlsencry.m3u8':
>   Metadata:
> encoder : Lavf58.30.100
> Stream #0:0: Video: h264 (libx264), yuv444p, 320x240 [SAR 1:1 DAR
> 4:3], q=-1--1, 25 fps, 90k tbn, 25 tbc
> Metadata:
>   encoder : Lavc58.56.100 libx264
> Side data:
>   cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
> [hls @ 0x24a1800] Opening '/tmp/file-hlsencry0.ts' for writingA speed=
>  0x
> *** Error in `./ffmpeg': free(): invalid size: 0x02b4aa50 ***
> Aborted (core dumped)
>
>
> [hls @ 0x25662840] Opening '/tmp/file-hlsencry0.ts' for writing speed=
>  0x
> ==13307== Invalid read of size 8
> ==13307==at 0x6BD2FE: avio_close_dyn_buf (in ffmpeg/ffmpeg_g)
> ==13307==by 0x6F5742: hls_write_trailer (in ffmpeg/ffmpeg_g)
> ==13307==by 0x763E0A: av_write_trailer (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4D390A: transcode (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4B1E1C: main (in ffmpeg/ffmpeg_g)
> ==13307==  Address 0x3dcc6f50 is 8 bytes after a block of size 8 alloc'd
> ==13307==at 0x4C2A6C5: memalign (vg_replace_malloc.c:727)
> ==13307==by 0x4C2A760: posix_memalign (vg_replace_malloc.c:876)
> ==13307==by 0x116963F: av_mallocz (in ffmpeg/ffmpeg_g)
> ==13307==by 0x6BBA37: ffio_open_whitelist (in ffmpeg/ffmpeg_g)
> ==13307==by 0x78B1E9: io_open_default (in ffmpeg/ffmpeg_g)
> ==13307==by 0x6F353D: hls_start (in ffmpeg/ffmpeg_g)
> ==13307==by 0x6F7312: hls_init (in ffmpeg/ffmpeg_g)
> ==13307==by 0x761D12: avformat_init_output (in ffmpeg/ffmpeg_g)
> ==13307==by 0x762434: avformat_write_header (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4C9D58: check_init_output_file (in ffmpeg/ffmpeg_g)
> ==13307==by 0x4CB23D: init_output_stream.constprop.23 (in
> ffmpeg/ffmpeg_g)
> ==13307==by 0x4D079F: reap_filters (in ffmpeg/ffmpeg_g)
> ==13307==
> [hls @ 0x25662840] Opening '/tmp/file-hlsencry.m3u8.tmp' for writing
>
> if you cannot reproduce, tell me and ill rebuild and provide better
> debug info
>
> Thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Its not that you shouldnt use gotos but rather that you should write
> readable code and code with gotos often but not always is less readable
> ___
> 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".


Is this patch to address bug #7975? https://trac.ffmpeg.org/ticket/7975

I tested it on Windows and it still crashes when attempting to write to a
http server that doesn't support persistent connections:

[http @ 029C0EBAD080] URL read error: End of file
[http @ 029C0D410740] Opening 'http://127.0.0.1/stream2.ts' for writing
[http @ 029C0EBAD080] URL read error: Error number -10053 occurred
[http @ 029C0D410740] Opening 'http://127.0.0.1/stream.m3u8' for writing
av_interleaved_write_frame(): Unknown error
___
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 6/7] avformat/dashenc: add missing padding to the updated extradata

2019-08-02 Thread Andreas Rheinhardt
James Almer:
> Signed-off-by: James Almer 
> ---
>  libavformat/dashenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index bded260806..50eba370d9 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1476,12 +1476,13 @@ static int update_stream_extradata(AVFormatContext 
> *s, OutputStream *os,
>  if (!extradata_size)
>  return 0;
>  
> -new_extradata = av_malloc(extradata_size);
> +new_extradata = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
>  
>  if (!new_extradata)
>  return AVERROR(ENOMEM);
>  
>  memcpy(new_extradata, extradata, extradata_size);
> +memset(new_extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>  
>  os->ctx->streams[0]->codecpar->extradata = new_extradata;
>  os->ctx->streams[0]->codecpar->extradata_size = extradata_size;
> 
Is there a reason you are not using ff_alloc_extradata?

- 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 7/7] avformat/dashenc: fix writting the AV1 codec string in mp4 mode

2019-08-02 Thread James Almer
On 7/30/2019 5:19 PM, James Almer wrote:
> From https://aomediacodec.github.io/av1-isobmff/#codecsparam, the parameters
> sample entry 4CC, profile, level, tier, and bitDepth are all mandatory fields.
> All the other fields are optional, mutually inclusive (all or none).
> 
> Fixes ticket #8049
> 
> Signed-off-by: James Almer 
> ---
>  libavformat/dashenc.c | 16 
>  1 file changed, 16 insertions(+)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 50eba370d9..a3d8168110 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -35,6 +35,7 @@
>  #include "libavutil/time.h"
>  #include "libavutil/time_internal.h"
>  
> +#include "av1.h"
>  #include "avc.h"
>  #include "avformat.h"
>  #include "avio_internal.h"
> @@ -389,6 +390,21 @@ static void set_codec_str(AVFormatContext *s, 
> AVCodecParameters *par,
>  av_strlcatf(str, size, ".%02x%02x%02x",
>  extradata[1], extradata[2], extradata[3]);
>  av_free(tmpbuf);
> +} else if (!strcmp(str, "av01")) {
> +AV1SequenceParameters seq;
> +if (!par->extradata_size)
> +return;
> +if (ff_av1_parse_seq_header(, par->extradata, 
> par->extradata_size) < 0)
> +return;
> +
> +av_strlcatf(str, size, ".%01u.%02u%s.%02u",
> +seq.profile, seq.level, seq.tier ? "H" : "M", 
> seq.bitdepth);
> +if (seq.color_description_present_flag)
> +av_strlcatf(str, size, ".%01u.%01u%01u%01u.%02u.%02u.%02u.%01u",
> +seq.monochrome,
> +seq.chroma_subsampling_x, seq.chroma_subsampling_y, 
> seq.chroma_sample_position,
> +seq.color_primaries, seq.transfer_characteristics, 
> seq.matrix_coefficients,
> +seq.color_range);
>  }
>  }

Will push the set soon.
___
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] Issues while encoding a ts file to m3u8

2019-08-02 Thread Ramana Jajula
Hi,

I am trying to encode my ts file m3u8 using my customised ffmpeg of version
4.1. I used below command to do encoding.

ffmpeg -re -threads 8 -i /videos/input.ts -vcodec libx264 -s 320x240 -b:v
512000 -maxrate 512000 -acodec libfdk_aac -b:a 32000 -ac 2 -ar 48000
-force_key_frames 'expr:gte(t,n_forced*3)' -hls_flags single_file
-hls_list_size 0 -hls_time 3 -fsize 400x222 -frames /frames/my_frames/
-index /mpegindex/my_index.idx  -y /encoded/test/output.m3u8

My encoding was bad. The output printed to console is
  libavutil  56. 22.100 / 56. 22.100
  libavcodec 58. 35.100 / 58. 35.100
  libavformat58. 20.100 / 58. 20.100
  libavdevice58.  5.100 / 58.  5.100
  libavfilter 7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale  5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc55.  3.100 / 55.  3.100
/videos/input.ts FPS 25.00 0
Input #0, mpegts, from '/videos/.input.ts':
  Duration: 00:04:05.97, start: 85837.091689, bitrate: 1769 kb/s
  Program 1
Stream #0:0[0x105]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn,
50 tbc
Stream #0:1[0x106]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
stereo, fltp, 128 kb/s
[libx264 @ 0x564a2f7cc480] VBV maxrate specified, but no bufsize, ignored
[libx264 @ 0x564a2f7cc480] using SAR=4/3
[libx264 @ 0x564a2f7cc480] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2
[libx264 @ 0x564a2f7cc480] profile High, level 2.0
[libx264 @ 0x564a2f7cc480] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options:
cabac=1 ref=3 debloc
k=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1
me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11
fast_pskip=1 chroma_qp_offset
=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
b_adapt=1 b_bias=0 direct=1 wei
ghtb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40
intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=512 ratetol=1.0
qcomp=0.60 qpmin=0 qpmax=69 qpst
ep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 0x564a2f7ccc40] Using AVStream.codec to pass codec parameters to
muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
[hls @ 0x564a2f7ccc40] Opening '/encodedt/input.ts' for writing
Output #0, hls, to '/encoded/output.m3u8':
  Metadata:
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264), yuv420p, 320x240 [SAR 4:3 DAR
16:9], q=-1--1, 512 kb/s, 25 fps, 90k tbn, 25 tbc
Metadata:
  encoder : Lavc58.35.100 libx264
Side data:
  cpb: bitrate max/min/avg: 512000/0/512000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (libfdk_aac), 48000 Hz, stereo, s16, 32 kb/s
Metadata:
  encoder : Lavc58.35.100 libfdk_aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (ac3 (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
frame=   34 fps=0.1 q=0.0 size=N/A time=00:05:02.11 bitrate=N/A dup=29
drop=0 speed=0.567x
[hls @ 0x564a2f7ccc40] Packets poorly interleaved, failed to avoid negative
timestamp -3360 in stream 0.0.567x
Try -max_interleave_delta 0 as a possible workaround.

Since the encoding speed is too slow I had to cancel the encoding process.
I killed it,

What is the reason for this slow encoding process?

PS: My input file is of 1 hour duration.

Thanks.
ReplyForward
___
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] libavcodec: add timer bitstream filter

2019-08-02 Thread Andreas Håkon
Hi Paul,


‐‐‐ Original Message ‐‐‐
On Monday, 29 de July de 2019 21:19, Paul B Mahol  wrote:

> Documentation for bsf does document single option, thus is incomplete.

Done: https://patchwork.ffmpeg.org/patch/14195/

Regards.
A.H.

---

___
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] libavcodec: add timer bitstream filter [v2]

2019-08-02 Thread Andreas Håkon
Hi,

This new version completes the documentation.
Supersedes: https://patchwork.ffmpeg.org/patch/13743/

Regards.
A.H.

---From 9d115c9c049c5a1141ea83174794bf773359ebd0 Mon Sep 17 00:00:00 2001
From: Andreas Hakon 
Date: Fri, 2 Aug 2019 13:55:48 +0100
Subject: [PATCH] libavcodec: add timer bitstream filter [v2]

This implements the new timer bitstream filter.

Signed-off-by: Andreas Hakon 
---
 doc/bitstream_filters.texi |   10 +
 libavcodec/Makefile|1 +
 libavcodec/bitstream_filters.c |1 +
 libavcodec/timer_bsf.c |   86 
 4 files changed, 98 insertions(+)
 create mode 100644 libavcodec/timer_bsf.c

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index 50a1679..2d92eeb 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -644,6 +644,16 @@ codec) with metadata headers.
 
 See also the @ref{mov2textsub} filter.
 
+@section timer
+
+Apply an offset to the PTS/DTS timestamps.
+
+@table @option
+@item offset
+The offset value to apply to the PTS/DTS timestamps.
+
+@end table
+
 @section trace_headers
 
 Log trace output containing all syntax elements in the coded stream
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fb..2c2f018 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1096,6 +1096,7 @@ OBJS-$(CONFIG_NULL_BSF)   += null_bsf.o
 OBJS-$(CONFIG_PRORES_METADATA_BSF)+= prores_metadata_bsf.o
 OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF)   += remove_extradata_bsf.o
 OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o
+OBJS-$(CONFIG_TIMER_BSF)  += timer_bsf.o
 OBJS-$(CONFIG_TRACE_HEADERS_BSF)  += trace_headers_bsf.o
 OBJS-$(CONFIG_TRUEHD_CORE_BSF)+= truehd_core_bsf.o mlp_parse.o 
mlp.o
 OBJS-$(CONFIG_VP9_METADATA_BSF)   += vp9_metadata_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 4630039..be6af05 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -51,6 +51,7 @@ extern const AVBitStreamFilter ff_null_bsf;
 extern const AVBitStreamFilter ff_prores_metadata_bsf;
 extern const AVBitStreamFilter ff_remove_extradata_bsf;
 extern const AVBitStreamFilter ff_text2movsub_bsf;
+extern const AVBitStreamFilter ff_timer_bsf;
 extern const AVBitStreamFilter ff_trace_headers_bsf;
 extern const AVBitStreamFilter ff_truehd_core_bsf;
 extern const AVBitStreamFilter ff_vp9_metadata_bsf;
diff --git a/libavcodec/timer_bsf.c b/libavcodec/timer_bsf.c
new file mode 100644
index 000..3f1c7f6
--- /dev/null
+++ b/libavcodec/timer_bsf.c
@@ -0,0 +1,86 @@
+/*
+ * 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
+ */
+
+/**
+ * @file
+ * This bitstream filter applies an offset to the PTS/DTS timestamps.
+ *
+ */
+
+// TODO: Control time wrapping
+// TODO: Instead of using absolute timestamp offsets, use frame numbers
+
+#include "avcodec.h"
+#include "bsf.h"
+
+#include "libavutil/opt.h"
+
+typedef struct TimerContext {
+const AVClass *class;
+int offset;
+int first_debug_done;
+} TimerContext;
+
+static int timer_filter(AVBSFContext *ctx, AVPacket *pkt)
+{
+int ret;
+TimerContext *s = ctx->priv_data;
+int64_t opts,odts;
+
+ret = ff_bsf_get_packet_ref(ctx, pkt);
+if (ret < 0)
+return ret;
+
+opts = pkt->pts;
+if (pkt->pts != AV_NOPTS_VALUE) {
+pkt->pts += s->offset;
+}
+odts = pkt->dts;
+if (pkt->dts != AV_NOPTS_VALUE) {
+pkt->dts += s->offset;
+}
+
+if (!s->first_debug_done) {
+av_log(ctx, AV_LOG_DEBUG, "Updated PTS/DTS (%"PRId64"/%"PRId64" : 
%"PRId64"/%"PRId64") with offset:%d\n",
+pkt->pts, pkt->dts, opts, odts, s->offset );
+}
+s->first_debug_done = 1;
+
+return 0;
+}
+
+#define OFFSET(x) offsetof(TimerContext, x)
+#define FLAGS 
(AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_SUBTITLE_PARAM|AV_OPT_FLAG_BSF_PARAM)
+static const AVOption options[] = {
+{ "offset", NULL, OFFSET(offset), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, 
INT_MAX, FLAGS },
+{ NULL },
+};
+
+static const AVClass timer_class = {
+.class_name = "timer",
+.item_name  = av_default_item_name,
+.option = options,
+

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/vp8: do vp7_fade_frame() later

2019-08-02 Thread Peter Ross
On Thu, Aug 01, 2019 at 11:44:39PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (100sec -> 5sec)
> Fixes: 
> 15073/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5649257362620416
> 
> Untested as none of the vp7 samples i found executes this codepath

see attached. its all i can find :(

> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vp8.c | 19 +++
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index ba79e5fdab..efc62aabaf 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -501,15 +501,10 @@ static void fade(uint8_t *dst, ptrdiff_t dst_linesize,
>  }
>  }
>  
> -static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c)
> +static int vp7_fade_frame(VP8Context *s, int alpha, int beta)
>  {
> -int alpha = (int8_t) vp8_rac_get_uint(c, 8);
> -int beta  = (int8_t) vp8_rac_get_uint(c, 8);
>  int ret;
>  
> -if (c->end <= c->buffer && c->bits >= 0)
> -return AVERROR_INVALIDDATA;
> -
>  if (!s->keyframe && (alpha || beta)) {
>  int width  = s->mb_width * 16;
>  int height = s->mb_height * 16;
> @@ -549,6 +544,8 @@ static int vp7_decode_frame_header(VP8Context *s, const 
> uint8_t *buf, int buf_si
>  int part1_size, hscale, vscale, i, j, ret;
>  int width  = s->avctx->width;
>  int height = s->avctx->height;
> +int alpha = 0;
> +int beta  = 0;
>  
>  if (buf_size < 4) {
>  return AVERROR_INVALIDDATA;
> @@ -665,8 +662,8 @@ static int vp7_decode_frame_header(VP8Context *s, const 
> uint8_t *buf, int buf_si
>  return AVERROR_INVALIDDATA;
>  /* E. Fading information for previous frame */
>  if (s->fade_present && vp8_rac_get(c)) {
> -if ((ret = vp7_fade_frame(s ,c)) < 0)
> -return ret;
> +alpha = (int8_t) vp8_rac_get_uint(c, 8);
> +beta  = (int8_t) vp8_rac_get_uint(c, 8);
>  }
>  
>  /* F. Loop filter type */
> @@ -696,6 +693,12 @@ static int vp7_decode_frame_header(VP8Context *s, const 
> uint8_t *buf, int buf_si
>  vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE);
>  }
>  
> +if (c->end <= c->buffer && c->bits >= 0)
> +return AVERROR_INVALIDDATA;
> +
> +if ((ret = vp7_fade_frame(s, alpha, beta)) < 0)
> +return ret;
> +
>  return 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".
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


vp7digimona_frame32.avi
Description: MS Video


vp7digimona_frame58.avi
Description: MS Video


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/msrle: remove unused items

2019-08-02 Thread Michael Niedermayer
On Thu, Aug 01, 2019 at 04:03:58PM +0200, Paul B Mahol wrote:
> Hi,
> 
> patch attached.

>  msrle.c |5 -
>  1 file changed, 5 deletions(-)
> 3d9a86788e29d2bf633b1a0350278f91df1fa4df  
> 0001-avcodec-msrle-remove-unused-items.patch
> From ff971f9f88ed4617d630ee10c6699a1fffdd956b Mon Sep 17 00:00:00 2001
> From: Paul B Mahol 
> Date: Thu, 1 Aug 2019 16:02:18 +0200
> Subject: [PATCH] avcodec/msrle: remove unused items

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- 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 v2] avformat/hlsenc: merge mpegts and fmp4 workflow to one workflow

2019-08-02 Thread Michael Niedermayer
On Wed, Jul 31, 2019 at 04:07:22PM +0800, Steven Liu wrote:
> 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(-)

make -j5 ffmpeg && ./ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags 
delete_segments -hls_key_info_file file.keyinfo -t 2 /tmp/file-hlsencry.m3u8
...
Output #0, hls, to '/tmp/file-hlsencry.m3u8':
  Metadata:
encoder : Lavf58.30.100
Stream #0:0: Video: h264 (libx264), yuv444p, 320x240 [SAR 1:1 DAR 4:3], 
q=-1--1, 25 fps, 90k tbn, 25 tbc
Metadata:
  encoder : Lavc58.56.100 libx264
Side data:
  cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[hls @ 0x24a1800] Opening '/tmp/file-hlsencry0.ts' for writingA speed=   0x
*** Error in `./ffmpeg': free(): invalid size: 0x02b4aa50 ***
Aborted (core dumped)


[hls @ 0x25662840] Opening '/tmp/file-hlsencry0.ts' for writing speed=   0x
==13307== Invalid read of size 8
==13307==at 0x6BD2FE: avio_close_dyn_buf (in ffmpeg/ffmpeg_g)
==13307==by 0x6F5742: hls_write_trailer (in ffmpeg/ffmpeg_g)
==13307==by 0x763E0A: av_write_trailer (in ffmpeg/ffmpeg_g)
==13307==by 0x4D390A: transcode (in ffmpeg/ffmpeg_g)
==13307==by 0x4B1E1C: main (in ffmpeg/ffmpeg_g)
==13307==  Address 0x3dcc6f50 is 8 bytes after a block of size 8 alloc'd
==13307==at 0x4C2A6C5: memalign (vg_replace_malloc.c:727)
==13307==by 0x4C2A760: posix_memalign (vg_replace_malloc.c:876)
==13307==by 0x116963F: av_mallocz (in ffmpeg/ffmpeg_g)
==13307==by 0x6BBA37: ffio_open_whitelist (in ffmpeg/ffmpeg_g)
==13307==by 0x78B1E9: io_open_default (in ffmpeg/ffmpeg_g)
==13307==by 0x6F353D: hls_start (in ffmpeg/ffmpeg_g)
==13307==by 0x6F7312: hls_init (in ffmpeg/ffmpeg_g)
==13307==by 0x761D12: avformat_init_output (in ffmpeg/ffmpeg_g)
==13307==by 0x762434: avformat_write_header (in ffmpeg/ffmpeg_g)
==13307==by 0x4C9D58: check_init_output_file (in ffmpeg/ffmpeg_g)
==13307==by 0x4CB23D: init_output_stream.constprop.23 (in ffmpeg/ffmpeg_g)
==13307==by 0x4D079F: reap_filters (in ffmpeg/ffmpeg_g)
==13307== 
[hls @ 0x25662840] Opening '/tmp/file-hlsencry.m3u8.tmp' for writing

if you cannot reproduce, tell me and ill rebuild and provide better
debug info

Thanks

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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] lavf/vf_deinterlace_vaapi: flush queued frame in field mode

2019-08-02 Thread Linjie Fu
Add deint_vaapi_request_frame for deinterlace_vaapi, send NULL frame
to flush the queued frame.

Fix the frame drop issue in field mode:

ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -c:v
h264 -i ./input.h264 -vf 'format=nv12|vaapi,hwupload,
deinterlace_vaapi=mode=bob:rate=field,hwdownload,format=nv12'
-pix_fmt yuv420p -f rawvideo -vsync passthrough -y dump.yuv

Signed-off-by: Linjie Fu 
---
 libavfilter/vf_deinterlace_vaapi.c | 46 --
 1 file changed, 39 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_deinterlace_vaapi.c 
b/libavfilter/vf_deinterlace_vaapi.c
index 72d0349..c811327 100644
--- a/libavfilter/vf_deinterlace_vaapi.c
+++ b/libavfilter/vf_deinterlace_vaapi.c
@@ -48,6 +48,9 @@ typedef struct DeintVAAPIContext {
 intqueue_count;
 AVFrame   *frame_queue[MAX_REFERENCES];
 intextra_delay_for_timestamps;
+
+inteof;
+intprev_pts;
 } DeintVAAPIContext;
 
 static const char *deint_vaapi_mode_name(int mode)
@@ -190,11 +193,16 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, 
AVFrame *input_frame)
 void *filter_params_addr = NULL;
 int err, i, field, current_frame_index;
 
-av_log(avctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u (%"PRId64").\n",
-   av_get_pix_fmt_name(input_frame->format),
-   input_frame->width, input_frame->height, input_frame->pts);
+// NULL frame is used to flush the queue in field mode
+if (input_frame)
+av_log(avctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u (%"PRId64").\n",
+av_get_pix_fmt_name(input_frame->format),
+input_frame->width, input_frame->height, input_frame->pts);
+else if (ctx->field_rate == 1) {
+return 0;
+}
 
-if (ctx->queue_count < ctx->queue_depth) {
+if (input_frame && ctx->queue_count < ctx->queue_depth) {
 ctx->frame_queue[ctx->queue_count++] = input_frame;
 if (ctx->queue_count < ctx->queue_depth) {
 // Need more reference surfaces before we can continue.
@@ -291,6 +299,8 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, 
AVFrame *input_frame)
 if (ctx->field_rate == 2) {
 if (field == 0)
 output_frame->pts = 2 * input_frame->pts;
+else if (ctx->eof)
+output_frame->pts = 3 * input_frame->pts - ctx->prev_pts;
 else
 output_frame->pts = input_frame->pts +
 ctx->frame_queue[current_frame_index + 1]->pts;
@@ -306,6 +316,8 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, 
AVFrame *input_frame)
 break;
 }
 
+ctx->prev_pts = input_frame->pts;
+
 return err;
 
 fail:
@@ -315,6 +327,25 @@ fail:
 return err;
 }
 
+static int deint_vaapi_request_frame(AVFilterLink *link)
+{
+AVFilterContext *avctx = link->src;
+DeintVAAPIContext *ctx   = avctx->priv;
+int ret;
+
+if (ctx->eof)
+return AVERROR_EOF;
+
+ret = ff_request_frame(link->src->inputs[0]);
+if (ret == AVERROR_EOF) {
+ctx->eof = 1;
+deint_vaapi_filter_frame(link->src->inputs[0], NULL);
+} else if (ret < 0)
+return ret;
+
+return 0;
+}
+
 static av_cold int deint_vaapi_init(AVFilterContext *avctx)
 {
 VAAPIVPPContext *vpp_ctx = avctx->priv;
@@ -376,9 +407,10 @@ static const AVFilterPad deint_vaapi_inputs[] = {
 
 static const AVFilterPad deint_vaapi_outputs[] = {
 {
-.name = "default",
-.type = AVMEDIA_TYPE_VIDEO,
-.config_props = _vaapi_config_output,
+.name   = "default",
+.type   = AVMEDIA_TYPE_VIDEO,
+.request_frame  = _vaapi_request_frame,
+.config_props   = _vaapi_config_output,
 },
 { NULL }
 };
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH] Fixing HW accelerated decoders hanging or throwing error in h263dec

2019-08-02 Thread Stefan Schoenefeld
Hi all,

Recently we encountered an issue when decoding a h.263 file:

FFmpeg will freeze when decoding h.263 video with NVDEC. Turns out this is not 
directly related to NVDEC but is a problem that shows with several other HW 
decoders like VDPAU, though the exact kind of error is different (either error 
messages or freezing[1]). The root cause is that ff_thread_finish_setup() is 
called twice per frame from ff_h263_decode_frame(). This is not supported by 
ff_thread_finish_setup() and specifically checked for and warned against in the 
functions code. The issue is also specific to hw accelerated decoding only as 
the second call to ff_thread_finish_setup() is only issued when hw acceleration 
is on. The fix is simple: add a check that the first call is only send when hw 
acceleration is off, and the second call only when hw acceleration is on (see 
attached patch). This works fine as far as I was able to test with vdpau and 
nvdec/nvcuvid hw decoding. The patch also adds NVDEC to the hw config list if 
available.

I also noticed a secondary issue when browsing through the code which is that, 
according to documentation, ff_thread_finish_setup() should only be called if 
the codec implements update_thread_context(), which h263dec does not. The patch 
does not address this and I'm not sure any action needs to be taken here at all.

Thanks,
Stefan

[1] This is depending on whether or not the hw decoder sets the  
HWACCEL_CAPS_ASYNC_SAFE flag

>From 0620ee777a8ba98145bb4781e30a77687c97dbf8 Mon Sep 17 00:00:00 2001
From: Stefan Schoenefeld 
Date: Fri, 2 Aug 2019 10:52:22 +0200
Subject: [PATCH] Fixing HW accelerated decoders hanging or throwing error
messages in h263dec

---
libavcodec/h263dec.c | 5 -
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 6f001f6..8ee844e 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -614,7 +614,7 @@ retry:
 if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
 return ret;
-if (!s->divx_packed)
+if (!s->divx_packed && !avctx->hwaccel)
 ff_thread_finish_setup(avctx);
 if (avctx->hwaccel) {
@@ -747,6 +747,9 @@ const AVCodecHWConfigInternal *ff_h263_hw_config_list[] = {
#if CONFIG_H263_VAAPI_HWACCEL
 HWACCEL_VAAPI(h263),
#endif
+#if CONFIG_MPEG4_NVDEC_HWACCEL
+HWACCEL_NVDEC(mpeg4),
+#endif
#if CONFIG_MPEG4_VDPAU_HWACCEL
 HWACCEL_VDPAU(mpeg4),
#endif
--
2.7.4


NVIDIA GmbH, Wuerselen, Germany, Amtsgericht Aachen, HRB 8361
Managing Director: Karen Theresa Burns

---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---


0001-Fixing-HW-accelerated-decoders-hanging-or-throwing-e.patch
Description: 0001-Fixing-HW-accelerated-decoders-hanging-or-throwing-e.patch
___
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]Support for Frame Doubling/ Tripling in FFMPEG's HEVC Decoder by parsing the picture_struct SEI value (Support for http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.h

2019-08-02 Thread Michael Niedermayer
On Thu, Aug 01, 2019 at 12:46:21PM +, Praveen Kumar wrote:
> Hi,
> 
> This patch has the implementation for frame duplication (doubling/ tripling) 
> in FFmpeg's HEVC decoder based on the picture_structre SEI value (7 for 
> doubling and 8 for tripling) set while encoding.
> This addresses the requirement mentioned in the thread 
> http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html
> 
> Thanks & Regards,
> Praveen

>  hevc_parser.c |   29 +
>  hevc_sei.c|6 ++
>  hevc_sei.h|   15 +++
>  hevcdec.c |8 
>  4 files changed, 58 insertions(+)
> 1acaad49a85cde86f32440d05b764ca2304887cd  
> Support-for-Frame-Doubling-Tripling-in-FFMPEG-HEVC-Decoder.patch
> From 6b602399c68ce7062d8c2aefee9b3814be3f3b0e Mon Sep 17 00:00:00 2001
> From: Praveen Karadugattu 
> Date: Thu, 1 Aug 2019 17:47:36 +0530
> Subject: [PATCH] Support for Frame Doubling/ Tripling in FFMPEG's HEVC Decoder
>  by parsing the picture_struct SEI value (Support for
>  http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html)

Breaks hevc fate tests

TESThevc-conformance-WP_MAIN10_B_Toshiba_3
--- ./tests/ref/fate/hevc-conformance-WP_MAIN10_B_Toshiba_3 2019-07-31 
21:32:01.464064534 +0200
+++ tests/data/fate/hevc-conformance-WP_MAIN10_B_Toshiba_3  2019-08-02 
10:55:39.707488117 +0200
@@ -4,258 +4,131 @@
 #dimensions 0: 416x240
 #sar 0: 0/1
 0,  0,  0,1,   299520, 0x6ecba46b
-0,  1,  1,1,   299520, 0x54e6ef0a
-0,  2,  2,1,   299520, 0x7a4d46c5
-0,  3,  3,1,   299520, 0xccd57f4e
-0,  4,  4,1,   299520, 0xbe0cb48d
-0,  5,  5,1,   299520, 0x10e7b49f
-0,  6,  6,1,   299520, 0x81aa72e2
-0,  7,  7,1,   299520, 0x5bf7b51f
-0,  8,  8,1,   299520, 0xfcedee4a
-0,  9,  9,1,   299520, 0x586c99b6
-0, 10, 10,1,   299520, 0x414ca13c
-0, 11, 11,1,   299520, 0x3f0162f2
-0, 12, 12,1,   299520, 0x4d450c05
-0, 13, 13,1,   299520, 0x0a58bd84
-0, 14, 14,1,   299520, 0x26e8394d
-0, 15, 15,1,   299520, 0xfd78121b
-0, 16, 16,1,   299520, 0x6afeaf44
-0, 17, 17,1,   299520, 0x3e9a9270
-0, 18, 18,1,   299520, 0x58b889ca
-0, 19, 19,1,   299520, 0x0245ba62
-0, 20, 20,1,   299520, 0xddecc5ab
-0, 21, 21,1,   299520, 0x32cf3cd9
-0, 22, 22,1,   299520, 0x5c0a0440
-0, 23, 23,1,   299520, 0x9d3e2fee
-0, 24, 24,1,   299520, 0x2894c708
-0, 25, 25,1,   299520, 0x25be67d5
-0, 26, 26,1,   299520, 0xe3ece9d6
-0, 27, 27,1,   299520, 0xcc98e38b
-0, 28, 28,1,   299520, 0xc448c794
-0, 29, 29,1,   299520, 0xb4f75575
-0, 30, 30,1,   299520, 0xac74a437
-0, 31, 31,1,   299520, 0x09c7f2e2
-0, 32, 32,1,   299520, 0xbfaed8ab
-0, 33, 33,1,   299520, 0xb077d700
-0, 34, 34,1,   299520, 0x6efa0545
-0, 35, 35,1,   299520, 0xb8c1802d
-0, 36, 36,1,   299520, 0x794774f8
-0, 37, 37,1,   299520, 0x1098f4ff
-0, 38, 38,1,   299520, 0x80ab8bfc
-0, 39, 39,1,   299520, 0xc324c3bc
-0, 40, 40,1,   299520, 0x1eee77cd
-0, 41, 41,1,   299520, 0x7147e72e
-0, 42, 42,1,   299520, 0x1a34883c
-0, 43, 43,1,   299520, 0x74e93e31
-0, 44, 44,1,   299520, 0x89410382
-0, 45, 45,1,   299520, 0xfcce0ce1
-0, 46, 46,1,   299520, 0x07bb33c6
-0, 47, 47,1,   299520, 0xc1ee7318
-0, 48, 48,1,   299520, 0xd1c4bd2d
-0, 49, 49,1,   299520, 0xa670cfae
-0, 50, 50,1,   299520, 0x718de79b
-0, 51, 51,1,   299520, 0x85e40b78
-0, 52, 52,1,   299520, 0x15362e72
-0, 53, 53,1,   299520, 0xc6e523fa
-0, 54, 54,1,   299520, 0x3e536edd
-0, 55, 55,1,   299520, 0x9312996e
-0, 56, 56,1,   299520, 0x9456d53c
-0, 57, 57,1,   299520, 0x7bc01398
-0, 58, 58,1,   299520, 0x5a40bcb4
-0, 59, 59,1,   299520, 0xcfe126ce
-0, 60, 60,1,   

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

2019-08-02 Thread Andreas Håkon
Hi Marton,

‐‐‐ Original Message ‐‐‐
On Friday, 2 de August de 2019 10:09, Marton Balint  wrote:

> > > > > Maybe I miss something but as far as I see only this block needs to 
> > > > > be in
> > > > > the loop, the rest is not. So you can actually write this:
> > > >
> > > > False! All checks require to be completed inside the loop.
> > > > Please, note that one stream (aka pid) can be assigned to multiple 
> > > > programs.
> > > > So we need to iterate over all programs and services.
> > >
> > > My problem is that the body of the inner loop, after the if (program)
> > > condition is executed exactly once. Therefore it does not belong to a
> > > loop.
> >
> > Why you say that the condition (after the "if (program)") is executed 
> > exactly once?
> > That statement is false! The inner loop (yes it's a loop) is executed:
> > A) Just one time, only if no program is defined (that's the reason of the 
> > last
> > "if (!program) break)" plus the "program = program ? ... : NULL" and the
> > "while(program)" ).
>
> Agreed.
>
> > B) Just one time, if only one service is found for this stream.
> > C) Multiple times, if the stream is inside multiple services.
>
> I agree that if the outer (program) loop fires more than once if there are
> multiple programs, I meant that for each outer loop iteration the body of
> the inner loop is only executed once.

Sorry, I disagree:

- The outer (program) loop (the "do-while" block) iterates over every program
  associated to the stream.
- And the inner (service) loop iterates over every SERVICE associated to the 
stream.

And take note that your target are SERVICES, so you really need to process ALL
services, and that's the reason to not break when the first service it's found.


> > > To be frank, the whole ts_st->service is bogus, because a stream can
> > > belong to multiple services, so on what grounds do we select one?
> >
> > To be frank too, I'm not responsible for the previous code.
> > I think the original author created the code with the assumption that there 
> > was
> > only one service. And after that, the support for multiple services was 
> > added.
> > And now I have discovered this error, and I have fixed it with minimal 
> > modifications.
> > Where's the problem, honestly?
>
> It is natural that existing code needs to be cleaned up before adding a
> new feature.

Yes. And my "added new feature" is the "interleaving mux":
https://patchwork.ffmpeg.org/patch/13745/

So, this patch is only a small part that solves a BUG (a serious bug).
IMHO I'm doing the best I can.


> > > I'd suggest to remove service from MpegTSWriteStream and move
> > > pcr_packet_count and pcr_packet_period from MpegTSService to
> > > MpegTSWriteStream. Of course this should be yet another, separate patch, a
> > > prerequisite to this one.
> >
> > Sorry, too much work for me!
>
> I will post a patch which does this, please test it and rebase your work
> upon it.

OK, I'll wait for your patch then.


> Thanks,
> Marton

You're welcome!
Regards.
A.H.

---

___
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] fate: add a case for ticket #3229

2019-08-02 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Tuesday, July 30, 2019 9:53 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH V2] fate: add a case for ticket #3229
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Michael Niedermayer
> > Sent: Tuesday, July 30, 2019 4:28 AM
> > To: FFmpeg development discussions and patches
> > 
> > Subject: Re: [FFmpeg-devel] [PATCH V2] fate: add a case for ticket
> > #3229
> >
> > On Mon, Jul 29, 2019 at 06:20:39PM +0800, Zhong Li wrote:
> > > Signed-off-by: Zhong Li 
> > > ---
> > > https://patchwork.ffmpeg.org/patch/13725/ introduces a regression
> > > but
> > not found by fate, so add it.
> > > Test clip produced by:
> > > ffmpeg -i tickets/3229/bad.avi -vframes 6 -c:v copy
> > > /fate-suite/mjpeg/mjpeg_field_order.avi
> > >
> > >  tests/fate/video.mak|  3 +++
> > >  tests/ref/fate/mjpeg-ticket3229 | 11 +++
> > >  2 files changed, 14 insertions(+)
> > >  create mode 100644 tests/ref/fate/mjpeg-ticket3229
> >
> > LGTM & passed on mingw32/64 arm/mips qemu and linux32
> >
> > thx
> 
> Thanks for review and testing.
> May I search your help to produce/upload the clip to fate server and then
> apply this patch?

Ping?
___
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] DSD improvements

2019-08-02 Thread Carl Eugen Hoyos



> Am 02.08.2019 um 09:00 schrieb Paul B Mahol :
> 
> Hi,
> 
> patches attached.
> 
> DST one dropped as it needs different approach.

I will report test results on a variety of hardware next Thursday.

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

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

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

2019-08-02 Thread Marton Balint



On Fri, 2 Aug 2019, Andreas Håkon wrote:


Hi Marton,



> > > +
> > > +  /* 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 (ts->services[j]->program == program)
> > > +  service = ts->services[j];
> > > +  else
> > > +  continue;
> > > +  }
> > > +
> > > +  ts_st->service = service;
> > > +
> > > +  /* check for PMT pid conflicts */
> > > +  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;
> > > +  }
> > > +
> > > +  /* 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;
> > > +  service->pcr_st  = st;
> > > +  }
> > > +
> > > +  /* store this stream as a candidate PCR if the service 
doesn't have any */
> > > +  if (service->pcr_pid == 0x1fff &&
> > > +  !service->pcr_st) {
> > > +  service->pcr_st  = st;
> > > +  }
> > > +
> > > +  /* exit when just one single service */
> > > +  if (!program)
> > > +  break;
> > > +  }
> > > +  program = program ? av_find_program_from_stream(s, 
program, i) : NULL;
> > > +  } while (program);
> > >
> > >
> >
> > Maybe I miss something but as far as I see only this block needs to be in
> > the loop, the rest is not. So you can actually write this:
>
> False! All checks require to be completed inside the loop.
> Please, note that one stream (aka pid) can be assigned to multiple programs.
> So we need to iterate over all programs and services.

My problem is that the body of the inner loop, after the if (program)
condition is executed exactly once. Therefore it does not belong to a
loop.



Why you say that the condition (after the "if (program)") is executed exactly 
once?
That statement is false! The inner **loop** (yes it's a loop) is executed:

A) Just one time, only if no program is defined (that's the reason of the last
  "if (!program) break)" plus the "program = program ? ... : NULL" and the
  "while(program)" ).


Agreed.


B) Just one time, if only one service is found for this stream.
C) Multiple times, if the stream is inside multiple services.


I agree that if the outer (program) loop fires more than once if there are 
multiple programs, I meant that for each outer loop iteration the body of 
the inner loop is only executed once.




So, because of (B) and (C) it's required to execute a loop. In fact, we iterate
over all programs, except in one edge case: when no programs are defined. And 
only
in this case the inner loop is executed once deterministically.



> > /* program service checks */
> > program = av_find_program_from_stream(s, NULL, i);
> > do {
> > 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;
> > /* check for PMT pid conflicts */
> > ...
> > This way you also ensure that ts_st->service is always set for every
> > stream which is kind of how the old code worked, right?
>
> Not really. The "service" can be assigned on two ways: or using the iteration
> over all programs, or in the creation of a new service with the call
> to the "mpegts_add_service()" function when no programs are defined.

To be frank, the whole ts_st->service is bogus, because a stream can
belong to multiple services, so on what grounds do we select one?


To be frank too, I'm not responsible for the previous code.
I think the original author created the code with the assumption that there was
only one service. And after that, the support for multiple services was added.
And now I have discovered this error, and I have fixed it with minimal 
modifications.
Where's the problem, honestly?


It is natural that existing code needs to be cleaned up before adding a 
new feature.





I'd suggest to remove service from MpegTSWriteStream and move
pcr_packet_count and pcr_packet_period from MpegTSService to
MpegTSWriteStream. Of course this should be yet another, separate patch, a

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

2019-08-02 Thread Andreas Håkon
Hi Andriy,


‐‐‐ Original Message ‐‐‐
On Thursday, 1 de August de 2019 16:15, Andriy Gelman  
wrote:

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

Marton recommends eliminating the unnecessary initialization.


> > >
> > > This may be easier to digest if you separate the cases when
> > > s->nb_programs == 0 and s->nb_programs > 0. Maybe something like this 
> > > could
> > > work:
> >
> > Well, the code works, right?
> > So let me to comment some things previous to discuss your suggestion:
> >
> > 1.  I prefer to leave the code close to the original one. If someone needs 
> > to do
> > more changes, it's preferable to do small changes. Don't you think so?
> >
> > 2.  The difference between "s->nb_programs == 0" and "s->nb_programs > 0" 
> > is because
> > the old code. From my point of view, the special case when 
> > "s->nb_programs == 0"
> > is a little sloppy. However, I need to consider it, so for this reason 
> > the code
> > handles it.
> >
>
> Yes, I believe the code works.

Thank you!

> But, readability is also very important. Think about someone who is not 
> familiar
> with the code. It's tough to see straightaway how the two cases 
> s->nb_programs == 0 and
> and s->nb_programs > 0 are handled differently. Also, I believe it's easier 
> for bugs to be
> appear if someone modifies this code.

I think so too!
But, the cases are (in reverse order):

A) One stream in multiple services.
B) One stream in one service.
C) No programs, so just one service.

Because (A) and (B) we need to iterate over all services. Futhermore, for each 
stream we
need to search for a program associated to it. But, an extreme case still 
remains: (C);
when no program is defined. And only for this special case can the code be 
somewhat confusing.
I will try to add some comments.


> I think Marton or Michael should have the final say.

Sure! And the comments from Marton are nice.


> > > /*update service when no programs defined. use default service */
> > > if (s->nb_programs == 0) {
> > >
> > > ret = update_service_and_set_pcr(s, st, service);
> > > if (ret < 0)
> > > goto fail:
> > >
> > >
> > > }
> > > /*find program for i-th stream */
> > > program = av_find_program_from_stream(s, NULL, i);
> > > while (s->nb_programs > 0 && program) {
> > > /*find the service that this program belongs to */
> > > for (j = 0; j < ts->nb_services; j++) {
> > >
> > > if (ts->services[j]->program == program) {
> > >
> > > service = ts->services[j];
> > >
> > > break;
> > > }
> > > }
> > >
> >
> > No, no! The loop requires to complete it for all services!
> > Every service requires a PCR, and the PCR can be inside a
> > shared stream. So if we break for the first service, then
> > other services will not be processed.
> > Please, see that the code is inside a loop and uses a continue
> > when the program doesn't match.
>
> The break refers to the "for" loop and not the "while" loop.
> You'll find the next service in the next iteration of the while loop.

Sorry?
In the "next" iteration of the while loop the "j" will return to start at 0,
so you don't iterate over ALL services in where this stream lives. The "j"
iterator requires to go over all services, and execute the inner block for
all cases. That's the core of this patch to solve the current bug!


> >
> > As commented before IMHO the code is more clear if we leave the service
> > checks here and not in a new function. When others update the code will
> > see that "all" checks requires to be completed here.
>
> I suppose the checks could be outside the function.

OK. If you read the entire source file after applying the patch, you can see
that several checks have been made for the stream. I make some rearrangements
to separate PID number checks from SERVICE checks. So instead of a separated
function called from the outher loop of the function "mpegts_init()" I prefer
this approach of inline code.


> > > +   for (i = 0; i < ts->nb_services; i++) {
> > > +  service = ts->services[i];
> > > +
> > > +  if (!service->pcr_st) {
> > > +  av_log(s, AV_LOG_ERROR, "no PCR selected for the service 
> > > %i\\n", service->sid);
> > > +  ret = AVERROR(EINVAL);
> > > +  goto fail_at_end;
> > >
> > > fail_at_end is not deallocating any memory.
> > > Just return AVERROR(EINVAL) instead of goto would be fine.
> >
> > Well, in the future perhaps some other change will require to do more 
> > processing
> > at end. So, I prefer to exit using the same behaviour as the rest of the 
> > code.
> > It's good coding practice, so I won't change it.
>
> I did a grep for goto in ffmpeg. I cannot see any cases where there is a 
> branch to
> simply return the error. We should probably be consistent with the rest of the
> code.

OK.


> > > +   if 

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

2019-08-02 Thread Andreas Håkon
Hi Marton,


‐‐‐ Original Message ‐‐‐
On Thursday, 1 de August de 2019 23:09, Marton Balint  wrote:

> On Thu, 1 Aug 2019, Andreas Håkon wrote:
>
> > Hi Marton,
> > First of all, a new version [v4] is posted here:
> > https://patchwork.ffmpeg.org/patch/14121/
>
> I replied to the wrong (v3) mail, but I commented the v4 version.

OK, no problem!


> > However, I'll comment on your suggestions, as they are reasonable.
> > ‐‐‐ Original Message ‐‐‐
> > On Wednesday, 31 de July de 2019 23:58, Marton Balint c...@passwd.hu wrote:
> >
> > > > +   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.
> >
> > I prefer to initilize any variable. Futhermore, Andriy has commented to
> > do it inside the mpegts_add_service function. I prefer his approach.
>
> You allocate the MpegTSService struct with av_mallocz therefore pcr_st it
> is already initialized to NULL, re-initializing it to NULL is pointless.

OK. I'll remove it. I think is a good practice to initializa all vars, but
if you prefer it that way, I don't criticize it.


> > > > +
> > > > +  /* 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 (ts->services[j]->program == program)
> > > > +  service = ts->services[j];
> > > > +  else
> > > > +  continue;
> > > > +  }
> > > > +
> > > > +  ts_st->service = service;
> > > > +
> > > > +  /* check for PMT pid conflicts */
> > > > +  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;
> > > > +  }
> > > > +
> > > > +  /* 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;
> > > > +  service->pcr_st  = st;
> > > > +  }
> > > > +
> > > > +  /* store this stream as a candidate PCR if the 
> > > > service doesn't have any */
> > > > +  if (service->pcr_pid == 0x1fff &&
> > > > +  !service->pcr_st) {
> > > > +  service->pcr_st  = st;
> > > > +  }
> > > > +
> > > > +  /* exit when just one single service */
> > > > +  if (!program)
> > > > +  break;
> > > > +  }
> > > > +  program = program ? av_find_program_from_stream(s, 
> > > > program, i) : NULL;
> > > > +  } while (program);
> > > >
> > > >
> > >
> > > Maybe I miss something but as far as I see only this block needs to be in
> > > the loop, the rest is not. So you can actually write this:
> >
> > False! All checks require to be completed inside the loop.
> > Please, note that one stream (aka pid) can be assigned to multiple programs.
> > So we need to iterate over all programs and services.
>
> My problem is that the body of the inner loop, after the if (program)
> condition is executed exactly once. Therefore it does not belong to a
> loop.
>

Why you say that the condition (after the "if (program)") is executed exactly 
once?
That statement is false! The inner **loop** (yes it's a loop) is executed:

A) Just one time, only if no program is defined (that's the reason of the last
   "if (!program) break)" plus the "program = program ? ... : NULL" and the
   "while(program)" ).
B) Just one time, if only one service is found for this stream.
C) Multiple times, if the stream is inside multiple services.

So, because of (B) and (C) it's required to execute a loop. In fact, we iterate
over all programs, except in one edge case: when no programs are defined. And 
only
in this case the inner loop is executed once deterministically.


> > > /* program service checks */
> > > program = av_find_program_from_stream(s, NULL, i);
> > > do {
> > > if (program) {
> > > for (j = 0; j < ts->nb_services; j++) {
> > >  if (ts->services[j]->program == program) {
> > >  service = ts->services[j];
> > >  break;
> > >  }
> > >  }
> > > 

[FFmpeg-devel] [PATCH] DSD improvements

2019-08-02 Thread Paul B Mahol
Hi,

patches attached.

DST one dropped as it needs different approach.


0001-avformat-dsfdec-set-packet-pts-duration-pos-correctl.patch
Description: Binary data


0002-avcodec-dsddec-add-slice-threading-support.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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