[FFmpeg-devel] [PATCH v4] avcodec/libvpxenc: add a way to set VP9E_SET_SVC_REF_FRAME_CONFIG

2021-01-07 Thread Wonkap Jang
In order to fine-control referencing schemes in VP9 encoding, there
is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit
provides a way to use the API through frame metadata.
---
 doc/encoders.texi  | 32 +++
 libavcodec/libvpxenc.c | 88 ++
 libavcodec/version.h   |  2 +-
 3 files changed, 121 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 0b1c69e982..ef85fbb062 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2129,6 +2129,38 @@ midpoint is passed in rather than calculated for a 
specific clip or chunk.
 The valid range is [0, 1]. 0 (default) uses standard VBR.
 @item enable-tpl @var{boolean}
 Enable temporal dependency model.
+@item ref-frame-config
+Using per-frame metadata, set members of the structure 
@code{vpx_svc_ref_frame_config_t} in @code{vpx/vp8cx.h} to fine-control 
referencing schemes and frame buffer management.
+@*Use a :-separated list of key=value pairs.
+For example,
+@example
+av_dict_set(_frame->metadata, "ref-frame-config", \
+"rfc_update_buffer_slot=7:rfc_lst_fb_idx=0:rfc_gld_fb_idx=1:rfc_alt_fb_idx=2:rfc_reference_last=0:rfc_reference_golden=0:rfc_reference_alt_ref=0");
+@end example
+@table @option
+@item rfc_update_buffer_slot
+Indicates the buffer slot number to update
+@item rfc_update_last
+Indicates whether to update the LAST frame
+@item rfc_update_golden
+Indicates whether to update GOLDEN frame
+@item rfc_update_alt_ref
+Indicates whether to update ALT_REF frame
+@item rfc_lst_fb_idx
+LAST frame buffer index
+@item rfc_gld_fb_idx
+GOLDEN frame buffer index
+@item rfc_alt_fb_idx
+ALT_REF frame buffer index
+@item rfc_reference_last
+Indicates whether to reference LAST frame
+@item rfc_reference_golden
+Indicates whether to reference GOLDEN frame
+@item rfc_reference_alt_ref
+Indicates whether to reference ALT_REF frame
+@item rfc_reference_duration
+Indicates frame duration
+@end table
 @end table
 
 @end table
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index a7c76eb835..13318e8a6f 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -125,6 +125,10 @@ typedef struct VPxEncoderContext {
  * encounter a frame with ROI side data.
  */
 int roi_warned;
+#if CONFIG_LIBVPX_VP9_ENCODER && 
defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
+vpx_svc_ref_frame_config_t ref_frame_config;
+AVDictionary *vpx_ref_frame_config;
+#endif
 } VPxContext;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -152,6 +156,7 @@ static const char *const ctlidstr[] = {
 [VP9E_SET_SVC_LAYER_ID]= "VP9E_SET_SVC_LAYER_ID",
 #if VPX_ENCODER_ABI_VERSION >= 12
 [VP9E_SET_SVC_PARAMETERS]  = "VP9E_SET_SVC_PARAMETERS",
+[VP9E_SET_SVC_REF_FRAME_CONFIG]= "VP9E_SET_SVC_REF_FRAME_CONFIG",
 #endif
 [VP9E_SET_SVC] = "VP9E_SET_SVC",
 #if VPX_ENCODER_ABI_VERSION >= 11
@@ -394,6 +399,21 @@ static void vp8_ts_parse_int_array(int *dest, char *value, 
size_t value_len, int
 }
 }
 
+#if CONFIG_LIBVPX_VP9_ENCODER && 
defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
+static void vp8_ts_parse_int64_array(int64_t *dest, char *value, size_t 
value_len, int max_entries)
+{
+int dest_idx = 0;
+char *saveptr = NULL;
+char *token = av_strtok(value, ",", );
+
+while (token && dest_idx < max_entries) {
+dest[dest_idx++] = strtoul(token, NULL, 10);
+token = av_strtok(NULL, ",", );
+}
+}
+
+#endif
+
 static void set_temporal_layer_pattern(int layering_mode, vpx_codec_enc_cfg_t 
*cfg,
int *layer_flags, int *flag_periodicity)
 {
@@ -541,6 +561,48 @@ static int vpx_ts_param_parse(VPxContext *ctx, struct 
vpx_codec_enc_cfg *enccfg,
 return 0;
 }
 
+#if CONFIG_LIBVPX_VP9_ENCODER && 
defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
+static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct 
vpx_codec_enc_cfg *enccfg,
+  char *key, char *value, enum AVCodecID 
codec_id)
+{
+size_t value_len = strlen(value);
+int ss_number_layers = enccfg->ss_number_layers;
+vpx_svc_ref_frame_config_t *ref_frame_config = >ref_frame_config;
+
+if (!value_len)
+return -1;
+
+if (codec_id != AV_CODEC_ID_VP9)
+return -1;
+
+if (!strcmp(key, "rfc_update_buffer_slot")) {
+vp8_ts_parse_int_array(ref_frame_config->update_buffer_slot, value, 
value_len, ss_number_layers);
+} else if (!strcmp(key, "rfc_update_last")) {
+vp8_ts_parse_int_array(ref_frame_config->update_last, value, 
value_len, ss_number_layers);
+} else if (!strcmp(key, "rfc_update_golden")) {
+vp8_ts_parse_int_array(ref_frame_config->update_golden, value, 
value_len, ss_number_layers);
+} else if (!strcmp(key, "rfc_update_alt_ref")) {
+vp8_ts_parse_int_array(ref_frame_config->update_alt_ref, value, 
value_len, ss_number_layers);
+} else if (!strcmp(key, 

[FFmpeg-devel] [PATCH v3 3/3] avformat/mxfenc: prefer to use the existing metadata

2021-01-07 Thread lance . lmwang
From: Limin Wang 

Please check metadata with below command:
./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
./ffmpeg -i out.mxf

company_name: FFmpeg
product_name: OP1a Muxer
product_version : 58.65.101o
=>
company_name: SONY
product_name: eVTR
product_version : 1.00

So need to update fate-mxf fate test.

Signed-off-by: Limin Wang 
---
 libavformat/mxfenc.c| 12 
 tests/ref/fate/mxf-d10-user-comments|  2 +-
 tests/ref/fate/mxf-opatom-user-comments |  2 +-
 tests/ref/fate/mxf-reel_name|  2 +-
 tests/ref/fate/mxf-user-comments|  2 +-
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index d8678c9..5244211 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -722,16 +722,20 @@ static void mxf_write_identification(AVFormatContext *s)
 {
 MXFContext *mxf = s->priv_data;
 AVIOContext *pb = s->pb;
-const char *company = "FFmpeg";
-const char *product = s->oformat != _mxf_opatom_muxer ? "OP1a Muxer" : 
"OPAtom Muxer";
-const char *version;
+AVDictionaryEntry *com_entry =  av_dict_get(s->metadata, "company_name", 
NULL, 0);
+AVDictionaryEntry *product_entry =  av_dict_get(s->metadata, 
"product_name", NULL, 0);
+AVDictionaryEntry *version_entry =  av_dict_get(s->metadata, 
"product_version", NULL, 0);
+const char *company = com_entry ? com_entry->value : "FFmpeg";
+const char *product = product_entry ? product_entry->value : s->oformat != 
_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
+const char *version = NULL;
+const char *product_version = version_entry ? version_entry->value : 
AV_STRINGIFY(LIBAVFORMAT_VERSION);
 int length;
 
 mxf_write_metadata_key(pb, 0x013000);
 PRINT_KEY(s, "identification key", pb->buf_ptr - 16);
 
 version = s->flags & AVFMT_FLAG_BITEXACT ?
-"0.0.0" : AV_STRINGIFY(LIBAVFORMAT_VERSION);
+"0.0.0" : product_version;
 length = 100 +mxf_utf16_local_tag_length(company) +
   mxf_utf16_local_tag_length(product) +
   mxf_utf16_local_tag_length(version);
diff --git a/tests/ref/fate/mxf-d10-user-comments 
b/tests/ref/fate/mxf-d10-user-comments
index de4f26c..4aebcaf 100644
--- a/tests/ref/fate/mxf-d10-user-comments
+++ b/tests/ref/fate/mxf-d10-user-comments
@@ -1 +1 @@
-68f0fa62b6a676894afbbe4c34ebf70b
+84e289a83797e793bfa0d3a31f94ac6c
diff --git a/tests/ref/fate/mxf-opatom-user-comments 
b/tests/ref/fate/mxf-opatom-user-comments
index 90e3fb2..374a72a 100644
--- a/tests/ref/fate/mxf-opatom-user-comments
+++ b/tests/ref/fate/mxf-opatom-user-comments
@@ -1 +1 @@
-f6760a9e710ba478bc3949f3e5c9b34a
+e7c41639b79ac54c4df05475fb0eea66
diff --git a/tests/ref/fate/mxf-reel_name b/tests/ref/fate/mxf-reel_name
index 16022b1..6e3218f 100644
--- a/tests/ref/fate/mxf-reel_name
+++ b/tests/ref/fate/mxf-reel_name
@@ -1 +1 @@
-73a891041b2fc836a893ffb49fff4fff
+be4c1b76138c855ac3e2d2579cbecc17
diff --git a/tests/ref/fate/mxf-user-comments b/tests/ref/fate/mxf-user-comments
index ddf51d9..46db6a3 100644
--- a/tests/ref/fate/mxf-user-comments
+++ b/tests/ref/fate/mxf-user-comments
@@ -1 +1 @@
-1255faf854223a74d707553121e5eca3
+8f2360104655971dc5fb68f98eda1b84
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH v3 2/3] avformat/udp: add memory alloc checks

2021-01-07 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 28987e0..333a612 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -892,6 +892,10 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if ((!is_output && s->circular_buffer_size) || (is_output && s->bitrate && 
s->circular_buffer_size)) {
 /* start the task going */
 s->fifo = av_fifo_alloc(s->circular_buffer_size);
+if (!s->fifo) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 ret = pthread_mutex_init(>mutex, NULL);
 if (ret != 0) {
 av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
strerror(ret));
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH v3 1/3] avformat/udp: return the error code instead of generic EIO

2021-01-07 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 42 ++
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 13c346a..28987e0 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -633,6 +633,8 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 char buf[256];
 struct sockaddr_storage my_addr;
 socklen_t len;
+int ret = AVERROR(EIO);
+int net_ret = 0;
 
 h->is_streamed = 1;
 
@@ -641,12 +643,12 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE;
 
 if (s->sources) {
-if (ff_ip_parse_sources(h, s->sources, >filters) < 0)
+if ((ret = ff_ip_parse_sources(h, s->sources, >filters)) < 0)
 goto fail;
 }
 
 if (s->block) {
-if (ff_ip_parse_blocks(h, s->block, >filters) < 0)
+if ((ret = ff_ip_parse_blocks(h, s->block, >filters)) < 0)
 goto fail;
 }
 
@@ -712,11 +714,11 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 av_strlcpy(localaddr, buf, sizeof(localaddr));
 }
 if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
-if (ff_ip_parse_sources(h, buf, >filters) < 0)
+if ((ret = ff_ip_parse_sources(h, buf, >filters)) < 0)
 goto fail;
 }
 if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
-if (ff_ip_parse_blocks(h, buf, >filters) < 0)
+if ((ret = ff_ip_parse_blocks(h, buf, >filters)) < 0)
 goto fail;
 }
 if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p))
@@ -742,7 +744,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if (!(flags & AVIO_FLAG_READ))
 goto fail;
 } else {
-if (ff_udp_set_remote_url(h, uri) < 0)
+if ((ret = ff_udp_set_remote_url(h, uri)) < 0)
 goto fail;
 }
 
@@ -763,13 +765,13 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
  */
 if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) {
 s->reuse_socket = 1;
-if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), 
sizeof(s->reuse_socket)) != 0)
+if ((net_ret = setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, 
&(s->reuse_socket), sizeof(s->reuse_socket))) != 0)
 goto fail;
 }
 
 if (s->is_broadcast) {
 #ifdef SO_BROADCAST
-if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), 
sizeof(s->is_broadcast)) != 0)
+if ((net_ret = setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, 
&(s->is_broadcast), sizeof(s->is_broadcast))) != 0)
 #endif
goto fail;
 }
@@ -788,7 +790,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 
 if (dscp >= 0) {
 dscp <<= 2;
-if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp)) != 0)
+if ((net_ret = setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , 
sizeof(dscp))) != 0)
 goto fail;
 }
 
@@ -802,7 +804,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 /* bind to the local address if not multicast or if the multicast
  * bind failed */
 /* the bind is needed to give a port to the socket now */
