[FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-08 Thread Linjie Fu
Use desc->log2_chroma_w/h to calculate the sps->conf_win_right/bottom_offset.

Based on Table 6-1, SubWidthC and SubHeightC depend on chroma 
format(log2_chroma_w/h).

Based on D-28 and D-29, set the correct cropped width/height.

croppedWidth  = pic_width_in_luma_samples −
SubWidthC * ( conf_win_right_offset + conf_win_left_offset );

croppedHeight = pic_height_in_luma_samples −
SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset );

Signed-off-by: Linjie Fu 
---
[v2]: use desc->log2_chroma_w/h.

 libavcodec/vaapi_encode_h265.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index ace7696..bebb0f9 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -410,10 +410,10 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 sps->conformance_window_flag = 1;
 sps->conf_win_left_offset   = 0;
 sps->conf_win_right_offset  =
-(ctx->surface_width - avctx->width) / 2;
+(ctx->surface_width - avctx->width) >> desc->log2_chroma_w;
 sps->conf_win_top_offset= 0;
 sps->conf_win_bottom_offset =
-(ctx->surface_height - avctx->height) / 2;
+(ctx->surface_height - avctx->height) >> desc->log2_chroma_h;
 } else {
 sps->conformance_window_flag = 0;
 }
-- 
2.7.4

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

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

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-08 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Mark Thompson
> Sent: Sunday, March 8, 2020 00:35
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix
> conf_win_xxx_offset for 4:2:2/4:4:4 encoding
> 
> On 05/03/2020 07:41, Linjie Fu wrote:
> > Based on Table 6-1, set SubWidth and SubHeightC depending on chroma
> format.
> >
> > Based on D-28 and D-29, set the correct cropped width/height.
> >
> > croppedWidth  = pic_width_in_luma_samples −
> > SubWidthC * ( conf_win_right_offset + conf_win_left_offset 
> > );
> >
> > croppedHeight = pic_height_in_luma_samples −
> > SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset 
> > );
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/vaapi_encode_h265.c | 9 +++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/vaapi_encode_h265.c
> b/libavcodec/vaapi_encode_h265.c
> > index 12f0e6f..db1bf24 100644
> > --- a/libavcodec/vaapi_encode_h265.c
> > +++ b/libavcodec/vaapi_encode_h265.c
> > @@ -268,6 +268,7 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
> >  VAEncPictureParameterBufferHEVC  *vpic = ctx->codec_picture_params;
> >  const AVPixFmtDescriptor *desc;
> >  int chroma_format, bit_depth;
> > +int SubWidthC, SubHeightC;
> >  int i;
> >
> >  memset(vps, 0, sizeof(*vps));
> > @@ -405,15 +406,19 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
> >  sps->pic_width_in_luma_samples  = ctx->surface_width;
> >  sps->pic_height_in_luma_samples = ctx->surface_height;
> >
> > +// Table 6-1
> > +SubWidthC  = chroma_format == 1 || chroma_format == 2 ? 2 : 1;
> > +SubHeightC = chroma_format == 1 ? 2 : 1;
> 
> You don't need to reverse chroma format into these value - desc-
> >log2_chroma_* as used above to calculate it above is still available.

Updated, thanks for the review.

- Linjie
___
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] tests/checkasm: add overflow test for hevc_add_res

2020-03-08 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Linjie Fu
> Sent: Thursday, March 5, 2020 15:48
> To: ffmpeg-devel@ffmpeg.org
> Cc: Xu, Guangxin ; Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v2 4/4] tests/checkasm: add overflow test
> for hevc_add_res
> 
> Add overflow test for hevc_add_res when int16_t coeff = -32768,
> and doubled the test cases.
> 
> The result of C is good, while ASM is not.
> 
> To verify:
> make fate-checkasm-hevc_add_res
> ffmpeg/tests/checkasm/checkasm --test=hevc_add_res
> 
> ./checkasm --test=hevc_add_res
> checkasm: using random seed 679391863
> MMXEXT:
> hevc_add_res_4x4_8_mmxext (hevc_add_res.c:69)
>   - hevc_add_res.add_residual [FAILED]
> SSE2:
> hevc_add_res_8x8_8_sse2 (hevc_add_res.c:69)
> hevc_add_res_16x16_8_sse2 (hevc_add_res.c:69)
> hevc_add_res_32x32_8_sse2 (hevc_add_res.c:69)
>   - hevc_add_res.add_residual [FAILED]
> AVX:
> hevc_add_res_8x8_8_avx (hevc_add_res.c:69)
> hevc_add_res_16x16_8_avx (hevc_add_res.c:69)
> hevc_add_res_32x32_8_avx (hevc_add_res.c:69)
>   - hevc_add_res.add_residual [FAILED]
> AVX2:
> hevc_add_res_32x32_8_avx2 (hevc_add_res.c:69)
>   - hevc_add_res.add_residual [FAILED]
> checkasm: 8 of 14 tests have failed
> 
> Signed-off-by: Xu Guangxin 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: test 2x cases to make sure enough random residuals
> are tested.
> 
>  tests/checkasm/hevc_add_res.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tests/checkasm/hevc_add_res.c
> b/tests/checkasm/hevc_add_res.c
> index e92c6b4..8c82ac1 100644
> --- a/tests/checkasm/hevc_add_res.c
> +++ b/tests/checkasm/hevc_add_res.c
> @@ -58,6 +58,7 @@ static void check_add_res(HEVCDSPContext h, int
> bit_depth)
> 
>  randomize_buffers(res0, size);
>  randomize_buffers2(dst0, size);
> +res0[0] = 0x8000;// overflow test
>  memcpy(res1, res0, sizeof(*res0) * size);
>  memcpy(dst1, dst0, sizeof(int16_t) * size);
> 
> @@ -80,6 +81,7 @@ void checkasm_check_hevc_add_res(void)
> 
>  ff_hevc_dsp_init(&h, bit_depth);
>  check_add_res(h, bit_depth);
> +check_add_res(h, bit_depth);
>  }
>  report("add_residual");
>  }
> --

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 2/2] avformat/libzmq: Make default pkt_size value consistent with amqp

2020-03-08 Thread Marton Balint



On Fri, 28 Feb 2020, Andriy Gelman wrote:


From: Andriy Gelman 

