[FFmpeg-devel] [PATCH 1/4] lavf: matroska subtitle muxer

2020-05-28 Thread rcombs
---
 configure |  1 +
 libavformat/allformats.c  |  1 +
 libavformat/matroskaenc.c | 30 ++
 libavformat/version.h |  2 +-
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 8569a60bf8..9929c29006 100755
--- a/configure
+++ b/configure
@@ -3305,6 +3305,7 @@ ismv_muxer_select="mov_muxer"
 ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
 latm_muxer_select="aac_adtstoasc_bsf"
 matroska_audio_muxer_select="matroska_muxer"
+matroska_subtitle_muxer_select="matroska_muxer"
 matroska_demuxer_select="iso_media riffdec"
 matroska_demuxer_suggest="bzlib lzo zlib"
 matroska_muxer_select="iso_media riffenc vp9_superframe_bsf aac_adtstoasc_bsf"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3919c9e4c1..1bae208195 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -233,6 +233,7 @@ extern AVOutputFormat ff_md5_muxer;
 extern AVInputFormat  ff_matroska_demuxer;
 extern AVOutputFormat ff_matroska_muxer;
 extern AVOutputFormat ff_matroska_audio_muxer;
+extern AVOutputFormat ff_matroska_subtitle_muxer;
 extern AVInputFormat  ff_mgsts_demuxer;
 extern AVInputFormat  ff_microdvd_demuxer;
 extern AVOutputFormat ff_microdvd_muxer;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1c1ea71f59..1f7a9528de 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2891,3 +2891,33 @@ AVOutputFormat ff_matroska_audio_muxer = {
 .priv_class= &mka_class,
 };
 #endif
+
+#if CONFIG_MATROSKA_SUBTITLE_MUXER
+static const AVClass mks_class = {
+.class_name = "matroska subtitle muxer",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+AVOutputFormat ff_matroska_subtitle_muxer = {
+.name  = "matroska",
+.long_name = NULL_IF_CONFIG_SMALL("Matroska Subtitle"),
+.extensions= "mks",
+.priv_data_size= sizeof(MatroskaMuxContext),
+.audio_codec   = AV_CODEC_ID_NONE,
+.video_codec   = AV_CODEC_ID_NONE,
+.subtitle_codec= AV_CODEC_ID_ASS,
+.init  = mkv_init,
+.deinit= mkv_deinit,
+.write_header  = mkv_write_header,
+.write_packet  = mkv_write_flush_packet,
+.write_trailer = mkv_write_trailer,
+.check_bitstream   = mkv_check_bitstream,
+.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT |
+ AVFMT_ALLOW_FLUSH,
+.codec_tag = (const AVCodecTag* const []){
+ additional_subtitle_tags, 0
+},
+.priv_class= &mks_class,
+};
+#endif
diff --git a/libavformat/version.h b/libavformat/version.h
index 493a0b337f..e0135fc7d3 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  43
+#define LIBAVFORMAT_VERSION_MINOR  44
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.26.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/4] lavf/matroskadec: support standard (non-WebM) WebVTT formatting

2020-05-28 Thread rcombs
Fixes ticket #5641
---
 libavformat/matroska.c|  11 ++--
 libavformat/matroskadec.c | 111 --
 2 files changed, 77 insertions(+), 45 deletions(-)

diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 7c56aba403..962fa496f4 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -60,16 +60,12 @@ const CodecTags ff_mkv_codec_tags[]={
 {"A_VORBIS" , AV_CODEC_ID_VORBIS},
 {"A_WAVPACK4"   , AV_CODEC_ID_WAVPACK},
 
-{"D_WEBVTT/SUBTITLES"   , AV_CODEC_ID_WEBVTT},
-{"D_WEBVTT/CAPTIONS", AV_CODEC_ID_WEBVTT},
-{"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT},
-{"D_WEBVTT/METADATA", AV_CODEC_ID_WEBVTT},
-
 {"S_TEXT/UTF8"  , AV_CODEC_ID_SUBRIP},
 {"S_TEXT/UTF8"  , AV_CODEC_ID_TEXT},
 {"S_TEXT/ASCII" , AV_CODEC_ID_TEXT},
 {"S_TEXT/ASS"   , AV_CODEC_ID_ASS},
 {"S_TEXT/SSA"   , AV_CODEC_ID_ASS},
+{"S_TEXT/WEBVTT", AV_CODEC_ID_WEBVTT},
 {"S_ASS", AV_CODEC_ID_ASS},
 {"S_SSA", AV_CODEC_ID_ASS},
 {"S_VOBSUB" , AV_CODEC_ID_DVD_SUBTITLE},
@@ -77,6 +73,11 @@ const CodecTags ff_mkv_codec_tags[]={
 {"S_HDMV/PGS"   , AV_CODEC_ID_HDMV_PGS_SUBTITLE},
 {"S_HDMV/TEXTST", AV_CODEC_ID_HDMV_TEXT_SUBTITLE},
 
+{"D_WEBVTT/SUBTITLES"   , AV_CODEC_ID_WEBVTT},
+{"D_WEBVTT/CAPTIONS", AV_CODEC_ID_WEBVTT},
+{"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT},
+{"D_WEBVTT/METADATA", AV_CODEC_ID_WEBVTT},
+
 {"V_AV1", AV_CODEC_ID_AV1},
 {"V_DIRAC"  , AV_CODEC_ID_DIRAC},
 {"V_FFV1"   , AV_CODEC_ID_FFV1},
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index bb3a126c29..1170f57be3 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3306,62 +3306,81 @@ static int matroska_parse_webvtt(MatroskaDemuxContext 
*matroska,
  uint8_t *data, int data_len,
  uint64_t timecode,
  uint64_t duration,
- int64_t pos)
+ int64_t pos,
+ uint8_t *additional, uint64_t additional_id, 
int additional_size)
 {
 AVPacket pktl, *pkt = &pktl;
-uint8_t *id, *settings, *text, *buf;
-int id_len, settings_len, text_len;
+uint8_t *id, *settings, *comment, *text, *buf;
+int id_len = 0, settings_len = 0, comment_len = 0, text_len;
 uint8_t *p, *q;
 int err;
+int webm_style = !strncmp(track->codec_id, "D_WEBVTT/", 9);
 
 if (data_len <= 0)
 return AVERROR_INVALIDDATA;
 
-p = data;
-q = data + data_len;
-
-id = p;
-id_len = -1;
-while (p < q) {
-if (*p == '\r' || *p == '\n') {
-id_len = p - id;
-if (*p == '\r')
-p++;
-break;
+p = webm_style ? data : additional;
+q = webm_style ? (data + data_len) : (additional + additional_size);
+
+if (p) {
+id = p;
+id_len = -1;
+while (p < q) {
+if (*p == '\r' || *p == '\n') {
+id_len = p - id;
+if (*p == '\r')
+p++;
+break;
+}
+p++;
 }
+
+if (p >= q || *p != '\n')
+return AVERROR_INVALIDDATA;
 p++;
-}
 
-if (p >= q || *p != '\n')
-return AVERROR_INVALIDDATA;
-p++;
-
-settings = p;
-settings_len = -1;
-while (p < q) {
-if (*p == '\r' || *p == '\n') {
-settings_len = p - settings;
-if (*p == '\r')
-p++;
-break;
+settings = p;
+settings_len = -1;
+while (p < q) {
+if (*p == '\r' || *p == '\n') {
+settings_len = p - settings;
+if (*p == '\r')
+p++;
+break;
+}
+p++;
 }
+
+if (p >= q || *p != '\n')
+return AVERROR_INVALIDDATA;
 p++;
+
+if (!webm_style && p < q) {
+if (q[-1] != '\r' && q[-1] != '\n')
+return AVERROR_INVALIDDATA;
+
+comment = p;
+comment_len = q - p;
+}
 }
 
-if (p >= q || *p != '\n')
-return AVERROR_INVALIDDATA;
-p++;
-
-text = p;
-text_len = q - p;
-while (text_len > 0) {
-const int len = text_len - 1;
-const uint8_t c = p[len];
-if (c != '\r' && c != '\n')
-break;
-text_len = len;
+if (webm_style) {
+text = p;
+text_len = q - p;
+
+while (text_len > 0) {
+const int len = text_len - 1;
+const uint8_t c = p[len];
+if (c != '\r' && c != '\n')
+break;
+text_len = len;
+}
+} else {
+text = data;
+text_len = data_len;
 }
 
+
 if (tex

[FFmpeg-devel] [PATCH 4/4] lavf/matroskaenc: mux WebVTT using standard (non-WebM) formatting

2020-05-28 Thread rcombs
---
 libavformat/matroskaenc.c | 33 +
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1f7a9528de..d34a47e646 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1351,7 +1351,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 return AVERROR(ENOSYS);
 }
 
-if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT)
+if (mkv->mode != MODE_WEBM)
 native_id = MATROSKA_TRACK_TYPE_SUBTITLE;
 
 put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, native_id);
@@ -1361,7 +1361,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 return AVERROR(EINVAL);
 }
 
-if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT) {
+if (mkv->mode != MODE_WEBM) {
 track->codecpriv_offset = avio_tell(pb);
 ret = mkv_write_codecprivate(s, pb, par, native_id, qt_id);
 if (ret < 0)
@@ -2117,20 +2117,22 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, 
AVIOContext *pb, const AVPac
 MatroskaMuxContext *mkv = s->priv_data;
 mkv_track *track = &mkv->tracks[pkt->stream_index];
 ebml_master blockgroup;
-int id_size, settings_size, size;
-uint8_t *id, *settings;
+int id_size = 0, settings_size = 0, comment_size = 0, size = pkt->size;
+uint8_t *id, *settings, *comment;
 int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
 const int flags = 0;
 
-id_size = 0;
 id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER,
  &id_size);
 
-settings_size = 0;
 settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS,
&settings_size);
 
-size = id_size + 1 + settings_size + 1 + pkt->size;
+comment = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_COMMENT,
+  &comment_size);
+
+if (mkv->mode == MODE_WEBM)
+size += id_size + 1 + settings_size + 1;
 
 /* The following string is identical to the one in mkv_write_block so that
  * only one copy needs to exist in binaries. */
@@ -2149,7 +2151,22 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, 
AVIOContext *pb, const AVPac
 put_ebml_num(pb, track->track_num, track->track_num_size);
 avio_wb16(pb, ts - mkv->cluster_pts);
 avio_w8(pb, flags);
-avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, 
pkt->size, pkt->data);
+if (mkv->mode == MODE_WEBM)
+avio_printf(pb, "%.*s\n%.*s\n", id_size, id, settings_size, settings);
+avio_write(pb, pkt->data, pkt->size);
+
+if (mkv->mode != MODE_WEBM && (id_size || settings_size || comment_size)) {
+ebml_master block_additions = start_ebml_master(pb, 
MATROSKA_ID_BLOCKADDITIONS, 0);
+ebml_master block_more  = start_ebml_master(pb, 
MATROSKA_ID_BLOCKMORE,  0);
+/* Until dbc50f8a our demuxer used a wrong default value
+ * of BlockAddID, so we write it unconditionally. */
+put_ebml_uint  (pb, MATROSKA_ID_BLOCKADDID, 1);
+put_ebml_id(pb, MATROSKA_ID_BLOCKADDITIONAL);
+put_ebml_length(pb, id_size + 1 + settings_size + 1 + comment_size, 0);
+avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, 
settings, comment_size, comment);
+end_ebml_master(pb, block_more);
+end_ebml_master(pb, block_additions);
+}
 
 put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, pkt->duration);
 end_ebml_master(pb, blockgroup);
-- 
2.26.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/4] lavf/webvtt: preserve comments

2020-05-28 Thread rcombs
---
 libavcodec/avpacket.c   |  1 +
 libavcodec/packet.h |  6 ++
 libavformat/webvttdec.c | 25 ++---
 libavformat/webvttenc.c | 10 --
 4 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 033f2d8f26..d62d93346c 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -399,6 +399,7 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_PRFT:   return "Producer Reference 
Time";
 case AV_PKT_DATA_ICC_PROFILE:return "ICC Profile";
 case AV_PKT_DATA_DOVI_CONF:  return "DOVI configuration 
record";
+case AV_PKT_DATA_WEBVTT_COMMENT: return "WebVTT Comment";
 }
 return NULL;
 }
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 41485f4527..6b282f04c9 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -282,6 +282,12 @@ enum AVPacketSideDataType {
  */
 AV_PKT_DATA_DOVI_CONF,
 
+/**
+ * The optional comment data that comes before the identifier or timing 
block
+ * of a WebVTT cue. Must end with a line break.
+ */
+AV_PKT_DATA_WEBVTT_COMMENT,
+
 /**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c
index 6c4d5f6736..bc4ef45fb6 100644
--- a/libavformat/webvttdec.c
+++ b/libavformat/webvttdec.c
@@ -60,7 +60,7 @@ static int64_t read_ts(const char *s)
 static int webvtt_read_header(AVFormatContext *s)
 {
 WebVTTContext *webvtt = s->priv_data;
-AVBPrint cue;
+AVBPrint cue, com;
 int res = 0;
 AVStream *st = avformat_new_stream(s, NULL);
 
@@ -72,6 +72,7 @@ static int webvtt_read_header(AVFormatContext *s)
 st->disposition |= webvtt->kind;
 
 av_bprint_init(&cue,0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprint_init(&com,0, AV_BPRINT_SIZE_UNLIMITED);
 
 for (;;) {
 int i;
@@ -91,10 +92,15 @@ static int webvtt_read_header(AVFormatContext *s)
 
 /* ignore header chunk */
 if (!strncmp(p, "\xEF\xBB\xBFWEBVTT", 9) ||
-!strncmp(p, "WEBVTT", 6) ||
-!strncmp(p, "NOTE", 4))
+!strncmp(p, "WEBVTT", 6))
 continue;
 
+if (!strncmp(p, "NOTE", 4) &&
+(p[4] == ' ' || p[4] == '\t' || p[4] == '\n' || p[4] == '\r')) {
+av_bprintf(&com, "%s%s\n", com.len ? "\n" : "", p);
+continue;
+}
+
 /* optional cue identifier (can be a number like in SRT or some kind of
  * chaptering id) */
 for (i = 0; p[i] && p[i] != '\n' && p[i] != '\r'; i++) {
@@ -159,12 +165,25 @@ static int webvtt_read_header(AVFormatContext *s)
 
 SET_SIDE_DATA(identifier, AV_PKT_DATA_WEBVTT_IDENTIFIER);
 SET_SIDE_DATA(settings,   AV_PKT_DATA_WEBVTT_SETTINGS);
+if (com.len) {
+char *com_str;
+if ((res = av_bprint_finalize(&com, &com_str)) < 0)
+goto end;
+
+if ((res = av_packet_add_side_data(sub, 
AV_PKT_DATA_WEBVTT_COMMENT, com_str, com.len)) < 0) {
+av_free(com_str);
+goto end;
+}
+
+av_bprint_init(&com,0, AV_BPRINT_SIZE_UNLIMITED);
+}
 }
 
 ff_subtitles_queue_finalize(s, &webvtt->q);
 
 end:
 av_bprint_finalize(&cue,NULL);
+av_bprint_finalize(&com,NULL);
 return res;
 }
 
diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index cbd989dcb6..ecd508db65 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -64,11 +64,17 @@ static int webvtt_write_header(AVFormatContext *ctx)
 static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt)
 {
 AVIOContext  *pb = ctx->pb;
-int id_size, settings_size;
-uint8_t *id, *settings;
+int id_size, settings_size, comment_size;
+uint8_t *id, *settings, *comment;
 
 avio_printf(pb, "\n");
 
+comment = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_COMMENT,
+  &comment_size);
+
+if (comment && comment_size > 0)
+avio_printf(pb, "%.*s\n", comment_size, comment);
+
 id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER,
  &id_size);
 
-- 
2.26.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".

Re: [FFmpeg-devel] aubmit Verisilicon VPE hardware codec implementation

2020-05-28 Thread Nicolas George
myp...@gmail.com (12020-05-28):
> I guess it is based on https://github.com/VeriSilicon/VPI, but I just
> find some so library

There is no license.

I do not think we could consider supporting this until the external part
is solid enough.

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/4] lavf: matroska subtitle muxer

2020-05-28 Thread Nicolas George
rcombs (12020-05-28):
> ---
>  configure |  1 +
>  libavformat/allformats.c  |  1 +
>  libavformat/matroskaenc.c | 30 ++
>  libavformat/version.h |  2 +-
>  4 files changed, 33 insertions(+), 1 deletion(-)

Was this not rejected two months ago as doing nothing useful?

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

[FFmpeg-devel] [PATCH] libavfilter/vf_drawtext.c:add support to generte ms level

2020-05-28 Thread 黄思远


0001-libavfilter-vf_drawtext.c-add-support-to-generte-ms-.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavfilter/vf_drawtext.c:add support to generte ms level

2020-05-28 Thread Gyan Doshi

If the patch isn't inlined in the email, please add a descriptive body.

Docs entry missing.

Gyan

On 28-05-2020 02:01 pm, 黄思远 wrote:

___
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 3/4] avfilter: add ff_inlink_peek_samples and ff_inlink_skip samples

2020-05-28 Thread Paul B Mahol
Will apply soon.

On 5/24/20, Paul B Mahol  wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/avfilter.c | 61 +-
>  libavfilter/filters.h  | 17 
>  2 files changed, 72 insertions(+), 6 deletions(-)
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 4/4] lavf/matroskaenc: mux WebVTT using standard (non-WebM) formatting

2020-05-28 Thread rcombs
---
 libavformat/matroskaenc.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1f7a9528de..61b0fe9f51 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2117,20 +2117,22 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, 
AVIOContext *pb, const AVPac
 MatroskaMuxContext *mkv = s->priv_data;
 mkv_track *track = &mkv->tracks[pkt->stream_index];
 ebml_master blockgroup;
-int id_size, settings_size, size;
-uint8_t *id, *settings;
+int id_size = 0, settings_size = 0, comment_size = 0, size = pkt->size;
+uint8_t *id, *settings, *comment;
 int64_t ts = track->write_dts ? pkt->dts : pkt->pts;
 const int flags = 0;
 
-id_size = 0;
 id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER,
  &id_size);
 
-settings_size = 0;
 settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS,
&settings_size);
 
-size = id_size + 1 + settings_size + 1 + pkt->size;
+comment = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_COMMENT,
+  &comment_size);
+
+if (mkv->mode == MODE_WEBM)
+size += id_size + 1 + settings_size + 1;
 
 /* The following string is identical to the one in mkv_write_block so that
  * only one copy needs to exist in binaries. */
@@ -2149,7 +2151,22 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, 
AVIOContext *pb, const AVPac
 put_ebml_num(pb, track->track_num, track->track_num_size);
 avio_wb16(pb, ts - mkv->cluster_pts);
 avio_w8(pb, flags);
-avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, 
pkt->size, pkt->data);
+if (mkv->mode == MODE_WEBM)
+avio_printf(pb, "%.*s\n%.*s\n", id_size, id, settings_size, settings);
+avio_write(pb, pkt->data, pkt->size);
+
+if (mkv->mode != MODE_WEBM && (id_size || settings_size || comment_size)) {
+ebml_master block_additions = start_ebml_master(pb, 
MATROSKA_ID_BLOCKADDITIONS, 0);
+ebml_master block_more  = start_ebml_master(pb, 
MATROSKA_ID_BLOCKMORE,  0);
+/* Until dbc50f8a our demuxer used a wrong default value
+ * of BlockAddID, so we write it unconditionally. */
+put_ebml_uint  (pb, MATROSKA_ID_BLOCKADDID, 1);
+put_ebml_id(pb, MATROSKA_ID_BLOCKADDITIONAL);
+put_ebml_length(pb, id_size + 1 + settings_size + 1 + comment_size, 0);
+avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, 
settings, comment_size, comment);
+end_ebml_master(pb, block_more);
+end_ebml_master(pb, block_additions);
+}
 
 put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, pkt->duration);
 end_ebml_master(pb, blockgroup);
-- 
2.26.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/4] lavf/matroskadec: support standard (non-WebM) WebVTT formatting

2020-05-28 Thread rcombs
Fixes ticket #5641
---
 libavformat/matroska.c|  11 ++--
 libavformat/matroskadec.c | 111 --
 2 files changed, 77 insertions(+), 45 deletions(-)

diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 7c56aba403..962fa496f4 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -60,16 +60,12 @@ const CodecTags ff_mkv_codec_tags[]={
 {"A_VORBIS" , AV_CODEC_ID_VORBIS},
 {"A_WAVPACK4"   , AV_CODEC_ID_WAVPACK},
 
-{"D_WEBVTT/SUBTITLES"   , AV_CODEC_ID_WEBVTT},
-{"D_WEBVTT/CAPTIONS", AV_CODEC_ID_WEBVTT},
-{"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT},
-{"D_WEBVTT/METADATA", AV_CODEC_ID_WEBVTT},
-
 {"S_TEXT/UTF8"  , AV_CODEC_ID_SUBRIP},
 {"S_TEXT/UTF8"  , AV_CODEC_ID_TEXT},
 {"S_TEXT/ASCII" , AV_CODEC_ID_TEXT},
 {"S_TEXT/ASS"   , AV_CODEC_ID_ASS},
 {"S_TEXT/SSA"   , AV_CODEC_ID_ASS},
+{"S_TEXT/WEBVTT", AV_CODEC_ID_WEBVTT},
 {"S_ASS", AV_CODEC_ID_ASS},
 {"S_SSA", AV_CODEC_ID_ASS},
 {"S_VOBSUB" , AV_CODEC_ID_DVD_SUBTITLE},
@@ -77,6 +73,11 @@ const CodecTags ff_mkv_codec_tags[]={
 {"S_HDMV/PGS"   , AV_CODEC_ID_HDMV_PGS_SUBTITLE},
 {"S_HDMV/TEXTST", AV_CODEC_ID_HDMV_TEXT_SUBTITLE},
 
+{"D_WEBVTT/SUBTITLES"   , AV_CODEC_ID_WEBVTT},
+{"D_WEBVTT/CAPTIONS", AV_CODEC_ID_WEBVTT},
+{"D_WEBVTT/DESCRIPTIONS", AV_CODEC_ID_WEBVTT},
+{"D_WEBVTT/METADATA", AV_CODEC_ID_WEBVTT},
+
 {"V_AV1", AV_CODEC_ID_AV1},
 {"V_DIRAC"  , AV_CODEC_ID_DIRAC},
 {"V_FFV1"   , AV_CODEC_ID_FFV1},
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index bb3a126c29..1170f57be3 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3306,62 +3306,81 @@ static int matroska_parse_webvtt(MatroskaDemuxContext 
*matroska,
  uint8_t *data, int data_len,
  uint64_t timecode,
  uint64_t duration,
- int64_t pos)
+ int64_t pos,
+ uint8_t *additional, uint64_t additional_id, 
int additional_size)
 {
 AVPacket pktl, *pkt = &pktl;
-uint8_t *id, *settings, *text, *buf;
-int id_len, settings_len, text_len;
+uint8_t *id, *settings, *comment, *text, *buf;
+int id_len = 0, settings_len = 0, comment_len = 0, text_len;
 uint8_t *p, *q;
 int err;
+int webm_style = !strncmp(track->codec_id, "D_WEBVTT/", 9);
 
 if (data_len <= 0)
 return AVERROR_INVALIDDATA;
 
-p = data;
-q = data + data_len;
-
-id = p;
-id_len = -1;
-while (p < q) {
-if (*p == '\r' || *p == '\n') {
-id_len = p - id;
-if (*p == '\r')
-p++;
-break;
+p = webm_style ? data : additional;
+q = webm_style ? (data + data_len) : (additional + additional_size);
+
+if (p) {
+id = p;
+id_len = -1;
+while (p < q) {
+if (*p == '\r' || *p == '\n') {
+id_len = p - id;
+if (*p == '\r')
+p++;
+break;
+}
+p++;
 }
+
+if (p >= q || *p != '\n')
+return AVERROR_INVALIDDATA;
 p++;
-}
 
-if (p >= q || *p != '\n')
-return AVERROR_INVALIDDATA;
-p++;
-
-settings = p;
-settings_len = -1;
-while (p < q) {
-if (*p == '\r' || *p == '\n') {
-settings_len = p - settings;
-if (*p == '\r')
-p++;
-break;
+settings = p;
+settings_len = -1;
+while (p < q) {
+if (*p == '\r' || *p == '\n') {
+settings_len = p - settings;
+if (*p == '\r')
+p++;
+break;
+}
+p++;
 }
+
+if (p >= q || *p != '\n')
+return AVERROR_INVALIDDATA;
 p++;
+
+if (!webm_style && p < q) {
+if (q[-1] != '\r' && q[-1] != '\n')
+return AVERROR_INVALIDDATA;
+
+comment = p;
+comment_len = q - p;
+}
 }
 
-if (p >= q || *p != '\n')
-return AVERROR_INVALIDDATA;
-p++;
-
-text = p;
-text_len = q - p;
-while (text_len > 0) {
-const int len = text_len - 1;
-const uint8_t c = p[len];
-if (c != '\r' && c != '\n')
-break;
-text_len = len;
+if (webm_style) {
+text = p;
+text_len = q - p;
+
+while (text_len > 0) {
+const int len = text_len - 1;
+const uint8_t c = p[len];
+if (c != '\r' && c != '\n')
+break;
+text_len = len;
+}
+} else {
+text = data;
+text_len = data_len;
 }
 
+
 if (tex

[FFmpeg-devel] [PATCH 1/4] lavf: matroska subtitle muxer

2020-05-28 Thread rcombs
---
 configure |  1 +
 libavformat/allformats.c  |  1 +
 libavformat/matroskaenc.c | 30 ++
 libavformat/version.h |  2 +-
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 8569a60bf8..9929c29006 100755
--- a/configure
+++ b/configure
@@ -3305,6 +3305,7 @@ ismv_muxer_select="mov_muxer"
 ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
 latm_muxer_select="aac_adtstoasc_bsf"
 matroska_audio_muxer_select="matroska_muxer"
+matroska_subtitle_muxer_select="matroska_muxer"
 matroska_demuxer_select="iso_media riffdec"
 matroska_demuxer_suggest="bzlib lzo zlib"
 matroska_muxer_select="iso_media riffenc vp9_superframe_bsf aac_adtstoasc_bsf"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3919c9e4c1..1bae208195 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -233,6 +233,7 @@ extern AVOutputFormat ff_md5_muxer;
 extern AVInputFormat  ff_matroska_demuxer;
 extern AVOutputFormat ff_matroska_muxer;
 extern AVOutputFormat ff_matroska_audio_muxer;
+extern AVOutputFormat ff_matroska_subtitle_muxer;
 extern AVInputFormat  ff_mgsts_demuxer;
 extern AVInputFormat  ff_microdvd_demuxer;
 extern AVOutputFormat ff_microdvd_muxer;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1c1ea71f59..1f7a9528de 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2891,3 +2891,33 @@ AVOutputFormat ff_matroska_audio_muxer = {
 .priv_class= &mka_class,
 };
 #endif
+
+#if CONFIG_MATROSKA_SUBTITLE_MUXER
+static const AVClass mks_class = {
+.class_name = "matroska subtitle muxer",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+AVOutputFormat ff_matroska_subtitle_muxer = {
+.name  = "matroska",
+.long_name = NULL_IF_CONFIG_SMALL("Matroska Subtitle"),
+.extensions= "mks",
+.priv_data_size= sizeof(MatroskaMuxContext),
+.audio_codec   = AV_CODEC_ID_NONE,
+.video_codec   = AV_CODEC_ID_NONE,
+.subtitle_codec= AV_CODEC_ID_ASS,
+.init  = mkv_init,
+.deinit= mkv_deinit,
+.write_header  = mkv_write_header,
+.write_packet  = mkv_write_flush_packet,
+.write_trailer = mkv_write_trailer,
+.check_bitstream   = mkv_check_bitstream,
+.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT |
+ AVFMT_ALLOW_FLUSH,
+.codec_tag = (const AVCodecTag* const []){
+ additional_subtitle_tags, 0
+},
+.priv_class= &mks_class,
+};
+#endif
diff --git a/libavformat/version.h b/libavformat/version.h
index 493a0b337f..e0135fc7d3 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  43
+#define LIBAVFORMAT_VERSION_MINOR  44
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
2.26.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/4] lavf/webvtt: preserve comments

2020-05-28 Thread rcombs
---
 libavcodec/avpacket.c   |  1 +
 libavcodec/packet.h |  6 ++
 libavformat/webvttdec.c | 25 ++---
 libavformat/webvttenc.c | 10 --
 4 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 033f2d8f26..d62d93346c 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -399,6 +399,7 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_PRFT:   return "Producer Reference 
Time";
 case AV_PKT_DATA_ICC_PROFILE:return "ICC Profile";
 case AV_PKT_DATA_DOVI_CONF:  return "DOVI configuration 
record";
+case AV_PKT_DATA_WEBVTT_COMMENT: return "WebVTT Comment";
 }
 return NULL;
 }
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 41485f4527..6b282f04c9 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -282,6 +282,12 @@ enum AVPacketSideDataType {
  */
 AV_PKT_DATA_DOVI_CONF,
 
+/**
+ * The optional comment data that comes before the identifier or timing 
block
+ * of a WebVTT cue. Must end with a line break.
+ */
+AV_PKT_DATA_WEBVTT_COMMENT,
+
 /**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c
index 6c4d5f6736..bc4ef45fb6 100644
--- a/libavformat/webvttdec.c
+++ b/libavformat/webvttdec.c
@@ -60,7 +60,7 @@ static int64_t read_ts(const char *s)
 static int webvtt_read_header(AVFormatContext *s)
 {
 WebVTTContext *webvtt = s->priv_data;
-AVBPrint cue;
+AVBPrint cue, com;
 int res = 0;
 AVStream *st = avformat_new_stream(s, NULL);
 
@@ -72,6 +72,7 @@ static int webvtt_read_header(AVFormatContext *s)
 st->disposition |= webvtt->kind;
 
 av_bprint_init(&cue,0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprint_init(&com,0, AV_BPRINT_SIZE_UNLIMITED);
 
 for (;;) {
 int i;
@@ -91,10 +92,15 @@ static int webvtt_read_header(AVFormatContext *s)
 
 /* ignore header chunk */
 if (!strncmp(p, "\xEF\xBB\xBFWEBVTT", 9) ||
-!strncmp(p, "WEBVTT", 6) ||
-!strncmp(p, "NOTE", 4))
+!strncmp(p, "WEBVTT", 6))
 continue;
 
+if (!strncmp(p, "NOTE", 4) &&
+(p[4] == ' ' || p[4] == '\t' || p[4] == '\n' || p[4] == '\r')) {
+av_bprintf(&com, "%s%s\n", com.len ? "\n" : "", p);
+continue;
+}
+
 /* optional cue identifier (can be a number like in SRT or some kind of
  * chaptering id) */
 for (i = 0; p[i] && p[i] != '\n' && p[i] != '\r'; i++) {
@@ -159,12 +165,25 @@ static int webvtt_read_header(AVFormatContext *s)
 
 SET_SIDE_DATA(identifier, AV_PKT_DATA_WEBVTT_IDENTIFIER);
 SET_SIDE_DATA(settings,   AV_PKT_DATA_WEBVTT_SETTINGS);
+if (com.len) {
+char *com_str;
+if ((res = av_bprint_finalize(&com, &com_str)) < 0)
+goto end;
+
+if ((res = av_packet_add_side_data(sub, 
AV_PKT_DATA_WEBVTT_COMMENT, com_str, com.len)) < 0) {
+av_free(com_str);
+goto end;
+}
+
+av_bprint_init(&com,0, AV_BPRINT_SIZE_UNLIMITED);
+}
 }
 
 ff_subtitles_queue_finalize(s, &webvtt->q);
 
 end:
 av_bprint_finalize(&cue,NULL);
+av_bprint_finalize(&com,NULL);
 return res;
 }
 
diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index cbd989dcb6..ecd508db65 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -64,11 +64,17 @@ static int webvtt_write_header(AVFormatContext *ctx)
 static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt)
 {
 AVIOContext  *pb = ctx->pb;
-int id_size, settings_size;
-uint8_t *id, *settings;
+int id_size, settings_size, comment_size;
+uint8_t *id, *settings, *comment;
 
 avio_printf(pb, "\n");
 
+comment = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_COMMENT,
+  &comment_size);
+
+if (comment && comment_size > 0)
+avio_printf(pb, "%.*s\n", comment_size, comment);
+
 id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER,
  &id_size);
 
-- 
2.26.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".

Re: [FFmpeg-devel] [PATCH 2/4] tools/target_dec_fuzzer: Do not test AV_CODEC_FLAG2_FAST with AV_CODEC_ID_H264

2020-05-28 Thread Jean-Baptiste Kempf
On Thu, May 28, 2020, at 00:08, Kieran Kunhya wrote:
> On Wed, 27 May 2020 at 22:53, Michael Niedermayer 
> wrote:
> 
> > On Sun, Mar 15, 2020 at 10:20:56PM +0100, Michael Niedermayer wrote:
> > > This combination skips allocating large padding which can read out of
> > array
> > >
> > > Fixes:
> > 20978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5746381832847360
> > >
> > > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  tools/target_dec_fuzzer.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > will apply
> >
> 
> Shouldn't there be warnings about FAST mode if it causes security issues?

I agree here.
Either we fix FAST mode, or it must come with important warnings.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
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] libavfilter/vf_drawtext.c:add support to generte ms level

2020-05-28 Thread 黄思远
___
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] libavfilter/vf_drawtext.c:add support to generte ms level

2020-05-28 Thread Paul B Mahol
No patch received at all.

On 5/28/20, 黄思远  wrote:
> ___
> 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] 答复: 答复: aubmit Verisilicon VPE hardware codec implementation

2020-05-28 Thread Hendrik Leppkes
On Thu, May 28, 2020 at 4:58 AM Zhang, Guiyong
 wrote:
>
> Hi softworkz,
>
> Currently no- but similar module maybe possible in further.
>

Support for proprietary hardware only deployed by Facebook seems like
it doesn't really benefit the FFmpeg ecosystem as a whole.

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

Re: [FFmpeg-devel] [PATCH v2 1/2] lavfi/afir: fix vpad.name leak

2020-05-28 Thread myp...@gmail.com
On Mon, May 25, 2020 at 4:17 PM Jun Zhao  wrote:
>
> From: Jun Zhao 
>
> Fix vpad.name leak in error path, move the vpad related operation
> only if enabled show IR frequency response.
>
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/af_afir.c | 14 ++
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
> index 7c7e845..5ba880f 100644
> --- a/libavfilter/af_afir.c
> +++ b/libavfilter/af_afir.c
> @@ -876,6 +876,12 @@ static av_cold int init(AVFilterContext *ctx)
>  if (!pad.name)
>  return AVERROR(ENOMEM);
>
> +ret = ff_insert_outpad(ctx, 0, &pad);
> +if (ret < 0) {
> +av_freep(&pad.name);
> +return ret;
> +}
> +
>  if (s->response) {
>  vpad = (AVFilterPad){
>  .name = av_strdup("filter_response"),
> @@ -884,15 +890,7 @@ static av_cold int init(AVFilterContext *ctx)
>  };
>  if (!vpad.name)
>  return AVERROR(ENOMEM);
> -}
>
> -ret = ff_insert_outpad(ctx, 0, &pad);
> -if (ret < 0) {
> -av_freep(&pad.name);
> -return ret;
> -}
> -
> -if (s->response) {
>  ret = ff_insert_outpad(ctx, 1, &vpad);
>  if (ret < 0) {
>  av_freep(&vpad.name);
> --
> 2.7.4
>
Ping ?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 4/4] lavf/mpegtsenc: misc style fixes

2020-05-28 Thread myp...@gmail.com
On Wed, May 27, 2020 at 2:58 PM Marton Balint  wrote:
>
>
>
> On Wed, 27 May 2020, Jun Zhao wrote:
>
> > From: Jun Zhao 
> >
> > commit 32aeba12755 missed coding style fix.
> >
> > Signed-off-by: Jun Zhao 
> > ---
> > libavformat/mpegtsenc.c | 24 
> > 1 file changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> > index bf1a7ee..de9819b 100644
> > --- a/libavformat/mpegtsenc.c
> > +++ b/libavformat/mpegtsenc.c
> > @@ -1432,10 +1432,10 @@ static void mpegts_write_pes(AVFormatContext *s, 
> > AVStream *st,
> > if (ts->m2ts_mode &&
> > st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
> > st->codecpar->codec_id == AV_CODEC_ID_AC3) {
> > -/* set PES_extension_flag */
> > -pes_extension = 1;
> > -flags |= 0x01;
> > -header_len += 3;
> > +/* set PES_extension_flag */
> > +pes_extension = 1;
> > +flags |= 0x01;
> > +header_len += 3;
> > }
> > if (is_dvb_teletext) {
> > pes_header_stuffing_bytes = 0x24 - header_len;
> > @@ -1478,14 +1478,14 @@ static void mpegts_write_pes(AVFormatContext *s, 
> > AVStream *st,
> > *q++ = 0x00 | 0x60;
> > }
> > /* For Blu-ray AC3 Audio Setting extended flags */
> > -  if (ts->m2ts_mode &&
> > -  pes_extension &&
> > -  st->codecpar->codec_id == AV_CODEC_ID_AC3) {
> > -  flags = 0x01; /* set PES_extension_flag_2 */
> > -  *q++ = flags;
> > -  *q++ = 0x80 | 0x01; /* marker bit + extension length 
> > */
> > -  *q++ = 0x00 | 0x71; /* for AC3 Audio (specifically 
> > on blue-rays) */
> > -  }
> > +if (ts->m2ts_mode &&
> > +pes_extension &&
> > +st->codecpar->codec_id == AV_CODEC_ID_AC3) {
> > +flags = 0x01; /* set PES_extension_flag_2 */
> > +*q++ = flags;
> > +*q++ = 0x80 | 0x01; /* marker bit + extension length */
> > +*q++ = 0x00 | 0x71; /* for AC3 Audio (specifically on 
> > blue-rays) */
> > +}
> >
>
> LGTM, thanks.
>
Pushed patch 3-4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v2] avformat/oggenc: Add partial support for OggPCM muxing

2020-05-28 Thread A G
This adds partial support for OggPCM muxing.

Heavily based on the work here:
https://ffmpeg.org/pipermail/ffmpeg-devel/2013-July/145556.html
and here:
http://www.on2.com/media/gpl/mplayer/
---
 libavformat/oggenc.c | 86 
 1 file changed, 80 insertions(+), 6 deletions(-)

diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index f5032759a6..153f7f6760 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -99,6 +99,36 @@ static const AVClass flavor ## _muxer_class = {\
 .version= LIBAVUTIL_VERSION_INT,\
 };

+
+static const struct ogg_pcm_codec {
+uint32_t codec_id;
+uint32_t format_id;
+} ogg_pcm_codecs[] = {
+{ AV_CODEC_ID_PCM_S8,0x00 },
+{ AV_CODEC_ID_PCM_U8,0x01 },
+{ AV_CODEC_ID_PCM_S16LE, 0x02 },
+{ AV_CODEC_ID_PCM_S16BE, 0x03 },
+{ AV_CODEC_ID_PCM_S24LE, 0x04 },
+{ AV_CODEC_ID_PCM_S24BE, 0x05 },
+{ AV_CODEC_ID_PCM_S32LE, 0x06 },
+{ AV_CODEC_ID_PCM_S32BE, 0x07 },
+{ AV_CODEC_ID_PCM_F32LE, 0x20 },
+{ AV_CODEC_ID_PCM_F32BE, 0x21 },
+{ AV_CODEC_ID_PCM_F64LE, 0x22 },
+{ AV_CODEC_ID_PCM_F64BE, 0x23 },
+};
+
+static inline uint32_t ogg_get_pcm_format_id(uint32_t codec_id)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(ogg_pcm_codecs); i++)
+if (ogg_pcm_codecs[i].codec_id == codec_id)
+return ogg_pcm_codecs[i].format_id;
+
+return 0;
+}
+
 static void ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
 {
 OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data;
@@ -363,6 +393,39 @@ static int ogg_build_speex_headers(AVCodecParameters *par,
 return 0;
 }

+#define OGGPCM_HEADER_SIZE 224
+
+static int ogg_build_pcm_headers(AVCodecParameters *par,
+   OGGStreamContext *oggstream, int bitexact,
+   AVDictionary **m)
+{
+uint8_t *p;
+
+// first packet: OggPCM header
+p = av_mallocz(OGGPCM_HEADER_SIZE);
+if (!p)
+return AVERROR(ENOMEM);
+oggstream->header[0] = p;
+oggstream->header_len[0] = OGGPCM_HEADER_SIZE;
+bytestream_put_buffer(&p, "PCM ", 8); // Identifier
+bytestream_put_be16(&p, 0x00); // VMAJ
+bytestream_put_be16(&p, 0x00); // VMIN
+bytestream_put_be32(&p, ogg_get_pcm_format_id(par->codec_id)); // PCM fmt
+bytestream_put_be32(&p, par->sample_rate); // Sample rate
+bytestream_put_byte(&p, 0); // Significant bits (0 == Same as fmt)
+bytestream_put_byte(&p, par->channels); // Channels
+bytestream_put_be16(&p, 0); // Max frames per packet TODO:// Actually 
calculate max frames per packet
+bytestream_put_be32(&p, 0); // Number of extra headers
+
+// second packet: VorbisComment
+p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 0, 
NULL, 0);
+if (!p)
+return AVERROR(ENOMEM);
+oggstream->header[1] = p;
+
+return 0;
+}
+
 #define OPUS_HEADER_SIZE 19

 static int ogg_build_opus_headers(AVCodecParameters *par,
@@ -487,18 +550,20 @@ static int ogg_init(AVFormatContext *s)
 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 }

-if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS &&
-st->codecpar->codec_id != AV_CODEC_ID_THEORA &&
-st->codecpar->codec_id != AV_CODEC_ID_SPEEX  &&
-st->codecpar->codec_id != AV_CODEC_ID_FLAC   &&
-st->codecpar->codec_id != AV_CODEC_ID_OPUS   &&
+if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS   &&
+st->codecpar->codec_id != AV_CODEC_ID_THEORA   &&
+st->codecpar->codec_id != AV_CODEC_ID_SPEEX&&
+st->codecpar->codec_id != AV_CODEC_ID_FLAC &&
+st->codecpar->codec_id != AV_CODEC_ID_OPUS &&
+!ogg_get_pcm_format_id(st->codecpar->codec_id) &&
 st->codecpar->codec_id != AV_CODEC_ID_VP8) {
 av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
 return AVERROR(EINVAL);
 }

 if ((!st->codecpar->extradata || !st->codecpar->extradata_size) &&
-st->codecpar->codec_id != AV_CODEC_ID_VP8) {
+st->codecpar->codec_id != AV_CODEC_ID_VP8  &&
+!ogg_get_pcm_format_id(st->codecpar->codec_id)) {
 av_log(s, AV_LOG_ERROR, "No extradata present\n");
 return AVERROR_INVALIDDATA;
 }
@@ -553,6 +618,14 @@ static int ogg_init(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "Error writing VP8 headers\n");
 return err;
 }
+} else if (ogg_get_pcm_format_id(st->codecpar->codec_id)) {
+int err = ogg_build_pcm_headers(st->codecpar, oggstream,
+  s->flags & AVFMT_FLAG_BITEXACT,
+  &st->metadata);
+if (err) {
+av_log(s, AV_LOG_ERROR, "Error writing OggPCM headers\n");
+   

Re: [FFmpeg-devel] [PATCH v2] avformat/oggenc: Add partial support for OggPCM muxing

2020-05-28 Thread A G
Apologies for the previous patch (v1), the commit message was incorrect 
and I failed to add the requested change.


___
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] x86: cabac: Disable the inline asm on clang on windows on i386

2020-05-28 Thread Martin Storsjö

On Mon, 25 May 2020, Martin Storsjö wrote:


On Sun, 24 May 2020, Carl Eugen Hoyos wrote:

Am So., 24. Mai 2020 um 21:53 Uhr schrieb Martin Storsjö 

:



configure --enable-gpl --arch=i686 --cc=clang-cl --ld=lld-link
--target-os=win32 --toolchain=msvc --enable-cross-compile --ar=llvm-ar
--nm=llvm-nm --disable-stripping --extra-cflags=-m32


Why are you cross-compiling?
On which system are you testing this?


Because I normally only ever cross compile for windows.

There seems to be a subtle difference in this case, between using clang-cl 
and "clang -target i686-win32-msvc"; clang-cl passes "-mdisable-fp-elim" 
to the compiler internals, while "clang -target i686-win32-msvc" doesn't.


And cross compiling does seem to affect this particular case; there's a 
check for whether ebp is available, which requires running the built 
executable. When cross compiling, it's assumed the built executable is ok 
and it isn't test run.


So with clang-cl running on windows, you'll end up with "#define 
HAVE_EBP_AVAILABLE 0" in config.h, and the x86 cabac code won't end up 
used at all - i.e. this patch wouldn't make any difference.


With clang-cl in cross compilation, and other invocations of "clang" 
instead of "clang-cl", targeting i686 windows, you'll end up with 
ebp_available enabled.


For a case where it does make a difference, in the same setup, try 
configuring this way instead:


--cc='clang -target i686-win32-msvc' --ld=lld-link 
--extra-ldflags='msvcrt.lib oldnames.lib' --toolchain=msvc


In this case, the ebp_available test will succeed, it will proceed to 
trying to build the x86 inline cabac code, which fails.


Any further comments on this patch?

// Martin
___
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] aubmit Verisilicon VPE hardware codec implementation

2020-05-28 Thread Steven Liu
Zhang, Guiyong  于2020年5月28日周四 上午10:12写道:
>
>
> ___
> 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".

How should I test the VPE? Or where can I get the hw codec devices?


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

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

Re: [FFmpeg-devel] [PATCH v2] avformat/oggenc: Add partial support for OggPCM muxing

2020-05-28 Thread A G
> +static const struct ogg_pcm_codec {
> +uint32_t codec_id;
> +uint32_t format_id;
> +} ogg_pcm_codecs[] = {
> +{ AV_CODEC_ID_PCM_S8,0x00 },
> +{ AV_CODEC_ID_PCM_U8,0x01 },
> +{ AV_CODEC_ID_PCM_S16LE, 0x02 },
> +{ AV_CODEC_ID_PCM_S16BE, 0x03 },
> +{ AV_CODEC_ID_PCM_S24LE, 0x04 },
> +{ AV_CODEC_ID_PCM_S24BE, 0x05 },
> +{ AV_CODEC_ID_PCM_S32LE, 0x06 },
> +{ AV_CODEC_ID_PCM_S32BE, 0x07 },
> +{ AV_CODEC_ID_PCM_F32LE, 0x20 },
> +{ AV_CODEC_ID_PCM_F32BE, 0x21 },
> +{ AV_CODEC_ID_PCM_F64LE, 0x22 },
> +{ AV_CODEC_ID_PCM_F64BE, 0x23 },
> +};
> +
> +static inline uint32_t ogg_get_pcm_format_id(uint32_t codec_id)
> +{
> +int i;
> +
> +for (i = 0; i < FF_ARRAY_ELEMS(ogg_pcm_codecs); i++)
> +if (ogg_pcm_codecs[i].codec_id == codec_id)
> +return ogg_pcm_codecs[i].format_id;
> +
> +return 0;
> +}
> +

The ogg_get_pcm_format_id cannot return 0 for an unsupported format since that 
is already assigned to pcm_s8.

From: ffmpeg-devel  on behalf of A G 

Sent: Thursday, May 28, 2020 3:34 AM
To: FFmpeg development discussions and patches 
Subject: [FFmpeg-devel] [PATCH v2] avformat/oggenc: Add partial support for 
OggPCM muxing

This adds partial support for OggPCM muxing.

Heavily based on the work here:
https://ffmpeg.org/pipermail/ffmpeg-devel/2013-July/145556.html
and here:
http://www.on2.com/media/gpl/mplayer/
---
 libavformat/oggenc.c | 86 
 1 file changed, 80 insertions(+), 6 deletions(-)

diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index f5032759a6..153f7f6760 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -99,6 +99,36 @@ static const AVClass flavor ## _muxer_class = {\
 .version= LIBAVUTIL_VERSION_INT,\
 };