-if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)_addr, len) < 0) {
+if (bind_ret < 0 && (net_ret = bind(udp_fd,(struct sockaddr *)_addr, 
len)) < 0) {
 ff_log_net_error(h, AV_LOG_ERROR, "bind failed");
 goto fail;
 }
@@ -814,28 +816,28 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if (s->is_multicast) {
 if (h->flags & AVIO_FLAG_WRITE) {
 /* output */
-if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr 
*)>dest_addr) < 0)
+if ((net_ret = udp_set_multicast_ttl(udp_fd, s->ttl, (struct 
sockaddr *)>dest_addr)) < 0)
 goto fail;
 }
 if (h->flags & AVIO_FLAG_READ) {
 /* input */
 if (s->filters.nb_include_addrs) {
-if (udp_set_multicast_sources(h, udp_fd,
+if ((net_ret = udp_set_multicast_sources(h, udp_fd,
   (struct sockaddr *)>dest_addr,
   s->dest_addr_len, 
>local_addr_storage,
   s->filters.include_addrs,
-  s->filters.nb_include_addrs, 1) 
< 0)
+  s->filters.nb_include_addrs, 1)) 
< 0)
 goto fail;
 } else {
-if (udp_join_multicast_group(udp_fd, (struct sockaddr 
*)>dest_addr,(struct sockaddr *)>local_addr_storage) < 0)
+if ((net_ret = udp_join_multicast_group(udp_fd, (struct 

Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: add memory alloc checks

2021-01-07 Thread lance . lmwang
On Thu, Jan 07, 2021 at 05:32:35PM -0800, Chad Fraleigh wrote:
> 
> 
> On 1/7/2021 2:43 AM, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >   libavformat/udp.c | 4 
> >   1 file changed, 4 insertions(+)
> > 
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 798b789..e6d1235 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -891,6 +891,10 @@ static int udp_open(URLContext *h, const char *uri, 
> > int flags)
> >   if ((!is_output && s->circular_buffer_size) || (is_output && 
> > s->bitrate && s->circular_buffer_size)) {
> >   /* start the task going */
> >   s->fifo = av_fifo_alloc(s->circular_buffer_size);
> > +if (s->fifo) {
> > +ret = AVERROR(ENOMEM);
> > +goto fail;
> > +}
> 
> Is this suppose to be  "if (!s->fifo)"  [i.e. fail on NULL] instead?

yes, it lost accidently when I solve the code conflict. Will fix it, thx.

> 
> 
> >   ret = pthread_mutex_init(>mutex, NULL);
> >   if (ret != 0) {
> >   av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
> > strerror(ret));
> > 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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

Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: add memory alloc checks

2021-01-07 Thread Chad Fraleigh



On 1/7/2021 2:43 AM, lance.lmw...@gmail.com wrote:

From: Limin Wang 

Signed-off-by: Limin Wang 
---
  libavformat/udp.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 798b789..e6d1235 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -891,6 +891,10 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
  if ((!is_output && s->circular_buffer_size) || (is_output && s->bitrate && 
s->circular_buffer_size)) {
  /* start the task going */
  s->fifo = av_fifo_alloc(s->circular_buffer_size);
+if (s->fifo) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}


Is this suppose to be  "if (!s->fifo)"  [i.e. fail on NULL] instead?



  ret = pthread_mutex_init(>mutex, NULL);
  if (ret != 0) {
  av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
strerror(ret));


___
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/Makefile: Make H.263 encoder compilable without MPEG4 encoder

2021-01-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile| 3 ++-
 libavcodec/mpeg4videoenc.c | 3 ---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c1c2322eb6..c5605ef92c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -360,7 +360,7 @@ OBJS-$(CONFIG_H263_DECODER)+= h263dec.o h263.o 
ituh263dec.o\
   mpeg4video.o mpeg4videodec.o \
   h263data.o
 OBJS-$(CONFIG_H263I_DECODER)   += intelh263dec.o
-OBJS-$(CONFIG_H263_ENCODER)+= mpeg4videoenc.o mpeg4video.o  \
+OBJS-$(CONFIG_H263_ENCODER)+= mpeg4video.o  \
   h263.o ituh263enc.o h263data.o
 OBJS-$(CONFIG_H263_V4L2M2M_DECODER)+= v4l2_m2m_dec.o
 OBJS-$(CONFIG_H263_V4L2M2M_ENCODER)+= v4l2_m2m_enc.o
@@ -498,6 +498,7 @@ OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
 OBJS-$(CONFIG_MPEG2_V4L2M2M_DECODER)   += v4l2_m2m_dec.o
 OBJS-$(CONFIG_MPEG4_DECODER)   += xvididct.o
+OBJS-$(CONFIG_MPEG4_ENCODER)   += mpeg4videoenc.o
 OBJS-$(CONFIG_MPEG4_CUVID_DECODER) += cuviddec.o
 OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_MPEG4_OMX_ENCODER)   += omx.o
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index b3fa910c64..a092ab01d0 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -961,9 +961,6 @@ static void mpeg4_encode_vol_header(MpegEncContext *s,
 {
 int vo_ver_id;
 
-if (!CONFIG_MPEG4_ENCODER)
-return;
-
 if (s->max_b_frames || s->quarter_sample) {
 vo_ver_id  = 5;
 s->vo_type = ADV_SIMPLE_VO_TYPE;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 4/5] avcodec/Makefile: Make H.263 decoder compilable without H.263I

2021-01-07 Thread Andreas Rheinhardt
The only call to ff_intel_h263_decode_picture_header() is already behind
"if (CONFIG_H263I_DECODER)".

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4c1044a281..c1c2322eb6 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -358,7 +358,8 @@ OBJS-$(CONFIG_H261_DECODER)+= h261dec.o 
h261data.o h261.o
 OBJS-$(CONFIG_H261_ENCODER)+= h261enc.o h261data.o h261.o
 OBJS-$(CONFIG_H263_DECODER)+= h263dec.o h263.o ituh263dec.o
\
   mpeg4video.o mpeg4videodec.o \
-  intelh263dec.o h263data.o
+  h263data.o
+OBJS-$(CONFIG_H263I_DECODER)   += intelh263dec.o
 OBJS-$(CONFIG_H263_ENCODER)+= mpeg4videoenc.o mpeg4video.o  \
   h263.o ituh263enc.o h263data.o
 OBJS-$(CONFIG_H263_V4L2M2M_DECODER)+= v4l2_m2m_dec.o
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 3/5] avcodec/Makefile: Remove FLAC dependencies on vorbis_data

2021-01-07 Thread Andreas Rheinhardt
2ef2496cd19eb833f4ad22a5051c11be80d09598 used ff_vorbis_channel_layouts
in flac.c, but added a dependency to the FLAC decoder only; lateron
aba0278e9fe8e66c078588efe66f6af4db432770 added the dependency of the
FLAC parser and encoder on vorbis_data.o. Yet when the original commit
was reverted in aba0278e9fe8e66c078588efe66f6af4db432770, the two other
dependencies were not removed. This commit fixes this.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a711eeeb81..4c1044a281 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -330,7 +330,7 @@ OBJS-$(CONFIG_FIC_DECODER) += fic.o
 OBJS-$(CONFIG_FITS_DECODER)+= fitsdec.o fits.o
 OBJS-$(CONFIG_FITS_ENCODER)+= fitsenc.o
 OBJS-$(CONFIG_FLAC_DECODER)+= flacdec.o flacdata.o flac.o
-OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flac.o 
vorbis_data.o
+OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flac.o
 OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
 OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o
 OBJS-$(CONFIG_FLASHSV2_ENCODER)+= flashsv2enc.o
@@ -1090,8 +1090,7 @@ OBJS-$(CONFIG_DVAUDIO_PARSER)  += dvaudio_parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)   += dvbsub_parser.o
 OBJS-$(CONFIG_DVD_NAV_PARSER)  += dvd_nav_parser.o
 OBJS-$(CONFIG_DVDSUB_PARSER)   += dvdsub_parser.o
-OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o \
-  vorbis_data.o
+OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o
 OBJS-$(CONFIG_G723_1_PARSER)   += g723_1_parser.o
 OBJS-$(CONFIG_G729_PARSER) += g729_parser.o
 OBJS-$(CONFIG_GIF_PARSER)  += gif_parser.o
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 2/5] avcodec/Makefile: Remove dependency of H.263 on FLV codecs

2021-01-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 36891bbb57..a711eeeb81 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -336,6 +336,8 @@ OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o
 OBJS-$(CONFIG_FLASHSV2_ENCODER)+= flashsv2enc.o
 OBJS-$(CONFIG_FLASHSV2_DECODER)+= flashsv.o
 OBJS-$(CONFIG_FLIC_DECODER)+= flicvideo.o
+OBJS-$(CONFIG_FLV_DECODER) += flvdec.o
+OBJS-$(CONFIG_FLV_ENCODER) += flvenc.o
 OBJS-$(CONFIG_FMVC_DECODER)+= fmvc.o
 OBJS-$(CONFIG_FOURXM_DECODER)  += 4xm.o
 OBJS-$(CONFIG_FRAPS_DECODER)   += fraps.o
@@ -355,10 +357,10 @@ OBJS-$(CONFIG_GSM_MS_DECODER)  += gsmdec.o 
gsmdec_data.o msgsmdec.o
 OBJS-$(CONFIG_H261_DECODER)+= h261dec.o h261data.o h261.o
 OBJS-$(CONFIG_H261_ENCODER)+= h261enc.o h261data.o h261.o
 OBJS-$(CONFIG_H263_DECODER)+= h263dec.o h263.o ituh263dec.o
\
-  mpeg4video.o mpeg4videodec.o 
flvdec.o\
+  mpeg4video.o mpeg4videodec.o \
   intelh263dec.o h263data.o
 OBJS-$(CONFIG_H263_ENCODER)+= mpeg4videoenc.o mpeg4video.o  \
-  h263.o ituh263enc.o flvenc.o 
h263data.o
+  h263.o ituh263enc.o h263data.o
 OBJS-$(CONFIG_H263_V4L2M2M_DECODER)+= v4l2_m2m_dec.o
 OBJS-$(CONFIG_H263_V4L2M2M_ENCODER)+= v4l2_m2m_enc.o
 OBJS-$(CONFIG_H264_DECODER)+= h264dec.o h264_cabac.o h264_cavlc.o \
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 1/5] avcodec/Makefile: Remove unnecessary cbrt_data dependency

2021-01-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fea37ef3c9..36891bbb57 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -174,7 +174,7 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o 
aaccoder.o aacenctab.o\
   aacenc_tns.o \
   aacenc_ltp.o \
   aacenc_pred.o \
-  psymodel.o mpeg4audio.o kbdwin.o 
cbrt_data.o
+  psymodel.o mpeg4audio.o kbdwin.o
 OBJS-$(CONFIG_AAC_MF_ENCODER)  += mfenc.o mf_utils.o
 OBJS-$(CONFIG_AASC_DECODER)+= aasc.o msrledec.o
 OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o 
kbdwin.o ac3tab.o
-- 
2.25.1

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

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

Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/udp: return the error code instead of generic EIO

2021-01-07 Thread lance . lmwang
On Thu, Jan 07, 2021 at 05:07:32PM +0100, Marton Balint wrote:
> 
> 
> On Thu, 7 Jan 2021, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/udp.c | 47 +++
> > 1 file changed, 23 insertions(+), 24 deletions(-)
> > 
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 13c346a..798b789 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -633,6 +633,7 @@ static int udp_open(URLContext *h, const char *uri, int 
> > flags)
> > char buf[256];
> > struct sockaddr_storage my_addr;
> > socklen_t len;
> > +int ret = AVERROR(EIO);
> > 
> > h->is_streamed = 1;
> > 
> > @@ -641,12 +642,12 @@ static int udp_open(URLContext *h, const char *uri, 
> > int flags)
> > s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE;
> > 
> > if (s->sources) {
> > -if (ff_ip_parse_sources(h, s->sources, >filters) < 0)
> > +if ((ret = ff_ip_parse_sources(h, s->sources, >filters)) < 0)
> > goto fail;
> > }
> > 
> > if (s->block) {
> > -if (ff_ip_parse_blocks(h, s->block, >filters) < 0)
> > +if ((ret = ff_ip_parse_blocks(h, s->block, >filters)) < 0)
> > goto fail;
> > }
> > 
> > @@ -712,11 +713,11 @@ static int udp_open(URLContext *h, const char *uri, 
> > int flags)
> > av_strlcpy(localaddr, buf, sizeof(localaddr));
> > }
> > if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
> > -if (ff_ip_parse_sources(h, buf, >filters) < 0)
> > +if ((ret = ff_ip_parse_sources(h, buf, >filters)) < 0)
> > goto fail;
> > }
> > if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
> > -if (ff_ip_parse_blocks(h, buf, >filters) < 0)
> > +if ((ret = ff_ip_parse_blocks(h, buf, >filters)) < 0)
> > goto fail;
> > }
> > if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p))
> > @@ -742,7 +743,7 @@ static int udp_open(URLContext *h, const char *uri, int 
> > flags)
> > if (!(flags & AVIO_FLAG_READ))
> > goto fail;
> > } else {
> > -if (ff_udp_set_remote_url(h, uri) < 0)
> > +if ((ret = ff_udp_set_remote_url(h, uri)) < 0)
> > goto fail;
> > }
> > 
> > @@ -763,13 +764,13 @@ static int udp_open(URLContext *h, const char *uri, 
> > int flags)
> >  */
> > if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) {
> > s->reuse_socket = 1;
> > -if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, 
> > &(s->reuse_socket), sizeof(s->reuse_socket)) != 0)
> > +if ((ret = setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, 
> > &(s->reuse_socket), sizeof(s->reuse_socket))) != 0)
> 
> ff_neterrno() has to be used here and in a lot of places below to get proper
> return value.
OK, will update to use ff_neterrno() to get the proper error code..