Signed-off-by: Andriy Gelman 
---
libavformat/libzmq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/libzmq.c b/libavformat/libzmq.c
index 8c8b294c921..1b0d8638dbf 100644
--- a/libavformat/libzmq.c
+++ b/libavformat/libzmq.c
@@ -40,7 +40,7 @@ typedef struct ZMQContext {
#define D AV_OPT_FLAG_DECODING_PARAM
#define E AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
-{ "pkt_size", "Maximum send/read packet size", OFFSET(pkt_size), 
AV_OPT_TYPE_INT, { .i64 = 32768 }, -1, INT_MAX, .flags = D | E },
+{ "pkt_size", "Maximum send/read packet size", OFFSET(pkt_size), 
AV_OPT_TYPE_INT, { .i64 = 131072 }, -1, INT_MAX, .flags = D | E },


The docs also needs updating.

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

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

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 protocol support

2020-03-08 Thread Marton Balint



Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 
protocol support

From: Andriy Gelman 

Supports connecting to a RabbitMQ broker via AMQP version 0-9-1.

Signed-off-by: Andriy Gelman 
---

Changes in v2:
- Addressed comments from Marton
- Updated documentation

Compilation notes:
- Requires librabbitmq-dev package (on ubuntu).
- The pkg-config libprabbitmq.pc has a corrupt entry.
  **update: fixed on the github master branch**
  The line "Libs.private: rt; -lpthread" should be changed to
  "Libs.private: -lrt -pthread".
- Compile FFmpeg with --enable-librabbitmq



[...]


+@item connection_timeout
+The timeout in microseconds during the initial connection to the broker. The


In *seconds* (because it is an AV_OPT_TYPE_DURATION)


+default value is rw_timeout, or 500 microseconds if rw_timeout is not set.


5 seconds

[...]


+static const AVOption options[] = {
+{ "pkt_size", "Maximum send/read packet size", OFFSET(pkt_size), 
AV_OPT_TYPE_INT, { .i64 = 131072 }, 4096, INT_MAX, .flags = D | E },
+{ "exchange", "Exchange to send/read packets", OFFSET(exchange), AV_OPT_TYPE_STRING, 
{ .str = "amq.direct" }, 0, 0, .flags = D | E },
+{ "routing_key", "Key to filter streams", OFFSET(routing_key), AV_OPT_TYPE_STRING, { 
.str = "amqp" }, 0, 0, .flags = D | E },
+{ "connection_timeout", "Initial connection timeout", 
OFFSET(connection_timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags = D | E},


INT64_MAX can be the maximum.


+{ NULL }
+};
+
+static int amqp_proto_open(URLContext *h, const char *uri, int flags)
+{
+int ret, server_msg;
+char hostname[STR_LEN], credentials[STR_LEN];
+char *credentials_decoded;
+int port;
+const char *user, *password = NULL;
+char *p;
+amqp_rpc_reply_t broker_reply;
+struct timeval tval = { 0 };
+
+AMQPContext *s = h->priv_data;
+
+h->is_streamed = 1;
+h->max_packet_size = s->pkt_size;
+
+av_url_split(NULL, 0, credentials, sizeof(credentials),
+ hostname, sizeof(hostname), &port, NULL, 0, uri);
+
+if (port < 0)
+port = 5672;
+
+if (hostname[0] == '\0' || port <= 0 || port > 65535 ) {
+av_log(h, AV_LOG_ERROR, "Invalid hostname/port\n");
+return AVERROR(EINVAL);
+}
+
+credentials_decoded = ff_urldecode(credentials, 0);


This is not entirely correct, becase the username may contain ':'
characters... So you should split first and urldecode the splitted
components...


+if (!credentials_decoded)
+return AVERROR(ENOMEM);
+
+p = strchr(credentials_decoded, ':');
+if (p) {
+*p = '\0';
+password = p + 1;
+}
+
+if (!password || *password == '\0')
+password = "guest";
+
+user = credentials_decoded;
+if (*user == '\0')
+user = "guest";
+
+s->conn = amqp_new_connection();
+if (!s->conn) {
+av_log(h, AV_LOG_ERROR, "Error creating connection\n");
+return AVERROR_EXTERNAL;
+}
+
+s->socket = amqp_tcp_socket_new(s->conn);
+if (!s->socket) {
+av_log(h, AV_LOG_ERROR, "Error creating socket\n");
+goto destroy_connection;
+}
+
+if (s->connection_timeout < 0)
+s->connection_timeout = (h->rw_timeout > 0 ? h->rw_timeout : 500);
+
+tval.tv_sec  = s->connection_timeout / 100;
+tval.tv_usec = s->connection_timeout % 100;
+ret = amqp_socket_open_noblock(s->socket, hostname, port, &tval);
+
+if (ret) {
+av_log(h, AV_LOG_ERROR, "Error connecting to server\n");


This should log the useful error, e.g:
av_log(h, AV_LOG_ERROR, "Error connecting to server: %s\n", 
amqp_error_string2(ret));

[...]


+static int amqp_proto_write(URLContext *h, const unsigned char *buf, int size)
+{
+int ret;
+AMQPContext *s = h->priv_data;
+int fd = amqp_socket_get_sockfd(s->socket);
+
+amqp_bytes_t message = { size, (void *)buf };
+amqp_basic_properties_t props;
+
+ret = ff_network_wait_fd_timeout(fd, 1, h->rw_timeout, 
&h->interrupt_callback);
+if (ret)
+return ret;
+
+props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | 
AMQP_BASIC_DELIVERY_MODE_FLAG;
+props.content_type = amqp_cstring_bytes("octet/stream");
+props.delivery_mode = 2; /* persistent delivery mode */
+
+ret = amqp_basic_publish(s->conn, DEFAULT_CHANNEL, 
amqp_cstring_bytes(s->exchange),
+ amqp_cstring_bytes(s->routing_key), 0, 0,
+ &props, message);
+
+if (ret) {
+av_log(h, AV_LOG_ERROR, "Error publish\n");


Same here


+return AVERROR_EXTERNAL;
+}
+
+return size;
+}
+


[...]

Thanks,
Marton

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

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

Re: [FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg_opt: warn about overwritten parsed options

2020-03-08 Thread Gyan Doshi



On 08-03-2020 01:22 am, Marton Balint wrote:



On Sat, 29 Feb 2020, Marton Balint wrote:


Signed-off-by: Marton Balint 
---
fftools/ffmpeg_opt.c | 70 
+---

1 file changed, 67 insertions(+), 3 deletions(-)


Ping, will apply soon.


LGTM.

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

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

[FFmpeg-devel] [PATCH v3 0/2] High Voltage Software ALP demuxer + decoder.

2020-03-08 Thread Zane van Iperen
Adds support for the .TUN and .PCM files used by some
High Voltage Software games.

Please ping for review.

v3:
  - Move Changelog and doc changes into their respective patches
  - Restored the empty line

v2:
  - check for header size and "ADPCM" magic in probe
  - error if sample rate > 44100 to catch possible overflow
  - don't allocate stream until after header is validated
  - formatting fixes

Zane van Iperen (2):
  avcodec: add decoder for High Voltage Software's ALP ADPCM
  avformat: add demuxer for LEGO Racers' ALP format

 Changelog|   2 +
 doc/general.texi |   1 +
 libavcodec/Makefile  |   1 +
 libavcodec/adpcm.c   |  36 ++
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 ++
 libavcodec/version.h |   4 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/alp.c| 146 +++
 libavformat/version.h|   4 +-
 12 files changed, 201 insertions(+), 4 deletions(-)
 create mode 100644 libavformat/alp.c

-- 
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 v3 2/2] avformat: add demuxer for LEGO Racers' ALP format

2020-03-08 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/alp.c| 146 +++
 libavformat/version.h|   4 +-
 5 files changed, 151 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/alp.c

diff --git a/Changelog b/Changelog
index a962657b85..41a9166827 100644
--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,7 @@ version :
 - Rayman 2 APM demuxer
 - cas video filter
 - High Voltage Software ADPCM decoder
+- LEGO Racers ALP (.tun & .pcm) demuxer
 
 
 version 4.2:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index e0681058a2..fbb29505ff 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -85,6 +85,7 @@ OBJS-$(CONFIG_AIFF_DEMUXER)  += aiffdec.o pcm.o 
isom.o \
 mov_chan.o replaygain.o
 OBJS-$(CONFIG_AIFF_MUXER)+= aiffenc.o id3v2enc.o
 OBJS-$(CONFIG_AIX_DEMUXER)   += aixdec.o
+OBJS-$(CONFIG_ALP_DEMUXER)   += alp.o
 OBJS-$(CONFIG_AMR_DEMUXER)   += amr.o
 OBJS-$(CONFIG_AMR_MUXER) += amr.o
 OBJS-$(CONFIG_AMRNB_DEMUXER) += amr.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0209bf0e30..08012ea208 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -46,6 +46,7 @@ extern AVInputFormat  ff_afc_demuxer;
 extern AVInputFormat  ff_aiff_demuxer;
 extern AVOutputFormat ff_aiff_muxer;
 extern AVInputFormat  ff_aix_demuxer;
+extern AVInputFormat  ff_alp_demuxer;
 extern AVInputFormat  ff_amr_demuxer;
 extern AVOutputFormat ff_amr_muxer;
 extern AVInputFormat  ff_amrnb_demuxer;
diff --git a/libavformat/alp.c b/libavformat/alp.c
new file mode 100644
index 00..c0c7905380
--- /dev/null
+++ b/libavformat/alp.c
@@ -0,0 +1,146 @@
+/*
+ * LEGO Racers ALP (.tun & .pcm) demuxer
+ *
+ * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "avformat.h"
+#include "internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/internal.h"
+
+#define ALP_TAGMKTAG('A', 'L', 'P', ' ')
+#define ALP_MAX_READ_SIZE  4096
+
+typedef struct ALPHeader {
+uint32_tmagic;  /*< Magic Number, {'A', 'L', 'P', ' '} */
+uint32_theader_size;/*< Header size (after this). */
+charadpcm[6];   /*< "ADPCM" */
+uint8_t unk1;   /*< Unknown */
+uint8_t num_channels;   /*< Channel Count. */
+uint32_tsample_rate;/*< Sample rate, only if header_size >= 12. */
+} ALPHeader;
+
+static int alp_probe(const AVProbeData *p)
+{
+uint32_t i;
+
+if (AV_RL32(p->buf) != ALP_TAG)
+return 0;
+
+/* Only allowed header sizes are 8 and 12. */
+i = AV_RL32(p->buf + 4);
+if (i != 8 && i != 12)
+return 0;
+
+if (strncmp("ADPCM", p->buf + 8, 6) != 0)
+return 0;
+
+return AVPROBE_SCORE_EXTENSION + 1;
+}
+
+static int alp_read_header(AVFormatContext *s)
+{
+int ret;
+AVStream *st;
+ALPHeader hdr;
+AVCodecParameters *par;
+
+if ((hdr.magic = avio_rl32(s->pb)) != ALP_TAG)
+return AVERROR_INVALIDDATA;
+
+hdr.header_size = avio_rl32(s->pb);
+
+if (hdr.header_size != 8 && hdr.header_size != 12) {
+return AVERROR_INVALIDDATA;
+}
+
+if ((ret = avio_read(s->pb, hdr.adpcm, sizeof(hdr.adpcm))) < 0)
+return ret;
+else if (ret != sizeof(hdr.adpcm))
+return AVERROR(EIO);
+
+if (strncmp("ADPCM", hdr.adpcm, sizeof(hdr.adpcm)) != 0)
+return AVERROR_INVALIDDATA;
+
+hdr.unk1= avio_r8(s->pb);
+hdr.num_channels= avio_r8(s->pb);
+
+if (hdr.header_size == 8) {
+/* .TUN music file */
+hdr.sample_rate = 11025 * hdr.num_channels;
+} else {
+/* .PCM sound file */
+hdr.sample_rate = avio_rl32(s->pb);
+}
+
+if (hdr.sample_rate > 44100) {
+avpriv_request_sample(s, "Sample Rate > 44100");
+return AVERROR_PATCHWELCOME;
+}
+
+if (!(st = avformat_new_stream(s, NULL)))
+return AVERROR(ENOMEM);
+
+par 

[FFmpeg-devel] [PATCH v3 1/2] avcodec: add decoder for High Voltage Software's ALP ADPCM

2020-03-08 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog   |  1 +
 doc/general.texi|  1 +
 libavcodec/Makefile |  1 +
 libavcodec/adpcm.c  | 36 
 libavcodec/allcodecs.c  |  1 +
 libavcodec/avcodec.h|  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/version.h|  4 ++--
 8 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index cb310a3abc..a962657b85 100644
--- a/Changelog
+++ b/Changelog
@@ -43,6 +43,7 @@ version :
 - Rayman 2 ADPCM decoder
 - Rayman 2 APM demuxer
 - cas video filter
+- High Voltage Software ADPCM decoder
 
 
 version 4.2:
diff --git a/doc/general.texi b/doc/general.texi
index dbdc348598..87eaad7791 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1100,6 +1100,7 @@ following image formats are supported:
 @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
 @item ADPCM IMA Electronic Arts SEAD  @tab @tab  X
 @item ADPCM IMA Funcom   @tab @tab  X
+@item ADPCM IMA High Voltage Software ALP   @tab @tab  X
 @item ADPCM IMA QuickTime@tab  X  @tab  X
 @item ADPCM IMA Simon & Schuster Interactive   @tab  @tab  X
 @item ADPCM IMA Ubisoft APM  @tab @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1c032b456..0fd374ffed 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -834,6 +834,7 @@ OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 5f152ee6ef..c69cac3379 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -15,6 +15,7 @@
  * Argonaut Games ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com)
  * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen 
(z...@zanevaniperen.com)
  * Ubisoft ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com)
+ * High Voltage Software ALP decoder by Zane van Iperen 
(z...@zanevaniperen.com)
  *
  * This file is part of FFmpeg.
  *
@@ -280,6 +281,29 @@ static inline int16_t 
adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibb
 return (int16_t)c->predictor;
 }
 
+static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, 
int8_t nibble, int shift)
+{
+int step_index;
+int predictor;
+int sign, delta, diff, step;
+
+step = ff_adpcm_step_table[c->step_index];
+step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
+step_index = av_clip(step_index, 0, 88);
+
+sign = nibble & 8;
+delta = nibble & 7;
+diff = (delta * step) >> shift;
+predictor = c->predictor;
+if (sign) predictor -= diff;
+else predictor += diff;
+
+c->predictor = av_clip_int16(predictor);
+c->step_index = step_index;
+
+return (int16_t)c->predictor;
+}
+
 static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, 
