Re: [FFmpeg-devel] FFmpeg 4.2

2019-08-03 Thread Michael Niedermayer
On Sun, Jul 21, 2019 at 07:11:40PM +0200, Michael Niedermayer wrote:
> On Mon, May 20, 2019 at 08:39:45PM +0200, Michael Niedermayer wrote:
> > Hi
> > 
> > Its quite some time since 4.1 so its probably getting time to branch
> > 4.2.
> > 
> > If there are any bugs you want fixed in 4.2 its probably a good idea to
> > fix them soon.
> > 
> > Are there any suggestions for a name ?
> > If not ill pick something from unused past suggestions.
> > 
> > If there are no objections i will likely make that release in the next weeks
> 
> 4.2 branch made
> i intend to make the 4.2 release from HEAD of release/4.2 in the next 1-2 
> weeks
> please backport any relevant bugfixes to it.

Status update: There are a few remaining crashes / security issues which i think
we should fix and include before the release. Iam working on that currently.

When thats done depends on 
1. any delays (bikesheds, distractions, headaches, good weather that makes me 
ignore
   this and go for a walk or maybe going for a walk occasionally actually helps 
   my efficiency who knows, ...)
2. influx of more security reports (fuzzer and any human reports), there where
   several new reports in the last 2 weeks which fall in the "I think that 
should
   be fixed before the release" category
3. murphies law and anything else unexpected

Thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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

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

[FFmpeg-devel] [PATCH] avformat/assenc: Don't truncate lines to 4095 characters

2019-08-03 Thread Tellow Krinkle
Fixes #6390

Sample file for new test: 
https://gist.githubusercontent.com/tellowkrinkle/d6a6e328f892dbbacc000ad9c3890644/raw/4f68e56b1f0fab594aae040723722af4f5161a02/longline.ass

Signed-off-by: Tellow Krinkle 
---
 libavformat/assenc.c | 4 +++-
 tests/fate/subtitles.mak | 4 
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/assenc.c b/libavformat/assenc.c
index d50f18feb1..9b44b16597 100644
--- a/libavformat/assenc.c
+++ b/libavformat/assenc.c
@@ -95,7 +95,9 @@ static void purge_dialogues(AVFormatContext *s, int force)
ass->expected_readorder, dialogue->readorder);
 ass->expected_readorder = dialogue->readorder;
 }
-avio_printf(s->pb, "Dialogue: %s\r\n", dialogue->line);
+avio_write(s->pb, "Dialogue: ", 10);
+avio_write(s->pb, dialogue->line, strlen(dialogue->line));
+avio_write(s->pb, "\r\n", 2);
 if (dialogue == ass->last_added_dialogue)
 ass->last_added_dialogue = next;
 av_freep(&dialogue->line);
diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak
index 0042902161..a4e0fc7432 100644
--- a/tests/fate/subtitles.mak
+++ b/tests/fate/subtitles.mak
@@ -13,6 +13,10 @@ fate-sub-cc-scte20: CMD = fmtstdout ass -f lavfi -i 
"movie=$(TARGET_SAMPLES)/sub
 FATE_SUBTITLES_ASS-$(call DEMDEC, ASS, ASS) += fate-sub-ass-to-ass-transcode
 fate-sub-ass-to-ass-transcode: CMD = fmtstdout ass -i 
$(TARGET_SAMPLES)/sub/1ededcbd7b.ass
 
+FATE_SUBTITLES_ASS-$(call DEMDEC, ASS, ASS) += fate-sub-ass-long-line
+fate-sub-ass-long-line: CMD = fmtstdout ass -i 
$(TARGET_SAMPLES)/sub/longline.ass
+fate-sub-ass-long-line: REF = $(TARGET_SAMPLES)/sub/longline.ass
+
 FATE_SUBTITLES_ASS-$(CONFIG_ASS_DEMUXER) += fate-sub-ssa-to-ass-remux
 fate-sub-ssa-to-ass-remux: CMD = fmtstdout ass -i 
$(TARGET_SAMPLES)/sub/a9-misc.ssa -c copy
 
-- 
2.20.1 (Apple Git-117)

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

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

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/atrac9dec: Check grad_range[1] more tightly

2019-08-03 Thread Lynne
Aug 4, 2019, 12:16 AM by mich...@niedermayer.cc:

> Alternatively the array could be made bigger but the extra values
> would not be read without other changes.
>
> Fixes: Out of array access
> Fixes: 
> 15658/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5738260074070016
>
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/atrac9dec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
> index 491e889788..e503e36dbf 100644
> --- a/libavcodec/atrac9dec.c
> +++ b/libavcodec/atrac9dec.c
> @@ -121,7 +121,7 @@ static inline int parse_gradient(ATRAC9Context *s, 
> ATRAC9BlockData *b,
>  }
>  b->grad_boundary = get_bits(gb, 4);
>  
> -if (grad_range[0] >= grad_range[1] || grad_range[1] > 47)
> +if (grad_range[0] >= grad_range[1] || grad_range[1] > 31)
>  return AVERROR_INVALIDDATA; 
>

Looked into it, lgtm.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/atrac9dec: Replace impossible conditions by assert

2019-08-03 Thread Lynne
Aug 4, 2019, 12:16 AM by mich...@niedermayer.cc:

> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/atrac9dec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
> index 2e23ea44e8..491e889788 100644
> --- a/libavcodec/atrac9dec.c
> +++ b/libavcodec/atrac9dec.c
> @@ -124,8 +124,7 @@ static inline int parse_gradient(ATRAC9Context *s, 
> ATRAC9BlockData *b,
>  if (grad_range[0] >= grad_range[1] || grad_range[1] > 47)
>  return AVERROR_INVALIDDATA;
>  
> -if (grad_value[0] > 31 || grad_value[1] > 31)
> -return AVERROR_INVALIDDATA;
> +av_assert0(grad_value[0] <= 31 && grad_value[1] <= 31);
>

Its impossible so just remove it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 2/3] avcodec/atrac9dec: Replace impossible conditions by assert

2019-08-03 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/atrac9dec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index 2e23ea44e8..491e889788 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -124,8 +124,7 @@ static inline int parse_gradient(ATRAC9Context *s, 
ATRAC9BlockData *b,
 if (grad_range[0] >= grad_range[1] || grad_range[1] > 47)
 return AVERROR_INVALIDDATA;
 
-if (grad_value[0] > 31 || grad_value[1] > 31)
-return AVERROR_INVALIDDATA;
+av_assert0(grad_value[0] <= 31 && grad_value[1] <= 31);
 
 if (b->grad_boundary > b->q_unit_cnt)
 return AVERROR_INVALIDDATA;
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 3/3] avcodec/atrac9dec: Check grad_range[1] more tightly

2019-08-03 Thread Michael Niedermayer
Alternatively the array could be made bigger but the extra values
would not be read without other changes.

Fixes: Out of array access
Fixes: 
15658/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5738260074070016

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

diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c
index 491e889788..e503e36dbf 100644
--- a/libavcodec/atrac9dec.c
+++ b/libavcodec/atrac9dec.c
@@ -121,7 +121,7 @@ static inline int parse_gradient(ATRAC9Context *s, 
ATRAC9BlockData *b,
 }
 b->grad_boundary = get_bits(gb, 4);
 
-if (grad_range[0] >= grad_range[1] || grad_range[1] > 47)
+if (grad_range[0] >= grad_range[1] || grad_range[1] > 31)
 return AVERROR_INVALIDDATA;
 
 av_assert0(grad_value[0] <= 31 && grad_value[1] <= 31);
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 1/3] avcodec/bink: Add many end of input checks

2019-08-03 Thread Michael Niedermayer
Fixes: Timeout (83sec -> 15sec)
Fixes: 
15595/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-5689153263501312

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

diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index d18c0ceae4..5bb3955f93 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -241,16 +241,19 @@ static void merge(GetBitContext *gb, uint8_t *dst, 
uint8_t *src, int size)
  * @param gb   context for reading bits
  * @param tree pointer for storing tree data
  */
-static void read_tree(GetBitContext *gb, Tree *tree)
+static int read_tree(GetBitContext *gb, Tree *tree)
 {
 uint8_t tmp1[16] = { 0 }, tmp2[16], *in = tmp1, *out = tmp2;
 int i, t, len;
 
+if (get_bits_left(gb) < 4)
+return AVERROR_INVALIDDATA;
+
 tree->vlc_num = get_bits(gb, 4);
 if (!tree->vlc_num) {
 for (i = 0; i < 16; i++)
 tree->syms[i] = i;
-return;
+return 0;
 }
 if (get_bits1(gb)) {
 len = get_bits(gb, 3);
@@ -273,6 +276,7 @@ static void read_tree(GetBitContext *gb, Tree *tree)
 }
 memcpy(tree->syms, in, 16);
 }
+return 0;
 }
 
 /**
@@ -282,19 +286,27 @@ static void read_tree(GetBitContext *gb, Tree *tree)
  * @param c   decoder context
  * @param bundle_num  number of the bundle to initialize
  */