> 
> Regards,
> Marton
> 
> > goto fail;
> > }
> > 
> > if (s->is_broadcast) {
> > #ifdef SO_BROADCAST
> > -if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, 
> > &(s->is_broadcast), sizeof(s->is_broadcast)) != 0)
> > +if ((ret = setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, 
> > &(s->is_broadcast), sizeof(s->is_broadcast))) != 0)
> > #endif
> >goto fail;
> > }
> > @@ -779,16 +780,16 @@ static int udp_open(URLContext *h, const char *uri, 
> > int flags)
> >  * Otherwise, the receiver will drop all packets.
> >  */
> > if (s->udplite_coverage) {
> > -if (setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV, 
> > &(s->udplite_coverage), sizeof(s->udplite_coverage)) != 0)
> > +if ((ret = setsockopt (udp_fd, IPPROTO_UDPLITE, 
> > UDPLITE_SEND_CSCOV, &(s->udplite_coverage), sizeof(s->udplite_coverage))) 
> > != 0)
> > av_log(h, AV_LOG_WARNING, "socket option UDPLITE_SEND_CSCOV not 
> > available");
> > 
> > -if (setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV, 
> > &(s->udplite_coverage), sizeof(s->udplite_coverage)) != 0)
> > +if ((ret = setsockopt (udp_fd, IPPROTO_UDPLITE, 
> > UDPLITE_RECV_CSCOV, &(s->udplite_coverage), sizeof(s->udplite_coverage))) 
> > != 0)
> > av_log(h, AV_LOG_WARNING, "socket option UDPLITE_RECV_CSCOV not 
> > available");
> > }
> > 
> > if (dscp >= 0) {
> > dscp <<= 2;
> > -if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp)) 
> > != 0)
> > +if ((ret = setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , 
> > sizeof(dscp))) != 0)
> > goto fail;
> > }
> > 
> > @@ -802,7 +803,7 @@ static int udp_open(URLContext *h, const char *uri, int 
> > flags)
> > /* bind to the local address if not multicast or if the multicast
> >  * bind failed */
> > /* the bind is needed to give a port to the socket now */
> > -if (bind_ret < 0 && bind(udp_fd,(struct 

[FFmpeg-devel] [PATCH] avformat/mxfdec: Free all types for both Descriptors

2021-01-07 Thread Michael Niedermayer
Fixes: memleak
Fixes: 
26352/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5201158714687488

Suggested-by: Tomas Härdin 
Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/mxfdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index b563f2abe1..9570d9c3c7 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -344,11 +344,10 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, 
int freectx)
 MXFIndexTableSegment *seg;
 switch ((*ctx)->type) {
 case Descriptor:
+case MultipleDescriptor:
 av_freep(&((MXFDescriptor *)*ctx)->extradata);
 av_freep(&((MXFDescriptor *)*ctx)->mastering);
 av_freep(&((MXFDescriptor *)*ctx)->coll);
-break;
-case MultipleDescriptor:
 av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs);
 break;
 case Sequence:
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 2/6] avcodec: add h266 codec id and profiles

2021-01-07 Thread Mark Thompson

On 22/12/2020 10:37, Nuo Mi wrote:

Hi James,
thanks for the review.

On Mon, Dec 21, 2020 at 11:14 PM James Almer  wrote:


On 12/21/2020 3:07 AM, Nuo Mi wrote:

---
   libavcodec/avcodec.h| 2 ++
   libavcodec/codec_desc.c | 8 
   libavcodec/codec_id.h   | 2 ++
   libavcodec/profiles.c   | 5 +
   libavcodec/profiles.h   | 1 +
   5 files changed, 18 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 1d3099d50a..f7ea4d5849 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1961,6 +1961,8 @@ typedef struct AVCodecContext {
   #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
   #define FF_PROFILE_HEVC_REXT4

+#define FF_PROFILE_H266_MAIN_10  1


We should decide first what we are going to use, if VVC or h266.

My suggestion was to use VVC for decoder, parser, demuxer and public
defines, which is what's exposed to the user, and h266 for CBS, which
makes things simpler to implement and is proper consider it's written
using the ITU spec.


Sorry for missed this. But seems mark and you have a different suggestion.
Could you align with him and other maintainers?


I have a preference for the ITU names, but in the end it's not very strong.

Please do go with the suggestion from James to use the VVC name in the external 
things, and h266 for cbs internals.

Thanks,

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

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/fft_fixed: Hardcode cosine tables to save space

2021-01-07 Thread Lynne
Jan 7, 2021, 21:26 by h.lepp...@gmail.com:

> On Thu, Jan 7, 2021 at 5:32 PM Lynne  wrote:
>
>>
>> Jan 7, 2021, 17:05 by andreas.rheinha...@gmail.com:
>>
>> > Lynne:
>> >
>> >> Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:
>> >>
>> >>> The tables that are used take 256B; the code to initialize them uses
>> >>> 281B here (GCC 9.3, x64, -O3, but in av_cold functions). On top of that,
>> >>> removing this code also allows to remove the array of AVOnce used to
>> >>> guard the cosine tables against multiple initializations; this also
>> >>> removes relocations.
>> >>>
>> >>> Signed-off-by: Andreas Rheinhardt 
>> >>> ---
>> >>>  libavcodec/Makefile   |  2 +-
>> >>>  libavcodec/fft.h  | 19 +-
>> >>>  libavcodec/fft_fixed.c| 42 +++
>> >>>  libavcodec/fft_template.c | 27 +
>> >>>  4 files changed, 62 insertions(+), 28 deletions(-)
>> >>>
>> >>
>> >> I'm not a big fan of this one. It saves minor amounts of space, introduces
>> >> more hard/soft table init splits, and is for code due to be replaced by
>> >> libavutil/tx anyway.
>> >>
>> >
>> > It actually removes a hard/soft table init split: Before this patch the
>> > cos tables for the 16-bit fixed-point FFT were sometimes hardcoded and
>> > sometimes not; now the latter option doesn't exist any more, reducing
>> > complexity.
>> > (I actually pondered removing the big #if at the beginning of
>> > fft_template.c by moving the code for FFT_FIXED_32 to fft_fixed_32.c and
>> > the code for FFT_FLOAT to fft_float.c.)
>> >
>>
>> My opinion still stands for this patch. This does introduce ifdeffery.
>> And the size gains are marginal at best, 256 bytes aren't worth it,
>> and can be likely saved in an easier and cleaner way elsewhere.
>>
>
> The patch seems to remove more ifdeffery then it adds, at worst it
> moves a bit of it due to changing the previous hardcoded behavior.
>

To an extent.
I'm still objecting to hardcoding those tables though.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/libopusenc: Fix for header pre-skip value

2021-01-07 Thread Lynne
Jan 7, 2021, 21:55 by a...@ified.ca:

> The Opus header initial padding preskip amount is always to be expressed
> relative to 48kHz. However, the encoder delay returned from querying
> libopus is relative to the encoding samplerate. Multiply by the
> samplerate conversion factor to correct.
>
> Signed-off-by: Arthur Taylor 
> ---
>  libavcodec/libopusenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
> index bf2d04b4fb..70d17f802b 100644
> --- a/libavcodec/libopusenc.c
> +++ b/libavcodec/libopusenc.c
> @@ -94,7 +94,7 @@ static void libopus_write_header(AVCodecContext *avctx, int 
> stream_count,
>  bytestream_put_buffer(, "OpusHead", 8);
>  bytestream_put_byte(, 1); /* Version */
>  bytestream_put_byte(, channels);
> -bytestream_put_le16(, avctx->initial_padding); /* Lookahead samples at 
> 48kHz */
> +bytestream_put_le16(, avctx->initial_padding * 48000 / 
> avctx->sample_rate); /* Lookahead samples at 48kHz */
>  bytestream_put_le32(, avctx->sample_rate); /* Original sample rate */
>  bytestream_put_le16(, 0); /* Gain of 0dB is recommended. */ 
>

Pushed, 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] avcodec/libopusenc: Fix for header pre-skip value

2021-01-07 Thread Arthur Taylor
The Opus header initial padding preskip amount is always to be expressed
relative to 48kHz. However, the encoder delay returned from querying
libopus is relative to the encoding samplerate. Multiply by the
samplerate conversion factor to correct.

Signed-off-by: Arthur Taylor 
---
 libavcodec/libopusenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index bf2d04b4fb..70d17f802b 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -94,7 +94,7 @@ static void libopus_write_header(AVCodecContext *avctx, int 
stream_count,
 bytestream_put_buffer(, "OpusHead", 8);
 bytestream_put_byte(, 1); /* Version */
 bytestream_put_byte(, channels);
-bytestream_put_le16(, avctx->initial_padding); /* Lookahead samples at 
48kHz */
+bytestream_put_le16(, avctx->initial_padding * 48000 / 
avctx->sample_rate); /* Lookahead samples at 48kHz */
 bytestream_put_le32(, avctx->sample_rate); /* Original sample rate */
 bytestream_put_le16(, 0); /* Gain of 0dB is recommended. */
 
-- 
2.30.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 v4] avcodec/libvpxenc: add a way to set VP9E_SET_SVC_REF_FRAME_CONFIG

2021-01-07 Thread James Zern
Hi,

On Wed, Jan 6, 2021 at 8:59 AM Wonkap Jang  wrote:
>
> HI JAmes,
>
> On Tue, Dec 29, 2020 at 11:54 AM Wonkap Jang <
> wonkap-at-google@ffmpeg.org> wrote:
>
> > Hi James,
> >
> > On Tue, Dec 29, 2020 at 11:51 AM Wonkap Jang  wrote:
> >
> > > In order to fine-control referencing schemes in VP9 encoding, there
> > > is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit
> > > provides a way to use the API through frame metadata.
> > > ---
> > >  doc/encoders.texi  | 32 +
> > >  libavcodec/libvpxenc.c | 81 ++
> > >  2 files changed, 113 insertions(+)
> > >

A change like this should also bump the micro version in avcodec.h

> > > diff --git a/doc/encoders.texi b/doc/encoders.texi
> > > index 0b1c69e982..11cf4d89d0 100644
> > > --- a/doc/encoders.texi
> > > +++ b/doc/encoders.texi
> > > @@ -2129,6 +2129,38 @@ midpoint is passed in rather than calculated for a
> > > specific clip or chunk.
> > >  The valid range is [0, 1]. 0 (default) uses standard VBR.
> > >  @item enable-tpl @var{boolean}
> > >  Enable temporal dependency model.
> > > +@item ref-frame-config
> > > +Using per-frame metadata, set members of the structure
> > > @code{vpx_svc_ref_frame_config_t} in @code{vpx/vp8cx.h} to fine-control
> > > referencing schemes and frame buffer management.
> > > +@*Use a :-separated list of key=value pairs.
> > > +For example,
> > > +@example
> > > +av_dict_set(_frame->metadata, "ref-frame-config", \
> > >
> > >
> > +"rfc_update_buffer_slot=7:rfc_lst_fb_idx=0:rfc_gld_fb_idx=1:rfc_alt_fb_idx=2:rfc_reference_last=0:rfc_reference_golden=0:rfc_reference_alt_ref=0");
> > > +@end example
> > > +@table @option
> > > +@item rfc_update_buffer_slot
> > > +Indicates the buffer slot number to update
> > > +@item rfc_update_last
> > > +Indicates whether to update the LAST frame
> > > +@item rfc_update_golden
> > > +Indicates whether to update GOLDEN frame
> > > +@item rfc_update_alt_ref
> > > +Indicates whether to update ALT_REF frame
> > > +@item rfc_lst_fb_idx
> > > +LAST frame buffer index
> > > +@item rfc_gld_fb_idx
> > > +GOLDEN frame buffer index
> > > +@item rfc_alt_fb_idx
> > > +ALT_REF frame buffer index
> > > +@item rfc_reference_last
> > > +Indicates whetehr to reference LAST frame

whether

> > > +@item rfc_reference_golden
> > > +Indicates whether to reference GOLDEN frame
> > > +@item rfc_reference_alt_ref
> > > +Indicates whether to reference ALT_REF frame
> > > +@item rfc_reference_duration
> > > +Indicates frame duration
> > > +@end table
> > >  @end table
> > >
> > >  @end table
> > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> > > index a7c76eb835..4943a9e32c 100644
> > > --- a/libavcodec/libvpxenc.c
> > > +++ b/libavcodec/libvpxenc.c
> > > @@ -125,6 +125,10 @@ typedef struct VPxEncoderContext {
> > >   * encounter a frame with ROI side data.
> > >   */
> > >  int roi_warned;
> > > +#if CONFIG_LIBVPX_VP9_ENCODER && defined
> > > (VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)

It's uncommon to add a space before ( with defined.

> > > [...]
> > >
> > > +#if CONFIG_LIBVPX_VP9_ENCODER && defined
> > > (VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
> > > +static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct
> > > vpx_codec_enc_cfg *enccfg,
> > > +  char *key, char *value, enum AVCodecID
> > > codec_id)

indent is off

> > > +{
> > > +size_t value_len = strlen(value);
> > > +int ss_number_layers = enccfg->ss_number_layers;
> > > +vpx_svc_ref_frame_config_t *ref_frame_config =
> > >ref_frame_config;
> > > +
> > > +if (!value_len)
> > > +return -1;
> > > +
> > > +if (codec_id != AV_CODEC_ID_VP9)
> > > +return -1;
> > > +

You might want to just skip the call altogether and add 1 warning
output if it's VP8.

> > > [...]
> > > +}
> > > +
> > > +return 0;
> > > +}
> > > +#endif
> > > +
> > > +

this line can be removed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/fft_fixed: Hardcode cosine tables to save space

2021-01-07 Thread Hendrik Leppkes
On Thu, Jan 7, 2021 at 5:32 PM Lynne  wrote:
>
> Jan 7, 2021, 17:05 by andreas.rheinha...@gmail.com:
>
> > Lynne:
> >
> >> Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:
> >>
> >>> The tables that are used take 256B; the code to initialize them uses
> >>> 281B here (GCC 9.3, x64, -O3, but in av_cold functions). On top of that,
> >>> removing this code also allows to remove the array of AVOnce used to
> >>> guard the cosine tables against multiple initializations; this also
> >>> removes relocations.
> >>>
> >>> Signed-off-by: Andreas Rheinhardt 
> >>> ---
> >>>  libavcodec/Makefile   |  2 +-
> >>>  libavcodec/fft.h  | 19 +-
> >>>  libavcodec/fft_fixed.c| 42 +++
> >>>  libavcodec/fft_template.c | 27 +
> >>>  4 files changed, 62 insertions(+), 28 deletions(-)
> >>>
> >>
> >> I'm not a big fan of this one. It saves minor amounts of space, introduces
> >> more hard/soft table init splits, and is for code due to be replaced by
> >> libavutil/tx anyway.
> >>
> >
> > It actually removes a hard/soft table init split: Before this patch the
> > cos tables for the 16-bit fixed-point FFT were sometimes hardcoded and
> > sometimes not; now the latter option doesn't exist any more, reducing
> > complexity.
> > (I actually pondered removing the big #if at the beginning of
> > fft_template.c by moving the code for FFT_FIXED_32 to fft_fixed_32.c and
> > the code for FFT_FLOAT to fft_float.c.)
> >
>
> My opinion still stands for this patch. This does introduce ifdeffery.
> And the size gains are marginal at best, 256 bytes aren't worth it,
> and can be likely saved in an easier and cleaner way elsewhere.

The patch seems to remove more ifdeffery then it adds, at worst it
moves a bit of it due to changing the previous hardcoded behavior.

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

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

[FFmpeg-devel] [PATCH] avformat/hlsenc: hls output optimisation Currently the output of the segment is delayed by 1 packet since the check condition compares the pts of the beginning of packet insted

2021-01-07 Thread Bartosz Ziemski
From: Bartosz Ziemski 

Signed-off-by: Bartosz Ziemski 
---
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cafe0e8c69..bac1e681f3 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2497,7 +2497,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 
 can_split = can_split && (pkt->pts - vs->end_pts > 0);
-if (vs->packets_written && can_split && av_compare_ts(pkt->pts - 
vs->start_pts, st->time_base,
+if (vs->packets_written && can_split && av_compare_ts(pkt->pts + 
pkt->duration - vs->start_pts, st->time_base,
   end_pts, 
AV_TIME_BASE_Q) >= 0) {
 int64_t new_start_pos;
 int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
(hls->max_seg_size > 0);
-- 
2.25.1

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

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

Re: [FFmpeg-devel] [PATCH 2/5] avcodec/fft_template: Remove unused fixed-point cosine tables

2021-01-07 Thread Lynne
Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:

> There are three types of FFTs: floating-point, 32-bit fixed-point and
> 16-bit fixed-point. The latter has exactly one user: The fixed-point
> AC-3-encoder; the cosine tables used by it use up to seven bits. The
> tables corresponding to eight to seventeen bits are unused, as are the
> FFT functions for these bits.
>
> Therefore this commit removes these tables and functions. This is
> especially beneficial when using hardcoded tables as they take up more
> than 255 KiB. But even without it one saves said unused functions as
> well as entries in corresponding tables (this also saves relocations).
>
> Signed-off-by: Andreas Rheinhardt 
> ---
> Thee changes to ARM assembly are honstely untested. I hope someone can
> test them. Btw: It seems that the ARM assembly code wouldn't be able to
> deal with an FFT with more than 16 bits (no function for this has been
> defined), which only worked because no one ever used that many bits with
> the fixed-point FFT.
>
>  libavcodec/arm/fft_fixed_neon.S | 18 --
>  libavcodec/cos_tablegen.c   |  4 ++--
>  libavcodec/fft.h|  4 +++-
>  libavcodec/fft_fixed.c  |  1 +
>  libavcodec/fft_template.c   | 31 +++
>  tests/fate/fft.mak  |  8 ++--
>  6 files changed, 35 insertions(+), 31 deletions(-)
>

The whole comment was hard to make sense of, since you keep mixing
fixed-point FFT precision bits (16 and 32) and FFT length (confusingly also in 
bits).
I'd rather have a blank comment with just the code or just no references to
the 16-bit fixed-point FFT.

LGTM. Thankfully nothing of the eldritchian fixed-point FFT monstrosity
is exposed to API users, so as long as FATE passes on ARM, should
be okay.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/fft_template: Only check for FF_FFT_PERM_AVX on ARCH_X86

2021-01-07 Thread Lynne
Jan 7, 2021, 17:38 by andreas.rheinha...@gmail.com:

> Lynne:
>
>> Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:
>>
>>> Also do it for FFT_FLOAT only, as this is the only combination for which
>>> it can be set.
>>>
>>> Signed-off-by: Andreas Rheinhardt 
>>> ---
>>>  libavcodec/fft_template.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
>>> index 9d125de073..ddde63714e 100644
>>> --- a/libavcodec/fft_template.c
>>> +++ b/libavcodec/fft_template.c
>>> @@ -251,7 +251,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int 
>>> inverse)
>>>  #endif /* FFT_FIXED_32 */
>>>  
>>>  
>>> -if (s->fft_permutation == FF_FFT_PERM_AVX) {
>>> +if (ARCH_X86 && FFT_FLOAT && s->fft_permutation == FF_FFT_PERM_AVX) {
>>>  fft_perm_avx(s);
>>>  } else {
>>>  #define PROCESS_FFT_PERM_SWAP_LSBS(num) do {\
>>>
>>
>> LGTM. Maybe mark fft_perm_avx as inline too if you can be bothered to amend 
>> the patch.
>>
>
> I don't see a reason to interfere in the compiler's inlining decision
> here. It is a static function only called once, so it will be inlined
> anyway.
>

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

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

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/fft_template: Only check for FF_FFT_PERM_AVX on ARCH_X86

2021-01-07 Thread Andreas Rheinhardt
Lynne:
> Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:
> 
>> Also do it for FFT_FLOAT only, as this is the only combination for which
>> it can be set.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/fft_template.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
>> index 9d125de073..ddde63714e 100644
>> --- a/libavcodec/fft_template.c
>> +++ b/libavcodec/fft_template.c
>> @@ -251,7 +251,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int 
>> inverse)
>>  #endif /* FFT_FIXED_32 */
>>  
>>  
>> -if (s->fft_permutation == FF_FFT_PERM_AVX) {
>> +if (ARCH_X86 && FFT_FLOAT && s->fft_permutation == FF_FFT_PERM_AVX) {
>>  fft_perm_avx(s);
>>  } else {
>>  #define PROCESS_FFT_PERM_SWAP_LSBS(num) do {\
>>
> 
> LGTM. Maybe mark fft_perm_avx as inline too if you can be bothered to amend 
> the patch.

I don't see a reason to interfere in the compiler's inlining decision
here. It is a static function only called once, so it will be inlined
anyway.

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

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/fft_fixed: Hardcode cosine tables to save space

2021-01-07 Thread Lynne
Jan 7, 2021, 17:05 by andreas.rheinha...@gmail.com:

> Lynne:
>
>> Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:
>>
>>> The tables that are used take 256B; the code to initialize them uses
>>> 281B here (GCC 9.3, x64, -O3, but in av_cold functions). On top of that,
>>> removing this code also allows to remove the array of AVOnce used to
>>> guard the cosine tables against multiple initializations; this also
>>> removes relocations.
>>>
>>> Signed-off-by: Andreas Rheinhardt 
>>> ---
>>>  libavcodec/Makefile   |  2 +-
>>>  libavcodec/fft.h  | 19 +-
>>>  libavcodec/fft_fixed.c| 42 +++
>>>  libavcodec/fft_template.c | 27 +
>>>  4 files changed, 62 insertions(+), 28 deletions(-)
>>>
>>
>> I'm not a big fan of this one. It saves minor amounts of space, introduces
>> more hard/soft table init splits, and is for code due to be replaced by
>> libavutil/tx anyway.
>>
>
> It actually removes a hard/soft table init split: Before this patch the
> cos tables for the 16-bit fixed-point FFT were sometimes hardcoded and
> sometimes not; now the latter option doesn't exist any more, reducing
> complexity.
> (I actually pondered removing the big #if at the beginning of
> fft_template.c by moving the code for FFT_FIXED_32 to fft_fixed_32.c and
> the code for FFT_FLOAT to fft_float.c.)
>

My opinion still stands for this patch. This does introduce ifdeffery.
And the size gains are marginal at best, 256 bytes aren't worth it,
and can be likely saved in an easier and cleaner way elsewhere.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/udp: return the error code instead of generic EIO

2021-01-07 Thread Marton Balint



On Thu, 7 Jan 2021, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavformat/udp.c | 47 +++
1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 13c346a..798b789 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -633,6 +633,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
char buf[256];
struct sockaddr_storage my_addr;
socklen_t len;
+int ret = AVERROR(EIO);

h->is_streamed = 1;

@@ -641,12 +642,12 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE;

if (s->sources) {
-if (ff_ip_parse_sources(h, s->sources, >filters) < 0)
+if ((ret = ff_ip_parse_sources(h, s->sources, >filters)) < 0)
goto fail;
}

if (s->block) {
-if (ff_ip_parse_blocks(h, s->block, >filters) < 0)
+if ((ret = ff_ip_parse_blocks(h, s->block, >filters)) < 0)
goto fail;
}

@@ -712,11 +713,11 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
av_strlcpy(localaddr, buf, sizeof(localaddr));
}
if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
-if (ff_ip_parse_sources(h, buf, >filters) < 0)
+if ((ret = ff_ip_parse_sources(h, buf, >filters)) < 0)
goto fail;
}
if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
-if (ff_ip_parse_blocks(h, buf, >filters) < 0)
+if ((ret = ff_ip_parse_blocks(h, buf, >filters)) < 0)
goto fail;
}
if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p))
@@ -742,7 +743,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
if (!(flags & AVIO_FLAG_READ))
goto fail;
} else {
-if (ff_udp_set_remote_url(h, uri) < 0)
+if ((ret = ff_udp_set_remote_url(h, uri)) < 0)
goto fail;
}

@@ -763,13 +764,13 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 */
if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) {
s->reuse_socket = 1;
-if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), 
sizeof(s->reuse_socket)) != 0)
+if ((ret = setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, 
&(s->reuse_socket), sizeof(s->reuse_socket))) != 0)


