Re: [FFmpeg-devel] [PATCH v3 1/2] avcodec/codec_par: Add codec properties field to AVCodecParameters

2021-10-05 Thread Hendrik Leppkes
On Wed, Oct 6, 2021 at 8:45 AM Soft Works  wrote:
> diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
> index 10cf79dff1..42ed8deb13 100644
> --- a/libavcodec/codec_par.h
> +++ b/libavcodec/codec_par.h
> @@ -198,6 +198,10 @@ typedef struct AVCodecParameters {
>   * Audio only. Number of samples to skip after a discontinuity.
>   */
>  int seek_preroll;
> +/**
> + * Codec properties of the stream that gets decoded
> + */
> +unsigned properties;
>  } AVCodecParameters;
>

This field is severly underspecified/underdocumented. I realize you
just copied it, but if I'm looking at this without pre-existing
knowledge, then I have absolutely no idea what it might be for, or
what kind of values go in there. The old field had the defines of the
possible bits right there for context - this doesn't have this, so it
would definitely benefit from added documentation.

- Hendrik
___
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 v3 2/2] ffprobe: Use codec properties value from AvCodecParameters

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
 fftools/ffprobe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 90e895bbf9..f5c6335a13 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2655,9 +2655,9 @@ static int show_stream(WriterContext *w, AVFormatContext 
*fmt_ctx, int stream_id
 if (dec_ctx) {
 print_int("coded_width",  dec_ctx->coded_width);
 print_int("coded_height", dec_ctx->coded_height);
-print_int("closed_captions", !!(dec_ctx->properties & 
FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
-print_int("film_grain", !!(dec_ctx->properties & 
FF_CODEC_PROPERTY_FILM_GRAIN));
 }
+print_int("closed_captions", !!(par->properties & 
FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
+print_int("film_grain", !!(par->properties & 
FF_CODEC_PROPERTY_FILM_GRAIN));
 print_int("has_b_frames", par->video_delay);
 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
 if (sar.num) {
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v3 1/2] avcodec/codec_par: Add codec properties field to AVCodecParameters

2021-10-05 Thread Soft Works
This fixes incorrect display of closed_captions property in ffprobe.

Repro Example:
ffprobe -show_entries stream=closed_captions:disposition=:side_data=  
"http://streams.videolan.org/streams/ts/CC/NewsStream-608-ac3.ts";

While the codec string included "Closed Captions",
the stream data is showed: closed_captions=0

The test ref was incorrect as the test media file actually does
have cc, which is fixed by this commit, so the test ref needs
to be updated.

Signed-off-by: softworkz 
---
v3: Moved test update to the right (this) commit

 doc/APIchanges  | 3 +++
 libavcodec/codec_par.c  | 2 ++
 libavcodec/codec_par.h  | 4 
 libavcodec/version.h| 2 +-
 tests/ref/fate/ts-demux | 2 +-
 5 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 7b267a79ac..2be3303efa 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2021-10-07 - xx - lavc 59.11.100 - codec_par.h
+  Add codec properties field to AVCodecParameters
+  
 2021-09-21 - xx - lavu 57.7.100 - pixfmt.h
   Add AV_PIX_FMT_X2BGR10.
 
diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
index 1a5168a04b..f6c13f7d11 100644
--- a/libavcodec/codec_par.c
+++ b/libavcodec/codec_par.c
@@ -101,6 +101,7 @@ int avcodec_parameters_from_context(AVCodecParameters *par,
 par->bits_per_raw_sample   = codec->bits_per_raw_sample;
 par->profile   = codec->profile;
 par->level = codec->level;
+par->properties= codec->properties;
 
 switch (par->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
@@ -156,6 +157,7 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 codec->bits_per_raw_sample   = par->bits_per_raw_sample;
 codec->profile   = par->profile;
 codec->level = par->level;
+codec->properties= par->properties;
 
 switch (par->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
index 10cf79dff1..42ed8deb13 100644
--- a/libavcodec/codec_par.h
+++ b/libavcodec/codec_par.h
@@ -198,6 +198,10 @@ typedef struct AVCodecParameters {
  * Audio only. Number of samples to skip after a discontinuity.
  */
 int seek_preroll;
+/**
+ * Codec properties of the stream that gets decoded
+ */
+unsigned properties;
 } AVCodecParameters;
 
 /**
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 4bd22f7e93..1c28fd0be5 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  59
-#define LIBAVCODEC_VERSION_MINOR  10
+#define LIBAVCODEC_VERSION_MINOR  11
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/tests/ref/fate/ts-demux b/tests/ref/fate/ts-demux
index 8e7a81da41..1d1382cf37 100644
--- a/tests/ref/fate/ts-demux
+++ b/tests/ref/fate/ts-demux
@@ -41,7 +41,7 @@ 
packet|codec_type=audio|stream_index=2|pts=3912642700|pts_time=43473.807778|dts=
 
packet|codec_type=video|stream_index=0|pts=3912686363|pts_time=43474.292922|dts=3912686363|dts_time=43474.292922|duration=1501|duration_time=0.016678|size=4944|pos=506660|flags=__|data_hash=CRC32:54a86cbb
 
packet|codec_type=audio|stream_index=1|pts=3912644825|pts_time=43473.831389|dts=3912644825|dts_time=43473.831389|duration=2880|duration_time=0.032000|size=906|pos=474888|flags=K_|data_hash=CRC32:0893d398
 
packet|codec_type=audio|stream_index=2|pts=3912645580|pts_time=43473.839778|dts=3912645580|dts_time=43473.839778|duration=2880|duration_time=0.032000|size=354|pos=491808|flags=K_|data_hash=CRC32:f5963fa6
-stream|index=0|codec_name=mpeg2video|profile=4|codec_type=video|codec_tag_string=[2][0][0][0]|codec_tag=0x0002|width=1280|height=720|coded_width=0|coded_height=0|closed_captions=0|film_grain=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=16:9|pix_fmt=yuv420p|level=4|color_range=tv|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|id=0x31|r_frame_rate=6/1001|avg_frame_rate=6/1001|time_base=1/9|start_pts=3912669846|start_time=43474.109400|duration_ts=19519|duration=0.216878|bit_rate=1500|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=15|extradata_hash=CRC32:53134fa8|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_
 
thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
+stream|index=0|codec_name=mpeg2video|profile=4|codec_type=video|codec_tag_string=[2][0][0][0

Re: [FFmpeg-devel] [PATCH] avcodec/amr_parser: passthrough if channels is unknown

2021-10-05 Thread Andreas Rheinhardt
James Almer:
> On 10/5/2021 5:51 PM, Michael Niedermayer wrote:
>> Fixes: division by 0
>> Fixes:
>> 39562/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-5448834960982016
>>
>> Fixes:
>> 39589/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-6119205334810624
>>
>>
>> Found-by: continuous fuzzing process
>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> Signed-off-by: Michael Niedermayer 
>> ---
>>   libavcodec/amr_parser.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/amr_parser.c b/libavcodec/amr_parser.c
>> index 79258d4d0cf..9fb7711fee0 100644
>> --- a/libavcodec/amr_parser.c
>> +++ b/libavcodec/amr_parser.c
>> @@ -62,7 +62,7 @@ static int amr_parse(AVCodecParserContext *s1,
>>   *poutbuf_size = 0;
>>   *poutbuf = NULL;
>>   -    if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
>> +    if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES || !avctx->channels) {
> 
> No line in the parser divides by avctx->channels. There's however one
> doing a modulo avctx->channels. Wouldn't this mean the compiler is being
> overzealous with optimizations?
> 

No. foo % 0 makes no sense and is undefined behaviour; this is even
stated in the same sentence of the spec: "In both operations, if the
value of
 the second operand is zero, the behavior is undefined."

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


[FFmpeg-devel] [PATCH v6 11/11] libavformat/asfdec: Fix variable types and add checks for unsupported values

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 168 ++---
 1 file changed, 108 insertions(+), 60 deletions(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index b8140a6d57..c7141f6da1 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -332,9 +332,9 @@ static int asf_read_stream_properties(AVFormatContext *s, 
uint64_t size)
 ASFStream *asf_st;
 ff_asf_guid g;
 enum AVMediaType type;
-int type_specific_size, sizeX;
-unsigned int tag1;
-int64_t pos1, pos2, start_time;
+unsigned int tag1, type_specific_size, sizeX;
+int64_t pos1, pos2;
+uint32_t start_time;
 int test_for_ext_stream_audio, is_dvr_ms_audio = 0;
 
 if (s->nb_streams == ASF_MAX_STREAMS) {
@@ -403,7 +403,14 @@ static int asf_read_stream_properties(AVFormatContext *s, 
uint64_t size)
 
 st->codecpar->codec_type = type;
 if (type == AVMEDIA_TYPE_AUDIO) {
-int ret = ff_get_wav_header(s, pb, st->codecpar, type_specific_size, 
0);
+int ret;
+
+if (type_specific_size > INT32_MAX) {
+av_log(s, AV_LOG_DEBUG, "Unsupported WAV header size (> 
INT32_MAX)\n");
+return AVERROR(ENOTSUP);
+}
+
+ret = ff_get_wav_header(s, pb, st->codecpar, (int)type_specific_size, 
0);
 if (ret < 0)
 return ret;
 if (is_dvr_ms_audio) {
@@ -433,21 +440,32 @@ static int asf_read_stream_properties(AVFormatContext *s, 
uint64_t size)
 }
 } else if (type == AVMEDIA_TYPE_VIDEO &&
size - (avio_tell(pb) - pos1 + 24) >= 51) {
+unsigned int width, height;
 avio_rl32(pb);
 avio_rl32(pb);
 avio_r8(pb);
 avio_rl16(pb);/* size */
-sizeX = avio_rl32(pb); /* size */
-st->codecpar->width  = avio_rl32(pb);
-st->codecpar->height = avio_rl32(pb);
+sizeX  = avio_rl32(pb); /* size */
+width  = avio_rl32(pb);
+height = avio_rl32(pb);
+
+if (width > INT32_MAX || height > INT32_MAX) {
+av_log(s, AV_LOG_DEBUG, "Unsupported video size %dx%d\n", width, 
height);
+return AVERROR(ENOTSUP);
+}
+
+st->codecpar->width  = (int)width;
+st->codecpar->height = (int)height;
 /* not available for asf */
 avio_rl16(pb); /* panes */
 st->codecpar->bits_per_coded_sample = avio_rl16(pb); /* depth */
 tag1 = avio_rl32(pb);
 avio_skip(pb, 20);
 if (sizeX > 40) {
-if (size < sizeX - 40 || sizeX - 40 > INT_MAX - 
AV_INPUT_BUFFER_PADDING_SIZE)
-return AVERROR_INVALIDDATA;
+if (size < sizeX - 40 || sizeX - 40 > INT_MAX - 
AV_INPUT_BUFFER_PADDING_SIZE) {
+av_log(s, AV_LOG_DEBUG, "Unsupported extradata size\n");
+return AVERROR(ENOTSUP);
+}
 st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40);
 st->codecpar->extradata  = 
av_mallocz(st->codecpar->extradata_size +

AV_INPUT_BUFFER_PADDING_SIZE);
@@ -499,9 +517,9 @@ static int asf_read_ext_stream_properties(AVFormatContext 
*s)
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb;
 ff_asf_guid g;
-int ext_len, payload_ext_ct, stream_ct, i;
-uint32_t leak_rate, stream_num;
-unsigned int stream_languageid_index;
+uint16_t payload_ext_ct, stream_ct, i;
+uint32_t leak_rate, ext_len;
+uint16_t stream_languageid_index, stream_num;
 
 avio_rl64(pb); // starttime
 avio_rl64(pb); // endtime
@@ -513,15 +531,15 @@ static int asf_read_ext_stream_properties(AVFormatContext 
*s)
 avio_rl32(pb); // alt-init-bucket-fullness
 avio_rl32(pb); // max-object-size
 avio_rl32(pb); // flags 
(reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits 
reserved)
-stream_num = avio_rl16(pb); // stream-num
+stream_num = (uint16_t)avio_rl16(pb); // stream-num
 
-stream_languageid_index = avio_rl16(pb); // stream-language-id-index
+stream_languageid_index = (uint16_t)avio_rl16(pb); // 
stream-language-id-index
 if (stream_num < 128)
 asf->streams[stream_num].stream_language_index = 
stream_languageid_index;
 
 avio_rl64(pb); // avg frametime in 100ns units
-stream_ct  = avio_rl16(pb); // stream-name-count
-payload_ext_ct = avio_rl16(pb); // payload-extension-system-count
+stream_ct  = (uint16_t)avio_rl16(pb); // stream-name-count
+payload_ext_ct = (uint16_t)avio_rl16(pb); // payload-extension-system-count
 
 if (stream_num < 128) {
 asf->stream_bitrates[stream_num] = leak_rate;
@@ -535,12 +553,10 @@ static int asf_read_ext_stream_properties(AVFormatContext 
*s)
 }
 
 for (i = 0; i < payload_ext_ct; i++) {
-int size;
+uint16_t size;
 ff_get_guid(pb, &g);
-size = avio_rl16(pb);
+   

[FFmpeg-devel] [PATCH v6 10/11] libavformat/asfdec: Fix parameter type in asf_read_stream_propertie()

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 024d77903b..b8140a6d57 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -323,7 +323,7 @@ static int asf_read_file_properties(AVFormatContext *s)
 return 0;
 }
 
-static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
+static int asf_read_stream_properties(AVFormatContext *s, uint64_t size)
 {
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb;
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 09/11] libavformat/asfdec: Ensure variables are initialized

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 8283f245ab..024d77903b 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -968,6 +968,7 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext 
*pb)
 avio_seek(pb, -1, SEEK_CUR); // FIXME
 }
 } else {
+d = e = 0;
 c = avio_r8(pb);
 if (c & 0x80) {
 rsize ++;
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 08/11] libavformat/asfdec: Remove variable redefinition in inner scope

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index a7b5ffe465..8283f245ab 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -1181,7 +1181,7 @@ static int asf_parse_packet(AVFormatContext *s, 
AVIOContext *pb, AVPacket *pkt)
 return AVERROR_EOF;
 if (asf->packet_size_left < FRAME_HEADER_SIZE ||
 asf->packet_segments < 1 && asf->packet_time_start == 0) {
-int ret = asf->packet_size_left + asf->packet_padsize;
+ret = asf->packet_size_left + asf->packet_padsize;
 
 if (asf->packet_size_left && asf->packet_size_left < 
FRAME_HEADER_SIZE)
 av_log(s, AV_LOG_WARNING, "Skip due to FRAME_HEADER_SIZE\n");
@@ -1250,7 +1250,6 @@ static int asf_parse_packet(AVFormatContext *s, 
AVIOContext *pb, AVPacket *pkt)
 if (asf_st->pkt.size != asf_st->packet_obj_size ||
 // FIXME is this condition sufficient?
 asf_st->frag_offset + asf->packet_frag_size > asf_st->pkt.size) {
-int ret;
 
 if (asf_st->pkt.data) {
 av_log(s, AV_LOG_INFO,
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 07/11] libavformat/asfdec: Fix macro definition and use

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index e87c78cd6c..a7b5ffe465 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -896,21 +896,21 @@ static int asf_read_header(AVFormatContext *s)
 }
 
 #define DO_2BITS(bits, var, defval) \
-switch (bits & 3) { \
+switch ((bits) & 3) {   \
 case 3: \
-var = avio_rl32(pb);\
+(var) = avio_rl32(pb);  \
 rsize += 4; \
 break;  \
 case 2: \
-var = avio_rl16(pb);\
+(var) = avio_rl16(pb);  \
 rsize += 2; \
 break;  \
 case 1: \
-var = avio_r8(pb);  \
+(var) = avio_r8(pb);\
 rsize++;\
 break;  \
 default:\
-var = defval;   \
+(var) = (defval);   \
 break;  \
 }
 
@@ -993,9 +993,9 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext 
*pb)
 asf->packet_flags= c;
 asf->packet_property = d;
 
-DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size);
-DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence ignored
-DO_2BITS(asf->packet_flags >> 3, padsize, 0); // padding length
+DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size)
+DO_2BITS(asf->packet_flags >> 1, padsize, 0) // sequence ignored
+DO_2BITS(asf->packet_flags >> 3, padsize, 0) // padding length
 
 // the following checks prevent overflows and infinite loops
 if (!packet_length || packet_length >= (1U << 29)) {
@@ -1056,9 +1056,9 @@ static int asf_read_frame_header(AVFormatContext *s, 
AVIOContext *pb)
 asf->stream_index = asf->asfid2avid[num & 0x7f];
 asfst = &asf->streams[num & 0x7f];
 // sequence should be ignored!
-DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0);
-DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0);
-DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
+DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0)
+DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0)
+DO_2BITS(asf->packet_property, asf->packet_replic_size, 0)
 av_log(asf, AV_LOG_TRACE, "key:%d stream:%d seq:%d offset:%d 
replic_size:%d num:%X packet_property %X\n",
 asf->packet_key_frame, asf->stream_index, asf->packet_seq,
 asf->packet_frag_offset, asf->packet_replic_size, num, 
asf->packet_property);
@@ -1134,7 +1134,7 @@ static int asf_read_frame_header(AVFormatContext *s, 
AVIOContext *pb)
 return AVERROR_INVALIDDATA;
 }
 if (asf->packet_flags & 0x01) {
-DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0); // 0 
is illegal
+DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0) // 0 
is illegal
 if (rsize > asf->packet_size_left) {
 av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n");
 return AVERROR_INVALIDDATA;
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 06/11] libavformat/asfdec: Remove unused parameters

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 4c898ab3f2..e87c78cd6c 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -299,7 +299,7 @@ finish:
 avio_seek(s->pb, off + len, SEEK_SET);
 }
 