GetBitContext *gb, int bps)
 {
 int nibble, step_index, predictor, sign, delta, diff, step, shift;
@@ -675,6 +699,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 case AV_CODEC_ID_ADPCM_AICA:
 case AV_CODEC_ID_ADPCM_IMA_SSI:
 case AV_CODEC_ID_ADPCM_IMA_APM:
+case AV_CODEC_ID_ADPCM_IMA_ALP:
 nb_samples = buf_size * 2 / ch;
 break;
 }
@@ -1247,6 +1272,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 samples += avctx->channels;
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_ALP:
+for (n = nb_samples / 2; n > 0; n--) {
+for (channel = 0; channel < avctx->channels; channel++) {
+int v = bytestream2_get_byteu(&gb);
+*samples++  = adpcm_ima_alp_expand_nibble(&c->status[channel], 
v >> 4  , 2);
+samples[st] = adpcm_ima_alp_expand_nibble(&c->status[channel], 
v & 0x0F, 2);
+}
+samples += avctx->channels;
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_OKI:
 while (bytestream2_get_bytes_left(&gb) > 0) {
 int v = bytestream2_get_byteu(&gb);
@@ -1997,6 +2032,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT,  
sample_fmts_s16p, adpcm_ima_qt,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16,  adpcm_ima_rad,  
   "ADPCM IMA Radical");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SSI, sample_fmts_s16,  adpcm_ima_ssi,  
   "ADPCM IMA Simon & Schuster Interactive");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG,  sample_fmts_s16,  
adpcm_ima_smjpeg,  "ADPCM IMA Loki SDL MJPEG");
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ALP, sample_fmts_s16,  adpcm_ima_alp,  
   "ADPCM IMA High Voltage S

Re: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_enc: Adapt to the new internal encode API

2020-03-08 Thread Lynne
Mar 8, 2020, 05:40 by andriy.gel...@gmail.com:

