Re: [FFmpeg-devel] [PATCH 2/3] libavformat/hls: add support for decryption of HLS streams in MPEG-TS format protected using SAMPLE-AES encryption

2021-02-28 Thread Steven Liu


> 2021年3月1日 下午3:22,Nachiket Tarate  写道:
> 
> On Mon, Mar 1, 2021 at 11:30 AM Steven Liu  wrote:
>> 
>> 
>> 
>>> 2021年3月1日 下午12:55,Nachiket Tarate  写道:
>>> 
>>> This is an updated version of the patch in which I have added the check. If
>>> the segments are in Fragmented MP4 format, HLS demuxer quits by giving an
>>> error message:
>>> 
>>> "SAMPLE-AES encryption is not supported for fragmented MP4 format yet”
>> I don’t think  is a good resolution for SAMPLE-AES encryption and decryption.
>> You should support that if you want support SAMPLE-AES in hls,
>> because SAMPLE-AES not only support in MPEG-TS, but also support fragment 
>> mp4.
>> Whatever, if you only support mpegts en[de]cryption, it should be a half 
>> part patch.
> 
> Two completely different technologies/specifications have been used
> for SAMPLE-AES encryption of HLS streams in MPEG-TS and fragmented MP4
> formats.
> 
> Fragmented MP4 media segments are encrypted using the 'cbcs' scheme of
> Common Encryption [CENC]:
> 
> https://www.iso.org/standard/68042.html
> 
> Encryption of other media segment formats such as MPEG-TS or external
> audio tracks containing H.264, AAC, AC-3 and Enhanced AC-3 media
> streams is described in the Apple's HTTP Live Streaming (HLS) Sample
> Encryption specifications:
> 
> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
> 
> This patch implements the later specifications and enables decryption
> of media segments in MPEG-TS, AAC, AC-3 and Enhanced AC-3 formats. So
> I think we should merge this patch right now.

I think sample ads should support not only mpegts, but also support fmp4 too.
Reference rfc8216 context:
 An encryption method of SAMPLE-AES means that the Media Segments
 contain media samples, such as audio or video, that are encrypted
 using the Advanced Encryption Standard [AES_128].  How these media
 streams are encrypted and encapsulated in a segment depends on the
 media encoding and the media format of the segment.  fMP4 Media
 Segments are encrypted using the 'cbcs' scheme of Common
 Encryption [COMMON_ENC].  Encryption of other Media Segment
 formats containing H.264 [H_264], AAC [ISO_14496], AC-3 [AC_3],
 and Enhanced AC-3 [AC_3] media streams is described in the HTTP
 Live Streaming (HLS) Sample Encryption specification [SampleEnc].
 The IV attribute MAY be present; see Section 5.2.

And I saw the m3u8 context, the METHOD is SAMPLE-AES.

(base) liuqi05:ufbuild liuqi$ head -n10  prog_index.m3u8
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:7
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS

Focus on this line.
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="http://127.0.0.1/keyOnly.bin",IV=0xcece273e2737a58ca785e257eb080482


#EXT-X-MAP:URI="fileSequence0.mp4"
#EXTINF:8.31667,
#EXT-X-BITRATE:7064


You can point me the part if I misunderstood SAMPLE-AES.

> 
> In future, we will add support for CENC or see how can we use existing
> things from MOV demuxer.
> 
> Best Regards,
> Nachiket Tarate
> 
>>> 
>>> Best Regards,
>>> Nachiket Tarate
>>> 
>>> On Mon, Mar 1, 2021 at 10:13 AM Steven Liu  wrote:
>>> 
 
 
> 2021年3月1日 下午12:35,Nachiket Tarate  写道:
> 
> @Steven Liu 
> 
> Can we merge this patch ?
 I’m waiting update patch for fragment mp4 encryption.
 After new version of the patchset I will test and review.
> 
> Best Regards,
> Nachiket Tarate
> 
> On Wed, Feb 24, 2021 at 4:44 PM Nachiket Tarate <
> nachiket.program...@gmail.com> wrote:
> 
>> Apple HTTP Live Streaming Sample Encryption:
>> 
>> 
>> 
 https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
>> 
>> Signed-off-by: Nachiket Tarate 
>> ---
>> libavformat/Makefile |   2 +-
>> libavformat/hls.c| 105 --
>> libavformat/hls_sample_aes.c | 391 +++
>> libavformat/hls_sample_aes.h |  66 ++
>> libavformat/mpegts.c |  12 ++
>> 5 files changed, 562 insertions(+), 14 deletions(-)
>> create mode 100644 libavformat/hls_sample_aes.c
>> create mode 100644 libavformat/hls_sample_aes.h
>> 
>> diff --git a/libavformat/Makefile b/libavformat/Makefile
>> index fcb39ce133..62627d50a6 100644
>> --- a/libavformat/Makefile
>> +++ b/libavformat/Makefile
>> @@ -236,7 +236,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o
>> pcm.o
>> OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
>> OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
>> OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
>> -OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
>> +OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_aes.o
>> OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
>> OBJS-$(CONFIG_HNM_DEMUXER)   += 

Re: [FFmpeg-devel] [PATCH v2 1/2] lavf/network: add wait fd callback to ff_network_wait_fd_timeout

2021-02-28 Thread zhilizhao(赵志立)
Ping.

> On Feb 8, 2021, at 11:04 AM, Zhao Zhili  wrote:
> 
> ---
> libavformat/libamqp.c |  4 ++--
> libavformat/network.c | 16 ++--
> libavformat/network.h | 14 +-
> libavformat/tcp.c |  6 --
> 4 files changed, 33 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/libamqp.c b/libavformat/libamqp.c
> index c3b9c484ea..ca7d3ab70f 100644
> --- a/libavformat/libamqp.c
> +++ b/libavformat/libamqp.c
> @@ -241,7 +241,7 @@ static int amqp_proto_write(URLContext *h, const unsigned 
> char *buf, int size)
> amqp_bytes_t message = { size, (void *)buf };
> amqp_basic_properties_t props;
> 
> -ret = ff_network_wait_fd_timeout(fd, 1, h->rw_timeout, 
> >interrupt_callback);
> +ret = ff_network_wait_fd_timeout(fd, 1, h->rw_timeout, 
> >interrupt_callback, NULL);
> if (ret)
> return ret;
> 
> @@ -270,7 +270,7 @@ static int amqp_proto_read(URLContext *h, unsigned char 
> *buf, int size)
> amqp_rpc_reply_t broker_reply;
> amqp_envelope_t envelope;
> 
> -ret = ff_network_wait_fd_timeout(fd, 0, h->rw_timeout, 
> >interrupt_callback);
> +ret = ff_network_wait_fd_timeout(fd, 0, h->rw_timeout, 
> >interrupt_callback, NULL);
> if (ret)
> return ret;
> 
> diff --git a/libavformat/network.c b/libavformat/network.c
> index 0f5a575f77..48a9af012e 100644
> --- a/libavformat/network.c
> +++ b/libavformat/network.c
> @@ -75,15 +75,27 @@ int ff_network_wait_fd(int fd, int write)
> return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 
> : AVERROR(EAGAIN);
> }
> 
> -int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, 
> AVIOInterruptCB *int_cb)
> +static int network_wait_fd_callback(int fd, int write, void *opaque) {
> +return ff_network_wait_fd(fd, write);
> +}
> +
> +int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout,
> +AVIOInterruptCB *int_cb, const NetworkWaitFdCB *wait_cb)
> {
> int ret;
> int64_t wait_start = 0;
> 
> +const static NetworkWaitFdCB wait_cb_internal = {
> +.wait_fd = network_wait_fd_callback,
> +};
> +
> +if (!wait_cb)
> +wait_cb = _cb_internal;
> +
> while (1) {
> if (ff_check_interrupt(int_cb))
> return AVERROR_EXIT;
> -ret = ff_network_wait_fd(fd, write);
> +ret = ff_network_wait_fd_cb(wait_cb, fd, write);
> if (ret != AVERROR(EAGAIN))
> return ret;
> if (timeout > 0) {
> diff --git a/libavformat/network.h b/libavformat/network.h
> index 71347e815b..1a02a6d9ee 100644
> --- a/libavformat/network.h
> +++ b/libavformat/network.h
> @@ -84,6 +84,16 @@ void ff_network_close(void);
> int ff_tls_init(void);
> void ff_tls_deinit(void);
> 
> +typedef struct NetworkWaitFdCB {
> +int (*wait_fd)(int /*fd*/, int /*write*/, void* /*opaque*/);
> +void *opaque;
> +} NetworkWaitFdCB;
> +
> +static av_always_inline int ff_network_wait_fd_cb(const NetworkWaitFdCB *cb,
> +int fd, int write) {
> +return cb->wait_fd(fd, write, cb->opaque);
> +}
> +
> int ff_network_wait_fd(int fd, int write);
> 
> /**
> @@ -94,9 +104,11 @@ int ff_network_wait_fd(int fd, int write);
>  * @param write Set 1 to wait for socket able to be read, 0 to be written
>  * @param timeout Timeout interval, in microseconds. Actual precision is 
> 10 mcs, due to ff_network_wait_fd usage
>  * @param int_cb Interrupt callback, is checked before each 
> ff_network_wait_fd call
> + * @param wait_cb Wait callback, default implementation is used if NULL
>  * @return 0 if data can be read/written, AVERROR(ETIMEDOUT) if timeout 
> expired, or negative error code
>  */
> -int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, 
> AVIOInterruptCB *int_cb);
> +int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout,
> +AVIOInterruptCB *int_cb, const NetworkWaitFdCB *wait_cb);
> 
> /**
>  * Waits for up to 'timeout' microseconds. If the usert's int_cb is set and
> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
> index 2198e0f00e..437eaecbb4 100644
> --- a/libavformat/tcp.c
> +++ b/libavformat/tcp.c
> @@ -237,7 +237,8 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
> int ret;
> 
> if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
> -ret = ff_network_wait_fd_timeout(s->fd, 0, h->rw_timeout, 
> >interrupt_callback);
> +ret = ff_network_wait_fd_timeout(s->fd, 0, h->rw_timeout,
> +>interrupt_callback, NULL);
> if (ret)
> return ret;
> }
> @@ -253,7 +254,8 @@ static int tcp_write(URLContext *h, const uint8_t *buf, 
> int size)
> int ret;
> 
> if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
> -ret = ff_network_wait_fd_timeout(s->fd, 1, h->rw_timeout, 
> >interrupt_callback);
> +ret = ff_network_wait_fd_timeout(s->fd, 1, h->rw_timeout,
> +>interrupt_callback, NULL);
> if (ret)
> return ret;
> }
> -- 
> 2.28.0
> 
> 

Re: [FFmpeg-devel] [PATCH 2/3] libavformat/hls: add support for decryption of HLS streams in MPEG-TS format protected using SAMPLE-AES encryption

2021-02-28 Thread Steven Liu


> 2021年3月1日 下午12:55,Nachiket Tarate  写道:
> 
> This is an updated version of the patch in which I have added the check. If
> the segments are in Fragmented MP4 format, HLS demuxer quits by giving an
> error message:
> 
> "SAMPLE-AES encryption is not supported for fragmented MP4 format yet”
I don’t think  is a good resolution for SAMPLE-AES encryption and decryption.
You should support that if you want support SAMPLE-AES in hls,
because SAMPLE-AES not only support in MPEG-TS, but also support fragment mp4.
Whatever, if you only support mpegts en[de]cryption, it should be a half part 
patch.

> 
> Best Regards,
> Nachiket Tarate
> 
> On Mon, Mar 1, 2021 at 10:13 AM Steven Liu  wrote:
> 
>> 
>> 
>>> 2021年3月1日 下午12:35,Nachiket Tarate  写道:
>>> 
>>> @Steven Liu 
>>> 
>>> Can we merge this patch ?
>> I’m waiting update patch for fragment mp4 encryption.
>> After new version of the patchset I will test and review.
>>> 
>>> Best Regards,
>>> Nachiket Tarate
>>> 
>>> On Wed, Feb 24, 2021 at 4:44 PM Nachiket Tarate <
>>> nachiket.program...@gmail.com> wrote:
>>> 
 Apple HTTP Live Streaming Sample Encryption:
 
 
 
>> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
 
 Signed-off-by: Nachiket Tarate 
 ---
 libavformat/Makefile |   2 +-
 libavformat/hls.c| 105 --
 libavformat/hls_sample_aes.c | 391 +++
 libavformat/hls_sample_aes.h |  66 ++
 libavformat/mpegts.c |  12 ++
 5 files changed, 562 insertions(+), 14 deletions(-)
 create mode 100644 libavformat/hls_sample_aes.c
 create mode 100644 libavformat/hls_sample_aes.h
 
 diff --git a/libavformat/Makefile b/libavformat/Makefile
 index fcb39ce133..62627d50a6 100644
 --- a/libavformat/Makefile
 +++ b/libavformat/Makefile
 @@ -236,7 +236,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o
 pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
 -OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
 +OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_aes.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
 OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
 diff --git a/libavformat/hls.c b/libavformat/hls.c
 index af2468ad9b..3cb3853c79 100644
 --- a/libavformat/hls.c
 +++ b/libavformat/hls.c
 @@ -2,6 +2,7 @@
 * Apple HTTP Live Streaming demuxer
 * Copyright (c) 2010 Martin Storsjo
 * Copyright (c) 2013 Anssi Hannula
 + * Copyright (c) 2021 Nachiket Tarate
 *
 * This file is part of FFmpeg.
 *
 @@ -39,6 +40,8 @@
 #include "avio_internal.h"
 #include "id3v2.h"
 
 +#include "hls_sample_aes.h"
 +
 #define INITIAL_BUFFER_SIZE 32768
 
 #define MAX_FIELD_LEN 64
 @@ -145,6 +148,10 @@ struct playlist {
int id3_changed; /* ID3 tag data has changed at some point */
ID3v2ExtraMeta *id3_deferred_extra; /* stored here until subdemuxer
 is opened */
 
 +/* Used in case of SAMPLE-AES encryption method */
 +HLSAudioSetupInfo audio_setup_info;
 +HLSCryptoContext  crypto_ctx;
 +
int64_t seek_timestamp;
int seek_flags;
int seek_stream_index; /* into subdemuxer stream array */
 @@ -266,6 +273,8 @@ static void free_playlist_list(HLSContext *c)
pls->ctx->pb = NULL;
avformat_close_input(>ctx);
}
 +if (pls->crypto_ctx.aes_ctx)
 + av_free(pls->crypto_ctx.aes_ctx);