-static int asf_read_file_properties(AVFormatContext *s, int64_t size)
+static int asf_read_file_properties(AVFormatContext *s)
 {
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb;
@@ -494,7 +494,7 @@ static int asf_read_stream_properties(AVFormatContext *s, 
int64_t size)
 return 0;
 }
 
-static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size)
+static int asf_read_ext_stream_properties(AVFormatContext *s)
 {
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb;
@@ -554,7 +554,7 @@ static int asf_read_ext_stream_properties(AVFormatContext 
*s, int64_t size)
 return 0;
 }
 
-static int asf_read_content_desc(AVFormatContext *s, int64_t size)
+static int asf_read_content_desc(AVFormatContext *s)
 {
 AVIOContext *pb = s->pb;
 uint32_t len1, len2, len3, len4, len5;
@@ -573,7 +573,7 @@ static int asf_read_content_desc(AVFormatContext *s, 
int64_t size)
 return 0;
 }
 
-static int asf_read_ext_content_desc(AVFormatContext *s, int64_t size)
+static int asf_read_ext_content_desc(AVFormatContext *s)
 {
 AVIOContext *pb = s->pb;
 ASFContext *asf = s->priv_data;
@@ -619,7 +619,7 @@ static int asf_read_ext_content_desc(AVFormatContext *s, 
int64_t size)
 return 0;
 }
 
-static int asf_read_language_list(AVFormatContext *s, int64_t size)
+static int asf_read_language_list(AVFormatContext *s)
 {
 AVIOContext *pb = s->pb;
 ASFContext *asf = s->priv_data;
@@ -639,7 +639,7 @@ static int asf_read_language_list(AVFormatContext *s, 
int64_t size)
 return 0;
 }
 
-static int asf_read_metadata(AVFormatContext *s, int64_t size)
+static int asf_read_metadata(AVFormatContext *s)
 {
 AVIOContext *pb = s->pb;
 ASFContext *asf = s->priv_data;
@@ -693,7 +693,7 @@ static int asf_read_metadata(AVFormatContext *s, int64_t 
size)
 return 0;
 }
 
-static int asf_read_marker(AVFormatContext *s, int64_t size)
+static int asf_read_marker(AVFormatContext *s)
 {
 AVIOContext *pb = s->pb;
 ASFContext *asf = s->priv_data;
@@ -772,21 +772,21 @@ static int asf_read_header(AVFormatContext *s)
 if (gsize < 24)
 return AVERROR_INVALIDDATA;
 if (!ff_guidcmp(&g, &ff_asf_file_header)) {
-ret = asf_read_file_properties(s, gsize);
+ret = asf_read_file_properties(s);
 } else if (!ff_guidcmp(&g, &ff_asf_stream_header)) {
 ret = asf_read_stream_properties(s, gsize);
 } else if (!ff_guidcmp(&g, &ff_asf_comment_header)) {
-asf_read_content_desc(s, gsize);
+asf_read_content_desc(s);
 } else if (!ff_guidcmp(&g, &ff_asf_language_guid)) {
-asf_read_language_list(s, gsize);
+asf_read_language_list(s);
 } else if (!ff_guidcmp(&g, &ff_asf_extended_content_header)) {
-asf_read_ext_content_desc(s, gsize);
+asf_read_ext_content_desc(s);
 } else if (!ff_guidcmp(&g, &ff_asf_metadata_header)) {
-asf_read_metadata(s, gsize);
+asf_read_metadata(s);
 } else if (!ff_guidcmp(&g, &ff_asf_metadata_library_header)) {
-asf_read_metadata(s, gsize);
+asf_read_metadata(s);
 } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_header)) {
-asf_read_ext_stream_properties(s, gsize);
+asf_read_ext_stream_properties(s);
 
 // there could be an optional stream properties object to follow
 // if so the next iteration will pick it up
@@ -796,7 +796,7 @@ static int asf_read_header(AVFormatContext *s)
 avio_skip(pb, 6);
 continue;
 } else if (!ff_guidcmp(&g, &ff_asf_marker_header)) {
-asf_read_marker(s, gsize);
+asf_read_marker(s);
 } else if (avio_feof(pb)) {
 return AVERROR_EOF;
 } else {
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 05/11] libavformat/asfdec: Implement parsing of GUID values

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 58c424b565..4c898ab3f2 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -280,9 +280,12 @@ static void get_tag(AVFormatContext *s, const char *key, 
int type, uint32_t len,
 snprintf(value, buffer_len, "%"PRIu64, num);
 break;
 }