ff_neterrno() has to be used here and in a lot of places below to get 
proper return value.


Regards,
Marton


goto fail;
}

if (s->is_broadcast) {
#ifdef SO_BROADCAST
-if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), 
sizeof(s->is_broadcast)) != 0)
+if ((ret = setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, 
&(s->is_broadcast), sizeof(s->is_broadcast))) != 0)
#endif
   goto fail;
}
@@ -779,16 +780,16 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 * Otherwise, the receiver will drop all packets.
 */
if (s->udplite_coverage) {
-if (setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV, 
&(s->udplite_coverage), sizeof(s->udplite_coverage)) != 0)
+if ((ret = setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV, 
&(s->udplite_coverage), sizeof(s->udplite_coverage))) != 0)
av_log(h, AV_LOG_WARNING, "socket option UDPLITE_SEND_CSCOV not 
available");

-if (setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV, 
&(s->udplite_coverage), sizeof(s->udplite_coverage)) != 0)
+if ((ret = setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV, 
&(s->udplite_coverage), sizeof(s->udplite_coverage))) != 0)
av_log(h, AV_LOG_WARNING, "socket option UDPLITE_RECV_CSCOV not 
available");
}

if (dscp >= 0) {
dscp <<= 2;
-if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp)) != 0)
+if ((ret = setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , 
sizeof(dscp))) != 0)
goto fail;
}

@@ -802,7 +803,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
/* bind to the local address if not multicast or if the multicast
 * bind failed */