+
+static const struct ogg_pcm_codec {
+uint32_t codec_id;
+uint32_t format_id;
+} ogg_pcm_codecs[] = {
+{ AV_CODEC_ID_PCM_S8,0x00 },
+{ AV_CODEC_ID_PCM_U8,0x01 },
+{ AV_CODEC_ID_PCM_S16LE, 0x02 },
+{ AV_CODEC_ID_PCM_S16BE, 0x03 },
+{ AV_CODEC_ID_PCM_S24LE, 0x04 },
+{ AV_CODEC_ID_PCM_S24BE, 0x05 },
+{ AV_CODEC_ID_PCM_S32LE, 0x06 },
+{ AV_CODEC_ID_PCM_S32BE, 0x07 },
+{ AV_CODEC_ID_PCM_F32LE, 0x20 },
+{ AV_CODEC_ID_PCM_F32BE, 0x21 },
+{ AV_CODEC_ID_PCM_F64LE, 0x22 },
+{ AV_CODEC_ID_PCM_F64BE, 0x23 },
+};
+
+static inline uint32_t ogg_get_pcm_format_id(uint32_t codec_id)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(ogg_pcm_codecs); i++)
+if (ogg_pcm_codecs[i].codec_id == codec_id)
+return ogg_pcm_codecs[i].format_id;
+
+return 0;
+}
+
 static void ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
 {
 OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data;
@@ -363,6 +393,39 @@ static int ogg_build_speex_headers(AVCodecParameters *par,
 return 0;
 }

+#define OGGPCM_HEADER_SIZE 224
+
+static int ogg_build_pcm_headers(AVCodecParameters *par,
+   OGGStreamContext *oggstream, int bitexact,
+   AVDictionary **m)
+{
+uint8_t *p;
+
+// first packet: OggPCM header
+p = av_mallocz(OGGPCM_HEADER_SIZE);
+if (!p)
+return AVERROR(ENOMEM);
+oggstream->header[0] = p;
+oggstream->header_len[0] = OGGPCM_HEADER_SIZE;
+bytestream_put_buffer(&p, "PCM ", 8); // Identifier
+bytestream_put_be16(&p, 0x00); // VMAJ
+bytestream_put_be16(&p, 0x00); // VMIN
+bytestream_put_be32(&p, ogg_get_pcm_format_id(par->codec_id)); // PCM fmt
+bytestream_put_be32(&p, par->sample_rate); // Sample rate
+bytestream_put_byte(&p, 0); // Significant bits (0 == Same as fmt)
+bytestream_put_byte(&p, par->channels); // Channels
+bytestream_put_be16(&p, 0); // Max frames per packet TODO:// Actually 
calculate max frames per packet
+bytestream_put_be32(&p, 0); // Number of extra headers
+
+// second packet: VorbisComment
+p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 0, 
NULL, 0);
+if (!p)
+return AVERROR(ENOMEM);
+oggstream->header[1] = p;
+
+return 0;
+}
+
 #define OPUS_HEADER_SIZE 19

 static int ogg_build_opus_headers(AVCodecParameters *par,
@@ -487,18 +550,20 @@ static int ogg_init(AVFormatContext *s)
 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 }

-if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS &&
-st->codecpar->codec_id != AV_CODEC_ID_THEORA &&
-st->codecpar->codec_id != AV_CODEC_ID_SPEEX  &&
-st->codecpar->codec_id != AV_CODEC_ID_FLAC   &&
-st->codecpar->codec_id != AV_CODEC_ID_OPUS   &&
+if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS   &&
+st->codecpar->codec_id != AV_CODEC_ID_THEORA   &&
+st->codecpar->codec_id != AV_CODEC_ID_SPEEX&&
+st->codecpar->codec_id != AV_CODEC_ID_FLAC &&
+

Re: [FFmpeg-devel] [PATCH 1/4] avformat/hlsplaylist: Add const where appropriate

2020-05-28 Thread Andreas Rheinhardt
Steven Liu:
> 
> 
>> 2020年5月26日 上午3:42,Andreas Rheinhardt  写道:
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> libavformat/hlsplaylist.c | 27 ---
>> libavformat/hlsplaylist.h | 23 +--
>> 2 files changed, 29 insertions(+), 21 deletions(-)
>>
>> diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
>> index 43f9d281ba..7a89846369 100644
>> --- a/libavformat/hlsplaylist.c
>> +++ b/libavformat/hlsplaylist.c
>> @@ -35,8 +35,10 @@ void ff_hls_write_playlist_version(AVIOContext *out, int 
>> version) {
>> avio_printf(out, "#EXT-X-VERSION:%d\n", version);
>> }
>>
>> -void ff_hls_write_audio_rendition(AVIOContext *out, char *agroup,
>> -  const char *filename, char *language, int 
>> name_id, int is_default) {
>> +void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup,
>> +  const char *filename, const char 
>> *language,
>> +  int name_id, int is_default)
>> +{
>> if (!out || !agroup || !filename)
>> return;
>>
>> @@ -48,8 +50,10 @@ void ff_hls_write_audio_rendition(AVIOContext *out, char 
>> *agroup,
>> avio_printf(out, "URI=\"%s\"\n", filename);
>> }
>>
>> -void ff_hls_write_subtitle_rendition(AVIOContext *out, char *sgroup,
>> -  const char *filename, char *language, int 
>> name_id, int is_default) {
>> +void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup,
>> + const char *filename, const char 
>> *language,
>> + int name_id, int is_default)
>> +{
>> if (!out || !filename)
>> return;
>>
>> @@ -61,10 +65,11 @@ void ff_hls_write_subtitle_rendition(AVIOContext *out, 
>> char *sgroup,
>> avio_printf(out, "URI=\"%s\"\n", filename);
>> }
>>
>> -void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
>> -  int bandwidth, const char *filename, char 
>> *agroup,
>> -  char *codecs, char *ccgroup, char *sgroup) {
>> -
>> +void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth,
>> +  const char *filename, const char *agroup,
>> +  const char *codecs, const char *ccgroup,
>> +  const char *sgroup)
>> +{
>> if (!out || !filename)
>> return;
>>
>> @@ -112,7 +117,7 @@ void ff_hls_write_playlist_header(AVIOContext *out, int 
>> version, int allowcache,
>> }
>> }
>>
>> -void ff_hls_write_init_file(AVIOContext *out, char *filename,
>> +void ff_hls_write_init_file(AVIOContext *out, const char *filename,
>> int byterange_mode, int64_t size, int64_t pos) {
>> avio_printf(out, "#EXT-X-MAP:URI=\"%s\"", filename);
>> if (byterange_mode) {
>> @@ -125,8 +130,8 @@ int ff_hls_write_file_entry(AVIOContext *out, int 
>> insert_discont,
>>  int byterange_mode,
>>  double duration, int round_duration,
>>  int64_t size, int64_t pos, //Used only if 
>> HLS_SINGLE_FILE flag is set
>> - char *baseurl, //Ignored if NULL
>> - char *filename, double *prog_date_time,
>> +const char *baseurl /* Ignored if NULL */,
>> +const char *filename, double *prog_date_time,
>>  int64_t video_keyframe_size, int64_t 
>> video_keyframe_pos, int iframe_mode) {
>> if (!out || !filename)
>> return AVERROR(EINVAL);
>> diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
>> index a124bdcffb..4348a26c75 100644
>> --- a/libavformat/hlsplaylist.h
>> +++ b/libavformat/hlsplaylist.h
>> @@ -37,24 +37,27 @@ typedef enum {
>> } PlaylistType;
>>
>> void ff_hls_write_playlist_version(AVIOContext *out, int version);
>> -void ff_hls_write_audio_rendition(AVIOContext *out, char *agroup,
>> -  const char *filename, char *language, int 
>> name_id, int is_default);
>> -void ff_hls_write_subtitle_rendition(AVIOContext *out, char *sgroup,
>> -  const char *filename, char *language, int 
>> name_id, int is_default);
>> -void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
>> -  int bandwidth, const char *filename, char 
>> *agroup,
>> -  char *codecs, char *ccgroup, char *sgroup);
>> +void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup,
>> +  const char *filename, const char 
>> *language,
>> +  int name_id, int is_default);
>> +void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup,
>> + const char *filename, const char 
>> *language,
>

Re: [FFmpeg-devel] [PATCH 3/4] avfilter: add ff_inlink_peek_samples and ff_inlink_skip samples

2020-05-28 Thread Nicolas George
Paul B Mahol (12020-05-28):
> Will apply soon.

I will hurry looking at it.

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

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

[FFmpeg-devel] [PATCH 2/2] avcodec/mpeg12dec: Fix got_output

2020-05-28 Thread Michael Niedermayer
Fixes: assertion failure
Fixes: 
22178/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-5664234440753152

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

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 40d054def5..54e122cd9d 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2497,7 +2497,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame 
*picture,
 return ret;
 else if (ret) {
 // FIXME: merge with the stuff in mpeg_decode_slice
-if (s2->last_picture_ptr || s2->low_delay)
+if (s2->last_picture_ptr || s2->low_delay || s2->pict_type 
== AV_PICTURE_TYPE_B)
 *got_output = 1;
 }
 }
-- 
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/2] avcodec/adpcm_data: extend ff_adpcm_ima_cunning_index_table

2020-05-28 Thread Michael Niedermayer
Fixes: overread by 1
Fixes: 
21880/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_CUNNING_fuzzer-5717917221257216.fuzz

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

diff --git a/libavcodec/adpcm_data.c b/libavcodec/adpcm_data.c
index cb9d20948e..6fbde8aece 100644
--- a/libavcodec/adpcm_data.c
+++ b/libavcodec/adpcm_data.c
@@ -178,8 +178,8 @@ const int16_t ff_adpcm_mtaf_stepsize[32][16] = {
-424, -1273, -2121, -2970, -3819, -4668, -5516, -6365, },
 };
 
-const int8_t ff_adpcm_ima_cunning_index_table[8] = {
--1, -1, -1, -1, 1, 2, 3, 4,
+const int8_t ff_adpcm_ima_cunning_index_table[9] = {
+-1, -1, -1, -1, 1, 2, 3, 4, 5
 };
 
 const int16_t ff_adpcm_ima_cunning_step_table[61] = {
diff --git a/libavcodec/adpcm_data.h b/libavcodec/adpcm_data.h
index fa8a03ee1f..d678bfc71a 100644
--- a/libavcodec/adpcm_data.h
+++ b/libavcodec/adpcm_data.h
@@ -42,7 +42,7 @@ extern const int16_t ff_adpcm_yamaha_indexscale[];
 extern const int8_t  ff_adpcm_yamaha_difflookup[];
 extern const int16_t ff_adpcm_afc_coeffs[2][16];
 extern const int16_t ff_adpcm_mtaf_stepsize[32][16];
-extern const int8_t  ff_adpcm_ima_cunning_index_table[8];
+extern const int8_t  ff_adpcm_ima_cunning_index_table[9];
 extern const int16_t ff_adpcm_ima_cunning_step_table[61];
 
 #endif /* AVCODEC_ADPCM_DATA_H */
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 2/4] tools/target_dec_fuzzer: Do not test AV_CODEC_FLAG2_FAST with AV_CODEC_ID_H264

2020-05-28 Thread Michael Niedermayer
On Thu, May 28, 2020 at 11:14:15AM +0200, Jean-Baptiste Kempf wrote:
> On Thu, May 28, 2020, at 00:08, Kieran Kunhya wrote:
> > On Wed, 27 May 2020 at 22:53, Michael Niedermayer 
> > wrote:
> > 
> > > On Sun, Mar 15, 2020 at 10:20:56PM +0100, Michael Niedermayer wrote:
> > > > This combination skips allocating large padding which can read out of
> > > array
> > > >
> > > > Fixes:
> > > 20978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5746381832847360
> > > >
> > > > Found-by: continuous fuzzing process
> > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > > Signed-off-by: Michael Niedermayer 
> > > > ---
> > > >  tools/target_dec_fuzzer.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > will apply
> > >
> > 
> > Shouldn't there be warnings about FAST mode if it causes security issues?
> 
> I agree here.
> Either we fix FAST mode, or it must come with important warnings.

I suggest to add a AV_CODEC_FLAG2_FAST_UNSAFE and split the current
uses of the flag up between the 2

will submit a patch doing that unless i hear objections / a better
suggestion.


thx

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

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


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

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

Re: [FFmpeg-devel] [PATCH 3/4] avfilter: add ff_inlink_peek_samples and ff_inlink_skip samples

2020-05-28 Thread Nicolas George
Paul B Mahol (12020-05-24):
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/avfilter.c | 61 +-
>  libavfilter/filters.h  | 17 
>  2 files changed, 72 insertions(+), 6 deletions(-)

I am against this.

It adds quite a lot of complexity in common code.

This complexity is not needed: in patch 4/4, you always peek
s->window_size samples and skip s->hop_size, constants: just allocate a
permanent buffer with size s->window_size and roll by s->hop_size in it.
It will be more efficient (less copying around, less allocations) and
simpler.

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/4] lavf: matroska subtitle muxer

2020-05-28 Thread Ridley Combs


> On May 28, 2020, at 03:26, Nicolas George  wrote:
> 
> rcombs (12020-05-28):
>> ---
>> configure |  1 +
>> libavformat/allformats.c  |  1 +
>> libavformat/matroskaenc.c | 30 ++
>> libavformat/version.h |  2 +-
>> 4 files changed, 33 insertions(+), 1 deletion(-)
> 
> Was this not rejected two months ago as doing nothing useful?

Dunno; I added it because an output file named .mks wasn't autoselecting the 
matroska muxer, and it seemed like if we're going to have an mka muxer (rather 
than just an additional extension on the main one) we might as well have an mks 
muxer as well. If we don't think it's useful, it might make sense to get rid of 
the mka muxer as well and just add all the extensions (including mk3d) to the 
mkv one; I don't feel strongly either way.

> 
> Regards,
> 
> -- 
>  Nicolas George
> ___
> 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/4] tools/target_dec_fuzzer: Do not test AV_CODEC_FLAG2_FAST with AV_CODEC_ID_H264

2020-05-28 Thread Michael Niedermayer
On Thu, May 28, 2020 at 02:23:34PM +0200, Michael Niedermayer wrote:
> On Thu, May 28, 2020 at 11:14:15AM +0200, Jean-Baptiste Kempf wrote:
> > On Thu, May 28, 2020, at 00:08, Kieran Kunhya wrote:
> > > On Wed, 27 May 2020 at 22:53, Michael Niedermayer 
> > > wrote:
> > > 
> > > > On Sun, Mar 15, 2020 at 10:20:56PM +0100, Michael Niedermayer wrote:
> > > > > This combination skips allocating large padding which can read out of
> > > > array
> > > > >
> > > > > Fixes:
> > > > 20978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5746381832847360
> > > > >
> > > > > Found-by: continuous fuzzing process
> > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > > > Signed-off-by: Michael Niedermayer 
> > > > > ---
> > > > >  tools/target_dec_fuzzer.c | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > will apply
> > > >
> > > 
> > > Shouldn't there be warnings about FAST mode if it causes security issues?
> > 
> > I agree here.
> > Either we fix FAST mode, or it must come with important warnings.
> 
> I suggest to add a AV_CODEC_FLAG2_FAST_UNSAFE and split the current
> uses of the flag up between the 2
> 
> will submit a patch doing that unless i hear objections / a better
> suggestion.

ill also disable the use that this would move in master to unsafe,
in release branches

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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

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

[FFmpeg-devel] [PATCH 1/7] avcodec/h264dec: cosmetics

2020-05-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/h264dec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index e463fde..7c7a63c 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -253,8 +253,7 @@ int ff_h264_slice_context_init(H264Context *h, 
H264SliceContext *sl)
 
 if (sl != h->slice_ctx) {
 memset(er, 0, sizeof(*er));
-} else
-if (CONFIG_ERROR_RESILIENCE) {
+} else if (CONFIG_ERROR_RESILIENCE) {
 
 /* init ER */
 er->avctx  = h->avctx;
-- 
1.8.3.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 2/7] avcodec/h264dec: store count of slice_table_base with local variable

2020-05-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/h264dec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 7c7a63c..b03e6ed 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -182,6 +182,7 @@ int ff_h264_alloc_tables(H264Context *h)
 {
 const int big_mb_num = h->mb_stride * (h->mb_height + 1);
 const int row_mb_num = 2*h->mb_stride*FFMAX(h->nb_slice_ctx, 1);
+const int slice_tsize = big_mb_num + h->mb_stride;
 int x, y;
 
 FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->intra4x4_pred_mode,
@@ -191,7 +192,7 @@ int ff_h264_alloc_tables(H264Context *h)
 FF_ALLOCZ_OR_GOTO(h->avctx, h->non_zero_count,
   big_mb_num * 48 * sizeof(uint8_t), fail)
 FF_ALLOCZ_OR_GOTO(h->avctx, h->slice_table_base,
-  (big_mb_num + h->mb_stride) * 
sizeof(*h->slice_table_base), fail)
+  slice_tsize * sizeof(*h->slice_table_base), fail)
 FF_ALLOCZ_OR_GOTO(h->avctx, h->cbp_table,
   big_mb_num * sizeof(uint16_t), fail)
 FF_ALLOCZ_OR_GOTO(h->avctx, h->chroma_pred_mode_table,
@@ -209,7 +210,7 @@ int ff_h264_alloc_tables(H264Context *h)
   big_mb_num * sizeof(uint8_t), fail)
 
 memset(h->slice_table_base, -1,
-   (big_mb_num + h->mb_stride) * sizeof(*h->slice_table_base));
+   slice_tsize * sizeof(*h->slice_table_base));
 h->slice_table = h->slice_table_base + h->mb_stride * 2 + 1;
 
 FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2b_xy,
-- 
1.8.3.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 4/7] avcodec/h264dec: prefer to use variable instead of type for sizeof

2020-05-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/h264dec.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 974d324..d5b3df3 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -185,17 +185,17 @@ int ff_h264_alloc_tables(H264Context *h)
 const int slice_tsize = big_mb_num + h->mb_stride;
 int x, y;
 
-if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
sizeof(uint8_t)))||
-!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
sizeof(uint8_t)))   ||
+if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
sizeof(*h->intra4x4_pred_mode))) ||
+!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
sizeof(*h->non_zero_count)))||
 !(h->slice_table_base   = av_mallocz_array(slice_tsize, 
sizeof(*h->slice_table_base)))  ||
-!(h->cbp_table  = av_mallocz_array(big_mb_num, 
sizeof(uint16_t)))   ||
-!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
sizeof(uint8_t)))||
-!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
sizeof(uint8_t)))||
-!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
sizeof(uint8_t)))||
-!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
sizeof(uint8_t)))||
-!(h->list_counts= av_mallocz_array(big_mb_num, 
sizeof(uint8_t)))||
-!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
sizeof(uint32_t)))   ||
-!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
sizeof(uint32_t
+!(h->cbp_table  = av_mallocz_array(big_mb_num, 
sizeof(*h->cbp_table)))  ||
+!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
sizeof(*h->chroma_pred_mode_table))) ||
+!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
sizeof(*h->mvd_table[0])))   ||
+!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
sizeof(*h->mvd_table[1])))   ||
+!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
sizeof(*h->direct_table)))   ||
+!(h->list_counts= av_mallocz_array(big_mb_num, 
sizeof(*h->list_counts)))||
+!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
sizeof(*h->mb2b_xy)))||
+!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
sizeof(*h->mb2br_xy
 return AVERROR(ENOMEM);
 h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
 h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
@@ -252,10 +252,10 @@ int ff_h264_slice_context_init(H264Context *h, 
H264SliceContext *sl)
 er->b8_stride   = h->mb_width * 2 + 1;
 
 // error resilience code looks cleaner with this
-if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
sizeof(int)))   ||
-!(er->error_status_table = av_mallocz_array(mb_array_size, 
sizeof(uint8_t)))   ||
-!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
h->mb_stride + 1, sizeof(int))) ||
-!(sl->dc_val_base= av_mallocz_array(yc_size, 
sizeof(int16_t
+if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
sizeof(*er->mb_index2xy)))  ||
+!(er->error_status_table = av_mallocz_array(mb_array_size, 
sizeof(*er->error_status_table)))   ||
+!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
h->mb_stride + 1, sizeof(*er->er_temp_buffer))) ||
+!(sl->dc_val_base= av_mallocz_array(yc_size, 
sizeof(*sl->dc_val_base
 return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
 
 for (y = 0; y < h->mb_height; y++)
-- 
1.8.3.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 3/7] avcodec/h264dec: replace FF_ALLOCZ{_ARRAY}_OR_GOTO with av_mallocz_array()

2020-05-28 Thread lance . lmwang
From: Limin Wang 

remove the fail goto label and return AVERROR(ENOMEM) directly

Signed-off-by: Limin Wang 
---
 libavcodec/h264dec.c | 60 +++-
 1 file changed, 17 insertions(+), 43 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index b03e6ed..974d324 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -185,38 +185,24 @@ int ff_h264_alloc_tables(H264Context *h)
 const int slice_tsize = big_mb_num + h->mb_stride;
 int x, y;
 
-FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->intra4x4_pred_mode,
-  row_mb_num, 8 * sizeof(uint8_t), fail)
+if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
sizeof(uint8_t)))||
+!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
sizeof(uint8_t)))   ||
+!(h->slice_table_base   = av_mallocz_array(slice_tsize, 
sizeof(*h->slice_table_base)))  ||
+!(h->cbp_table  = av_mallocz_array(big_mb_num, 
sizeof(uint16_t)))   ||
+!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
sizeof(uint8_t)))||
+!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
sizeof(uint8_t)))||
+!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
sizeof(uint8_t)))||
+!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
sizeof(uint8_t)))||
+!(h->list_counts= av_mallocz_array(big_mb_num, 
sizeof(uint8_t)))||
+!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
sizeof(uint32_t)))   ||
+!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
sizeof(uint32_t
+return AVERROR(ENOMEM);
 h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
-
-FF_ALLOCZ_OR_GOTO(h->avctx, h->non_zero_count,
-  big_mb_num * 48 * sizeof(uint8_t), fail)
-FF_ALLOCZ_OR_GOTO(h->avctx, h->slice_table_base,
-  slice_tsize * sizeof(*h->slice_table_base), fail)
-FF_ALLOCZ_OR_GOTO(h->avctx, h->cbp_table,
-  big_mb_num * sizeof(uint16_t), fail)
-FF_ALLOCZ_OR_GOTO(h->avctx, h->chroma_pred_mode_table,
-  big_mb_num * sizeof(uint8_t), fail)
-FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[0],
-  row_mb_num, 16 * sizeof(uint8_t), fail);
-FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[1],
-  row_mb_num, 16 * sizeof(uint8_t), fail);
 h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
 h->slice_ctx[0].mvd_table[1] = h->mvd_table[1];
-
-FF_ALLOCZ_OR_GOTO(h->avctx, h->direct_table,
-  4 * big_mb_num * sizeof(uint8_t), fail);
-FF_ALLOCZ_OR_GOTO(h->avctx, h->list_counts,
-  big_mb_num * sizeof(uint8_t), fail)
-
 memset(h->slice_table_base, -1,
slice_tsize * sizeof(*h->slice_table_base));
 h->slice_table = h->slice_table_base + h->mb_stride * 2 + 1;
-
-FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2b_xy,
-  big_mb_num * sizeof(uint32_t), fail);
-FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2br_xy,
-  big_mb_num * sizeof(uint32_t), fail);
 for (y = 0; y < h->mb_height; y++)
 for (x = 0; x < h->mb_width; x++) {
 const int mb_xy = x + y * h->mb_stride;
@@ -227,9 +213,6 @@ int ff_h264_alloc_tables(H264Context *h)
 }
 
 return 0;