> On Sat, 07. Mar 23:13, James Almer wrote:
>
>> On 3/7/2020 9:23 PM, Andriy Gelman wrote:
>> > From: Andriy Gelman 
>> > 
>> > Should be squashed with:
>> > http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257735.html
>>
>> Thank you! Only three remain now :)
>>
>> > 
>> > Signed-off-by: Andriy Gelman 
>> > ---
>> >  libavcodec/v4l2_m2m.c |  9 -
>> >  libavcodec/v4l2_m2m.h |  6 +-
>> >  libavcodec/v4l2_m2m_dec.c |  2 +-
>> >  libavcodec/v4l2_m2m_enc.c | 17 +++--
>> >  4 files changed, 29 insertions(+), 5 deletions(-)
>> > 
>> > diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
>> > index 2d21f910bcc..1799837fb9f 100644
>> > --- a/libavcodec/v4l2_m2m.c
>> > +++ b/libavcodec/v4l2_m2m.c
>> > @@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, 
>> > uint8_t *context)
>> >  sem_destroy(&s->refsync);
>> > 
>> >  close(s->fd);
>> > +av_frame_free(&s->frame);
>> > 
>> >  av_free(s);
>> >  }
>> > @@ -394,7 +395,7 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
>> >  return v4l2_configure_contexts(s);
>> >  }
>> > 
>> > -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
>> > +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
>> > V4L2m2mContext **s)
>> >  {
>> >  *s = av_mallocz(sizeof(V4L2m2mContext));
>> >  if (!*s)
>> > @@ -417,5 +418,11 @@ int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, 
>> > V4L2m2mContext **s)
>> >  priv->context->self_ref = priv->context_ref;
>> >  priv->context->fd = -1;
>> > 
>> > +if (is_encoder) {
>> > +priv->context->frame = av_frame_alloc();
>> > +if (!priv->context->frame)
>> > +return AVERROR(ENOMEM);
>> > +}
>> > +
>> >  return 0;
>> >  }
>> > diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
>> > index 456281f48c5..5d6106224dd 100644
>> > --- a/libavcodec/v4l2_m2m.h
>> > +++ b/libavcodec/v4l2_m2m.h
>> > @@ -58,6 +58,9 @@ typedef struct V4L2m2mContext {
>> >  int draining;
>> >  AVPacket buf_pkt;
>> > 
>> > +/* Reference to a frame. Only used during encoding */
>> > +AVFrame *frame;
>> > +
>> >  /* Reference to self; only valid while codec is active. */
>> >  AVBufferRef *self_ref;
>> > 
>> > @@ -79,11 +82,12 @@ typedef struct V4L2m2mPriv {
>> >   * Allocate a new context and references for a V4L2 M2M instance.
>> >   *
>> >   * @param[in] ctx The V4L2m2mPriv instantiated by the encoder/decoder.
>> > + * @param[in] is_encoder Whether the context is for encoder/decoder
>> >   * @param[out] ctx The V4L2m2mContext.
>> >   *
>> >   * @returns 0 in success, a negative error code otherwise.
>> >   */
>> > -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s);
>> > +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
>> > V4L2m2mContext **s);
>> > 
>> > 
>> >  /**
>> > diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
>> > index d666edffe46..7c7ac2de8c5 100644
>> > --- a/libavcodec/v4l2_m2m_dec.c
>> > +++ b/libavcodec/v4l2_m2m_dec.c
>> > @@ -181,7 +181,7 @@ static av_cold int v4l2_decode_init(AVCodecContext 
>> > *avctx)
>> >  V4L2m2mPriv *priv = avctx->priv_data;
>> >  int ret;
>> > 
>> > -ret = ff_v4l2_m2m_create_context(priv, &s);
>> > +ret = ff_v4l2_m2m_create_context(priv, 
>> > !av_codec_is_decoder(avctx->codec), &s);
>>
>>
>> There's av_codec_is_encoder(). Also, You could pass avctx to
>> ff_v4l2_m2m_create_context() instead of priv, and call
>> av_codec_is_encoder() there, saving yourself the extra parameter.
>>
>> Alternatively, just allocate the frame unconditionally and avoid all
>> this extra code. ff_v4l2_m2m_create_context() is called once during
>> init, so it's not an issue if the decoder allocates it as well.
>>
>
> That's true, thanks.
> I prefer your second option a bit more because it keeps same style in
> v4l2_m2m.h.
>
> I'll resend tomorrow in case there are more comments.
>

To be honest, I'm against the new internal API.
I'd rather keep the new API as a wrapper for the old API unless the codec uses 
the new API if it means we can have asynchronous encoders and decoders. The new 
API eliminates that since codec threads would have to resort to polling for new 
packets/frames. With the old send/receive API those functions would simply be 
queuing and fetching from FIFO buffers the codec main thread 
retrieves/populates.
Sure, it'll take time to port over all the old codecs to the new API (so the 
wrapping code can be removed), but the only reason no new software encoders 
have used the new API was simply because it was discouraged. Otherwise I'd have 
used the new API in any new software codecs I've written and I'd have started 
porting codecs to the new API.
Not to mention the porting can be hugely simplified by a few dozen lines of 
helpers to automatically make FIFOs and invoke the old single function.
__

Re: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_enc: Adapt to the new internal encode API

2020-03-08 Thread James Almer
On 3/8/2020 9:29 AM, Lynne wrote:
> Mar 8, 2020, 05:40 by andriy.gel...@gmail.com:
> 
>> On Sat, 07. Mar 23:13, James Almer wrote:
>>
>>> On 3/7/2020 9:23 PM, Andriy Gelman wrote:
 From: Andriy Gelman 

 Should be squashed with:
 http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257735.html
>>>
>>> Thank you! Only three remain now :)
>>>

 Signed-off-by: Andriy Gelman 
 ---
  libavcodec/v4l2_m2m.c |  9 -
  libavcodec/v4l2_m2m.h |  6 +-
  libavcodec/v4l2_m2m_dec.c |  2 +-
  libavcodec/v4l2_m2m_enc.c | 17 +++--
  4 files changed, 29 insertions(+), 5 deletions(-)

 diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
 index 2d21f910bcc..1799837fb9f 100644
 --- a/libavcodec/v4l2_m2m.c
 +++ b/libavcodec/v4l2_m2m.c
 @@ -329,6 +329,7 @@ static void v4l2_m2m_destroy_context(void *opaque, 
 uint8_t *context)
  sem_destroy(&s->refsync);

  close(s->fd);
 +av_frame_free(&s->frame);

  av_free(s);
  }
 @@ -394,7 +395,7 @@ int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
  return v4l2_configure_contexts(s);
  }

 -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
 +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
 V4L2m2mContext **s)
  {
  *s = av_mallocz(sizeof(V4L2m2mContext));
  if (!*s)
 @@ -417,5 +418,11 @@ int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, 
 V4L2m2mContext **s)
  priv->context->self_ref = priv->context_ref;
  priv->context->fd = -1;

 +if (is_encoder) {
 +priv->context->frame = av_frame_alloc();
 +if (!priv->context->frame)
 +return AVERROR(ENOMEM);
 +}
 +
  return 0;
  }
 diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
 index 456281f48c5..5d6106224dd 100644
 --- a/libavcodec/v4l2_m2m.h
 +++ b/libavcodec/v4l2_m2m.h
 @@ -58,6 +58,9 @@ typedef struct V4L2m2mContext {
  int draining;
  AVPacket buf_pkt;

 +/* Reference to a frame. Only used during encoding */
 +AVFrame *frame;
 +
  /* Reference to self; only valid while codec is active. */
  AVBufferRef *self_ref;

 @@ -79,11 +82,12 @@ typedef struct V4L2m2mPriv {
   * Allocate a new context and references for a V4L2 M2M instance.
   *
   * @param[in] ctx The V4L2m2mPriv instantiated by the encoder/decoder.
 + * @param[in] is_encoder Whether the context is for encoder/decoder
   * @param[out] ctx The V4L2m2mContext.
   *
   * @returns 0 in success, a negative error code otherwise.
   */
 -int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s);
 +int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, int is_encoder, 
 V4L2m2mContext **s);


  /**
 diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
 index d666edffe46..7c7ac2de8c5 100644
 --- a/libavcodec/v4l2_m2m_dec.c
 +++ b/libavcodec/v4l2_m2m_dec.c
 @@ -181,7 +181,7 @@ static av_cold int v4l2_decode_init(AVCodecContext 
 *avctx)
  V4L2m2mPriv *priv = avctx->priv_data;
  int ret;

 -ret = ff_v4l2_m2m_create_context(priv, &s);
 +ret = ff_v4l2_m2m_create_context(priv, 
 !av_codec_is_decoder(avctx->codec), &s);
>>>
>>>
>>> There's av_codec_is_encoder(). Also, You could pass avctx to
>>> ff_v4l2_m2m_create_context() instead of priv, and call
>>> av_codec_is_encoder() there, saving yourself the extra parameter.
>>>
>>> Alternatively, just allocate the frame unconditionally and avoid all
>>> this extra code. ff_v4l2_m2m_create_context() is called once during
>>> init, so it's not an issue if the decoder allocates it as well.
>>>
>>
>> That's true, thanks.
>> I prefer your second option a bit more because it keeps same style in
>> v4l2_m2m.h.
>>
>> I'll resend tomorrow in case there are more comments.
>>
> 
> To be honest, I'm against the new internal API.
> I'd rather keep the new API as a wrapper for the old API

Removing the dependency of the new public encode API
(avcodec_send_frame/avcodec_receive_packet) on the old public encode API
(avcodec_encode_audio2/avcodec_encode_video2) so the latter may finally
be removed is one of the core objectives of this patchset.
You mentioned you wanted that to happen in the upcoming major bump.
While it's not going to be the case, it wouldn't even be possible
without this change.

> unless the codec uses the new API if it means we can have asynchronous 
> encoders and decoders. The new API eliminates that since codec threads would 
> have to resort to polling for new packets/frames. With the old send/receive 
> API those functions would simply be queuing and fetching from FIFO buffers 
> the codec main thread retrieves/populates.

Having a single internal callback function that fetches fr

Re: [FFmpeg-devel] [PATCH v3 2/2] avformat: add demuxer for LEGO Racers' ALP format

2020-03-08 Thread Paul B Mahol
lgtm

On 3/8/20, Zane van Iperen  wrote:
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/alp.c| 146 +++
>  libavformat/version.h|   4 +-
>  5 files changed, 151 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/alp.c
>
> diff --git a/Changelog b/Changelog
> index a962657b85..41a9166827 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -44,6 +44,7 @@ version :
>  - Rayman 2 APM demuxer
>  - cas video filter
>  - High Voltage Software ADPCM decoder
> +- LEGO Racers ALP (.tun & .pcm) demuxer
>
>
>  version 4.2:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index e0681058a2..fbb29505ff 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -85,6 +85,7 @@ OBJS-$(CONFIG_AIFF_DEMUXER)  += aiffdec.o
> pcm.o isom.o \
>  mov_chan.o replaygain.o
>  OBJS-$(CONFIG_AIFF_MUXER)+= aiffenc.o id3v2enc.o
>  OBJS-$(CONFIG_AIX_DEMUXER)   += aixdec.o
> +OBJS-$(CONFIG_ALP_DEMUXER)   += alp.o
>  OBJS-$(CONFIG_AMR_DEMUXER)   += amr.o
>  OBJS-$(CONFIG_AMR_MUXER) += amr.o
>  OBJS-$(CONFIG_AMRNB_DEMUXER) += amr.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 0209bf0e30..08012ea208 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -46,6 +46,7 @@ extern AVInputFormat  ff_afc_demuxer;
>  extern AVInputFormat  ff_aiff_demuxer;
>  extern AVOutputFormat ff_aiff_muxer;
>  extern AVInputFormat  ff_aix_demuxer;
> +extern AVInputFormat  ff_alp_demuxer;
>  extern AVInputFormat  ff_amr_demuxer;
>  extern AVOutputFormat ff_amr_muxer;
>  extern AVInputFormat  ff_amrnb_demuxer;
> diff --git a/libavformat/alp.c b/libavformat/alp.c
> new file mode 100644
> index 00..c0c7905380
> --- /dev/null
> +++ b/libavformat/alp.c
> @@ -0,0 +1,146 @@
> +/*
> + * LEGO Racers ALP (.tun & .pcm) demuxer
> + *
> + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> + */
> +#include "avformat.h"
> +#include "internal.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/internal.h"
> +
> +#define ALP_TAGMKTAG('A', 'L', 'P', ' ')
> +#define ALP_MAX_READ_SIZE  4096
> +
> +typedef struct ALPHeader {
> +uint32_tmagic;  /*< Magic Number, {'A', 'L', 'P', ' '} */
> +uint32_theader_size;/*< Header size (after this). */
> +charadpcm[6];   /*< "ADPCM" */
> +uint8_t unk1;   /*< Unknown */
> +uint8_t num_channels;   /*< Channel Count. */
> +uint32_tsample_rate;/*< Sample rate, only if header_size >= 12.
> */
> +} ALPHeader;
> +
> +static int alp_probe(const AVProbeData *p)
> +{
> +uint32_t i;
> +
> +if (AV_RL32(p->buf) != ALP_TAG)
> +return 0;
> +
> +/* Only allowed header sizes are 8 and 12. */
> +i = AV_RL32(p->buf + 4);
> +if (i != 8 && i != 12)
> +return 0;
> +
> +if (strncmp("ADPCM", p->buf + 8, 6) != 0)
> +return 0;
> +
> +return AVPROBE_SCORE_EXTENSION + 1;
> +}
> +
> +static int alp_read_header(AVFormatContext *s)
> +{
> +int ret;
> +AVStream *st;
> +ALPHeader hdr;
> +AVCodecParameters *par;
> +
> +if ((hdr.magic = avio_rl32(s->pb)) != ALP_TAG)
> +return AVERROR_INVALIDDATA;
> +
> +hdr.header_size = avio_rl32(s->pb);
> +
> +if (hdr.header_size != 8 && hdr.header_size != 12) {
> +return AVERROR_INVALIDDATA;
> +}
> +
> +if ((ret = avio_read(s->pb, hdr.adpcm, sizeof(hdr.adpcm))) < 0)
> +return ret;
> +else if (ret != sizeof(hdr.adpcm))
> +return AVERROR(EIO);
> +
> +if (strncmp("ADPCM", hdr.adpcm, sizeof(hdr.adpcm)) != 0)
> +return AVERROR_INVALIDDATA;
> +
> +hdr.unk1= avio_r8(s->pb);
> +hdr.num_channels= avio_r8(s->pb);
> +
> +if (hdr.header_size == 8) {
> +/* .TUN music file */
> +hdr.sample_rate = 11025 * hdr.num_channels;
> +} else {
> +/* .PCM sound file 

Re: [FFmpeg-devel] [PATCH v3 1/2] avcodec: add decoder for High Voltage Software's ALP ADPCM

2020-03-08 Thread Paul B Mahol
lgtm

On 3/8/20, Zane van Iperen  wrote:
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog   |  1 +
>  doc/general.texi|  1 +
>  libavcodec/Makefile |  1 +
>  libavcodec/adpcm.c  | 36 
>  libavcodec/allcodecs.c  |  1 +
>  libavcodec/avcodec.h|  1 +
>  libavcodec/codec_desc.c |  7 +++
>  libavcodec/version.h|  4 ++--
>  8 files changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/Changelog b/Changelog
> index cb310a3abc..a962657b85 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -43,6 +43,7 @@ version :
>  - Rayman 2 ADPCM decoder
>  - Rayman 2 APM demuxer
>  - cas video filter
> +- High Voltage Software ADPCM decoder
>
>
>  version 4.2:
> diff --git a/doc/general.texi b/doc/general.texi
> index dbdc348598..87eaad7791 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -1100,6 +1100,7 @@ following image formats are supported:
>  @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
>  @item ADPCM IMA Electronic Arts SEAD  @tab @tab  X
>  @item ADPCM IMA Funcom   @tab @tab  X
> +@item ADPCM IMA High Voltage Software ALP   @tab @tab  X
>  @item ADPCM IMA QuickTime@tab  X  @tab  X
>  @item ADPCM IMA Simon & Schuster Interactive   @tab  @tab  X
>  @item ADPCM IMA Ubisoft APM  @tab @tab X
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index f1c032b456..0fd374ffed 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -834,6 +834,7 @@ OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
>  OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
>  OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
>  OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
> +OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)  += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER)  += adpcm.o adpcm_data.o
>  OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
> diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> index 5f152ee6ef..c69cac3379 100644
> --- a/libavcodec/adpcm.c
> +++ b/libavcodec/adpcm.c
> @@ -15,6 +15,7 @@
>   * Argonaut Games ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com)
>   * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen
> (z...@zanevaniperen.com)
>   * Ubisoft ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com)
> + * High Voltage Software ALP decoder by Zane van Iperen
> (z...@zanevaniperen.com)
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -280,6 +281,29 @@ static inline int16_t
> adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibb
>  return (int16_t)c->predictor;
>  }
>
> +static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c,
> int8_t nibble, int shift)
> +{
> +int step_index;
> +int predictor;
> +int sign, delta, diff, step;
> +
> +step = ff_adpcm_step_table[c->step_index];
> +step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
> +step_index = av_clip(step_index, 0, 88);
> +
> +sign = nibble & 8;
> +delta = nibble & 7;
> +diff = (delta * step) >> shift;
> +predictor = c->predictor;
> +if (sign) predictor -= diff;
> +else predictor += diff;
> +
> +c->predictor = av_clip_int16(predictor);
> +c->step_index = step_index;
> +
> +return (int16_t)c->predictor;
> +}
> +
>  static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c,
> GetBitContext *gb, int bps)
>  {
>  int nibble, step_index, predictor, sign, delta, diff, step, shift;
> @@ -675,6 +699,7 @@ static int get_nb_samples(AVCodecContext *avctx,
> GetByteContext *gb,
>  case AV_CODEC_ID_ADPCM_AICA:
>  case AV_CODEC_ID_ADPCM_IMA_SSI:
>  case AV_CODEC_ID_ADPCM_IMA_APM:
> +case AV_CODEC_ID_ADPCM_IMA_ALP:
>  nb_samples = buf_size * 2 / ch;
>  break;
>  }
> @@ -1247,6 +1272,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
> void *data,
>  samples += avctx->channels;
>  }
>  break;
> +case AV_CODEC_ID_ADPCM_IMA_ALP:
> +for (n = nb_samples / 2; n > 0; n--) {
> +for (channel = 0; channel < avctx->channels; channel++) {
> +int v = bytestream2_get_byteu(&gb);
> +*samples++  =
> adpcm_ima_alp_expand_nibble(&c->status[channel], v >> 4  , 2);
> +samples[st] =
> adpcm_ima_alp_expand_nibble(&c->status[channel], v & 0x0F, 2);
> +}
> +samples += avctx->channels;
> +}
> +break;
>  case AV_CODEC_ID_ADPCM_IMA_OKI:
>  while (bytestream2_get_bytes_left(&gb) > 0) {
>  int v = bytestream2_get_byteu(&gb);
> @@ -1997,6 +2032,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT,
> sample_fmts_s16p, adpcm_ima_qt,
>  ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16,
> adpcm_ima_rad, "ADPCM IMA Radical");
>  ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SSI, sample_fmts_s16,
> adpcm_ima

[FFmpeg-devel] [PATCH] lavc/v4l2_m2m_dec: Init reserved bytes to zero before ioctl call

2020-03-08 Thread Andriy Gelman
From: Andriy Gelman 

struct v4l2_selection contains reserved bytes which should be set to
zero before the ioctl call.

Fixes valgrind error:
Syscall param ioctl(VKI_V4L2_S_SELECTION) points to uninitialised byte(s)

Signed-off-by: Andriy Gelman 
---
 libavcodec/v4l2_m2m_dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index d666edffe46..c5ee86b9935 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -39,7 +39,7 @@ static int v4l2_try_start(AVCodecContext *avctx)
 V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
 V4L2Context *const capture = &s->capture;
 V4L2Context *const output = &s->output;
-struct v4l2_selection selection;
+struct v4l2_selection selection = { 0 };
 int ret;
 
 /* 1. start the output process */
-- 
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] fftools/ffplay: fix possible memory leak in decoder

2020-03-08 Thread Marton Balint



On Thu, 5 Mar 2020, Marton Balint wrote:


Fixes ticket #8549.


Applied.

Regards,
Marton



Signed-off-by: Marton Balint 
---
fftools/ffplay.c | 5 -
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index fee0619f7c..f6511e4afd 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -644,7 +644,10 @@ static int decoder_decode_frame(Decoder *d, AVFrame 
*frame, AVSubtitle *sub) {
if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0)
return -1;
}
-} while (d->queue->serial != d->pkt_serial);
+if (d->queue->serial == d->pkt_serial)
+break;
+av_packet_unref(&pkt);
+} while (1);