/* the bind is needed to give a port to the socket now */
-if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)_addr, len) < 0) {
+if (bind_ret < 0 && (ret = bind(udp_fd,(struct sockaddr *)_addr, len)) 
< 0) {
ff_log_net_error(h, AV_LOG_ERROR, "bind failed");
goto fail;
}
@@ -814,28 +815,28 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
if (s->is_multicast) {
if (h->flags & AVIO_FLAG_WRITE) {
/* output */
-if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr 
*)>dest_addr) < 0)
+if ((ret = udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr 
*)>dest_addr)) < 0)
goto fail;
}
if (h->flags 

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/fft_fixed: Hardcode cosine tables to save space

2021-01-07 Thread Andreas Rheinhardt
Lynne:
> Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:
> 
>> The tables that are used take 256B; the code to initialize them uses
>> 281B here (GCC 9.3, x64, -O3, but in av_cold functions). On top of that,
>> removing this code also allows to remove the array of AVOnce used to
>> guard the cosine tables against multiple initializations; this also
>> removes relocations.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/Makefile   |  2 +-
>>  libavcodec/fft.h  | 19 +-
>>  libavcodec/fft_fixed.c| 42 +++
>>  libavcodec/fft_template.c | 27 +
>>  4 files changed, 62 insertions(+), 28 deletions(-)
>>
> 
> I'm not a big fan of this one. It saves minor amounts of space, introduces
> more hard/soft table init splits, and is for code due to be replaced by
> libavutil/tx anyway.

It actually removes a hard/soft table init split: Before this patch the
cos tables for the 16-bit fixed-point FFT were sometimes hardcoded and
sometimes not; now the latter option doesn't exist any more, reducing
complexity.
(I actually pondered removing the big #if at the beginning of
fft_template.c by moving the code for FFT_FIXED_32 to fft_fixed_32.c and
the code for FFT_FLOAT to fft_float.c.)

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

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

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/fft_template: Perform some checks at compile-time

2021-01-07 Thread Lynne
Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:

> The fixed point FFT never uses the 32bit revtab; this commit adds
> some compile-time checks to make sure that dead code doesn't get
> compiled in.
>
> Also, while just at it, fix the indentation in ff_fft_init() and make sure
> that a do {} while (0) macro does not already swallow the semicolon on its
> own.
>
> Signed-off-by: Andreas Rheinhardt 
>

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

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

Re: [FFmpeg-devel] [PATCH 4/5] avcodec/fft_template: Only check for FF_FFT_PERM_AVX on ARCH_X86

2021-01-07 Thread Lynne
Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:

> Also do it for FFT_FLOAT only, as this is the only combination for which
> it can be set.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/fft_template.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
> index 9d125de073..ddde63714e 100644
> --- a/libavcodec/fft_template.c
> +++ b/libavcodec/fft_template.c
> @@ -251,7 +251,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int 
> inverse)
>  #endif /* FFT_FIXED_32 */
>  
>  
> -if (s->fft_permutation == FF_FFT_PERM_AVX) {
> +if (ARCH_X86 && FFT_FLOAT && s->fft_permutation == FF_FFT_PERM_AVX) {
>  fft_perm_avx(s);
>  } else {
>  #define PROCESS_FFT_PERM_SWAP_LSBS(num) do {\
>

LGTM. Maybe mark fft_perm_avx as inline too if you can be bothered to amend the 
patch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/fft_fixed: Hardcode cosine tables to save space

2021-01-07 Thread Lynne
Jan 7, 2021, 00:13 by andreas.rheinha...@gmail.com:

> The tables that are used take 256B; the code to initialize them uses
> 281B here (GCC 9.3, x64, -O3, but in av_cold functions). On top of that,
> removing this code also allows to remove the array of AVOnce used to
> guard the cosine tables against multiple initializations; this also
> removes relocations.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/Makefile   |  2 +-
>  libavcodec/fft.h  | 19 +-
>  libavcodec/fft_fixed.c| 42 +++
>  libavcodec/fft_template.c | 27 +
>  4 files changed, 62 insertions(+), 28 deletions(-)
>

I'm not a big fan of this one. It saves minor amounts of space, introduces
more hard/soft table init splits, and is for code due to be replaced by
libavutil/tx anyway.
___
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 03/27] cbs_h2645: Merge SEI message handling in common between codecs

2021-01-07 Thread Nuo Mi
>
> >> ...
>
> On reviewing, it really helps to trim irrelevant context from replies so
> that we aren't searching through long messages looking for comments.  (And
> apologies if I missed anything.)
>
No, you address all my concerns. thanks for the suggstion.


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

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

[FFmpeg-devel] [PATCH 4/4] checkasm: add hevc_pel tests

2021-01-07 Thread Josh Dekker
Co-authored-by: Niklas Haas 
Signed-off-by: Josh Dekker 
---
 tests/checkasm/Makefile   |   2 +-
 tests/checkasm/checkasm.c |  10 +
 tests/checkasm/checkasm.h |  10 +
 tests/checkasm/hevc_pel.c | 523 ++
 4 files changed, 544 insertions(+), 1 deletion(-)
 create mode 100644 tests/checkasm/hevc_pel.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 9e9569777b..1827a4e134 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -24,7 +24,7 @@ AVCODECOBJS-$(CONFIG_HUFFYUV_DECODER)   += huffyuvdsp.o
 AVCODECOBJS-$(CONFIG_JPEG2000_DECODER)  += jpeg2000dsp.o
 AVCODECOBJS-$(CONFIG_OPUS_DECODER)  += opusdsp.o
 AVCODECOBJS-$(CONFIG_PIXBLOCKDSP)   += pixblockdsp.o
-AVCODECOBJS-$(CONFIG_HEVC_DECODER)  += hevc_add_res.o hevc_idct.o 
hevc_sao.o
+AVCODECOBJS-$(CONFIG_HEVC_DECODER)  += hevc_add_res.o hevc_idct.o 
hevc_sao.o hevc_pel.o
 AVCODECOBJS-$(CONFIG_UTVIDEO_DECODER)   += utvideodsp.o
 AVCODECOBJS-$(CONFIG_V210_DECODER)  += v210dec.o
 AVCODECOBJS-$(CONFIG_V210_ENCODER)  += v210enc.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index b3ac76c325..8338e8ff58 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -116,6 +116,16 @@ static const struct {
 #if CONFIG_HEVC_DECODER
 { "hevc_add_res", checkasm_check_hevc_add_res },
 { "hevc_idct", checkasm_check_hevc_idct },
+{ "hevc_qpel", checkasm_check_hevc_qpel },
+{ "hevc_qpel_uni", checkasm_check_hevc_qpel_uni },
+{ "hevc_qpel_uni_w", checkasm_check_hevc_qpel_uni_w },
+{ "hevc_qpel_bi", checkasm_check_hevc_qpel_bi },
+{ "hevc_qpel_bi_w", checkasm_check_hevc_qpel_bi_w },
+{ "hevc_epel", checkasm_check_hevc_epel },
+{ "hevc_epel_uni", checkasm_check_hevc_epel_uni },
+{ "hevc_epel_uni_w", checkasm_check_hevc_epel_uni_w },
+{ "hevc_epel_bi", checkasm_check_hevc_epel_bi },
+{ "hevc_epel_bi_w", checkasm_check_hevc_epel_bi_w },
 { "hevc_sao", checkasm_check_hevc_sao },
 #endif
 #if CONFIG_HUFFYUV_DECODER
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 0190bc912c..ef6645e3a2 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -58,6 +58,16 @@ void checkasm_check_h264pred(void);
 void checkasm_check_h264qpel(void);
 void checkasm_check_hevc_add_res(void);
 void checkasm_check_hevc_idct(void);
+void checkasm_check_hevc_qpel(void);
+void checkasm_check_hevc_qpel_uni(void);
+void checkasm_check_hevc_qpel_uni_w(void);
+void checkasm_check_hevc_qpel_bi(void);
+void checkasm_check_hevc_qpel_bi_w(void);
+void checkasm_check_hevc_epel(void);
+void checkasm_check_hevc_epel_uni(void);
+void checkasm_check_hevc_epel_uni_w(void);
+void checkasm_check_hevc_epel_bi(void);
+void checkasm_check_hevc_epel_bi_w(void);
 void checkasm_check_hevc_sao(void);
 void checkasm_check_huffyuvdsp(void);
 void checkasm_check_jpeg2000dsp(void);
diff --git a/tests/checkasm/hevc_pel.c b/tests/checkasm/hevc_pel.c
new file mode 100644
index 00..236404f8ff
--- /dev/null
+++ b/tests/checkasm/hevc_pel.c
@@ -0,0 +1,523 @@
+/*
+ * Copyright (c) 2015 Henrik Gramner
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+#include "checkasm.h"
+#include "libavcodec/hevcdsp.h"
+#include "libavutil/common.h"
+#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
+
+static const uint32_t pixel_mask[] = { 0x, 0x01ff01ff, 0x03ff03ff, 
0x07ff07ff, 0x0fff0fff };
+static const uint32_t pixel_mask16[] = { 0x00ff00ff, 0x01ff01ff, 0x03ff03ff, 
0x07ff07ff, 0x0fff0fff };
+static const int sizes[] = { -1, 4, 6, 8, 12, 16, 24, 32, 48, 64 };
+static const int weights[] = { 0, 128, 255, -1 };
+static const int denoms[] = {0, 7, 12, -1 };
+static const int offsets[] = {0, 255, -1 };
+
+#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
+#define BUF_SIZE (2 * MAX_PB_SIZE * (2 * 4 + MAX_PB_SIZE))
+
+#define randomize_buffers()  \
+do { \
+uint32_t mask = pixel_mask[bit_depth - 8];   \
+int k;   \
+for (k = 0; k < BUF_SIZE; k += 4) {  \
+uint32_t r = rnd() & mask; 

[FFmpeg-devel] [PATCH 3/4] lavc/aarch64: add HEVC sao_band NEON

2021-01-07 Thread Josh Dekker
Only works for 8x8.

Signed-off-by: Josh Dekker 
---
 libavcodec/aarch64/Makefile   |  3 +-
 libavcodec/aarch64/hevcdsp_init.c |  7 +++
 libavcodec/aarch64/hevcdsp_sao_neon.S | 87 +++
 3 files changed, 96 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/aarch64/hevcdsp_sao_neon.S

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 42d80bf74c..1f54fc31f4 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -55,7 +55,8 @@ NEON-OBJS-$(CONFIG_VP8DSP)  += 
aarch64/vp8dsp_neon.o
 NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_neon.o
 NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
 NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_add_res_neon.o  
\
-   aarch64/hevcdsp_idct_neon.o
+   aarch64/hevcdsp_idct_neon.o 
\
+   aarch64/hevcdsp_sao_neon.o
 NEON-OBJS-$(CONFIG_OPUS_DECODER)+= aarch64/opusdsp_neon.o
 NEON-OBJS-$(CONFIG_VORBIS_DECODER)  += aarch64/vorbisdsp_neon.o
 NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o   
\
diff --git a/libavcodec/aarch64/hevcdsp_init.c 
b/libavcodec/aarch64/hevcdsp_init.c
index 2cd7ef3a6c..8f0a923ab1 100644
--- a/libavcodec/aarch64/hevcdsp_init.c
+++ b/libavcodec/aarch64/hevcdsp_init.c
@@ -23,6 +23,11 @@
 #include "libavcodec/hevcdsp.h"
 #include "libavcodec/avcodec.h"
 
+void ff_hevc_sao_band_filter_8x8_8_neon(uint8_t *_dst, uint8_t *_src,
+  ptrdiff_t stride_dst, ptrdiff_t stride_src,
+  int16_t *sao_offset_val, int sao_left_class,
+  int width, int height);
+
 void ff_hevc_idct_4x4_dc_8_neon(int16_t *coeffs);
 void ff_hevc_idct_8x8_dc_8_neon(int16_t *coeffs);
 void ff_hevc_idct_16x16_dc_8_neon(int16_t *coeffs);
@@ -53,6 +58,8 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, 
const int bit_depth)
 {
 int cpu_flags = av_get_cpu_flags();
 if (have_neon(cpu_flags) && bit_depth == 8) {
+c->sao_band_filter[0]  = ff_hevc_sao_band_filter_8x8_8_neon;
+
 c->add_residual[0] = ff_hevc_add_residual_4x4_8_neon;
 c->add_residual[1] = ff_hevc_add_residual_8x8_8_neon;
 c->add_residual[2] = ff_hevc_add_residual_16x16_8_neon;
diff --git a/libavcodec/aarch64/hevcdsp_sao_neon.S 
b/libavcodec/aarch64/hevcdsp_sao_neon.S
new file mode 100644
index 00..25b6c25117
--- /dev/null
+++ b/libavcodec/aarch64/hevcdsp_sao_neon.S
@@ -0,0 +1,87 @@
+/* -*-arm64-*-
+ * vim: syntax=arm64asm
+ *
+ * AArch64 NEON optimised SAO functions for HEVC decoding
+ *
+ * Copyright (c) 2020 Josh Dekker 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+// void sao_band_filter(uint8_t *_dst, uint8_t *_src,
+//  ptrdiff_t stride_dst, ptrdiff_t stride_src,
+//  int16_t *sao_offset_val, int sao_left_class,
+//  int width, int height)
+function ff_hevc_sao_band_filter_8x8_8_neon, export=1
+sub sp, sp, #64
+stp xzr, xzr, [sp]
+stp xzr, xzr, [sp, #16]
+stp xzr, xzr, [sp, #32]
+stp xzr, xzr, [sp, #48]
+mov w8, #4
+.setup:
+ldrsh x9, [x4, x8, lsl #1] // x9 = sao_offset_val[k+1]
+subs w8, w8, #1
+add w10, w8, w5 // x10 = k + sao_left_class
+and w10, w10, #0x1F
+strh w9, [sp, x10, lsl #1]
+bne .setup
+ld1 {v16.16B-v19.16B}, [sp], #64
+movi v20.8H, #1
+0:  // beginning of line
+mov w8, w6
+8:
+// Simple layout for accessing 16bit values
+// with 8bit LUT.
+//
+//   00  01  02  03  04  05  06  07
+// +--->
+// |xDE#xAD|xCA#xFE|xBE#xEF|xFE#xED|
+// +--->
+//i-0 i-1 i-2 i-3
+// dst[x] = av_clip_pixel(src[x] + offset_table[src[x] >> shift]);
+ld1 {v2.8B}, [x1]
+// load src[x]
+ushll v0.8H, v2.8B, #0
+// >> shift
+ushr v2.8H, v0.8H, #3 // BIT_DEPTH - 3
+// x2 (access lower short)
+shl v1.8H, v2.8H, #1 // low 

[FFmpeg-devel] [PATCH 2/4] lavc/aarch64: add HEVC idct_dc NEON

2021-01-07 Thread Josh Dekker
Signed-off-by: Josh Dekker 
---
 libavcodec/aarch64/Makefile|  3 +-
 libavcodec/aarch64/hevcdsp_idct_neon.S | 74 ++
 libavcodec/aarch64/hevcdsp_init.c  | 19 +++
 3 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/aarch64/hevcdsp_idct_neon.S

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 4bdd554e7e..42d80bf74c 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -54,7 +54,8 @@ NEON-OBJS-$(CONFIG_VP8DSP)  += 
aarch64/vp8dsp_neon.o
 # decoders/encoders
 NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_neon.o
 NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
-NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_add_res_neon.o
+NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_add_res_neon.o  
\
+   aarch64/hevcdsp_idct_neon.o
 NEON-OBJS-$(CONFIG_OPUS_DECODER)+= aarch64/opusdsp_neon.o
 NEON-OBJS-$(CONFIG_VORBIS_DECODER)  += aarch64/vorbisdsp_neon.o
 NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o   
\
diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S 
b/libavcodec/aarch64/hevcdsp_idct_neon.S
new file mode 100644
index 00..cd886bb6dc
--- /dev/null
+++ b/libavcodec/aarch64/hevcdsp_idct_neon.S
@@ -0,0 +1,74 @@
+/* -*-arm64-*-
+ *
+ * AArch64 NEON optimised IDCT functions for HEVC decoding
+ *
+ * Copyright (c) 2020 Josh Dekker 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+.macro idct_dc size bitdepth
+function ff_hevc_idct_\size\()x\size\()_dc_\bitdepth\()_neon, export=1
+ldrsh w1, [x0]
+mov   w2, #(1 << (13 - \bitdepth))
+add   w1, w1, #1
+asr   w1, w1, #1
+add   w1, w1, w2
+asr   w1, w1, #(14 - \bitdepth)
+dup   v0.8h, w1
+dup   v1.8h, w1
+.if \size > 4
+dup   v2.8h, w1
+dup   v3.8h, w1
+.if \size > 16 /* dc 32x32 */
+mov x2, #4
+1:
+subs x2, x2, #1
+.endif
+.if \size > 8 /* dc 16x16 */
+st1   {v0.8h-v3.8h}, [x0], #64
+st1   {v0.8h-v3.8h}, [x0], #64
+st1   {v0.8h-v3.8h}, [x0], #64
+st1   {v0.8h-v3.8h}, [x0], #64
+st1   {v0.8h-v3.8h}, [x0], #64
+st1   {v0.8h-v3.8h}, [x0], #64
+.endif /* dc 8x8 */
+st1   {v0.8h-v3.8h}, [x0], #64
+st1   {v0.8h-v3.8h}, [x0], #64
+.if \size > 16 /* dc 32x32 */
+bne 1b
+.endif
+.else /* dc 4x4 */
+st1   {v0.8h-v1.8h}, [x0]
+.endif
+ret
+endfunc
+.endm
+
+idct_dc 4 8
+idct_dc 4 10
+
+idct_dc 8 8
+idct_dc 8 10
+
+idct_dc 16 8
+idct_dc 16 10
+
+idct_dc 32 8
+idct_dc 32 10
diff --git a/libavcodec/aarch64/hevcdsp_init.c 
b/libavcodec/aarch64/hevcdsp_init.c
index f0a617ab39..2cd7ef3a6c 100644
--- a/libavcodec/aarch64/hevcdsp_init.c
+++ b/libavcodec/aarch64/hevcdsp_init.c
@@ -23,6 +23,15 @@
 #include "libavcodec/hevcdsp.h"
 #include "libavcodec/avcodec.h"
 
+void ff_hevc_idct_4x4_dc_8_neon(int16_t *coeffs);
+void ff_hevc_idct_8x8_dc_8_neon(int16_t *coeffs);
+void ff_hevc_idct_16x16_dc_8_neon(int16_t *coeffs);
+void ff_hevc_idct_32x32_dc_8_neon(int16_t *coeffs);
+void ff_hevc_idct_4x4_dc_10_neon(int16_t *coeffs);
+void ff_hevc_idct_8x8_dc_10_neon(int16_t *coeffs);
+void ff_hevc_idct_16x16_dc_10_neon(int16_t *coeffs);
+void ff_hevc_idct_32x32_dc_10_neon(int16_t *coeffs);
+
 void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, int16_t *coeffs,
  ptrdiff_t stride);
 void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, int16_t *coeffs,