-case ASF_GUID:
-av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key);
-goto finish;
+case ASF_GUID: {
+ff_asf_guid g;
+ff_get_guid(s->pb, &g);
+snprintf(value, buffer_len, "%x", g[0]);
+break;
+}
 default:
 av_log(s, AV_LOG_DEBUG,
"Unsupported value type %d in tag %s.\n", type, key);
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 04/11] libavformat/asfdec: Fixing get_tag

2021-10-05 Thread Soft Works
These three are closely related and can't be separated easily:

In get_tag, the code was adding 22 bytes (in order to allow
it to hold 64bit numbers as string) to the value len for creating
creating a buffer. This was unnecessarily imposing a
size-constraint on the value_len parameter.

The code in get_tag, was limiting the maximum value_len to
half the size of INT32. This was applied for all value types, even
though it is required only in case of ASF_UNICODE, not for any
other ones (like ASCII).

get_tag was always allocating a buffer regardless of the
datatype, even though this isn't required in case of ASF_BYTE_ARRAY

The check for the return value from ff_asf_handle_byte_array()
being >0 is removed here because the log message is emitted
by the function itself now.

Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 54 +++---
 1 file changed, 40 insertions(+), 14 deletions(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 29b429fee9..58c424b565 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -221,37 +221,63 @@ static uint64_t get_value(AVIOContext *pb, int type, int 
type2_size)
 static void get_tag(AVFormatContext *s, const char *key, int type, uint32_t 
len, int type2_size)
 {
 ASFContext *asf = s->priv_data;
-char *value = NULL;
 int64_t off = avio_tell(s->pb);
-#define LEN 22
-
-av_assert0((unsigned)len < (INT_MAX - LEN) / 2);
+char *value = NULL;
+uint64_t required_bufferlen;
+int buffer_len;
 
 if (!asf->export_xmp && !strncmp(key, "xmp", 3))
 goto finish;
 
-value = av_malloc(2 * len + LEN);
+switch (type) {
+case ASF_UNICODE:
+required_bufferlen = (uint64_t)len * 2 + 1;
+break;
+case -1: // ASCII
+required_bufferlen = (uint64_t)len + 1;
+break;
+case ASF_BYTE_ARRAY:
+ff_asf_handle_byte_array(s, key, len);
+goto finish;
+case ASF_BOOL:
+case ASF_DWORD:
+case ASF_QWORD:
+case ASF_WORD:
+required_bufferlen = 22;
+break;
+case ASF_GUID:
+required_bufferlen = 33;
+break;
+default:
+required_bufferlen = len;
+break;
+}
+
+if (required_bufferlen > INT32_MAX) {
+av_log(s, AV_LOG_VERBOSE, "Unable to handle values > INT32_MAX  in tag 
%s.\n", key);
+goto finish;
+}
+
+buffer_len = (int)required_bufferlen;
+
+value = av_malloc(buffer_len);
 if (!value)
 goto finish;
 
 switch (type) {
 case ASF_UNICODE:
-avio_get_str16le(s->pb, len, value, 2 * len + 1);
+avio_get_str16le(s->pb, len, value, buffer_len);
 break;
-case -1: // ASCI
-avio_read(s->pb, value, len);
-value[len]=0;
+case -1: // ASCII
+avio_read(s->pb, value, buffer_len - 1);
+value[buffer_len - 1] = 0;
 break;
-case ASF_BYTE_ARRAY:
-if (ff_asf_handle_byte_array(s, key, len) > 0)
-av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", 
key);
-goto finish;
 case ASF_BOOL:
 case ASF_DWORD:
 case ASF_QWORD:
 case ASF_WORD: {
 uint64_t num = get_value(s->pb, type, type2_size);
-snprintf(value, LEN, "%"PRIu64, num);
+snprintf(value, buffer_len, "%"PRIu64, num);
 break;
 }
 case ASF_GUID:
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 03/11] libavformat/asfdec: Fix type of value_len

2021-10-05 Thread Soft Works
The value_len is an uint32 not an int32 per spec. That
value must not be truncated, neither by casting to int, nor by any
conditional checks, because at the end of get_tag, this value is
needed to move forward in parsing. When the len value gets
modified, the parsing may break.

Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index d31e1d581d..29b429fee9 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -218,7 +218,7 @@ static uint64_t get_value(AVIOContext *pb, int type, int 
type2_size)
 }
 }
 