if (pkt.data == flush_pkt.data) {
avcodec_flush_buffers(d->avctx);
--
2.16.4

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

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

___
ffmpeg-devel 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] fftools/ffmpeg_opt: warn about overwritten parsed options

2020-03-08 Thread Marton Balint



On Sun, 8 Mar 2020, Gyan Doshi wrote:




On 08-03-2020 01:22 am, Marton Balint wrote:



On Sat, 29 Feb 2020, Marton Balint wrote:


Signed-off-by: Marton Balint 
---
fftools/ffmpeg_opt.c | 70 
+---

1 file changed, 67 insertions(+), 3 deletions(-)


Ping, will apply soon.


LGTM.


Thanks, applied the series.

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

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

Re: [FFmpeg-devel] [PATCH] avformat/udp: support w32pthreads compat

2020-03-08 Thread Marton Balint



On Fri, 6 Mar 2020, Ross Nicholson wrote:


Ping


Thanks, applied.

Regards,
Marton




On 2 Mar 2020, at 21:30, Ross Nicholson  wrote:

phunkyfish in the history is fine thanks ;)


On 2 Mar 2020, at 21:00, Marton Balint  wrote:




On Mon, 2 Mar 2020, Ross Nicholson wrote:


Updated to correct header.


Can you resend the patch with the proper author (e.g. Ross Nicholson instead of 
phunkyfish?) Or you want to appear as phunkyfish in the history?

Thanks,
Marton




On Mon, 2 Mar 2020 at 19:53, Marton Balint  wrote:




On Mon, 2 Mar 2020, phunkyfish wrote:



---
compat/w32pthreads.h | 8 
libavformat/udp.c| 6 +-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 7df33b7da4..6405e72b64 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -63,6 +63,9 @@ typedef CONDITION_VARIABLE pthread_cond_t;
#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)

+#define PTHREAD_CANCEL_ENABLE 1
+#define PTHREAD_CANCEL_DISABLE 0
+
static av_unused unsigned __stdcall attribute_align_arg

win32thread_worker(void *arg)

{
   pthread_t *h = (pthread_t*)arg;
@@ -180,4 +183,9 @@ static inline int pthread_cond_signal(pthread_cond_t

*cond)

   return 0;
}

+static inline int pthread_setcancelstate(int state, int *oldstate)
+{
+return 0;
+}
+
#endif /* COMPAT_W32PTHREADS_H */
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 23c3773c64..692ff07cec 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -61,7 +61,11 @@
#define IPPROTO_UDPLITE  136
#endif

-#if HAVE_PTHREAD_CANCEL
+#if HAVE_W32THREADS
+#include "compat/w32pthreads.h"


This should be #include "libavutil/thread.h" instead, the compat layer
should not be included directly.

Regards,
Marton


+#undef HAVE_PTHREAD_CANCEL
+#define HAVE_PTHREAD_CANCEL 1
+#elif HAVE_PTHREAD_CANCEL
#include 
#endif

--
2.20.1 (Apple Git-117)

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

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

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

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

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

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

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

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

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

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

___
ffmpeg-devel 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] fftools/ffmpeg_opt: warn about overwritten parsed options

2020-03-08 Thread Carl Eugen Hoyos
Am So., 8. März 2020 um 19:35 Uhr schrieb Marton Balint :
>
>
>
> On Sun, 8 Mar 2020, Gyan Doshi wrote:
>
> >
> >
> > On 08-03-2020 01:22 am, Marton Balint wrote:
> >>
> >>
> >> On Sat, 29 Feb 2020, Marton Balint wrote:
> >>
> >>> Signed-off-by: Marton Balint 
> >>> ---
> >>> fftools/ffmpeg_opt.c | 70
> >>> +---
> >>> 1 file changed, 67 insertions(+), 3 deletions(-)
> >>
> >> Ping, will apply soon.
> >
> > LGTM.
>
> Thanks, applied the series.

Thank you!

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

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

[FFmpeg-devel] [PATCH v3 1/2] avformat: Add AMQP version 0-9-1 protocol support

2020-03-08 Thread Andriy Gelman
From: Andriy Gelman 

Supports connecting to a RabbitMQ broker via AMQP version 0-9-1.

Signed-off-by: Andriy Gelman 
---

Changes in v3:
- Fixed a bug when parsing username that contained a url encoded ":"
- Fixed documentation error and improved logging

Changes in v2:
- Addressed comments from Marton
- Updated documentation

Compilation notes:
- Requires librabbitmq-dev package (on ubuntu).
- The pkg-config libprabbitmq.pc has a corrupt entry.  
  **update: fixed on the github master branch**
  The line "Libs.private: rt; -lpthread" should be changed to
  "Libs.private: -lrt -pthread".
- Compile FFmpeg with --enable-librabbitmq

 Changelog   |   1 +
 configure   |   5 +
 doc/general.texi|   1 +
 doc/protocols.texi  |  60 
 libavformat/Makefile|   1 +
 libavformat/libamqp.c   | 296 
 libavformat/protocols.c |   1 +
 libavformat/version.h   |   4 +-
 8 files changed, 367 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/libamqp.c

diff --git a/Changelog b/Changelog
index cb310a3abc2..ab30d670a15 100644
--- a/Changelog
+++ b/Changelog
@@ -43,6 +43,7 @@ version :
 - Rayman 2 ADPCM decoder
 - Rayman 2 APM demuxer
 - cas video filter
+- AMQP 0-9-1 protocol (RabbitMQ)
 
 
 version 4.2:
diff --git a/configure b/configure
index 06e3a7b2a88..8b171349440 100755
--- a/configure
+++ b/configure
@@ -255,6 +255,7 @@ External library support:
   --enable-libopenmpt  enable decoding tracked files via libopenmpt [no]
   --enable-libopus enable Opus de/encoding via libopus [no]
   --enable-libpulseenable Pulseaudio input via libpulse [no]
+  --enable-librabbitmq enable RabbitMQ library [no]
   --enable-librav1eenable AV1 encoding via rav1e [no]
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
@@ -1789,6 +1790,7 @@ EXTERNAL_LIBRARY_LIST="
 libopenmpt
 libopus
 libpulse
+librabbitmq
 librav1e
 librsvg
 librtmp
@@ -3434,6 +3436,8 @@ unix_protocol_deps="sys_un_h"
 unix_protocol_select="network"
 
 # external library protocols
+libamqp_protocol_deps="librabbitmq"
+libamqp_protocol_select="network"
 librtmp_protocol_deps="librtmp"
 librtmpe_protocol_deps="librtmp"
 librtmps_protocol_deps="librtmp"
@@ -6317,6 +6321,7 @@ enabled libopus   && {
 }
 }
 enabled libpulse  && require_pkg_config libpulse libpulse 
pulse/pulseaudio.h pa_context_new
+enabled librabbitmq   && require_pkg_config librabbitmq "librabbitmq >= 
0.7.1" amqp.h amqp_new_connection
 enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.1.0" 
rav1e.h rav1e_context_new
 enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
 enabled librtmp   && require_pkg_config librtmp librtmp librtmp/rtmp.h 