-
-fail:
-return AVERROR(ENOMEM);
 }
 
 /**
@@ -269,8 +252,11 @@ int ff_h264_slice_context_init(H264Context *h, 
H264SliceContext *sl)
 er->b8_stride   = h->mb_width * 2 + 1;
 
 // error resilience code looks cleaner with this
-FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
-  (h->mb_num + 1) * sizeof(int), fail);
+if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
sizeof(int)))   ||
+!(er->error_status_table = av_mallocz_array(mb_array_size, 
sizeof(uint8_t)))   ||
+!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
h->mb_stride + 1, sizeof(int))) ||
+!(sl->dc_val_base= av_mallocz_array(yc_size, 
sizeof(int16_t
+return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
 
 for (y = 0; y < h->mb_height; y++)
 for (x = 0; x < h->mb_width; x++)
@@ -278,15 +264,6 @@ int ff_h264_slice_context_init(H264Context *h, 
H264SliceContext *sl)
 
 er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
   h->mb_stride + 
h->mb_width;
-
-FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
-  mb_array_size * sizeof(uint8_t), fail);
-
-FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
- h->mb_height 

[FFmpeg-devel] [PATCH 5/7] avcodec/h264dec: define and use FF_ALLOCZ_TYPED_ARRAY helper macro

2020-05-28 Thread lance . lmwang
From: Limin Wang 

The macro will help to short the long lines and avoid split them.

Signed-off-by: Limin Wang 
---
 libavcodec/h264dec.c | 30 +++---
 libavutil/internal.h |  2 ++
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index d5b3df3..b797c79 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -185,17 +185,17 @@ int ff_h264_alloc_tables(H264Context *h)
 const int slice_tsize = big_mb_num + h->mb_stride;
 int x, y;
 
-if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
sizeof(*h->intra4x4_pred_mode))) ||
-!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
sizeof(*h->non_zero_count)))||
-!(h->slice_table_base   = av_mallocz_array(slice_tsize, 
sizeof(*h->slice_table_base)))  ||
-!(h->cbp_table  = av_mallocz_array(big_mb_num, 
sizeof(*h->cbp_table)))  ||
-!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
sizeof(*h->chroma_pred_mode_table))) ||
-!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
sizeof(*h->mvd_table[0])))   ||
-!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
sizeof(*h->mvd_table[1])))   ||
-!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
sizeof(*h->direct_table)))   ||
-!(h->list_counts= av_mallocz_array(big_mb_num, 
sizeof(*h->list_counts)))||
-!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
sizeof(*h->mb2b_xy)))||
-!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
sizeof(*h->mb2br_xy
+if (!FF_ALLOCZ_TYPED_ARRAY(h->intra4x4_pred_mode, row_mb_num * 8) ||
+!FF_ALLOCZ_TYPED_ARRAY(h->non_zero_count, big_mb_num * 48)||
+!FF_ALLOCZ_TYPED_ARRAY(h->slice_table_base, slice_tsize)  ||
+!FF_ALLOCZ_TYPED_ARRAY(h->cbp_table, big_mb_num)  ||
+!FF_ALLOCZ_TYPED_ARRAY(h->chroma_pred_mode_table,big_mb_num)  ||
+!FF_ALLOCZ_TYPED_ARRAY(h->mvd_table[0], row_mb_num * 8)   ||
+!FF_ALLOCZ_TYPED_ARRAY(h->mvd_table[1], row_mb_num * 8)   ||
+!FF_ALLOCZ_TYPED_ARRAY(h->direct_table, big_mb_num * 4)   ||
+!FF_ALLOCZ_TYPED_ARRAY(h->list_counts, big_mb_num)||
+!FF_ALLOCZ_TYPED_ARRAY(h->mb2b_xy, big_mb_num)||
+!FF_ALLOCZ_TYPED_ARRAY(h->mb2br_xy, big_mb_num))
 return AVERROR(ENOMEM);
 h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
 h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
@@ -252,10 +252,10 @@ int ff_h264_slice_context_init(H264Context *h, 
H264SliceContext *sl)
 er->b8_stride   = h->mb_width * 2 + 1;
 
 // error resilience code looks cleaner with this
-if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
sizeof(*er->mb_index2xy)))  ||
-!(er->error_status_table = av_mallocz_array(mb_array_size, 
sizeof(*er->error_status_table)))   ||
-!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
h->mb_stride + 1, sizeof(*er->er_temp_buffer))) ||
-!(sl->dc_val_base= av_mallocz_array(yc_size, 
sizeof(*sl->dc_val_base
+ if (!FF_ALLOCZ_TYPED_ARRAY(er->mb_index2xy, h->mb_num + 1)
  ||
+ !FF_ALLOCZ_TYPED_ARRAY(er->error_status_table, mb_array_size) 
  ||
+ !FF_ALLOCZ_TYPED_ARRAY(er->er_temp_buffer, h->mb_height * 
h->mb_stride + 1) ||
+ !FF_ALLOCZ_TYPED_ARRAY(sl->dc_val_base, yc_size))
 return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
 
 for (y = 0; y < h->mb_height; y++)
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 4acbcf5..9c4499e 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -137,6 +137,8 @@
 #   define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, 
__VA_ARGS__,,))
 #endif
 
+#define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_mallocz_array(nelem, 
sizeof(*p)))
+
 #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
 {\
 p = av_malloc(size);\
-- 
1.8.3.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 7/7] avcodec/adpcmenc: remove gotos and error label

2020-05-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/adpcmenc.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index bcb6783..52f0f67 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -65,7 +65,6 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 ADPCMEncodeContext *s = avctx->priv_data;
 uint8_t *extradata;
 int i;
-int ret = AVERROR(ENOMEM);
 
 if (avctx->channels > 2) {
 av_log(avctx, AV_LOG_ERROR, "only stereo or mono is supported\n");
@@ -120,7 +119,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 avctx->bits_per_coded_sample = 4;
 avctx->block_align= BLKSIZE;
 if (!(avctx->extradata = av_malloc(32 + AV_INPUT_BUFFER_PADDING_SIZE)))
-goto error;
+return AVERROR(ENOMEM);
 avctx->extradata_size = 32;
 extradata = avctx->extradata;
 bytestream_put_le16(&extradata, avctx->frame_size);
@@ -140,8 +139,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 avctx->sample_rate != 44100) {
 av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
"22050 or 44100\n");
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 avctx->frame_size = 512 * (avctx->sample_rate / 11025);
 break;
@@ -150,13 +148,10 @@ static av_cold int adpcm_encode_init(AVCodecContext 
*avctx)
 avctx->block_align = BLKSIZE;
 break;
 default:
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 
 return 0;
-error:
-return ret;
 }
 
 static av_cold int adpcm_encode_close(AVCodecContext *avctx)
@@ -725,8 +720,6 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 avpkt->size = pkt_size;
 *got_packet_ptr = 1;
 return 0;
-error:
-return AVERROR(ENOMEM);
 }
 
 static const enum AVSampleFormat sample_fmts[] = {
-- 
1.8.3.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 6/7] avcodec/adpcmenc: remove FF_ALLOC_OR_GOTO macros for gotos will be removed

2020-05-28 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/adpcmenc.c | 25 +
 libavutil/internal.h  |  1 +
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index d5fbc0b..bcb6783 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -89,14 +89,11 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 if (avctx->trellis) {
 int frontier  = 1 << avctx->trellis;
 int max_paths =  frontier * FREEZE_INTERVAL;
-FF_ALLOC_OR_GOTO(avctx, s->paths,
- max_paths * sizeof(*s->paths), error);
-FF_ALLOC_OR_GOTO(avctx, s->node_buf,
- 2 * frontier * sizeof(*s->node_buf),  error);
-FF_ALLOC_OR_GOTO(avctx, s->nodep_buf,
- 2 * frontier * sizeof(*s->nodep_buf), error);
-FF_ALLOC_OR_GOTO(avctx, s->trellis_hash,
- 65536 * sizeof(*s->trellis_hash), error);
+if (!FF_ALLOC_TYPED_ARRAY(s->paths, max_paths)||
+!FF_ALLOC_TYPED_ARRAY(s->node_buf, 2 * frontier)  ||
+!FF_ALLOC_TYPED_ARRAY(s->nodep_buf, 2 * frontier) ||
+!FF_ALLOC_TYPED_ARRAY(s->trellis_hash, 65536))
+return AVERROR(ENOMEM);
 }
 
 avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
@@ -523,7 +520,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 
 /* stereo: 4 bytes (8 samples) for left, 4 bytes for right */
 if (avctx->trellis > 0) {
-FF_ALLOC_ARRAY_OR_GOTO(avctx, buf, avctx->channels, blocks * 8, 
error);
+if (!FF_ALLOC_TYPED_ARRAY(buf, avctx->channels * blocks * 8))
+return AVERROR(ENOMEM);
 for (ch = 0; ch < avctx->channels; ch++) {
 adpcm_compress_trellis(avctx, &samples_p[ch][1],
buf + ch * blocks * 8, &c->status[ch],
@@ -618,7 +616,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 }
 
 if (avctx->trellis > 0) {
-FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
+if (!(buf = av_malloc(2 * n)))
+return AVERROR(ENOMEM);
 adpcm_compress_trellis(avctx, samples + avctx->channels, buf,
&c->status[0], n, avctx->channels);
 if (avctx->channels == 2)
@@ -666,7 +665,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 
 if (avctx->trellis > 0) {
 n = avctx->block_align - 7 * avctx->channels;
-FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
+if (!(buf = av_malloc(2 * n)))
+return AVERROR(ENOMEM);
 if (avctx->channels == 1) {
 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
avctx->channels);
@@ -693,7 +693,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 case AV_CODEC_ID_ADPCM_YAMAHA:
 n = frame->nb_samples / 2;
 if (avctx->trellis > 0) {
-FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 2, error);
+if (!(buf = av_malloc(2 * n * 2)))
+return AVERROR(ENOMEM);
 n *= 2;
 if (avctx->channels == 1) {
 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 9c4499e..485bc3c 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -137,6 +137,7 @@
 #   define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, 
__VA_ARGS__,,))
 #endif
 
+#define FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p)))
 #define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_mallocz_array(nelem, 
sizeof(*p)))
 
 #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
-- 
1.8.3.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 1/2] avcodec/adpcm_data: extend ff_adpcm_ima_cunning_index_table

2020-05-28 Thread Zane van Iperen
On Thu, 28 May 2020 14:12:33 +0200
"Michael Niedermayer"  wrote:

> 
> Fixes: overread by 1
> Fixes:
> 21880/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_CUNNING_fuzzer-5717917221257216.fuzz
> 
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> 
> -const int8_t ff_adpcm_ima_cunning_index_table[8] = {
> --1, -1, -1, -1, 1, 2, 3, 4,
> +const int8_t ff_adpcm_ima_cunning_index_table[9] = {
> +-1, -1, -1, -1, 1, 2, 3, 4, 5
>  };
> 
The index table should only ever be indexed between [0,7], so this
looks like a bug in adpcm_ima_cunning_expand_nibble() instead. 

Where would one go to see the inputs for this? I'd like to investigate
(and test against the original decoder).

Zane




___
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 v7 1/3] avfilter/graphdump: support for the graph2dot function

2020-05-28 Thread lance . lmwang
On Mon, May 25, 2020 at 07:50:24AM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/Makefile|   1 -
>  libavfilter/graphdump.c |  89 +
>  tools/graph2dot.c   | 204 
> 
>  3 files changed, 89 insertions(+), 205 deletions(-)
>  delete mode 100644 tools/graph2dot.c
> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 4d07bb6..291126e 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -526,7 +526,6 @@ SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h
>  
>  OBJS-$(CONFIG_LIBGLSLANG)+= glslang.o
>  
> -TOOLS = graph2dot
>  TESTPROGS = drawutils filtfmts formats integral
>  
>  TOOLS-$(CONFIG_LIBZMQ) += zmqsend
> diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
> index 79ef1a7..97d4f39 100644
> --- a/libavfilter/graphdump.c
> +++ b/libavfilter/graphdump.c
> @@ -151,15 +151,104 @@ static void avfilter_graph_dump_to_buf(AVBPrint *buf, 
> AVFilterGraph *graph)
>  }
>  }
>  
> +static void avfilter_graph2dot_to_buf(AVBPrint *buf, AVFilterGraph *graph)
> +{
> +int i, j;
> +
> +av_bprintf(buf, "digraph G {\n");
> +av_bprintf(buf, "node [shape=box]\n");
> +av_bprintf(buf, "rankdir=LR\n");
> +
> +for (i = 0; i < graph->nb_filters; i++) {
> +char filter_ctx_label[128];
> +const AVFilterContext *filter_ctx = graph->filters[i];
> +
> +snprintf(filter_ctx_label, sizeof(filter_ctx_label), "%s\\n(%s)",
> + filter_ctx->name,
> + filter_ctx->filter->name);
> +
> +for (j = 0; j < filter_ctx->nb_outputs; j++) {
> +AVFilterLink *link = filter_ctx->outputs[j];
> +if (link) {
> +char dst_filter_ctx_label[128];
> +const AVFilterContext *dst_filter_ctx = link->dst;
> +
> +snprintf(dst_filter_ctx_label, sizeof(dst_filter_ctx_label),
> + "%s\\n(%s)",
> + dst_filter_ctx->name,
> + dst_filter_ctx->filter->name);
> +
> +av_bprintf(buf, "\"%s\" -> \"%s\" [ label= \"inpad:%s -> 
> outpad:%s\\n",
> +filter_ctx_label, dst_filter_ctx_label,
> +avfilter_pad_get_name(link->srcpad, 0),
> +avfilter_pad_get_name(link->dstpad, 0));
> +
> +if (link->type == AVMEDIA_TYPE_VIDEO) {
> +const AVPixFmtDescriptor *desc = 
> av_pix_fmt_desc_get(link->format);
> +av_bprintf(buf,
> +"fmt:%s w:%d h:%d tb:%d/%d",
> +desc->name,
> +link->w, link->h,
> +link->time_base.num, link->time_base.den);
> +} else if (link->type == AVMEDIA_TYPE_AUDIO) {
> +char audio_buf[255];
> +av_get_channel_layout_string(audio_buf, 
> sizeof(audio_buf), -1,
> + link->channel_layout);
> +av_bprintf(buf,
> +"fmt:%s sr:%d cl:%s tb:%d/%d",
> +av_get_sample_fmt_name(link->format),
> +link->sample_rate, audio_buf,
> +link->time_base.num, link->time_base.den);
> +}
> +av_bprintf(buf, "\" ];\n");
> +}
> +}
> +}
> +av_bprintf(buf, "}\n");
> +}
> +
>  char *avfilter_graph_dump(AVFilterGraph *graph, const char *options)
>  {
>  AVBPrint buf;
>  char *dump = NULL;
> +int ret;
> +AVDictionary *dict = NULL;
> +AVDictionaryEntry *format = NULL;
> +AVDictionaryEntry *filename = NULL;
> +
> +ret = av_dict_parse_string(&dict, options, "=", ":", 0);
> +if (ret < 0) {
> +av_dict_free(&dict);
> +return NULL;
> +}
> +format = av_dict_get(dict, "fmt", NULL, 0);
>  
> +if (format && !av_strcasecmp(format->value, "DOT")) {
> +av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
> +avfilter_graph2dot_to_buf(&buf, graph);
> +av_bprint_finalize(&buf, &dump);
> +} else {
>  av_bprint_init(&buf, 0, AV_BPRINT_SIZE_COUNT_ONLY);
>  avfilter_graph_dump_to_buf(&buf, graph);
>  av_bprint_init(&buf, buf.len + 1, buf.len + 1);
>  avfilter_graph_dump_to_buf(&buf, graph);
>  av_bprint_finalize(&buf, &dump);
> +}
> +
> +if (filename = av_dict_get(dict, "filename", NULL, 0)) {
> +FILE* file = fopen(filename->value, "w");
> +if (!file) {
> +av_log(graph, AV_LOG_ERROR, "failed to open: %s \n", 
> filename->value);
> +av_freep(&dump);
> +return NULL;
> +}
> +if (dump) {
> +fputs(dump, file);
> +fflush(file);
> +}
> +fclose(file);
> +}
> +

Re: [FFmpeg-devel] [PATCH v7 1/3] avfilter/graphdump: support for the graph2dot function

2020-05-28 Thread Nicolas George
lance.lmw...@gmail.com (12020-05-28):
> will apply the patchset tomorrow if no further comments.

Please give me time to look carefully. This is not urgent.

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 4/7] avcodec/h264dec: prefer to use variable instead of type for sizeof

2020-05-28 Thread myp...@gmail.com
On Thu, May 28, 2020 at 9:58 PM  wrote:
>
> From: Limin Wang 
>
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/h264dec.c | 28 ++--
>  1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index 974d324..d5b3df3 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -185,17 +185,17 @@ int ff_h264_alloc_tables(H264Context *h)
>  const int slice_tsize = big_mb_num + h->mb_stride;
>  int x, y;
>
> -if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
> sizeof(uint8_t)))||
> -!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
> sizeof(uint8_t)))   ||
> +if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
> sizeof(*h->intra4x4_pred_mode))) ||
> +!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
> sizeof(*h->non_zero_count)))||
>  !(h->slice_table_base   = av_mallocz_array(slice_tsize, 
> sizeof(*h->slice_table_base)))  ||
> -!(h->cbp_table  = av_mallocz_array(big_mb_num, 
> sizeof(uint16_t)))   ||
> -!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
> sizeof(uint8_t)))||
> -!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
> sizeof(uint8_t)))||
> -!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
> sizeof(uint8_t)))||
> -!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
> sizeof(uint8_t)))||
> -!(h->list_counts= av_mallocz_array(big_mb_num, 
> sizeof(uint8_t)))||
> -!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
> sizeof(uint32_t)))   ||
> -!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
> sizeof(uint32_t
> +!(h->cbp_table  = av_mallocz_array(big_mb_num, 
> sizeof(*h->cbp_table)))  ||
> +!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
> sizeof(*h->chroma_pred_mode_table))) ||
> +!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
> sizeof(*h->mvd_table[0])))   ||
> +!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
> sizeof(*h->mvd_table[1])))   ||
> +!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
> sizeof(*h->direct_table)))   ||
> +!(h->list_counts= av_mallocz_array(big_mb_num, 
> sizeof(*h->list_counts)))||
> +!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
> sizeof(*h->mb2b_xy)))||
> +!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
> sizeof(*h->mb2br_xy
>  return AVERROR(ENOMEM);
>  h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
>  h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
> @@ -252,10 +252,10 @@ int ff_h264_slice_context_init(H264Context *h, 
> H264SliceContext *sl)
>  er->b8_stride   = h->mb_width * 2 + 1;
>
>  // error resilience code looks cleaner with this
> -if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
> sizeof(int)))   ||
> -!(er->error_status_table = av_mallocz_array(mb_array_size, 
> sizeof(uint8_t)))   ||
> -!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
> h->mb_stride + 1, sizeof(int))) ||
> -!(sl->dc_val_base= av_mallocz_array(yc_size, 
> sizeof(int16_t
> +if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
> sizeof(*er->mb_index2xy)))  ||
> +!(er->error_status_table = av_mallocz_array(mb_array_size, 
> sizeof(*er->error_status_table)))   ||
> +!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
> h->mb_stride + 1, sizeof(*er->er_temp_buffer))) ||
> +!(sl->dc_val_base= av_mallocz_array(yc_size, 
> sizeof(*sl->dc_val_base
>  return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for 
> us
>
>  for (y = 0; y < h->mb_height; y++)
> --
Do you have any special reason to use 2 patches (patch 3-4) and don't
combine patch 3-4 as one patch?   And I don't think splitting this
step as 2 patches will help code-review

The other thing is, I can't find this change for what special reasons
___
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 v7 1/3] avfilter/graphdump: support for the graph2dot function

2020-05-28 Thread lance . lmwang
On Thu, May 28, 2020 at 04:14:27PM +0200, Nicolas George wrote:
> lance.lmw...@gmail.com (12020-05-28):
> > will apply the patchset tomorrow if no further comments.
> 
> Please give me time to look carefully. This is not urgent.

Of course, thanks for review, anytime is OK, stay tune.

> 
> Regards,
> 
> -- 
>   Nicolas George



> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2] avformat/oggenc: Add partial support for OggPCM muxing

2020-05-28 Thread Lynne
May 28, 2020, 11:34 by oreo...@outlook.com:

> This adds partial support for OggPCM muxing.
>
> +static inline uint32_t ogg_get_pcm_format_id(uint32_t codec_id)
>

use enum AVCodecID instead of uint32_t.
Also use that in ogg_pcm_codec for the codec IDs.



> +{
> +int i;
> +
> +for (i = 0; i < FF_ARRAY_ELEMS(ogg_pcm_codecs); i++)
>

Save 2 lines, use for (int i...



> +if (ogg_pcm_codecs[i].codec_id == codec_id)
> +return ogg_pcm_codecs[i].format_id;
> +
> +return 0;
>

return AV_CODEC_ID_NONE;



> +}
> +
>  static void ogg_write_page(AVFormatContext *s, OGGPage *page, int 
> extra_flags)
>  {
>  OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data;
> @@ -363,6 +393,39 @@ static int ogg_build_speex_headers(AVCodecParameters 
> *par,
>  return 0;
>  }
>
> +#define OGGPCM_HEADER_SIZE 224
> +
> +static int ogg_build_pcm_headers(AVCodecParameters *par,
> +   OGGStreamContext *oggstream, int bitexact,
> +   AVDictionary **m)
>

Indentation seems wrong here.



> +{
> +uint8_t *p;
> +
> +// first packet: OggPCM header
> +p = av_mallocz(OGGPCM_HEADER_SIZE);
> +if (!p)
> +return AVERROR(ENOMEM);
> +oggstream->header[0] = p;
> +oggstream->header_len[0] = OGGPCM_HEADER_SIZE;
> +bytestream_put_buffer(&p, "PCM ", 8); // Identifier
> +bytestream_put_be16(&p, 0x00); // VMAJ
> +bytestream_put_be16(&p, 0x00); // VMIN
> +bytestream_put_be32(&p, ogg_get_pcm_format_id(par->codec_id)); // PCM fmt
> +bytestream_put_be32(&p, par->sample_rate); // Sample rate
> +bytestream_put_byte(&p, 0); // Significant bits (0 == Same as fmt)
>

That's not correct.
par->bits_per_raw_sample is what you want it set to.



> +bytestream_put_byte(&p, par->channels); // Channels
> +bytestream_put_be16(&p, 0); // Max frames per packet TODO:// Actually 
> calculate max frames per packet
>

That's not really possible. PCM data packets can contain any number of samples.
Best you can do is place an upper bound for it, since an Ogg packet cannot be 
larger than
65xxx bytes.



> +bytestream_put_be32(&p, 0); // Number of extra headers
> +
> +// second packet: VorbisComment
> +p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 
> 0, NULL, 0);
> +if (!p)
> +return AVERROR(ENOMEM);
> +oggstream->header[1] = p;
> +
> +return 0;
> +}
> +
>  #define OPUS_HEADER_SIZE 19
>
>  static int ogg_build_opus_headers(AVCodecParameters *par,
> @@ -487,18 +550,20 @@ static int ogg_init(AVFormatContext *s)
>  avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
>  }
>
> -if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS &&
> -st->codecpar->codec_id != AV_CODEC_ID_THEORA &&
> -st->codecpar->codec_id != AV_CODEC_ID_SPEEX  &&
> -st->codecpar->codec_id != AV_CODEC_ID_FLAC   &&
> -st->codecpar->codec_id != AV_CODEC_ID_OPUS   &&
> +if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS   &&
> +st->codecpar->codec_id != AV_CODEC_ID_THEORA   &&
> +st->codecpar->codec_id != AV_CODEC_ID_SPEEX&&
> +st->codecpar->codec_id != AV_CODEC_ID_FLAC &&
> +st->codecpar->codec_id != AV_CODEC_ID_OPUS &&
> +!ogg_get_pcm_format_id(st->codecpar->codec_id) &&
>  st->codecpar->codec_id != AV_CODEC_ID_VP8) {
>  av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
>  return AVERROR(EINVAL);
>  }
>
>  if ((!st->codecpar->extradata || !st->codecpar->extradata_size) &&
> -st->codecpar->codec_id != AV_CODEC_ID_VP8) {
> +st->codecpar->codec_id != AV_CODEC_ID_VP8  &&
> +!ogg_get_pcm_format_id(st->codecpar->codec_id)) {
>  av_log(s, AV_LOG_ERROR, "No extradata present\n");
>  return AVERROR_INVALIDDATA;
>  }
> @@ -553,6 +618,14 @@ static int ogg_init(AVFormatContext *s)
>  av_log(s, AV_LOG_ERROR, "Error writing VP8 headers\n");
>  return err;
>  }
> +} else if (ogg_get_pcm_format_id(st->codecpar->codec_id)) {
> +int err = ogg_build_pcm_headers(st->codecpar, oggstream,
> +  s->flags & AVFMT_FLAG_BITEXACT,
> +  &st->metadata);
>

Indent seems wrong here too.

___
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/7] avcodec/h264dec: prefer to use variable instead of type for sizeof