@@ -48,6 +57,11 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, 
const int bit_depth)
 c->add_residual[1] = ff_hevc_add_residual_8x8_8_neon;
 c->add_residual[2] = ff_hevc_add_residual_16x16_8_neon;
 c->add_residual[3] = ff_hevc_add_residual_32x32_8_neon;
+
+c->idct_dc[0]  = ff_hevc_idct_4x4_dc_8_neon;
+c->idct_dc[1]  = ff_hevc_idct_8x8_dc_8_neon;
+c->idct_dc[2]  = ff_hevc_idct_16x16_dc_8_neon;
+c->idct_dc[3]  = ff_hevc_idct_32x32_dc_8_neon;
 }
 
 if (have_neon(cpu_flags) && bit_depth == 10) {
@@ -55,5 +69,10 @@ av_cold void 

[FFmpeg-devel] [PATCH 1/4] lavc/aarch64: add HEVC add_residual NEON

2021-01-07 Thread Josh Dekker
Signed-off-by: Josh Dekker 
---
 libavcodec/aarch64/Makefile   |   2 +
 libavcodec/aarch64/hevcdsp_add_res_neon.S | 298 ++
 libavcodec/aarch64/hevcdsp_init.c |  59 +
 libavcodec/hevcdsp.c  |   2 +
 libavcodec/hevcdsp.h  |   1 +
 5 files changed, 362 insertions(+)
 create mode 100644 libavcodec/aarch64/hevcdsp_add_res_neon.S
 create mode 100644 libavcodec/aarch64/hevcdsp_init.c

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index f6434e40da..4bdd554e7e 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -17,6 +17,7 @@ OBJS-$(CONFIG_VP8DSP)   += 
aarch64/vp8dsp_init_aarch64.o
 OBJS-$(CONFIG_AAC_DECODER)  += aarch64/aacpsdsp_init_aarch64.o \
aarch64/sbrdsp_init_aarch64.o
 OBJS-$(CONFIG_DCA_DECODER)  += aarch64/synth_filter_init.o
+OBJS-$(CONFIG_HEVC_DECODER) += aarch64/hevcdsp_init.o
 OBJS-$(CONFIG_OPUS_DECODER) += aarch64/opusdsp_init.o
 OBJS-$(CONFIG_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o
 OBJS-$(CONFIG_VC1DSP)   += aarch64/vc1dsp_init_aarch64.o
@@ -53,6 +54,7 @@ NEON-OBJS-$(CONFIG_VP8DSP)  += 
aarch64/vp8dsp_neon.o
 # decoders/encoders
 NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_neon.o
 NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
+NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_add_res_neon.o
 NEON-OBJS-$(CONFIG_OPUS_DECODER)+= aarch64/opusdsp_neon.o
 NEON-OBJS-$(CONFIG_VORBIS_DECODER)  += aarch64/vorbisdsp_neon.o
 NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o   
\
diff --git a/libavcodec/aarch64/hevcdsp_add_res_neon.S 
b/libavcodec/aarch64/hevcdsp_add_res_neon.S
new file mode 100644
index 00..4005366192
--- /dev/null
+++ b/libavcodec/aarch64/hevcdsp_add_res_neon.S
@@ -0,0 +1,298 @@
+/* -*-arm64-*-
+ *
+ * AArch64 NEON optimised add residual functions for HEVC decoding
+ *
+ * Copyright (c) 2020 Josh Dekker 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+.macro clip10 in1, in2, c1, c2
+smax \in1, \in1, \c1
+smax \in2, \in2, \c1
+smin \in1, \in1, \c2
+smin \in2, \in2, \c2
+.endm
+
+function ff_hevc_add_residual_4x4_8_neon, export=1
+mov x3, x0
+ld1 {v0.S}[0], [x3], x2
+ld1 {v0.S}[1], [x3], x2
+ld1 {v1.S}[0], [x3], x2
+ld1 {v1.S}[1], [x3], x2
+ld1 { v2.8H-v3.8H}, [x1]
+ushll v4.8H, v0.8B, #0
+ushll v5.8H, v1.8B, #0
+add v6.8H, v4.8H, v2.8H
+add v7.8H, v5.8H, v3.8H
+sqxtun v0.8B, v6.8H
+sqxtun v1.8B, v7.8H
+st1 {v0.S}[0], [x0], x2
+st1 {v0.S}[1], [x0], x2
+st1 {v1.S}[0], [x0], x2
+st1 {v1.S}[1], [x0], x2
+ret
+endfunc
+
+function ff_hevc_add_residual_4x4_10_neon, export=1
+mov x3, x0
+movi v4.8H, #0
+mvni v5.8H, #0xFC, lsl #8
+ld1 {v0.D}[0], [x3], x2
+ld1 {v0.D}[1], [x3], x2
+ld1 {v1.D}[0], [x3], x2
+ld1 {v1.D}[1], [x3], x2
+ld1 { v2.8H-v3.8H}, [x1]
+add v2.8H, v0.8H, v2.8H
+add v3.8H, v1.8H, v3.8H
+clip10 v2.8H, v3.8H, v4.8H, v5.8H
+st1 {v2.D}[0], [x0], x2
+st1 {v2.D}[1], [x0], x2
+st1 {v3.D}[0], [x0], x2
+st1 {v3.D}[1], [x0], x2
+ret
+endfunc
+
+function ff_hevc_add_residual_8x8_8_neon, export=1
+mov x3, x0
+ld1 {v0.8B}, [x3], x2
+ld1 {v1.8B}, [x3], x2
+ld1 {v2.8B}, [x3], x2
+ld1 {v3.8B}, [x3], x2
+ld1 {v4.8B}, [x3], x2
+ld1 {v5.8B}, [x3], x2
+ld1 {v6.8B}, [x3], x2
+ld1 {v7.8B}, [x3], x2
+ld1 { v16.8H-v19.8H}, [x1], #64
+ld1 { v20.8H-v23.8H}, [x1]
+ushll v24.8H, v0.8B, #0
+ushll v25.8H, v1.8B, #0
+ushll v26.8H, v2.8B, #0
+ushll v27.8H, v3.8B, #0
+ushll v28.8H, v4.8B, #0
+ushll v29.8H, v5.8B, #0
+ushll v30.8H, v6.8B, #0
+ushll v31.8H, v7.8B, #0
+add v0.8H, v24.8H, v16.8H
+add v1.8H, v25.8H, v17.8H
+add v2.8H, v26.8H, v18.8H
+add v3.8H, v27.8H, v19.8H
+add v4.8H, v28.8H, v20.8H
+add v5.8H, v29.8H, v21.8H
+add v6.8H, v30.8H, v22.8H
+add v7.8H, v31.8H, v23.8H
+sqxtun v24.8B, v0.8H
+sqxtun v25.8B, v1.8H

[FFmpeg-devel] [PATCH 0/4] AArch64 NEON for HEVC

2021-01-07 Thread Josh Dekker
checkasm: all 657 tests passed
hevc_add_res_4x4_8_c: 49.7
hevc_add_res_4x4_8_neon: 20.5
hevc_add_res_4x4_10_c: 45.7
hevc_add_res_4x4_10_neon: 18.7
hevc_add_res_8x8_8_c: 211.0
hevc_add_res_8x8_8_neon: 24.5
hevc_add_res_8x8_10_c: 195.7
hevc_add_res_8x8_10_neon: 24.0
hevc_add_res_16x16_8_c: 787.2
hevc_add_res_16x16_8_neon: 79.0
hevc_add_res_16x16_10_c: 714.7
hevc_add_res_16x16_10_neon: 77.7
hevc_add_res_32x32_8_c: 3444.2
hevc_add_res_32x32_8_neon: 306.5
hevc_add_res_32x32_10_c: 3820.7
hevc_add_res_32x32_10_neon: 299.5
hevc_idct_4x4_dc_8_c: 16.2
hevc_idct_4x4_dc_8_neon: 13.7
hevc_idct_4x4_dc_10_c: 16.2
hevc_idct_4x4_dc_10_neon: 14.5
hevc_idct_8x8_dc_8_c: 40.7
hevc_idct_8x8_dc_8_neon: 18.5
hevc_idct_8x8_dc_10_c: 39.2
hevc_idct_8x8_dc_10_neon: 19.2
hevc_idct_16x16_dc_8_c: 136.7
hevc_idct_16x16_dc_8_neon: 35.7
hevc_idct_16x16_dc_10_c: 136.0
hevc_idct_16x16_dc_10_neon: 36.0
hevc_idct_32x32_dc_8_c: 1386.7
hevc_idct_32x32_dc_8_neon: 132.0
hevc_idct_32x32_dc_10_c: 1366.2
hevc_idct_32x32_dc_10_neon: 132.0
hevc_sao_band_8x8_8_c: 230.7
hevc_sao_band_8x8_8_neon: 92.7

Please disregard my previous email with subject 'lavc/aarch64: add HEVC
add_residual NEON', the patch was split incorrectly.

IDCT (first) and QPEL functions in the works, then SAO edge, and
whatever is left for parity with ARM NEON.

-- 
Josh


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

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

Re: [FFmpeg-devel] [PATCH 2/6] avcodec: add h266 codec id and profiles

2021-01-07 Thread Nuo Mi
On Sat, Jan 2, 2021 at 10:06 AM Nuo Mi  wrote:

> Hi Mark & all,
> Happy new year!
> I have implemented the h266 metadata bsf. For all vvdec decodable clips,
> the metadata pass-through mode can get a bit matched result.
> Could you align with James about the name convention, so I can send the
> second patchset?
>
> BTW: could you share the hevc aud adding command line?
> I tried "ffmpeg -i input.265  -c:v copy -bsf h266_metadata -aud insert
> output.265", but the output.265 has no aud.
>
> thanks
>
>
> On Sat, Dec 26, 2020 at 9:37 AM Nuo Mi  wrote:
>
>>
>>
>> On Tue, Dec 22, 2020 at 6:37 PM Nuo Mi  wrote:
>>
>>>
>>> Hi James,
>>> thanks for the review.
>>>
>>> On Mon, Dec 21, 2020 at 11:14 PM James Almer  wrote:
>>>
 On 12/21/2020 3:07 AM, Nuo Mi wrote:
 > ---
 >   libavcodec/avcodec.h| 2 ++
 >   libavcodec/codec_desc.c | 8 
 >   libavcodec/codec_id.h   | 2 ++
 >   libavcodec/profiles.c   | 5 +
 >   libavcodec/profiles.h   | 1 +
 >   5 files changed, 18 insertions(+)
 >
 > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
 > index 1d3099d50a..f7ea4d5849 100644
 > --- a/libavcodec/avcodec.h
 > +++ b/libavcodec/avcodec.h
 > @@ -1961,6 +1961,8 @@ typedef struct AVCodecContext {
 >   #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
 >   #define FF_PROFILE_HEVC_REXT4
 >
 > +#define FF_PROFILE_H266_MAIN_10  1

 We should decide first what we are going to use, if VVC or h266.

 My suggestion was to use VVC for decoder, parser, demuxer and public
 defines, which is what's exposed to the user, and h266 for CBS, which
 makes things simpler to implement and is proper consider it's written
 using the ITU spec.

>>> Sorry for missed this. But seems mark and you have a different
>>> suggestion.  Could you align with him and other maintainers?
>>> I can continue to address other issues. It's not too later to change
>>> this before I checked the patch set.
>>>
>> Hi Mark,
>> Most of the issue are addressed.  I will send the second reversion of
>> this patchset.
>> Are you ok with James's suggestion?
>>
>
Hi Mark,
ping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] lavc/aarch64: add HEVC add_residual NEON

2021-01-07 Thread Josh Dekker
Signed-off-by: Josh Dekker 
---

checkasm: all 648 tests passed
hevc_add_res_4x4_8_c: 49.7
hevc_add_res_4x4_8_neon: 20.5
hevc_add_res_4x4_10_c: 46.0
hevc_add_res_4x4_10_neon: 19.0
hevc_add_res_8x8_8_c: 209.0
hevc_add_res_8x8_8_neon: 24.5
hevc_add_res_8x8_10_c: 192.7
hevc_add_res_8x8_10_neon: 27.0
hevc_add_res_16x16_8_c: 791.5
hevc_add_res_16x16_8_neon: 79.0
hevc_add_res_16x16_10_c: 711.0
hevc_add_res_16x16_10_neon: 77.7
hevc_add_res_32x32_8_c: 3431.2
hevc_add_res_32x32_8_neon: 306.5
hevc_add_res_32x32_10_c: 3825.0
hevc_add_res_32x32_10_neon: 299.5

 libavcodec/aarch64/Makefile   |   3 +
 libavcodec/aarch64/hevcdsp_add_res_neon.S | 298 ++
 libavcodec/aarch64/hevcdsp_idct_neon.S|  24 ++
 libavcodec/aarch64/hevcdsp_init.c |  59 +
 libavcodec/hevcdsp.c  |   2 +
 libavcodec/hevcdsp.h  |   1 +
 6 files changed, 387 insertions(+)
 create mode 100644 libavcodec/aarch64/hevcdsp_add_res_neon.S
 create mode 100644 libavcodec/aarch64/hevcdsp_idct_neon.S
 create mode 100644 libavcodec/aarch64/hevcdsp_init.c

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index f6434e40da..0eaafce74b 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -17,6 +17,7 @@ OBJS-$(CONFIG_VP8DSP)   += 
aarch64/vp8dsp_init_aarch64.o
 OBJS-$(CONFIG_AAC_DECODER)  += aarch64/aacpsdsp_init_aarch64.o \
aarch64/sbrdsp_init_aarch64.o
 OBJS-$(CONFIG_DCA_DECODER)  += aarch64/synth_filter_init.o
+OBJS-$(CONFIG_HEVC_DECODER) += aarch64/hevcdsp_init.o
 OBJS-$(CONFIG_OPUS_DECODER) += aarch64/opusdsp_init.o
 OBJS-$(CONFIG_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o
 OBJS-$(CONFIG_VC1DSP)   += aarch64/vc1dsp_init_aarch64.o
@@ -53,6 +54,8 @@ NEON-OBJS-$(CONFIG_VP8DSP)  += 
aarch64/vp8dsp_neon.o
 # decoders/encoders
 NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_neon.o
 NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
+NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_add_res_neon.o  
 \
+   aarch64/hevcdsp_idct_neon.o
 NEON-OBJS-$(CONFIG_OPUS_DECODER)+= aarch64/opusdsp_neon.o
 NEON-OBJS-$(CONFIG_VORBIS_DECODER)  += aarch64/vorbisdsp_neon.o
 NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o   
\
diff --git a/libavcodec/aarch64/hevcdsp_add_res_neon.S 
b/libavcodec/aarch64/hevcdsp_add_res_neon.S
new file mode 100644
index 00..dc7e8127b9
--- /dev/null
+++ b/libavcodec/aarch64/hevcdsp_add_res_neon.S
@@ -0,0 +1,298 @@
+/* -*-armv8-*-
+ *
+ * AArch64 NEON optimised add residual functions for HEVC decoding
+ *
+ * Copyright (c) 2020 Josh Dekker 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/aarch64/asm.S"
+
+.macro clip10 in1, in2, c1, c2
+smax \in1, \in1, \c1
+smax \in2, \in2, \c1
+smin \in1, \in1, \c2
+smin \in2, \in2, \c2
+.endm
+
+function ff_hevc_add_residual_4x4_8_neon, export=1
+mov x3, x0
+ld1 {v0.S}[0], [x3], x2
+ld1 {v0.S}[1], [x3], x2
+ld1 {v1.S}[0], [x3], x2
+ld1 {v1.S}[1], [x3], x2
+ld1 { v2.8H-v3.8H}, [x1]
+ushll v4.8H, v0.8B, #0
+ushll v5.8H, v1.8B, #0
+add v6.8H, v4.8H, v2.8H
+add v7.8H, v5.8H, v3.8H
+sqxtun v0.8B, v6.8H
+sqxtun v1.8B, v7.8H
+st1 {v0.S}[0], [x0], x2
+st1 {v0.S}[1], [x0], x2
+st1 {v1.S}[0], [x0], x2
+st1 {v1.S}[1], [x0], x2
+ret
+endfunc
+
+function ff_hevc_add_residual_4x4_10_neon, export=1
+mov x3, x0
+movi v4.8H, #0
+mvni v5.8H, #0xFC, lsl #8
+ld1 {v0.D}[0], [x3], x2
+ld1 {v0.D}[1], [x3], x2
+ld1 {v1.D}[0], [x3], x2
+ld1 {v1.D}[1], [x3], x2
+ld1 { v2.8H-v3.8H}, [x1]
+add v2.8H, v0.8H, v2.8H
+add v3.8H, v1.8H, v3.8H
+clip10 v2.8H, v3.8H, v4.8H, v5.8H
+st1 {v2.D}[0], [x0], x2
+st1 {v2.D}[1], [x0], x2
+st1 {v3.D}[0], [x0], x2
+st1 {v3.D}[1], [x0], x2
+ret
+endfunc
+
+function ff_hevc_add_residual_8x8_8_neon, export=1
+mov x3, x0
+ld1 {v0.8B}, [x3], x2
+ld1 {v1.8B}, [x3], x2
+ld1 {v2.8B}, [x3], x2
+ld1 {v3.8B}, 

[FFmpeg-devel] [PATCH v2 2/3] avformat/udp: add memory alloc checks

2021-01-07 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 798b789..e6d1235 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -891,6 +891,10 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if ((!is_output && s->circular_buffer_size) || (is_output && s->bitrate && 
s->circular_buffer_size)) {
 /* start the task going */
 s->fifo = av_fifo_alloc(s->circular_buffer_size);
+if (s->fifo) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 ret = pthread_mutex_init(>mutex, NULL);
 if (ret != 0) {
 av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
strerror(ret));
-- 
1.8.3.1

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

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

[FFmpeg-devel] [PATCH v2 1/3] avformat/udp: return the error code instead of generic EIO

2021-01-07 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/udp.c | 47 +++
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 13c346a..798b789 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -633,6 +633,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 char buf[256];
 struct sockaddr_storage my_addr;
 socklen_t len;
+int ret = AVERROR(EIO);
 
 h->is_streamed = 1;
 
@@ -641,12 +642,12 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE;
 
 if (s->sources) {
-if (ff_ip_parse_sources(h, s->sources, >filters) < 0)
+if ((ret = ff_ip_parse_sources(h, s->sources, >filters)) < 0)
 goto fail;
 }
 
 if (s->block) {
-if (ff_ip_parse_blocks(h, s->block, >filters) < 0)
+if ((ret = ff_ip_parse_blocks(h, s->block, >filters)) < 0)
 goto fail;
 }
 
@@ -712,11 +713,11 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 av_strlcpy(localaddr, buf, sizeof(localaddr));
 }
 if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
-if (ff_ip_parse_sources(h, buf, >filters) < 0)
+if ((ret = ff_ip_parse_sources(h, buf, >filters)) < 0)
 goto fail;
 }
 if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