RTMP_Socket
diff --git a/doc/general.texi b/doc/general.texi
index dbdc3485982..623566dabea 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1330,6 +1330,7 @@ performance on systems without hardware floating point 
support).
 
 @multitable @columnfractions .4 .1
 @item Name @tab Support
+@item AMQP @tab X
 @item file @tab X
 @item FTP  @tab X
 @item Gopher   @tab X
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 54a287f488b..27df4759b63 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -51,6 +51,66 @@ in microseconds.
 
 A description of the currently available protocols follows.
 
+@section amqp
+
+Advanced Message Queueing Protocol (AMQP) version 0-9-1 is a broker based
+publish-subscribe communication protocol.
+
+FFmpeg must be compiled with --enable-librabbitmq to support AMQP. A separate
+AMQP broker must also be run. An example open-source AMQP broker is RabbitMQ.
+
+After starting the broker, an FFmpeg client may stream data to the broker using
+the command:
+
+@example
+ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port]
+@end example
+
+Where hostname and port (default is 5672) is the address of the broker. The
+client may also set a user/password for authentication. The default for both
+fields is "guest".
+
+Muliple subscribers may stream from the broker using the command:
+@example
+ffplay amqp://[[user]:[password]@@]hostname[:port]
+@end example
+
+In RabbitMQ all data published to the broker flows through a specific exchange,
+and each subscribing client has an assigned queue/buffer. When a packet arrives
+at an exchange, it may be copied to a client's queue depending on the exchange
+and routing_key fields.
+
+The following options are supported:
+
+@table @option
+
+@item exchange
+Sets the exchange to use on the broker. RabbitMQ has several predefined
+exchanges: "amq.direct" is the default exchange, where the publisher and
+subscriber must have a matching routing_k

[FFmpeg-devel] [PATCH v3 2/2] avformat/libzmq: Make default pkt_size value consistent with amqp

2020-03-08 Thread Andriy Gelman
From: Andriy Gelman 

Signed-off-by: Andriy Gelman 
---
 doc/protocols.texi   | 2 +-
 libavformat/libzmq.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 27df4759b63..e510019f2d8 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1858,7 +1858,7 @@ line. The following options are supported:
 
 @item pkt_size
 Forces the maximum packet size for sending/receiving data. The default value is
-32,768 bytes. On the server side, this sets the maximum size of sent packets
+131,072 bytes. On the server side, this sets the maximum size of sent packets
 via ZeroMQ. On the clients, it sets an internal buffer size for receiving
 packets. Note that pkt_size on the clients should be equal to or greater than
 pkt_size on the server. Otherwise the received message may be truncated causing
diff --git a/libavformat/libzmq.c b/libavformat/libzmq.c
index 8c8b294c921..1b0d8638dbf 100644
--- a/libavformat/libzmq.c
+++ b/libavformat/libzmq.c
@@ -40,7 +40,7 @@ typedef struct ZMQContext {
 #define D AV_OPT_FLAG_DECODING_PARAM
 #define E AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
-{ "pkt_size", "Maximum send/read packet size", OFFSET(pkt_size), 
AV_OPT_TYPE_INT, { .i64 = 32768 }, -1, INT_MAX, .flags = D | E },
+{ "pkt_size", "Maximum send/read packet size", OFFSET(pkt_size), 
AV_OPT_TYPE_INT, { .i64 = 131072 }, -1, INT_MAX, .flags = D | E },
 { NULL }
 };
 
-- 
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 v2 1/2] avformat: Add AMQP version 0-9-1 protocol support

2020-03-08 Thread Andriy Gelman
On Sun, 08. Mar 12:25, Marton Balint wrote:
> 
> > Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 
> > protocol support
> > 
> > From: Andriy Gelman 
> > 
> > Supports connecting to a RabbitMQ broker via AMQP version 0-9-1.
> > 
> > Signed-off-by: Andriy Gelman 
> > ---
> > 
> > Changes in v2:
> > - Addressed comments from Marton
> > - Updated documentation
> > 
> > Compilation notes:
> > - Requires librabbitmq-dev package (on ubuntu).
> > - The pkg-config libprabbitmq.pc has a corrupt entry.
> >   **update: fixed on the github master branch**
> >   The line "Libs.private: rt; -lpthread" should be changed to
> >   "Libs.private: -lrt -pthread".
> > - Compile FFmpeg with --enable-librabbitmq
> > 
> 
> [...]
> 
> > +@item connection_timeout
> > +The timeout in microseconds during the initial connection to the broker. 
> > The
> 
> In *seconds* (because it is an AV_OPT_TYPE_DURATION)
> 
> > +default value is rw_timeout, or 500 microseconds if rw_timeout is not 
> > set.
> 
> 5 seconds
> 
> [...]
> 
> > +static const AVOption options[] = {
> > +{ "pkt_size", "Maximum send/read packet size", OFFSET(pkt_size), 
> > AV_OPT_TYPE_INT, { .i64 = 131072 }, 4096, INT_MAX, .flags = D | E },
> > +{ "exchange", "Exchange to send/read packets", OFFSET(exchange), 
> > AV_OPT_TYPE_STRING, { .str = "amq.direct" }, 0, 0, .flags = D | E },
> > +{ "routing_key", "Key to filter streams", OFFSET(routing_key), 
> > AV_OPT_TYPE_STRING, { .str = "amqp" }, 0, 0, .flags = D | E },
> > +{ "connection_timeout", "Initial connection timeout", 
> > OFFSET(connection_timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, 
> > INT_MAX, .flags = D | E},
> 
> INT64_MAX can be the maximum.
> 
> > +{ NULL }
> > +};
> > +
> > +static int amqp_proto_open(URLContext *h, const char *uri, int flags)
> > +{
> > +int ret, server_msg;
> > +char hostname[STR_LEN], credentials[STR_LEN];
> > +char *credentials_decoded;
> > +int port;
> > +const char *user, *password = NULL;
> > +char *p;
> > +amqp_rpc_reply_t broker_reply;
> > +struct timeval tval = { 0 };
> > +
> > +AMQPContext *s = h->priv_data;
> > +
> > +h->is_streamed = 1;
> > +h->max_packet_size = s->pkt_size;
> > +
> > +av_url_split(NULL, 0, credentials, sizeof(credentials),
> > + hostname, sizeof(hostname), &port, NULL, 0, uri);
> > +
> > +if (port < 0)
> > +port = 5672;
> > +
> > +if (hostname[0] == '\0' || port <= 0 || port > 65535 ) {
> > +av_log(h, AV_LOG_ERROR, "Invalid hostname/port\n");
> > +return AVERROR(EINVAL);
> > +}
> > +
> > +credentials_decoded = ff_urldecode(credentials, 0);

> 
> This is not entirely correct, becase the username may contain ':'
> characters... So you should split first and urldecode the splitted
> components...
> 

Thanks for reviewing and catching these two.

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

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

Re: [FFmpeg-devel] [PATCH v3 1/2] avformat: Add AMQP version 0-9-1 protocol support

2020-03-08 Thread Marton Balint



On Sun, 8 Mar 2020, Andriy Gelman wrote:


From: Andriy Gelman 

Supports connecting to a RabbitMQ broker via AMQP version 0-9-1.

Signed-off-by: Andriy Gelman 
---

Changes in v3:
   - Fixed a bug when parsing username that contained a url encoded ":"
   - Fixed documentation error and improved logging

Changes in v2:
   - Addressed comments from Marton
   - Updated documentation

Compilation notes:
   - Requires librabbitmq-dev package (on ubuntu).
   - The pkg-config libprabbitmq.pc has a corrupt entry.
 **update: fixed on the github master branch**
 The line "Libs.private: rt; -lpthread" should be changed to
 "Libs.private: -lrt -pthread".
   - Compile FFmpeg with --enable-librabbitmq

Changelog   |   1 +
configure   |   5 +
doc/general.texi|   1 +
doc/protocols.texi  |  60 
libavformat/Makefile|   1 +
libavformat/libamqp.c   | 296 
libavformat/protocols.c |   1 +
libavformat/version.h   |   4 +-
8 files changed, 367 insertions(+), 2 deletions(-)
create mode 100644 libavformat/libamqp.c


[...]


+password_decoded = ff_urldecode(password, 0);
+if (!password_decoded)
+return AVERROR(ENOMEM);
+
+user = credentials;
+if (*user == '\0')
+user = "guest";
+
+user_decoded = ff_urldecode(user, 0);
+if (!user_decoded) {
+av_freep(&password_decoded);
+return AVERROR(ENOMEM);
+}
+
+s->conn = amqp_new_connection();
+if (!s->conn) {
+av_log(h, AV_LOG_ERROR, "Error creating connection\n");
+return AVERROR_EXTERNAL;


This is leaking username and password.

Other than that, it looks good. I hope we resolved the usefulness 
concerns, so I plan to apply this tomorrow.


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

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

Re: [FFmpeg-devel] [PATCH v3 1/2] avformat: Add AMQP version 0-9-1 protocol support

2020-03-08 Thread Andriy Gelman
On Sun, 08. Mar 16:33, Andriy Gelman wrote:
> From: Andriy Gelman 
> 
> Supports connecting to a RabbitMQ broker via AMQP version 0-9-1.
> 
> Signed-off-by: Andriy Gelman 
> ---
> 
> Changes in v3:
> - Fixed a bug when parsing username that contained a url encoded ":"
> - Fixed documentation error and improved logging
> 
> Changes in v2:
> - Addressed comments from Marton
> - Updated documentation
> 
> Compilation notes:
> - Requires librabbitmq-dev package (on ubuntu).
> - The pkg-config libprabbitmq.pc has a corrupt entry.  
>   **update: fixed on the github master branch**
>   The line "Libs.private: rt; -lpthread" should be changed to
>   "Libs.private: -lrt -pthread".
> - Compile FFmpeg with --enable-librabbitmq
> 
>  Changelog   |   1 +
>  configure   |   5 +
>  doc/general.texi|   1 +
>  doc/protocols.texi  |  60 
>  libavformat/Makefile|   1 +
>  libavformat/libamqp.c   | 296 
>  libavformat/protocols.c |   1 +
>  libavformat/version.h   |   4 +-
>  8 files changed, 367 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/libamqp.c
> 
> diff --git a/Changelog b/Changelog
> index cb310a3abc2..ab30d670a15 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -43,6 +43,7 @@ version :
>  - Rayman 2 ADPCM decoder
>  - Rayman 2 APM demuxer
>  - cas video filter
> +- AMQP 0-9-1 protocol (RabbitMQ)
>  
>  
>  version 4.2:
> diff --git a/configure b/configure
> index 06e3a7b2a88..8b171349440 100755
> --- a/configure
> +++ b/configure
> @@ -255,6 +255,7 @@ External library support:
>--enable-libopenmpt  enable decoding tracked files via libopenmpt [no]
>--enable-libopus enable Opus de/encoding via libopus [no]
>--enable-libpulseenable Pulseaudio input via libpulse [no]
> +  --enable-librabbitmq enable RabbitMQ library [no]
>--enable-librav1eenable AV1 encoding via rav1e [no]
>--enable-librsvg enable SVG rasterization via librsvg [no]
>--enable-librubberband   enable rubberband needed for rubberband filter 
> [no]
> @@ -1789,6 +1790,7 @@ EXTERNAL_LIBRARY_LIST="
>  libopenmpt
>  libopus
>  libpulse
> +librabbitmq
>  librav1e
>  librsvg
>  librtmp
> @@ -3434,6 +3436,8 @@ unix_protocol_deps="sys_un_h"
>  unix_protocol_select="network"
>  
>  # external library protocols
> +libamqp_protocol_deps="librabbitmq"
> +libamqp_protocol_select="network"
>  librtmp_protocol_deps="librtmp"
>  librtmpe_protocol_deps="librtmp"
>  librtmps_protocol_deps="librtmp"
> @@ -6317,6 +6321,7 @@ enabled libopus   && {
>  }
>  }
>  enabled libpulse  && require_pkg_config libpulse libpulse 
> pulse/pulseaudio.h pa_context_new
> +enabled librabbitmq   && require_pkg_config librabbitmq "librabbitmq >= 
> 0.7.1" amqp.h amqp_new_connection
>  enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.1.0" 
> rav1e.h rav1e_context_new
>  enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
> librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
>  enabled librtmp   && require_pkg_config librtmp librtmp 
> librtmp/rtmp.h RTMP_Socket
> diff --git a/doc/general.texi b/doc/general.texi
> index dbdc3485982..623566dabea 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -1330,6 +1330,7 @@ performance on systems without hardware floating point 
> support).
>  
>  @multitable @columnfractions .4 .1
>  @item Name @tab Support
> +@item AMQP @tab X
>  @item file @tab X
>  @item FTP  @tab X
>  @item Gopher   @tab X
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index 54a287f488b..27df4759b63 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -51,6 +51,66 @@ in microseconds.
>  
>  A description of the currently available protocols follows.
>  
> +@section amqp
> +
> +Advanced Message Queueing Protocol (AMQP) version 0-9-1 is a broker based
> +publish-subscribe communication protocol.
> +
> +FFmpeg must be compiled with --enable-librabbitmq to support AMQP. A separate
> +AMQP broker must also be run. An example open-source AMQP broker is RabbitMQ.
> +
> +After starting the broker, an FFmpeg client may stream data to the broker 
> using
> +the command:
> +
> +@example
> +ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port]
> +@end example
> +
> +Where hostname and port (default is 5672) is the address of the broker. The
> +client may also set a user/password for authentication. The default for both
> +fields is "guest".
> +
> +Muliple subscribers may stream from the broker using the command:
> +@example
> +ffplay amqp://[[user]:[password]@@]hostname[:port]
> +@end example
> +
> +In RabbitMQ all data published to the broker flows through a specific 
> exchange,
> +and each subscribing client has an assigned queue/buffer. When a packet 
> arrives
> +at an exchange, it may be copied to a cli