2020-05-28 Thread lance . lmwang
On Thu, May 28, 2020 at 10:18:09PM +0800, myp...@gmail.com wrote:
> On Thu, May 28, 2020 at 9:58 PM  wrote:
> >
> > From: Limin Wang 
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  libavcodec/h264dec.c | 28 ++--
> >  1 file changed, 14 insertions(+), 14 deletions(-)
> >
> > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> > index 974d324..d5b3df3 100644
> > --- a/libavcodec/h264dec.c
> > +++ b/libavcodec/h264dec.c
> > @@ -185,17 +185,17 @@ int ff_h264_alloc_tables(H264Context *h)
> >  const int slice_tsize = big_mb_num + h->mb_stride;
> >  int x, y;
> >
> > -if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
> > sizeof(uint8_t)))||
> > -!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
> > sizeof(uint8_t)))   ||
> > +if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
> > sizeof(*h->intra4x4_pred_mode))) ||
> > +!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
> > sizeof(*h->non_zero_count)))||
> >  !(h->slice_table_base   = av_mallocz_array(slice_tsize, 
> > sizeof(*h->slice_table_base)))  ||
> > -!(h->cbp_table  = av_mallocz_array(big_mb_num, 
> > sizeof(uint16_t)))   ||
> > -!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
> > sizeof(uint8_t)))||
> > -!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
> > sizeof(uint8_t)))||
> > -!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
> > sizeof(uint8_t)))||
> > -!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
> > sizeof(uint8_t)))||
> > -!(h->list_counts= av_mallocz_array(big_mb_num, 
> > sizeof(uint8_t)))||
> > -!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
> > sizeof(uint32_t)))   ||
> > -!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
> > sizeof(uint32_t
> > +!(h->cbp_table  = av_mallocz_array(big_mb_num, 
> > sizeof(*h->cbp_table)))  ||
> > +!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
> > sizeof(*h->chroma_pred_mode_table))) ||
> > +!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
> > sizeof(*h->mvd_table[0])))   ||
> > +!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
> > sizeof(*h->mvd_table[1])))   ||
> > +!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
> > sizeof(*h->direct_table)))   ||
> > +!(h->list_counts= av_mallocz_array(big_mb_num, 
> > sizeof(*h->list_counts)))||
> > +!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
> > sizeof(*h->mb2b_xy)))||
> > +!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
> > sizeof(*h->mb2br_xy
> >  return AVERROR(ENOMEM);
> >  h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
> >  h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
> > @@ -252,10 +252,10 @@ int ff_h264_slice_context_init(H264Context *h, 
> > H264SliceContext *sl)
> >  er->b8_stride   = h->mb_width * 2 + 1;
> >
> >  // error resilience code looks cleaner with this
> > -if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
> > sizeof(int)))   ||
> > -!(er->error_status_table = av_mallocz_array(mb_array_size, 
> > sizeof(uint8_t)))   ||
> > -!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
> > h->mb_stride + 1, sizeof(int))) ||
> > -!(sl->dc_val_base= av_mallocz_array(yc_size, 
> > sizeof(int16_t
> > +if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
> > sizeof(*er->mb_index2xy)))  ||
> > +!(er->error_status_table = av_mallocz_array(mb_array_size, 
> > sizeof(*er->error_status_table)))   ||
> > +!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
> > h->mb_stride + 1, sizeof(*er->er_temp_buffer))) ||
> > +!(sl->dc_val_base= av_mallocz_array(yc_size, 
> > sizeof(*sl->dc_val_base
> >  return AVERROR(ENOMEM); // ff_h264_free_tables will clean up 
> > for us
> >
> >  for (y = 0; y < h->mb_height; y++)
> > --
> Do you have any special reason to use 2 patches (patch 3-4) and don't
> combine patch 3-4 as one patch?   And I don't think splitting this
> step as 2 patches will help code-review
At first, I change 3-4 in one patch, but it's difficult to say clearly in the 
commit message for two changes mixed,
so I split into 2 patch.

> 
> The other thing is, I can't find this change for what special reasons

refine the code for better readiablity, remove the unneeded gotos, remove the
FF_ALLOC{Z}{_ARRAY}_OR_G

Re: [FFmpeg-devel] [PATCH 3/4] avfilter: add ff_inlink_peek_samples and ff_inlink_skip samples

2020-05-28 Thread Paul B Mahol
On 5/28/20, Nicolas George  wrote:
> Paul B Mahol (12020-05-24):
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavfilter/avfilter.c | 61 +-
>>  libavfilter/filters.h  | 17 
>>  2 files changed, 72 insertions(+), 6 deletions(-)
>
> I am against this.
>
> It adds quite a lot of complexity in common code.
>
> This complexity is not needed: in patch 4/4, you always peek
> s->window_size samples and skip s->hop_size, constants: just allocate a
> permanent buffer with size s->window_size and roll by s->hop_size in it.
> It will be more efficient (less copying around, less allocations) and
> simpler.
>

Your arrogance means nothing to me.

Will apply in 5 minutes.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/7] avcodec/h264dec: replace FF_ALLOCZ{_ARRAY}_OR_GOTO with av_mallocz_array()

2020-05-28 Thread lance . lmwang
On Thu, May 28, 2020 at 09:57:26PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> remove the fail goto label and return AVERROR(ENOMEM) directly
> 
> Signed-off-by: Limin Wang 
> ---
>  libavcodec/h264dec.c | 60 
> +++-
>  1 file changed, 17 insertions(+), 43 deletions(-)
> 
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index b03e6ed..974d324 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -185,38 +185,24 @@ int ff_h264_alloc_tables(H264Context *h)
>  const int slice_tsize = big_mb_num + h->mb_stride;
>  int x, y;
>  
> -FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->intra4x4_pred_mode,
> -  row_mb_num, 8 * sizeof(uint8_t), fail)
> +if (!(h->intra4x4_pred_mode = av_mallocz_array(row_mb_num * 8, 
> sizeof(uint8_t)))||
> +!(h->non_zero_count = av_mallocz_array(big_mb_num * 48, 
> sizeof(uint8_t)))   ||
> +!(h->slice_table_base   = av_mallocz_array(slice_tsize, 
> sizeof(*h->slice_table_base)))  ||
> +!(h->cbp_table  = av_mallocz_array(big_mb_num, 
> sizeof(uint16_t)))   ||
> +!(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, 
> sizeof(uint8_t)))||
> +!(h->mvd_table[0]   = av_mallocz_array(row_mb_num * 8, 
> sizeof(uint8_t)))||
> +!(h->mvd_table[1]   = av_mallocz_array(row_mb_num * 8, 
> sizeof(uint8_t)))||
> +!(h->direct_table   = av_mallocz_array(big_mb_num * 4, 
> sizeof(uint8_t)))||
> +!(h->list_counts= av_mallocz_array(big_mb_num, 
> sizeof(uint8_t)))||
> +!(h->mb2b_xy= av_mallocz_array(big_mb_num, 
> sizeof(uint32_t)))   ||
> +!(h->mb2br_xy   = av_mallocz_array(big_mb_num, 
> sizeof(uint32_t
> +return AVERROR(ENOMEM);
>  h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
> -
> -FF_ALLOCZ_OR_GOTO(h->avctx, h->non_zero_count,
> -  big_mb_num * 48 * sizeof(uint8_t), fail)
> -FF_ALLOCZ_OR_GOTO(h->avctx, h->slice_table_base,
> -  slice_tsize * sizeof(*h->slice_table_base), fail)
> -FF_ALLOCZ_OR_GOTO(h->avctx, h->cbp_table,
> -  big_mb_num * sizeof(uint16_t), fail)
> -FF_ALLOCZ_OR_GOTO(h->avctx, h->chroma_pred_mode_table,
> -  big_mb_num * sizeof(uint8_t), fail)
> -FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[0],
> -  row_mb_num, 16 * sizeof(uint8_t), fail);
> -FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[1],
> -  row_mb_num, 16 * sizeof(uint8_t), fail);
>  h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
>  h->slice_ctx[0].mvd_table[1] = h->mvd_table[1];
> -
> -FF_ALLOCZ_OR_GOTO(h->avctx, h->direct_table,
> -  4 * big_mb_num * sizeof(uint8_t), fail);
> -FF_ALLOCZ_OR_GOTO(h->avctx, h->list_counts,
> -  big_mb_num * sizeof(uint8_t), fail)
> -
>  memset(h->slice_table_base, -1,
> slice_tsize * sizeof(*h->slice_table_base));
>  h->slice_table = h->slice_table_base + h->mb_stride * 2 + 1;
> -
> -FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2b_xy,
> -  big_mb_num * sizeof(uint32_t), fail);
> -FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2br_xy,
> -  big_mb_num * sizeof(uint32_t), fail);
>  for (y = 0; y < h->mb_height; y++)
>  for (x = 0; x < h->mb_width; x++) {
>  const int mb_xy = x + y * h->mb_stride;
> @@ -227,9 +213,6 @@ int ff_h264_alloc_tables(H264Context *h)
>  }
>  
>  return 0;
> -
> -fail:
> -return AVERROR(ENOMEM);
>  }
>  
>  /**
> @@ -269,8 +252,11 @@ int ff_h264_slice_context_init(H264Context *h, 
> H264SliceContext *sl)
>  er->b8_stride   = h->mb_width * 2 + 1;
>  
>  // error resilience code looks cleaner with this
> -FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
> -  (h->mb_num + 1) * sizeof(int), fail);
> +if (!(er->mb_index2xy= av_mallocz_array(h->mb_num + 1, 
> sizeof(int)))   ||
> +!(er->error_status_table = av_mallocz_array(mb_array_size, 
> sizeof(uint8_t)))   ||
> +!(er->er_temp_buffer = av_mallocz_array(h->mb_height * 
> h->mb_stride + 1, sizeof(int))) ||
> +!(sl->dc_val_base= av_mallocz_array(yc_size, 
> sizeof(int16_t
> +return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for 
> us
>  
>  for (y = 0; y < h->mb_height; y++)
>  for (x = 0; x < h->mb_width; x++)
> @@ -278,15 +264,6 @@ int ff_h264_slice_context_init(H264Context *h, 
> H264SliceContext *sl)
>  
>  er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
>

[FFmpeg-devel] [PATCH 1/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread Michael Niedermayer
TODO: Bump

Signed-off-by: Michael Niedermayer 
---
 doc/APIchanges | 3 +++
 doc/codecs.texi| 2 ++
 libavcodec/avcodec.h   | 6 ++
 libavcodec/h264dec.c   | 2 +-
 libavcodec/options_table.h | 1 +
 tools/target_dec_fuzzer.c  | 2 +-
 6 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index fb5534b5f5..3e20a44379 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-xx-xx - xx - lavc 58.xx.100 - avcodec.h
+  Add AV_CODEC_FLAG2_FAST_UNSAFE
+
 2020-xx-xx - xx - lavc 58.88.100 - avcodec.h codec.h
   Move AVCodec-related public API to new header codec.h.
 
diff --git a/doc/codecs.texi b/doc/codecs.texi
index c092aadc0e..46790b66b3 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -787,6 +787,8 @@ Possible values:
 @table @samp
 @item fast
 Allow non spec compliant speedup tricks.
+@item fast_unsafe
+Allow speedup tricks which can lead to out of array reads and crashes on 
damaged or crafted files.
 @item noout
 Skip bitstream encoding.
 @item ignorecrop
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 01099bc8cd..479f219b43 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -346,6 +346,12 @@ typedef struct RcOverride{
  * Allow non spec compliant speedup tricks.
  */
 #define AV_CODEC_FLAG2_FAST   (1 <<  0)
+
+/**
+ * Allow speedups tricks which can read out of array on non compliant streams.
+ */
+#define AV_CODEC_FLAG2_FAST_UNSAFE(1 <<  1)
+
 /**
  * Skip bitstream encoding.
  */
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index e463fde2a5..b764caa942 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -603,7 +603,7 @@ static int decode_nal_units(H264Context *h, const uint8_t 
*buf, int buf_size)
 }
 
 ret = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, h->is_avc, 