-if (ff_ip_parse_blocks(h, buf, >filters) < 0)
+if ((ret = ff_ip_parse_blocks(h, buf, >filters)) < 0)
 goto fail;
 }
 if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p))
@@ -742,7 +743,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if (!(flags & AVIO_FLAG_READ))
 goto fail;
 } else {
-if (ff_udp_set_remote_url(h, uri) < 0)
+if ((ret = ff_udp_set_remote_url(h, uri)) < 0)
 goto fail;
 }
 
@@ -763,13 +764,13 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
  */
 if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) {
 s->reuse_socket = 1;
-if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), 
sizeof(s->reuse_socket)) != 0)
+if ((ret = setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, 
&(s->reuse_socket), sizeof(s->reuse_socket))) != 0)
 goto fail;
 }
 
 if (s->is_broadcast) {
 #ifdef SO_BROADCAST
-if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), 
sizeof(s->is_broadcast)) != 0)
+if ((ret = setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, 
&(s->is_broadcast), sizeof(s->is_broadcast))) != 0)
 #endif
goto fail;
 }
@@ -779,16 +780,16 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
  * Otherwise, the receiver will drop all packets.
  */
 if (s->udplite_coverage) {
-if (setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV, 
&(s->udplite_coverage), sizeof(s->udplite_coverage)) != 0)
+if ((ret = setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV, 
&(s->udplite_coverage), sizeof(s->udplite_coverage))) != 0)
 av_log(h, AV_LOG_WARNING, "socket option UDPLITE_SEND_CSCOV not 
available");
 
-if (setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV, 
&(s->udplite_coverage), sizeof(s->udplite_coverage)) != 0)
+if ((ret = setsockopt (udp_fd, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV, 
&(s->udplite_coverage), sizeof(s->udplite_coverage))) != 0)
 av_log(h, AV_LOG_WARNING, "socket option UDPLITE_RECV_CSCOV not 
available");
 }
 
 if (dscp >= 0) {
 dscp <<= 2;
-if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , sizeof(dscp)) != 0)
+if ((ret = setsockopt (udp_fd, IPPROTO_IP, IP_TOS, , 
sizeof(dscp))) != 0)
 goto fail;
 }
 