[FFmpeg-devel] [PATCH v4 1/2] avformat: Add AMQP version 0-9-1 protocol support

2020-03-08 Thread Andriy Gelman
From: Andriy Gelman 

Supports connecting to a RabbitMQ broker via AMQP version 0-9-1.

Signed-off-by: Andriy Gelman 
---

Changes in v4:
- Fixed leak from user_decoded/password_decoded when amqp_new_connection()
  fails 

Changes in v3:
- Fixed a bug when parsing username that contained a url encoded ":"
- Fixed documentation error and improved logging

Changes in v2:
- Addressed comments from Marton
- Updated documentation

Compilation notes:
- Requires librabbitmq-dev package (on ubuntu).
- The pkg-config libprabbitmq.pc has a corrupt entry.  
  **update: fixed on the github master branch**
  The line "Libs.private: rt; -lpthread" should be changed to
  "Libs.private: -lrt -pthread".
- Compile FFmpeg with --enable-librabbitmq

 Changelog   |   1 +
 configure   |   5 +
 doc/general.texi|   1 +
 doc/protocols.texi  |  60 
 libavformat/Makefile|   1 +
 libavformat/libamqp.c   | 298 
 libavformat/protocols.c |   1 +
 libavformat/version.h   |   4 +-
 8 files changed, 369 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/libamqp.c

diff --git a/Changelog b/Changelog
index cb310a3abc2..ab30d670a15 100644
--- a/Changelog
+++ b/Changelog
@@ -43,6 +43,7 @@ version :
 - Rayman 2 ADPCM decoder
 - Rayman 2 APM demuxer
 - cas video filter
+- AMQP 0-9-1 protocol (RabbitMQ)
 
 
 version 4.2:
diff --git a/configure b/configure
index 06e3a7b2a88..8b171349440 100755
--- a/configure
+++ b/configure
@@ -255,6 +255,7 @@ External library support:
   --enable-libopenmpt  enable decoding tracked files via libopenmpt [no]
   --enable-libopus enable Opus de/encoding via libopus [no]
   --enable-libpulseenable Pulseaudio input via libpulse [no]
+  --enable-librabbitmq enable RabbitMQ library [no]
   --enable-librav1eenable AV1 encoding via rav1e [no]
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
@@ -1789,6 +1790,7 @@ EXTERNAL_LIBRARY_LIST="
 libopenmpt
 libopus
 libpulse
+librabbitmq
 librav1e
 librsvg
 librtmp
@@ -3434,6 +3436,8 @@ unix_protocol_deps="sys_un_h"
 unix_protocol_select="network"
 
 # external library protocols
+libamqp_protocol_deps="librabbitmq"
+libamqp_protocol_select="network"
 librtmp_protocol_deps="librtmp"
 librtmpe_protocol_deps="librtmp"
 librtmps_protocol_deps="librtmp"
@@ -6317,6 +6321,7 @@ enabled libopus   && {
 }
 }
 enabled libpulse  && require_pkg_config libpulse libpulse 
pulse/pulseaudio.h pa_context_new
+enabled librabbitmq   && require_pkg_config librabbitmq "librabbitmq >= 
0.7.1" amqp.h amqp_new_connection
 enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.1.0" 
rav1e.h rav1e_context_new
 enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
 enabled librtmp   && require_pkg_config librtmp librtmp librtmp/rtmp.h 
RTMP_Socket
diff --git a/doc/general.texi b/doc/general.texi
index dbdc3485982..623566dabea 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1330,6 +1330,7 @@ performance on systems without hardware floating point 
support).
 
 @multitable @columnfractions .4 .1
 @item Name @tab Support
+@item AMQP @tab X
 @item file @tab X
 @item FTP  @tab X
 @item Gopher   @tab X
diff --git a/doc/protocols.texi b/doc/protocols.texi
index 54a287f488b..27df4759b63 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -51,6 +51,66 @@ in microseconds.
 
 A description of the currently available protocols follows.
 
+@section amqp
+
+Advanced Message Queueing Protocol (AMQP) version 0-9-1 is a broker based
+publish-subscribe communication protocol.
+
+FFmpeg must be compiled with --enable-librabbitmq to support AMQP. A separate
+AMQP broker must also be run. An example open-source AMQP broker is RabbitMQ.
+
+After starting the broker, an FFmpeg client may stream data to the broker using
+the command:
+
+@example
+ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port]
+@end example
+
+Where hostname and port (default is 5672) is the address of the broker. The
+client may also set a user/password for authentication. The default for both
+fields is "guest".
+
+Muliple subscribers may stream from the broker using the command:
+@example
+ffplay amqp://[[user]:[password]@@]hostname[:port]
+@end example
+
+In RabbitMQ all data published to the broker flows through a specific exchange,
+and each subscribing client has an assigned queue/buffer. When a packet arrives
+at an exchange, it may be copied to a client's queue depending on the exchange
+and routing_key fields.
+
+The following options are supported:
+
+@table @option
+
+@item exchange
+Sets the exchange to use on the broker. RabbitMQ has several predefined
+exchang

Re: [FFmpeg-devel] [PATCH, v2 4/4] tests/checkasm: add overflow test for hevc_add_res