h->nal_length_size,
-avctx->codec_id, avctx->flags2 & 
AV_CODEC_FLAG2_FAST, 0);
+avctx->codec_id, avctx->flags2 & 
AV_CODEC_FLAG2_FAST_UNSAFE, 0);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR,
"Error splitting the input into NAL units.\n");
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 8ba137f51e..4e26b844f6 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -71,6 +71,7 @@ static const AVOption avcodec_options[] = {
 {"drop_changed", "Drop frames whose parameters differ from first decoded 
frame", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_DROPCHANGED }, INT_MIN, 
INT_MAX, A|V|D, "flags"},
 {"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, 
UINT_MAX, V|A|E|D|S, "flags2"},
 {"fast", "allow non-spec-compliant speedup tricks", 0, AV_OPT_TYPE_CONST, 
{.i64 = AV_CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"},
+{"fast_unsafe", "allow speedup tricks which can read out of arrays", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_FAST_UNSAFE }, INT_MIN, INT_MAX, V|E, 
"flags2"},
 {"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 
AV_CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"},
 {"ignorecrop", "ignore cropping information from sps", 0, AV_OPT_TYPE_CONST, 
{.i64 = AV_CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"},
 {"local_header", "place global headers at every keyframe instead of in 
extradata", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_LOCAL_HEADER }, 
INT_MIN, INT_MAX, V|E, "flags2"},
diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index d01deaf8d5..414cdab593 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -208,7 +208,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 if (flags & 8)
 ctx->err_recognition |= AV_EF_EXPLODE;
 }
-if ((flags & 0x10) && c->id != AV_CODEC_ID_H264)
+if (flags & 0x10)
 ctx->flags2 |= AV_CODEC_FLAG2_FAST;
 
 if (flags & 0x40)
-- 
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 2/2] avcodec/lzf: Consider the needed size in reallocation

2020-05-28 Thread Michael Niedermayer
Fixes: NULL pointer dereference
Fixes: 
22381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-5659879921680384.fuzz

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

diff --git a/libavcodec/lzf.c b/libavcodec/lzf.c
index 5b7526ef18..1e3c86c88c 100644
--- a/libavcodec/lzf.c
+++ b/libavcodec/lzf.c
@@ -49,7 +49,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, 
int64_t *size)
 if (s < LZF_LITERAL_MAX) {
 s++;
 if (s > *size - len) {
-*size += *size /2;
+*size += s + *size /2;
 ret = av_reallocp(buf, *size);
 if (ret < 0)
 return ret;
@@ -72,7 +72,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, 
int64_t *size)
 return AVERROR_INVALIDDATA;
 
 if (l > *size - len) {
-*size += *size / 2;
+*size += l + *size / 2;
 ret = av_reallocp(buf, *size);
 if (ret < 0)
 return ret;
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/adpcm_data: extend ff_adpcm_ima_cunning_index_table

2020-05-28 Thread Michael Niedermayer
On Thu, May 28, 2020 at 02:06:32PM +, Zane van Iperen wrote:
> On Thu, 28 May 2020 14:12:33 +0200
> "Michael Niedermayer"  wrote:
> 
> > 
> > Fixes: overread by 1
> > Fixes:
> > 21880/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_CUNNING_fuzzer-5717917221257216.fuzz
> > 
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > 
> > -const int8_t ff_adpcm_ima_cunning_index_table[8] = {
> > --1, -1, -1, -1, 1, 2, 3, 4,
> > +const int8_t ff_adpcm_ima_cunning_index_table[9] = {
> > +-1, -1, -1, -1, 1, 2, 3, 4, 5
> >  };
> > 
> The index table should only ever be indexed between [0,7], so this
> looks like a bug in adpcm_ima_cunning_expand_nibble() instead. 

maybe it should be only 0..7 but abs(-8 .. 7) needs a 8th entrty or a
check


> 
> Where would one go to see the inputs for this? I'd like to investigate
> (and test against the original decoder).

The file is from a fuzzer so is random trash and it needs target_dec_fuzzer.c 
to be read. It wont be read as "Pro Pinball Series Soundbank"
so i think that file will not be useful to test the behavior of the original
decoder as i would assume it will not accept the target_dec_fuzzer data
but i surely can send it to you privatly if you need it.
just say if you want me to send you the file

Thanks

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread James Almer
On 5/28/2020 1:20 PM, Michael Niedermayer wrote:
> TODO: Bump
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  doc/APIchanges | 3 +++
>  doc/codecs.texi| 2 ++
>  libavcodec/avcodec.h   | 6 ++
>  libavcodec/h264dec.c   | 2 +-
>  libavcodec/options_table.h | 1 +
>  tools/target_dec_fuzzer.c  | 2 +-
>  6 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index fb5534b5f5..3e20a44379 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>  
>  API changes, most recent first:
>  
> +2020-xx-xx - xx - lavc 58.xx.100 - avcodec.h
> +  Add AV_CODEC_FLAG2_FAST_UNSAFE
> +
>  2020-xx-xx - xx - lavc 58.88.100 - avcodec.h codec.h
>Move AVCodec-related public API to new header codec.h.
>  
> diff --git a/doc/codecs.texi b/doc/codecs.texi
> index c092aadc0e..46790b66b3 100644
> --- a/doc/codecs.texi
> +++ b/doc/codecs.texi
> @@ -787,6 +787,8 @@ Possible values:
>  @table @samp
>  @item fast
>  Allow non spec compliant speedup tricks.
> +@item fast_unsafe
> +Allow speedup tricks which can lead to out of array reads and crashes on 
> damaged or crafted files.

This will raise more than a couple eyebrows. Having an option to enable
what people will consider security issues is not a good idea at all. For
starters, it acknowledges lavc is not secure and has known issues that
are purposely not being fixed. And on top of it, this can't be outright
disabled/removed at compile time, so something could still call
ffmpeg/lavc with it enabled.

The issues should be fixed, or the relevant "fast" codepath in the
decoder removed for being buggy.

>  @item noout
>  Skip bitstream encoding.
>  @item ignorecrop
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 01099bc8cd..479f219b43 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -346,6 +346,12 @@ typedef struct RcOverride{
>   * Allow non spec compliant speedup tricks.
>   */
>  #define AV_CODEC_FLAG2_FAST   (1 <<  0)
> +
> +/**
> + * Allow speedups tricks which can read out of array on non compliant 
> streams.
> + */
> +#define AV_CODEC_FLAG2_FAST_UNSAFE(1 <<  1)
> +
>  /**
>   * Skip bitstream encoding.
>   */
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index e463fde2a5..b764caa942 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -603,7 +603,7 @@ static int decode_nal_units(H264Context *h, const uint8_t 
> *buf, int buf_size)
>  }
>  
>  ret = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, h->is_avc, 
> h->nal_length_size,
> -avctx->codec_id, avctx->flags2 & 
> AV_CODEC_FLAG2_FAST, 0);
> +avctx->codec_id, avctx->flags2 & 
> AV_CODEC_FLAG2_FAST_UNSAFE, 0);
>  if (ret < 0) {
>  av_log(avctx, AV_LOG_ERROR,
> "Error splitting the input into NAL units.\n");
> diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> index 8ba137f51e..4e26b844f6 100644
> --- a/libavcodec/options_table.h
> +++ b/libavcodec/options_table.h
> @@ -71,6 +71,7 @@ static const AVOption avcodec_options[] = {
>  {"drop_changed", "Drop frames whose parameters differ from first decoded 
> frame", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_DROPCHANGED }, INT_MIN, 
> INT_MAX, A|V|D, "flags"},
>  {"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, 
> UINT_MAX, V|A|E|D|S, "flags2"},
>  {"fast", "allow non-spec-compliant speedup tricks", 0, AV_OPT_TYPE_CONST, 
> {.i64 = AV_CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"},
> +{"fast_unsafe", "allow speedup tricks which can read out of arrays", 0, 
> AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_FAST_UNSAFE }, INT_MIN, INT_MAX, 
> V|E, "flags2"},
>  {"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = 
> AV_CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"},
>  {"ignorecrop", "ignore cropping information from sps", 0, AV_OPT_TYPE_CONST, 
> {.i64 = AV_CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"},
>  {"local_header", "place global headers at every keyframe instead of in 
> extradata", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_LOCAL_HEADER }, 
> INT_MIN, INT_MAX, V|E, "flags2"},
> diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> index d01deaf8d5..414cdab593 100644
> --- a/tools/target_dec_fuzzer.c
> +++ b/tools/target_dec_fuzzer.c
> @@ -208,7 +208,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>  if (flags & 8)
>  ctx->err_recognition |= AV_EF_EXPLODE;
>  }
> -if ((flags & 0x10) && c->id != AV_CODEC_ID_H264)
> +if (flags & 0x10)
>  ctx->flags2 |= AV_CODEC_FLAG2_FAST;
>  
>  if (flags & 0x40)
> 

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

To unsubscri

Re: [FFmpeg-devel] [PATCH 3/4] avfilter: add ff_inlink_peek_samples and ff_inlink_skip samples

2020-05-28 Thread Nicolas George
Paul B Mahol (12020-05-28):
> Will apply in 5 minutes.

No. This code is unnecessary and complicates things.

-- 
  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 3/4] avfilter: add ff_inlink_peek_samples and ff_inlink_skip samples

2020-05-28 Thread Paul B Mahol
On 5/28/20, Nicolas George  wrote:
> Paul B Mahol (12020-05-28):
>> Will apply in 5 minutes.
>
> No. This code is unnecessary and complicates things.

You can say whatever you want. I simply do not care.

You could block it months ago instead of requesting me to lose all my
precious time on your requested changes.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/4] avfilter: add ff_inlink_peek_samples and ff_inlink_skip samples

2020-05-28 Thread Nicolas George
Paul B Mahol (12020-05-28):
> You can say whatever you want. I simply do not care.
> 
> You could block it months ago instead of requesting me to lose all my
> precious time on your requested changes.

This is not about you, it is about the code. I did not notice the
problem then, I notice it now. Better than after it is pushed

And since you are being rude, I am allowed to say what I have on my
mind:

I would not have to reject your code if it was good in the first place.
Spend fifteen minutes more thinking about your code before writing it,
and we would not have to waste both hours arguing over it.

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

[FFmpeg-devel] [PATCH] Replace 'FontName' with 'Fontname' in the documentation.

2020-05-28 Thread Joe Ratterman
This is the only use of 'FontName' with that capitalization, as both
source-code and tests use 'Fontname'. Having consistent capitalization
makes it easier to find the relevant source from the docs.

See these examples for other uses:
libavcodec/ass_split.c:68
tests/ref/fate/sub-cc:9
---
 doc/filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 85a511b205..84afa1fff3 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17943,7 +17943,7 @@ subtitles=video.mkv:si=1
 To make the subtitles stream from @file{sub.srt} appear in 80% transparent blue
 @code{DejaVu Serif}, use:
 @example
-subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HCCFF'
+subtitles=sub.srt:force_style='Fontname=DejaVu Serif,PrimaryColour=&HCCFF'
 @end example
 
 @section super2xsai
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH 3/4] avfilter: add ff_inlink_peek_samples and ff_inlink_skip samples

2020-05-28 Thread Paul B Mahol
On 5/28/20, Nicolas George  wrote:
> Paul B Mahol (12020-05-28):
>> You can say whatever you want. I simply do not care.
>>
>> You could block it months ago instead of requesting me to lose all my
>> precious time on your requested changes.
>
> This is not about you, it is about the code. I did not notice the
> problem then, I notice it now. Better than after it is pushed
>
> And since you are being rude, I am allowed to say what I have on my
> mind:
>
> I would not have to reject your code if it was good in the first place.
> Spend fifteen minutes more thinking about your code before writing it,
> and we would not have to waste both hours arguing over it.
>

You are one that are extremely unpleasant and rude to me and to anyone else.

Your technical explanation is invalid, and your proposed solution
extremely convoluted
and needs more code for each filter needing this functionality.

Watch me applying this set.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread Michael Niedermayer
On Thu, May 28, 2020 at 01:43:17PM -0300, James Almer wrote:
> On 5/28/2020 1:20 PM, Michael Niedermayer wrote:
> > TODO: Bump
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  doc/APIchanges | 3 +++
> >  doc/codecs.texi| 2 ++
> >  libavcodec/avcodec.h   | 6 ++
> >  libavcodec/h264dec.c   | 2 +-
> >  libavcodec/options_table.h | 1 +
> >  tools/target_dec_fuzzer.c  | 2 +-
> >  6 files changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index fb5534b5f5..3e20a44379 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -15,6 +15,9 @@ libavutil: 2017-10-21
> >  
> >  API changes, most recent first:
> >  
> > +2020-xx-xx - xx - lavc 58.xx.100 - avcodec.h
> > +  Add AV_CODEC_FLAG2_FAST_UNSAFE
> > +
> >  2020-xx-xx - xx - lavc 58.88.100 - avcodec.h codec.h
> >Move AVCodec-related public API to new header codec.h.
> >  
> > diff --git a/doc/codecs.texi b/doc/codecs.texi
> > index c092aadc0e..46790b66b3 100644
> > --- a/doc/codecs.texi
> > +++ b/doc/codecs.texi
> > @@ -787,6 +787,8 @@ Possible values:
> >  @table @samp
> >  @item fast
> >  Allow non spec compliant speedup tricks.
> > +@item fast_unsafe
> > +Allow speedup tricks which can lead to out of array reads and crashes on 
> > damaged or crafted files.
> 
> This will raise more than a couple eyebrows. Having an option to enable
> what people will consider security issues is not a good idea at all. For
> starters, it acknowledges lavc is not secure and has known issues that
> are purposely not being fixed.

now, thats not what this was intended to do, of course.
the idea is more

A user can have a stream that is known to be valid, quite possibly
the users own stream, or otherwise "in house" made or already checked
to be valid.

In that case any code that is only needed for invalid streams becomes
unneeded.


> And on top of it, this can't be outright
> disabled/removed at compile time, so something could still call
> ffmpeg/lavc with it enabled.

well, yes, but thats not the only such case
we have other options to enable unsafe behavior


> 
> The issues should be fixed, or the relevant "fast" codepath in the
> decoder removed for being buggy.

h264 is a specific use of this flag, and that might not be the only
place it could be used in

But about h264 What this is about if i remember it correctly, is
that the maximum input any crafted bitstream of a block can require is X,
now you can if the input size is less than X copy that to a larger buffer or
you can add lots of checks. Both of these slow the code down a bit.
OTOH, if the stream is known to be valid that can be skipped.

It can also be skiped if the buffer is already big enough to begin with
OR if the output goes to the parser and not the decoder.
So even without the user having access to this, the codepath does not
become unneeded
the h264 case is more a "even if you cant proof its safe on case 123
use it anyway"
And quite possibly we can add more code detecting more cases where
it is safe, this should be investigated either way probably.

Thanks

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

If the United States is serious about tackling the national security threats 
related to an insecure 5G network, it needs to rethink the extent to which it
values corporate profits and government espionage over security.-Bruce Schneier


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/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread Anton Khirnov
Quoting Lynne (2020-05-28 18:26:44)
> May 28, 2020, 17:20 by mich...@niedermayer.cc:
> 
> > TODO: Bump
> >
> >  */
> >  #define AV_CODEC_FLAG2_FAST   (1 <<  0)
> > +
> > +/**
> > + * Allow speedups tricks which can read out of array on non compliant 
> > streams.
> > + */
> > +#define AV_CODEC_FLAG2_FAST_UNSAFE(1 <<  1)
> >
> 
> That's a bug. We should absolutely not have flags to enable bugs.
> The fast flag should be removed from h264 until that bug is fixed,
> or deprecated altogether.

+9001

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread Anton Khirnov
Quoting Michael Niedermayer (2020-05-28 20:09:15)
> 
> h264 is a specific use of this flag, and that might not be the only
> place it could be used in
> 
> But about h264 What this is about if i remember it correctly, is
> that the maximum input any crafted bitstream of a block can require is X,
> now you can if the input size is less than X copy that to a larger buffer or
> you can add lots of checks. Both of these slow the code down a bit.
> OTOH, if the stream is known to be valid that can be skipped.
> 
> It can also be skiped if the buffer is already big enough to begin with
> OR if the output goes to the parser and not the decoder.
> So even without the user having access to this, the codepath does not
> become unneeded
> the h264 case is more a "even if you cant proof its safe on case 123
> use it anyway"
> And quite possibly we can add more code detecting more cases where
> it is safe, this should be investigated either way probably.

It does not seem to me that there is a sufficient use case for "decode
as fast as possible, even at the cost of crashing sometimes". Big
transcoders like youtube have process untrusted input and therefore care
about correctness. End-user playback is either fast enough or
hardware-accelerated (and thus fast enough).

What kind of users do you believe warrants this extra complexity?

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread Michael Niedermayer
On Thu, May 28, 2020 at 08:09:15PM +0200, Michael Niedermayer wrote:
> On Thu, May 28, 2020 at 01:43:17PM -0300, James Almer wrote:
> > On 5/28/2020 1:20 PM, Michael Niedermayer wrote:
> > > TODO: Bump
> > > 
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  doc/APIchanges | 3 +++
> > >  doc/codecs.texi| 2 ++
> > >  libavcodec/avcodec.h   | 6 ++
> > >  libavcodec/h264dec.c   | 2 +-
> > >  libavcodec/options_table.h | 1 +
> > >  tools/target_dec_fuzzer.c  | 2 +-
> > >  6 files changed, 14 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/doc/APIchanges b/doc/APIchanges
> > > index fb5534b5f5..3e20a44379 100644
> > > --- a/doc/APIchanges
> > > +++ b/doc/APIchanges
> > > @@ -15,6 +15,9 @@ libavutil: 2017-10-21
> > >  
> > >  API changes, most recent first:
> > >  
> > > +2020-xx-xx - xx - lavc 58.xx.100 - avcodec.h
> > > +  Add AV_CODEC_FLAG2_FAST_UNSAFE
> > > +
> > >  2020-xx-xx - xx - lavc 58.88.100 - avcodec.h codec.h
> > >Move AVCodec-related public API to new header codec.h.
> > >  
> > > diff --git a/doc/codecs.texi b/doc/codecs.texi
> > > index c092aadc0e..46790b66b3 100644
> > > --- a/doc/codecs.texi
> > > +++ b/doc/codecs.texi
> > > @@ -787,6 +787,8 @@ Possible values:
> > >  @table @samp
> > >  @item fast
> > >  Allow non spec compliant speedup tricks.
> > > +@item fast_unsafe
> > > +Allow speedup tricks which can lead to out of array reads and crashes on 
> > > damaged or crafted files.
> > 
> > This will raise more than a couple eyebrows. Having an option to enable
> > what people will consider security issues is not a good idea at all. For
> > starters, it acknowledges lavc is not secure and has known issues that
> > are purposely not being fixed.
> 
> now, thats not what this was intended to do, of course.
> the idea is more
> 
> A user can have a stream that is known to be valid, quite possibly
> the users own stream, or otherwise "in house" made or already checked
> to be valid.
> 
> In that case any code that is only needed for invalid streams becomes
> unneeded.
> 
> 
> > And on top of it, this can't be outright
> > disabled/removed at compile time, so something could still call
> > ffmpeg/lavc with it enabled.
> 
> well, yes, but thats not the only such case
> we have other options to enable unsafe behavior

Also if people dont want a "fast_unsafe" flag we surely can
just drop this patch, and set the value to 0 where it otherwise would be
used

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


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

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

[FFmpeg-devel] [RFC PATCH] libavcodec/jpeg2000_parser: Add jpeg2000 parser

2020-05-28 Thread gautamramk
From: Gautam Ramakrishnan 

I have attempted to write a JPEG2000 Parser. Have tested
by generating a file containing 14 frames, as mentioned
by Micheal. Have also tried testing with various packet
sizes by setting -frame_size option. Need feedback on the
code and on further testing.
---
 libavcodec/Makefile  |   1 +
 libavcodec/jpeg2000_parser.c | 190 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 192 insertions(+)
 create mode 100644 libavcodec/jpeg2000_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d0917a656f..1f7c91a91b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1073,6 +1073,7 @@ OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
 OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
 OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_sei.o h264data.o
 OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
+OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
 OBJS-$(CONFIG_MJPEG_PARSER)+= mjpeg_parser.o
 OBJS-$(CONFIG_MLP_PARSER)  += mlp_parse.o mlp_parser.o mlp.o
 OBJS-$(CONFIG_MPEG4VIDEO_PARSER)   += mpeg4video_parser.o h263.o \
diff --git a/libavcodec/jpeg2000_parser.c b/libavcodec/jpeg2000_parser.c
new file mode 100644
index 00..c28b694219
--- /dev/null
+++ b/libavcodec/jpeg2000_parser.c
@@ -0,0 +1,190 @@
+/*
+ * JPEG2000 parser
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * JPEG2000 parser.
+ */
+
+#include "parser.h"
+
+/* Whether frame is jp2 file or codestream
+*/
+enum frame_type {
+jp2_file = 1,
+j2k_cstream
+};
+
+typedef struct JPEG2000ParserContext{
+ParseContext pc;
+uint64_t bytes_read;
+uint64_t fheader_state;
+uint32_t skip_bytes; // skip bytes inside codestream data
+enum frame_type ft; // 1 if file, 2 if codestream
+uint8_t fheader_read; // are we reading
+uint8_t reading_file_header;
+uint8_t skipped_codestream;
+uint8_t codestream_frame_end;
+uint8_t read_tp;
+uint8_t in_codestream;
+}JPEG2000ParserContext;
+
+static inline void reset_context(JPEG2000ParserContext *m)
+{
+ParseContext *pc = &m->pc;
+
+pc->frame_start_found= 0;
+pc->state = 0;
+m->bytes_read = 0;
+m->ft = 0;
+m->skipped_codestream = 0;
+m->fheader_read = 0;
+m->codestream_frame_end = 0;
+m->skip_bytes = 0;
+m->read_tp = 0;
+m->in_codestream = 0;
+}
+
+/* Returns 1 if marker has any data which can be skipped
+*/
+static uint8_t info_marker(uint16_t marker)
+{
+if (marker == 0xFF92 || marker == 0xFF4F ||
+marker == 0xFF90 || marker == 0xFF93 ||
+marker == 0xFFD9)
+return 0;
+else
+if (marker > 0xFF00) return 1;
+return 0;
+}
+
+/**
+ * Find the end of the current frame in the bitstream.
+ * @return the position of the first byte of the next frame, or -1
+ */
+static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int 
buf_size)
+{
+ParseContext *pc= &m->pc;
+int i;
+uint32_t state;
+uint64_t state64;
+state= pc->state;
+state64 = pc->state64;
+if (buf_size == 0) {
+return 0;
+}
+
+for (i = 0; i < buf_size; i++) {
+state = state << 8 | buf[i];
+state64 = state64 << 8 | buf[i];
+m->bytes_read++;
+if (m->skip_bytes) {
+m->skip_bytes--;
+continue;
+}
+if (m->codestream_frame_end) {
+reset_context(m);
+return i;
+}
+if (m->read_tp) { // Find out how many bytes inside Tile part 
codestream to skip.
+if (m->read_tp == 1){
+m->skip_bytes = (state64 & 0x) - 10 > 0?
+(state64 & 0x) - 10 : 0;
+}
+m->read_tp--;
+}
+if (m->fheader_read) {
+if (m->fheader_read == 1) {
+if (state64 == 0x6A5020200D0A870A) { // JP2 signature box 
value.
+if (pc->frame_start_found) {
+pc->frame_start_found = 0;
+reset_context(m);
+return i - 11;
+ 

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread Michael Niedermayer
On Thu, May 28, 2020 at 08:30:16PM +0200, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2020-05-28 20:09:15)
> > 
> > h264 is a specific use of this flag, and that might not be the only
> > place it could be used in
> > 
> > But about h264 What this is about if i remember it correctly, is
> > that the maximum input any crafted bitstream of a block can require is X,
> > now you can if the input size is less than X copy that to a larger buffer or
> > you can add lots of checks. Both of these slow the code down a bit.
> > OTOH, if the stream is known to be valid that can be skipped.
> > 
> > It can also be skiped if the buffer is already big enough to begin with
> > OR if the output goes to the parser and not the decoder.
> > So even without the user having access to this, the codepath does not
> > become unneeded
> > the h264 case is more a "even if you cant proof its safe on case 123
> > use it anyway"
> > And quite possibly we can add more code detecting more cases where
> > it is safe, this should be investigated either way probably.
> 
> It does not seem to me that there is a sufficient use case for "decode
> as fast as possible, even at the cost of crashing sometimes". Big
> transcoders like youtube have process untrusted input and therefore care
> about correctness. End-user playback is either fast enough or
> hardware-accelerated (and thus fast enough).
> 
> What kind of users do you believe warrants this extra complexity?

The patch really was a response to kieran and jbs comments
They asked this to be either fixed or warnings to be added / documented

declaring the fast flag as unsafe would make it unusable for many
usecases.
And the specific feature can be removed / split to a different flag
but not really "fixed".
So this patch was born which moved it into a clearly documented new
flag.
Apparently that struck a nerve of some people, even though i asked
about it before posting it.

We can drop this patch and disable the one case, if thats what people
want

More generally though (outside this unsafe flag case) 
i do disagree with your argument a bit, performance does matter.
Iam regularly reminded of that for example, so much software becomes
slower on each upgrade with few if any features added the real users
care about. Just to pick one, the editor i use to write replies in mutt
is slower to close than before i upgraded the OS. 

Also again to stay general here, this does not apply to the unsafe flag.
speed / cpu load does add up. Slower code means more CO2 emissions if
the software is used alot.
If you want a real example insetad of this flag where we could improve
IIRC there was some code iterating over options in the iteration over
options resulting in some sort of O(n^3) or so. Thats from memory though
would need to check where that was exactly but thats something we should
fix. 

Thanks


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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


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

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

Re: [FFmpeg-devel] [PATCH 3/5] [mov] Check if DTS is AV_NOPTS_VALUE in mov_find_next_sample().

2020-05-28 Thread Dale Curtis
  Bump now that the saturated math operations have landed. Thanks!

- dale

On Thu, May 14, 2020 at 3:31 PM Dale Curtis  wrote:

>
> Signed-off-by: Dale Curtis 
> ---
>  libavformat/mov.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
___
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/5] [utils, mathematics] Fix overflow in compute_pkt_fields().

2020-05-28 Thread Dale Curtis
  Bump now that the saturated math operations have landed. Thanks!

- dale

On Thu, May 14, 2020 at 3:31 PM Dale Curtis  wrote:

> Fixes one issue in the function itself and one in the dependent
> function av_add_stable() which wasn't checking for NaN.
>
> Signed-off-by: Dale Curtis 
> ---
>  libavformat/utils.c | 2 +-
>  libavutil/mathematics.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
___
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] [oggparsetheora] Use av_sat_sub64() when updating pts by duration.

2020-05-28 Thread Dale Curtis
  Bump now that the saturated math operations have landed. Thanks!

- dale

On Thu, May 14, 2020 at 3:31 PM Dale Curtis  wrote:

> Signed-off-by: Dale Curtis 
> ---
>  libavformat/oggparsetheora.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/5] Use av_sat_add64() when updating start_time by skip_samples.

2020-05-28 Thread Dale Curtis
Bump now that the saturated math operations have landed. Thanks!

- dale

On Thu, May 14, 2020 at 3:31 PM Dale Curtis  wrote:

> Avoids overflow from fuzzed skip_samples values.
>
> Signed-off-by: Dale Curtis 
> ---
>  libavformat/utils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
___
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] libavfilter/vf_drawtext.c:add support to generte ms level

2020-05-28 Thread Michael Niedermayer
On Thu, May 28, 2020 at 04:31:58PM +0800, 黄思远 wrote:

> ea327ff8f5deb8958062cf9dc0d5c4acbb47111d  
> 0001-libavfilter-vf_drawtext.c-add-support-to-generte-ms-.patch
> From 94cf5f13eaf565ea230ca3628119029caf07d2c5 Mon Sep 17 00:00:00 2001
> From: SiyuanHuang 
> Date: Thu, 28 May 2020 13:42:01 +0800
> Subject: [PATCH] libavfilter/vf_drawtext.c:add support to generte ms level
>  timestamp
> 
> for test latency , need sub-seconds level timestamp watermark
> 
> Signed-off-by: SiyuanHuang 
> ---
>  libavfilter/vf_drawtext.c | 19 +--
>  1 file changed, 17 insertions(+), 2 deletions(-)
>  mode change 100644 => 100755 libavfilter/vf_drawtext.c
> 
> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> old mode 100644
> new mode 100755
> index abe1ca6c35..734556eef3
> --- a/libavfilter/vf_drawtext.c
> +++ b/libavfilter/vf_drawtext.c
> @@ -61,6 +61,8 @@
>  #include "internal.h"
>  #include "video.h"
>  
> +#include 
> +#include 
>  #if CONFIG_LIBFRIBIDI
>  #include 
>  #endif
> @@ -1322,8 +1324,21 @@ static int draw_text(AVFilterContext *ctx, AVFrame 
> *frame,
>  return ret;
>  break;
>  case EXP_STRFTIME:
> -localtime_r(&now,  -av_bprint_strftime(bp, s->text,  +if (!= av_stristr(s->text, "mspts")) {

Please test your code before submitting, this will not build

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/libaomenc: remove the experimental flag when using libaom 2.0.0 or newer

2020-05-28 Thread James Almer
On 5/27/2020 2:46 PM, James Zern wrote:
> On Tue, May 26, 2020 at 6:40 PM James Almer  wrote:
>>
>> Signed-off-by: James Almer 
>> ---
>> Alternatively, we could remove support for libaom 1.0.0, since it's pretty 
>> much
>> unusable. But unfortunately both current Debian Stable and latest Ubuntu LTS
>> ship it, so i'm not sure if it would be wise.
>>
>> Any opinions?
>>
> 
> Those were based off of the normative branch so I agree with you it's
> pretty unusable. For LTS at least if there has been an incompatible
> ffmpeg release since their snapshot I don't think a new one with
> libaom disabled would get pulled in. That said, I'm ok with leaving
> 1.0.0 support through another release and when we see 2.0 get picked
> up by distros. This patch is lgtm depending on other people's
> preferences.

The idea is that if a library version is supported in one version of
ffmpeg, there should be a good argument to drop it in future versions.
So while libaom 1.0.0 is extremely slow, it (in theory) still produces
valid output, is supposedly not insecure, and is the only version
currently shipped by non rolling release distros.

Will apply this soon unless someone objects.
___
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 05/17] lavu/opt: add a more general child class iteration API

2020-05-28 Thread Anton Khirnov
Use opaque iteration state instead of the previous child class. This
mirrors similar changes done in lavf/lavc.

Deprecate the av_opt_child_class_next() API.
---
 libavutil/log.h | 13 +
 libavutil/opt.c | 24 ++--
 libavutil/opt.h | 31 +++
 libavutil/version.h |  3 +++
 4 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/libavutil/log.h b/libavutil/log.h
index 9c14188a9c..4a7fdca8c2 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -112,6 +112,7 @@ typedef struct AVClass {
  */
 void* (*child_next)(void *obj, void *prev);
 
+#if FF_API_CHILD_CLASS_NEXT
 /**
  * Return an AVClass corresponding to the next potential
  * AVOptions-enabled child.
@@ -120,7 +121,9 @@ typedef struct AVClass {
  * child_next iterates over _already existing_ objects, while
  * child_class_next iterates over _all possible_ children.
  */
+attribute_deprecated
 const struct AVClass* (*child_class_next)(const struct AVClass *prev);
+#endif
 
 /**
  * Category used for visualization (like color)
@@ -140,6 +143,16 @@ typedef struct AVClass {
  * available since version (52.12)
  */
 int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, 
int flags);
+
+/**
+ * Return an AVClass corresponding to the next potential
+ * AVOptions-enabled child.
+ *
+ * The difference between child_next and this is that
+ * child_next iterates over _already existing_ objects, while
+ * child_class_next iterates over _all possible_ children.
+ */
+const struct AVClass* (*child_class_iterate)(void **iter);
 } AVClass;
 
 /**
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 423313bce2..2c3f998d97 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1679,8 +1679,9 @@ const AVOption *av_opt_find2(void *obj, const char *name, 
const char *unit,
 
 if (search_flags & AV_OPT_SEARCH_CHILDREN) {
 if (search_flags & AV_OPT_SEARCH_FAKE_OBJ) {
-const AVClass *child = NULL;
-while (child = av_opt_child_class_next(c, child))
+void *iter = NULL;
+const AVClass *child;
+while (child = av_opt_child_class_iterate(c, &iter))
 if (o = av_opt_find2(&child, name, unit, opt_flags, 
search_flags, NULL))
 return o;
 } else {
@@ -1715,12 +1716,31 @@ void *av_opt_child_next(void *obj, void *prev)
 return NULL;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
+FF_DISABLE_DEPRECATION_WARNINGS
 const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass 
*prev)
 {
 if (parent->child_class_next)
 return parent->child_class_next(prev);
 return NULL;
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter)
+{
+if (parent->child_class_iterate)
+return parent->child_class_iterate(iter);
+#if FF_API_CHILD_CLASS_NEXT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (parent->child_class_next) {
+*iter = parent->child_class_next(*iter);
+return *iter;
+}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+return NULL;
+}
 
 void *av_opt_ptr(const AVClass *class, void *obj, const char *name)
 {
diff --git a/libavutil/opt.h b/libavutil/opt.h
index e46119572a..8dc020a820 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -114,7 +114,7 @@
  *  libavcodec exports generic options, while its priv_data field exports
  *  codec-specific options). In such a case, it is possible to set up the
  *  parent struct to export a child's options. To do that, simply
- *  implement AVClass.child_next() and AVClass.child_class_next() in the
+ *  implement AVClass.child_next() and AVClass.child_class_iterate() in the
  *  parent struct's AVClass.
  *  Assuming that the test_struct from above now also contains a
  *  child_struct field:
@@ -143,23 +143,25 @@
  *  return t->child_struct;
  *  return NULL
  *  }
- *  const AVClass child_class_next(const AVClass *prev)
+ *  const AVClass child_class_iterate(void **iter)
  *  {
- *  return prev ? NULL : &child_class;
+ *  const AVClass *c = *iter ? NULL : &child_class;
+ *  *iter = (void*)(uintptr_t)c;
+ *  return c;
  *  }
  *  @endcode
- *  Putting child_next() and child_class_next() as defined above into
+ *  Putting child_next() and child_class_iterate() as defined above into
  *  test_class will now make child_struct's options accessible through
  *  test_struct (again, proper setup as described above needs to be done on
  *  child_struct right after it is created).
  *
  *  From the above example it might not be clear why both child_next()
- *  and child_class_next() are needed. The distinction is that child_next()
- *  iterates over actually existing objects, while child_class_next()
+ *  and child_

[FFmpeg-devel] [PATCH 01/17] Remove unnecessary use of avcodec_close().

2020-05-28 Thread Anton Khirnov
Replace it with avcodec_free_context() or drop it completely as
appropriate.
---
 libavcodec/avrndec.c   |  3 +--
 libavcodec/smvjpegdec.c|  3 +--
 libavcodec/tests/options.c |  1 -
 libavfilter/vf_subtitles.c |  1 -
 libavfilter/vf_uspp.c  |  6 ++
 tests/api/api-band-test.c  |  1 -
 tests/api/api-flac-test.c  | 18 ++
 tests/api/api-h264-test.c  |  1 -
 tests/api/api-seek-test.c  |  1 -
 9 files changed, 6 insertions(+), 29 deletions(-)

diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
index 104ff2d904..a7bdab280d 100644
--- a/libavcodec/avrndec.c
+++ b/libavcodec/avrndec.c
@@ -91,8 +91,7 @@ static av_cold int end(AVCodecContext *avctx)
 {
 AVRnContext *a = avctx->priv_data;
 
-avcodec_close(a->mjpeg_avctx);
-av_freep(&a->mjpeg_avctx);
+avcodec_free_context(&a->mjpeg_avctx);
 
 return 0;
 }
diff --git a/libavcodec/smvjpegdec.c b/libavcodec/smvjpegdec.c
index 7ea82ebfee..209f3ff334 100644
--- a/libavcodec/smvjpegdec.c
+++ b/libavcodec/smvjpegdec.c
@@ -84,8 +84,7 @@ static av_cold int smvjpeg_decode_end(AVCodecContext *avctx)
 jpg->picture_ptr = NULL;
 av_frame_free(&s->picture[0]);
 av_frame_free(&s->picture[1]);
-ret = avcodec_close(s->avctx);
-av_freep(&s->avctx);
+avcodec_free_context(&s->avctx);
 return ret;
 }
 
diff --git a/libavcodec/tests/options.c b/libavcodec/tests/options.c
index 2e19a6eac2..010e3c0145 100644
--- a/libavcodec/tests/options.c
+++ b/libavcodec/tests/options.c
@@ -167,7 +167,6 @@ static void test_copy(const AVCodec *c1, const AVCodec *c2)
 avcodec_copy_context(ctx2, ctx1);
 test_copy_print_codec(ctx1);
 test_copy_print_codec(ctx2);
-avcodec_close(ctx1);
 }
 avcodec_free_context(&ctx1);
 avcodec_free_context(&ctx2);
diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index a3b4029af4..1bd42391e0 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -478,7 +478,6 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
 
 end:
 av_dict_free(&codec_opts);
-avcodec_close(dec_ctx);
 avcodec_free_context(&dec_ctx);
 avformat_close_input(&fmt);
 return ret;
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index da4029f4b2..f6fb193433 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -468,10 +468,8 @@ static av_cold void uninit(AVFilterContext *ctx)
 av_freep(&uspp->src[i]);
 }
 
-for (i = 0; i < (1 << uspp->log2_count); i++) {
-avcodec_close(uspp->avctx_enc[i]);
-av_freep(&uspp->avctx_enc[i]);
-}
+for (i = 0; i < (1 << uspp->log2_count); i++)
+avcodec_free_context(&uspp->avctx_enc[i]);
 
 av_freep(&uspp->non_b_qp_table);
 av_freep(&uspp->outbuf);
diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c
index a84f6b7e55..257e741694 100644
--- a/tests/api/api-band-test.c
+++ b/tests/api/api-band-test.c
@@ -198,7 +198,6 @@ static int video_decode(const char *input_filename)
 
 av_packet_unref(&pkt);
 av_frame_free(&fr);
-avcodec_close(ctx);
 avformat_close_input(&fmt_ctx);
 avcodec_free_context(&ctx);
 av_freep(&byte_buffer);
diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index ae6a9316d8..3fea3258f3 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -223,20 +223,6 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 return 0;
 }
 
-static int close_encoder(AVCodecContext **enc_ctx)
-{
-avcodec_close(*enc_ctx);
-av_freep(enc_ctx);
-return 0;
-}
-
-static int close_decoder(AVCodecContext **dec_ctx)
-{
-avcodec_close(*dec_ctx);
-av_freep(dec_ctx);
-return 0;
-}
-
 int main(void)
 {
 AVCodec *enc = NULL, *dec = NULL;
@@ -265,8 +251,8 @@ int main(void)
 return 1;
 if (run_test(enc, dec, enc_ctx, dec_ctx) != 0)
 return 1;
-close_encoder(&enc_ctx);
-close_decoder(&dec_ctx);
+avcodec_free_context(&enc_ctx);
+avcodec_free_context(&dec_ctx);
 }
 }
 
diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
index 60a3ae5ef4..678a1ea166 100644
--- a/tests/api/api-h264-test.c
+++ b/tests/api/api-h264-test.c
@@ -144,7 +144,6 @@ static int video_decode_example(const char *input_filename)
 
 av_packet_unref(&pkt);
 av_frame_free(&fr);
-avcodec_close(ctx);
 avformat_close_input(&fmt_ctx);
 avcodec_free_context(&ctx);
 av_freep(&byte_buffer);
diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
index d0531a2f73..ae33581244 100644
--- a/tests/api/api-seek-test.c
+++ b/tests/api/api-seek-test.c
@@ -266,7 +266,6 @@ end:
 av_freep(&crc_array);
 av_freep(&pts_array);
 av_frame_free(&fr);
-avcodec_close(ctx);
 avformat_close_input(&fmt_ctx);
 avcodec_free_context(&ctx);
 return result;
-- 
2.26.2

_

[FFmpeg-devel] [PATCH 09/17] af_aresample: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavfilter/af_aresample.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index ef10621c35..fb10bd1c33 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -293,10 +293,19 @@ static int request_frame(AVFilterLink *outlink)
 return ret;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
 static const AVClass *resample_child_class_next(const AVClass *prev)
 {
 return prev ? NULL : swr_get_class();
 }
+#endif
+
+static const AVClass *resample_child_class_iterate(void **iter)
+{
+const AVClass *c = *iter ? NULL : swr_get_class();
+*iter = (void*)(uintptr_t)c;
+return c;
+}
 
 static void *resample_child_next(void *obj, void *prev)
 {
@@ -317,7 +326,10 @@ static const AVClass aresample_class = {
 .item_name= av_default_item_name,
 .option   = options,
 .version  = LIBAVUTIL_VERSION_INT,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = resample_child_class_next,
+#endif
+.child_class_iterate = resample_child_class_iterate,
 .child_next   = resample_child_next,
 };
 
-- 
2.26.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 03/17] lavf/dump: schedule use of deprecated API for removal

2020-05-28 Thread Anton Khirnov
---
 libavformat/dump.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavformat/dump.c b/libavformat/dump.c
index 06bafc272d..117c68145c 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -500,6 +500,8 @@ static void dump_stream_format(AVFormatContext *ic, int i,
 return;
 }
 
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
 // Fields which are missing from AVCodecParameters need to be taken from 
the AVCodecContext
 avctx->properties = st->codec->properties;
 avctx->codec  = st->codec->codec;
@@ -507,6 +509,8 @@ static void dump_stream_format(AVFormatContext *ic, int i,
 avctx->qmax   = st->codec->qmax;
 avctx->coded_width  = st->codec->coded_width;
 avctx->coded_height = st->codec->coded_height;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 if (separator)
 av_opt_set(avctx, "dump_separator", separator, 0);
@@ -541,7 +545,13 @@ static void dump_stream_format(AVFormatContext *ic, int i,
 int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
 int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
 int tbn = st->time_base.den && st->time_base.num;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
 int tbc = st->codec->time_base.den && st->codec->time_base.num;
+FF_ENABLE_DEPRECATION_WARNINGS
+#else
+int tbc = 0;
+#endif
 
 if (fps || tbr || tbn || tbc)
 av_log(NULL, AV_LOG_INFO, "%s", separator);
@@ -552,8 +562,12 @@ static void dump_stream_format(AVFormatContext *ic, int i,
 print_fps(av_q2d(st->r_frame_rate), tbn || tbc ? "tbr, " : "tbr");
 if (tbn)
 print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn");
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
 if (tbc)
 print_fps(1 / av_q2d(st->codec->time_base), "tbc");
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 }
 
 if (st->disposition & AV_DISPOSITION_DEFAULT)
-- 
2.26.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 06/17] fftools: switch to the new child class iteration API

2020-05-28 Thread Anton Khirnov
---
 fftools/cmdutils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index a948d478d5..e7ceed1c38 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -202,13 +202,14 @@ void show_help_options(const OptionDef *options, const 
char *msg, int req_flags,
 
 void show_help_children(const AVClass *class, int flags)
 {
-const AVClass *child = NULL;
+void *iter = NULL;
+const AVClass *child;
 if (class->option) {
 av_opt_show2(&class, NULL, flags, 0);
 printf("\n");
 }
 
-while (child = av_opt_child_class_next(class, child))
+while (child = av_opt_child_class_iterate(class, &iter))
 show_help_children(child, flags);
 }
 
-- 
2.26.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 14/17] vf_spp: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavfilter/vf_spp.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c
index a83b1195c0..4bcc6429e0 100644
--- a/libavfilter/vf_spp.c
+++ b/libavfilter/vf_spp.c
@@ -44,10 +44,19 @@ enum mode {
 NB_MODES
 };
 
+#if FF_API_CHILD_CLASS_NEXT
 static const AVClass *child_class_next(const AVClass *prev)
 {
 return prev ? NULL : avcodec_dct_get_class();
 }
+#endif
+
+static const AVClass *child_class_iterate(void **iter)
+{
+const AVClass *c = *iter ? NULL : avcodec_dct_get_class();
+*iter = (void*)(uintptr_t)c;
+return c;
+}
 
 static void *child_next(void *obj, void *prev)
 {
@@ -74,7 +83,10 @@ static const AVClass spp_class = {
 .option   = spp_options,
 .version  = LIBAVUTIL_VERSION_INT,
 .category = AV_CLASS_CATEGORY_FILTER,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = child_class_next,
+#endif
+.child_class_iterate = child_class_iterate,
 .child_next   = child_next,
 };
 
-- 
2.26.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 13/17] vf_scale: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavfilter/vf_scale.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 0348f19d33..f92529e7c8 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -882,10 +882,19 @@ static int process_command(AVFilterContext *ctx, const 
char *cmd, const char *ar
 return ret;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
 static const AVClass *child_class_next(const AVClass *prev)
 {
 return prev ? NULL : sws_get_class();
 }
+#endif
+
+static const AVClass *child_class_iterate(void **iter)
+{
+const AVClass *c = *iter ? NULL : sws_get_class();
+*iter = (void*)(uintptr_t)c;
+return c;
+}
 
 #define OFFSET(x) offsetof(ScaleContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
@@ -944,7 +953,10 @@ static const AVClass scale_class = {
 .option   = scale_options,
 .version  = LIBAVUTIL_VERSION_INT,
 .category = AV_CLASS_CATEGORY_FILTER,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = child_class_next,
+#endif
+.child_class_iterate = child_class_iterate,
 };
 
 static const AVFilterPad avfilter_vf_scale_inputs[] = {
@@ -984,7 +996,10 @@ static const AVClass scale2ref_class = {
 .option   = scale_options,
 .version  = LIBAVUTIL_VERSION_INT,
 .category = AV_CLASS_CATEGORY_FILTER,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = child_class_next,
+#endif
+.child_class_iterate = child_class_iterate,
 };
 
 static const AVFilterPad avfilter_vf_scale2ref_inputs[] = {
-- 
2.26.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 10/17] af_resample: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavfilter/af_resample.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c
index e3c6a20696..785cd0c7f4 100644
--- a/libavfilter/af_resample.c
+++ b/libavfilter/af_resample.c
@@ -306,10 +306,19 @@ fail:
 return ret;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
 static const AVClass *resample_child_class_next(const AVClass *prev)
 {
 return prev ? NULL : avresample_get_class();
 }
+#endif
+
+static const AVClass *resample_child_class_iterate(void **iter)
+{
+const AVClass *c = *iter ? NULL : avresample_get_class();
+*iter = (void*)(uintptr_t)c;
+return c;
+}
 
 static void *resample_child_next(void *obj, void *prev)
 {
@@ -321,7 +330,10 @@ static const AVClass resample_class = {
 .class_name   = "resample",
 .item_name= av_default_item_name,
 .version  = LIBAVUTIL_VERSION_INT,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = resample_child_class_next,
+#endif
+.child_class_iterate = resample_child_class_iterate,
 .child_next   = resample_child_next,
 };
 
-- 
2.26.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 16/17] AVIOContext: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavformat/aviobuf.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index eb0387bdf7..5ba5de01c6 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -48,10 +48,19 @@ static void *ff_avio_child_next(void *obj, void *prev)
 return prev ? NULL : s->opaque;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
 static const AVClass *ff_avio_child_class_next(const AVClass *prev)
 {
 return prev ? NULL : &ffurl_context_class;
 }
+#endif
+
+static const AVClass *child_class_iterate(void **iter)
+{
+const AVClass *c = *iter ? NULL : &ffurl_context_class;
+*iter = (void*)(uintptr_t)c;
+return c;
+}
 
 #define OFFSET(x) offsetof(AVIOContext,x)
 #define E AV_OPT_FLAG_ENCODING_PARAM
@@ -67,7 +76,10 @@ const AVClass ff_avio_class = {
 .version= LIBAVUTIL_VERSION_INT,
 .option = ff_avio_options,
 .child_next = ff_avio_child_next,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = ff_avio_child_class_next,
+#endif
+.child_class_iterate = child_class_iterate,
 };
 
 static void fill_buffer(AVIOContext *s);
-- 
2.26.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 17/17] AVFormatContext: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavformat/options.c | 64 +++
 1 file changed, 64 insertions(+)

diff --git a/libavformat/options.c b/libavformat/options.c
index e14510504f..3160904fda 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -21,6 +21,7 @@
 #include "avio_internal.h"
 #include "internal.h"
 
+#include "libavutil/avassert.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 
@@ -53,6 +54,8 @@ static void *format_child_next(void *obj, void *prev)
 return NULL;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
+FF_DISABLE_DEPRECATION_WARNINGS
 static const AVClass *format_child_class_next(const AVClass *prev)
 {
 AVInputFormat  *ifmt = NULL;
@@ -80,6 +83,64 @@ static const AVClass *format_child_class_next(const AVClass 
*prev)
 
 return NULL;
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+enum {
+CHILD_CLASS_ITER_AVIO = 0,
+CHILD_CLASS_ITER_MUX,
+CHILD_CLASS_ITER_DEMUX,
+CHILD_CLASS_ITER_DONE,
+
+};
+
+#define ITER_STATE_SHIFT 16
+
+static const AVClass *format_child_class_iterate(void **iter)
+{
+// we use the low 16 bits of iter as the value to be passed to
+// av_(de)muxer_iterate()
+void *val = (void*)(((uintptr_t)*iter) & ((1 << ITER_STATE_SHIFT) - 1));
+unsigned int state = ((uintptr_t)*iter) >> ITER_STATE_SHIFT;
+const AVClass *ret = NULL;
+
+if (state == CHILD_CLASS_ITER_AVIO) {
+ret = &ff_avio_class;
+state++;
+goto finish;
+}
+
+if (state == CHILD_CLASS_ITER_MUX) {
+const AVOutputFormat *ofmt;
+
+while ((ofmt = av_muxer_iterate(&val))) {
+ret = ofmt->priv_class;
+if (ret)
+goto finish;
+}
+
+val = NULL;
+state++;
+}
+
+if (state == CHILD_CLASS_ITER_DEMUX) {
+const AVInputFormat *ifmt;
+
+while ((ifmt = av_demuxer_iterate(&val))) {
+ret = ifmt->priv_class;
+if (ret)
+goto finish;
+}
+val = NULL;
+state++;
+}
+
+finish:
+// make sure none av_(de)muxer_iterate does not set the high bits of val
+av_assert0(!((uintptr_t)val >> ITER_STATE_SHIFT));
+*iter = (void*)((uintptr_t)val | (state << ITER_STATE_SHIFT));
+return ret;
+}
 
 static AVClassCategory get_category(void *ptr)
 {
@@ -94,7 +155,10 @@ static const AVClass av_format_context_class = {
 .option = avformat_options,
 .version= LIBAVUTIL_VERSION_INT,
 .child_next = format_child_next,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = format_child_class_next,
+#endif
+.child_class_iterate = format_child_class_iterate,
 .category   = AV_CLASS_CATEGORY_MUXER,
 .get_category   = get_category,
 };
-- 
2.26.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 12/17] framesync: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavfilter/framesync.c | 7 +++
 libavfilter/framesync.h | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
index b32a5cba6c..04119d686c 100644
--- a/libavfilter/framesync.c
+++ b/libavfilter/framesync.c
@@ -53,6 +53,13 @@ static const AVClass framesync_class = {
 .parent_log_context_offset = OFFSET(parent),
 };
 
+const AVClass *ff_framesync_child_class_iterate(void **iter)
+{
+const AVClass *c = *iter ? NULL : &framesync_class;
+*iter = (void*)(uintptr_t)c;
+return c;
+}
+
 enum {
 STATE_BOF,
 STATE_RUN,
diff --git a/libavfilter/framesync.h b/libavfilter/framesync.h
index 37743cccb7..51bab16285 100644
--- a/libavfilter/framesync.h
+++ b/libavfilter/framesync.h
@@ -297,6 +297,8 @@ int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame 
**f0, AVFrame **f1);
  */
 int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame 
**f1);
 
+const AVClass *ff_framesync_child_class_iterate(void **iter);
+
 #define FRAMESYNC_DEFINE_CLASS(name, context, field) \
 static int name##_framesync_preinit(AVFilterContext *ctx) { \
 context *s = ctx->priv; \
@@ -318,6 +320,7 @@ static const AVClass name##_class = { \
 .version  = LIBAVUTIL_VERSION_INT, \
 .category = AV_CLASS_CATEGORY_FILTER, \
 .child_class_next = name##_child_class_next, \
+.child_class_iterate = ff_framesync_child_class_iterate, \
 .child_next   = name##_child_next, \
 }
 
-- 
2.26.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 04/17] lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next bump

2020-05-28 Thread Anton Khirnov
They are not properly namespaced and not intended for public use.
---
 libavutil/mem.h  |  6 
 libavutil/mem_internal.h | 70 
 libavutil/version.h  |  4 ++-
 3 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/libavutil/mem.h b/libavutil/mem.h
index 5fb1a02dd9..e21a1feaae 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -33,6 +33,7 @@
 #include "attributes.h"
 #include "error.h"
 #include "avutil.h"
+#include "version.h"
 
 /**
  * @addtogroup lavu_mem
@@ -49,6 +50,10 @@
  * dealing with memory consistently possible on all platforms.
  *
  * @{
+ */
+
+#if FF_API_DECLARE_ALIGNED
+/**
  *
  * @defgroup lavu_mem_macros Alignment Macros
  * Helper macros for declaring aligned variables.
@@ -125,6 +130,7 @@
 /**
  * @}
  */
+#endif
 
 /**
  * @defgroup lavu_mem_attrs Function Attributes
diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h
index 6fdbcb016e..c25c28ed1a 100644
--- a/libavutil/mem_internal.h
+++ b/libavutil/mem_internal.h
@@ -23,6 +23,76 @@
 
 #include "avassert.h"
 #include "mem.h"
+#include "version.h"
+
+#if !FF_API_DECLARE_ALIGNED
+/**
+ * @def DECLARE_ALIGNED(n,t,v)
+ * Declare a variable that is aligned in memory.
+ *
+ * @code{.c}
+ * DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42;
+ * DECLARE_ALIGNED(32, uint8_t, aligned_array)[128];
+ *
+ * // The default-alignment equivalent would be
+ * uint16_t aligned_int = 42;
+ * uint8_t aligned_array[128];
+ * @endcode
+ *
+ * @param n Minimum alignment in bytes
+ * @param t Type of the variable (or array element)
+ * @param v Name of the variable
+ */
+
+/**
+ * @def DECLARE_ASM_ALIGNED(n,t,v)
+ * Declare an aligned variable appropriate for use in inline assembly code.
+ *
+ * @code{.c}
+ * DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
+ * @endcode
+ *
+ * @param n Minimum alignment in bytes
+ * @param t Type of the variable (or array element)
+ * @param v Name of the variable
+ */
+
+/**
+ * @def DECLARE_ASM_CONST(n,t,v)
+ * Declare a static constant aligned variable appropriate for use in inline
+ * assembly code.
+ *
+ * @code{.c}
+ * DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008);
+ * @endcode
+ *
+ * @param n Minimum alignment in bytes
+ * @param t Type of the variable (or array element)
+ * @param v Name of the variable
+ */
+
+#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
+#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
+#define DECLARE_ASM_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
+#define DECLARE_ASM_CONST(n,t,v)const t __attribute__ ((aligned (n))) v
+#elif defined(__DJGPP__)
+#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (FFMIN(n, 
16 v
+#define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned 
(FFMIN(n, 16 v
+#define DECLARE_ASM_CONST(n,t,v)static const t av_used __attribute__ 
((aligned (FFMIN(n, 16 v
+#elif defined(__GNUC__) || defined(__clang__)
+#define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
+#define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned 
(n))) v
+#define DECLARE_ASM_CONST(n,t,v)static const t av_used __attribute__ 
((aligned (n))) v
+#elif defined(_MSC_VER)
+#define DECLARE_ALIGNED(n,t,v)  __declspec(align(n)) t v
+#define DECLARE_ASM_ALIGNED(n,t,v)  __declspec(align(n)) t v
+#define DECLARE_ASM_CONST(n,t,v)__declspec(align(n)) static const t v
+#else
+#define DECLARE_ALIGNED(n,t,v)  t v
+#define DECLARE_ASM_ALIGNED(n,t,v)  t v
+#define DECLARE_ASM_CONST(n,t,v)static const t v
+#endif
+#endif
 
 static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t 
min_size, int zero_realloc)
 {
diff --git a/libavutil/version.h b/libavutil/version.h
index 7acecf5a97..f8cd0b5f8a 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -129,7 +129,9 @@
 #ifndef FF_API_PSEUDOPAL
 #define FF_API_PSEUDOPAL(LIBAVUTIL_VERSION_MAJOR < 57)
 #endif
-
+#ifndef FF_API_DECLARE_ALIGNED
+#define FF_API_DECLARE_ALIGNED  (LIBAVUTIL_VERSION_MAJOR < 57)
+#endif
 
 /**
  * @}
-- 
2.26.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 11/17] avflter: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavfilter/avfilter.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 394811916d..dd8074e462 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -583,6 +583,7 @@ static void *filter_child_next(void *obj, void *prev)
 return NULL;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
 static const AVClass *filter_child_class_next(const AVClass *prev)
 {
 void *opaque = NULL;
@@ -604,6 +605,18 @@ static const AVClass *filter_child_class_next(const 
AVClass *prev)
 
 return NULL;
 }
+#endif
+
+static const AVClass *filter_child_class_iterate(void **iter)
+{
+const AVFilter *f;
+
+while ((f = av_filter_iterate(iter)))
+if (f->priv_class)
+return f->priv_class;
+
+return NULL;
+}
 
 #define OFFSET(x) offsetof(AVFilterContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM
@@ -625,7 +638,10 @@ static const AVClass avfilter_class = {
 .version= LIBAVUTIL_VERSION_INT,
 .category   = AV_CLASS_CATEGORY_FILTER,
 .child_next = filter_child_next,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = filter_child_class_next,
+#endif
+.child_class_iterate = filter_child_class_iterate,
 .option   = avfilter_options,
 };
 
-- 
2.26.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 07/17] bsf: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavcodec/bitstream_filters.c | 14 ++
 libavcodec/bsf.c   |  3 +++
 libavcodec/bsf_internal.h  |  4 
 3 files changed, 21 insertions(+)

diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index a7aa5dca65..b26d6a910e 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -96,6 +96,7 @@ const AVBitStreamFilter *av_bsf_get_by_name(const char *name)
 return NULL;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
 const AVClass *ff_bsf_child_class_next(const AVClass *prev)
 {
 const AVBitStreamFilter *f = NULL;
@@ -115,3 +116,16 @@ const AVClass *ff_bsf_child_class_next(const AVClass *prev)
 }
 return NULL;
 }
+#endif
+
+const AVClass *ff_bsf_child_class_iterate(void **opaque)
+{
+const AVBitStreamFilter *f;
+
+/* find next filter with priv options */
+while ((f = av_bsf_iterate(opaque))) {
+if (f->priv_class)
+return f->priv_class;
+}
+return NULL;
+}
diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 5e1c794a76..d71bc32584 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -79,7 +79,10 @@ static const AVClass bsf_class = {
 .item_name= bsf_to_name,
 .version  = LIBAVUTIL_VERSION_INT,
 .child_next   = bsf_child_next,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = ff_bsf_child_class_next,
+#endif
+.child_class_iterate = ff_bsf_child_class_iterate,
 .category = AV_CLASS_CATEGORY_BITSTREAM_FILTER,
 };
 
diff --git a/libavcodec/bsf_internal.h b/libavcodec/bsf_internal.h
index fefd5b8905..b78c134bdd 100644
--- a/libavcodec/bsf_internal.h
+++ b/libavcodec/bsf_internal.h
@@ -42,6 +42,10 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt);
  */
 int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt);
 
+#if FF_API_CHILD_CLASS_NEXT
 const AVClass *ff_bsf_child_class_next(const AVClass *prev);
+#endif
+
+const AVClass *ff_bsf_child_class_iterate(void **opaque);
 
 #endif /* AVCODEC_BSF_INTERNAL_H */
-- 
2.26.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 08/17] AVCodecContext: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavcodec/options.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index 7706a03297..ff16e2cbfd 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -53,6 +53,7 @@ static void *codec_child_next(void *obj, void *prev)
 return NULL;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
 static const AVClass *codec_child_class_next(const AVClass *prev)
 {
 void *iter = NULL;
@@ -69,6 +70,17 @@ static const AVClass *codec_child_class_next(const AVClass 
*prev)
 return c->priv_class;
 return NULL;
 }
+#endif
+
+static const AVClass *codec_child_class_iterate(void **iter)
+{
+const AVCodec *c;
+/* find next codec with priv options */
+while (c = av_codec_iterate(iter))
+if (c->priv_class)
+return c->priv_class;
+return NULL;
+}
 
 static AVClassCategory get_category(void *ptr)
 {
@@ -84,7 +96,10 @@ static const AVClass av_codec_context_class = {
 .version = LIBAVUTIL_VERSION_INT,
 .log_level_offset_offset = offsetof(AVCodecContext, log_level_offset),
 .child_next  = codec_child_next,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next= codec_child_class_next,
+#endif
+.child_class_iterate = codec_child_class_iterate,
 .category= AV_CLASS_CATEGORY_ENCODER,
 .get_category= get_category,
 };
-- 
2.26.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 02/17] avdevice: deprecate av_*_device_next()

2020-05-28 Thread Anton Khirnov
These functions rely on deprecated libavformat APIs and apparently have
zero users outside of cmdutils. Since the functionality they provide is
apparently not useful to anyone, deprecate them without replacement.
---
 doc/APIchanges | 4 
 fftools/cmdutils.c | 2 +-
 fftools/cmdutils.h | 4 ++--
 libavdevice/avdevice.c | 4 
 libavdevice/avdevice.h | 6 ++
 5 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index fb5534b5f5..f5b2a7b964 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-xx-xx - avdevice.h
+  Deprecate av_input_video_device_next, av_output_video_device_next,
+  av_input_audio_device_next, av_output_audio_device_next
+
 2020-xx-xx - xx - lavc 58.88.100 - avcodec.h codec.h
   Move AVCodec-related public API to new header codec.h.
 
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index dec18850d8..a948d478d5 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -2216,7 +2216,7 @@ double get_rotation(AVStream *st)
 return theta;
 }
 
-#if CONFIG_AVDEVICE
+#if CONFIG_AVDEVICE && FF_API_NEXT
 static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
 {
 int ret, i;
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 1917510589..ae5208f1aa 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -201,7 +201,7 @@ typedef struct OptionDef {
 void show_help_options(const OptionDef *options, const char *msg, int 
req_flags,
int rej_flags, int alt_flags);
 
-#if CONFIG_AVDEVICE
+#if CONFIG_AVDEVICE && FF_API_NEXT
 #define CMDUTILS_COMMON_OPTIONS_AVDEVICE   
 \
 { "sources", OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, 
 \
   "list sources of the input device", "device" },  
 \
@@ -498,7 +498,7 @@ int show_demuxers(void *optctx, const char *opt, const char 
*arg);
  */
 int show_devices(void *optctx, const char *opt, const char *arg);
 
-#if CONFIG_AVDEVICE
+#if CONFIG_AVDEVICE && FF_API_NEXT
 /**
  * Print a listing containing autodetected sinks of the output device.
  * Device name with options may be passed as an argument to limit results.
diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
index 3d03d89f04..e45cc06153 100644
--- a/libavdevice/avdevice.c
+++ b/libavdevice/avdevice.c
@@ -78,6 +78,8 @@ const char * avdevice_license(void)
 return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
 }
 
+#if FF_API_NEXT
+FF_DISABLE_DEPRECATION_WARNINGS
 static void *device_next(void *prev, int output,
  AVClassCategory c1, AVClassCategory c2)
 {
@@ -99,6 +101,7 @@ static void *device_next(void *prev, int output,
 } while (category != c1 && category != c2);
 return prev;
 }
+FF_ENABLE_DEPRECATION_WARNINGS
 
 AVInputFormat *av_input_audio_device_next(AVInputFormat  *d)
 {
@@ -123,6 +126,7 @@ AVOutputFormat *av_output_video_device_next(AVOutputFormat 
*d)
 return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT,
AV_CLASS_CATEGORY_DEVICE_OUTPUT);
 }
+#endif
 
 int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum 
AVAppToDevMessageType type,
 void *data, size_t data_size)
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index ee9462480e..c63f661fc7 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -70,6 +70,7 @@ const char *avdevice_license(void);
  */
 void avdevice_register_all(void);
 
+#if FF_API_NEXT
 /**
  * Audio input devices iterator.
  *
@@ -77,6 +78,7 @@ void avdevice_register_all(void);
  * if d is non-NULL, returns the next registered input audio/video device 
after d
  * or NULL if d is the last one.
  */
+attribute_deprecated
 AVInputFormat *av_input_audio_device_next(AVInputFormat  *d);
 
 /**
@@ -86,6 +88,7 @@ AVInputFormat *av_input_audio_device_next(AVInputFormat  *d);
  * if d is non-NULL, returns the next registered input audio/video device 
after d
  * or NULL if d is the last one.
  */
+attribute_deprecated
 AVInputFormat *av_input_video_device_next(AVInputFormat  *d);
 
 /**
@@ -95,6 +98,7 @@ AVInputFormat *av_input_video_device_next(AVInputFormat  *d);
  * if d is non-NULL, returns the next registered output audio/video device 
after d
  * or NULL if d is the last one.
  */
+attribute_deprecated
 AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d);
 
 /**
@@ -104,7 +108,9 @@ AVOutputFormat *av_output_audio_device_next(AVOutputFormat 
*d);
  * if d is non-NULL, returns the next registered output audio/video device 
after d
  * or NULL if d is the last one.
  */
+attribute_deprecated
 AVOutputFormat *av_output_video_device_next(AVOutputFormat *d);
+#endif
 
 typedef struct AVDe

[FFmpeg-devel] [PATCH 15/17] URLContext: switch to child_class_iterate()

2020-05-28 Thread Anton Khirnov
---
 libavformat/avio.c  |  3 +++
 libavformat/protocols.c | 16 
 libavformat/url.h   |  4 
 3 files changed, 23 insertions(+)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 237966c303..3886ed7a90 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -67,7 +67,10 @@ const AVClass ffurl_context_class = {
 .option   = options,
 .version  = LIBAVUTIL_VERSION_INT,
 .child_next   = urlcontext_child_next,
+#if FF_API_CHILD_CLASS_NEXT
 .child_class_next = ff_urlcontext_child_class_next,
+#endif
+.child_class_iterate = ff_urlcontext_child_class_iterate,
 };
 /*@}*/
 
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index f1b8eab0fd..7df18fbb3b 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -73,6 +73,7 @@ extern const URLProtocol ff_libzmq_protocol;
 
 #include "libavformat/protocol_list.c"
 
+#if FF_API_CHILD_CLASS_NEXT
 const AVClass *ff_urlcontext_child_class_next(const AVClass *prev)
 {
 int i;
@@ -91,7 +92,22 @@ const AVClass *ff_urlcontext_child_class_next(const AVClass 
*prev)
 return url_protocols[i]->priv_data_class;
 return NULL;
 }
+#endif
 
+const AVClass *ff_urlcontext_child_class_iterate(void **iter)
+{
+const AVClass *ret = NULL;
+uintptr_t i;
+
+for (i = (uintptr_t)*iter; url_protocols[i]; i++) {
+ret = url_protocols[i]->priv_data_class;
+if (ret)
+break;
+}
+
+*iter = (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i);
+return ret;
+}
 
 const char *avio_enum_protocols(void **opaque, int output)
 {
diff --git a/libavformat/url.h b/libavformat/url.h
index 4750bfff82..de0d30aca0 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -322,7 +322,11 @@ void ff_make_absolute_url(char *buf, int size, const char 
*base,
  */
 AVIODirEntry *ff_alloc_dir_entry(void);
 
+#if FF_API_CHILD_CLASS_NEXT
 const AVClass *ff_urlcontext_child_class_next(const AVClass *prev);
+#endif
+
+const AVClass *ff_urlcontext_child_class_iterate(void **iter);
 
 /**
  * Construct a list of protocols matching a given whitelist and/or blacklist.
-- 
2.26.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".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread Lynne
May 28, 2020, 17:20 by mich...@niedermayer.cc:

> TODO: Bump
>
>  */
>  #define AV_CODEC_FLAG2_FAST   (1 <<  0)
> +
> +/**
> + * Allow speedups tricks which can read out of array on non compliant 
> streams.
> + */
> +#define AV_CODEC_FLAG2_FAST_UNSAFE(1 <<  1)
>

That's a bug. We should absolutely not have flags to enable bugs.
The fast flag should be removed from h264 until that bug is fixed,
or deprecated altogether.

___
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] Don't adjust start time for MP3 files; packets are not adjusted.

2020-05-28 Thread Michael Niedermayer
On Wed, May 27, 2020 at 11:57:13AM -0700, Dale Curtis wrote:
> On Wed, May 27, 2020 at 8:29 AM Michael Niedermayer 
> wrote:
> 
> > what id like to point out here is that the audio stream no
> > longer starts at the same time as the video
> > also the duration from adding the durations before is
> > exact but not afterwards
> >
> 
> I'm not sure about the duration issue, I'd assume it's just an accounting
> error since the change only affects start_time. As noted in the change
> description, if you want to keep start_time adjusted for skip samples all
> packet timestamps need to be changed too. Doing that broke many test cases
> at the time, so we opted to just revert the patch. I.e., basically every
> mp3 changes to having its first PTS be ~26ms due to the common 1152 skip
> sample amount.

I dont really have an oppinion about start_time, its more the change in
timestamps & duratiion on the output side which is whats user vissible
and that looked worse for the testcase

thx

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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/2] avcodec: Add AV_CODEC_FLAG2_FAST_UNSAFE, move unsafe uses of FAST to it

2020-05-28 Thread Kieran Kunhya
>
> More generally though (outside this unsafe flag case)
> i do disagree with your argument a bit, performance does matter.
> Iam regularly reminded of that for example, so much software becomes
> slower on each upgrade with few if any features added the real users
> care about. Just to pick one, the editor i use to write replies in mutt
> is slower to close than before i upgraded the OS.
>
> Also again to stay general here, this does not apply to the unsafe flag.
> speed / cpu load does add up. Slower code means more CO2 emissions if
> the software is used alot.
> If you want a real example insetad of this flag where we could improve
> IIRC there was some code iterating over options in the iteration over
> options resulting in some sort of O(n^3) or so. Thats from memory though
> would need to check where that was exactly but thats something we should
> fix.
>

Please provide evidence that the H.264 Decoder has got slower.
Surely by your argument all your fuzzing fixes need an #ifdef to turn them
off to save CO2?

Kieran
___
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] [FFmpeg-cvslog] lavfi/vulkan: use all enabled queues in the queue family

2020-05-28 Thread Michael Niedermayer
On Sat, May 23, 2020 at 06:09:06PM +, Lynne wrote:
> ffmpeg | branch: master | Lynne  | Thu May 14 00:37:21 2020 
> +0100| [727cac88b8c4b1facd93a3c863ef7e7072feda36] | committer: Lynne
> 
> lavfi/vulkan: use all enabled queues in the queue family
> 
> This should significantly improve the performance with certain
> filterchains.
> 
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=727cac88b8c4b1facd93a3c863ef7e7072feda36
> ---
> 
>  libavfilter/vf_avgblur_vulkan.c   |  39 ++---
>  libavfilter/vf_chromaber_vulkan.c |  30 ++--
>  libavfilter/vf_overlay_vulkan.c   |  37 ++---
>  libavfilter/vf_scale_vulkan.c |  30 ++--
>  libavfilter/vulkan.c  | 296 
> +-
>  libavfilter/vulkan.h  |  74 --
>  6 files changed, 371 insertions(+), 135 deletions(-)
> 
> diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c
> index 105d753f73..12d57e0875 100644
> --- a/libavfilter/vf_avgblur_vulkan.c
> +++ b/libavfilter/vf_avgblur_vulkan.c
> @@ -97,6 +97,10 @@ static av_cold int init_filter(AVFilterContext *ctx, 
> AVFrame *in)
>  if (!sampler)
>  return AVERROR_EXTERNAL;
>  
> +s->vkctx.queue_family_idx = s->vkctx.hwctx->queue_family_comp_index;
> +s->vkctx.queue_count = GET_QUEUE_COUNT(s->vkctx.hwctx, 0, 1, 0);

> +s->vkctx.cur_queue_idx = rand() % s->vkctx.queue_count;
[...]
> +s->vkctx.cur_queue_idx = rand() % s->vkctx.queue_count;
[...]
> +s->vkctx.cur_queue_idx = rand() % s->vkctx.queue_count;
[...]
> +s->vkctx.cur_queue_idx = rand() % s->vkctx.queue_count;

This modifies global state, is neither thread safe nor can it be used from a
library (it breaks a user application using rand())

if you need a PRNG, 
Please see libavutil/lfg.h, or simply use a simple LCG like state= 
state*1664525+1013904223

thx

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

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


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

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

Re: [FFmpeg-devel] [PATCH v5 4/4] avformat: add kvag muxer

2020-05-28 Thread Michael Niedermayer
On Sat, May 16, 2020 at 11:53:51AM +, Zane van Iperen wrote:
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|  1 +
>  libavformat/Makefile |  1 +
>  libavformat/allformats.c |  1 +
>  libavformat/kvag.c   | 84 +++-
>  libavformat/version.h|  2 +-
>  5 files changed, 87 insertions(+), 2 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index 1f2cf7692d..6aacf6e819 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -68,6 +68,7 @@ version :
>  - pcm_rechunk bitstream filter
>  - scdet filter
>  - Simon & Schuster Interactive ADPCM encoder
> +- Real War KVAG muxer
>  
>  
>  version 4.2:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 5fa24cef16..c342c7f245 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -285,6 +285,7 @@ OBJS-$(CONFIG_JACOSUB_MUXER) += jacosubenc.o 
> rawenc.o
>  OBJS-$(CONFIG_JV_DEMUXER)+= jvdec.o
>  OBJS-$(CONFIG_KUX_DEMUXER)   += flvdec.o
>  OBJS-$(CONFIG_KVAG_DEMUXER)  += kvag.o
> +OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o rawenc.o
>  OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o
>  OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o
>  OBJS-$(CONFIG_LOAS_DEMUXER)  += loasdec.o rawdec.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 3919c9e4c1..a7c5c9db89 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -220,6 +220,7 @@ extern AVOutputFormat ff_jacosub_muxer;
>  extern AVInputFormat  ff_jv_demuxer;
>  extern AVInputFormat  ff_kux_demuxer;
>  extern AVInputFormat  ff_kvag_demuxer;
> +extern AVOutputFormat ff_kvag_muxer;
>  extern AVOutputFormat ff_latm_muxer;
>  extern AVInputFormat  ff_lmlm4_demuxer;
>  extern AVInputFormat  ff_loas_demuxer;
> diff --git a/libavformat/kvag.c b/libavformat/kvag.c
> index 71b0eb4118..8be820a3c8 100644
> --- a/libavformat/kvag.c
> +++ b/libavformat/kvag.c
> @@ -1,5 +1,5 @@
>  /*
> - * Simon & Schuster Interactive VAG demuxer
> + * Simon & Schuster Interactive VAG (de)muxer
>   *
>   * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
>   *
> @@ -21,6 +21,7 @@
>   */
>  #include "avformat.h"
>  #include "internal.h"
> +#include "rawenc.h"
>  #include "libavutil/intreadwrite.h"
>  
>  #define KVAG_TAGMKTAG('K', 'V', 'A', 'G')
> @@ -34,6 +35,7 @@ typedef struct KVAGHeader {
>  uint16_tstereo;
>  } KVAGHeader;
>  
> +#if CONFIG_KVAG_DEMUXER
>  static int kvag_probe(const AVProbeData *p)
>  {
>  if (AV_RL32(p->buf) != KVAG_TAG)
> @@ -115,3 +117,83 @@ AVInputFormat ff_kvag_demuxer = {
>  .read_header= kvag_read_header,
>  .read_packet= kvag_read_packet
>  };
> +#endif
> +
> +#if CONFIG_KVAG_MUXER
> +static int kvag_write_init(AVFormatContext *s)
> +{
> +AVCodecParameters *par;
> +
> +if (s->nb_streams != 1) {
> +av_log(s, AV_LOG_ERROR, "KVAG files have exactly one stream\n");
> +return AVERROR(EINVAL);
> +}
> +
> +par = s->streams[0]->codecpar;
> +
> +if (par->codec_id != AV_CODEC_ID_ADPCM_IMA_SSI) {
> +av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
> +   avcodec_get_name(par->codec_id));
> +return AVERROR(EINVAL);
> +}
> +
> +if (par->channels > 2) {
> +av_log(s, AV_LOG_ERROR, "KVAG files only support up to 2 
> channels\n");
> +return AVERROR(EINVAL);
> +}
> +
> +return 0;
> +}
> +
> +static int kvag_write_header(AVFormatContext *s)
> +{
> +uint8_t buf[KVAG_HEADER_SIZE];
> +AVCodecParameters *par = s->streams[0]->codecpar;
> +
> +AV_WL32(buf +  0, KVAG_TAG);
> +AV_WL32(buf +  4, 0); /* Data size, we fix this up later. */
> +AV_WL32(buf +  8, par->sample_rate);
> +AV_WL16(buf + 12, par->channels == 2);
> +
> +avio_write(s->pb, buf, sizeof(buf));
> +return 0;
> +}
> +

> +static int kvag_write_trailer(AVFormatContext *s)
> +{
> +int64_t file_size, data_size;
> +
> +if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
> +av_log(s, AV_LOG_WARNING,
> +   "Stream not seekable, unable to write data size. "
> +   "Output file will be broken\n");
> +return 0;
> +}

this could be checked earlier, checking it earlier would avoid transcoding the
whole file just to fail
or is such a broken file usefull in some usecase ?

thx

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

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


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

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

Re: [FFmpeg-devel] [PATCH 02/17] avdevice: deprecate av_*_device_next()

2020-05-28 Thread Josh de Kock

On 28/05/2020 21:15, Anton Khirnov wrote:

These functions rely on deprecated libavformat APIs and apparently have
zero users outside of cmdutils. Since the functionality they provide is
apparently not useful to anyone, deprecate them without replacement.
---
  doc/APIchanges | 4 
  fftools/cmdutils.c | 2 +-
  fftools/cmdutils.h | 4 ++--
  libavdevice/avdevice.c | 4 
  libavdevice/avdevice.h | 6 ++
  5 files changed, 17 insertions(+), 3 deletions(-)

[...]


This is the last part of the iterate() API update. I was recently 
looking at this again, and I think this is the best way to solve it.


--
Josh
___
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] [RFC PATCH] libavcodec/jpeg2000_parser: Add jpeg2000 parser

2020-05-28 Thread Michael Niedermayer
On Fri, May 29, 2020 at 12:33:01AM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> I have attempted to write a JPEG2000 Parser. Have tested
> by generating a file containing 14 frames, as mentioned
> by Micheal. Have also tried testing with various packet
> sizes by setting -frame_size option. Need feedback on the
> code and on further testing.
> ---
>  libavcodec/Makefile  |   1 +
>  libavcodec/jpeg2000_parser.c | 190 +++
>  libavcodec/parsers.c |   1 +
>  3 files changed, 192 insertions(+)
>  create mode 100644 libavcodec/jpeg2000_parser.c

can you add some test to fate for this ?
(doesnt need to be related to the tests you did, but can of course)
such a test would also make it easy for others to test the code on
less common hardware like big endian ...
This can also be very simple test if its not easy


> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index d0917a656f..1f7c91a91b 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1073,6 +1073,7 @@ OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
>  OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
>  OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_sei.o h264data.o
>  OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
> +OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
>  OBJS-$(CONFIG_MJPEG_PARSER)+= mjpeg_parser.o
>  OBJS-$(CONFIG_MLP_PARSER)  += mlp_parse.o mlp_parser.o mlp.o
>  OBJS-$(CONFIG_MPEG4VIDEO_PARSER)   += mpeg4video_parser.o h263.o \
> diff --git a/libavcodec/jpeg2000_parser.c b/libavcodec/jpeg2000_parser.c
> new file mode 100644
> index 00..c28b694219

> --- /dev/null
> +++ b/libavcodec/jpeg2000_parser.c
> @@ -0,0 +1,190 @@
> +/*
> + * JPEG2000 parser

> + * Copyright (c) 2000, 2001 Fabrice Bellard

Thats ok if you used code from fabrice but you probably want to
add your name assuming you wrote the parser

[...]

thx
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand


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

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

[FFmpeg-devel] [PATCH] libavfilter/vf_drawtext.c:add support to generte ms level

2020-05-28 Thread 黄思远
___
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] libavformat/dashenc.c:make a sample Latency element

2020-05-28 Thread 黄思远
___
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] libavformat/dashenc.c:add mimetype

2020-05-28 Thread 黄思远
___
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] libavformat/dashenc.c:add support to change update interval

2020-05-28 Thread 黄思远
___
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] libavformat/dashenc.c:keep same with streaming , when live end

2020-05-28 Thread 黄思远
___
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/hls: check segment duration value of EXTINF

2020-05-28 Thread Steven Liu
fix ticket: 8673
set the default EXTINF duration to 1ms if duration is smaller than 1ms

Signed-off-by: Steven Liu 
---
 libavformat/hls.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3e35d157ad..8c4126b880 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -883,8 +883,6 @@ static int parse_playlist(HLSContext *c, const char *url,
 ret = AVERROR(ENOMEM);
 goto fail;
 }
-seg->duration = duration;
-seg->key_type = key_type;
 if (has_iv) {
 memcpy(seg->iv, iv, sizeof(iv));
 } else {
@@ -914,6 +912,13 @@ static int parse_playlist(HLSContext *c, const char *url,
 goto fail;
 }
 
+if (duration < 0.001 * AV_TIME_BASE) {
+av_log(c->ctx, AV_LOG_WARNING, "Cannot get correct #EXTINF 
value of segment %s,"
+" set to default value to 1ms.\n", 
seg->url);
+duration = 0.001 * AV_TIME_BASE;
+}
+seg->duration = duration;
+seg->key_type = key_type;
 dynarray_add(&pls->segments, &pls->n_segments, seg);
 is_segment = 0;
 
-- 
2.25.0



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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/adpcm_data: extend ff_adpcm_ima_cunning_index_table

2020-05-28 Thread Zane van Iperen
On Thu, 28 May 2020 18:44:55 +0200
"Michael Niedermayer"  wrote:


> > The index table should only ever be indexed between [0,7], so this
> > looks like a bug in adpcm_ima_cunning_expand_nibble() instead.  
> 
> maybe it should be only 0..7 but abs(-8 .. 7) needs a 8th entrty or a
> check
> 
> 
> >
> > Where would one go to see the inputs for this? I'd like to
> > investigate (and test against the original decoder).  
> 
> The file is from a fuzzer so is random trash and it needs
> target_dec_fuzzer.c to be read. It wont be read as "Pro Pinball
> Series Soundbank" so i think that file will not be useful to test the
> behavior of the original decoder as i would assume it will not accept
> the target_dec_fuzzer data but i surely can send it to you privatly
> if you need it. just say if you want me to send you the file
> 

No need, I've found an existing file that has the same problem. Out of
all the 453 files I have, only one of them triggers this.

tl;dr: Change the 5 to -1.


ff_adpcm_ima_cunning_index_table[abs(nibble)] is wrong in the case
where nibble == -8.

If you take the unsigned nibble, and apply f():
  f(x) = 16 - x if x > 8 else x & 0x7

you'll get the same value as abs() applied with the signed nibble,
except for this one case (abs(-8) == 8, f(8) == 0).


Instead of changing the abs(), a cleaner fix is to simply change the 5
to -1. That should give the correct output.

Zane


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

  1   2   >