@@ -802,7 +803,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 /* bind to the local address if not multicast or if the multicast
  * bind failed */
 /* the bind is needed to give a port to the socket now */
-if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)_addr, len) < 0) {
+if (bind_ret < 0 && (ret = bind(udp_fd,(struct sockaddr *)_addr, len)) 
< 0) {
 ff_log_net_error(h, AV_LOG_ERROR, "bind failed");
 goto fail;
 }
@@ -814,28 +815,28 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if (s->is_multicast) {
 if (h->flags & AVIO_FLAG_WRITE) {
 /* output */
-if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr 
*)>dest_addr) < 0)
+if ((ret = udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr 
*)>dest_addr)) < 0)
 goto fail;
 }
 if (h->flags & AVIO_FLAG_READ) {
 /* input */
 if (s->filters.nb_include_addrs) {
-   

[FFmpeg-devel] [PATCH v2 3/3] avformat/mxfenc: prefer to use the existing metadata

2021-01-07 Thread lance . lmwang
From: Limin Wang 

Please check metadata with below command:
./ffmpeg -i ../fate-suite/mxf/Sony-1.mxf -c:v copy -c:a copy out.mxf
./ffmpeg -i out.mxf

company_name: FFmpeg
product_name: OP1a Muxer
product_version : 58.65.101o
=>
company_name: SONY
product_name: eVTR
product_version : 1.00

So need to update fate-mxf fate test.

Signed-off-by: Limin Wang 
---
 libavformat/mxfenc.c| 12 
 tests/ref/fate/mxf-d10-user-comments|  2 +-
 tests/ref/fate/mxf-opatom-user-comments |  2 +-
 tests/ref/fate/mxf-reel_name|  2 +-
 tests/ref/fate/mxf-user-comments|  2 +-
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index d8678c9..5244211 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -722,16 +722,20 @@ static void mxf_write_identification(AVFormatContext *s)
 {
 MXFContext *mxf = s->priv_data;
 AVIOContext *pb = s->pb;
-const char *company = "FFmpeg";
-const char *product = s->oformat != _mxf_opatom_muxer ? "OP1a Muxer" : 
"OPAtom Muxer";
-const char *version;
+AVDictionaryEntry *com_entry =  av_dict_get(s->metadata, "company_name", 
NULL, 0);
+AVDictionaryEntry *product_entry =  av_dict_get(s->metadata, 
"product_name", NULL, 0);
+AVDictionaryEntry *version_entry =  av_dict_get(s->metadata, 
"product_version", NULL, 0);
+const char *company = com_entry ? com_entry->value : "FFmpeg";
+const char *product = product_entry ? product_entry->value : s->oformat != 
_mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
+const char *version = NULL;
+const char *product_version = version_entry ? version_entry->value : 
AV_STRINGIFY(LIBAVFORMAT_VERSION);
 int length;
 
 mxf_write_metadata_key(pb, 0x013000);
 PRINT_KEY(s, "identification key", pb->buf_ptr - 16);
 
 version = s->flags & AVFMT_FLAG_BITEXACT ?
-"0.0.0" : AV_STRINGIFY(LIBAVFORMAT_VERSION);
+"0.0.0" : product_version;
 length = 100 +mxf_utf16_local_tag_length(company) +
   mxf_utf16_local_tag_length(product) +
   mxf_utf16_local_tag_length(version);
diff --git a/tests/ref/fate/mxf-d10-user-comments 
b/tests/ref/fate/mxf-d10-user-comments
index de4f26c..4aebcaf 100644
--- a/tests/ref/fate/mxf-d10-user-comments
+++ b/tests/ref/fate/mxf-d10-user-comments
@@ -1 +1 @@
-68f0fa62b6a676894afbbe4c34ebf70b
+84e289a83797e793bfa0d3a31f94ac6c
diff --git a/tests/ref/fate/mxf-opatom-user-comments 
b/tests/ref/fate/mxf-opatom-user-comments
index 90e3fb2..374a72a 100644
--- a/tests/ref/fate/mxf-opatom-user-comments
+++ b/tests/ref/fate/mxf-opatom-user-comments
@@ -1 +1 @@
-f6760a9e710ba478bc3949f3e5c9b34a
+e7c41639b79ac54c4df05475fb0eea66
diff --git a/tests/ref/fate/mxf-reel_name b/tests/ref/fate/mxf-reel_name
index 16022b1..6e3218f 100644
--- a/tests/ref/fate/mxf-reel_name
+++ b/tests/ref/fate/mxf-reel_name
@@ -1 +1 @@
-73a891041b2fc836a893ffb49fff4fff
+be4c1b76138c855ac3e2d2579cbecc17
diff --git a/tests/ref/fate/mxf-user-comments b/tests/ref/fate/mxf-user-comments
index ddf51d9..46db6a3 100644
--- a/tests/ref/fate/mxf-user-comments
+++ b/tests/ref/fate/mxf-user-comments
@@ -1 +1 @@
-1255faf854223a74d707553121e5eca3
+8f2360104655971dc5fb68f98eda1b84
-- 
1.8.3.1

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

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

Re: [FFmpeg-devel] Issue with ogg page termination on full last page with even last segment size

2021-01-07 Thread Peter Zebühr
> On 5 Jan 2021, at 16:22, Lynne  wrote:
> 
> Was going to respond to this but forgot.
> Opus can have 0 byte packets to signal silence. So you'll have to fix this 
> for real.

Ok, sounds reasonable. Was also thinking that 0 byte packets would be 
reasonable to support from the containers perspective.

To clarify, the patch I am working on supports handling 0 byte packets better 
than what oggenc was previously doing.
So by fixing this for real, do you mean that I should try to figure out what is 
causing the encoder to produce a zero sized last packet in the fate test that 
is failing? 

I can have a look at that, but not sure if there is anything there. The other 
alternative that I can see is to update the reference for the fate test to 
expect one more page in the test that is failing.

/ Peter
___
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] Moves yuv2yuvX_sse3 to yasm, unrolls main loop and other small optimizations for ~20% speedup.

2021-01-07 Thread Alan Kelly
Thanks for your patience with this, I have replaced mova with movdqu - movu
generated a compile error on ssse3. What system did this crash on?

On Wed, Jan 6, 2021 at 9:10 PM Michael Niedermayer 
wrote:

> On Tue, Jan 05, 2021 at 01:31:25PM +0100, Alan Kelly wrote:
> > Ping!
>
> crashes (due to alignment i think)
>
> (gdb) disassemble $rip-32,$rip+32
> Dump of assembler code from 0x555730a1 to 0x555730e1:
>0x555730a1 :   int$0x71
>0x555730a3 :   out%al,$0x3
>0x555730a5 :   vpsraw $0x3,%ymm1,%ymm1
>0x555730aa :   vpackuswb %ymm4,%ymm3,%ymm3
>0x555730ae :   vpackuswb %ymm1,%ymm6,%ymm6
>0x555730b2 :   mov(%rdi),%rdx
>0x555730b5 :   vpermq $0xd8,%ymm3,%ymm3
>0x555730bb :   vpermq $0xd8,%ymm6,%ymm6
> => 0x555730c1 :   vmovdqa %ymm3,(%rcx,%rax,1)
>0x555730c6 :   vmovdqa
> %ymm6,0x20(%rcx,%rax,1)
>0x555730cc :   add$0x40,%rax
>0x555730d0 :   mov%rdi,%rsi
>0x555730d3 :   cmp%r8,%rax
>0x555730d6 :   jb 0x5557304d
> 
>0x555730dc :   vzeroupper
>0x555730df :   retq
>0x555730e0 : push   %r15
> End of assembler dump.
> (gdb) info all-registers
> rax0x0  0
> rbx0x0  0
> rcx0x5583f470   93824995292272
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Modern terrorism, a quick summary: Need oil, start war with country that
> has oil, kill hundread thousand in war. Let country fall into chaos,
> be surprised about raise of fundamantalists. Drop more bombs, kill more
> people, be surprised about them taking revenge and drop even more bombs
> and strip your own citizens of their rights and freedoms. to be continued
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] Moves yuv2yuvX_sse3 to yasm, unrolls main loop and other small optimizations for ~20% speedup.

2021-01-07 Thread Alan Kelly
---
 Replaces mova with movdqu due to alignment issues
 libswscale/x86/Makefile |   1 +
 libswscale/x86/swscale.c| 106 +---
 libswscale/x86/yuv2yuvX.asm | 117 
 tests/checkasm/sw_scale.c   |  98 ++
 4 files changed, 246 insertions(+), 76 deletions(-)
 create mode 100644 libswscale/x86/yuv2yuvX.asm

diff --git a/libswscale/x86/Makefile b/libswscale/x86/Makefile
index 831d5359aa..bfe383364e 100644
--- a/libswscale/x86/Makefile
+++ b/libswscale/x86/Makefile
@@ -13,3 +13,4 @@ X86ASM-OBJS += x86/input.o
  \
x86/scale.o  \
x86/rgb_2_rgb.o  \
x86/yuv_2_rgb.o  \
+   x86/yuv2yuvX.o   \
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 3160fedf04..8cd8713705 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -197,81 +197,30 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY)
 }
 
 #if HAVE_MMXEXT
-static void yuv2yuvX_sse3(const int16_t *filter, int filterSize,
-   const int16_t **src, uint8_t *dest, int dstW,
-   const uint8_t *dither, int offset)
-{
-if(((uintptr_t)dest) & 15){
-yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset);
-return;
-}
-filterSize--;
-#define MAIN_FUNCTION \
-"pxor   %%xmm0, %%xmm0 \n\t" \
-"punpcklbw  %%xmm0, %%xmm3 \n\t" \
-"movd   %4, %%xmm1 \n\t" \
-"punpcklwd  %%xmm1, %%xmm1 \n\t" \
-"punpckldq  %%xmm1, %%xmm1 \n\t" \
-"punpcklqdq %%xmm1, %%xmm1 \n\t" \
-"psllw  $3, %%xmm1 \n\t" \
-"paddw  %%xmm1, %%xmm3 \n\t" \
-"psraw  $4, %%xmm3 \n\t" \
-"movdqa %%xmm3, %%xmm4 \n\t" \
-"movdqa %%xmm3, %%xmm7 \n\t" \
-"movl   %3, %%ecx  \n\t" \
-"mov %0, %%"FF_REG_d"\n\t"\
-"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
-".p2align 4 \n\t" /* FIXME 
Unroll? */\
-"1: \n\t"\
-"movddup  8(%%"FF_REG_d"), %%xmm0   \n\t" /* 
filterCoeff */\
-"movdqa  (%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm2 \n\t" /* 
srcData */\
-"movdqa16(%%"FF_REG_S", %%"FF_REG_c", 2), %%xmm5 \n\t" /* 
srcData */\
-"add$16, %%"FF_REG_d"\n\t"\
-"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
-"test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
-"pmulhw   %%xmm0, %%xmm2  \n\t"\
-"pmulhw   %%xmm0, %%xmm5  \n\t"\
-"paddw%%xmm2, %%xmm3  \n\t"\
-"paddw%%xmm5, %%xmm4  \n\t"\
-" jnz1b \n\t"\
-"psraw   $3, %%xmm3  \n\t"\
-"psraw   $3, %%xmm4  \n\t"\
-"packuswb %%xmm4, %%xmm3  \n\t"\
-"movntdq  %%xmm3, (%1, %%"FF_REG_c") \n\t"\
-"add $16, %%"FF_REG_c"\n\t"\
-"cmp  %2, %%"FF_REG_c"\n\t"\
-"movdqa   %%xmm7, %%xmm3\n\t" \
-"movdqa   %%xmm7, %%xmm4\n\t" \
-"mov %0, %%"FF_REG_d"\n\t"\
-"mov(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
-"jb  1b \n\t"
-
-if (offset) {
-__asm__ volatile(
-"movq  %5, %%xmm3  \n\t"
-"movdqa%%xmm3, %%xmm4  \n\t"
-"psrlq$24, %%xmm3  \n\t"
-"psllq$40, %%xmm4  \n\t"
-"por   %%xmm4, %%xmm3  \n\t"
-MAIN_FUNCTION
-  :: "g" (filter),
-  "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset),
-  "m"(filterSize), "m"(((uint64_t *) dither)[0])
-  : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" , 
"%xmm5" , "%xmm7" ,)
-"%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_c
-  );
-} else {
-__asm__ volatile(
-"movq  %5, %%xmm3   \n\t"
-MAIN_FUNCTION
-  :: "g" (filter),
-  "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset),
-  "m"(filterSize), "m"(((uint64_t