2020-03-08 Thread Michael Niedermayer
On Thu, Mar 05, 2020 at 03:48:28PM +0800, Linjie Fu wrote:
> Add overflow test for hevc_add_res when int16_t coeff = -32768,
> and doubled the test cases.
> 
> The result of C is good, while ASM is not.
> 
> To verify:
> make fate-checkasm-hevc_add_res
> ffmpeg/tests/checkasm/checkasm --test=hevc_add_res
> 
> ./checkasm --test=hevc_add_res
> checkasm: using random seed 679391863
> MMXEXT:
> hevc_add_res_4x4_8_mmxext (hevc_add_res.c:69)
>   - hevc_add_res.add_residual [FAILED]
> SSE2:
> hevc_add_res_8x8_8_sse2 (hevc_add_res.c:69)
> hevc_add_res_16x16_8_sse2 (hevc_add_res.c:69)
> hevc_add_res_32x32_8_sse2 (hevc_add_res.c:69)
>   - hevc_add_res.add_residual [FAILED]
> AVX:
> hevc_add_res_8x8_8_avx (hevc_add_res.c:69)
> hevc_add_res_16x16_8_avx (hevc_add_res.c:69)
> hevc_add_res_32x32_8_avx (hevc_add_res.c:69)
>   - hevc_add_res.add_residual [FAILED]
> AVX2:
> hevc_add_res_32x32_8_avx2 (hevc_add_res.c:69)
>   - hevc_add_res.add_residual [FAILED]
> checkasm: 8 of 14 tests have failed
> 
> Signed-off-by: Xu Guangxin 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: test 2x cases to make sure enough random residuals
> are tested.
> 
>  tests/checkasm/hevc_add_res.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tests/checkasm/hevc_add_res.c b/tests/checkasm/hevc_add_res.c
> index e92c6b4..8c82ac1 100644
> --- a/tests/checkasm/hevc_add_res.c
> +++ b/tests/checkasm/hevc_add_res.c
> @@ -58,6 +58,7 @@ static void check_add_res(HEVCDSPContext h, int bit_depth)
>  
>  randomize_buffers(res0, size);
>  randomize_buffers2(dst0, size);
> +res0[0] = 0x8000;// overflow test
>  memcpy(res1, res0, sizeof(*res0) * size);
>  memcpy(dst1, dst0, sizeof(int16_t) * size);
>  
> @@ -80,6 +81,7 @@ void checkasm_check_hevc_add_res(void)
>  
>  ff_hevc_dsp_init(&h, bit_depth);
>  check_add_res(h, bit_depth);
> +check_add_res(h, bit_depth);

Maybe iam mis-reading this diff but doesnt this run the same test
twice instead of running it once with the frist elemet locked to 0x8000 and
once freely floating ?

thx

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

There will always be a question for which you do not know the correct answer.


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 v3 1/2] avcodec: add decoder for High Voltage Software's ALP ADPCM

2020-03-08 Thread Michael Niedermayer
On Sun, Mar 08, 2020 at 03:32:25PM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
-- 
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 v3 2/2] avformat: add demuxer for LEGO Racers' ALP format

2020-03-08 Thread Michael Niedermayer
On Sun, Mar 08, 2020 at 03:31:48PM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

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

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


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

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

Re: [FFmpeg-devel] [PATCH v3 2/2] avformat: add demuxer for LEGO Racers' ALP format

2020-03-08 Thread Carl Eugen Hoyos
Am So., 8. März 2020 um 13:09 Uhr schrieb Zane van Iperen
:

> +static int alp_probe(const AVProbeData *p)
> +{
> +uint32_t i;
> +
> +if (AV_RL32(p->buf) != ALP_TAG)
> +return 0;
> +
> +/* Only allowed header sizes are 8 and 12. */
> +i = AV_RL32(p->buf + 4);
> +if (i != 8 && i != 12)
> +return 0;
> +
> +if (strncmp("ADPCM", p->buf + 8, 6) != 0)
> +return 0;
> +
> +return AVPROBE_SCORE_EXTENSION + 1;

Should be MAX or MAX-1

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

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

[FFmpeg-devel] [PATCH] avcodec/decode: remove unused AVCodecInternal compat_decode field

2020-03-08 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/decode.c   | 1 -
 libavcodec/internal.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 03b9da25f9..0e3d7e17e4 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -826,7 +826,6 @@ static int compat_decode(AVCodecContext *avctx, AVFrame 
*frame,
 }
 
 *got_frame = 0;
-avci->compat_decode = 1;
 
 if (avci->compat_decode_partial_size > 0 &&
 avci->compat_decode_partial_size != pkt->size) {
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index bccd9222d4..972e93bcfa 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -208,7 +208,6 @@ typedef struct AVCodecInternal {
 AVFrame *buffer_frame;
 int draining_done;
 /* set to 1 when the caller is using the old decoding API */
-int compat_decode;
 int compat_decode_warned;
 /* this variable is set by the decoder internals to signal to the old
  * API compat wrappers the amount of data consumed from the last packet */
-- 
2.25.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, v2 4/4] tests/checkasm: add overflow test for hevc_add_res

2020-03-08 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Monday, March 9, 2020 06:16
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 4/4] tests/checkasm: add overflow
> test for hevc_add_res
> 
> On Thu, Mar 05, 2020 at 03:48:28PM +0800, Linjie Fu wrote:
> > Add overflow test for hevc_add_res when int16_t coeff = -32768,
> > and doubled the test cases.
> >
> > The result of C is good, while ASM is not.
> >
> > To verify:
> > make fate-checkasm-hevc_add_res
> > ffmpeg/tests/checkasm/checkasm --test=hevc_add_res
> >
> > ./checkasm --test=hevc_add_res
> > checkasm: using random seed 679391863
> > MMXEXT:
> > hevc_add_res_4x4_8_mmxext (hevc_add_res.c:69)
> >   - hevc_add_res.add_residual [FAILED]
> > SSE2:
> > hevc_add_res_8x8_8_sse2 (hevc_add_res.c:69)
> > hevc_add_res_16x16_8_sse2 (hevc_add_res.c:69)
> > hevc_add_res_32x32_8_sse2 (hevc_add_res.c:69)
> >   - hevc_add_res.add_residual [FAILED]
> > AVX:
> > hevc_add_res_8x8_8_avx (hevc_add_res.c:69)
> > hevc_add_res_16x16_8_avx (hevc_add_res.c:69)
> > hevc_add_res_32x32_8_avx (hevc_add_res.c:69)
> >   - hevc_add_res.add_residual [FAILED]
> > AVX2:
> > hevc_add_res_32x32_8_avx2 (hevc_add_res.c:69)
> >   - hevc_add_res.add_residual [FAILED]
> > checkasm: 8 of 14 tests have failed
> >
> > Signed-off-by: Xu Guangxin 
> > Signed-off-by: Linjie Fu 
> > ---
> > [v2]: test 2x cases to make sure enough random residuals
> > are tested.
> >
> >  tests/checkasm/hevc_add_res.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tests/checkasm/hevc_add_res.c
> b/tests/checkasm/hevc_add_res.c
> > index e92c6b4..8c82ac1 100644
> > --- a/tests/checkasm/hevc_add_res.c
> > +++ b/tests/checkasm/hevc_add_res.c
> > @@ -58,6 +58,7 @@ static void check_add_res(HEVCDSPContext h, int
> bit_depth)
> >
> >  randomize_buffers(res0, size);
> >  randomize_buffers2(dst0, size);
> > +res0[0] = 0x8000;// overflow test
> >  memcpy(res1, res0, sizeof(*res0) * size);
> >  memcpy(dst1, dst0, sizeof(int16_t) * size);
> >
> > @@ -80,6 +81,7 @@ void checkasm_check_hevc_add_res(void)
> >
> >  ff_hevc_dsp_init(&h, bit_depth);
> >  check_add_res(h, bit_depth);
> > +check_add_res(h, bit_depth);
> 
> Maybe iam mis-reading this diff but doesnt this run the same test
> twice instead of running it once with the frist elemet locked to 0x8000 and
> once freely floating ?
> 

Running twice seems to be enough for the randomness even if it's the smallest
block size (1/30 difference for 4x4 blocks).

Current patch to simply run twice:
0x8000 +  (size x size - 1) random residual; // 15 random residuals for 4x4
0x8000 +  (size x size - 1) random residual; // 15 random residuals for 4x4

If modify to lock only one time:
size x size  random residual; // 16 random residuals for 4x4
0x8000 +  (size x size - 1) random residual; // 15 random residuals for 4x4


However as you've pointed out, this introduced misunderstandings and may be
treated as redundant code someday.

It would be better to be treated more explicitly as you've suggested.
Will update, thx.

- Linjie




___
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] dashenc: more accurate time values in playlist.mpd

2020-03-08 Thread Jeyapal, Karthick

On 3/5/20 9:02 PM, Alfred E. Heggestad wrote:
>
>
> On 05/03/2020 15:37, Carl Eugen Hoyos wrote:
>> Am Do., 5. März 2020 um 11:08 Uhr schrieb Alfred E. Heggestad
>> :
>>
>>> -int64_t update_period = c->last_duration / AV_TIME_BASE;
>>> +double update_period = (double)c->last_duration / AV_TIME_BASE; 
>>
>> Can't you instead do int64 update_period = last_duration * 1000 / 
>> AV_TIME_BASE
>> to avoid using doubles that will potentially break automatic testing?
>>
>
> in this case the update_period will be in [milliseconds] units.
> how should I print that ?
I guess in any case a . will be present that can break any automatic testing.
I would suggest having this feature of printing double(.3f) under an option 
with default as false.
In that way there anyone relying on the current behavior is not affected.
>
>
> or we can use write_time() to print it, in AV_TIME_BASE units:
>
>
> int64_t update_period = c->last_duration;
>
> avio_printf(out, "\tminimumUpdatePeriod=\"");
> write_time(out, update_period);
> avio_printf(out, "\"\n");
>
>
>
>
>
> /alfred
> ___
> 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/2] avcodec/cbs_h2645: Avoid more cases of 0 size slices

2020-03-08 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: Assertion failure
> Fixes: 
> 19629/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5676822528524288
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/cbs_h2645.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index c8347ba5fa..7427eefa30 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -870,7 +870,8 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext 
> *ctx,
> "from slice data.\n", z);
>  len -= z;
>  }
> -
> +if (len <= pos / 8)
> +return AVERROR_INVALIDDATA;
>  slice->data_size = len - pos / 8;
>  slice->data_ref  = av_buffer_ref(unit->data_ref);
>  if (!slice->data_ref)
> @@ -1052,7 +1053,8 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
> *ctx,
> "from slice data.\n", z);
>  len -= z;
>  }
> -
> +if (len <= pos / 8)
> +return AVERROR_INVALIDDATA;
>  slice->data_size = len - pos / 8;
>  slice->data_ref  = av_buffer_ref(unit->data_ref);
>  if (!slice->data_ref)
> 

Imagine you have CAVLC encoded H.264 where there is nothing after the
header except zero bits and where the slice header is not
byte-aligned. Then av_assert0(temp) in cbs_h2645_write_slice_data()
will be triggered both now as well as with your patch, because your
check is too crude.

I have already sent a patch [2] for this. It presupposes [1].

- Andreas

[1]:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20191209222604.28920-5-andreas.rheinha...@gmail.com/
[2]:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20191209222604.28920-6-andreas.rheinha...@gmail.com/
___
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".