-static void read_bundle(GetBitContext *gb, BinkContext *c, int bundle_num)
+static int read_bundle(GetBitContext *gb, BinkContext *c, int bundle_num)
 {
 int i;
 
 if (bundle_num == BINK_SRC_COLORS) {
-for (i = 0; i < 16; i++)
-read_tree(gb, &c->col_high[i]);
+for (i = 0; i < 16; i++) {
+int ret = read_tree(gb, &c->col_high[i]);
+if (ret < 0)
+return ret;
+}
 c->col_lastval = 0;
 }
-if (bundle_num != BINK_SRC_INTRA_DC && bundle_num != BINK_SRC_INTER_DC)
-read_tree(gb, &c->bundle[bundle_num].tree);
+if (bundle_num != BINK_SRC_INTRA_DC && bundle_num != BINK_SRC_INTER_DC) {
+int ret = read_tree(gb, &c->bundle[bundle_num].tree);
+if (ret < 0)
+return ret;
+}
 c->bundle[bundle_num].cur_dec =
 c->bundle[bundle_num].cur_ptr = c->bundle[bundle_num].data;
+
+return 0;
 }
 
 /**
@@ -324,6 +336,8 @@ static int read_runs(AVCodecContext *avctx, GetBitContext 
*gb, Bundle *b)
 av_log(avctx, AV_LOG_ERROR, "Run value went out of bounds\n");
 return AVERROR_INVALIDDATA;
 }
+if (get_bits_left(gb) < 1)
+return AVERROR_INVALIDDATA;
 if (get_bits1(gb)) {
 v = get_bits(gb, 4);
 memset(b->cur_dec, v, t);
@@ -346,6 +360,8 @@ static int read_motion_values(AVCodecContext *avctx, 
GetBitContext *gb, Bundle *
 av_log(avctx, AV_LOG_ERROR, "Too many motion values\n");
 return AVERROR_INVALIDDATA;
 }
+if (get_bits_left(gb) < 1)
+return AVERROR_INVALIDDATA;
 if (get_bits1(gb)) {
 v = get_bits(gb, 4);
 if (v) {
@@ -389,6 +405,8 @@ static int read_block_types(AVCodecContext *avctx, 
GetBitContext *gb, Bundle *b)
 av_log(avctx, AV_LOG_ERROR, "Too many block type values\n");
 return AVERROR_INVALIDDATA;
 }
+if (get_bits_left(gb) < 1)
+return AVERROR_INVALIDDATA;
 if (get_bits1(gb)) {
 v = get_bits(gb, 4);
 memset(b->cur_dec, v, t);
@@ -424,6 +442,8 @@ static int read_patterns(AVCodecContext *avctx, 
GetBitContext *gb, Bundle *b)
 return AVERROR_INVALIDDATA;
 }
 while (b->cur_dec < dec_end) {
+if (get_bits_left(gb) < 2)
+return AVERROR_INVALIDDATA;
 v  = GET_HUFF(gb, b->tree);
 v |= GET_HUFF(gb, b->tree) << 4;
 *b->cur_dec++ = v;
@@ -443,6 +463,8 @@ static int read_colors(GetBitContext *gb, Bundle *b, 
BinkContext *c)
 av_log(c->avctx, AV_LOG_ERROR, "Too many color values\n");
 return AVERROR_INVALIDDATA;
 }
+if (get_bits_left(gb) < 1)
+return AVERROR_INVALIDDATA;
 if (get_bits1(gb)) {
 c->col_lastval = GET_HUFF(gb, c->col_high[c->col_lastval]);
 v = GET_HUFF(gb, b->tree);
@@ -456,6 +478,8 @@ static int read_colors(GetBitContext *gb, Bundle *b, 
BinkContext *c)
 b->cur_dec += t;
 } else {
 while (b->cur_dec < dec_end) {
+if (get_bits_left(gb) < 2)
+return AVERROR_INVALIDDATA;
 c->col_lastval = GET_HUFF(gb, c->col_high[c->col_lastval]);
 v = GET_HUFF(gb, b->tree);
 v = (c->col_lastval << 4) | v;
@@ -481,6 +505,8 @@ static int read_dcs(AVCodecContext *avctx, GetBitContext 
*gb, Bundle *b,
 int16_t *dst_end = (int16_t*)b->data_end;
 
 CHECK_READ_VAL(gb, b, len);
+if (get_bits_left(gb) < start_bits - has_sign)
+

Re: [FFmpeg-devel] [PATCH] avformat/mpegenc - reject unsupported audio streams

2019-08-03 Thread Carl Eugen Hoyos


> Am 19.07.2019 um 12:44 schrieb Gyan :
> 
> 
> 
>> On 17-07-2019 02:23 PM, Carl Eugen Hoyos wrote:
>> 
>> 
>>> Am 08.07.2019 um 14:05 schrieb Gyan :
>>> 
>>> 
>>> 
 On 25-04-2019 01:48 PM, Gyan wrote:
 
 
> On 25-04-2019 01:23 PM, Ali KIZIL wrote:
> 
> There are also Dolby Codecs (ac3 & eac3). Will it also throw error for
> these codecs ?
 AC3   is  supported before and after this patch.
 EAC3 is unsupported before and after this patch.
 
 But it's sent to the same decoder, so support could be added. I'll check.
>>> Attached patch allows muxing EAC3 in MPEG-PS.  Stock ffmpeg can demux and 
>>> decode such streams fine.
>> Which descriptor is used for eac3?
>> Please do not commit just because decoding works with FFmpeg, at least try 
>> to find some specification.
> 
> The PS muxer appears to use System A and this is what the ATSC A/52 (2012) 
> standard says,
> 
> "For System A, this section extends the use ofthe AC-3 Registration 
> Descriptor defined in Section A3 in combination with the E-AC-3 stream_type 
> value defined below."
> 
> and
> 
> "E-AC-3 bit streams shall be identified with a stream_typevalue of 0x87 when 
> transmitted as PES streams conforming to ATSC-published standards."
> 
> Note that the stream_type value of AC-3 is 0x81 yet our id sequence starts 
> from 0x80.  This patch uses the same descriptor series as AC-3, however if I 
> switch to 0x87, only one such stream may be muxed as 0x88 was assigned (by 
> you) to DTS. Also, our demuxer sets the codec_id to DTS for 0x88 to 0x8f.
> 
> Both stock ffmpeg and VlC 4.0 nightly play files using the current patch. 
> Mediainfo also identifies the codec correctly.
> 
> Comments?

Did you test with WMP or QT?

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/encode: only allow undersized audio frames if they are the last

2019-08-03 Thread Marton Balint



On Sat, 3 Aug 2019, Lynne wrote:


Aug 3, 2019, 9:40 PM by c...@passwd.hu:


Otherwise the user might get a silence padded frame in the beginning or in the
middle of the encoding.

Some other bug uncovered this:

./ffmpeg -loglevel verbose -y -f data -i /dev/zero \
-filter_complex "nullsrc=s=60x60:d=10[v0];sine=d=10[a]" \
-map '[v0]' -c:v:0 rawvideo \
-map '[a]'  -c:a:0 mp2 \
-f mpegts out.ts

Signed-off-by: Marton Balint 
---
 libavcodec/encode.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index d12c42526b..d81b32b983 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -174,8 +174,14 @@ int attribute_align_arg 
avcodec_encode_audio2(AVCodecContext *avctx,
 goto end;
 }
 } else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {
-if (frame->nb_samples < avctx->frame_size &&
-!avctx->internal->last_audio_frame) {
+/* if we already got an undersized frame, that must have been the 
last */
+if (avctx->internal->last_audio_frame) {
+av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected for a 
non-last frame (avcodec_encode_audio2)\n", avctx->frame_size);
+ret = AVERROR(EINVAL);
+goto end;
+}
+
+if (frame->nb_samples < avctx->frame_size) {
 ret = pad_last_frame(avctx, &padded_frame, frame);
 if (ret < 0)
 goto end;



You haven't fixed the bug, you've just made it an error. You have to fix the 
encoder instead.
The check might be useful if its made a warning instead though.


The command line was also failing before the patch with an invalid frame 
size error at the end of the stream. So ffmpeg.c / libavfilter not 
providing fixed frame sizes is a different bug to the one this patch 
supposed to fix.


This fix disallows padding a frame with silence in the middle of the 
encoding if the user provides an undersized frame. libavcodec should 
reject such encoding attempts and not corrupt the output with silence.


Regards,
Marton
___
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/encode: only allow undersized audio frames if they are the last

2019-08-03 Thread Lynne
Aug 3, 2019, 9:40 PM by c...@passwd.hu:

> Otherwise the user might get a silence padded frame in the beginning or in the
> middle of the encoding.
>
> Some other bug uncovered this:
>
> ./ffmpeg -loglevel verbose -y -f data -i /dev/zero \
> -filter_complex "nullsrc=s=60x60:d=10[v0];sine=d=10[a]" \
> -map '[v0]' -c:v:0 rawvideo \
> -map '[a]'  -c:a:0 mp2 \
> -f mpegts out.ts
>
> Signed-off-by: Marton Balint 
> ---
>  libavcodec/encode.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/encode.c b/libavcodec/encode.c
> index d12c42526b..d81b32b983 100644
> --- a/libavcodec/encode.c
> +++ b/libavcodec/encode.c
> @@ -174,8 +174,14 @@ int attribute_align_arg 
> avcodec_encode_audio2(AVCodecContext *avctx,
>  goto end;
>  }
>  } else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) 
> {
> -if (frame->nb_samples < avctx->frame_size &&
> -!avctx->internal->last_audio_frame) {
> +/* if we already got an undersized frame, that must have been 
> the last */
> +if (avctx->internal->last_audio_frame) {
> +av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not 
> respected for a non-last frame (avcodec_encode_audio2)\n", avctx->frame_size);
> +ret = AVERROR(EINVAL);
> +goto end;
> +}
> +
> +if (frame->nb_samples < avctx->frame_size) {
>  ret = pad_last_frame(avctx, &padded_frame, frame);
>  if (ret < 0)
>  goto end;
>

You haven't fixed the bug, you've just made it an error. You have to fix the 
encoder instead.
The check might be useful if its made a warning instead though.

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

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

[FFmpeg-devel] [PATCH] avcodec/encode: only allow undersized audio frames if they are the last

2019-08-03 Thread Marton Balint
Otherwise the user might get a silence padded frame in the beginning or in the
middle of the encoding.

Some other bug uncovered this:

./ffmpeg -loglevel verbose -y -f data -i /dev/zero \
-filter_complex "nullsrc=s=60x60:d=10[v0];sine=d=10[a]" \
-map '[v0]' -c:v:0 rawvideo \
-map '[a]'  -c:a:0 mp2 \
-f mpegts out.ts

Signed-off-by: Marton Balint 
---
 libavcodec/encode.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index d12c42526b..d81b32b983 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -174,8 +174,14 @@ int attribute_align_arg 
avcodec_encode_audio2(AVCodecContext *avctx,
 goto end;
 }
 } else if (!(avctx->codec->capabilities & 
AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {
-if (frame->nb_samples < avctx->frame_size &&
-!avctx->internal->last_audio_frame) {
+/* if we already got an undersized frame, that must have been the 
last */
+if (avctx->internal->last_audio_frame) {
+av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected 
for a non-last frame (avcodec_encode_audio2)\n", avctx->frame_size);
+ret = AVERROR(EINVAL);
+goto end;
+}
+
+if (frame->nb_samples < avctx->frame_size) {
 ret = pad_last_frame(avctx, &padded_frame, frame);
 if (ret < 0)
 goto end;
-- 
2.16.4

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

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

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

2019-08-03 Thread Michael Niedermayer
On Thu, Aug 01, 2019 at 04:48:32PM -0700, Juan De León wrote:
> Fixed
> 
> design doc: 
> https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing
> 
> Signed-off-by: Juan De León 
> ---
>  libavutil/Makefile  |   2 +
>  libavutil/frame.h   |   6 ++
>  libavutil/quantization_params.c |  42 +
>  libavutil/quantization_params.h | 101 
>  4 files changed, 151 insertions(+)
>  create mode 100644 libavutil/quantization_params.c
>  create mode 100644 libavutil/quantization_params.h
[...]

> +/**
> + * Data structure for extracting Quantization Parameters, codec independent
> + */
> +typedef struct AVQuantizationParams {
> +/**
> + * x and y coordinates of the block in pixels
> + */
> +int x, y;
> +/**
> + * width and height of the block in pixels
> + * set to 0 for the last block in the array
> + */
> +int w, h;

> +/**
> + * qp array, indexed by type according to
> + * the enum corresponding to the codec
> + */
> +int qp_type[AV_QP_ARR_SIZE_AV1];

What happens if a future codec needs more than AV1 ?
i think this would not be extendible without breaking ABI

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


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

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

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

2019-08-03 Thread Michael Niedermayer
On Mon, Jul 29, 2019 at 11:12:34AM -0700, Juan De León wrote:
> Here is the second patch, I sent the first one twice accidentaly. 
> First patch is libavutil, this patch is libavcodec.
> 
> Signed-off-by: Juan De León 
> ---
>  libavcodec/avcodec.h   |  1 +
>  libavcodec/h264dec.c   | 44 ++
>  libavcodec/options_table.h |  1 +
>  3 files changed, 46 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index d234271c5b..9e3185720a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2671,6 +2671,7 @@ typedef struct AVCodecContext {
>  #endif
>  #define FF_DEBUG_BUFFERS 0x8000
>  #define FF_DEBUG_THREADS 0x0001
> +#define FF_DEBUG_EXTRACTQP   0x0002
>  #define FF_DEBUG_GREEN_MD0x0080
>  #define FF_DEBUG_NOMC0x0100
>  
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index 8d1bd16a8e..52ad12e55d 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -33,6 +33,7 @@
>  #include "libavutil/opt.h"
>  #include "libavutil/stereo3d.h"
>  #include "libavutil/timer.h"
> +#include "libavutil/quantization_params.h"
>  #include "internal.h"
>  #include "bytestream.h"
>  #include "cabac.h"
> @@ -922,6 +923,49 @@ static int finalize_frame(H264Context *h, AVFrame *dst, 
> H264Picture *out, int *g
>  }
>  }
>  
> +if (h->avctx->debug & FF_DEBUG_EXTRACTQP) {
> +int mb_height = h->height / 16;
> +int mb_width = h->width / 16;

has this been tested with files which have dimensions not a multiple of 16 ?


> +int mb_xy = mb_width * mb_height;
> +
> +int buf_size = sizeof(AVQuantizationParamsArray) +
> +   mb_xy * sizeof(AVQuantizationParams);
> +AVBufferRef *buffer = av_buffer_alloc(buf_size);
> +if (!buffer) {
> +return AVERROR(ENOMEM);
> +}
> +
> +AVQuantizationParamsArray *params = (AVQuantizationParamsArray 
> *)buffer->data;
> +params->nb_blocks = mb_xy;
> +params->codec_id = h->avctx->codec_id;
> +// offset memory for qp_arr in same buffer
> +params->qp_arr = (AVQuantizationParams*) (params + 1);
> +
> +// loop allocate qp
> +int qp_index = 0;
> +for (int mb_y = 0; mb_y < mb_height; mb_y++) {
> +for (int mb_x = 0; mb_x < mb_width; mb_x++) {
> +int qs_index = mb_x + mb_y * h->mb_stride;
> +AVQuantizationParams *qp_block = &(params->qp_arr[qp_index]);
> +
> +qp_block->x = mb_x * 16;
> +qp_block->y = mb_y * 16;
> +qp_block->w = qp_block->h = 16;
> +qp_block->type[QP_H264] = out->qscale_table[qs_index];
> +
> +qp_index++;
> +}
> +}
> +

> +AVFrameSideData *sd;
> +sd = av_frame_new_side_data_from_buf(dst,
> + 
> AV_FRAME_DATA_QUANTIZATION_PARAMS,
> + buffer);
> +if (!sd) {
> +return AVERROR(ENOMEM);

buffer leaks here


[...]

thx

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Elect your leaders based on what they did after the last election, not
based on what they say before an election.



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

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

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

2019-08-03 Thread Michael Niedermayer
On Thu, Aug 01, 2019 at 04:48:32PM -0700, Juan De León wrote:
> Fixed

That would end in the commit message which is probably unintended


> 
> design doc: 
> https://docs.google.com/document/d/1WClt3EqhjwdGXhEw386O0wfn3IBQ1Ib-_5emVM1gbnA/edit?usp=sharing
> 
> Signed-off-by: Juan De León 
> ---
>  libavutil/Makefile  |   2 +
>  libavutil/frame.h   |   6 ++
>  libavutil/quantization_params.c |  42 +
>  libavutil/quantization_params.h | 101 
>  4 files changed, 151 insertions(+)
>  create mode 100644 libavutil/quantization_params.c
>  create mode 100644 libavutil/quantization_params.h
> 
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 8a7a44e4b5..be1a9c3a9c 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -60,6 +60,7 @@ HEADERS = adler32.h 
> \
>pixdesc.h \
>pixelutils.h  \
>pixfmt.h  \
> +  quantization_params.h \
>random_seed.h \
>rc4.h \
>rational.h\
> @@ -140,6 +141,7 @@ OBJS = adler32.o  
>   \
> parseutils.o \
> pixdesc.o\
> pixelutils.o \
> +   quantization_params.o\
> random_seed.o\
> rational.o   \
> reverse.o\
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 5d3231e7bb..b64fd9c02c 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -179,6 +179,12 @@ enum AVFrameSideDataType {
>   * array element is implied by AVFrameSideData.size / 
> AVRegionOfInterest.self_size.
>   */
>  AV_FRAME_DATA_REGIONS_OF_INTEREST,
> +/**
> + * To extract quantization parameters from supported decoders.
> + * The data is stored as AVQuantizationParamsArray type, described in
> + * libavuitl/quantization_params.h
> + */
> +AV_FRAME_DATA_QUANTIZATION_PARAMS,
>  };
>  
>  enum AVActiveFormatDescription {
> diff --git a/libavutil/quantization_params.c b/libavutil/quantization_params.c
> new file mode 100644
> index 00..152be71ba7
> --- /dev/null
> +++ b/libavutil/quantization_params.c
> @@ -0,0 +1,42 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +#include 
> +
> +#include "libavutil/quantization_params.h"
> +

> +static const char* const QP_NAMES_H264[] = {"qp", "qpcb", "qpcr"};
> +
> +static const char* const QP_NAMES_VP9[] = {"qyac", "qydc", "quvdc", "quvac",
> +   "qiyac", "qiydc", "qiuvdc", 
> "qiuvac"};
> +
> +static const char* const QP_NAMES_AV1[] = {"qyac", "qydc", "qudc", "quac", 
> "qvdc", "qvac",
> +  "qiyac", "qiydc", "qiudc", "qiuac", 
> "qivdc", "qivac"};
> +

The meaning of the chars in the strings should maybe be described
So generic code could interpret a new codecs qp values
though for such generic interpretation more would be needed like which direction
quality improves, if its linear or log scale, ...
so maybe this is just out of scope of this initial implementation


> +const char* av_get_qp_type_string(enum AVExtractQPSupportedCodecs codec_id, 
> int index)
> +{
> +switch (codec_id) {
> +case AV_EXTRACT_QP_CODEC_ID_H264:
> +return index < AV_QP_ARR_SIZE_H264 ? QP_NAMES_H264[index] :NULL;
> +case AV_EXTRACT_QP_CODEC_ID_VP9:
> +return index < AV_QP_ARR_SIZE_VP9  ? QP_NAMES_VP9[index]  :NULL;
> +case AV_EXTRACT_QP_CODEC_ID_AV1

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

2019-08-03 Thread Andriy Gelman
On Sat, 03. Aug 10:19, 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
> 
> Fixes ticket #8039.
> 
> v2: a video is stream is preferred if there are no programs, just like before
> the patch.

Thanks. 
I looked at the other patches and they seem fine. 

Andriy
___
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] [RFC] samples.ffmpeg.org

2019-08-03 Thread Michael Niedermayer
Hi all

It seems we do not have a list of people volunteering to do uploads to
samples. And no place to send such requests to except here, where they
sometimes get ignored.

Also i do NOT volunteer to do these uploads. I think i never did volunteer
but if i did i withdraw that now. I think my time is better spend doing
other things for FFmpeg.
It does seem some people think iam the one to talk to to do these upoads. 
See: "0802 10:50 Li, Zhong   (2,2K) Re: [FFmpeg-devel] [PATCH V2] fate: add 
a case for ticket #3229"

Iam not the right one to ask also i dont know where to send these requests
to as noone else officially volunteered AFAIK. So i dont really know where to
point people asking to ... I suggested to make an entry
in MAINTAINERs previously but that went without replies
See: "0312 14:15 To FFmpeg devel (1,5K) [FFmpeg-devel] [RFC] fate-samples entry 
in MAINTAINERS"

What i can do is give some volunteer who wants to do this work, write access
to upload new samples. But IIRC someone suggested that existing people with 
access should do it ...

So i dont know but this issue seems to be still unsolved ...

Thanks

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


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 5/6] avcodec/hnm4video: Forward errors of decode_interframe_v4()

2019-08-03 Thread Michael Niedermayer
On Sat, Aug 03, 2019 at 04:09:27PM +0200, Tomas Härdin wrote:
> lör 2019-08-03 klockan 01:49 +0200 skrev 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)
> >  {
> > [...]
> > @@ -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;
> 
> Looks OK

will apply

thanks

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

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- 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 4/6] avcodec/hnm4video: Optimize postprocess_current_frame()

2019-08-03 Thread Michael Niedermayer
On Sat, Aug 03, 2019 at 04:07:22PM +0200, Tomas Härdin wrote:
> lör 2019-08-03 klockan 01:49 +0200 skrev Michael Niedermayer:
> > -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;
> 
> Looks OK. Maybe telling the compiler that src and dst don't alias would
> be worthwhile?

i can add restrict keywords if you want:
?

diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c
index 68d0baef6d..1c2501afab 100644
--- a/libavcodec/hnm4video.c
+++ b/libavcodec/hnm4video.c
@@ -121,8 +121,8 @@ static void postprocess_current_frame(AVCodecContext *avctx)
 int width = hnm->width;
 
 for (y = 0; y < hnm->height; y++) {
-uint8_t *dst = hnm->processed + y * width;
-const uint8_t *src = hnm->current;
+uint8_t * restrict dst = hnm->processed + y * width;
+const uint8_t * restrict src = hnm->current;
 src_y = y - (y % 2);
 src += src_y * width + (y % 2);
 for (x = 0; x < width; x++) {


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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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

2019-08-03 Thread James Almer
On 8/2/2019 11:13 AM, James Almer wrote:
> 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(&seq, 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.

Pushed with the suggested changes.

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] avformat/mpegenc - reject unsupported audio streams

2019-08-03 Thread Gyan



On 19-07-2019 04:14 PM, Gyan wrote:



On 17-07-2019 02:23 PM, Carl Eugen Hoyos wrote:




Am 08.07.2019 um 14:05 schrieb Gyan :




On 25-04-2019 01:48 PM, Gyan wrote:



On 25-04-2019 01:23 PM, Ali KIZIL wrote:

There are also Dolby Codecs (ac3 & eac3). Will it also throw error 
for

these codecs ?

AC3   is  supported before and after this patch.
EAC3 is unsupported before and after this patch.

But it's sent to the same decoder, so support could be added. I'll 
check.
Attached patch allows muxing EAC3 in MPEG-PS.  Stock ffmpeg can 
demux and decode such streams fine.

Which descriptor is used for eac3?
Please do not commit just because decoding works with FFmpeg, at 
least try to find some specification.


The PS muxer appears to use System A and this is what the ATSC A/52 
(2012) standard says,


"For System A, this section extends the use ofthe AC-3 Registration 
Descriptor defined in Section A3 in combination with the E-AC-3 
stream_type value defined below."


and

"E-AC-3 bit streams shall be identified with a stream_typevalue of 
0x87 when transmitted as PES streams conforming to ATSC-published 
standards."


Note that the stream_type value of AC-3 is 0x81 yet our id sequence 
starts from 0x80.  This patch uses the same descriptor series as AC-3, 
however if I switch to 0x87, only one such stream may be muxed as 0x88 
was assigned (by you) to DTS. Also, our demuxer sets the codec_id to 
DTS for 0x88 to 0x8f.


Both stock ffmpeg and VlC 4.0 nightly play files using the current 
patch. Mediainfo also identifies the codec correctly.


Comments?


Carl, ping.

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

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

Re: [FFmpeg-devel] [PATCH 2/4] avcodec/interplayvideo: Avoid ff_get_buffer() during init

2019-08-03 Thread Michael Niedermayer
On Thu, Jul 11, 2019 at 11:49:38PM +0200, Michael Niedermayer wrote:
> This is unneeded for interplay video
> 
> Fixes: memleak
> Fixes: 
> 15562/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_VIDEO_fuzzer-5162268645392384
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/interplayvideo.c | 8 
>  1 file changed, 8 deletions(-)

will apply

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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

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

Re: [FFmpeg-devel] [PATCH 2/4] avformat/vividas: Check that value from ffio_read_varlen() does not overflow

2019-08-03 Thread Michael Niedermayer
On Sun, Jul 21, 2019 at 12:08:54AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -1241665686 + -1340629419 cannot be 
> represented in type 'int'
> Fixes: 
> 15922/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5692826442006528
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)

will apply

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

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


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

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

Re: [FFmpeg-devel] [PATCH 1/4] avformat/vividas: forward errors from track_header()

2019-08-03 Thread Michael Niedermayer
On Sun, Jul 21, 2019 at 12:08:53AM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)

will apply

[...]
-- 
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 4/6] avformat/vividas: Check if extradata was read successfully

2019-08-03 Thread Michael Niedermayer
On Sat, Jul 13, 2019 at 10:25:04PM +0200, Michael Niedermayer wrote:
> Fixes: OOM
> Fixes: 
> 15575/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5654666781655040
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

will apply

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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 6/6] avcodec/clearvideo: fix invalid shift in tile size check

2019-08-03 Thread Michael Niedermayer
On Sat, Jul 13, 2019 at 10:25:06PM +0200, Michael Niedermayer wrote:
> Fixes: left shift of 1 by 31 places cannot be represented in type 'int'
> Fixes: 
> 15631/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5690110605000704
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/clearvideo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

Re: [FFmpeg-devel] [PATCH 3/6] avformat/vividas: Check buffer size before allocation

2019-08-03 Thread Michael Niedermayer
On Sat, Jul 13, 2019 at 10:25:03PM +0200, Michael Niedermayer wrote:
> Fixes: out of array access
> Fixes: 
> 15365/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5716153105645568
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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 5/6] avcodec/hnm4video: Forward errors of decode_interframe_v4()

2019-08-03 Thread Tomas Härdin
lör 2019-08-03 klockan 01:49 +0200 skrev 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)
>  {
> [...]
> @@ -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;

Looks OK

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH 4/6] avcodec/hnm4video: Optimize postprocess_current_frame()

2019-08-03 Thread Tomas Härdin
lör 2019-08-03 klockan 01:49 +0200 skrev Michael Niedermayer:
> -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;

Looks OK. Maybe telling the compiler that src and dst don't alias would
be worthwhile?

/Tomas

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

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

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

2019-08-03 Thread Tomas Härdin
tor 2019-08-01 klockan 16:34 + skrev Gaullier Nicolas:
> > > > MXF has a UL registered for Dolby-E:
> > I also notice this UL is already in mxf.c, but added commented out
> > by Baptiste back in 2006..
> There are two ways for signalling dolby-E in MXF : channel status IF
> using an AES3 descriptor, or the registered UL for Sound Essence
> Coding.

Which specs pertain to this?

> ARD/ZDF/HDF requires both but it is very specific. The use of the
> channel status only seems a little bit more common, I have seen it in
> Harmonic files.
> But at the end, what is really highly widespread is to have no
> signaling at all.

Wouldn't be broadcast if the crappiest way wasn't the most widespread

> > So, a general solution is needed. When the user knows the audio is
> > Dolby-E then they can obviously just override the decoder, if they
> > want (not always). Another typical case is "if you think the audio
> > is Dolby- E, automatically decode it so I don't blow my speakers!".
> > An option could allow avformat_find_stream_info() to wait for the
> > first audio packet and probe it, and not take what the demuxer says
> > at face value.
> Concerning a general solution, the problem is even worse : nowadays
> MXF files are mostly structured with mono audio tracks (ARD/ZDF, AS-
> 10 in France etc.)...
> My idea was to enable the submux only for wav/mxf/potentially
> quicktime because I don't see use case for other formats; but this
> require stereo audio.

I wouldn't be surprised if this shows up in GXF and LXF also

> For a more general solution (MXF with mono audio tracks
> specifically), I have in mind to build an audio filter : a graph
> would merge the L/R to build a dolbyE stream that the filter could
> decode: this is not very handy for users, but I don't know how it
> could be done otherwise.

This would suggest that a filter based approach would be best. It
sounds like the user will have to apply quite a bit of business logic
either way, except maybe for files that signal Dolby-E properly

> I am currently working with an AVOption in MXF&WAV contexts, but if
> you think avformat_find_stream_info() is a better way, I will take a
> look... but I am not very confident with my knowledge of ffmpeg for
> that work, and I will rather certainly concentrate on the general
> case with the audio filter if this is valid for you ?

It's been a while since I poked at lavf internals, so I'm not quite
sure what would be the best approach. Maybe Baptiste has some ideas?

Feel free to poke me on IRC about this, since it seems a bit of
discussion is needed (thardin in #ffmpeg-devel on freenode)

/Tomas


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

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

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

2019-08-03 Thread Michael Niedermayer
On Sat, Aug 03, 2019 at 11:44:06AM +1000, Peter Ross wrote:
> 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.

ok, tested with same "+1"

ill push my change as that seems the most that can be reasonable be done.

maybe we should ask for a sample if this codepath executes ?


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

Thanks!

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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

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

[FFmpeg-devel] [PATCH] avcodec/dirac_parser: Fix overflow in dts

2019-08-03 Thread Michael Niedermayer
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 
'int'
Fixes: 
15568/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5634719611355136

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

diff --git a/libavcodec/dirac_parser.c b/libavcodec/dirac_parser.c
index 1ade44a438..fbc7414c79 100644
--- a/libavcodec/dirac_parser.c
+++ b/libavcodec/dirac_parser.c
@@ -212,7 +212,7 @@ static int dirac_combine_frame(AVCodecParserContext *s, 
AVCodecContext *avctx,
 if (parse_timing_info && pu1.prev_pu_offset >= 13) {
 uint8_t *cur_pu = pc->buffer +
   pc->index - 13 - pu1.prev_pu_offset;
-int pts = AV_RB32(cur_pu + 13);
+int64_t pts = AV_RB32(cur_pu + 13);
 if (s->last_pts == 0 && s->last_dts == 0)
 s->dts = pts - 1;
 else
-- 
2.22.0

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

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

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

2019-08-03 Thread Michael Niedermayer
On Sat, Aug 03, 2019 at 12:43:32PM +1000, Peter Ross wrote:
> 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.

actually, looking at this again, i think we should use the same j,
This also now excludes s->width % pixels_per_value != 0 for which i suspect 
there
is no testcase. Ill add support for this in case the fuzzer finds a case
that way we then also have a testcase for implementing that corner case.

heres the new code:

--- 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 &&
+s->width % pixels_per_value == 0
+) {
+for (; xl < pixels_per_value; xl ++) {
+j = (j < bits_per_plane ? 8 : j) - bits_per_plane;
+d[xl] |= (value >> j) & mask;
+}
+av_memcpy_backptr(d+xl, pixels_per_value, s->width - xl);
+run -= s->width / pixels_per_value;
+xl = s->width;
+}
 }
 }
 run--;


[...]


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/vp3: Check that theora is theora

2019-08-03 Thread Michael Niedermayer
On Wed, Jul 24, 2019 at 02:40:08PM +0200, Michael Niedermayer wrote:
> Theora is forced to be non zero if it is zero and a sample
> is asked for, as suggested by reimar
> 
> Fixes: Timeout (2min -> 600ms)
> Fixes: 
> 15366/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5737849938247680
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vp3.c | 4 
>  1 file changed, 4 insertions(+)

will apply

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

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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-03 Thread Michael Niedermayer
On Sat, Aug 03, 2019 at 11:45:17AM +1000, Peter Ross wrote:
> 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.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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] [PATCHv2 1/4] avformat/mpegtsenc: fix incorrect PCR selection with multiple programs

2019-08-03 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

Fixes ticket #8039.

v2: a video is stream is preferred if there are no programs, just like before
the patch.

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

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..3ca7599097 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,73 @@ 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;
+AVProgram *program = service->program;
+int nb_streams = program ? program->nb_stream_indexes : s->nb_streams;
+
+for (int j = 0; j < nb_streams; j++) {
+AVStream *st = s->streams[program ? program->stream_index[j] : j];
+if (!pcr_st ||
+pcr_st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO && 
st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+{
+pcr_st = st;
+}
+}
+
+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(AVFormat