-static void get_tag(AVFormatContext *s, const char *key, int type, int len, 
int type2_size)
+static void get_tag(AVFormatContext *s, const char *key, int type, uint32_t 
len, int type2_size)
 {
 ASFContext *asf = s->priv_data;
 char *value = NULL;
@@ -528,7 +528,7 @@ static int asf_read_ext_stream_properties(AVFormatContext 
*s, int64_t size)
 static int asf_read_content_desc(AVFormatContext *s, int64_t size)
 {
 AVIOContext *pb = s->pb;
-int len1, len2, len3, len4, len5;
+uint32_t len1, len2, len3, len4, len5;
 
 len1 = avio_rl16(pb);
 len2 = avio_rl16(pb);
@@ -614,25 +614,23 @@ static int asf_read_metadata(AVFormatContext *s, int64_t 
size)
 {
 AVIOContext *pb = s->pb;
 ASFContext *asf = s->priv_data;
-int n, stream_num, name_len_utf16, name_len_utf8, value_len;
+int n, name_len_utf8;
+uint16_t stream_num, name_len_utf16, value_type;
+uint32_t value_len;
 int ret, i;
 n = avio_rl16(pb);
 
 for (i = 0; i < n; i++) {
 uint8_t *name;
-int value_type;
 
 avio_rl16(pb);  // lang_list_index
-stream_num = avio_rl16(pb);
-name_len_utf16 = avio_rl16(pb);
-value_type = avio_rl16(pb); /* value_type */
-value_len  = avio_rl32(pb);
+stream_num = (uint16_t)avio_rl16(pb);
+name_len_utf16 = (uint16_t)avio_rl16(pb);
+value_type = (uint16_t)avio_rl16(pb); /* value_type */
+value_len  = avio_rl32(pb);
 
-if (value_len < 0 || value_len > UINT16_MAX)
-return AVERROR_INVALIDDATA;
-
-name_len_utf8 = 2*name_len_utf16 + 1;
-name  = av_malloc(name_len_utf8);
+name_len_utf8  = 2 * name_len_utf16 + 1;
+name   = av_malloc(name_len_utf8);
 if (!name)
 return AVERROR(ENOMEM);
 
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 02/11] libavformat/asfdec: Fix get_value return type and add checks for unsupported values

2021-10-05 Thread Soft Works
get_value had a return type of int, which means that reading
QWORDS (case 4) was broken due to truncation of the result from
avio_rl64().

Signed-off-by: softworkz 
---
 libavformat/asfdec_f.c | 38 +-
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index a8f36ed286..d31e1d581d 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -202,7 +202,7 @@ static int asf_probe(const AVProbeData *pd)
 
 /* size of type 2 (BOOL) is 32bit for "Extended Content Description Object"
  * but 16 bit for "Metadata Object" and "Metadata Library Object" */
-static int get_value(AVIOContext *pb, int type, int type2_size)
+static uint64_t get_value(AVIOContext *pb, int type, int type2_size)
 {
 switch (type) {
 case ASF_BOOL:
@@ -567,10 +567,22 @@ static int asf_read_ext_content_desc(AVFormatContext *s, 
int64_t size)
 /* My sample has that stream set to 0 maybe that mean the container.
  * ASF stream count starts at 1. I am using 0 to the container value
  * since it's unused. */
-if (!strcmp(name, "AspectRatioX"))
-asf->dar[0].num = get_value(s->pb, value_type, 32);
-else if (!strcmp(name, "AspectRatioY"))
-asf->dar[0].den = get_value(s->pb, value_type, 32);
+if (!strcmp(name, "AspectRatioX")) {
+const uint64_t value = get_value(s->pb, value_type, 32);
+if (value > INT32_MAX) {
+av_log(s, AV_LOG_DEBUG, "Unsupported AspectRatioX value: 
%"PRIu64"\n", value);
+return AVERROR(ENOTSUP);
+}
+asf->dar[0].num = (int)value;
+}
+else if (!strcmp(name, "AspectRatioY")) {
+const uint64_t value = get_value(s->pb, value_type, 32);
+if (value > INT32_MAX) {
+av_log(s, AV_LOG_DEBUG, "Unsupported AspectRatioY value: 
%"PRIu64"\n", value);
+return AVERROR(ENOTSUP);
+}
+asf->dar[0].den = (int)value;
+}
 else
 get_tag(s, name, value_type, value_len, 32);
 }
@@ -630,13 +642,21 @@ static int asf_read_metadata(AVFormatContext *s, int64_t 
size)
 i, stream_num, name_len_utf16, value_type, value_len, name);
 
 if (!strcmp(name, "AspectRatioX")){
-int aspect_x = get_value(s->pb, value_type, 16);
+const uint64_t aspect_x = get_value(s->pb, value_type, 16);
+if (aspect_x > INT32_MAX) {
+av_log(s, AV_LOG_DEBUG, "Unsupported AspectRatioX value: 
%"PRIu64"\n", aspect_x);
+return AVERROR(ENOTSUP);
+}
 if(stream_num < 128)
-asf->dar[stream_num].num = aspect_x;
+asf->dar[stream_num].num = (int)aspect_x;
 } else if(!strcmp(name, "AspectRatioY")){
-int aspect_y = get_value(s->pb, value_type, 16);
+const uint64_t aspect_y = get_value(s->pb, value_type, 16);
+if (aspect_y > INT32_MAX) {
+av_log(s, AV_LOG_DEBUG, "Unsupported AspectRatioY value: 
%"PRIu64"\n", aspect_y);
+return AVERROR(ENOTSUP);
+}
 if(stream_num < 128)
-asf->dar[stream_num].den = aspect_y;
+asf->dar[stream_num].den = (int)aspect_y;
 } else {
 get_tag(s, name, value_type, value_len, 16);
 }
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v6 01/11] libavformat/asf: Fix handling of byte array length values

2021-10-05 Thread Soft Works
The spec allows attachment sizes of up to UINT32_MAX while
we can handle only sizes up to INT32_MAX (in downstream
code).

The debug.assert in get_tag didn't really address this,
and truncating the value_len in calling methods cannot
be used because the length value is required in order to
continue parsing. This adds a check with log message in
ff_asf_handle_byte_array to handle those (rare) cases.

Signed-off-by: softworkz 
---
 libavformat/asf.c | 12 +---
 libavformat/asf.h |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/asf.c b/libavformat/asf.c
index 1ac8b5f078..179b66a2b4 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -267,12 +267,18 @@ static int get_id3_tag(AVFormatContext *s, int len)
 }
 
 int ff_asf_handle_byte_array(AVFormatContext *s, const char *name,
- int val_len)
+ uint32_t val_len)
 {
+if (val_len > INT32_MAX) {
+av_log(s, AV_LOG_VERBOSE, "Unable to handle byte arrays > INT32_MAX  
in tag %s.\n", name);
+return 1;
+}
+
 if (!strcmp(name, "WM/Picture")) // handle cover art
-return asf_read_picture(s, val_len);
+return asf_read_picture(s, (int)val_len);
 else if (!strcmp(name, "ID3")) // handle ID3 tag
-return get_id3_tag(s, val_len);
+return get_id3_tag(s, (int)val_len);
 
+av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", name);
 return 1;
 }
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 01cc4f7a46..4d28560f56 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -111,7 +111,7 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
  * is unsupported by this function and 0 otherwise.
  */
 int ff_asf_handle_byte_array(AVFormatContext *s, const char *name,
- int val_len);
+ uint32_t val_len);
 
 
 #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 
-- 
2.30.2.windows.1

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

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


[FFmpeg-devel] [PATCH v2] avfilter/vf_lut3d: add x86-optimized tetrahedral interpolation

2021-10-05 Thread mindmark
From: Mark Reid 

I spotted an interesting pattern that I didn't see before that leads to the 
implementation being faster.
The bit shifting table I was using before is no longer needed, and was able to 
remove quite a few lines. 
I also add use of FMA on the AVX2 version.

f32 1920x1080 1 thread with prelut
c impl
1434012700 UNITS in lut3d->interp,       1 runs,      0 skips
1434035335 UNITS in lut3d->interp,       2 runs,      0 skips
1423615347 UNITS in lut3d->interp,       4 runs,      0 skips
1426268863 UNITS in lut3d->interp,       8 runs,      0 skips

sse2
905484420 UNITS in lut3d->interp,       1 runs,      0 skips
905659010 UNITS in lut3d->interp,       2 runs,      0 skips
915167140 UNITS in lut3d->interp,       4 runs,      0 skips
915834222 UNITS in lut3d->interp,       8 runs,      0 skips

avx
574794860 UNITS in lut3d->interp,       1 runs,      0 skips
581035090 UNITS in lut3d->interp,       2 runs,      0 skips
584116720 UNITS in lut3d->interp,       4 runs,      0 skips
581460290 UNITS in lut3d->interp,       8 runs,      0 skips

avx2
301698880 UNITS in lut3d->interp,       1 runs,      0 skips
301982880 UNITS in lut3d->interp,       2 runs,      0 skips
306962430 UNITS in lut3d->interp,       4 runs,      0 skips
305472025 UNITS in lut3d->interp,       8 runs,      0 skips

gbrap16 1920x1080 1 thread with prelut
c impl
1480894840 UNITS in lut3d->interp,       1 runs,      0 skips
1502922990 UNITS in lut3d->interp,       2 runs,      0 skips
1496114307 UNITS in lut3d->interp,       4 runs,      0 skips
1492554551 UNITS in lut3d->interp,       8 runs,      0 skips

sse2
980777180 UNITS in lut3d->interp,       1 runs,      0 skips
986121520 UNITS in lut3d->interp,       2 runs,      0 skips
986489840 UNITS in lut3d->interp,       4 runs,      0 skips
998832248 UNITS in lut3d->interp,       8 runs,      0 skips

avx
622212360 UNITS in lut3d->interp,       1 runs,      0 skips
622981160 UNITS in lut3d->interp,       2 runs,      0 skips
645396315 UNITS in lut3d->interp,       4 runs,      0 skips
641057075 UNITS in lut3d->interp,       8 runs,      0 skips

avx2
321336400 UNITS in lut3d->interp,       1 runs,      0 skips
321268920 UNITS in lut3d->interp,       2 runs,      0 skips
323459895 UNITS in lut3d->interp,       4 runs,      0 skips
324949967 UNITS in lut3d->interp,       8 runs,      0 skips

---
 libavfilter/lut3d.h |  83 
 libavfilter/vf_lut3d.c  |  61 +--
 libavfilter/x86/Makefile|   2 +
 libavfilter/x86/vf_lut3d.asm| 662 
 libavfilter/x86/vf_lut3d_init.c |  88 +
 5 files changed, 840 insertions(+), 56 deletions(-)
 create mode 100644 libavfilter/lut3d.h
 create mode 100644 libavfilter/x86/vf_lut3d.asm
 create mode 100644 libavfilter/x86/vf_lut3d_init.c

diff --git a/libavfilter/lut3d.h b/libavfilter/lut3d.h
new file mode 100644
index 00..ded2a036a5
--- /dev/null
+++ b/libavfilter/lut3d.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013 Clément Bœsch
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef AVFILTER_LUT3D_H
+#define AVFILTER_LUT3D_H
+
+#include "libavutil/pixdesc.h"
+#include "framesync.h"
+#include "avfilter.h"
+
+enum interp_mode {
+INTERPOLATE_NEAREST,
+INTERPOLATE_TRILINEAR,
+INTERPOLATE_TETRAHEDRAL,
+INTERPOLATE_PYRAMID,
+INTERPOLATE_PRISM,
+NB_INTERP_MODE
+};
+
+struct rgbvec {
+float r, g, b;
+};
+
+/* 3D LUT don't often go up to level 32, but it is common to have a Hald CLUT
+ * of 512x512 (64x64x64) */
+#define MAX_LEVEL 256
+#define PRELUT_SIZE 65536
+
+typedef struct Lut3DPreLut {
+int size;
+float min[3];
+float max[3];
+float scale[3];
+float* lut[3];
+} Lut3DPreLut;
+
+typedef struct LUT3DContext {
+const AVClass *class;
+struct rgbvec *lut;
+int lutsize;
+int lutsize2;
+struct rgbvec scale;
+int interpolation;  ///
+;*
+;* 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 t

[FFmpeg-devel] [PATCH v2 2/2] ffprobe: Fix incorrect display of closed_captions property

2021-10-05 Thread Soft Works
Repro Example:
ffprobe -show_entries stream=closed_captions:disposition=:side_data=  
"http://streams.videolan.org/streams/ts/CC/NewsStream-608-ac3.ts";

While the codec string includes "Closed Captions",
the stream data is showing: closed_captions=0

The test ref was incorrect as the test media file
actually does have cc.

Signed-off-by: softworkz 
---
 fftools/ffprobe.c   | 4 ++--
 tests/ref/fate/ts-demux | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 90e895bbf9..f5c6335a13 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2655,9 +2655,9 @@ static int show_stream(WriterContext *w, AVFormatContext 
*fmt_ctx, int stream_id
 if (dec_ctx) {
 print_int("coded_width",  dec_ctx->coded_width);
 print_int("coded_height", dec_ctx->coded_height);
-print_int("closed_captions", !!(dec_ctx->properties & 
FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
-print_int("film_grain", !!(dec_ctx->properties & 
FF_CODEC_PROPERTY_FILM_GRAIN));
 }
+print_int("closed_captions", !!(par->properties & 
FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
+print_int("film_grain", !!(par->properties & 
FF_CODEC_PROPERTY_FILM_GRAIN));
 print_int("has_b_frames", par->video_delay);
 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
 if (sar.num) {
diff --git a/tests/ref/fate/ts-demux b/tests/ref/fate/ts-demux
index 8e7a81da41..1d1382cf37 100644
--- a/tests/ref/fate/ts-demux
+++ b/tests/ref/fate/ts-demux
@@ -41,7 +41,7 @@ 
packet|codec_type=audio|stream_index=2|pts=3912642700|pts_time=43473.807778|dts=
 
packet|codec_type=video|stream_index=0|pts=3912686363|pts_time=43474.292922|dts=3912686363|dts_time=43474.292922|duration=1501|duration_time=0.016678|size=4944|pos=506660|flags=__|data_hash=CRC32:54a86cbb
 
packet|codec_type=audio|stream_index=1|pts=3912644825|pts_time=43473.831389|dts=3912644825|dts_time=43473.831389|duration=2880|duration_time=0.032000|size=906|pos=474888|flags=K_|data_hash=CRC32:0893d398
 
packet|codec_type=audio|stream_index=2|pts=3912645580|pts_time=43473.839778|dts=3912645580|dts_time=43473.839778|duration=2880|duration_time=0.032000|size=354|pos=491808|flags=K_|data_hash=CRC32:f5963fa6
-stream|index=0|codec_name=mpeg2video|profile=4|codec_type=video|codec_tag_string=[2][0][0][0]|codec_tag=0x0002|width=1280|height=720|coded_width=0|coded_height=0|closed_captions=0|film_grain=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=16:9|pix_fmt=yuv420p|level=4|color_range=tv|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|id=0x31|r_frame_rate=6/1001|avg_frame_rate=6/1001|time_base=1/9|start_pts=3912669846|start_time=43474.109400|duration_ts=19519|duration=0.216878|bit_rate=1500|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=15|extradata_hash=CRC32:53134fa8|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_
 
thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
+stream|index=0|codec_name=mpeg2video|profile=4|codec_type=video|codec_tag_string=[2][0][0][0]|codec_tag=0x0002|width=1280|height=720|coded_width=0|coded_height=0|closed_captions=1|film_grain=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=16:9|pix_fmt=yuv420p|level=4|color_range=tv|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|id=0x31|r_frame_rate=6/1001|avg_frame_rate=6/1001|time_base=1/9|start_pts=3912669846|start_time=43474.109400|duration_ts=19519|duration=0.216878|bit_rate=1500|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=15|extradata_hash=CRC32:53134fa8|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_
 
thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
 side_data|side_data_type=CPB 
properties|max_bitrate=1500|min_bitrate=0|avg_bitrate=0|buffer_size=9781248|vbv_delay=-1
 
stream|index=1|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[4][0][0][0]|codec_tag=0x0004|sample_fmt=fltp|sample_rate=48000|channels=6|channel_layout=5.1(side)|bits_per_sample=0|id=0x34|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/9|start_pts=3912633305|start_time=43473.703389|duration_ts=14

[FFmpeg-devel] [PATCH v2 1/2] avcodec/codec_par: Add codec properties field to AVCodecParameters

2021-10-05 Thread Soft Works
Signed-off-by: softworkz 
---
v2: include codec properties in AVCodecParameters instead of adding an API to 
retrieve it

 doc/APIchanges | 3 +++
 libavcodec/codec_par.c | 2 ++
 libavcodec/codec_par.h | 4 
 libavcodec/version.h   | 2 +-
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 7b267a79ac..2be3303efa 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2021-10-07 - xx - lavc 59.11.100 - codec_par.h
+  Add codec properties field to AVCodecParameters
+  
 2021-09-21 - xx - lavu 57.7.100 - pixfmt.h
   Add AV_PIX_FMT_X2BGR10.
 
diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
index 1a5168a04b..f6c13f7d11 100644
--- a/libavcodec/codec_par.c
+++ b/libavcodec/codec_par.c
@@ -101,6 +101,7 @@ int avcodec_parameters_from_context(AVCodecParameters *par,
 par->bits_per_raw_sample   = codec->bits_per_raw_sample;
 par->profile   = codec->profile;
 par->level = codec->level;
+par->properties= codec->properties;
 
 switch (par->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
@@ -156,6 +157,7 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 codec->bits_per_raw_sample   = par->bits_per_raw_sample;
 codec->profile   = par->profile;
 codec->level = par->level;
+codec->properties= par->properties;
 
 switch (par->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
index 10cf79dff1..42ed8deb13 100644
--- a/libavcodec/codec_par.h
+++ b/libavcodec/codec_par.h
@@ -198,6 +198,10 @@ typedef struct AVCodecParameters {
  * Audio only. Number of samples to skip after a discontinuity.
  */
 int seek_preroll;
+/**
+ * Codec properties of the stream that gets decoded
+ */
+unsigned properties;
 } AVCodecParameters;
 
 /**
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 4bd22f7e93..1c28fd0be5 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  59
-#define LIBAVCODEC_VERSION_MINOR  10
+#define LIBAVCODEC_VERSION_MINOR  11
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.30.2.windows.1

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

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


Re: [FFmpeg-devel] [PATCH 2/5] avformat/imf: CPL processor

2021-10-05 Thread Pierre-Anthony Lemieux
On Tue, Oct 5, 2021 at 5:03 PM Lynne  wrote:
>
> 5 Oct 2021, 17:22 by p...@sandflow.com:
>
> > Hi Lynne,
> >
> > Can you be more specific?
> >
> > The file header we used look consistent with the header of other
> > BSD-licensed files, like aacdec.c.
> >
> > Thanks,
> >
> > -- Pierre
> >
> > On Thu, Sep 30, 2021 at 6:40 AM Lynne  wrote:
> >
> >>
> >> 29 Sept 2021, 22:47 by p...@sandflow.com:
> >>
> >> > From: Pierre-Anthony Lemieux 
> >> >
> >> > Signed-off-by: Pierre-Anthony Lemieux 
> >> > ---
> >> >
> >> > Notes:
> >> >  Implements IMF Composition Playlist (CPL) parsing.
> >> >
> >> >  libavformat/imf_cpl.c | 652 ++
> >> >  1 file changed, 652 insertions(+)
> >> >  create mode 100644 libavformat/imf_cpl.c
> >> >
> >> > diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
> >> > new file mode 100644
> >> > index 00..e0c8e2c58f
> >> > --- /dev/null
> >> > +++ b/libavformat/imf_cpl.c
> >> > @@ -0,0 +1,652 @@
> >> > +/*
> >> > + * This file is part of FFmpeg.
> >> > + *
> >> > + * Copyright (c) Sandflow Consulting LLC
> >> > + *
> >> > + * Redistribution and use in source and binary forms, with or without
> >> > + * modification, are permitted provided that the following conditions 
> >> > are met:
> >> > + *
> >> > + * * Redistributions of source code must retain the above copyright 
> >> > notice, this
> >> > + *   list of conditions and the following disclaimer.
> >> > + * * Redistributions in binary form must reproduce the above copyright 
> >> > notice,
> >> > + *   this list of conditions and the following disclaimer in the 
> >> > documentation
> >> > + *   and/or other materials provided with the distribution.
> >> > + *
> >> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
> >> > "AS IS"
> >> > + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
> >> > TO, THE
> >> > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> >> > PURPOSE
> >> > + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
> >> > CONTRIBUTORS BE
> >> > + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> >> > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> >> > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
> >> > BUSINESS
> >> > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
> >> > IN
> >> > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
> >> > OTHERWISE)
> >> > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
> >> > OF THE
> >> > + * POSSIBILITY OF SUCH DAMAGE.
> >> > + */
> >> >
> >>
> >> Please use the standard file headers we use.
> >>
>
> Please don't top-post.
> libavcodec/aacdec.c's header isn't BSD. It's LGPL, like most of our code.

Oh. I think I meant libavcodec/aadec.c.

> We have a test that runs to check the header of every file in our repo,

Do you mean `make fate-source`? If so, the patch currently passes the test.

> and unfortunately, that test doesn't have a law degree. So, you have to copy
> the header verbatim from other files (which you can BSD is compatible
> with LGPL, so if you copy the author's attributions, you can) or add an 
> exception

The intent is not to add an exception, just offer the code under
2-clause BSD. Ok?

> (we generally don't, except for some optional GPL code we have).
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/5] avformat/imf: CPL processor

2021-10-05 Thread Lynne
5 Oct 2021, 17:22 by p...@sandflow.com:

> Hi Lynne,
>
> Can you be more specific?
>
> The file header we used look consistent with the header of other
> BSD-licensed files, like aacdec.c.
>
> Thanks,
>
> -- Pierre
>
> On Thu, Sep 30, 2021 at 6:40 AM Lynne  wrote:
>
>>
>> 29 Sept 2021, 22:47 by p...@sandflow.com:
>>
>> > From: Pierre-Anthony Lemieux 
>> >
>> > Signed-off-by: Pierre-Anthony Lemieux 
>> > ---
>> >
>> > Notes:
>> >  Implements IMF Composition Playlist (CPL) parsing.
>> >
>> >  libavformat/imf_cpl.c | 652 ++
>> >  1 file changed, 652 insertions(+)
>> >  create mode 100644 libavformat/imf_cpl.c
>> >
>> > diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
>> > new file mode 100644
>> > index 00..e0c8e2c58f
>> > --- /dev/null
>> > +++ b/libavformat/imf_cpl.c
>> > @@ -0,0 +1,652 @@
>> > +/*
>> > + * This file is part of FFmpeg.
>> > + *
>> > + * Copyright (c) Sandflow Consulting LLC
>> > + *
>> > + * Redistribution and use in source and binary forms, with or without
>> > + * modification, are permitted provided that the following conditions are 
>> > met:
>> > + *
>> > + * * Redistributions of source code must retain the above copyright 
>> > notice, this
>> > + *   list of conditions and the following disclaimer.
>> > + * * Redistributions in binary form must reproduce the above copyright 
>> > notice,
>> > + *   this list of conditions and the following disclaimer in the 
>> > documentation
>> > + *   and/or other materials provided with the distribution.
>> > + *
>> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
>> > "AS IS"
>> > + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
>> > THE
>> > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
>> > PURPOSE
>> > + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 
>> > BE
>> > + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>> > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
>> > BUSINESS
>> > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
>> > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
>> > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
>> > THE
>> > + * POSSIBILITY OF SUCH DAMAGE.
>> > + */
>> >
>>
>> Please use the standard file headers we use.
>>

Please don't top-post.
libavcodec/aacdec.c's header isn't BSD. It's LGPL, like most of our code.
We have a test that runs to check the header of every file in our repo,
and unfortunately, that test doesn't have a law degree. So, you have to copy
the header verbatim from other files (which you can BSD is compatible
with LGPL, so if you copy the author's attributions, you can), or add an 
exception
(we generally don't, except for some optional GPL code we have).
___
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/http: parse Content-Range responses with unknown document size

2021-10-05 Thread Aman Karmani
From: Aman Karmani 

The HTTP spec allows '*' for document size in Content-Range response headers,
to specify that the file size is unknown:

Content-Range:  -/
Content-Range:  -/*
Content-Range:  */

In the case where the filesize is unknown, this patch keeps track of a new 
fileend variable
which is the approximate size based on the range and data returned by the 
server.

Practically speaking, this patch can be used effectively "tail" a stream that is
still being appended to. For example, a PVR system may record an mpegts stream 
to disk,
and serve up the same file to players while the stream is actively being 
recorded.

By adding a `Content-Range: bytes X-Y/*` header to the response, the server can
inform the ffmpeg-based player that the stream is "active" and that the file 
size
will continue to grow. For every incoming request, the server would:

- open file handle to recording in progress
- seek file handle to offset requested by the incoming `Range` header
- query the current file size of the file
- return a `Content-Range` header with the format `bytes -/*`
- copy bytes from the file to the http socket
- on eof, wait and try reading from the file again to "tail" it as long as the 
recording is "active"

On the ffmpeg size, we simply use MAX(s->off, s->fileend) to decide how large 
the file is
whenever requested via AVSEEK_SIZE. This effectively allows ffmpeg based 
players to
watch and seek around a growing mpegts stream even while it is being appended 
to.

Signed-off-by: Aman Karmani 
---
 libavformat/http.c | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 476b9a8456..9dc0ff935d 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -68,7 +68,7 @@ typedef struct HTTPContext {
 /* Used if "Transfer-Encoding: chunked" otherwise -1. */
 uint64_t chunksize;
 int chunkend;
-uint64_t off, end_off, filesize;
+uint64_t off, end_off, filesize, fileend;
 char *location;
 HTTPAuthState auth_state;
 HTTPAuthState proxy_auth_state;
@@ -621,6 +621,7 @@ static int http_open(URLContext *h, const char *uri, int 
flags,
 h->is_streamed = 1;
 
 s->filesize = UINT64_MAX;
+s->fileend = UINT64_MAX;
 s->location = av_strdup(uri);
 if (!s->location)
 return AVERROR(ENOMEM);
@@ -750,13 +751,22 @@ static int parse_location(HTTPContext *s, const char *p)
 static void parse_content_range(URLContext *h, const char *p)
 {
 HTTPContext *s = h->priv_data;
-const char *slash;
+const char *slash, *dash;
+uint64_t range_end = UINT64_MAX;
 
 if (!strncmp(p, "bytes ", 6)) {
 p += 6;
 s->off = strtoull(p, NULL, 10);
-if ((slash = strchr(p, '/')) && strlen(slash) > 0)
-s->filesize = strtoull(slash + 1, NULL, 10);
+if ((dash = strchr(p, '-')))
+range_end = strtoll(dash + 1, NULL, 10);
+if ((slash = strchr(p, '/')) && strlen(slash) > 0) {
+if (slash[0] == '*') {
+s->fileend = range_end;
+} else {
+s->filesize = strtoull(slash + 1, NULL, 10);
+s->fileend = UINT64_MAX;
+}
+}
 }
 if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647))
 h->is_streamed = 0; /* we _can_ in fact seek */
@@ -1404,6 +1414,7 @@ static int http_connect(URLContext *h, const char *path, 
const char *local_path,
 s->off  = 0;
 s->icy_data_read= 0;
 s->filesize = UINT64_MAX;
+s->fileend  = UINT64_MAX;
 s->willclose= 0;
 s->end_chunked_post = 0;
 s->end_header   = 0;
@@ -1779,19 +1790,21 @@ static int64_t http_seek_internal(URLContext *h, 
int64_t off, int whence, int fo
 int old_buf_size, ret;
 AVDictionary *options = NULL;
 
-if (whence == AVSEEK_SIZE)
+if (whence == AVSEEK_SIZE && s->fileend != UINT64_MAX)
+return s->off > s->fileend ? s->off : s->fileend;
+else if (whence == AVSEEK_SIZE)
 return s->filesize;
 else if (!force_reconnect &&
  ((whence == SEEK_CUR && off == 0) ||
   (whence == SEEK_SET && off == s->off)))
 return s->off;
-else if ((s->filesize == UINT64_MAX && whence == SEEK_END))
+else if ((s->filesize == UINT64_MAX && s->fileend == UINT64_MAX && whence 
== SEEK_END))
 return AVERROR(ENOSYS);
 
 if (whence == SEEK_CUR)
 off += s->off;
 else if (whence == SEEK_END)
-off += s->filesize;
+off += s->fileend > 0 ? s->fileend : s->filesize;
 else if (whence != SEEK_SET)
 return AVERROR(EINVAL);
 if (off < 0)
-- 
2.33.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 v2 1/1] avformat: Add probe_streams option

2021-10-05 Thread Nicolas Gaullier
Allow user to disable codec probing:
- spdif (and s337m incl. s-adm in the future) is not sub-demuxed and
  may pass-through to a muxer
- disable any stream probing in wav files (dts detection).
- mpeg-ts files missing PAT/PMT are considered invalid.

Signed-off-by: Nicolas Gaullier 
---
 doc/formats.texi|  3 +++
 libavformat/avformat.h  |  9 +
 libavformat/mpeg.c  |  5 +++--
 libavformat/mpegts.c| 10 ++
 libavformat/options_table.h |  1 +
 libavformat/version.h   |  4 ++--
 libavformat/wavdec.c|  8 +---
 7 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/doc/formats.texi b/doc/formats.texi
index 640b23b790..272a6a71e7 100644
--- a/doc/formats.texi
+++ b/doc/formats.texi
@@ -27,6 +27,9 @@ stream information. A higher value will enable detecting more
 information in case it is dispersed into the stream, but will increase
 latency. Must be an integer not lesser than 32. It is 500 by default.
 
+@item probe_streams @var{bool} (@emph{input})
+Enable codec probing if set to 1. Default is 1.
+
 @item max_probe_packets @var{integer} (@emph{input})
 Set the maximum number of buffered packets when probing a codec.
 Default is 2500 packets.
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index a2af7e9f89..daf37420d0 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1702,6 +1702,15 @@ typedef struct AVFormatContext {
  * - decoding: set by user
  */
 int max_probe_packets;
+
+/**
+ * Enable codec probing.
+ * When disabled: always trust the descriptors and allows pass-through of 
data such as spdif.
+ * @note mpegts missing PAT/PMT are considered invalid if codec probing is 
disabled.
+ * - encoding: unused
+ * - decoding: set by user
+ */
+int probe_streams;
 } AVFormatContext;
 
 /**
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index ca15d9f241..f795a258d6 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -557,7 +557,7 @@ redo:
 avio_seek(s->pb, -8, SEEK_CUR);
 if (!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
 codec_id = AV_CODEC_ID_CAVS;
-else
+else if (s->probe_streams)
 request_probe= 1;
 type = AVMEDIA_TYPE_VIDEO;
 } else if (startcode == PRIVATE_STREAM_2) {
@@ -568,7 +568,8 @@ redo:
 if (m->sofdec > 0) {
 codec_id = AV_CODEC_ID_ADPCM_ADX;
 // Auto-detect AC-3
-request_probe = 50;
+if (s->probe_streams)
+request_probe = 50;
 } else if (m->imkh_cctv && startcode == 0x1c0 && len > 80) {
 codec_id = AV_CODEC_ID_PCM_ALAW;
 request_probe = 50;
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index da8eee2414..bf7c6554ea 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -917,7 +917,7 @@ static int mpegts_set_stream_info(AVStream *st, PESContext 
*pes,
 st->codecpar->codec_tag = pes->stream_type;
 
 mpegts_find_stream_type(st, pes->stream_type, ISO_types);
-if (pes->stream_type == 4 || pes->stream_type == 0x0f)
+if (pes->stream->probe_streams && (pes->stream_type == 4 || 
pes->stream_type == 0x0f))
 sti->request_probe = 50;
 if ((prog_reg_desc == AV_RL32("HDMV") ||
  prog_reg_desc == AV_RL32("HDPR")) &&
@@ -960,7 +960,8 @@ static int mpegts_set_stream_info(AVStream *st, PESContext 
*pes,
 stream_type == STREAM_TYPE_PRIVATE_DATA) {
 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
 st->codecpar->codec_id   = AV_CODEC_ID_BIN_DATA;
-sti->request_probe = AVPROBE_SCORE_STREAM_RETRY / 5;
+if (pes->stream->probe_streams)
+sti->request_probe = AVPROBE_SCORE_STREAM_RETRY / 5;
 }
 
 /* queue a context update if properties changed */
@@ -1202,7 +1203,8 @@ static int mpegts_push_data(MpegTSFilter *filter,
 code != 0x1f8) {  /* ITU-T Rec. 
H.222.1 type E stream */
 FFStream *const pes_sti = ffstream(pes->st);
 pes->state = MPEGTS_PESHEADER;
-if (pes->st->codecpar->codec_id == AV_CODEC_ID_NONE && 
!pes_sti->request_probe) {
+if (pes->stream->probe_streams &&
+pes->st->codecpar->codec_id == AV_CODEC_ID_NONE && 
!pes_sti->request_probe) {
 av_log(pes->stream, AV_LOG_TRACE,
 "pid=%x stream_type=%x probing\n",
 pes->pid,
@@ -2001,7 +2003,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 av_log(fc, AV_LOG_TRACE, "reg_desc=%.4s\n", (char 
*)&st->codecpar->codec_tag);
 if (st->codecpar->codec_id == AV_CODEC_ID_NONE || sti->request_probe > 
0) {
 mpegts_find_stream_type(st, st->codecpar->codec_tag, REGD_types);
-if (st->codecpar->codec_

[FFmpeg-devel] [PATCH v2 0/1] Add-probe_streams-option

2021-10-05 Thread Nicolas Gaullier
This V2 is just a rebase. See my post yesterday for details.

Nicolas Gaullier (1):
  avformat: Add probe_streams option

 doc/formats.texi|  3 +++
 libavformat/avformat.h  |  9 +
 libavformat/mpeg.c  |  5 +++--
 libavformat/mpegts.c| 10 ++
 libavformat/options_table.h |  1 +
 libavformat/version.h   |  4 ++--
 libavformat/wavdec.c|  8 +---
 7 files changed, 29 insertions(+), 11 deletions(-)

-- 
2.27.0.windows.1

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/amr_parser: passthrough if channels is unknown

2021-10-05 Thread Paul B Mahol
On Tue, Oct 5, 2021 at 11:03 PM James Almer  wrote:

> On 10/5/2021 5:51 PM, Michael Niedermayer wrote:
> > Fixes: division by 0
> > Fixes:
> 39562/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-5448834960982016
> > Fixes:
> 39589/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-6119205334810624
> >
> > Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >   libavcodec/amr_parser.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/amr_parser.c b/libavcodec/amr_parser.c
> > index 79258d4d0cf..9fb7711fee0 100644
> > --- a/libavcodec/amr_parser.c
> > +++ b/libavcodec/amr_parser.c
> > @@ -62,7 +62,7 @@ static int amr_parse(AVCodecParserContext *s1,
> >   *poutbuf_size = 0;
> >   *poutbuf = NULL;
> >
> > -if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
> > +if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES || !avctx->channels) {
>
> No line in the parser divides by avctx->channels. There's however one
> doing a modulo avctx->channels. Wouldn't this mean the compiler is being
> overzealous with optimizations?
>
> Also, instead of this please do the same as the decoder, and set
> channels to 1 and layout to mono if nothing is already set. Forcing the
> "complete frames" path when no channels are set feels like a hacky
> workaround.
> If the relevant parser flag is not set, then you must not treat packets
> as if they contained complete frames.
>

Agreed also with that solution.


>
> >   next = buf_size;
> >   } else {
> >   int ch, offset = 0;
> >
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avcodec/amr_parser: passthrough if channels is unknown

2021-10-05 Thread James Almer

On 10/5/2021 5:51 PM, Michael Niedermayer wrote:

Fixes: division by 0
Fixes: 
39562/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-5448834960982016
Fixes: 
39589/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-6119205334810624

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

diff --git a/libavcodec/amr_parser.c b/libavcodec/amr_parser.c
index 79258d4d0cf..9fb7711fee0 100644
--- a/libavcodec/amr_parser.c
+++ b/libavcodec/amr_parser.c
@@ -62,7 +62,7 @@ static int amr_parse(AVCodecParserContext *s1,
  *poutbuf_size = 0;
  *poutbuf = NULL;
  
-if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {

+if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES || !avctx->channels) {


No line in the parser divides by avctx->channels. There's however one 
doing a modulo avctx->channels. Wouldn't this mean the compiler is being 
overzealous with optimizations?


Also, instead of this please do the same as the decoder, and set 
channels to 1 and layout to mono if nothing is already set. Forcing the 
"complete frames" path when no channels are set feels like a hacky 
workaround.
If the relevant parser flag is not set, then you must not treat packets 
as if they contained complete frames.



  next = buf_size;
  } else {
  int ch, offset = 0;



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

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


Re: [FFmpeg-devel] [PATCH] avcodec/amr_parser: passthrough if channels is unknown

2021-10-05 Thread Paul B Mahol
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".


[FFmpeg-devel] [PATCH 8/8] avfilter/vf_thumbnail_cuda: Reindent after the previous commit

2021-10-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_thumbnail_cuda.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vf_thumbnail_cuda.c b/libavfilter/vf_thumbnail_cuda.c
index 7c86203227..c8dd905123 100644
--- a/libavfilter/vf_thumbnail_cuda.c
+++ b/libavfilter/vf_thumbnail_cuda.c
@@ -304,27 +304,26 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 
 static av_cold void uninit(AVFilterContext *ctx)
 {
-int i;
 ThumbnailCudaContext *s = ctx->priv;
 
 if (s->hwctx) {
-CudaFunctions *cu = s->hwctx->internal->cuda_dl;
+CudaFunctions *cu = s->hwctx->internal->cuda_dl;
 
-if (s->data) {
-CHECK_CU(cu->cuMemFree(s->data));
-s->data = 0;
-}
+if (s->data) {
+CHECK_CU(cu->cuMemFree(s->data));
+s->data = 0;
+}
 
-if (s->cu_module) {
-CHECK_CU(cu->cuModuleUnload(s->cu_module));
-s->cu_module = NULL;
-}
+if (s->cu_module) {
+CHECK_CU(cu->cuModuleUnload(s->cu_module));
+s->cu_module = NULL;
+}
 }
 
 if (s->frames) {
-for (i = 0; i < s->n_frames && s->frames[i].buf; i++)
-av_frame_free(&s->frames[i].buf);
-av_freep(&s->frames);
+for (int i = 0; i < s->n_frames && s->frames[i].buf; i++)
+av_frame_free(&s->frames[i].buf);
+av_freep(&s->frames);
 }
 }
 
-- 
2.30.2

___
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 7/8] avfilter/vf_thumbnail_cuda: Fix segfaults on uninit

2021-10-05 Thread Andreas Rheinhardt
Uninit crashed if an array containing frames could not be allocated
or config_props() has never been called.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_thumbnail_cuda.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/vf_thumbnail_cuda.c b/libavfilter/vf_thumbnail_cuda.c
index 491542c60a..7c86203227 100644
--- a/libavfilter/vf_thumbnail_cuda.c
+++ b/libavfilter/vf_thumbnail_cuda.c
@@ -306,6 +306,8 @@ static av_cold void uninit(AVFilterContext *ctx)
 {
 int i;
 ThumbnailCudaContext *s = ctx->priv;
+
+if (s->hwctx) {
 CudaFunctions *cu = s->hwctx->internal->cuda_dl;
 
 if (s->data) {
@@ -317,10 +319,13 @@ static av_cold void uninit(AVFilterContext *ctx)
 CHECK_CU(cu->cuModuleUnload(s->cu_module));
 s->cu_module = NULL;
 }
+}
 
+if (s->frames) {
 for (i = 0; i < s->n_frames && s->frames[i].buf; i++)
 av_frame_free(&s->frames[i].buf);
 av_freep(&s->frames);
+}
 }
 
 static int request_frame(AVFilterLink *link)
-- 
2.30.2

___
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/8] avfilter/tests/filtfmts: Check for existence of formats/channel layouts

2021-10-05 Thread Andreas Rheinhardt
Fixes segfaults with filters that either return AVERROR(EAGAIN)
(or another error) or that do not set everything and rely on
filter_query_formats() to set the rest.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/tests/filtfmts.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/tests/filtfmts.c b/libavfilter/tests/filtfmts.c
index 07e387b92e..d793480344 100644
--- a/libavfilter/tests/filtfmts.c
+++ b/libavfilter/tests/filtfmts.c
@@ -43,7 +43,7 @@ static void print_formats_internal(AVFilterLink **links, 
const AVFilterPad *pads
 
 if (link->type == AVMEDIA_TYPE_VIDEO) {
 const AVFilterFormats *const fmts = cfg->formats;
-for (unsigned j = 0; j < fmts->nb_formats; j++) {
+for (unsigned j = 0; fmts && j < fmts->nb_formats; j++) {
 printf("%s[%u] %s: fmt:%s\n",
 inout_string, i, pad_name,
 av_get_pix_fmt_name(fmts->formats[j]));
@@ -52,12 +52,12 @@ static void print_formats_internal(AVFilterLink **links, 
const AVFilterPad *pads
 const AVFilterFormats *const fmts = cfg->formats;
 const AVFilterChannelLayouts *const layouts = cfg->channel_layouts;
 
-for (unsigned j = 0; j < fmts->nb_formats; j++)
+for (unsigned j = 0; fmts && j < fmts->nb_formats; j++)
 printf("%s[%u] %s: fmt:%s\n",
inout_string, i, pad_name,
av_get_sample_fmt_name(fmts->formats[j]));
 
-for (unsigned j = 0; j < layouts->nb_channel_layouts; j++) {
+for (unsigned j = 0; layouts && j < layouts->nb_channel_layouts; 
j++) {
 char buf[256];
 av_get_channel_layout_string(buf, sizeof(buf), -1,
  layouts->channel_layouts[j]);
-- 
2.30.2

___
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/8] avfilter/vf_scale: Reindentation

2021-10-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_scale.c | 45 +-
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 993fd18620..44f85cb019 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -341,34 +341,35 @@ static av_cold void uninit(AVFilterContext *ctx)
 static int query_formats(AVFilterContext *ctx)
 {
 AVFilterFormats *formats;
+const AVPixFmtDescriptor *desc;
 enum AVPixelFormat pix_fmt;
 int ret;
 
-const AVPixFmtDescriptor *desc = NULL;
-formats = NULL;
-while ((desc = av_pix_fmt_desc_next(desc))) {
-pix_fmt = av_pix_fmt_desc_get_id(desc);
-if ((sws_isSupportedInput(pix_fmt) ||
- sws_isSupportedEndiannessConversion(pix_fmt))
-&& (ret = ff_add_format(&formats, pix_fmt)) < 0) {
-return ret;
-}
-}
-if ((ret = ff_formats_ref(formats, &ctx->inputs[0]->outcfg.formats)) < 
0)
+desc= NULL;
+formats = NULL;
+while ((desc = av_pix_fmt_desc_next(desc))) {
+pix_fmt = av_pix_fmt_desc_get_id(desc);
+if ((sws_isSupportedInput(pix_fmt) ||
+ sws_isSupportedEndiannessConversion(pix_fmt))
+&& (ret = ff_add_format(&formats, pix_fmt)) < 0) {
 return ret;
-
-desc= NULL;
-formats = NULL;
-while ((desc = av_pix_fmt_desc_next(desc))) {
-pix_fmt = av_pix_fmt_desc_get_id(desc);
-if ((sws_isSupportedOutput(pix_fmt) || pix_fmt == AV_PIX_FMT_PAL8 
||
- sws_isSupportedEndiannessConversion(pix_fmt))
-&& (ret = ff_add_format(&formats, pix_fmt)) < 0) {
-return ret;
-}
 }
-if ((ret = ff_formats_ref(formats, &ctx->outputs[0]->incfg.formats)) < 
0)
+}
+if ((ret = ff_formats_ref(formats, &ctx->inputs[0]->outcfg.formats)) < 0)
+return ret;
+
+desc= NULL;
+formats = NULL;
+while ((desc = av_pix_fmt_desc_next(desc))) {
+pix_fmt = av_pix_fmt_desc_get_id(desc);
+if ((sws_isSupportedOutput(pix_fmt) || pix_fmt == AV_PIX_FMT_PAL8 ||
+ sws_isSupportedEndiannessConversion(pix_fmt))
+&& (ret = ff_add_format(&formats, pix_fmt)) < 0) {
 return ret;
+}
+}
+if ((ret = ff_formats_ref(formats, &ctx->outputs[0]->incfg.formats)) < 0)
+return ret;
 
 return 0;
 }
-- 
2.30.2

___
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/8] avfilter/vf_scale: Remove always-true checks

2021-10-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_scale.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 5411289894..993fd18620 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -344,7 +344,6 @@ static int query_formats(AVFilterContext *ctx)
 enum AVPixelFormat pix_fmt;
 int ret;
 
-if (ctx->inputs[0]) {
 const AVPixFmtDescriptor *desc = NULL;
 formats = NULL;
 while ((desc = av_pix_fmt_desc_next(desc))) {
@@ -357,9 +356,8 @@ static int query_formats(AVFilterContext *ctx)
 }
 if ((ret = ff_formats_ref(formats, &ctx->inputs[0]->outcfg.formats)) < 
0)
 return ret;
-}
-if (ctx->outputs[0]) {
-const AVPixFmtDescriptor *desc = NULL;
+
+desc= NULL;
 formats = NULL;
 while ((desc = av_pix_fmt_desc_next(desc))) {
 pix_fmt = av_pix_fmt_desc_get_id(desc);
@@ -371,7 +369,6 @@ static int query_formats(AVFilterContext *ctx)
 }
 if ((ret = ff_formats_ref(formats, &ctx->outputs[0]->incfg.formats)) < 
0)
 return ret;
-}
 
 return 0;
 }
-- 
2.30.2

___
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/8] avfilter/vf_transpose: Don't call av_pix_fmt_desc_get() twice

2021-10-05 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_transpose.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index b0354b938f..f9f0d70cd5 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -55,10 +55,10 @@ typedef struct TransContext {
 static int query_formats(AVFilterContext *ctx)
 {
 AVFilterFormats *pix_fmts = NULL;
+const AVPixFmtDescriptor *desc;
 int fmt, ret;
 
-for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+for (fmt = 0; desc = av_pix_fmt_desc_get(fmt); fmt++) {
 if (!(desc->flags & AV_PIX_FMT_FLAG_PAL ||
   desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
   desc->flags & AV_PIX_FMT_FLAG_BITSTREAM ||
-- 
2.30.2

___
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/8] examples/remuxing: Fix use of uninitialized value

2021-10-05 Thread Andreas Rheinhardt
Fixes Coverity ticket 1492326.
Regression since 53f374c08d5cc97158c17ea34b1c8ee0116c0578.

Signed-off-by: Andreas Rheinhardt 
---
Sorry for this.

 doc/examples/remuxing.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/examples/remuxing.c b/doc/examples/remuxing.c
index 9ded91..2657f9dc66 100644
--- a/doc/examples/remuxing.c
+++ b/doc/examples/remuxing.c
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
 pkt = av_packet_alloc();
 if (!pkt) {
 fprintf(stderr, "Could not allocate AVPacket\n");
-goto end;
+return 1;
 }
 
 if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
-- 
2.30.2

___
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/amr_parser: passthrough if channels is unknown

2021-10-05 Thread Michael Niedermayer
Fixes: division by 0
Fixes: 
39562/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-5448834960982016
Fixes: 
39589/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-6119205334810624

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

diff --git a/libavcodec/amr_parser.c b/libavcodec/amr_parser.c
index 79258d4d0cf..9fb7711fee0 100644
--- a/libavcodec/amr_parser.c
+++ b/libavcodec/amr_parser.c
@@ -62,7 +62,7 @@ static int amr_parse(AVCodecParserContext *s1,
 *poutbuf_size = 0;
 *poutbuf = NULL;
 
-if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES || !avctx->channels) {
 next = buf_size;
 } else {
 int ch, offset = 0;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 1/8] avfilter/tests/filtfmts: Replace macro by ordinary function

2021-10-05 Thread Andreas Rheinhardt
This is possible now that AVFilterFormatsConfig exists.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/tests/filtfmts.c | 77 
 1 file changed, 42 insertions(+), 35 deletions(-)

diff --git a/libavfilter/tests/filtfmts.c b/libavfilter/tests/filtfmts.c
index 55bb64abc5..07e387b92e 100644
--- a/libavfilter/tests/filtfmts.c
+++ b/libavfilter/tests/filtfmts.c
@@ -32,43 +32,50 @@
 #include "libavfilter/formats.h"
 #include "libavfilter/internal.h"
 
+static void print_formats_internal(AVFilterLink **links, const AVFilterPad 
*pads,
+   unsigned nb, size_t fmts_cfg_offset,
+   const char *inout_string)
+{
+for (unsigned i = 0; i < nb; i++) {
+const AVFilterLink *const link = links[i];
+const AVFilterFormatsConfig *const cfg = 
(AVFilterFormatsConfig*)((const char*)link + fmts_cfg_offset);
+const char *pad_name = avfilter_pad_get_name(pads, i);
+
+if (link->type == AVMEDIA_TYPE_VIDEO) {
+const AVFilterFormats *const fmts = cfg->formats;
+for (unsigned j = 0; j < fmts->nb_formats; j++) {
+printf("%s[%u] %s: fmt:%s\n",
+inout_string, i, pad_name,
+av_get_pix_fmt_name(fmts->formats[j]));
+}
+} else if (link->type == AVMEDIA_TYPE_AUDIO) {
+const AVFilterFormats *const fmts = cfg->formats;
+const AVFilterChannelLayouts *const layouts = cfg->channel_layouts;
+
+for (unsigned j = 0; j < fmts->nb_formats; j++)
+printf("%s[%u] %s: fmt:%s\n",
+   inout_string, i, pad_name,
+   av_get_sample_fmt_name(fmts->formats[j]));
+
+for (unsigned j = 0; j < layouts->nb_channel_layouts; j++) {
+char buf[256];
+av_get_channel_layout_string(buf, sizeof(buf), -1,
+ layouts->channel_layouts[j]);
+printf("%s[%u] %s: chlayout:%s\n",
+   inout_string, i, pad_name, buf);
+}
+}
+}
+}
+
 static void print_formats(AVFilterContext *filter_ctx)
 {
-int i, j;
-
-#define PRINT_FMTS(inout, outin, INOUT) \
-for (i = 0; i < filter_ctx->nb_##inout##puts; i++) { \
-if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) {   \
-AVFilterFormats *fmts = \
-filter_ctx->inout##puts[i]->outin##cfg.formats;\
-for (j = 0; j < fmts->nb_formats; j++)\
-if(av_get_pix_fmt_name(fmts->formats[j]))   \
-printf(#INOUT "PUT[%d] %s: fmt:%s\n",   \
-   i, avfilter_pad_get_name(filter_ctx->inout##put_pads, 
i),  \
-   av_get_pix_fmt_name(fmts->formats[j]));  \
-} else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \
-AVFilterFormats *fmts;  \
-AVFilterChannelLayouts *layouts;\
-\
-fmts = filter_ctx->inout##puts[i]->outin##cfg.formats; \
-for (j = 0; j < fmts->nb_formats; j++)\
-printf(#INOUT "PUT[%d] %s: fmt:%s\n",   \
-   i, avfilter_pad_get_name(filter_ctx->inout##put_pads, 
i),  \
-   av_get_sample_fmt_name(fmts->formats[j]));   \
-\
-layouts = filter_ctx->inout##puts[i]->outin##cfg.channel_layouts; \
-for (j = 0; j < layouts->nb_channel_layouts; j++) {
  \
-char buf[256];  \
-av_get_channel_layout_string(buf, sizeof(buf), -1,  \
- layouts->channel_layouts[j]); 
\
-printf(#INOUT "PUT[%d] %s: chlayout:%s\n",  \
-   i, avfilter_pad_get_name(filter_ctx->inout##put_pads, 
i), buf); \
-}   \
-}   \
-}   \
-
-PRINT_FMTS(in,  out, IN);
-PRINT_FMTS(out, in,  OUT);
+print_formats_internal(filter_ctx->inputs, filter_ctx->input_pads,
+   filter_ctx->nb_inputs,
+   offsetof(AVFilterLink, outcfg), "INPUT");
+print_formats_internal(filter_ctx->outputs, filter_ctx->output_pads,
+   filter_ctx->nb_outputs,
+   offsetof(

Re: [FFmpeg-devel] [PATCH] avcodec/rasc: Fix potential use of uninitialized value

2021-10-05 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Fixes Coverity issue #1439566.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/rasc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
> index 7fedf73878..b328e219bb 100644
> --- a/libavcodec/rasc.c
> +++ b/libavcodec/rasc.c
> @@ -721,6 +721,7 @@ static int decode_frame(AVCodecContext *avctx,
>  break;
>  default:
>  bytestream2_skip(gb, size);
> +ret = 0;
>  }
>  
>  if (ret < 0)
> 

Will apply later tonight unless there are objections.

- 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 4/4] libavfilter/vf_avgblur_vulkan: fix incorrect conditional judgement

2021-10-05 Thread Wu Jianhua
Jianhua wrote:

> Signed-off-by: Wu Jianhua  intel.com>

> ---

>  libavfilter/vf_avgblur_vulkan.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c

> index 1e485061cd..2dbfc947a8 100644

> --- a/libavfilter/vf_avgblur_vulkan.c

> +++ b/libavfilter/vf_avgblur_vulkan.c

> @@ -333,7 +333,7 @@ static int avgblur_vulkan_filter_frame(AVFilterLink 
> *link, AVFrame *in)

>  }

>

>  tmp = ff_get_video_buffer(outlink, outlink->w, outlink->h);

> -if (!out) {

> +if (!tmp) {

>  err = AVERROR(ENOMEM);

>  goto fail;

>  }

> --

> 2.17.1

Hi there,

This patch is a common fix. Could it be applied separately?

Thanks,
Jianhua


___
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/5] avformat/imf: CPL processor

2021-10-05 Thread Pierre-Anthony Lemieux
Hi Lynne,

Can you be more specific?

The file header we used look consistent with the header of other
BSD-licensed files, like aacdec.c.

Thanks,

-- Pierre

On Thu, Sep 30, 2021 at 6:40 AM Lynne  wrote:
>
> 29 Sept 2021, 22:47 by p...@sandflow.com:
>
> > From: Pierre-Anthony Lemieux 
> >
> > Signed-off-by: Pierre-Anthony Lemieux 
> > ---
> >
> > Notes:
> >  Implements IMF Composition Playlist (CPL) parsing.
> >
> >  libavformat/imf_cpl.c | 652 ++
> >  1 file changed, 652 insertions(+)
> >  create mode 100644 libavformat/imf_cpl.c
> >
> > diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
> > new file mode 100644
> > index 00..e0c8e2c58f
> > --- /dev/null
> > +++ b/libavformat/imf_cpl.c
> > @@ -0,0 +1,652 @@
> > +/*
> > + * This file is part of FFmpeg.
> > + *
> > + * Copyright (c) Sandflow Consulting LLC
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions are 
> > met:
> > + *
> > + * * Redistributions of source code must retain the above copyright 
> > notice, this
> > + *   list of conditions and the following disclaimer.
> > + * * Redistributions in binary form must reproduce the above copyright 
> > notice,
> > + *   this list of conditions and the following disclaimer in the 
> > documentation
> > + *   and/or other materials provided with the distribution.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> > IS"
> > + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
> > THE
> > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> > PURPOSE
> > + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 
> > BE
> > + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
> > THE
> > + * POSSIBILITY OF SUCH DAMAGE.
> > + */
> >
>
> Please use the standard file headers we use.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 004/218] avfilter: Replace query_formats callback with union of list and callback

2021-10-05 Thread Nicolas George
Andreas Rheinhardt (12021-09-30):
> If one looks at the many query_formats callbacks in existence,
> one will immediately recognize that there is one type of default
> callback for video and a slightly different default callback for
> audio: It is "return ff_set_common_formats_from_list(ctx, pix_fmts);"
> for video with a filter-specific pix_fmts list. For audio, it is
> the same with a filter-specific sample_fmts list together with
> ff_set_common_all_samplerates() and ff_set_common_all_channel_counts().
> 
> This commit allows to remove the boilerplate query_formats callbacks
> by replacing said callback with a union consisting the old callback
> and pointers for pixel and sample format arrays. For the not uncommon
> case in which these lists only contain a single entry (besides the
> sentinel) enum AVPixelFormat and enum AVSampleFormat fields are also
> added to the union to store them directly in the AVFilter,
> thereby avoiding a relocation.
> 
> The state of said union will be contained in a new, dedicated AVFilter
> field (the nb_inputs and nb_outputs fields have been shrunk to uint8_t
> in order to create a hole for this new field; this is no problem, as
> the maximum of all the nb_inputs is four; for nb_outputs it is only
> two).
> 
> The state's default value coincides with the earlier default of
> query_formats being unset, namely that the filter accepts all formats
> (and also sample rates and channel counts/layouts for audio)
> provided that these properties agree coincide for all inputs and
> outputs.
> 
> By using different union members for audio and video filters
> the type-unsafety of using the same functions for audio and video
> lists will furthermore be more confined to formats.c than before.
> 
> When the new fields are used, they will also avoid allocations:
> Currently something nearly equivalent to ff_default_query_formats()
> is called after every successful call to a query_formats callback;
> yet in the common case that the newly allocated AVFilterFormats
> are not used at all (namely if there are no free links) these newly
> allocated AVFilterFormats are freed again without ever being used.
> Filters no longer using the callback will not exhibit this any more.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> This patchset here aims to remove boilerplate code from the
> query-formats API. Despite touching lots of filters, there should be
> only very few conflicts (if at all) with Nicolas' earlier patch [1].
> The reason for this is that the filters touched here typically only
> use ff_set_common_* functions, which are unaffected by his change.

I do not like the aesthetics of this very much, but it is a useful
change.

I have not looked at each individual filter change, but they are
straightforward.

So ok for my part.

Regards,

-- 
  Nicolas George


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 003/218] avfilter/formats: Add function to create AVFilterFormats with one entry

2021-10-05 Thread Nicolas George
Andreas Rheinhardt (12021-09-30):
> Most instances ff_add_formats() actually only ever add one format;
> this function can be used to simplify those callers.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavfilter/formats.c | 6 ++
>  libavfilter/formats.h | 6 ++
>  2 files changed, 12 insertions(+)

Even if there is only one, it is still a formats list, and the name of
the function should reflect it; "make_format", singular, is not clear.
ff_make_formats_list_single() maybe?

Regards,

-- 
  Nicolas George


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

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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/wmaprodec: Do not initialize unused variable to out of array value

2021-10-05 Thread Paul B Mahol
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".