av_free(pls);
}
av_freep(>playlists);
 @@ -994,7 +1003,10 @@ fail:
 
 static struct segment *current_segment(struct playlist *pls)
 {
 -return pls->segments[pls->cur_seq_no - pls->start_seq_no];
 +int64_t n = pls->cur_seq_no - pls->start_seq_no;
 +if (n >= pls->n_segments)
 +return NULL;
 +return pls->segments[n];
 }
 
 static struct segment *next_segment(struct playlist *pls)
 @@ -1023,10 +1035,11 @@ static int read_from_url(struct playlist *pls,
 struct segment *seg,
 
 /* Parse the raw ID3 data and pass contents to caller */
 static void parse_id3(AVFormatContext *s, AVIOContext *pb,
 -  AVDictionary **metadata, int64_t *dts,
 +  AVDictionary **metadata, int64_t *dts,
 HLSAudioSetupInfo *audio_setup_info,
  ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta
 **extra_meta)
 {
static const char id3_priv_owner_ts[] =
 "com.apple.streaming.transportStreamTimestamp";
 +static const char id3_priv_owner_audio_setup[] =
 

Re: [FFmpeg-devel] [PATCH 2/3] libavformat/hls: add support for decryption of HLS streams in MPEG-TS format protected using SAMPLE-AES encryption

2021-02-28 Thread Nachiket Tarate
This is an updated version of the patch in which I have added the check. If
the segments are in Fragmented MP4 format, HLS demuxer quits by giving an
error message:

"SAMPLE-AES encryption is not supported for fragmented MP4 format yet"

Best Regards,
Nachiket Tarate

On Mon, Mar 1, 2021 at 10:13 AM Steven Liu  wrote:

>
>
> > 2021年3月1日 下午12:35,Nachiket Tarate  写道:
> >
> > @Steven Liu 
> >
> > Can we merge this patch ?
> I’m waiting update patch for fragment mp4 encryption.
> After new version of the patchset I will test and review.
> >
> > Best Regards,
> > Nachiket Tarate
> >
> > On Wed, Feb 24, 2021 at 4:44 PM Nachiket Tarate <
> > nachiket.program...@gmail.com> wrote:
> >
> >> Apple HTTP Live Streaming Sample Encryption:
> >>
> >>
> >>
> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
> >>
> >> Signed-off-by: Nachiket Tarate 
> >> ---
> >> libavformat/Makefile |   2 +-
> >> libavformat/hls.c| 105 --
> >> libavformat/hls_sample_aes.c | 391 +++
> >> libavformat/hls_sample_aes.h |  66 ++
> >> libavformat/mpegts.c |  12 ++
> >> 5 files changed, 562 insertions(+), 14 deletions(-)
> >> create mode 100644 libavformat/hls_sample_aes.c
> >> create mode 100644 libavformat/hls_sample_aes.h
> >>
> >> diff --git a/libavformat/Makefile b/libavformat/Makefile
> >> index fcb39ce133..62627d50a6 100644
> >> --- a/libavformat/Makefile
> >> +++ b/libavformat/Makefile
> >> @@ -236,7 +236,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o
> >> pcm.o
> >> OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
> >> OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
> >> OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
> >> -OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
> >> +OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_aes.o
> >> OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
> >> OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
> >> OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
> >> diff --git a/libavformat/hls.c b/libavformat/hls.c
> >> index af2468ad9b..3cb3853c79 100644
> >> --- a/libavformat/hls.c
> >> +++ b/libavformat/hls.c
> >> @@ -2,6 +2,7 @@
> >>  * Apple HTTP Live Streaming demuxer
> >>  * Copyright (c) 2010 Martin Storsjo
> >>  * Copyright (c) 2013 Anssi Hannula
> >> + * Copyright (c) 2021 Nachiket Tarate
> >>  *
> >>  * This file is part of FFmpeg.
> >>  *
> >> @@ -39,6 +40,8 @@
> >> #include "avio_internal.h"
> >> #include "id3v2.h"
> >>
> >> +#include "hls_sample_aes.h"
> >> +
> >> #define INITIAL_BUFFER_SIZE 32768
> >>
> >> #define MAX_FIELD_LEN 64
> >> @@ -145,6 +148,10 @@ struct playlist {
> >> int id3_changed; /* ID3 tag data has changed at some point */
> >> ID3v2ExtraMeta *id3_deferred_extra; /* stored here until subdemuxer
> >> is opened */
> >>
> >> +/* Used in case of SAMPLE-AES encryption method */
> >> +HLSAudioSetupInfo audio_setup_info;
> >> +HLSCryptoContext  crypto_ctx;
> >> +
> >> int64_t seek_timestamp;
> >> int seek_flags;
> >> int seek_stream_index; /* into subdemuxer stream array */
> >> @@ -266,6 +273,8 @@ static void free_playlist_list(HLSContext *c)
> >> pls->ctx->pb = NULL;
> >> avformat_close_input(>ctx);
> >> }
> >> +if (pls->crypto_ctx.aes_ctx)
> >> + av_free(pls->crypto_ctx.aes_ctx);
> >> av_free(pls);
> >> }
> >> av_freep(>playlists);
> >> @@ -994,7 +1003,10 @@ fail:
> >>
> >> static struct segment *current_segment(struct playlist *pls)
> >> {
> >> -return pls->segments[pls->cur_seq_no - pls->start_seq_no];
> >> +int64_t n = pls->cur_seq_no - pls->start_seq_no;
> >> +if (n >= pls->n_segments)
> >> +return NULL;
> >> +return pls->segments[n];
> >> }
> >>
> >> static struct segment *next_segment(struct playlist *pls)
> >> @@ -1023,10 +1035,11 @@ static int read_from_url(struct playlist *pls,
> >> struct segment *seg,
> >>
> >> /* Parse the raw ID3 data and pass contents to caller */
> >> static void parse_id3(AVFormatContext *s, AVIOContext *pb,
> >> -  AVDictionary **metadata, int64_t *dts,
> >> +  AVDictionary **metadata, int64_t *dts,
> >> HLSAudioSetupInfo *audio_setup_info,
> >>   ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta
> >> **extra_meta)
> >> {
> >> static const char id3_priv_owner_ts[] =
> >> "com.apple.streaming.transportStreamTimestamp";
> >> +static const char id3_priv_owner_audio_setup[] =
> >> "com.apple.streaming.audioDescription";
> >> ID3v2ExtraMeta *meta;
> >>
> >> ff_id3v2_read_dict(pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta);
> >> @@ -1041,6 +1054,8 @@ static void parse_id3(AVFormatContext *s,
> >> AVIOContext *pb,
> >> *dts = ts;
> >> else
> >> av_log(s, AV_LOG_ERROR, "Invalid HLS ID3 audio
> >> timestamp 

Re: [FFmpeg-devel] [PATCH V3 3/3] libavfilter: add filter dnn_detect for object detection

2021-02-28 Thread Andreas Rheinhardt
Guo, Yejun:
> Below are the example steps to do object detection:
> 
> 1. download and install l_openvino_toolkit_p_2021.1.110.tgz from
> https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/download.html
>   or, we can get source code (tag 2021.1), build and install.
> 2. export LD_LIBRARY_PATH with openvino settings, for example:
> .../deployment_tools/inference_engine/lib/intel64/:.../deployment_tools/inference_engine/external/tbb/lib/
> 3. rebuild ffmpeg from source code with configure option:
> --enable-libopenvino
> --extra-cflags='-I.../deployment_tools/inference_engine/include/'
> --extra-ldflags='-L.../deployment_tools/inference_engine/lib/intel64'
> 4. download model files and test image
> wget 
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.bin
> wget 
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.xml
> wget
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.label
> wget https://github.com/guoyejun/ffmpeg_dnn/raw/main/images/cici.jpg
> 5. run ffmpeg with:
> ./ffmpeg -i cici.jpg -vf 
> dnn_detect=dnn_backend=openvino:model=face-detection-adas-0001.xml:input=data:output=detection_out:confidence=0.6:labels=face-detection-adas-0001.label
>  -f null -
> 
> We'll see the detect result as below:
> [Parsed_dnn_detect_0 @ 0x56226644e540] frame->private_ref (bounding boxes):
> [Parsed_dnn_detect_0 @ 0x56226644e540] source: face-detection-adas-0001.xml
> [Parsed_dnn_detect_0 @ 0x56226644e540] index: 0, region: (1005, 813) -> 
> (1086, 905), label: face, confidence: 1/1.
> [Parsed_dnn_detect_0 @ 0x56226644e540] index: 1, region: (888, 839) -> (967, 
> 926), label: face, confidence: 6917/1.
> 
> There are two faces detected with confidence 100% and 69.17%.
> 
> Signed-off-by: Guo, Yejun 
> ---
>  configure  |   1 +
>  doc/filters.texi   |  40 +++
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/dnn/dnn_backend_openvino.c |  12 +
>  libavfilter/dnn_filter_common.c|   7 +
>  libavfilter/dnn_filter_common.h|   1 +
>  libavfilter/dnn_interface.h|   6 +-
>  libavfilter/vf_dnn_detect.c| 462 +
>  9 files changed, 529 insertions(+), 2 deletions(-)
>  create mode 100644 libavfilter/vf_dnn_detect.c
> 
> diff --git a/configure b/configure
> index 336301cb40..cdac292c2f 100755
> --- a/configure
> +++ b/configure
> @@ -3549,6 +3549,7 @@ derain_filter_select="dnn"
>  deshake_filter_select="pixelutils"
>  deshake_opencl_filter_deps="opencl"
>  dilation_opencl_filter_deps="opencl"
> +dnn_detect_filter_select="dnn"
>  dnn_processing_filter_select="dnn"
>  drawtext_filter_deps="libfreetype"
>  drawtext_filter_suggest="libfontconfig libfribidi"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 426cb158da..55368c6f1b 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -10133,6 +10133,46 @@ ffmpeg -i INPUT -f lavfi -i 
> nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2
>  @end example
>  @end itemize
>  
> +@section dnn_detect
> +
> +Do object detection with deep neural networks.
> +
> +The filter accepts the following options:
> +
> +@table @option
> +@item dnn_backend
> +Specify which DNN backend to use for model loading and execution. This 
> option accepts
> +only openvino now, tensorflow backends will be added.
> +
> +@item model
> +Set path to model file specifying network architecture and its parameters.
> +Note that different backends use different file formats.
> +
> +@item input
> +Set the input name of the dnn network.
> +
> +@item output
> +Set the output name of the dnn network.
> +
> +@item confidence
> +Set the confidence threshold (default: 0.5).
> +
> +@item labels
> +Set path to label file specifying the mapping between label id and name.
> +Each label name is written in one line, tailing spaces and empty lines are 
> skipped.
> +The first line is the name of label id 0 (usually it is 'background'),
> +and the second line is the name of label id 1, etc.
> +The label id is considered as name if the label file is not provided.
> +
> +@item backend_configs
> +Set the configs to be passed into backend
> +
> +@item async
> +use DNN async execution if set (default: set),
> +roll back to sync execution if the backend does not support async.
> +
> +@end table
> +
>  @anchor{dnn_processing}
>  @section dnn_processing
>  
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 359ea7f903..b14c0ecdb9 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -245,6 +245,7 @@ OBJS-$(CONFIG_DILATION_FILTER)   += 
> vf_neighbor.o
>  OBJS-$(CONFIG_DILATION_OPENCL_FILTER)+= vf_neighbor_opencl.o 
> opencl.o \
>  opencl/neighbor.o
>  

Re: [FFmpeg-devel] [PATCH 2/3] libavformat/hls: add support for decryption of HLS streams in MPEG-TS format protected using SAMPLE-AES encryption

2021-02-28 Thread Steven Liu


> 2021年3月1日 下午12:35,Nachiket Tarate  写道:
> 
> @Steven Liu 
> 
> Can we merge this patch ?
I’m waiting update patch for fragment mp4 encryption.
After new version of the patchset I will test and review.
> 
> Best Regards,
> Nachiket Tarate
> 
> On Wed, Feb 24, 2021 at 4:44 PM Nachiket Tarate <
> nachiket.program...@gmail.com> wrote:
> 
>> Apple HTTP Live Streaming Sample Encryption:
>> 
>> 
>> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
>> 
>> Signed-off-by: Nachiket Tarate 
>> ---
>> libavformat/Makefile |   2 +-
>> libavformat/hls.c| 105 --
>> libavformat/hls_sample_aes.c | 391 +++
>> libavformat/hls_sample_aes.h |  66 ++
>> libavformat/mpegts.c |  12 ++
>> 5 files changed, 562 insertions(+), 14 deletions(-)
>> create mode 100644 libavformat/hls_sample_aes.c
>> create mode 100644 libavformat/hls_sample_aes.h
>> 
>> diff --git a/libavformat/Makefile b/libavformat/Makefile
>> index fcb39ce133..62627d50a6 100644
>> --- a/libavformat/Makefile
>> +++ b/libavformat/Makefile
>> @@ -236,7 +236,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o
>> pcm.o
>> OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
>> OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
>> OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
>> -OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
>> +OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_aes.o
>> OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
>> OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
>> OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
>> diff --git a/libavformat/hls.c b/libavformat/hls.c
>> index af2468ad9b..3cb3853c79 100644
>> --- a/libavformat/hls.c
>> +++ b/libavformat/hls.c
>> @@ -2,6 +2,7 @@
>>  * Apple HTTP Live Streaming demuxer
>>  * Copyright (c) 2010 Martin Storsjo
>>  * Copyright (c) 2013 Anssi Hannula
>> + * Copyright (c) 2021 Nachiket Tarate
>>  *
>>  * This file is part of FFmpeg.
>>  *
>> @@ -39,6 +40,8 @@
>> #include "avio_internal.h"
>> #include "id3v2.h"
>> 
>> +#include "hls_sample_aes.h"
>> +
>> #define INITIAL_BUFFER_SIZE 32768
>> 
>> #define MAX_FIELD_LEN 64
>> @@ -145,6 +148,10 @@ struct playlist {
>> int id3_changed; /* ID3 tag data has changed at some point */
>> ID3v2ExtraMeta *id3_deferred_extra; /* stored here until subdemuxer
>> is opened */
>> 
>> +/* Used in case of SAMPLE-AES encryption method */
>> +HLSAudioSetupInfo audio_setup_info;
>> +HLSCryptoContext  crypto_ctx;
>> +
>> int64_t seek_timestamp;
>> int seek_flags;
>> int seek_stream_index; /* into subdemuxer stream array */
>> @@ -266,6 +273,8 @@ static void free_playlist_list(HLSContext *c)
>> pls->ctx->pb = NULL;
>> avformat_close_input(>ctx);
>> }
>> +if (pls->crypto_ctx.aes_ctx)
>> + av_free(pls->crypto_ctx.aes_ctx);
>> av_free(pls);
>> }
>> av_freep(>playlists);
>> @@ -994,7 +1003,10 @@ fail:
>> 
>> static struct segment *current_segment(struct playlist *pls)
>> {
>> -return pls->segments[pls->cur_seq_no - pls->start_seq_no];
>> +int64_t n = pls->cur_seq_no - pls->start_seq_no;
>> +if (n >= pls->n_segments)
>> +return NULL;
>> +return pls->segments[n];
>> }
>> 
>> static struct segment *next_segment(struct playlist *pls)
>> @@ -1023,10 +1035,11 @@ static int read_from_url(struct playlist *pls,
>> struct segment *seg,
>> 
>> /* Parse the raw ID3 data and pass contents to caller */
>> static void parse_id3(AVFormatContext *s, AVIOContext *pb,
>> -  AVDictionary **metadata, int64_t *dts,
>> +  AVDictionary **metadata, int64_t *dts,
>> HLSAudioSetupInfo *audio_setup_info,
>>   ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta
>> **extra_meta)
>> {
>> static const char id3_priv_owner_ts[] =
>> "com.apple.streaming.transportStreamTimestamp";
>> +static const char id3_priv_owner_audio_setup[] =
>> "com.apple.streaming.audioDescription";
>> ID3v2ExtraMeta *meta;
>> 
>> ff_id3v2_read_dict(pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta);
>> @@ -1041,6 +1054,8 @@ static void parse_id3(AVFormatContext *s,
>> AVIOContext *pb,
>> *dts = ts;
>> else
>> av_log(s, AV_LOG_ERROR, "Invalid HLS ID3 audio
>> timestamp %"PRId64"\n", ts);
>> +} else if (priv->datasize >= 8 && !strcmp(priv->owner,
>> id3_priv_owner_audio_setup)) {
>> +ff_hls_read_audio_setup_info(audio_setup_info,
>> priv->data, priv->datasize);
>> }
>> } else if (!strcmp(meta->tag, "APIC") && apic)
>> *apic = >data.apic;
>> @@ -1084,7 +1099,7 @@ static void handle_id3(AVIOContext *pb, struct
>> playlist *pls)
>> ID3v2ExtraMeta *extra_meta = NULL;
>> int64_t timestamp = AV_NOPTS_VALUE;
>> 
>> -parse_id3(pls->ctx, pb, , , , _meta);
>> +

Re: [FFmpeg-devel] [PATCH 2/3] libavformat/hls: add support for decryption of HLS streams in MPEG-TS format protected using SAMPLE-AES encryption

2021-02-28 Thread Nachiket Tarate
@Steven Liu 

Can we merge this patch ?

Best Regards,
Nachiket Tarate

On Wed, Feb 24, 2021 at 4:44 PM Nachiket Tarate <
nachiket.program...@gmail.com> wrote:

> Apple HTTP Live Streaming Sample Encryption:
>
>
> https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
>
> Signed-off-by: Nachiket Tarate 
> ---
>  libavformat/Makefile |   2 +-
>  libavformat/hls.c| 105 --
>  libavformat/hls_sample_aes.c | 391 +++
>  libavformat/hls_sample_aes.h |  66 ++
>  libavformat/mpegts.c |  12 ++
>  5 files changed, 562 insertions(+), 14 deletions(-)
>  create mode 100644 libavformat/hls_sample_aes.c
>  create mode 100644 libavformat/hls_sample_aes.h
>
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index fcb39ce133..62627d50a6 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -236,7 +236,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o
> pcm.o
>  OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
>  OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
>  OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
> -OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o
> +OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_aes.o
>  OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
>  OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
>  OBJS-$(CONFIG_ICO_DEMUXER)   += icodec.o
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index af2468ad9b..3cb3853c79 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -2,6 +2,7 @@
>   * Apple HTTP Live Streaming demuxer
>   * Copyright (c) 2010 Martin Storsjo
>   * Copyright (c) 2013 Anssi Hannula
> + * Copyright (c) 2021 Nachiket Tarate
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -39,6 +40,8 @@
>  #include "avio_internal.h"
>  #include "id3v2.h"
>
> +#include "hls_sample_aes.h"
> +
>  #define INITIAL_BUFFER_SIZE 32768
>
>  #define MAX_FIELD_LEN 64
> @@ -145,6 +148,10 @@ struct playlist {
>  int id3_changed; /* ID3 tag data has changed at some point */
>  ID3v2ExtraMeta *id3_deferred_extra; /* stored here until subdemuxer
> is opened */
>
> +/* Used in case of SAMPLE-AES encryption method */
> +HLSAudioSetupInfo audio_setup_info;
> +HLSCryptoContext  crypto_ctx;
> +
>  int64_t seek_timestamp;
>  int seek_flags;
>  int seek_stream_index; /* into subdemuxer stream array */
> @@ -266,6 +273,8 @@ static void free_playlist_list(HLSContext *c)
>  pls->ctx->pb = NULL;
>  avformat_close_input(>ctx);
>  }
> +if (pls->crypto_ctx.aes_ctx)
> + av_free(pls->crypto_ctx.aes_ctx);
>  av_free(pls);
>  }
>  av_freep(>playlists);
> @@ -994,7 +1003,10 @@ fail:
>
>  static struct segment *current_segment(struct playlist *pls)
>  {
> -return pls->segments[pls->cur_seq_no - pls->start_seq_no];
> +int64_t n = pls->cur_seq_no - pls->start_seq_no;
> +if (n >= pls->n_segments)
> +return NULL;
> +return pls->segments[n];
>  }
>
>  static struct segment *next_segment(struct playlist *pls)
> @@ -1023,10 +1035,11 @@ static int read_from_url(struct playlist *pls,
> struct segment *seg,
>
>  /* Parse the raw ID3 data and pass contents to caller */
>  static void parse_id3(AVFormatContext *s, AVIOContext *pb,
> -  AVDictionary **metadata, int64_t *dts,
> +  AVDictionary **metadata, int64_t *dts,
> HLSAudioSetupInfo *audio_setup_info,
>ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta
> **extra_meta)
>  {
>  static const char id3_priv_owner_ts[] =
> "com.apple.streaming.transportStreamTimestamp";
> +static const char id3_priv_owner_audio_setup[] =
> "com.apple.streaming.audioDescription";
>  ID3v2ExtraMeta *meta;
>
>  ff_id3v2_read_dict(pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta);
> @@ -1041,6 +1054,8 @@ static void parse_id3(AVFormatContext *s,
> AVIOContext *pb,
>  *dts = ts;
>  else
>  av_log(s, AV_LOG_ERROR, "Invalid HLS ID3 audio
> timestamp %"PRId64"\n", ts);
> +} else if (priv->datasize >= 8 && !strcmp(priv->owner,
> id3_priv_owner_audio_setup)) {
> +ff_hls_read_audio_setup_info(audio_setup_info,
> priv->data, priv->datasize);
>  }
>  } else if (!strcmp(meta->tag, "APIC") && apic)
>  *apic = >data.apic;
> @@ -1084,7 +1099,7 @@ static void handle_id3(AVIOContext *pb, struct
> playlist *pls)
>  ID3v2ExtraMeta *extra_meta = NULL;
>  int64_t timestamp = AV_NOPTS_VALUE;
>
> -parse_id3(pls->ctx, pb, , , , _meta);
> +parse_id3(pls->ctx, pb, , ,
> >audio_setup_info, , _meta);
>
>  if (timestamp != AV_NOPTS_VALUE) {
>  pls->id3_mpegts_timestamp = timestamp;
> @@ -1238,10 +1253,7 @@ static int open_input(HLSContext *c, struct
> playlist *pls, struct segment 

Re: [FFmpeg-devel] [PATCH] libavdevice/avfoundation: add buffer fifo and output packets in order they arrive

2021-02-28 Thread Mark Reid
On Sat, Feb 13, 2021 at 10:04 PM  wrote:

> From: Mark Reid 
>
> Hi,
> This patch fixes audio issues I've had with some capture devices. The audio
> gets really choppy and stops working. This seems to be because
> avf_read_packet
> stops outputting the audio frames because a video frame happens to be
> available first.
>
> It base on the approach used in a patch from #4437
> https://trac.ffmpeg.org/ticket/4437
>
> My approach uses an AVFifoBuffer instead of NSMutableArray and also
> outputs the packets in the same order they arrive from AVFFoundation.
>
> should fix ticket #4437 and #4513
>
>
> ---
>  libavdevice/avfoundation.m | 160 -
>  1 file changed, 124 insertions(+), 36 deletions(-)
>
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index 59d5b0af4f..5ac6ec4183 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -31,13 +31,17 @@
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/avstring.h"
> +#include "libavutil/avassert.h"
>  #include "libavformat/internal.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/parseutils.h"
>  #include "libavutil/time.h"
>  #include "libavutil/imgutils.h"
> +#include "libavutil/fifo.h"
>  #include "avdevice.h"
>
> +#define FIFO_SIZE 4
> +
>  static const int avf_time_base = 100;
>
>  static const AVRational avf_time_base_q = {
> @@ -128,8 +132,8 @@ typedef struct
>  AVCaptureSession *capture_session;
>  AVCaptureVideoDataOutput *video_output;
>  AVCaptureAudioDataOutput *audio_output;
> -CMSampleBufferRef current_frame;
> -CMSampleBufferRef current_audio_frame;
> +AVFifoBuffer *video_fifo;
> +AVFifoBuffer *audio_fifo;
>
>  AVCaptureDevice  *observed_device;
>  #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
> @@ -138,6 +142,11 @@ typedef struct
>  int  observed_quit;
>  } AVFContext;
>
> +typedef struct {
> +int64_t ts;
> +CMSampleBufferRef frame;
> +} BufferRef;
> +
>  static void lock_frames(AVFContext* ctx)
>  {
>  pthread_mutex_lock(>frame_lock);
> @@ -148,6 +157,48 @@ static void unlock_frames(AVFContext* ctx)
>  pthread_mutex_unlock(>frame_lock);
>  }
>
> +static inline void fifo_write(AVFifoBuffer* f, int64_t ts,
> CMSampleBufferRef frame)
> +{
> +BufferRef buf = {
> +.ts= ts,
> +.frame = frame,
> +};
> +
> +CFRetain(frame);
> +av_fifo_generic_write(f, , sizeof(BufferRef), NULL);
> +}
> +
> +static inline void fifo_peek(AVFifoBuffer* f, BufferRef *buf)
> +{
> +if (av_fifo_size(f)) {
> +av_fifo_generic_peek(f, buf, sizeof(BufferRef), NULL);
> +return;
> +}
> +buf->frame = nil;
> +return;
> +}
> +
> +static inline void fifo_drain(AVFifoBuffer* f, int release)
> +{
> +av_assert2(av_fifo_size(f) >= sizeof(BufferRef));
> +if (release) {
> +BufferRef buf;
> +fifo_peek(f, );
> +CFRelease(buf.frame);
> +}
> +av_fifo_drain(f, sizeof(BufferRef));
> +}
> +
> +static inline void fifo_freep(AVFifoBuffer **f)
> +{
> +if (f) {
> +while (av_fifo_size(*f)) {
> +fifo_drain(*f, 1);
> +}
> +av_fifo_freep(f);
> +}
> +}
> +
>  /** FrameReciever class - delegate for AVCaptureSession
>   */
>  @interface AVFFrameReceiver : NSObject
> @@ -225,13 +276,16 @@ static void unlock_frames(AVFContext* ctx)
>didOutputSampleBuffer:(CMSampleBufferRef)videoFrame
>   fromConnection:(AVCaptureConnection *)connection
>  {
> +AVFifoBuffer *fifo = _context->video_fifo;
> +int64_t ts = av_gettime_relative();
>  lock_frames(_context);
>
> -if (_context->current_frame != nil) {
> -CFRelease(_context->current_frame);
> +if (av_fifo_space(fifo) == 0) {
> +av_log(_context, AV_LOG_DEBUG, "video fifo is full, the oldest
> frame has been dropped\n");
> +fifo_drain(fifo, 1);
>  }
>
> -_context->current_frame = (CMSampleBufferRef)CFRetain(videoFrame);
> +fifo_write(fifo, ts, videoFrame);
>
>  unlock_frames(_context);
>
> @@ -269,13 +323,16 @@ static void unlock_frames(AVFContext* ctx)
>didOutputSampleBuffer:(CMSampleBufferRef)audioFrame
>   fromConnection:(AVCaptureConnection *)connection
>  {
> +AVFifoBuffer *fifo = _context->audio_fifo;
> +int64_t ts = av_gettime_relative();
>  lock_frames(_context);
>
> -if (_context->current_audio_frame != nil) {
> -CFRelease(_context->current_audio_frame);
> +if (!av_fifo_space(fifo)) {
> +av_log(_context, AV_LOG_DEBUG, "audio fifo is full, the oldest
> frame has been dropped\n");
> +fifo_drain(fifo, 1);
>  }
>
> -_context->current_audio_frame =
> (CMSampleBufferRef)CFRetain(audioFrame);
> +fifo_write(fifo, ts, audioFrame);
>
>  unlock_frames(_context);
>
> @@ -301,12 +358,10 @@ static void destroy_context(AVFContext* ctx)
> 

Re: [FFmpeg-devel] [PATCH V3 1/5] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-28 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Nicolas
> George
> Sent: 2021年2月28日 19:45
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V3 1/5] libavdevice/v4l2.c: fix build
> warning for [-Wformat-truncation=]
> 
> Guo, Yejun (12021-02-27):
> > 'man readdir' on my system shows that it is d_name[256], see below.
> 
> man tells you what your particular system does right now, assuming the man
> page is up-to-date. It does not tell you if your system will change tomorrow,
> nor what other system do.
> 
> > agree, and maybe we can just let this build warning there.
> 
> In the long run, better disable it. We have check_disable_warning in 
> configure,
> so it is probably a one line patch.

thanks for the advice, we might don't disable it, because the disabling will no 
longer
remind the developers of this issue existing, this is another comment. thanks.

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

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

Re: [FFmpeg-devel] [PATCH V3 3/3] libavfilter: add filter dnn_detect for object detection

2021-02-28 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Guo,
> Yejun
> Sent: 2021年2月25日 10:02
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH V3 3/3] libavfilter: add filter dnn_detect
> for object detection
> 
> 
> 
> > -Original Message-
> > From: Guo, Yejun 
> > Sent: 2021年2月22日 15:31
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Guo, Yejun 
> > Subject: [PATCH V3 3/3] libavfilter: add filter dnn_detect for object
> > detection
> >
> > Below are the example steps to do object detection:
> >
> > 1. download and install l_openvino_toolkit_p_2021.1.110.tgz from
> > https://software.intel.com/content/www/us/en/develop/tools/openvino-to
> > olk
> > it/download.html
> >   or, we can get source code (tag 2021.1), build and install.
> > 2. export LD_LIBRARY_PATH with openvino settings, for example:
> > .../deployment_tools/inference_engine/lib/intel64/:.../deployment_tool
> > s/infer
> > ence_engine/external/tbb/lib/
> > 3. rebuild ffmpeg from source code with configure option:
> > --enable-libopenvino
> > --extra-cflags='-I.../deployment_tools/inference_engine/include/'
> > --extra-ldflags='-L.../deployment_tools/inference_engine/lib/intel64'
> > 4. download model files and test image wget
> >
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.
> > 1/face-detection-adas-0001.bin
> > wget
> >
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.
> > 1/face-detection-adas-0001.xml
> > wget
> >
> https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.
> > 1/face-detection-adas-0001.label
> > wget https://github.com/guoyejun/ffmpeg_dnn/raw/main/images/cici.jpg
> > 5. run ffmpeg with:
> > ./ffmpeg -i cici.jpg -vf
> >
> dnn_detect=dnn_backend=openvino:model=face-detection-adas-0001.xml:inp
> > ut=data:output=detection_out:confidence=0.6:labels=face-detection-adas
> > -000
> > 1.label -f null -
> >
> > We'll see the detect result as below:
> > [Parsed_dnn_detect_0 @ 0x56226644e540] frame->private_ref (bounding
> > boxes):
> > [Parsed_dnn_detect_0 @ 0x56226644e540] source:
> > face-detection-adas-0001.xml
> > [Parsed_dnn_detect_0 @ 0x56226644e540] index: 0, region: (1005, 813)
> > -> (1086, 905), label: face, confidence: 1/1.
> > [Parsed_dnn_detect_0 @ 0x56226644e540] index: 1, region: (888, 839) ->
> > (967, 926), label: face, confidence: 6917/1.
> >
> > There are two faces detected with confidence 100% and 69.17%.
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> >  configure  |   1 +
> >  doc/filters.texi   |  40 +++
> >  libavfilter/Makefile   |   1 +
> >  libavfilter/allfilters.c   |   1 +
> >  libavfilter/dnn/dnn_backend_openvino.c |  12 +
> >  libavfilter/dnn_filter_common.c|   7 +
> >  libavfilter/dnn_filter_common.h|   1 +
> >  libavfilter/dnn_interface.h|   6 +-
> >  libavfilter/vf_dnn_detect.c| 462
> > +
> >  9 files changed, 529 insertions(+), 2 deletions(-)  create mode
> > 100644 libavfilter/vf_dnn_detect.c
> >
> 
> any other comment for this patch set? thanks.

will push tomorrow if no other objections, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v4 2/2] avformat/gopher: Add support for Gopher over TLS.

2021-02-28 Thread parazyd
This commit adds a "gophers" handler to the gopher protocol. gophers
is a community-adopted protocol that acts the same way like normal
gopher with the added TLS encapsulation.

The gophers protocol is supported by gopher servers like geomydae(8),
and clients like curl(1), clic(1), and hurl(1).

This commit also adds compilation guards to both gopher and gophers,
since now there are two protocols in the file it makes sense to
have this addition.

Signed-off-by: parazyd 
---
 Changelog |  1 +
 configure |  1 +
 doc/general_contents.texi |  1 +
 doc/protocols.texi|  6 ++
 libavformat/Makefile  |  1 +
 libavformat/gopher.c  | 30 ++
 libavformat/protocols.c   |  1 +
 libavformat/version.h |  2 +-
 8 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/Changelog b/Changelog
index ba5aebf79d..5a7e007647 100644
--- a/Changelog
+++ b/Changelog
@@ -77,6 +77,7 @@ version :
 - OpenEXR image encoder
 - Simbiosis IMX decoder
 - Simbiosis IMX demuxer
+- gophers protocol
 
 
 version 4.3:
diff --git a/configure b/configure
index 380fca5245..cbce2b0f69 100755
--- a/configure
+++ b/configure
@@ -3451,6 +3451,7 @@ ffrtmphttp_protocol_conflict="librtmp_protocol"
 ffrtmphttp_protocol_select="http_protocol"
 ftp_protocol_select="tcp_protocol"
 gopher_protocol_select="tcp_protocol"
+gophers_protocol_select="tls_protocol"
 http_protocol_select="tcp_protocol"
 http_protocol_suggest="zlib"
 httpproxy_protocol_select="tcp_protocol"
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 6acdf441d6..b6513a6178 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1370,6 +1370,7 @@ performance on systems without hardware floating point 
support).
 @item file @tab X
 @item FTP  @tab X
 @item Gopher   @tab X
+@item Gophers  @tab X
 @item HLS  @tab X
 @item HTTP @tab X
 @item HTTPS@tab X
diff --git a/doc/protocols.texi b/doc/protocols.texi
index c0b511b7a4..2b2fab8752 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -341,6 +341,12 @@ operation. ff* tools may produce incomplete content due to 
server limitations.
 
 Gopher protocol.
 
+@section gophers
+
+Gophers protocol.
+
+The Gopher protocol with TLS encapsulation.
+
 @section hls
 
 Read Apple HTTP Live Streaming compliant segmented stream as
diff --git a/libavformat/Makefile b/libavformat/Makefile
index fcb39ce133..09038e40c3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -619,6 +619,7 @@ OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)   += rtmphttp.o
 OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
 OBJS-$(CONFIG_FTP_PROTOCOL)  += ftp.o urldecode.o
 OBJS-$(CONFIG_GOPHER_PROTOCOL)   += gopher.o
+OBJS-$(CONFIG_GOPHERS_PROTOCOL)  += gopher.o
 OBJS-$(CONFIG_HLS_PROTOCOL)  += hlsproto.o
 OBJS-$(CONFIG_HTTP_PROTOCOL) += http.o httpauth.o urldecode.o
 OBJS-$(CONFIG_HTTPPROXY_PROTOCOL)+= http.o httpauth.o urldecode.o
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index 7c88ab01a8..9bbe171640 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -2,6 +2,7 @@
  * Gopher protocol
  *
  * Copyright (c) 2009 Toshimitsu Kimura
+ * Copyright (c) 2021 parazyd 
  *
  * based on libavformat/http.c, Copyright (c) 2000, 2001 Fabrice Bellard
  *
@@ -22,6 +23,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+
 #include "libavutil/avstring.h"
 #include "avformat.h"
 #include "internal.h"
@@ -75,19 +78,23 @@ static int gopher_close(URLContext *h)
 static int gopher_open(URLContext *h, const char *uri, int flags)
 {
 GopherContext *s = h->priv_data;
-char hostname[1024], auth[1024], path[1024], buf[1024];
+char proto[10], hostname[1024], auth[1024], path[1024], buf[1024];
 int port, err;
+const char *lower_proto = "tcp";
 
 h->is_streamed = 1;
 
 /* needed in any case to build the host string */
-av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), 
,
- path, sizeof(path), uri);
+av_url_split(proto, sizeof(proto), auth, sizeof(auth),
+ hostname, sizeof(hostname), , path, sizeof(path), uri);
 
 if (port < 0)
 port = 70;
 
-ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
+if (!strcmp(proto, "gophers"))
+lower_proto = "tls";
+
+ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
 
 s->hd = NULL;
 err = ffurl_open_whitelist(>hd, buf, AVIO_FLAG_READ_WRITE,
@@ -110,6 +117,7 @@ static int gopher_read(URLContext *h, uint8_t *buf, int 
size)
 return len;
 }
 
+#if CONFIG_GOPHER_PROTOCOL
 const URLProtocol ff_gopher_protocol = {
 .name  = "gopher",
 .url_open  = gopher_open,
@@ -120,3 +128,17 @@ const URLProtocol ff_gopher_protocol = {
 .flags = 

[FFmpeg-devel] [PATCH v4 1/2] avformat/gopher: Add default_whitelist to ff_gopher_protocol

2021-02-28 Thread parazyd
Signed-off-by: parazyd 
---
 configure|  2 +-
 libavformat/gopher.c | 16 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 98daa1a64a..380fca5245 100755
--- a/configure
+++ b/configure
@@ -3450,7 +3450,7 @@ ffrtmpcrypt_protocol_select="tcp_protocol"
 ffrtmphttp_protocol_conflict="librtmp_protocol"
 ffrtmphttp_protocol_select="http_protocol"
 ftp_protocol_select="tcp_protocol"
-gopher_protocol_select="network"
+gopher_protocol_select="tcp_protocol"
 http_protocol_select="tcp_protocol"
 http_protocol_suggest="zlib"
 httpproxy_protocol_select="tcp_protocol"
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index 8b6d14a1f7..7c88ab01a8 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -110,13 +110,13 @@ static int gopher_read(URLContext *h, uint8_t *buf, int 
size)
 return len;
 }
 
-
 const URLProtocol ff_gopher_protocol = {
-.name   = "gopher",
-.url_open   = gopher_open,
-.url_read   = gopher_read,
-.url_write  = gopher_write,
-.url_close  = gopher_close,
-.priv_data_size = sizeof(GopherContext),
-.flags  = URL_PROTOCOL_FLAG_NETWORK,
+.name  = "gopher",
+.url_open  = gopher_open,
+.url_read  = gopher_read,
+.url_write = gopher_write,
+.url_close = gopher_close,
+.priv_data_size= sizeof(GopherContext),
+.flags = URL_PROTOCOL_FLAG_NETWORK,
+.default_whitelist = "gopher,tcp"
 };
-- 
2.30.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] libavformat: add librist protocol

2021-02-28 Thread Marton Balint



On Sun, 28 Feb 2021, Paul B Mahol wrote:


On Sun, Feb 28, 2021 at 11:14 PM Marton Balint  wrote:




On Sun, 28 Feb 2021, Paul B Mahol wrote:

> This work is sponsored by Open Broadcast Systems.
>
> Signed-off-by: Paul B Mahol 
> ---
> configure   |   5 +
> doc/protocols.texi  |  29 +
> libavformat/Makefile|   1 +
> libavformat/librist.c   | 236 
> libavformat/protocols.c |   1 +
> 5 files changed, 272 insertions(+)
> create mode 100644 libavformat/librist.c
>

[...]

> +static int librist_read(URLContext *h, uint8_t *buf, int size)
> +{
> +RISTContext *s = h->priv_data;
> +const struct rist_data_block *data_block;
> +int ret;
> +
> +ret = rist_receiver_data_read(s->ctx, _block, s->queue_count
<= 0 ? POLLING_TIME : 0);

Use POLLING_TIME unconditionally. If there are packets in the queue,
POLLING_TIME should not matter. This also means that keeping track of
queue_count is useless.




Not possible, that would cause fifo filling up.


But why?

Here is the code directly from librist:

ssize_t num = 0;
// Select the flow with highest queue count to minimize jitter for calling app
struct rist_flow *f = rist_get_longest_flow(ctx, );
if (!num && timeout > 0)
{
pthread_mutex_lock(&(ctx->mutex));
pthread_cond_timedwait_ms(&(ctx->condition), &(ctx->mutex), timeout);
pthread_mutex_unlock(&(ctx->mutex));
f = rist_get_longest_flow(ctx, );
}

timeout should only matter, if queue is empty.



I give up. FFmpeg protocols API is utterly useless.


Please, don't, if using a constant POLLING_TIME indeed makes a difference 
then you are on the right track of finding the core bug.


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

[FFmpeg-devel] [PATCH v3 2/2] avformat/gopher: Add support for Gopher over TLS.

2021-02-28 Thread parazyd
This commit adds a "gophers" handler to the gopher protocol. gophers
is a community-adopted protocol that acts the same way like normal
gopher with the added TLS encapsulation.

The gophers protocol is supported by gopher servers like geomydae(8),
and clients like curl(1), clic(1), and hurl(1).

Signed-off-by: parazyd 
---
 Changelog   |  1 +
 configure   |  1 +
 libavformat/Makefile|  1 +
 libavformat/gopher.c| 23 +++
 libavformat/protocols.c |  1 +
 5 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/Changelog b/Changelog
index ba5aebf79d..5a7e007647 100644
--- a/Changelog
+++ b/Changelog
@@ -77,6 +77,7 @@ version :
 - OpenEXR image encoder
 - Simbiosis IMX decoder
 - Simbiosis IMX demuxer
+- gophers protocol
 
 
 version 4.3:
diff --git a/configure b/configure
index 380fca5245..cbce2b0f69 100755
--- a/configure
+++ b/configure
@@ -3451,6 +3451,7 @@ ffrtmphttp_protocol_conflict="librtmp_protocol"
 ffrtmphttp_protocol_select="http_protocol"
 ftp_protocol_select="tcp_protocol"
 gopher_protocol_select="tcp_protocol"
+gophers_protocol_select="tls_protocol"
 http_protocol_select="tcp_protocol"
 http_protocol_suggest="zlib"
 httpproxy_protocol_select="tcp_protocol"
diff --git a/libavformat/Makefile b/libavformat/Makefile
index fcb39ce133..09038e40c3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -619,6 +619,7 @@ OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)   += rtmphttp.o
 OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
 OBJS-$(CONFIG_FTP_PROTOCOL)  += ftp.o urldecode.o
 OBJS-$(CONFIG_GOPHER_PROTOCOL)   += gopher.o
+OBJS-$(CONFIG_GOPHERS_PROTOCOL)  += gopher.o
 OBJS-$(CONFIG_HLS_PROTOCOL)  += hlsproto.o
 OBJS-$(CONFIG_HTTP_PROTOCOL) += http.o httpauth.o urldecode.o
 OBJS-$(CONFIG_HTTPPROXY_PROTOCOL)+= http.o httpauth.o urldecode.o
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index 7c88ab01a8..c9326080db 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -75,19 +75,23 @@ static int gopher_close(URLContext *h)
 static int gopher_open(URLContext *h, const char *uri, int flags)
 {
 GopherContext *s = h->priv_data;
-char hostname[1024], auth[1024], path[1024], buf[1024];
+char proto[10], hostname[1024], auth[1024], path[1024], buf[1024];
 int port, err;
+const char *lower_proto = "tcp";
 
 h->is_streamed = 1;
 
 /* needed in any case to build the host string */
-av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), 
,
- path, sizeof(path), uri);
+av_url_split(proto, sizeof(proto), auth, sizeof(auth),
+ hostname, sizeof(hostname), , path, sizeof(path), uri);
 
 if (port < 0)
 port = 70;
 
-ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
+if (!strcmp(proto, "gophers"))
+lower_proto = "tls";
+
+ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
 
 s->hd = NULL;
 err = ffurl_open_whitelist(>hd, buf, AVIO_FLAG_READ_WRITE,
@@ -120,3 +124,14 @@ const URLProtocol ff_gopher_protocol = {
 .flags = URL_PROTOCOL_FLAG_NETWORK,
 .default_whitelist = "gopher,tcp"
 };
+
+const URLProtocol ff_gophers_protocol = {
+.name  = "gophers",
+.url_open  = gopher_open,
+.url_read  = gopher_read,
+.url_write = gopher_write,
+.url_close = gopher_close,
+.priv_data_size= sizeof(GopherContext),
+.flags = URL_PROTOCOL_FLAG_NETWORK,
+.default_whitelist = "gopher,gophers,tcp,tls"
+};
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 7df18fbb3b..9e77dc2506 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -34,6 +34,7 @@ extern const URLProtocol ff_ffrtmphttp_protocol;
 extern const URLProtocol ff_file_protocol;
 extern const URLProtocol ff_ftp_protocol;
 extern const URLProtocol ff_gopher_protocol;
+extern const URLProtocol ff_gophers_protocol;
 extern const URLProtocol ff_hls_protocol;
 extern const URLProtocol ff_http_protocol;
 extern const URLProtocol ff_httpproxy_protocol;
-- 
2.30.1

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

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

[FFmpeg-devel] [PATCH v3 1/2] avformat/gopher: Add default_whitelist to ff_gopher_protocol

2021-02-28 Thread parazyd
Signed-off-by: parazyd 
---
 configure|  2 +-
 libavformat/gopher.c | 16 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 98daa1a64a..380fca5245 100755
--- a/configure
+++ b/configure
@@ -3450,7 +3450,7 @@ ffrtmpcrypt_protocol_select="tcp_protocol"
 ffrtmphttp_protocol_conflict="librtmp_protocol"
 ffrtmphttp_protocol_select="http_protocol"
 ftp_protocol_select="tcp_protocol"
-gopher_protocol_select="network"
+gopher_protocol_select="tcp_protocol"
 http_protocol_select="tcp_protocol"
 http_protocol_suggest="zlib"
 httpproxy_protocol_select="tcp_protocol"
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index 8b6d14a1f7..7c88ab01a8 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -110,13 +110,13 @@ static int gopher_read(URLContext *h, uint8_t *buf, int 
size)
 return len;
 }
 
-
 const URLProtocol ff_gopher_protocol = {
-.name   = "gopher",
-.url_open   = gopher_open,
-.url_read   = gopher_read,
-.url_write  = gopher_write,
-.url_close  = gopher_close,
-.priv_data_size = sizeof(GopherContext),
-.flags  = URL_PROTOCOL_FLAG_NETWORK,
+.name  = "gopher",
+.url_open  = gopher_open,
+.url_read  = gopher_read,
+.url_write = gopher_write,
+.url_close = gopher_close,
+.priv_data_size= sizeof(GopherContext),
+.flags = URL_PROTOCOL_FLAG_NETWORK,
+.default_whitelist = "gopher,tcp"
 };
-- 
2.30.1

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

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

[FFmpeg-devel] [PATCH v2] avformat/gopher: Add support for Gopher over TLS.

2021-02-28 Thread parazyd
This commit adds a "gophers" handler to the gopher protocol. gophers
is a community-adopted protocol that acts the same way like normal
gopher with the added TLS encapsulation.

The gophers protocol is supported by gopher servers like geomyidae(8),
and clients like curl(1), clic(1), and hurl(1).

Signed-off-by: parazyd 
---
 configure   |  3 ++-
 libavformat/Makefile|  1 +
 libavformat/gopher.c| 39 +++
 libavformat/protocols.c |  1 +
 4 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index 98daa1a64a..cbce2b0f69 100755
--- a/configure
+++ b/configure
@@ -3450,7 +3450,8 @@ ffrtmpcrypt_protocol_select="tcp_protocol"
 ffrtmphttp_protocol_conflict="librtmp_protocol"
 ffrtmphttp_protocol_select="http_protocol"
 ftp_protocol_select="tcp_protocol"
-gopher_protocol_select="network"
+gopher_protocol_select="tcp_protocol"
+gophers_protocol_select="tls_protocol"
 http_protocol_select="tcp_protocol"
 http_protocol_suggest="zlib"
 httpproxy_protocol_select="tcp_protocol"
diff --git a/libavformat/Makefile b/libavformat/Makefile
index fcb39ce133..09038e40c3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -619,6 +619,7 @@ OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)   += rtmphttp.o
 OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
 OBJS-$(CONFIG_FTP_PROTOCOL)  += ftp.o urldecode.o
 OBJS-$(CONFIG_GOPHER_PROTOCOL)   += gopher.o
+OBJS-$(CONFIG_GOPHERS_PROTOCOL)  += gopher.o
 OBJS-$(CONFIG_HLS_PROTOCOL)  += hlsproto.o
 OBJS-$(CONFIG_HTTP_PROTOCOL) += http.o httpauth.o urldecode.o
 OBJS-$(CONFIG_HTTPPROXY_PROTOCOL)+= http.o httpauth.o urldecode.o
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index 8b6d14a1f7..c9326080db 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -75,19 +75,23 @@ static int gopher_close(URLContext *h)
 static int gopher_open(URLContext *h, const char *uri, int flags)
 {
 GopherContext *s = h->priv_data;
-char hostname[1024], auth[1024], path[1024], buf[1024];
+char proto[10], hostname[1024], auth[1024], path[1024], buf[1024];
 int port, err;
+const char *lower_proto = "tcp";
 
 h->is_streamed = 1;
 
 /* needed in any case to build the host string */
-av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), 
,
- path, sizeof(path), uri);
+av_url_split(proto, sizeof(proto), auth, sizeof(auth),
+ hostname, sizeof(hostname), , path, sizeof(path), uri);
 
 if (port < 0)
 port = 70;
 
-ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
+if (!strcmp(proto, "gophers"))
+lower_proto = "tls";
+
+ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
 
 s->hd = NULL;
 err = ffurl_open_whitelist(>hd, buf, AVIO_FLAG_READ_WRITE,
@@ -110,13 +114,24 @@ static int gopher_read(URLContext *h, uint8_t *buf, int 
size)
 return len;
 }
 
-
 const URLProtocol ff_gopher_protocol = {
-.name   = "gopher",
-.url_open   = gopher_open,
-.url_read   = gopher_read,
-.url_write  = gopher_write,
-.url_close  = gopher_close,
-.priv_data_size = sizeof(GopherContext),
-.flags  = URL_PROTOCOL_FLAG_NETWORK,
+.name  = "gopher",
+.url_open  = gopher_open,
+.url_read  = gopher_read,
+.url_write = gopher_write,
+.url_close = gopher_close,
+.priv_data_size= sizeof(GopherContext),
+.flags = URL_PROTOCOL_FLAG_NETWORK,
+.default_whitelist = "gopher,tcp"
+};
+
+const URLProtocol ff_gophers_protocol = {
+.name  = "gophers",
+.url_open  = gopher_open,
+.url_read  = gopher_read,
+.url_write = gopher_write,
+.url_close = gopher_close,
+.priv_data_size= sizeof(GopherContext),
+.flags = URL_PROTOCOL_FLAG_NETWORK,
+.default_whitelist = "gopher,gophers,tcp,tls"
 };
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 7df18fbb3b..9e77dc2506 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -34,6 +34,7 @@ extern const URLProtocol ff_ffrtmphttp_protocol;
 extern const URLProtocol ff_file_protocol;
 extern const URLProtocol ff_ftp_protocol;
 extern const URLProtocol ff_gopher_protocol;
+extern const URLProtocol ff_gophers_protocol;
 extern const URLProtocol ff_hls_protocol;
 extern const URLProtocol ff_http_protocol;
 extern const URLProtocol ff_httpproxy_protocol;
-- 
2.30.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] libavformat: add librist protocol

2021-02-28 Thread Paul B Mahol
On Sun, Feb 28, 2021 at 11:14 PM Marton Balint  wrote:

>
>
> On Sun, 28 Feb 2021, Paul B Mahol wrote:
>
> > This work is sponsored by Open Broadcast Systems.
> >
> > Signed-off-by: Paul B Mahol 
> > ---
> > configure   |   5 +
> > doc/protocols.texi  |  29 +
> > libavformat/Makefile|   1 +
> > libavformat/librist.c   | 236 
> > libavformat/protocols.c |   1 +
> > 5 files changed, 272 insertions(+)
> > create mode 100644 libavformat/librist.c
> >
>
> [...]
>
> > +static int librist_read(URLContext *h, uint8_t *buf, int size)
> > +{
> > +RISTContext *s = h->priv_data;
> > +const struct rist_data_block *data_block;
> > +int ret;
> > +
> > +ret = rist_receiver_data_read(s->ctx, _block, s->queue_count
> <= 0 ? POLLING_TIME : 0);
>
> Use POLLING_TIME unconditionally. If there are packets in the queue,
> POLLING_TIME should not matter. This also means that keeping track of
> queue_count is useless.
>


Not possible, that would cause fifo filling up.

I give up. FFmpeg protocols API is utterly useless.


>
> > +if (ret < 0)
> > +return risterr2ret(ret);
> > +
> > +if (ret == 0 || data_block->payload_len <= 0)
> > +return 0;
>
> You should return EAGAIN if ret == 0, as in the previous version of the
> patch. Otherwise you are "making up" a 0 sized packet.
>
> Yet again, this should not make a difference, because
> retry_transfer_wrapper in libavformat/avio.c fast retries EAGAIN
> immedietly for the first five times. So the user will only see an EAGAIN
> if the queue was empty for 5 * POLLING_TIME, which is 0.5 sec. If a
> librist stream receives no packets for 0.5 secs, then something is wrong.
>
> 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".
___
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 3/4] avcodec: enable usage of AV_EF_EXPLODE for subtitle encoders

2021-02-28 Thread Jan Ekström
On Mon, Feb 22, 2021 at 3:19 PM Jan Ekström  wrote:
>
> From: Jan Ekström 
>
> As currently it is the responsibility of the following subtitle
> encoder to validate the correctness of the incoming ASS dialog line.
>
> Signed-off-by: Jan Ekström 

Requesting comments on this bit of the change set, since apparently
the actual implementation bits have been reviewed.

This way of doing it was recommended by Anton, and as noted in the
opening mail for the patch set I am open to just an AVOption if
someone feels like this is a bad idea.

Jan
___
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] libavformat: add librist protocol

2021-02-28 Thread Marton Balint



On Sun, 28 Feb 2021, Paul B Mahol wrote:


This work is sponsored by Open Broadcast Systems.

Signed-off-by: Paul B Mahol 
---
configure   |   5 +
doc/protocols.texi  |  29 +
libavformat/Makefile|   1 +
libavformat/librist.c   | 236 
libavformat/protocols.c |   1 +
5 files changed, 272 insertions(+)
create mode 100644 libavformat/librist.c



[...]


+static int librist_read(URLContext *h, uint8_t *buf, int size)
+{
+RISTContext *s = h->priv_data;
+const struct rist_data_block *data_block;
+int ret;
+
+ret = rist_receiver_data_read(s->ctx, _block, s->queue_count <= 0 ? 
POLLING_TIME : 0);


Use POLLING_TIME unconditionally. If there are packets in the queue, 
POLLING_TIME should not matter. This also means that keeping track of 
queue_count is useless.



+if (ret < 0)
+return risterr2ret(ret);
+
+if (ret == 0 || data_block->payload_len <= 0)
+return 0;


You should return EAGAIN if ret == 0, as in the previous version of the 
patch. Otherwise you are "making up" a 0 sized packet.


Yet again, this should not make a difference, because 
retry_transfer_wrapper in libavformat/avio.c fast retries EAGAIN 
immedietly for the first five times. So the user will only see an EAGAIN 
if the queue was empty for 5 * POLLING_TIME, which is 0.5 sec. If a 
librist stream receives no packets for 0.5 secs, then something is wrong.


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] libavformat: add librist protocol

2021-02-28 Thread Marton Balint



On Sun, 28 Feb 2021, Paul B Mahol wrote:


On Fri, Feb 26, 2021 at 9:54 PM Marton Balint  wrote:




On Fri, 26 Feb 2021, Paul B Mahol wrote:

> This work is sponsored by Open Broadcast Systems.
>
> Signed-off-by: Paul B Mahol 
> ---
> configure   |   5 +
> doc/protocols.texi  |  29 +
> libavformat/Makefile|   1 +
> libavformat/librist.c   | 248 
> libavformat/protocols.c |   1 +
> 5 files changed, 284 insertions(+)
> create mode 100644 libavformat/librist.c
>

> +#define D AV_OPT_FLAG_DECODING_PARAM
> +#define E AV_OPT_FLAG_ENCODING_PARAM
> +#define OFFSET(x) offsetof(RISTContext, x)
> +static const AVOption librist_options[] = {
> +{ "rist_profile","set profile", OFFSET(profile),
 AV_OPT_TYPE_INT,   {.i64=RIST_PROFILE_MAIN}, 0, 2, .flags = D|E,
"profile" },
> +{ "simple",  NULL,  0,
 AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_SIMPLE},   0, 0, .flags = D|E,
"profile" },
> +{ "main",NULL,  0,
 AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_MAIN}, 0, 0, .flags = D|E,
"profile" },
> +{ "advanced",NULL,  0,
 AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_ADVANCED}, 0, 0, .flags = D|E,
"profile" },
> +{ "buffer_size", "set buffer_size", OFFSET(buffer_size),
AV_OPT_TYPE_INT,   {.i64=0}, 0, INT_MAX, .flags = D|E },
> +{ "log_level",   "set loglevel",OFFSET(log_level),
 AV_OPT_TYPE_INT,   {.i64=-1},   -1, INT_MAX, .flags = D|E
},
> +{ "secret", "set encryption secret",OFFSET(secret),
AV_OPT_TYPE_STRING,{.str=NULL},  0, 0,   .flags = D|E },
> +{ "encryption","set encryption type",OFFSET(encryption),
AV_OPT_TYPE_INT   ,{.i64=0}, 0, INT_MAX, .flags = D|E },

Why have you removed pkt_size? For writing, it is surely useful to be
configurable, please put it back with -1 as default, so different default
can be used for read and write. And for writing, the default of 1316
should be used, as we typically want to pump mpegts into it, split on
packet boundaries and want no fragmentation.



This options makes no sense for read/receive end.


Then use the value set by the option for the write/send case only.

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/gopher: Add support for Gopher over TLS.

2021-02-28 Thread Ivan J.
Pinging for review.

Best regards,
Ivan
___
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: add librist protocol

2021-02-28 Thread Paul B Mahol
This work is sponsored by Open Broadcast Systems.

Signed-off-by: Paul B Mahol 
---
 configure   |   5 +
 doc/protocols.texi  |  29 +
 libavformat/Makefile|   1 +
 libavformat/librist.c   | 236 
 libavformat/protocols.c |   1 +
 5 files changed, 272 insertions(+)
 create mode 100644 libavformat/librist.c

diff --git a/configure b/configure
index d11942fced..378b1e0cc2 100755
--- a/configure
+++ b/configure
@@ -259,6 +259,7 @@ External library support:
   --enable-libpulseenable Pulseaudio input via libpulse [no]
   --enable-librabbitmq enable RabbitMQ library [no]
   --enable-librav1eenable AV1 encoding via rav1e [no]
+  --enable-librist enable RIST via librist [no]
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
   --enable-librtmp enable RTMP[E] support via librtmp [no]
@@ -1797,6 +1798,7 @@ EXTERNAL_LIBRARY_LIST="
 libpulse
 librabbitmq
 librav1e
+librist
 librsvg
 librtmp
 libshine
@@ -3490,6 +3492,8 @@ unix_protocol_select="network"
 # external library protocols
 libamqp_protocol_deps="librabbitmq"
 libamqp_protocol_select="network"
+librist_protocol_deps="librist"
+librist_protocol_select="network"
 librtmp_protocol_deps="librtmp"
 librtmpe_protocol_deps="librtmp"
 librtmps_protocol_deps="librtmp"
@@ -6409,6 +6413,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.4.0" 
rav1e.h rav1e_context_new
+enabled librist   && require_pkg_config librist "librist >= 0.2" 
librist/librist.h rist_receiver_create
 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
 enabled librubberband && require_pkg_config librubberband "rubberband >= 
1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
librubberband_extralibs "-lstdc++"
diff --git a/doc/protocols.texi b/doc/protocols.texi
index c0b511b7a4..11fb351bf6 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -690,6 +690,35 @@ Example usage:
 -f rtp_mpegts -fec prompeg=l=8:d=4 rtp://@var{hostname}:@var{port}
 @end example
 
+@section rist
+
+Reliable Internet Streaming Transport protocol
+
+The accepted options are:
+@table @option
+@item rist_profile
+Supported values:
+@table @samp
+@item simple
+@item main
+This one is default.
+@item advanced
+@end table
+
+@item buffer_size
+Set internal RIST buffer size for retransmission of data.
+
+@item log_level
+Set loglevel for RIST logging messages.
+
+@item secret
+Set override of encryption secret, by default is unset.
+
+@item encryption
+Set encryption type, by default is disabled.
+Acceptable values are 128 and 256.
+@end table
+
 @section rtmp
 
 Real-Time Messaging Protocol.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 56fa96ea7f..95ed25e866 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -654,6 +654,7 @@ OBJS-$(CONFIG_UNIX_PROTOCOL) += unix.o
 
 # external library protocols
 OBJS-$(CONFIG_LIBAMQP_PROTOCOL)  += libamqp.o
+OBJS-$(CONFIG_LIBRIST_PROTOCOL)  += librist.o
 OBJS-$(CONFIG_LIBRTMP_PROTOCOL)  += librtmp.o
 OBJS-$(CONFIG_LIBRTMPE_PROTOCOL) += librtmp.o
 OBJS-$(CONFIG_LIBRTMPS_PROTOCOL) += librtmp.o
diff --git a/libavformat/librist.c b/libavformat/librist.c
new file mode 100644
index 00..789cefda36
--- /dev/null
+++ b/libavformat/librist.c
@@ -0,0 +1,236 @@
+/*
+ * 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
+ * Reliable Internet Streaming Transport protocol
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "libavutil/time.h"
+
+#include "avformat.h"
+#include "internal.h"
+#include "network.h"
+#include "os_support.h"
+#include "url.h"
+

Re: [FFmpeg-devel] [PATCH] libavformat: add librist protocol

2021-02-28 Thread Paul B Mahol
On Fri, Feb 26, 2021 at 9:54 PM Marton Balint  wrote:

>
>
> On Fri, 26 Feb 2021, Paul B Mahol wrote:
>
> > This work is sponsored by Open Broadcast Systems.
> >
> > Signed-off-by: Paul B Mahol 
> > ---
> > configure   |   5 +
> > doc/protocols.texi  |  29 +
> > libavformat/Makefile|   1 +
> > libavformat/librist.c   | 248 
> > libavformat/protocols.c |   1 +
> > 5 files changed, 284 insertions(+)
> > create mode 100644 libavformat/librist.c
> >
>
> > +#define D AV_OPT_FLAG_DECODING_PARAM
> > +#define E AV_OPT_FLAG_ENCODING_PARAM
> > +#define OFFSET(x) offsetof(RISTContext, x)
> > +static const AVOption librist_options[] = {
> > +{ "rist_profile","set profile", OFFSET(profile),
>  AV_OPT_TYPE_INT,   {.i64=RIST_PROFILE_MAIN}, 0, 2, .flags = D|E,
> "profile" },
> > +{ "simple",  NULL,  0,
>  AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_SIMPLE},   0, 0, .flags = D|E,
> "profile" },
> > +{ "main",NULL,  0,
>  AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_MAIN}, 0, 0, .flags = D|E,
> "profile" },
> > +{ "advanced",NULL,  0,
>  AV_OPT_TYPE_CONST, {.i64=RIST_PROFILE_ADVANCED}, 0, 0, .flags = D|E,
> "profile" },
> > +{ "buffer_size", "set buffer_size", OFFSET(buffer_size),
> AV_OPT_TYPE_INT,   {.i64=0}, 0, INT_MAX, .flags = D|E },
> > +{ "log_level",   "set loglevel",OFFSET(log_level),
>  AV_OPT_TYPE_INT,   {.i64=-1},   -1, INT_MAX, .flags = D|E
> },
> > +{ "secret", "set encryption secret",OFFSET(secret),
> AV_OPT_TYPE_STRING,{.str=NULL},  0, 0,   .flags = D|E },
> > +{ "encryption","set encryption type",OFFSET(encryption),
> AV_OPT_TYPE_INT   ,{.i64=0}, 0, INT_MAX, .flags = D|E },
>
> Why have you removed pkt_size? For writing, it is surely useful to be
> configurable, please put it back with -1 as default, so different default
> can be used for read and write. And for writing, the default of 1316
> should be used, as we typically want to pump mpegts into it, split on
> packet boundaries and want no fragmentation.
>

This options makes no sense for read/receive end.


>
> > +static int librist_open(URLContext *h, const char *uri, int flags)
> > +{
> > +RISTContext *s = h->priv_data;
> > +struct rist_logging_settings *logging_settings =
> >logging_settings;
> > +struct rist_peer_config *peer_config = >peer_config;
> > +int ret;
> > +
> > +if ((flags & (AVIO_FLAG_WRITE | AVIO_FLAG_READ)) ==
> (AVIO_FLAG_WRITE | AVIO_FLAG_READ))
> > +return AVERROR(EINVAL);
>
> AVIO_FLAG_READ_WRITE
>
> > +
> > +return risterr2ret(ret);
> > +}
> > +
> > +static int librist_read(URLContext *h, uint8_t *buf, int size)
> > +{
> > +RISTContext *s = h->priv_data;
> > +int available_size = size;
> > +int queue_size = 0;
> > +int offset = 0;
> > +
> > +do {
> > +const struct rist_data_block *data_block;
> > +int ret;
> > +
> > +ret = rist_receiver_data_read(s->ctx, _block, offset == 0
> ? POLLING_TIME : 0);
> > +if (ret < 0)
> > +return risterr2ret(ret);
> > +
> > +if (ret == 0 || data_block->payload_len <= 0)
> > +break;
> > +
> > +queue_size = ret;
> > +av_assert0(data_block->payload_len <= available_size);
> > +
> > +size = FFMIN(available_size, data_block->payload_len);
> > +memcpy(buf + offset, data_block->payload, size);
> > +offset += size;
> > +available_size -= size;
> > +rist_receiver_data_block_free((struct
> rist_data_block**)_block);
> > +queue_size--;
>
> No, read one packet in one read call, do not merge packets. Protocols
> don't merge packets. UDP does not merge packets. If this is some
> workaround for librist dropping packets then figure out the bug causing
> that. If UDP works, librist should work too, even without merging packets.
>
> 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".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/roqvideoenc: Avoid allocating buffers separately

2021-02-28 Thread Paul B Mahol
lgtm if encoding is still working and tested.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 5/5] avcodec/roqvideoenc: Avoid allocating buffers separately

2021-02-28 Thread Andreas Rheinhardt
This is possible because their size is known at compile-time; so they
can be put directly into the context and don't need to be allocated for
every frame.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/roqvideoenc.c | 146 ++-
 1 file changed, 68 insertions(+), 78 deletions(-)

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index d65c740d5f..1ab0de0abb 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -78,6 +78,36 @@
 /* The cast is useful when multiplying it by INT_MAX */
 #define ROQ_LAMBDA_SCALE ((uint64_t) FF_LAMBDA_SCALE)
 
+typedef struct RoqCodebooks {
+int numCB4;
+int numCB2;
+int usedCB2[MAX_CBS_2x2];
+int usedCB4[MAX_CBS_4x4];
+uint8_t unpacked_cb2[MAX_CBS_2x2*2*2*3];
+uint8_t unpacked_cb4[MAX_CBS_4x4*4*4*3];
+uint8_t unpacked_cb4_enlarged[MAX_CBS_4x4*8*8*3];
+} RoqCodebooks;
+
+/**
+ * Temporary vars
+ */
+typedef struct RoqTempData
+{
+int f2i4[MAX_CBS_4x4];
+int i2f4[MAX_CBS_4x4];
+int f2i2[MAX_CBS_2x2];
+int i2f2[MAX_CBS_2x2];
+
+int mainChunkSize;
+
+int numCB4;
+int numCB2;
+
+RoqCodebooks codebooks;
+
+int used_option[4];
+} RoqTempData;
+
 typedef struct SubcelEvaluation {
 int eval_dist[4];
 int best_bit_use;
@@ -115,7 +145,9 @@ typedef struct RoqEncContext {
 
 const AVFrame *frame_to_enc;
 uint8_t *out_buf;
-struct RoqTempData *tmpData;
+RoqTempData tmp_data;
+roq_cell results4[4 * MAX_CBS_4x4];
+int tmp_codebook_buf[FFMAX(24 * MAX_CBS_4x4, 6 * MAX_CBS_2x2)];
 
 CelEvaluation *cel_evals;
 int *closest_cb;
@@ -233,36 +265,6 @@ static inline int squared_diff_macroblock(uint8_t a[], 
uint8_t b[], int size)
 return sdiff;
 }
 
-typedef struct RoqCodebooks {
-int numCB4;
-int numCB2;
-int usedCB2[MAX_CBS_2x2];
-int usedCB4[MAX_CBS_4x4];
-uint8_t unpacked_cb2[MAX_CBS_2x2*2*2*3];
-uint8_t unpacked_cb4[MAX_CBS_4x4*4*4*3];
-uint8_t unpacked_cb4_enlarged[MAX_CBS_4x4*8*8*3];
-} RoqCodebooks;
-
-/**
- * Temporary vars
- */
-typedef struct RoqTempData
-{
-int f2i4[MAX_CBS_4x4];
-int i2f4[MAX_CBS_4x4];
-int f2i2[MAX_CBS_2x2];
-int i2f2[MAX_CBS_2x2];
-
-int mainChunkSize;
-
-int numCB4;
-int numCB2;
-
-RoqCodebooks codebooks;
-
-int used_option[4];
-} RoqTempdata;
-
 /**
  * Initialize cel evaluators and set their source coordinates
  */
@@ -424,9 +426,10 @@ static void motion_search(RoqEncContext *enc, int 
blocksize)
  * Get distortion for all options available to a subcel
  */
 static void gather_data_for_subcel(SubcelEvaluation *subcel, int x,
-   int y, RoqEncContext *enc, RoqTempdata 
*tempData)
+   int y, RoqEncContext *enc)
 {
 RoqContext *const roq = >common;
+RoqTempData *const tempData = >tmp_data;
 uint8_t mb4[4*4*3];
 uint8_t mb2[2*2*3];
 int cluster_index;
@@ -488,10 +491,10 @@ static void gather_data_for_subcel(SubcelEvaluation 
*subcel, int x,
 /**
  * Get distortion for all options available to a cel
  */
-static void gather_data_for_cel(CelEvaluation *cel, RoqEncContext *enc,
-RoqTempdata *tempData)
+static void gather_data_for_cel(CelEvaluation *cel, RoqEncContext *enc)
 {
 RoqContext *const roq = >common;
+RoqTempData *const tempData = >tmp_data;
 uint8_t mb8[8*8*3];
 int index = cel->sourceY * roq->width / 64 + cel->sourceX/8;
 int i, j, best_dist, divide_bit_use;
@@ -523,10 +526,10 @@ static void gather_data_for_cel(CelEvaluation *cel, 
RoqEncContext *enc,
 index_mb(mb8, tempData->codebooks.unpacked_cb4_enlarged,
  tempData->codebooks.numCB4, >cbEntry, 8);
 
-gather_data_for_subcel(cel->subCels + 0, cel->sourceX+0, cel->sourceY+0, 
enc, tempData);
-gather_data_for_subcel(cel->subCels + 1, cel->sourceX+4, cel->sourceY+0, 
enc, tempData);
-gather_data_for_subcel(cel->subCels + 2, cel->sourceX+0, cel->sourceY+4, 
enc, tempData);
-gather_data_for_subcel(cel->subCels + 3, cel->sourceX+4, cel->sourceY+4, 
enc, tempData);
+gather_data_for_subcel(cel->subCels + 0, cel->sourceX+0, cel->sourceY+0, 
enc);
+gather_data_for_subcel(cel->subCels + 1, cel->sourceX+4, cel->sourceY+0, 
enc);
+gather_data_for_subcel(cel->subCels + 2, cel->sourceX+0, cel->sourceY+4, 
enc);
+gather_data_for_subcel(cel->subCels + 3, cel->sourceX+4, cel->sourceY+4, 
enc);
 
 cel->eval_dist[RoQ_ID_CCC] = 0;
 divide_bit_use = 0;
@@ -563,9 +566,10 @@ static void gather_data_for_cel(CelEvaluation *cel, 
RoqEncContext *enc,
 }
 }
 
-static void remap_codebooks(RoqEncContext *enc, RoqTempdata *tempData)
+static void remap_codebooks(RoqEncContext *enc)
 {
 RoqContext *const roq = >common;
+RoqTempData *const tempData = >tmp_data;
 int i, j, idx=0;
 
 /* Make remaps for the final codebook usage */
@@ -596,9 +600,10 @@ static void 

[FFmpeg-devel] [PATCH 4/5] avcodec/roqvideoenc: Avoid intermediate buffer

2021-02-28 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/roqvideoenc.c | 25 -
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 7ce0332f5b..d65c740d5f 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -773,7 +773,7 @@ static void reconstruct_and_encode_image(RoqEncContext *enc,
 /**
  * Create a single YUV cell from a 2x2 section of the image
  */
-static inline void frame_block_to_cell(uint8_t *block, uint8_t * const *data,
+static inline void frame_block_to_cell(int *block, uint8_t * const *data,
int top, int left, const int *stride)
 {
 int i, j, u=0, v=0;
@@ -787,14 +787,14 @@ static inline void frame_block_to_cell(uint8_t *block, 
uint8_t * const *data,
 v   += data[2][x];
 }
 
-*block++ = (u+2)/4;
-*block++ = (v+2)/4;
+*block++ = (u + 2) / 4 * CHROMA_BIAS;
+*block++ = (v + 2) / 4 * CHROMA_BIAS;
 }
 
 /**
  * Create YUV clusters for the entire image
  */
-static void create_clusters(const AVFrame *frame, int w, int h, uint8_t 
*yuvClusters)
+static void create_clusters(const AVFrame *frame, int w, int h, int *points)
 {
 int i, j, k, l;
 
@@ -802,9 +802,9 @@ static void create_clusters(const AVFrame *frame, int w, 
int h, uint8_t *yuvClus
 for (j=0; jdata,
+frame_block_to_cell(points + (l + 2*k)*6, frame->data,
 i+2*k, j+2*l, frame->linesize);
-yuvClusters += 24;
+points += 24;
 }
 }
 
@@ -853,23 +853,15 @@ static int generate_new_codebooks(RoqEncContext *enc, 
RoqTempdata *tempData)
 int max = roq->width * roq->height / 16;
 uint8_t mb2[3*4];
 roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
-uint8_t *yuvClusters=av_malloc_array(max, sizeof(int)*6*4);
 int *points = enc->points;
-int bias;
 
-if (!results4 || !yuvClusters) {
+if (!results4) {
 ret = AVERROR(ENOMEM);
 goto out;
 }
 
 /* Subsample YUV data */
-create_clusters(enc->frame_to_enc, roq->width, roq->height, yuvClusters);
-
-/* Cast to integer and apply chroma bias */
-for (i=0; iframe_to_enc, roq->width, roq->height, points);
 
 /* Create 4x4 codebooks */
 if ((ret = generate_codebook(enc, points, max,
@@ -902,7 +894,6 @@ static int generate_new_codebooks(RoqEncContext *enc, 
RoqTempdata *tempData)
 codebooks->unpacked_cb4_enlarged + i*8*8*3);
 }
 out:
-av_free(yuvClusters);
 av_free(results4);
 return ret;
 }
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 3/5] avcodec/roqvideoenc: Reuse buffers instead of alloc+free for each frame

2021-02-28 Thread Andreas Rheinhardt
In case of the cel evaluators it even allows to perform the
initialization of the source coordinates only once instead of for each
frame.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/roqvideoenc.c | 125 +--
 1 file changed, 55 insertions(+), 70 deletions(-)

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index f52c1f5454..7ce0332f5b 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -78,6 +78,28 @@
 /* The cast is useful when multiplying it by INT_MAX */
 #define ROQ_LAMBDA_SCALE ((uint64_t) FF_LAMBDA_SCALE)
 
+typedef struct SubcelEvaluation {
+int eval_dist[4];
+int best_bit_use;
+int best_coding;
+
+int subCels[4];
+motion_vect motion;
+int cbEntry;
+} SubcelEvaluation;
+
+typedef struct CelEvaluation {
+int eval_dist[4];
+int best_coding;
+
+SubcelEvaluation subCels[4];
+
+motion_vect motion;
+int cbEntry;
+
+int sourceX, sourceY;
+} CelEvaluation;
+
 typedef struct RoqEncContext {
 RoqContext common;
 AVLFG randctx;
@@ -95,6 +117,10 @@ typedef struct RoqEncContext {
 uint8_t *out_buf;
 struct RoqTempData *tmpData;
 
+CelEvaluation *cel_evals;
+int *closest_cb;
+int *points;  // Allocated together with closest_cb
+
 int first_frame;
 int quake3_compat; // Quake 3 compatibility option
 } RoqEncContext;
@@ -207,28 +233,6 @@ static inline int squared_diff_macroblock(uint8_t a[], 
uint8_t b[], int size)
 return sdiff;
 }
 
-typedef struct SubcelEvaluation {
-int eval_dist[4];
-int best_bit_use;
-int best_coding;
-
-int subCels[4];
-motion_vect motion;
-int cbEntry;
-} SubcelEvaluation;
-
-typedef struct CelEvaluation {
-int eval_dist[4];
-int best_coding;
-
-SubcelEvaluation subCels[4];
-
-motion_vect motion;
-int cbEntry;
-
-int sourceX, sourceY;
-} CelEvaluation;
-
 typedef struct RoqCodebooks {
 int numCB4;
 int numCB2;
@@ -244,8 +248,6 @@ typedef struct RoqCodebooks {
  */
 typedef struct RoqTempData
 {
-CelEvaluation *cel_evals;
-
 int f2i4[MAX_CBS_4x4];
 int i2f4[MAX_CBS_4x4];
 int f2i2[MAX_CBS_2x2];
@@ -258,27 +260,26 @@ typedef struct RoqTempData
 
 RoqCodebooks codebooks;
 
-int *closest_cb2;
 int used_option[4];
 } RoqTempdata;
 
 /**
  * Initialize cel evaluators and set their source coordinates
  */
-static int create_cel_evals(RoqContext *enc, RoqTempdata *tempData)
+static int create_cel_evals(RoqEncContext *enc)
 {
-int n=0, x, y, i;
+RoqContext *const roq = >common;
 
-tempData->cel_evals = av_malloc_array(enc->width*enc->height/64, 
sizeof(CelEvaluation));
-if (!tempData->cel_evals)
+enc->cel_evals = av_malloc_array(roq->width * roq->height / 64, 
sizeof(CelEvaluation));
+if (!enc->cel_evals)
 return AVERROR(ENOMEM);
 
 /* Map to the ROQ quadtree order */
-for (y=0; yheight; y+=16)
-for (x=0; xwidth; x+=16)
-for(i=0; i<4; i++) {
-tempData->cel_evals[n  ].sourceX = x + (i&1)*8;
-tempData->cel_evals[n++].sourceY = y + (i&2)*4;
+for (int y = 0, n = 0; y < roq->height; y += 16)
+for (int x = 0; x < roq->width; x += 16)
+for(int i = 0; i < 4; i++) {
+enc->cel_evals[n  ].sourceX = x + (i&1)*8;
+enc->cel_evals[n++].sourceY = y + (i&2)*4;
 }
 
 return 0;
@@ -464,7 +465,7 @@ static void gather_data_for_subcel(SubcelEvaluation 
*subcel, int x,
 subcel->eval_dist[RoQ_ID_CCC] = 0;
 
 for(i=0;i<4;i++) {
-subcel->subCels[i] = tempData->closest_cb2[cluster_index*4+i];
+subcel->subCels[i] = enc->closest_cb[cluster_index*4+i];
 
 get_frame_mb(enc->frame_to_enc, x+2*(i&1),
  y+(i&2), mb2, 2);
@@ -680,7 +681,7 @@ static void reconstruct_and_encode_image(RoqEncContext *enc,
 bytestream_put_byte(>out_buf, 0x0);
 
 for (i=0; icel_evals + i;
+eval = enc->cel_evals + i;
 
 x = eval->sourceX;
 y = eval->sourceY;
@@ -807,7 +808,7 @@ static void create_clusters(const AVFrame *frame, int w, 
int h, uint8_t *yuvClus
 }
 }
 
-static int generate_codebook(RoqEncContext *enc, RoqTempdata *tempdata,
+static int generate_codebook(RoqEncContext *enc,
  int *points, int inputCount, roq_cell *results,
  int size, int cbsize)
 {
@@ -815,20 +816,11 @@ static int generate_codebook(RoqEncContext *enc, 
RoqTempdata *tempdata,
 int c_size = size*size/4;
 int *buf;
 int *codebook = av_malloc_array(6*c_size, cbsize*sizeof(int));
-int *closest_cb;
+int *closest_cb = enc->closest_cb;
 
 if (!codebook)
 return AVERROR(ENOMEM);
 
-if (size == 4) {
-closest_cb = av_malloc_array(6*c_size, inputCount*sizeof(int));
-if (!closest_cb) {
-ret = AVERROR(ENOMEM);
-goto out;
-}
-} else
-closest_cb 

[FFmpeg-devel] [PATCH 2/5] avcodec/roqvideo: Use dedicated context for encoder

2021-02-28 Thread Andreas Rheinhardt
Up until now, the RoQ video decoder and encoder used the same context;
and said context contained several fields that are only used by the
encoder. This commit changes this and uses a dedicated context for the
encoder; it contains the common context as first element in order to use
functions common to the de- and encoder.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/roqvideo.h|  28 +
 libavcodec/roqvideoenc.c | 218 ++-
 2 files changed, 127 insertions(+), 119 deletions(-)

diff --git a/libavcodec/roqvideo.h b/libavcodec/roqvideo.h
index f47b2c8e6f..8318b6e5a0 100644
--- a/libavcodec/roqvideo.h
+++ b/libavcodec/roqvideo.h
@@ -22,9 +22,7 @@
 #ifndef AVCODEC_ROQVIDEO_H
 #define AVCODEC_ROQVIDEO_H
 
-#include "libavutil/lfg.h"
 #include "avcodec.h"
-#include "bytestream.h"
 
 typedef struct roq_cell {
 unsigned char y[4];
@@ -39,39 +37,15 @@ typedef struct motion_vect {
 int d[2];
 } motion_vect;
 
-struct RoqTempData;
-
 typedef struct RoqContext {
-
 const AVClass *class;
 AVCodecContext *avctx;
 AVFrame *last_frame;
 AVFrame *current_frame;
-int first_frame;
+int width, height;
 
 roq_cell cb2x2[256];
 roq_qcell cb4x4[256];
-
-int width, height;
-
-/* Encoder only data */
-AVLFG randctx;
-uint64_t lambda;
-
-motion_vect *this_motion4;
-motion_vect *last_motion4;
-
-motion_vect *this_motion8;
-motion_vect *last_motion8;
-
-unsigned int framesSinceKeyframe;
-
-const AVFrame *frame_to_enc;
-uint8_t *out_buf;
-struct RoqTempData *tmpData;
-
-int quake3_compat; // Quake 3 compatibility option
-
 } RoqContext;
 
 #define RoQ_INFO  0x1001
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index dc6a63099d..f52c1f5454 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -57,6 +57,7 @@
 #include 
 
 #include "libavutil/attributes.h"
+#include "libavutil/lfg.h"
 #include "libavutil/opt.h"
 #include "roqvideo.h"
 #include "bytestream.h"
@@ -77,6 +78,27 @@
 /* The cast is useful when multiplying it by INT_MAX */
 #define ROQ_LAMBDA_SCALE ((uint64_t) FF_LAMBDA_SCALE)
 
+typedef struct RoqEncContext {
+RoqContext common;
+AVLFG randctx;
+uint64_t lambda;
+
+motion_vect *this_motion4;
+motion_vect *last_motion4;
+
+motion_vect *this_motion8;
+motion_vect *last_motion8;
+
+unsigned int framesSinceKeyframe;
+
+const AVFrame *frame_to_enc;
+uint8_t *out_buf;
+struct RoqTempData *tmpData;
+
+int first_frame;
+int quake3_compat; // Quake 3 compatibility option
+} RoqEncContext;
+
 /* Macroblock support functions */
 static void unpack_roq_cell(roq_cell *cell, uint8_t u[4*3])
 {
@@ -143,9 +165,10 @@ static int block_sse(uint8_t * const *buf1, uint8_t * 
const *buf2, int x1, int y
 return sse;
 }
 
-static int eval_motion_dist(RoqContext *enc, int x, int y, motion_vect vect,
+static int eval_motion_dist(RoqEncContext *enc, int x, int y, motion_vect vect,
  int size)
 {
+RoqContext *const roq = >common;
 int mx=vect.d[0];
 int my=vect.d[1];
 
@@ -158,12 +181,12 @@ static int eval_motion_dist(RoqContext *enc, int x, int 
y, motion_vect vect,
 mx += x;
 my += y;
 
-if ((unsigned) mx > enc->width-size || (unsigned) my > enc->height-size)
+if ((unsigned) mx > roq->width-size || (unsigned) my > roq->height-size)
 return INT_MAX;
 
-return block_sse(enc->frame_to_enc->data, enc->last_frame->data, x, y,
+return block_sse(enc->frame_to_enc->data, roq->last_frame->data, x, y,
  mx, my,
- enc->frame_to_enc->linesize, enc->last_frame->linesize,
+ enc->frame_to_enc->linesize, roq->last_frame->linesize,
  size);
 }
 
@@ -307,7 +330,7 @@ static int index_mb(uint8_t cluster[], uint8_t cb[], int 
numCB,
 } \
 } while(0)
 
-static void motion_search(RoqContext *enc, int blocksize)
+static void motion_search(RoqEncContext *enc, int blocksize)
 {
 static const motion_vect offsets[8] = {
 {{ 0,-1}},
@@ -320,6 +343,7 @@ static void motion_search(RoqContext *enc, int blocksize)
 {{ 1, 1}},
 };
 
+RoqContext *const roq = >common;
 int diff, lowestdiff, oldbest;
 int off[3];
 motion_vect bestpick = {{0,0}};
@@ -328,8 +352,7 @@ static void motion_search(RoqContext *enc, int blocksize)
 motion_vect *last_motion;
 motion_vect *this_motion;
 motion_vect vect, vect2;
-
-int max=(enc->width/blocksize)*enc->height/blocksize;
+const int max = (roq->width / blocksize) * roq->height / blocksize;
 
 if (blocksize == 4) {
 last_motion = enc->last_motion4;
@@ -339,17 +362,17 @@ static void motion_search(RoqContext *enc, int blocksize)
 this_motion = enc->this_motion8;
 }
 
-for (i=0; iheight; i+=blocksize)
-for (j=0; jwidth; j+=blocksize) {
+for (i = 0; i< 

[FFmpeg-devel] [PATCH 1/5] tests/fate: Don't keep unnecessary temp files

2021-02-28 Thread Andreas Rheinhardt
Some FATE tests use files created by other FATE tests as input files;
this mostly affects the seek tests which use files from vsynth_lena as
well as acodec-pcm as input files. In order to make this possible the
temporary files of all the vsynth* and all acodec-pcm tests are kept.
Yet only a fraction of these files are actually used. This commit
changes this to only keep the files that are actually needed for other
tests. This reduces the size of the tests/data/fate folder after a full
FATE run from 2024727441B to 138739312B.

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/acodec.mak   | 2 +-
 tests/fate/filter-video.mak | 1 +
 tests/fate/seek.mak | 1 +
 tests/fate/vcodec.mak   | 4 ++--
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/fate/acodec.mak b/tests/fate/acodec.mak
index 35b597859c..1b8c32b163 100644
--- a/tests/fate/acodec.mak
+++ b/tests/fate/acodec.mak
@@ -1,6 +1,6 @@
 fate-acodec-%: CODEC = $(@:fate-acodec-%=%)
 fate-acodec-%: SRC = tests/data/asynth-44100-2.wav
-fate-acodec-%: CMD = enc_dec wav $(SRC) $(FMT) "-b:a 128k -c $(CODEC) 
$(ENCOPTS)" wav "-c pcm_s16le $(DECOPTS)" -keep
+fate-acodec-%: CMD = enc_dec wav $(SRC) $(FMT) "-b:a 128k -c $(CODEC) 
$(ENCOPTS)" wav "-c pcm_s16le $(DECOPTS)" "$(KEEP_OVERRIDE)"
 fate-acodec-%: CMP_UNIT = 2
 fate-acodec-%: REF = $(SRC_PATH)/tests/ref/acodec/$(@:fate-acodec-%=%)
 
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 9c7e3489f4..a0d645cc4a 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -564,6 +564,7 @@ fate-filter-pad: CMD = video_filter 
"pad=iw*1.5:ih*1.5:iw*0.3:ih*0.2"
 FATE_FILTER_PP = fate-filter-pp fate-filter-pp1 fate-filter-pp2 
fate-filter-pp3 fate-filter-pp4 fate-filter-pp5 fate-filter-pp6
 FATE_FILTER_VSYNTH-$(CONFIG_PP_FILTER) += $(FATE_FILTER_PP)
 $(FATE_FILTER_PP): fate-vsynth1-mpeg4-qprd
+fate-vsynth1-mpeg4-qprd: KEEP_OVERRIDE= -keep
 
 fate-filter-pp:  CMD = framecrc -flags bitexact -export_side_data venc_params 
-idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 
5 -flags +bitexact -vf "pp=be/hb/vb/tn/l5/al"
 fate-filter-pp1: CMD = video_filter "pp=fq|4/be/hb/vb/tn/l5/al"
diff --git a/tests/fate/seek.mak b/tests/fate/seek.mak
index 98d2b54674..5efec32702 100644
--- a/tests/fate/seek.mak
+++ b/tests/fate/seek.mak
@@ -270,6 +270,7 @@ FATE_SEEK_EXTRA += $(FATE_SEEK_EXTRA-yes)
 $(FATE_SEEK) $(FATE_SAMPLES_SEEK) $(FATE_SEEK_EXTRA): 
libavformat/tests/seek$(EXESUF)
 $(FATE_SEEK) $(FATE_SAMPLES_SEEK): CMD = run libavformat/tests/seek$(EXESUF) 
$(TARGET_PATH)/tests/data/$(SRC)
 $(FATE_SEEK) $(FATE_SAMPLES_SEEK): fate-seek-%: fate-%
+$(subst fate-seek-,fate-,$(FATE_SAMPLES_SEEK) $(FATE_SEEK)): KEEP_OVERRIDE = 
-keep
 fate-seek-%: REF = $(SRC_PATH)/tests/ref/seek/$(@:fate-seek-%=%)
 
 FATE_AVCONV += $(FATE_SEEK)
diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak
index 1e9c0d5647..ef892366eb 100644
--- a/tests/fate/vcodec.mak
+++ b/tests/fate/vcodec.mak
@@ -4,8 +4,8 @@ fate-vsynth_lena-%: SRC = tests/data/vsynth_lena.yuv
 fate-vsynth3-%: SRC = tests/data/vsynth3.yuv
 fate-vsynth%: CODEC = $(word 3, $(subst -, ,$(@)))
 fate-vsynth%: FMT = avi
-fate-vsynth%: CMD = enc_dec "rawvideo -s 352x288 -pix_fmt yuv420p 
$(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s 352x288 
-pix_fmt yuv420p -vsync 0 $(DECOPTS)" -keep "$(DECINOPTS)"
-fate-vsynth3-%: CMD = enc_dec "rawvideo -s $(FATEW)x$(FATEH) -pix_fmt yuv420p 
$(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s 
$(FATEW)x$(FATEH) -pix_fmt yuv420p -vsync 0 $(DECOPTS)" -keep "$(DECINOPTS)"
+fate-vsynth%: CMD = enc_dec "rawvideo -s 352x288 -pix_fmt yuv420p 
$(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s 352x288 
-pix_fmt yuv420p -vsync 0 $(DECOPTS)" "$(KEEP_OVERRIDE)" "$(DECINOPTS)"
+fate-vsynth3-%: CMD = enc_dec "rawvideo -s $(FATEW)x$(FATEH) -pix_fmt yuv420p 
$(RAWDECOPTS)" $(SRC) $(FMT) "-c $(CODEC) $(ENCOPTS)" rawvideo "-s 
$(FATEW)x$(FATEH) -pix_fmt yuv420p -vsync 0 $(DECOPTS)" "" "$(DECINOPTS)"
 fate-vsynth%: CMP_UNIT = 1
 fate-vsynth%: REF = $(SRC_PATH)/tests/ref/vsynth/$(@:fate-%=%)
 
-- 
2.27.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] x11grab: capture a window instead of the whole screen

2021-02-28 Thread Andriy Gelman
On Sun, 28. Feb 13:57, sgerwk-at-aol@ffmpeg.org wrote:
> Hi,
> 
> On Sat, 27 Feb 2021, Andriy Gelman wrote:
> 
> > On Mon, 22. Feb 17:53, sgerwk-at-aol@ffmpeg.org wrote:
> > > Hi,
> > > 
> > > On Sun, 21 Feb 2021, Andriy Gelman wrote:
> > > > Hi,
> > > > > Thanks for updating the patch. Sorry for the delay in getting
> > > you some feedback..
> > > > > When I tested with -show_mouse 1 -show_region 1 -window_id xx,
> > > the mouse and
> > > > border get drawn in the wrong place. There is around (0.6cm error). Can 
> > > > you
> > > > reproduce?
> > > >
> > > 
> > > I didn't notice the problem because the wm I use places the top-level
> > > windows in a window of the same size - at position 0,0. Still, I could
> > > reproduce it by capturing a subwindow.
> > > 
> > > The problem was indeed what you suspected: geo->x,geo->y is the position
> > > inside the parent, but translate includes it already as it is the position
> > > within the root window.
> > > 
> > > > > From e13c1be7abd6989b3ad80fd8086fe6a0819fd810 Mon Sep 17 00:00:00 2001
> > > > > From: sgerwk 
> > > > > Date: Wed, 10 Feb 2021 17:36:00 +0100
> > > > > Subject: [PATCH] libavdevice/xcbgrab: option for grabbing a window 
> > > > > instead of
> > > > >  desktop
> > > > > > > ---
> > > > >  doc/indevs.texi   | 14 +++-
> > > > >  libavdevice/xcbgrab.c | 79 
> > > > > ---
> > > > >  2 files changed, 72 insertions(+), 21 deletions(-)
> > > > > > > diff --git a/doc/indevs.texi b/doc/indevs.texi
> > > > > index 3924d03..48fd2b1 100644
> > > > > --- a/doc/indevs.texi
> > > > > +++ b/doc/indevs.texi
> > > > > @@ -1564,8 +1564,20 @@ With @var{follow_mouse}:
> > > > >  ffmpeg -f x11grab -follow_mouse centered -show_region 1 -framerate 
> > > > > 25 -video_size cif -i :0.0 out.mpg
> > > > >  @end example
> > > > > > > +@item window_id
> > > > > +Grab this window, instead of the whole screen.
> > > > > +
> > > > > +The id of a window can be found by xwininfo(1), possibly with 
> > > > > options -tree and
> > > > > +-root.
> > > > > +
> > > > > +If the window is later enlarged, the new area is not recorded. Video 
> > > > > ends when
> > > > > +the window is closed, unmapped (i.e., iconified) or shrunk beyond 
> > > > > the video
> > > > > +size (which defaults to the initial window size).
> > > > > +
> > > > > +This option disables options @option{follow_mouse} and 
> > > > > @option{select_region}.
> > > > > +
> > > > >  @item video_size
> > > > > -Set the video frame size. Default is the full desktop.
> > > > > +Set the video frame size. Default is the full desktop or window.
> > > > > > >  @item grab_x
> > > > >  @item grab_y
> > > > > diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
> > > > > index be5d5ea..7697090 100644
> > > > > --- a/libavdevice/xcbgrab.c
> > > > > +++ b/libavdevice/xcbgrab.c
> > > > > @@ -60,6 +60,8 @@ typedef struct XCBGrabContext {
> > > > >  AVRational time_base;
> > > > >  int64_t frame_duration;
> > > > > > > +xcb_window_t window_id;
> > > > > > +int win_x, win_y;
> > > > > The position of the window is always recalculated so I don't
> > > think win_x and
> > > > win_y should be part of the of XCBGrabContext.
> > > >
> > > 
> > > Done. Some functions now require win_x and win_y because they no longer
> > > find them in XCBGrabContext.
> > > 
> > > > >  int x, y;
> > > > >  int width, height;
> > > > >  int frame_size;
> > > > > @@ -82,6 +84,7 @@ typedef struct XCBGrabContext {
> > > > >  #define OFFSET(x) offsetof(XCBGrabContext, x)
> > > > >  #define D AV_OPT_FLAG_DECODING_PARAM
> > > > >  static const AVOption options[] = {
> > > > > +{ "window_id", "Window to capture", OFFSET(window_id), 
> > > > > AV_OPT_TYPE_INT, { .i64 = XCB_NONE }, 0, UINT32_MAX, D },
> > > > >  { "x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, { 
> > > > > .i64 = 0 }, 0, INT_MAX, D },
> > > > >  { "y", "Initial y coordinate.", OFFSET(y), AV_OPT_TYPE_INT, { 
> > > > > .i64 = 0 }, 0, INT_MAX, D },
> > > > >  { "grab_x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, 
> > > > > { .i64 = 0 }, 0, INT_MAX, D },
> > > > > @@ -157,7 +160,7 @@ static int xcbgrab_frame(AVFormatContext *s, 
> > > > > AVPacket *pkt)
> > > > >  XCBGrabContext *c = s->priv_data;
> > > > >  xcb_get_image_cookie_t iq;
> > > > >  xcb_get_image_reply_t *img;
> > > > > -xcb_drawable_t drawable = c->screen->root;
> > > > > +xcb_drawable_t drawable = c->window_id;
> > > > >  xcb_generic_error_t *e = NULL;
> > > > >  uint8_t *data;
> > > > >  int length;
> > > > > @@ -267,7 +270,7 @@ static int xcbgrab_frame_shm(AVFormatContext *s, 
> > > > > AVPacket *pkt)
> > > > >  XCBGrabContext *c = s->priv_data;
> > > > >  xcb_shm_get_image_cookie_t iq;
> > > > >  xcb_shm_get_image_reply_t *img;
> > > > > -xcb_drawable_t drawable = c->screen->root;
> > > > > +xcb_drawable_t drawable = c->window_id;
> > > > >  

Re: [FFmpeg-devel] [PATCH 11/19] avformat/matroskadec: Support FlagOriginal

2021-02-28 Thread Andreas Rheinhardt
Anton Khirnov:
> Quoting Andreas Rheinhardt (2021-02-22 05:05:29)
>> Andreas Rheinhardt:
>>> Needs a CountedElement in order to distinguish the case of the element
>>> not being present and the element being present with a value of zero.
>>>
>>> Signed-off-by: Andreas Rheinhardt 
>>> ---
>>>  libavformat/matroska.h| 1 +
>>>  libavformat/matroskadec.c | 7 ++-
>>>  2 files changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavformat/matroska.h b/libavformat/matroska.h
>>> index 191c4f6149..8ab87eff20 100644
>>> --- a/libavformat/matroska.h
>>> +++ b/libavformat/matroska.h
>>> @@ -100,6 +100,7 @@
>>>  #define MATROSKA_ID_TRACKFLAGDEFAULT 0x88
>>>  #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA
>>>  #define MATROSKA_ID_TRACKFLAGLACING 0x9C
>>> +#define MATROSKA_ID_TRACKFLAGORIGINAL 0x55AE
>>>  #define MATROSKA_ID_TRACKMINCACHE 0x6DE7
>>>  #define MATROSKA_ID_TRACKMAXCACHE 0x6DF8
>>>  #define MATROSKA_ID_TRACKDEFAULTDURATION 0x23E383
>>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>>> index fa266fcaec..f15bf8f9d2 100644
>>> --- a/libavformat/matroskadec.c
>>> +++ b/libavformat/matroskadec.c
>>> @@ -251,6 +251,7 @@ typedef struct MatroskaTrack {
>>>  uint64_t flag_default;
>>>  uint64_t flag_forced;
>>>  uint64_t flag_comment;
>>> +CountedElement flag_original;
>>>  uint64_t seek_preroll;
>>>  MatroskaTrackVideo video;
>>>  MatroskaTrackAudio audio;
>>> @@ -410,7 +411,7 @@ typedef struct MatroskaDemuxContext {
>>>  // incomplete type (6.7.2 in C90, 6.9.2 in C99).
>>>  // Removing the sizes breaks MSVC.
>>>  static EbmlSyntax ebml_syntax[3], matroska_segment[9], 
>>> matroska_track_video_color[15], matroska_track_video[19],
>>> -  matroska_track[28], matroska_track_encoding[6], 
>>> matroska_track_encodings[2],
>>> +  matroska_track[29], matroska_track_encoding[6], 
>>> matroska_track_encodings[2],
>>>matroska_track_combine_planes[2], 
>>> matroska_track_operation[2], matroska_tracks[2],
>>>matroska_attachments[2], matroska_chapter_entry[9], 
>>> matroska_chapter[6], matroska_chapters[2],
>>>matroska_index_entry[3], matroska_index[2], 
>>> matroska_tag[3], matroska_tags[2], matroska_seekhead[2],
>>> @@ -575,6 +576,7 @@ static EbmlSyntax matroska_track[] = {
>>>  { MATROSKA_ID_TRACKFLAGCOMMENTARY,   EBML_UINT,  0, 0, 
>>> offsetof(MatroskaTrack, flag_comment), { .u = 0 } },
>>>  { MATROSKA_ID_TRACKFLAGDEFAULT,  EBML_UINT,  0, 0, 
>>> offsetof(MatroskaTrack, flag_default), { .u = 1 } },
>>>  { MATROSKA_ID_TRACKFLAGFORCED,   EBML_UINT,  0, 0, 
>>> offsetof(MatroskaTrack, flag_forced),  { .u = 0 } },
>>> +{ MATROSKA_ID_TRACKFLAGORIGINAL, EBML_UINT,  1, 0, 
>>> offsetof(MatroskaTrack, flag_original), {.u = 0 } },
>>>  { MATROSKA_ID_TRACKVIDEO,EBML_NEST,  0, 0, 
>>> offsetof(MatroskaTrack, video),{ .n = matroska_track_video } },
>>>  { MATROSKA_ID_TRACKAUDIO,EBML_NEST,  0, 0, 
>>> offsetof(MatroskaTrack, audio),{ .n = matroska_track_audio } },
>>>  { MATROSKA_ID_TRACKOPERATION,EBML_NEST,  0, 0, 
>>> offsetof(MatroskaTrack, operation),{ .n = matroska_track_operation } },
>>> @@ -2746,6 +2748,9 @@ static int matroska_parse_tracks(AVFormatContext *s)
>>>  st->disposition |= AV_DISPOSITION_FORCED;
>>>  if (track->flag_comment)
>>>  st->disposition |= AV_DISPOSITION_COMMENT;
>>> +if (track->flag_original.count > 0)
>>> +st->disposition |= track->flag_original.el.u ? 
>>> AV_DISPOSITION_ORIGINAL
>>> + : 
>>> AV_DISPOSITION_DUB;
>>>  
>>>  if (!st->codecpar->extradata) {
>>>  if (extradata) {
>>>
>> Ridley Combs reviewed this set via IRC and approved it with one
>> exception: It makes no sense to use AV_DISPOSITION_DUB for something
>> else than an audio track, so if FlagOriginal is set to zero (meaning the
>> track is not in the content's original language), it should not be
>> exported at all. And the muxer should ignore AV_DISPOSITION_DUB for
>> non-audio-tracks. How do others think about this?
> 
> AV_DISPOSITION_DUB is not documented, so you can interpret it pretty
> widely. One interpretation that I can think of is:
> - there are two audio tracks - let's say japanese original and english
>   dub
> - there are also two english subtitle tracks:
> * one that translates everything, meant to be used with the original
>   audio;
> * the other one translating just the text in the video (and possibly
>   things that were meant to be subtitled in the original, like
>   speech in Klingon), meant to be used with the english dub
> 
> Then it can make sense to tag the second subtitle track with
> AV_DISPOSITION_DUB to indicate it is supposed to be used with the dubbed
> audio track.
> 
That is also pretty much what I thought; furthermore, 

Re: [FFmpeg-devel] [PATCH] avformat/wtvdec: Fix reading OLE dates on BE

2021-02-28 Thread Andreas Rheinhardt
Peter Ross:
> On Sun, Feb 28, 2021 at 04:01:21AM +0100, Andreas Rheinhardt wrote:
>> The WTV demuxer's oledata_to_iso8601 reads a value via avio_rl64
>> and reinterprets it as a double via av_int2double. This does not
>> work on big endian systems. So swap it to native endianness before
>> av_int2double.
>>
>> law-and-order-partial.wtv from the FATE-suite exhibited the problem.
>>
>> Thanks-to: Andriy Gelman 
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavformat/wtvdec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
>> index 7def9d2348..bb84e5dc9f 100644
>> --- a/libavformat/wtvdec.c
>> +++ b/libavformat/wtvdec.c
>> @@ -418,7 +418,7 @@ static int crazytime_to_iso8601(char *buf, int buf_size, 
>> int64_t value)
>>   */
>>  static int oledate_to_iso8601(char *buf, int buf_size, int64_t value)
>>  {
>> -time_t t = (av_int2double(value) - 25569.0) * 86400;
>> +time_t t = (av_int2double(av_le2ne64(value)) - 25569.0) * 86400;
>>  struct tm tmbuf;
>>  struct tm *tm= gmtime_r(, );
>>  if (!tm)
>> -- 
>> 2.27.0
> 
> ok, please apply.
> 
Unfortunately, I was wrong. avio_rl64 already implicitly performs the
necessary byteswap. The actual problem is that the date in
law-and-order-partial.wtv (-12-31 23:59:59) is outside the range
representable by a 32bit time_t. So we have to write our own gmtime_r to
fix this. Btw: A non-representable float->int conversion is undefined
behaviour.
(The Matroska fate test which started all this could of course also be
fixed by simply deleting the relevant metadata entry, but I don't want
to do this.)

- Andreas

PS: Thanks to Andriy for his continued involvement in the investigation
of this. And for pointing out my error.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat/wtvdec: Fix reading OLE dates on BE

2021-02-28 Thread Andriy Gelman
On Sun, 28. Feb 04:01, Andreas Rheinhardt wrote:
> The WTV demuxer's oledata_to_iso8601 reads a value via avio_rl64
> and reinterprets it as a double via av_int2double. This does not
> work on big endian systems. So swap it to native endianness before
> av_int2double.
> 
> law-and-order-partial.wtv from the FATE-suite exhibited the problem.
> 
> Thanks-to: Andriy Gelman 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/wtvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> index 7def9d2348..bb84e5dc9f 100644
> --- a/libavformat/wtvdec.c
> +++ b/libavformat/wtvdec.c
> @@ -418,7 +418,7 @@ static int crazytime_to_iso8601(char *buf, int buf_size, 
> int64_t value)
>   */
>  static int oledate_to_iso8601(char *buf, int buf_size, int64_t value)
>  {
> -time_t t = (av_int2double(value) - 25569.0) * 86400;
> +time_t t = (av_int2double(av_le2ne64(value)) - 25569.0) * 86400;
>  struct tm tmbuf;
>  struct tm *tm= gmtime_r(, );
>  if (!tm)

I don't think that's correct because the output of avio_rl64() is already native
endian.

The result of:
double a = (av_int2double(value) - 25569.0) * 86400;
is consistent on my x86_64 and PPC64.

The failing fate test seems to be because sizeof(time_t) = 4 on the BE PPC64
docker instance, but is 8 on my x86_64.

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

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

[FFmpeg-devel] [PATCH] lavc/alsdec: Add NEON optimizations

2021-02-28 Thread Thilo Borgmann
Hi,

it's my first attempt to do some assembly, it might still includes some dont's 
of the asm world...
Tested with gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

Speed-wise, it sees a drop for small prediction orders until around 10 or 11.
Well, the maximum prediction order is 1023.
I therefore checked with the "real-world" samples from the fate-suite, which 
suggests low prediction orders are non-dominant:



pred_order = 9, gain: -6%

als_reconstruct_all_c: 15898.2
als_reconstruct_all_neon: 16460.0


pred_order = 15,gain:  35%

als_reconstruct_all_c: 34843.7
als_reconstruct_all_neon: 22840.5


pred_order = {7..17}, gain: 23%

als_reconstruct_all_c: 26645.2
als_reconstruct_all_neon: 20635.2




patched: 

TESTmpeg4-als-conformance-00
TESTmpeg4-als-conformance-01
TESTmpeg4-als-conformance-02
TESTmpeg4-als-conformance-03
TESTmpeg4-als-conformance-04
TESTmpeg4-als-conformance-05
TESTmpeg4-als-conformance-09

real0m1.006s
user0m0.903s
sys 0m0.112s


real0m1.007s
user0m0.889s
sys 0m0.127s

real0m1.005s
user0m0.897s
sys 0m0.117s


unpatched:

TESTmpeg4-als-conformance-00
TESTmpeg4-als-conformance-01
TESTmpeg4-als-conformance-02
TESTmpeg4-als-conformance-03
TESTmpeg4-als-conformance-04
TESTmpeg4-als-conformance-05
TESTmpeg4-als-conformance-09

real0m1.204s
user0m1.122s
sys 0m0.091s

real0m1.204s
user0m1.098s
sys 0m0.115s

real0m1.205s
user0m1.077s
sys 0m0.137s


-Thilo
From 42a4d5f581570b0d292b63bb193e3e8da9645fcd Mon Sep 17 00:00:00 2001
From: Thilo Borgmann 
Date: Sun, 28 Feb 2021 14:13:32 +
Subject: [PATCH] lavc/alsdec: Add NEON optimizations

---
 configure|   3 +-
 libavcodec/Makefile  |   1 +
 libavcodec/aarch64/Makefile  |   2 +
 libavcodec/aarch64/alsdsp_init_aarch64.c |  35 +
 libavcodec/aarch64/alsdsp_neon.S | 155 +++
 libavcodec/alsdec.c  |  13 +-
 libavcodec/alsdsp.c  |  49 +++
 libavcodec/alsdsp.h  |  35 +
 tests/checkasm/Makefile  |   1 +
 tests/checkasm/alsdsp.c  |  81 
 tests/checkasm/checkasm.c|   3 +
 tests/checkasm/checkasm.h|   1 +
 12 files changed, 370 insertions(+), 9 deletions(-)
 create mode 100644 libavcodec/aarch64/alsdsp_init_aarch64.c
 create mode 100644 libavcodec/aarch64/alsdsp_neon.S
 create mode 100644 libavcodec/alsdsp.c
 create mode 100644 libavcodec/alsdsp.h
 create mode 100644 tests/checkasm/alsdsp.c

diff --git a/configure b/configure
index 900505756b..30875f87f2 100755
--- a/configure
+++ b/configure
@@ -2345,6 +2345,7 @@ CONFIG_EXTRA="
 aandcttables
 ac3dsp
 adts_header
+alsdsp
 atsc_a53
 audio_frame_queue
 audiodsp
@@ -2664,7 +2665,7 @@ adpcm_g722_decoder_select="g722dsp"
 adpcm_g722_encoder_select="g722dsp"
 aic_decoder_select="golomb idctdsp"
 alac_encoder_select="lpc"
-als_decoder_select="bswapdsp"
+als_decoder_select="bswapdsp alsdsp"
 amrnb_decoder_select="lsp"
 amrwb_decoder_select="lsp"
 amv_decoder_select="sp5x_decoder exif"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 35318f4f4d..8a23ab8ea0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -62,6 +62,7 @@ OBJS = ac3_parser.o   
  \
 OBJS-$(CONFIG_AANDCTTABLES)+= aandcttab.o
 OBJS-$(CONFIG_AC3DSP)  += ac3dsp.o ac3.o ac3tab.o
 OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o
+OBJS-$(CONFIG_ALSDSP)  += alsdsp.o
 OBJS-$(CONFIG_AMF) += amfenc.o
 OBJS-$(CONFIG_AUDIO_FRAME_QUEUE)   += audio_frame_queue.o
 OBJS-$(CONFIG_ATSC_A53)+= atsc_a53.o
diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index f6434e40da..a7493c7c2b 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -1,4 +1,5 @@
 # subsystems
+OBJS-$(CONFIG_ALSDSP)   += aarch64/alsdsp_init_aarch64.o
 OBJS-$(CONFIG_FFT)  += aarch64/fft_init_aarch64.o
 OBJS-$(CONFIG_FMTCONVERT)   += aarch64/fmtconvert_init.o
 OBJS-$(CONFIG_H264CHROMA)   += aarch64/h264chroma_init_aarch64.o
@@ -52,6 +53,7 @@ NEON-OBJS-$(CONFIG_VP8DSP)  += 
aarch64/vp8dsp_neon.o
 
 # decoders/encoders
 NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_neon.o
+NEON-OBJS-$(CONFIG_ALS_DECODER) += aarch64/alsdsp_neon.o
 NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
 NEON-OBJS-$(CONFIG_OPUS_DECODER)+= aarch64/opusdsp_neon.o
 NEON-OBJS-$(CONFIG_VORBIS_DECODER)  += aarch64/vorbisdsp_neon.o
diff --git a/libavcodec/aarch64/alsdsp_init_aarch64.c 
b/libavcodec/aarch64/alsdsp_init_aarch64.c
new file mode 100644
index 00..130b1a615e
--- /dev/null
+++ 

Re: [FFmpeg-devel] [PATCH 2/5] avdevice/alsa_dec: make sure we have enough data in non-blocking mode

2021-02-28 Thread Nicolas George
Marton Balint (12021-02-28):
> Robust how? For non-blocking mode that would mean you have to keep the read
> data in the context if you read less than period size. Doable, but I wanted
> to avoid it.

That is exactly what I am suggesting. It does not rely on less tested
functions like snd_pcm_avail() (I have observed bugs with this kind of
functions and some of the infrastructure plugins), and it does not
require starting the PCM manually at seemingly random places in the
code.

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 2/5] avdevice/alsa_dec: make sure we have enough data in non-blocking mode

2021-02-28 Thread Marton Balint



On Sun, 28 Feb 2021, Nicolas George wrote:


Marton Balint (12021-02-21):

Otherwise we might return 1-2 samples per packet if av_read_frame() call rate is
only sligthly less than the stream sample rate.

Signed-off-by: Marton Balint 
---
 libavdevice/alsa_dec.c | 18 ++
 1 file changed, 18 insertions(+)


Looping snd_pcm_readi() seems like a more robust solution to this issue.


Robust how? For non-blocking mode that would mean you have to keep the 
read data in the context if you read less than period size. Doable, but 
I wanted to avoid it.


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 2/5] avdevice/alsa_dec: make sure we have enough data in non-blocking mode

2021-02-28 Thread Nicolas George
Marton Balint (12021-02-21):
> Otherwise we might return 1-2 samples per packet if av_read_frame() call rate 
> is
> only sligthly less than the stream sample rate.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavdevice/alsa_dec.c | 18 ++
>  1 file changed, 18 insertions(+)

Looping snd_pcm_readi() seems like a more robust solution to this issue.

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/5] avdevice/alsa_dec: do not set codecpar frame_size

2021-02-28 Thread Nicolas George
Marton Balint (12021-02-21):
> Constant frame size is not guaranteed if the read call interrupted by a 
> signal,
> or if non-blocking mode is used.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavdevice/alsa_dec.c | 1 -
>  1 file changed, 1 deletion(-)

Should be ok.

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] x11grab: capture a window instead of the whole screen

2021-02-28 Thread sgerwk-at-aol . com

Hi,

On Sat, 27 Feb 2021, Andriy Gelman wrote:


On Mon, 22. Feb 17:53, sgerwk-at-aol@ffmpeg.org wrote:

Hi,

On Sun, 21 Feb 2021, Andriy Gelman wrote:
> Hi,
> 
> Thanks for updating the patch. Sorry for the delay in getting you some feedback..
> 
> When I tested with -show_mouse 1 -show_region 1 -window_id xx, the mouse and

> border get drawn in the wrong place. There is around (0.6cm error). Can you
> reproduce?
> 


I didn't notice the problem because the wm I use places the top-level
windows in a window of the same size - at position 0,0. Still, I could
reproduce it by capturing a subwindow.

The problem was indeed what you suspected: geo->x,geo->y is the position
inside the parent, but translate includes it already as it is the position
within the root window.

> > From e13c1be7abd6989b3ad80fd8086fe6a0819fd810 Mon Sep 17 00:00:00 2001
> > From: sgerwk 
> > Date: Wed, 10 Feb 2021 17:36:00 +0100
> > Subject: [PATCH] libavdevice/xcbgrab: option for grabbing a window instead 
of
> >  desktop
> > 
> > ---

> >  doc/indevs.texi   | 14 +++-
> >  libavdevice/xcbgrab.c | 79 ---
> >  2 files changed, 72 insertions(+), 21 deletions(-)
> > 
> > diff --git a/doc/indevs.texi b/doc/indevs.texi

> > index 3924d03..48fd2b1 100644
> > --- a/doc/indevs.texi
> > +++ b/doc/indevs.texi
> > @@ -1564,8 +1564,20 @@ With @var{follow_mouse}:
> >  ffmpeg -f x11grab -follow_mouse centered -show_region 1 -framerate 25 
-video_size cif -i :0.0 out.mpg
> >  @end example
> > 
> > +@item window_id

> > +Grab this window, instead of the whole screen.
> > +
> > +The id of a window can be found by xwininfo(1), possibly with options 
-tree and
> > +-root.
> > +
> > +If the window is later enlarged, the new area is not recorded. Video ends 
when
> > +the window is closed, unmapped (i.e., iconified) or shrunk beyond the video
> > +size (which defaults to the initial window size).
> > +
> > +This option disables options @option{follow_mouse} and 
@option{select_region}.
> > +
> >  @item video_size
> > -Set the video frame size. Default is the full desktop.
> > +Set the video frame size. Default is the full desktop or window.
> > 
> >  @item grab_x

> >  @item grab_y
> > diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
> > index be5d5ea..7697090 100644
> > --- a/libavdevice/xcbgrab.c
> > +++ b/libavdevice/xcbgrab.c
> > @@ -60,6 +60,8 @@ typedef struct XCBGrabContext {
> >  AVRational time_base;
> >  int64_t frame_duration;
> > 
> > +xcb_window_t window_id;
> 
> > +int win_x, win_y;
> 
> The position of the window is always recalculated so I don't think win_x and

> win_y should be part of the of XCBGrabContext.
> 


Done. Some functions now require win_x and win_y because they no longer
find them in XCBGrabContext.

> >  int x, y;
> >  int width, height;
> >  int frame_size;
> > @@ -82,6 +84,7 @@ typedef struct XCBGrabContext {
> >  #define OFFSET(x) offsetof(XCBGrabContext, x)
> >  #define D AV_OPT_FLAG_DECODING_PARAM
> >  static const AVOption options[] = {
> > +{ "window_id", "Window to capture", OFFSET(window_id), 
AV_OPT_TYPE_INT, { .i64 = XCB_NONE }, 0, UINT32_MAX, D },
> >  { "x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, INT_MAX, D },
> >  { "y", "Initial y coordinate.", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, INT_MAX, D },
> >  { "grab_x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, INT_MAX, D },
> > @@ -157,7 +160,7 @@ static int xcbgrab_frame(AVFormatContext *s, AVPacket 
*pkt)
> >  XCBGrabContext *c = s->priv_data;
> >  xcb_get_image_cookie_t iq;
> >  xcb_get_image_reply_t *img;
> > -xcb_drawable_t drawable = c->screen->root;
> > +xcb_drawable_t drawable = c->window_id;
> >  xcb_generic_error_t *e = NULL;
> >  uint8_t *data;
> >  int length;
> > @@ -267,7 +270,7 @@ static int xcbgrab_frame_shm(AVFormatContext *s, 
AVPacket *pkt)
> >  XCBGrabContext *c = s->priv_data;
> >  xcb_shm_get_image_cookie_t iq;
> >  xcb_shm_get_image_reply_t *img;
> > -xcb_drawable_t drawable = c->screen->root;
> > +xcb_drawable_t drawable = c->window_id;
> >  xcb_generic_error_t *e = NULL;
> >  AVBufferRef *buf;
> >  xcb_shm_seg_t segment;
> > @@ -355,17 +358,17 @@ static void xcbgrab_draw_mouse(AVFormatContext *s, 
AVPacket *pkt,
> >  cx = ci->x - ci->xhot;
> >  cy = ci->y - ci->yhot;
> > 
> > -x = FFMAX(cx, gr->x);

> > -y = FFMAX(cy, gr->y);
> > +x = FFMAX(cx, gr->win_x + gr->x);
> > +y = FFMAX(cy, gr->win_y + gr->y);
> > 
> > -w = FFMIN(cx + ci->width,  gr->x + gr->width)  - x;

> > -h = FFMIN(cy + ci->height, gr->y + gr->height) - y;
> > +w = FFMIN(cx + ci->width,  gr->win_x + gr->x + gr->width)  - x;
> > +h = FFMIN(cy + ci->height, gr->win_y + gr->y + gr->height) - y;
> > 
> >  c_off = x - cx;

> > -i_off = x - gr->x;
> > +i_off = x - gr->x - gr->win_x;
> > 
> >  

[FFmpeg-devel] [PATCH 3/3] avcodec/exr: add lut oriented half to float conversion code

2021-02-28 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/exr.c| 90 +
 libavcodec/half2float.h | 74 +
 2 files changed, 103 insertions(+), 61 deletions(-)
 create mode 100644 libavcodec/half2float.h

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index e0e525e53c..646b06bad9 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -29,8 +29,6 @@
  *
  * For more information on the OpenEXR format, visit:
  *  http://openexr.com/
- *
- * exr_half2float() is credited to Aaftab Munshi, Dan Ginsburg, Dave Shreiner.
  */
 
 #include 
@@ -54,6 +52,7 @@
 #include "exrdsp.h"
 #include "get_bits.h"
 #include "internal.h"
+#include "half2float.h"
 #include "mathops.h"
 #include "thread.h"
 
@@ -190,6 +189,10 @@ typedef struct EXRContext {
 enum AVColorTransferCharacteristic apply_trc_type;
 float gamma;
 union av_intfloat32 gamma_table[65536];
+
+uint32_t mantissatable[2048];
+uint32_t exponenttable[64];
+uint16_t offsettable[64];
 } EXRContext;
 
 /* -15 stored using a single precision bias of 127 */
@@ -204,55 +207,6 @@ typedef struct EXRContext {
 
 #define HALF_FLOAT_MAX_BIASED_EXP (0x1F << 10)
 
-/**
- * Convert a half float as a uint16_t into a full float.
- *
- * @param hf half float as uint16_t
- *
- * @return float value
- */
-static union av_intfloat32 exr_half2float(uint16_t hf)
-{
-unsigned int sign = (unsigned int) (hf >> 15);
-unsigned int mantissa = (unsigned int) (hf & ((1 << 10) - 1));
-unsigned int exp = (unsigned int) (hf & HALF_FLOAT_MAX_BIASED_EXP);
-union av_intfloat32 f;
-
-if (exp == HALF_FLOAT_MAX_BIASED_EXP) {
-// we have a half-float NaN or Inf
-// half-float NaNs will be converted to a single precision NaN
-// half-float Infs will be converted to a single precision Inf
-exp = FLOAT_MAX_BIASED_EXP;
-mantissa <<= 13; // preserve half-float NaN bits if set
-} else if (exp == 0x0) {
-// convert half-float zero/denorm to single precision value
-if (mantissa) {
-mantissa <<= 1;
-exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
-// check for leading 1 in denorm mantissa
-while (!(mantissa & (1 << 10))) {
-// for every leading 0, decrement single precision exponent by 
1
-// and shift half-float mantissa value to the left
-mantissa <<= 1;
-exp -= (1 << 23);
-}
-// clamp the mantissa to 10 bits
-mantissa &= ((1 << 10) - 1);
-// shift left to generate single-precision mantissa of 23 bits
-mantissa <<= 13;
-}
-} else {
-// shift left to generate single-precision mantissa of 23 bits
-mantissa <<= 13;
-// generate single precision biased exponent value
-exp = (exp << 13) + HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
-}
-
-f.i = (sign << 31) | exp | mantissa;
-
-return f;
-}
-
 static int zip_uncompress(EXRContext *s, const uint8_t *src, int 
compressed_size,
   int uncompressed_size, EXRThreadData *td)
 {
@@ -951,7 +905,10 @@ static int ac_uncompress(EXRContext *s, GetByteContext 
*gb, float *block)
 n += val & 0xff;
 } else {
 ret = n;
-block[ff_zigzag_direct[n]] = exr_half2float(val).f;
+block[ff_zigzag_direct[n]] = av_int2float(half2float(val,
+  s->mantissatable,
+  s->exponenttable,
+  s->offsettable));
 n++;
 }
 }
@@ -1161,10 +1118,12 @@ static int dwa_uncompress(EXRContext *s, const uint8_t 
*src, int compressed_size
 float *block = td->block[j];
 const int idx = (x >> 3) + (y >> 3) * dc_w + dc_w * dc_h * j;
 uint16_t *dc = (uint16_t *)td->dc_data;
-float dc_val = dc[idx];
+union av_intfloat32 dc_val;
 
-dc_val = exr_half2float(dc_val).f;
-block[0] = dc_val;
+dc_val.i = half2float(dc[idx], s->mantissatable,
+  s->exponenttable, s->offsettable);
+
+block[0] = dc_val.f;
 ac_uncompress(s, , block);
 dct_inverse(block);
 }
@@ -1209,8 +1168,11 @@ static int dwa_uncompress(EXRContext *s, const uint8_t 
*src, int compressed_size
 uint8_t *ai0 = td->rle_raw_data + y * td->xsize;
 uint8_t *ai1 = td->rle_raw_data + y * td->xsize + rle_raw_size / 2;
 
-for (int x = 0; x < td->xsize; x++)
-ao[x] = exr_half2float(ai0[x] | (ai1[x] << 8)).i;
+for (int x = 0; x < td->xsize; x++) {
+uint16_t ha = ai0[x] | (ai1[x] << 8);
+
+ao[x] = half2float(ha, s->mantissatable, 

[FFmpeg-devel] [PATCH 2/3] avcodec/exrenc: move float2half code to own header

2021-02-28 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/exrenc.c | 52 +++-
 libavcodec/float2half.h | 67 +
 2 files changed, 72 insertions(+), 47 deletions(-)
 create mode 100644 libavcodec/float2half.h

diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c
index f9d802543d..db9000a85c 100644
--- a/libavcodec/exrenc.c
+++ b/libavcodec/exrenc.c
@@ -34,6 +34,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "internal.h"
+#include "float2half.h"
 
 enum ExrCompr {
 EXR_RAW,
@@ -87,54 +88,11 @@ typedef struct EXRContext {
 uint8_t shifttable[512];
 } EXRContext;
 
-static void half_tables(EXRContext *s)
-{
-for (int i = 0; i < 256; i++) {
-int e = i - 127;
-
-if (e < -24) { // Very small numbers map to zero
-s->basetable[i|0x000]  = 0x;
-s->basetable[i|0x100]  = 0x8000;
-s->shifttable[i|0x000] = 24;
-s->shifttable[i|0x100] = 24;
-} else if (e < -14) { // Small numbers map to denorms
-s->basetable[i|0x000] = (0x0400>>(-e-14));
-s->basetable[i|0x100] = (0x0400>>(-e-14)) | 0x8000;
-s->shifttable[i|0x000] = -e-1;
-s->shifttable[i|0x100] = -e-1;
-} else if (e <= 15) { // Normal numbers just lose precision
-s->basetable[i|0x000] = ((e + 15) << 10);
-s->basetable[i|0x100] = ((e + 15) << 10) | 0x8000;
-s->shifttable[i|0x000] = 13;
-s->shifttable[i|0x100] = 13;
-} else if (e < 128) { // Large numbers map to Infinity
-s->basetable[i|0x000]  = 0x7C00;
-s->basetable[i|0x100]  = 0xFC00;
-s->shifttable[i|0x000] = 24;
-s->shifttable[i|0x100] = 24;
-} else{ // Infinity and NaN's stay Infinity and NaN's
-s->basetable[i|0x000]  = 0x7C00;
-s->basetable[i|0x100]  = 0xFC00;
-s->shifttable[i|0x000] = 13;
-s->shifttable[i|0x100] = 13;
-}
-}
-}
-
-static uint16_t float2half(EXRContext *s, uint32_t f)
-{
-uint16_t h;
-
-h = s->basetable[(f >> 23) & 0x1ff] + ((f & 0x007f) >> 
s->shifttable[(f >> 23) & 0x1ff]);
-
-return h;
-}
-
 static int encode_init(AVCodecContext *avctx)
 {
 EXRContext *s = avctx->priv_data;
 
-half_tables(s);
+float2half_tables(s->basetable, s->shifttable);
 
 switch (avctx->pix_fmt) {
 case AV_PIX_FMT_GBRPF32:
@@ -290,7 +248,7 @@ static int encode_scanline_rle(EXRContext *s, const AVFrame 
*frame)
 uint32_t *src = (uint32_t *)(frame->data[ch] + y * 
frame->linesize[ch]);
 
 for (int x = 0; x < frame->width; x++)
-dst[x] = float2half(s, src[x]);
+dst[x] = float2half(src[x], s->basetable, s->shifttable);
 }
 break;
 }
@@ -358,7 +316,7 @@ static int encode_scanline_zip(EXRContext *s, const AVFrame 
*frame)
 uint32_t *src = (uint32_t *)(frame->data[ch] + (y * 
s->scanline_height + l) * frame->linesize[ch]);
 
 for (int x = 0; x < frame->width; x++)
-dst[x] = float2half(s, src[x]);
+dst[x] = float2half(src[x], s->basetable, 
s->shifttable);
 }
 }
 break;
@@ -516,7 +474,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 uint32_t *src = (uint32_t *)(frame->data[ch] + y * 
frame->linesize[ch]);
 
 for (int x = 0; x < frame->width; x++)
-bytestream2_put_le16(pb, float2half(s, src[x]));
+bytestream2_put_le16(pb, float2half(src[x], 
s->basetable, s->shifttable));
 }
 }
 }
diff --git a/libavcodec/float2half.h b/libavcodec/float2half.h
new file mode 100644
index 00..ff547b490c
--- /dev/null
+++ b/libavcodec/float2half.h
@@ -0,0 +1,67 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_FLOAT2HALF_H
+#define AVCODEC_FLOAT2HALF_H
+
+#include 
+
+static void float2half_tables(uint16_t *basetable, uint8_t *shifttable)
+{
+for (int i = 0; i < 256; i++) {
+int e = i - 127;
+
+if (e < 

[FFmpeg-devel] [PATCH 1/3] avcodec/exr: add DWA decompression support

2021-02-28 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/exr.c | 343 +--
 1 file changed, 331 insertions(+), 12 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 4559174ba2..e0e525e53c 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -66,8 +66,8 @@ enum ExrCompr {
 EXR_PXR24,
 EXR_B44,
 EXR_B44A,
-EXR_DWA,
-EXR_DWB,
+EXR_DWAA,
+EXR_DWAB,
 EXR_UNKN,
 };
 
@@ -119,6 +119,20 @@ typedef struct EXRThreadData {
 uint8_t *bitmap;
 uint16_t *lut;
 
+uint8_t *ac_data;
+unsigned ac_size;
+
+uint8_t *dc_data;
+unsigned dc_size;
+
+uint8_t *rle_data;
+unsigned rle_size;
+
+uint8_t *rle_raw_data;
+unsigned rle_raw_size;
+
+float block[3][64];
+
 int ysize, xsize;
 
 int channel_line_size;
@@ -256,10 +270,10 @@ static int zip_uncompress(EXRContext *s, const uint8_t 
*src, int compressed_size
 return 0;
 }
 
-static int rle_uncompress(EXRContext *ctx, const uint8_t *src, int 
compressed_size,
-  int uncompressed_size, EXRThreadData *td)
+static int rle(uint8_t *dst, const uint8_t *src,
+   int compressed_size, int uncompressed_size)
 {
-uint8_t *d  = td->tmp;
+uint8_t *d  = dst;
 const int8_t *s = src;
 int ssize   = compressed_size;
 int dsize   = uncompressed_size;
@@ -295,6 +309,14 @@ static int rle_uncompress(EXRContext *ctx, const uint8_t 
*src, int compressed_si
 if (dend != d)
 return AVERROR_INVALIDDATA;
 
+return 0;
+}
+
+static int rle_uncompress(EXRContext *ctx, const uint8_t *src, int 
compressed_size,
+  int uncompressed_size, EXRThreadData *td)
+{
+rle(td->tmp, src, compressed_size, uncompressed_size);
+
 av_assert1(uncompressed_size % 2 == 0);
 
 ctx->dsp.predictor(td->tmp, uncompressed_size);
@@ -475,18 +497,16 @@ static int huf_uncompress(EXRContext *s,
   GetByteContext *gb,
   uint16_t *dst, int dst_size)
 {
-int32_t src_size, im, iM;
+int32_t im, iM;
 uint32_t nBits;
 int ret;
 
-src_size = bytestream2_get_le32(gb);
 im   = bytestream2_get_le32(gb);
 iM   = bytestream2_get_le32(gb);
 bytestream2_skip(gb, 4);
 nBits = bytestream2_get_le32(gb);
 if (im < 0 || im >= HUF_ENCSIZE ||
-iM < 0 || iM >= HUF_ENCSIZE ||
-src_size < 0)
+iM < 0 || iM >= HUF_ENCSIZE)
 return AVERROR_INVALIDDATA;
 
 bytestream2_skip(gb, 4);
@@ -659,6 +679,7 @@ static int piz_uncompress(EXRContext *s, const uint8_t 
*src, int ssize,
 
 maxval = reverse_lut(td->bitmap, td->lut);
 
+bytestream2_skip(, 4);
 ret = huf_uncompress(s, td, , tmp, dsize / sizeof(uint16_t));
 if (ret)
 return ret;
@@ -917,6 +938,284 @@ static int b44_uncompress(EXRContext *s, const uint8_t 
*src, int compressed_size
 return 0;
 }
 
+static int ac_uncompress(EXRContext *s, GetByteContext *gb, float *block)
+{
+int ret = 0, n = 1;
+
+while (n < 64) {
+uint16_t val = bytestream2_get_ne16(gb);
+
+if (val == 0xff00) {
+n = 64;
+} else if ((val >> 8) == 0xff) {
+n += val & 0xff;
+} else {
+ret = n;
+block[ff_zigzag_direct[n]] = exr_half2float(val).f;
+n++;
+}
+}
+
+return ret;
+}
+
+static void idct_1d(float *blk, int step)
+{
+const float a = .5f * cosf(M_PI / 4.f);
+const float b = .5f * cosf(M_PI / 16.f);
+const float c = .5f * cosf(M_PI / 8.f);
+const float d = .5f * cosf(3.f*M_PI / 16.f);
+const float e = .5f * cosf(5.f*M_PI / 16.f);
+const float f = .5f * cosf(3.f*M_PI / 8.f);
+const float g = .5f * cosf(7.f*M_PI / 16.f);
+
+float alpha[4], beta[4], theta[4], gamma[4];
+
+alpha[0] = c * blk[2 * step];
+alpha[1] = f * blk[2 * step];
+alpha[2] = c * blk[6 * step];
+alpha[3] = f * blk[6 * step];
+
+beta[0] = b * blk[1 * step] + d * blk[3 * step] + e * blk[5 * step] + g * 
blk[7 * step];
+beta[1] = d * blk[1 * step] - g * blk[3 * step] - b * blk[5 * step] - e * 
blk[7 * step];
+beta[2] = e * blk[1 * step] - b * blk[3 * step] + g * blk[5 * step] + d * 
blk[7 * step];
+beta[3] = g * blk[1 * step] - e * blk[3 * step] + d * blk[5 * step] - b * 
blk[7 * step];
+
+theta[0] = a * (blk[0 * step] + blk[4 * step]);
+theta[3] = a * (blk[0 * step] - blk[4 * step]);
+
+theta[1] = alpha[0] + alpha[3];
+theta[2] = alpha[1] - alpha[2];
+
+gamma[0] = theta[0] + theta[1];
+gamma[1] = theta[3] + theta[2];
+gamma[2] = theta[3] - theta[2];
+gamma[3] = theta[0] - theta[1];
+
+blk[0 * step] = gamma[0] + beta[0];
+blk[1 * step] = gamma[1] + beta[1];
+blk[2 * step] = gamma[2] + beta[2];
+blk[3 * step] = gamma[3] + beta[3];
+
+blk[4 * step] = gamma[3] - beta[3];
+blk[5 * step] = gamma[2] - beta[2];
+blk[6 * step] = 

Re: [FFmpeg-devel] Apple M1 Mac Mini Access

2021-02-28 Thread Thilo Borgmann
Am 28.02.21 um 13:30 schrieb Kieran Kunhya:
> Hi,
> 
> Please email me privately with your ssh public key and desired username if
> you would like access to the second Apple M1 Mac Mini which we bought for
> development purposes.

Done, thanks for setting these things up!

-Thilo
___
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] Apple M1 Mac Mini Access

2021-02-28 Thread Kieran Kunhya
Hi,

Please email me privately with your ssh public key and desired username if
you would like access to the second Apple M1 Mac Mini which we bought for
development purposes.

Regards,
Kieran Kunhya
___
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/5] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-28 Thread Nicolas George
Guo, Yejun (12021-02-27):
> 'man readdir' on my system shows that it is d_name[256], see below.

man tells you what your particular system does right now, assuming the
man page is up-to-date. It does not tell you if your system will change
tomorrow, nor what other system do.

> agree, and maybe we can just let this build warning there.

In the long run, better disable it. We have check_disable_warning in
configure, so it is probably a one line patch.

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] Proposal of two projects for GSoC

2021-02-28 Thread Thilo Borgmann
Hi,

> Please find the proposal for the following two projects for GSoC this year.
> 
> The FATE project had been proposed earlier already but I don't know why it
> didn't happen.
> 
> I previously got the feedback from Thilo Borgmann and would be happy to get
> feedback from the community as well.

according to the replies I figure this project seems ok, I added it to the gsoc 
page.

Anyone wants to comment about the FATE proposal?


> "
> 
> 
> 
> FATE tests for HW acceleration
> 
> 
> 
> Description: FFmpeg's FATE regression test system do not include validation
> of hardware acceleration. This project is about to include these
> hardware-specific regression tests to the FATE system. Since this project
> requires access to corresponding hardware, it is not expected to cover the
> whole range of hardware accelerators there are but to initialize some
> useful tests for available hardware, most likely to include CPU
> acceleration on Intel or AMD at least. Access to other hardware can also be
> provided during the project, depending on the students requirements.
> 
> 
> 
> Expected results: Implement tests for the different hardware decoding,
> encoding and transcoding capabilities there are.
> 
> 
> 
> Prerequisites: Good C and Makefile coding skills, basic familiarity with
> Git.
> 
> 
> 
> Qualification Task: TBD
> 
> 
> 
> Mentor: Artem G (artem.galin [at] intel [dot] com)
> 
> 
> 
> Backup Mentor: TBD


-Thilo
___
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 3/5] libavformat/protocols.c: fix build warning for [-Wdiscarded-qualifiers]

2021-02-28 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Reimar
> D?ffinger
> Sent: 2021年2月27日 22:09
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V3 3/5] libavformat/protocols.c: fix build
> warning for [-Wdiscarded-qualifiers]
> 
> 
> 
> > On 27 Feb 2021, at 09:14, Guo, Yejun  wrote:
> >
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel  On Behalf Of
> >> Paul B Mahol
> >> Sent: 2021年2月26日 19:37
> >> To: FFmpeg development discussions and patches
> >> 
> >> Cc: Guo, Yejun 
> >> Subject: Re: [FFmpeg-devel] [PATCH V3 3/5] libavformat/protocols.c:
> >> fix build warning for [-Wdiscarded-qualifiers]
> >>
> >> look at same/similar patches like yours that have been already rejected.
> >
> > thanks for the info.
> >
> > My motivation to fix the build warnings is that: I have several
> > patches caught by patchwork with build warnings that I missed. I'd
> > like to avoid it. And the best method, IMO, is to add '-Wall -Werror' for 
> > the
> build option.
> 
> I think that is a bad idea, compilers add new warnings all the time, many of
> them unreliable or of questionable quality/usefulness.
> What you end up with using -Werror is a project that constantly fails to build
> and gets a reputation for low quality.
> However there may well be specific, reliable warning types for which we
> should add an error specifically, as we already do now for e.g.
> -Werror=implicit-function-declaration
> There might also be other options to improve things and ensure relevant
> warnings are visible and addressed, but I’ve yet to see a -Werror have
> convincing effects (for example one effect it usually has is that people have 
> to
> stick to “supported” compiler versions to avoid constant issues with build
> failures, reducing testing and actually decreasing code quality instead of
> increasing it).
> Turning it around, using -Werror successfully would mean testing with all
> compiler versions regularly including pre-release versions and ensuring any
> issues are fixed immediately. Which I don’t think is an approach that would
> work for FFmpeg.
> 
> > Such option can also help to find
> > potential issues in the code. This is the reason that I plan to fix
> > the build warnings one by one together with community.
> 
> I believe many are likely to be fixable in a way that most developers would be
> quite happy with, even consider it an improvement beyond just the
> warning/bug fix.
> It’ll just take a lot more effort to find those types of fixes.
> After all if it was that simple there could just be an option for the 
> compiler to
> fix them itself, the reason there isn’t is because it would likely end very 
> badly.
> 
> Best regards,
> Reimar

thanks for your nice explanation, thank you.

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