[FFmpeg-devel] [PATCH] libavformat/mxfdec.c: Recognize and Ignore MXF fill boxes

2024-09-11 Thread Martin Schitter
This adds support for empty 'fill' boxes while decoding MXF files.
---
 libavformat/mxfdec.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 142b3e6..701fc9f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -367,6 +367,8 @@ static const uint8_t mxf_mca_rfc5646_spoken_language[] 
= { 0x06,0x0e,0x2b,0x
 
 static const uint8_t mxf_sub_descriptor[]  = { 
0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 
};
 
+static const uint8_t mxf_fill_key[]= { 
0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x01,0x02,0x10,0x01,0x00,0x00,0x00 
};
+
 static const uint8_t mxf_mastering_display_prefix[13]  = { 
FF_MXF_MasteringDisplay_PREFIX };
 static const uint8_t mxf_mastering_display_uls[4][16] = {
 FF_MXF_MasteringDisplayPrimaries,
@@ -3730,6 +3732,11 @@ static int mxf_read_header(AVFormatContext *s)
 continue;
 }
 
+if (IS_KLV_KEY(klv.key, mxf_fill_key)){
+avio_skip(s->pb, klv.length);
+continue;
+}
+
 PRINT_KEY(s, "read header", klv.key);
 av_log(s, AV_LOG_TRACE, "size %"PRIu64" offset %#"PRIx64"\n", 
klv.length, klv.offset);
 if (mxf_match_uid(klv.key, mxf_encrypted_triplet_key, 
sizeof(mxf_encrypted_triplet_key)) ||
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [PATCH v4 2/4] libavformat/mxf: DNxUncompressed MXF related changes

2024-09-11 Thread martin schitter



On 11.09.24 08:14, Tomas Härdin wrote:

btw. there is an annoying flaw in the ffmpeg mxf parser:

The very common 'fill' boxes, which are used in DNxUncompressed files
to
align 'pack' boxes on 265 byte boundaries, are not recognized by
ffmpegs
mxf parser and generate lots of
"Dark key 06.0e.2b.34.01.01.01.02.03.01.02.10.01.00.00.00" warnings.

>
Patch welcome 😉 


Done!


But surely we already deal with KAG fill? Maybe the UL
for it just has too large a matching length.. But looking at
mxf_metadata_read_table[] and searching for "fill" it appears we don't?


The 'fill' key is present and used on the mxf encoder side, but it 
wasn't recognized by the decoder until now.


I hope, my patch looks acceptable to you.

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

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


Re: [FFmpeg-devel] [PATCH] libavformat/mxfdec.c: Recognize and Ignore MXF fill boxes

2024-09-11 Thread Tomas Härdin
ons 2024-09-11 klockan 10:15 +0200 skrev Martin Schitter:
> This adds support for empty 'fill' boxes while decoding MXF files.
> ---
>  libavformat/mxfdec.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 142b3e6..701fc9f 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -367,6 +367,8 @@ static const uint8_t
> mxf_mca_rfc5646_spoken_language[] = { 0x06,0x0e,0x2b,0x
>  
>  static const uint8_t mxf_sub_descriptor[]  = {
> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10
> ,0x00,0x00 };
>  
> +static const uint8_t mxf_fill_key[]    = {
> 0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x01,0x02,0x10,0x01,0x00
> ,0x00,0x00 };
> +
>  static const uint8_t mxf_mastering_display_prefix[13]  = {
> FF_MXF_MasteringDisplay_PREFIX };
>  static const uint8_t mxf_mastering_display_uls[4][16] = {
>  FF_MXF_MasteringDisplayPrimaries,
> @@ -3730,6 +3732,11 @@ static int mxf_read_header(AVFormatContext *s)
>  continue;
>  }
>  
> +    if (IS_KLV_KEY(klv.key, mxf_fill_key)){
> +    avio_skip(s->pb, klv.length);
> +    continue;
> +    }

This could also be done using mxf_metadata_read_table[] using a simple
stub callback.

Alternatively we could add some logic to the parsing loop that skips
KLVs whose key's entry in the table have read == NULL. The loop
termination condition would need to either change to checking if the
first byte of the UL is zero, or maybe just use FF_ARRAY_ELEMS. This
way we could add more keys to skip in the future. This is also possible
with the stub approach

Another thing we could do while we're at it is to add a matching length
to MXFMetadataReadTableEntry, which would allow simplifying the table

Also IS_KLV_KEY() seems wrong. It should skip the version byte I think
(I'd have to double-check the spec). That doesn't need to hold up this
patch of course

/Tomas
___
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] is libswscale maintained?

2024-09-11 Thread Niklas Haas
On Wed, 11 Sep 2024 02:45:59 +0300 Andrew Randrianasulu 
 wrote:
> I can't find entry about it in ffmpeg/MAINTAINERS
>
> bugs meanwhile exist
>
> https://trac.ffmpeg.org/ticket/3345
> https://trac.ffmpeg.org/ticket/7978

There is on ongoing effort to redesign swscale, as well as fixing all currently
open bugs, throughout the rest of 2024. Stay tuned for this.

>
> I often saw suggestion to use -vf zscale but this is not default, and z.img
> upstream seems to be in suspended animation:
>
> https://github.com/sekrit-twc/zimg/issues/207
> ___
> 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 v5 1/4] libavcodec/dnxuc_parser: DNxUncompressed essence parser

2024-09-11 Thread Martin Schitter
This time only small corrections...

---
 libavcodec/dnxuc_parser.c | 124 ++
 libavcodec/parsers.c  |   1 +
 2 files changed, 125 insertions(+)
 create mode 100644 libavcodec/dnxuc_parser.c

diff --git a/libavcodec/dnxuc_parser.c b/libavcodec/dnxuc_parser.c
new file mode 100644
index 000..55d5763
--- /dev/null
+++ b/libavcodec/dnxuc_parser.c
@@ -0,0 +1,124 @@
+/*
+ * Avid DNxUncomressed / SMPTE RDD 50 parser
+ * Copyright (c) 2024 Martin Schitter
+ *
+ * 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
+ */
+
+/*
+ This parser for DNxUncompressed video data is mostly based on
+ reverse engineering of output generated by DaVinci Resolve 19
+ but was later also checked against the SMPTE RDD 50 specification.
+
+ Limitations: Multiple image planes are not supported.
+*/
+
+#include "avcodec.h"
+#include "libavutil/intreadwrite.h"
+
+typedef struct DNxUcParseContext {
+uint32_t fourcc_tag;
+uint32_t width;
+uint32_t height;
+uint32_t nr_bytes;
+} DNxUcParseContext;
+
+/*
+DNxUncompressed frame data comes wrapped in nested boxes of metadata
+(box structure: len + fourcc marker + data):
+
+[0-4]   len of outer essence unit box (typically 37 bytes of header + frame 
data)
+[4-7]   fourcc 'pack'
+
+[8-11]  len of "signal info box" (always 21)
+[12-15] fourcc 'sinf'
+[16-19] frame width / line packing size
+[20-23] frame hight / nr of lines
+[24-27] fourcc pixel format indicator
+[28]frame_layout (0: progressive, 1: interlaced)
+
+[29-32] len of "signal data box" (nr of frame data bytes + 8)
+[33-36] fourcc 'sdat'
+[37-..] frame data
+
+A sequence of 'signal info'+'signal data' box pairs wrapped in
+'icmp'(=image component) boxes can be utilized to compose more
+complex multi plane images.
+This feature is only partially supported in the present implementation.
+We never pick more than the first pair of info and image data enclosed
+in this way.
+*/
+
+static int dnxuc_parse(AVCodecParserContext *s,
+AVCodecContext *avctx,
+const uint8_t **poutbuf, int *poutbuf_size,
+const uint8_t *buf, int buf_size)
+{
+char fourcc_buf[5];
+const int HEADER_SIZE = 37;
+int icmp_offset = 0;
+
+DNxUcParseContext *pc;
+pc = (DNxUcParseContext *) s->priv_data;
+
+if (!buf_size) {
+return 0;
+}
+if (buf_size > 16 && MKTAG('i','c','m','p') == AV_RL32(buf+12)){
+icmp_offset += 8;
+}
+if ( buf_size < 37 + icmp_offset /* check metadata structure expectations 
*/
+|| MKTAG('p','a','c','k') != AV_RL32(buf+4+icmp_offset)
+|| MKTAG('s','i','n','f') != AV_RL32(buf+12+icmp_offset)
+|| MKTAG('s','d','a','t') != AV_RL32(buf+33+icmp_offset)){
+av_log(avctx, AV_LOG_ERROR, "can't read DNxUncompressed 
metadata.\n");
+*poutbuf_size = 0;
+return buf_size;
+}
+
+pc->fourcc_tag = AV_RL32(buf+24+icmp_offset);
+pc->width = AV_RL32(buf+16+icmp_offset);
+pc->height = AV_RL32(buf+20+icmp_offset);
+pc->nr_bytes = AV_RL32(buf+29+icmp_offset) - 8;
+
+if (!avctx->codec_tag) {
+av_fourcc_make_string(fourcc_buf, pc->fourcc_tag);
+av_log(avctx, AV_LOG_INFO, "dnxuc_parser: '%s' %dx%d %dbpp %d\n",
+fourcc_buf,
+pc->width, pc->height,
+(pc->nr_bytes*8)/(pc->width*pc->height),
+pc->nr_bytes);
+avctx->codec_tag = pc->fourcc_tag;
+}
+
+if (pc->nr_bytes > buf_size - HEADER_SIZE + icmp_offset){
+av_log(avctx, AV_LOG_ERROR, "Insufficient size of image essence 
data.\n");
+*poutbuf_size = 0;
+return buf_size;
+}
+
+*poutbuf = buf + HEADER_SIZE + icmp_offset;
+*poutbuf_size = pc->nr_bytes;
+
+return buf_size;
+}
+
+const AVCodecParser ff_dnxuc_parser = {
+.codec_ids  = { AV_CODEC_ID_DNXUC },
+.priv_data_size = sizeof(DNxUcParseContext),
+.parser_parse   = dnxuc_parse,
+};
diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c
index 5128009..8bfd2db 100644
--- a/libavcodec/parsers.c
+++ b/libavcodec/parsers.c
@@ -35,6 +35,7 @@ extern const AVCodecParser ff_cri_parser;
 extern const AVCodecParser ff_dca_parser;
 extern const AVCodecParser ff_dirac_parser;
 extern const AVCodecPar

[FFmpeg-devel] [PATCH v5 2/4] libavformat/mxf: add DNxUncompressed MXF ULs

2024-09-11 Thread Martin Schitter
---
 libavformat/mxf.c| 1 +
 libavformat/mxfdec.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index a73e40e..885b4df 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -61,6 +61,7 @@ const MXFCodecUL ff_mxf_codec_uls[] = {
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x71,0x00,0x00,0x00 
}, 13,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x03,0x02,0x00,0x00 
}, 14,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0E,0x04,0x02,0x01,0x02,0x04,0x01,0x00 
}, 16,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD Legacy Avid Media Composer 
MXF */
+{ { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03,0x07,0x01,0x00 
}, 15,  AV_CODEC_ID_DNXUC }, /* DNxUncompressed/SMPTE RDD 50 */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 
}, 14,   AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC Intra */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x31,0x11,0x01 
}, 14,   AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC SPS/PPS in-band */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x02,0x01 
}, 16,   AV_CODEC_ID_V210 }, /* V210 */
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index ac63c0d..142b3e6 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1597,6 +1597,7 @@ static const MXFCodecUL 
mxf_picture_essence_container_uls[] = {
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 
}, 14,   AV_CODEC_ID_JPEG2000, NULL, 14, J2KWrap },
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x10,0x60,0x01 
}, 14,   AV_CODEC_ID_H264, NULL, 15 }, /* H.264 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x11,0x01,0x00 
}, 14,  AV_CODEC_ID_DNXHD, NULL, 14 }, /* VC-3 */
+{ { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1e,0x01,0x00 
}, 14,  AV_CODEC_ID_DNXUC, NULL, 14 }, /* DNxUncompressed / SMPTE RDD 50 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x12,0x01,0x00 
}, 14,AV_CODEC_ID_VC1, NULL, 14 }, /* VC-1 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x14,0x01,0x00 
}, 14,   AV_CODEC_ID_TIFF, NULL, 14 }, /* TIFF */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x15,0x01,0x00 
}, 14,  AV_CODEC_ID_DIRAC, NULL, 14 }, /* VC-2 */
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH v5 3/4] libavformat/dnxucdec: DNxUncompressed decoder

2024-09-11 Thread Martin Schitter
---
 libavcodec/allcodecs.c  |   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/codec_id.h   |   1 +
 libavcodec/dnxucdec.c   | 391 
 libavcodec/version.c|   2 +-
 5 files changed, 401 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/dnxucdec.c

diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d773ac3..1a3c084 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -93,6 +93,7 @@ extern const FFCodec ff_dfa_decoder;
 extern const FFCodec ff_dirac_decoder;
 extern const FFCodec ff_dnxhd_encoder;
 extern const FFCodec ff_dnxhd_decoder;
+extern const FFCodec ff_dnxuc_decoder;
 extern const FFCodec ff_dpx_encoder;
 extern const FFCodec ff_dpx_decoder;
 extern const FFCodec ff_dsicinvideo_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index a28ef68..27bf105 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1959,6 +1959,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("LEAD MCMP"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_DNXUC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "dnxuc",
+.long_name = NULL_IF_CONFIG_SMALL("DNxUncompressed / SMPTE RDD 50"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 0ab1e34..c8f8072 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -322,6 +322,7 @@ enum AVCodecID {
 AV_CODEC_ID_RTV1,
 AV_CODEC_ID_VMIX,
 AV_CODEC_ID_LEAD,
+AV_CODEC_ID_DNXUC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/dnxucdec.c b/libavcodec/dnxucdec.c
new file mode 100644
index 000..8fffd0a
--- /dev/null
+++ b/libavcodec/dnxucdec.c
@@ -0,0 +1,391 @@
+/*
+ * Avid DNxUncomressed / SMPTE RDD 50 decoder
+ * Copyright (c) 2024 Martin Schitter
+ *
+ * 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
+ */
+
+/*
+ This decoder for DNxUncompressed video data is mostly based on
+ reverse engineering of output generated by DaVinci Resolve 19
+ but was later also checked against the SMPTE RDD 50 specification.
+
+ Not all DNxUncompressed pixel format variants are supported,
+ but at least an elementary base set is already usable:
+
+  - YUV 4:2:2 8/10/12bit
+  - RGB 8/10/12bit/half/float
+
+*/
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "decode.h"
+#include "libavutil/imgutils.h"
+#include "thread.h"
+
+static av_cold int dnxuc_decode_init(AVCodecContext *avctx)
+{
+return 0;
+}
+
+
+static int pass_though(AVCodecContext *avctx, AVFrame *frame, const AVPacket 
*avpkt)
+{
+/* there is no need to copy as the data already match
+ * a known pixel format */
+
+frame->buf[0] = av_buffer_ref(avpkt->buf);
+
+if (!frame->buf[0]) {
+return AVERROR(ENOMEM);
+}
+
+return av_image_fill_arrays(frame->data, frame->linesize, avpkt->data,
+   avctx->pix_fmt, avctx->width, avctx->height, 1);
+}
+
+static int float2planes(AVCodecContext *avctx, AVFrame *frame, const AVPacket 
*pkt)
+{
+int x, y, lw;
+const size_t sof = 4;
+
+lw = frame->width;
+
+for(y = 0; y < frame->height; y++){
+for(x = 0; x < frame->width; x++){
+memcpy(&frame->data[2][sof*(lw*y + x)], &pkt->data[sof* 3*(lw*y + 
x)], sof);
+memcpy(&frame->data[0][sof*(lw*y + x)], &pkt->data[sof*(3*(lw*y + 
x) + 1)], sof);
+memcpy(&frame->data[1][sof*(lw*y + x)], &pkt->data[sof*(3*(lw*y + 
x) + 2)], sof);
+}
+}
+return pkt->size;
+}
+
+static int half_add_alpha(AVCodecContext *avctx, AVFrame *frame, const 
AVPacket *pkt)
+{
+/* ffmpeg doesn't provide RGB half bit depth without alpha channel right 
now
+ * we simply add an opaque alpha layer as workaround */
+
+int x, y, lw;
+const size_t soh = 2;
+const uint16_t opaque = 0x3c00;
+
+lw = frame->width;
+
+for(y = 0; y < frame->height; y++){
+for(x = 0; x < frame->width; x++){
+

[FFmpeg-devel] [PATCH v5 4/4] libavformat: DNxUncompressed aux files

2024-09-11 Thread Martin Schitter
---
 Changelog   | 1 +
 libavcodec/Makefile | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Changelog b/Changelog
index 7237648..0464bee 100644
--- a/Changelog
+++ b/Changelog
@@ -20,6 +20,7 @@ version :
 - Intel QSV-accelerated VVC decoding
 - MediaCodec AAC/AMR-NB/AMR-WB/MP3 decoding
 - YUV colorspace negotiation for codecs and filters, obsoleting YUVJ
+- DNxUncompressed (SMPTE RDD 50) decoder
 
 
 version 7.0:
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1d27e55..eee98ed 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -325,6 +325,7 @@ OBJS-$(CONFIG_DFPWM_DECODER)   += dfpwmdec.o
 OBJS-$(CONFIG_DFPWM_ENCODER)   += dfpwmenc.o
 OBJS-$(CONFIG_DNXHD_DECODER)   += dnxhddec.o dnxhddata.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += dnxhdenc.o dnxhddata.o
+OBJS-$(CONFIG_DNXUC_DECODER)   += dnxucdec.o dnxuc_parser.o
 OBJS-$(CONFIG_DOLBY_E_DECODER) += dolby_e.o dolby_e_parse.o kbdwin.o
 OBJS-$(CONFIG_DPX_DECODER) += dpx.o
 OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [PATCH 11/60] lavfi/vf_ssim: use av_err2str to simplify code

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 20:13:45)
> No need to explicitly specify the buffer here as it is only
> ever passed to av_log, so av_err2str can be used.
> ---
>  libavfilter/vf_ssim.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

LGTM

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

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


Re: [FFmpeg-devel] [PATCH 12/60] lavfi/vf_ssim: narrow variable scopes

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 20:51:47)
> ---
>  libavfilter/vf_ssim.c | 15 ++-
>  1 file changed, 6 insertions(+), 9 deletions(-)

Looks ok

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

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


Re: [FFmpeg-devel] [PATCH 09/13] avformat: add an LCEVC stream group

2024-09-11 Thread James Almer

On 9/9/2024 8:33 AM, Anton Khirnov wrote:

Quoting James Almer (2024-09-08 15:26:51)

On 9/6/2024 8:44 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 18:31:10)

+typedef struct AVStreamGroupLCEVC {
+const AVClass *av_class;
+
+/**
+ * Width of the final stream for presentation.
+ */
+int width;
+/**
+ * Height of the final image for presentation.
+ */
+int height;


What's the point of exporting these separately when they are the same as
the enhancement AVStream's dimensions?


The enhancement stream is of data type, so width/height are undefined in
it. Hence including these here.


Why not define them then? Seems simpler and more straightforward to me.


I personally don't think re-defining the AVStream API in order to have 
two fields start meaning something for DATA type streams for the sake of 
only one codec_id is better than just having said fields defined in the 
specific stream group.




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

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


Re: [FFmpeg-devel] [PATCH 13/60] lavfi/f_metadata: use av_err2str to simplify code

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 20:53:11)
> No need to explicitly specify the buffer here as it is only
> ever passed to av_log, so av_err2str can be used.
> ---
>  libavfilter/f_metadata.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Looks very ok

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

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


Re: [FFmpeg-devel] [PATCH 14/60] lavfi/vf_signature: use av_err2str to simplify code

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 20:56:38)
> No need to explicitly specify the buffer here as it is only
> ever passed to av_log, so av_err2str can be used.
> ---
>  libavfilter/vf_signature.c | 8 ++--
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
> index f205f6919f..f419522ac6 100644
> --- a/libavfilter/vf_signature.c
> +++ b/libavfilter/vf_signature.c
> @@ -386,9 +386,7 @@ static int xml_export(AVFilterContext *ctx, StreamContext 
> *sc, const char* filen
>  f = avpriv_fopen_utf8(filename, "w");
>  if (!f) {
>  int err = AVERROR(EINVAL);
> -char buf[128];
> -av_strerror(err, buf, sizeof(buf));
> -av_log(ctx, AV_LOG_ERROR, "cannot open xml file %s: %s\n", filename, 
> buf);
> +av_log(ctx, AV_LOG_ERROR, "cannot open xml file %s: %s\n", filename, 
> av_err2str(err));
>  return err;
>  }
>  
> @@ -500,9 +498,7 @@ static int binary_export(AVFilterContext *ctx, 
> StreamContext *sc, const char* fi
>  f = avpriv_fopen_utf8(filename, "wb");
>  if (!f) {
>  int err = AVERROR(EINVAL);
> -char buf[128];
> -av_strerror(err, buf, sizeof(buf));
> -av_log(ctx, AV_LOG_ERROR, "cannot open file %s: %s\n", filename, 
> buf);
> +av_log(ctx, AV_LOG_ERROR, "cannot open file %s: %s\n", filename, 
> av_err2str(err));

The change looks ok, but the original code highly suspicious (should be
errno rather than EINVAL).

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

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


Re: [FFmpeg-devel] [PATCH 54/60] avformat/matroskadec: fix variable shadowing

2024-09-11 Thread James Almer

On 9/8/2024 9:23 PM, Marvin Scholz wrote:

---
  libavformat/matroskadec.c | 13 ++---
  1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index c8741ff2af..60b20e9658 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1281,8 +1281,8 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
  MatroskaLevel *level = matroska->num_levels ? 
&matroska->levels[matroska->num_levels - 1] : NULL;
  
  if (!matroska->current_id) {

-uint64_t id;
-res = ebml_read_num(matroska, pb, 4, &id, 0);
+uint64_t tmp_id;
+res = ebml_read_num(matroska, pb, 4, &tmp_id, 0);
  if (res < 0) {
  if (pb->eof_reached && res == AVERROR_EOF) {
  if (matroska->is_live)
@@ -1301,7 +1301,7 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
  }
  return res;
  }
-matroska->current_id = id | 1 << 7 * res;
+matroska->current_id = tmp_id | 1 << 7 * res;
  pos_alt = pos + res;
  } else {
  pos_alt = pos;
@@ -3039,7 +3039,7 @@ static int mkv_parse_video(MatroskaTrack *track, AVStream 
*st,
  if (track->video.stereo_mode < MATROSKA_VIDEO_STEREOMODE_TYPE_NB &&
  track->video.stereo_mode != MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_CYAN_RED 
&&
  track->video.stereo_mode != 
MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_GREEN_MAG) {
-int ret = mkv_stereo3d_conv(st, track->video.stereo_mode);
+ret = mkv_stereo3d_conv(st, track->video.stereo_mode);
  if (ret < 0)
  return ret;
  }
@@ -4683,8 +4683,7 @@ static int webm_dash_manifest_cues(AVFormatContext *s, 
int64_t init_range)
  AVBPrint bprint;
  char *buf;
  int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
-int i;
-int ret;
+int i, ret;


Seems unrelated.

  
  // determine cues start and end positions

  for (i = 0; i < seekhead_list->nb_elem; i++)
@@ -4740,7 +4739,7 @@ static int webm_dash_manifest_cues(AVFormatContext *s, 
int64_t init_range)
  // Store cue point timestamps as a comma separated list
  // for checking subsegment alignment in the muxer.
  av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
-for (int i = 0; i < sti->nb_index_entries; i++)
+for (i = 0; i < sti->nb_index_entries; i++)
  av_bprintf(&bprint, "%" PRId64",", sti->index_entries[i].timestamp);
  if (!av_bprint_is_complete(&bprint)) {
  av_bprint_finalize(&bprint, NULL);




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

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


Re: [FFmpeg-devel] [PATCH 15/60] avformat/network: use av_err2str to simplify code

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 21:16:45)
> No need to explicitly specify the buffer here as it is only
> ever passed to av_log, so av_err2str can be used.
> ---
>  libavformat/network.c | 21 +++--
>  1 file changed, 7 insertions(+), 14 deletions(-)

Looks ok

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

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


Re: [FFmpeg-devel] [PATCH 17/60] avformat/crypto: fix variable shadowing

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 21:38:12)
> ---
>  libavformat/crypto.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Looks ok

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

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


Re: [FFmpeg-devel] [PATCH 18/60] avutil/file: use av_err2str to simplify code

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 21:43:39)
> No need to explicitly specify the buffer here as it is only
> ever passed to av_log, so av_err2str can be used.
> ---
>  libavutil/file.c | 10 +++---
>  1 file changed, 3 insertions(+), 7 deletions(-)

Looks ok

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

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


Re: [FFmpeg-devel] [PATCH 19/60] avdevice/jack: use av_err2str to simplify code

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 21:45:24)
> No need to explicitly specify the buffer here as it is only
> ever passed to av_log, so av_err2str can be used.
> ---
>  libavdevice/jack.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

LGTM

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

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


Re: [FFmpeg-devel] [PATCH 20/60] fftools/ffmpeg_mux_init: remove unused variable

2024-09-11 Thread Anton Khirnov
Quoting Marvin Scholz (2024-09-08 22:20:42)
> This dict is declared and freed but nothing is ever written to it.
> ---
>  fftools/ffmpeg_mux_init.c | 2 --
>  1 file changed, 2 deletions(-)

Very ok

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

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


Re: [FFmpeg-devel] [PATCH 01/60] fftools/ffmpeg_opt: fix variable shadowing

2024-09-11 Thread Michael Niedermayer
On Sun, Sep 08, 2024 at 07:14:10PM +0200, Marvin Scholz wrote:
> ---
>  fftools/ffmpeg_opt.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)

btw, iam not sure its needed to post patches for things like
shadow fixes. Maybe we can fix the shadowing stuff quicker without posting
patches also as these are quite trivial (i mean the trivial ones only of course)

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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

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


Re: [FFmpeg-devel] [PATCH 4/6] aarch64/vvc: Add put_pel/put_pel_uni/put_pel_uni_w

2024-09-11 Thread Martin Storsjö

On Sun, 8 Sep 2024, Zhao Zhili wrote:


diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index f72746ce03..076d01b477 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -248,4 +248,26 @@ NEON8_FNPROTO_PARTIAL_4(qpel, (int16_t *dst, const uint8_t 
*_src, ptrdiff_t _src
NEON8_FNPROTO_PARTIAL_4(qpel_uni, (uint8_t *_dst, ptrdiff_t _dststride, const 
uint8_t *_src,
ptrdiff_t _srcstride, int height, const int8_t *hf, const int8_t *vf, 
int width),)

+#undef NEON8_FNPROTO_PARTIAL_6
+#define NEON8_FNPROTO_PARTIAL_6(fn, args, ext) \
+void ff_vvc_put_##fn##4_8_neon##ext args; \
+void ff_vvc_put_##fn##8_8_neon##ext args; \
+void ff_vvc_put_##fn##16_8_neon##ext args; \
+void ff_vvc_put_##fn##32_8_neon##ext args; \
+void ff_vvc_put_##fn##64_8_neon##ext args; \
+void ff_vvc_put_##fn##128_8_neon##ext args
+
+NEON8_FNPROTO_PARTIAL_6(pel_pixels, (int16_t *dst,
+const uint8_t *src, ptrdiff_t srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width),);
+
+NEON8_FNPROTO_PARTIAL_6(pel_uni_pixels, (uint8_t *_dst, ptrdiff_t _dststride,
+const uint8_t *_src, ptrdiff_t _srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width),);
+
+NEON8_FNPROTO_PARTIAL_6(pel_uni_w_pixels, (uint8_t *_dst, ptrdiff_t _dststride,
+const uint8_t *_src, ptrdiff_t _srcstride,
+int height, int denom, int wx, int ox,
+const int8_t *hf, const int8_t *vf, int width),);
+
#endif
diff --git a/libavcodec/aarch64/h26x/epel_neon.S 
b/libavcodec/aarch64/h26x/epel_neon.S
index 378b0f7fb2..729395f2f0 100644
--- a/libavcodec/aarch64/h26x/epel_neon.S
+++ b/libavcodec/aarch64/h26x/epel_neon.S
@@ -19,7 +19,8 @@
 */

#include "libavutil/aarch64/asm.S"
-#define MAX_PB_SIZE 64
+#define HEVC_MAX_PB_SIZE 64
+#define VVC_MAX_PB_SIZE 128

const epel_filters, align=4
.byte  0,  0,  0,  0
@@ -131,8 +132,13 @@ endconst
b.ne1b
.endm

+function ff_vvc_put_pel_pixels4_8_neon, export=1
+mov x7, #(VVC_MAX_PB_SIZE * 2)
+b   1f
+endfunc
+
function ff_hevc_put_hevc_pel_pixels4_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2)
+mov x7, #(HEVC_MAX_PB_SIZE * 2)
1:  ld1 {v0.s}[0], [x1], x2
ushll   v4.8h, v0.8b, #6
subsw3, w3, #1
@@ -142,7 +148,7 @@ function ff_hevc_put_hevc_pel_pixels4_8_neon, export=1
endfunc

function ff_hevc_put_hevc_pel_pixels6_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2 - 8)
+mov x7, #(HEVC_MAX_PB_SIZE * 2 - 8)
1:  ld1 {v0.8b}, [x1], x2
ushll   v4.8h, v0.8b, #6
st1 {v4.d}[0], [x0], #8
@@ -152,8 +158,13 @@ function ff_hevc_put_hevc_pel_pixels6_8_neon, export=1
ret
endfunc

+function ff_vvc_put_pel_pixels8_8_neon, export=1
+mov x7, #(VVC_MAX_PB_SIZE * 2)
+b   1f
+endfunc
+
function ff_hevc_put_hevc_pel_pixels8_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2)
+mov x7, #(HEVC_MAX_PB_SIZE * 2)
1:  ld1 {v0.8b}, [x1], x2
ushll   v4.8h, v0.8b, #6
subsw3, w3, #1
@@ -163,7 +174,7 @@ function ff_hevc_put_hevc_pel_pixels8_8_neon, export=1
endfunc

function ff_hevc_put_hevc_pel_pixels12_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2 - 16)
+mov x7, #(HEVC_MAX_PB_SIZE * 2 - 16)
1:  ld1 {v0.8b, v1.8b}, [x1], x2
ushll   v4.8h, v0.8b, #6
st1 {v4.8h}, [x0], #16
@@ -174,8 +185,13 @@ function ff_hevc_put_hevc_pel_pixels12_8_neon, export=1
ret
endfunc

+function ff_vvc_put_pel_pixels16_8_neon, export=1
+mov x7, #(VVC_MAX_PB_SIZE * 2)
+b   1f
+endfunc
+
function ff_hevc_put_hevc_pel_pixels16_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2)
+mov x7, #(HEVC_MAX_PB_SIZE * 2)
1:  ld1 {v0.8b, v1.8b}, [x1], x2
ushll   v4.8h, v0.8b, #6
ushll   v5.8h, v1.8b, #6
@@ -186,7 +202,7 @@ function ff_hevc_put_hevc_pel_pixels16_8_neon, export=1
endfunc

function ff_hevc_put_hevc_pel_pixels24_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2)
+mov x7, #(HEVC_MAX_PB_SIZE * 2)
1:  ld1 {v0.8b-v2.8b}, [x1], x2
ushll   v4.8h, v0.8b, #6
ushll   v5.8h, v1.8b, #6
@@ -197,8 +213,13 @@ function ff_hevc_put_hevc_pel_pixels24_8_neon, export=1
ret
endfunc

+function ff_vvc_put_pel_pixels32_8_neon, export=1
+mov x7, #(VVC_MAX_PB_SIZE * 2)
+b   1f
+endfunc
+
function ff_hevc_put_hevc_pel_pixels32_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2)
+mov x7, #(HEVC_MAX_PB_SIZE * 2)
1:  ld1   

[FFmpeg-devel] ./configure and nvidia/cuda sdk

2024-09-11 Thread Top Secret
Hello,

We are trying to redistribute a ffmpeg binary commercially. We use free version 
for generally decoding video only(some demuxing). We want to use nvidia's 
suggestion of using the GPU with ffmpeg. They give a sample configure string 
like so:
./configure --enable-cuda --enable-cuvid --enable-nvdec --enable-nvenc 
--enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include  
--extra-ldflags=-L/usr/local/cuda/lib64

In here we notice --enable-nonfree which basically means we can't give ffmpeg 
commerically right? Well looking into this legal wise... If we get NVidia's 
written consent that a lawyer can use in a court of law, alter configure script 
to say libnpp is not considered "non-free" and ditch that string would it be 
okay?

NVidia seems to advocate for FFmpeg use. If its not permissible, then would it 
make sense to just use opencv's implementation of ffmpeg which then advertises 
a completely different license(Apache).

Looking for serious answers with out sarcasm, insults, or claims of simplicity.

Thanks!

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

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


Re: [FFmpeg-devel] [PATCH 6/6] avcodec/hevc: ff_hevc_(qpel/epel)_filters are signed type

2024-09-11 Thread Martin Storsjö

On Sun, 8 Sep 2024, Zhao Zhili wrote:


From: Zhao Zhili 

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


The rest of these patches seem fine (or where I don't have much of an 
opinion).


// Martin

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

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


Re: [FFmpeg-devel] [PATCH 1/3] aarch64/h26x: Remove duplicate b.eq instruction

2024-09-11 Thread Martin Storsjö

On Wed, 11 Sep 2024, Zhao Zhili wrote:


From: Zhao Zhili 

b.eq is added by calc_all after each calc.
---
libavcodec/aarch64/h26x/qpel_neon.S | 1 -
1 file changed, 1 deletion(-)

diff --git a/libavcodec/aarch64/h26x/qpel_neon.S 
b/libavcodec/aarch64/h26x/qpel_neon.S
index 8a372a76be..7868811b3b 100644
--- a/libavcodec/aarch64/h26x/qpel_neon.S
+++ b/libavcodec/aarch64/h26x/qpel_neon.S
@@ -754,7 +754,6 @@ function ff_hevc_put_hevc_qpel_v4_8_neon, export=1
calc_qpelb  v24, \src0, \src1, \src2, \src3, \src4, \src5, \src6, 
\src7
st1 {v24.4h}, [x0], x9
subsw3, w3, #1
-b.eq2f
.endm
1:  calc_all
.purgem calc
--
2.42.0


Ok

// Martin

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

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


Re: [FFmpeg-devel] [PATCH 2/3] aarch64/vvc: Add put_qpel_vx

2024-09-11 Thread Martin Storsjö

On Wed, 11 Sep 2024, Zhao Zhili wrote:


From: Zhao Zhili 

put_luma_v_8_4x4_c:  1.0 ( 1.00x)
put_luma_v_8_4x4_neon:   0.0 ( 0.00x)
put_luma_v_8_8x8_c:  3.5 ( 1.00x)
put_luma_v_8_8x8_neon:   0.5 ( 7.00x)
put_luma_v_8_16x16_c:   13.8 ( 1.00x)
put_luma_v_8_16x16_neon: 1.2 (11.00x)
put_luma_v_8_32x32_c:   54.2 ( 1.00x)
put_luma_v_8_32x32_neon: 5.0 (10.85x)
put_luma_v_8_64x64_c:  217.5 ( 1.00x)
put_luma_v_8_64x64_neon:18.8 (11.60x)
put_luma_v_8_128x128_c:886.2 ( 1.00x)
put_luma_v_8_128x128_neon:  74.0 (11.98x)
---
libavcodec/aarch64/h26x/dsp.h   |   8 +++
libavcodec/aarch64/h26x/qpel_neon.S | 100 
libavcodec/aarch64/vvc/dsp_init.c   |   7 ++
3 files changed, 115 insertions(+)


This doesn't look harmful, and looks like the rest of these functions, so 
I guess it's acceptable. Let it be known that I very much dislike the 
structure of these functions, but you're adding more in the same style of 
the old, so I guess that's ok.


// Martin

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

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


Re: [FFmpeg-devel] [PATCH 3/3] aarch64/vvc: Add put_qpel_hv

2024-09-11 Thread Martin Storsjö

On Wed, 11 Sep 2024, Zhao Zhili wrote:


From: Zhao Zhili 

With Apple M1 (no i8mm):

put_luma_hv_8_4x4_c: 2.2 ( 1.00x)
put_luma_hv_8_4x4_neon:  0.8 ( 3.00x)
put_luma_hv_8_8x8_c: 7.0 ( 1.00x)
put_luma_hv_8_8x8_neon:  0.8 ( 9.33x)
put_luma_hv_8_16x16_c:  22.8 ( 1.00x)
put_luma_hv_8_16x16_neon:2.5 ( 9.10x)
put_luma_hv_8_32x32_c:  84.8 ( 1.00x)
put_luma_hv_8_32x32_neon:9.5 ( 8.92x)
put_luma_hv_8_64x64_c: 333.0 ( 1.00x)
put_luma_hv_8_64x64_neon:   35.5 ( 9.38x)
put_luma_hv_8_128x128_c:  1294.5 ( 1.00x)
put_luma_hv_8_128x128_neon:137.8 ( 9.40x)

With Pixel 8 Pro:

put_luma_hv_8_4x4_c: 5.0 ( 1.00x)
put_luma_hv_8_4x4_neon:  0.8 ( 6.67x)
put_luma_hv_8_4x4_i8mm:  0.2 (20.00x)
put_luma_hv_8_8x8_c:13.2 ( 1.00x)
put_luma_hv_8_8x8_neon:  1.2 (10.60x)
put_luma_hv_8_8x8_i8mm:  1.2 (10.60x)
put_luma_hv_8_16x16_c:  44.2 ( 1.00x)
put_luma_hv_8_16x16_neon:4.5 ( 9.83x)
put_luma_hv_8_16x16_i8mm:4.2 (10.41x)
put_luma_hv_8_32x32_c: 160.8 ( 1.00x)
put_luma_hv_8_32x32_neon:   17.5 ( 9.19x)
put_luma_hv_8_32x32_i8mm:   16.0 (10.05x)
put_luma_hv_8_64x64_c: 611.2 ( 1.00x)
put_luma_hv_8_64x64_neon:   68.0 ( 8.99x)
put_luma_hv_8_64x64_i8mm:   62.2 ( 9.82x)
put_luma_hv_8_128x128_c:  2384.8 ( 1.00x)
put_luma_hv_8_128x128_neon:268.8 ( 8.87x)
put_luma_hv_8_128x128_i8mm:245.8 ( 9.70x)
---
libavcodec/aarch64/h26x/dsp.h   |   8 ++
libavcodec/aarch64/h26x/qpel_neon.S | 140 
libavcodec/aarch64/vvc/dsp_init.c   |  14 +++
3 files changed, 162 insertions(+)


Ok

// Martin

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

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


Re: [FFmpeg-devel] ./configure and nvidia/cuda sdk

2024-09-11 Thread Timo Rothenpieler

On 11.09.2024 14:21, Top Secret wrote:

Hello,

We are trying to redistribute a ffmpeg binary commercially. We use free version 
for generally decoding video only(some demuxing). We want to use nvidia's 
suggestion of using the GPU with ffmpeg. They give a sample configure string 
like so:
./configure --enable-cuda --enable-cuvid --enable-nvdec --enable-nvenc 
--enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include  
--extra-ldflags=-L/usr/local/cuda/lib64

In here we notice --enable-nonfree which basically means we can't give ffmpeg 
commerically right? Well looking into this legal wise... If we get NVidia's written 
consent that a lawyer can use in a court of law, alter configure script to say libnpp is 
not considered "non-free" and ditch that string would it be okay?

NVidia seems to advocate for FFmpeg use. If its not permissible, then would it 
make sense to just use opencv's implementation of ffmpeg which then advertises 
a completely different license(Apache).

Looking for serious answers with out sarcasm, insults, or claims of simplicity.


Just don't use libnpp
___
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] ./configure and nvidia/cuda sdk

2024-09-11 Thread Anton Khirnov
(I am not a lawyer, the following is my personal opinion and not legal
advice)
Quoting Top Secret (2024-09-11 14:21:21)
> Hello,
> 
> We are trying to redistribute a ffmpeg binary commercially. We use free 
> version for generally decoding video only(some demuxing). We want to use 
> nvidia's suggestion of using the GPU with ffmpeg. They give a sample 
> configure string like so:
> ./configure --enable-cuda --enable-cuvid --enable-nvdec --enable-nvenc 
> --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include  
> --extra-ldflags=-L/usr/local/cuda/lib64
> 
> In here we notice --enable-nonfree which basically means we can't give ffmpeg 
> commerically right?

No, AFAIU it means you cannot distribute such a build at all, since
there is no well-defined license for it.

> Well looking into this legal wise... If we get NVidia's written consent that 
> a lawyer can use in a court of law, alter configure script to say libnpp is 
> not considered "non-free" and ditch that string would it be okay?
> 
> NVidia seems to advocate for FFmpeg use. If its not permissible, then would 
> it make sense to just use opencv's implementation of ffmpeg which then 
> advertises a completely different license(Apache).

If you want a redistributable build with NPP, Nvidia would have to
relicense NPP to something LGPL-compatible.

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

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


Re: [FFmpeg-devel] ./configure and nvidia/cuda sdk

2024-09-11 Thread Anton Khirnov
Quoting Top Secret (2024-09-11 14:21:21)
> opencv's implementation of ffmpeg which then advertises a completely 
> different license(Apache).

Huh? What is that supposed to be?

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

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/amfenc: Add support for on-demand key frames

2024-09-11 Thread Dmitrii Ovchinnikov
Thanks for your contribution.  It looks good to me. If there are no
comments, I'll merge it in a few days.
___
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/hevcdec: set output frame pkt_dts

2024-09-11 Thread Anton Khirnov
pkt_dts needs to be set manually when using the receive_frame() callback, so
it was unset after 2fdecbb239714b6203e37067fda2521f80e19d47.

Fixes PTS guessing for certain files with broken timestamps. Cf.
https://github.com/mpv-player/mpv/issues/14806

Reported-by: llyyr 
---
 libavcodec/hevc/hevcdec.c |  4 
 libavcodec/hevc/hevcdec.h |  3 +++
 libavcodec/hevc/refs.c| 10 ++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index c8c425fd71..d67730418b 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3444,6 +3444,8 @@ static int hevc_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 uint8_t *sd;
 size_t sd_size;
 
+s->pkt_dts = AV_NOPTS_VALUE;
+
 if (ff_container_fifo_can_read(s->output_fifo))
 goto do_output;
 
@@ -3457,6 +3459,8 @@ static int hevc_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 } else if (ret < 0)
 return ret;
 
+s->pkt_dts = avpkt->dts;
+
 sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &sd_size);
 if (sd && sd_size > 0) {
 ret = hevc_decode_extradata(s, sd, sd_size, 0);
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index e43f2d0201..e3194fd87e 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -545,6 +545,9 @@ typedef struct HEVCContext {
 
 int film_grain_warning_shown;
 
+// dts of the packet currently being decoded
+int64_t pkt_dts;
+
 AVBufferRef *rpu_buf;   ///< 0 or 1 Dolby Vision RPUs.
 DOVIContext dovi_ctx;   ///< Dolby Vision decoding context
 } HEVCContext;
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index 09d759f936..20fdbb5794 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -182,7 +182,7 @@ int ff_hevc_output_frames(HEVCContext *s, HEVCLayerContext 
*l,
 int nb_dpb= 0;
 int nb_output = 0;
 int min_poc   = INT_MAX;
-int i, min_idx, ret;
+int i, min_idx, ret = 0;
 
 for (i = 0; i < FF_ARRAY_ELEMS(l->DPB); i++) {
 HEVCFrame *frame = &l->DPB[i];
@@ -199,10 +199,12 @@ int ff_hevc_output_frames(HEVCContext *s, 
HEVCLayerContext *l,
 if (nb_output > max_output ||
 (nb_output && nb_dpb > max_dpb)) {
 HEVCFrame *frame = &l->DPB[min_idx];
+AVFrame *f = frame->needs_fg ? frame->frame_grain : frame->f;
 
-ret = discard ? 0 :
-  ff_container_fifo_write(s->output_fifo,
-  frame->needs_fg ? frame->frame_grain 
: frame->f);
+if (!discard) {
+f->pkt_dts = s->pkt_dts;
+ret = ff_container_fifo_write(s->output_fifo, f);
+}
 ff_hevc_unref_frame(frame, HEVC_FRAME_FLAG_OUTPUT);
 if (ret < 0)
 return ret;
-- 
2.43.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 v3 1/2] tests/fate: force MPEG range for rawvideo tests

2024-09-11 Thread Niklas Haas
Merging tomorrow, as it fixes a release blocking bug.
___
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] tests/checkasm/sw_rgb: don't write random data past the end of the buffer

2024-09-11 Thread James Almer
Should fix fate-checkasm-sw_rgb under gcc-ubsan.

Signed-off-by: James Almer 
---
 tests/checkasm/sw_rgb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c
index af9434073a..cdd43df8ba 100644
--- a/tests/checkasm/sw_rgb.c
+++ b/tests/checkasm/sw_rgb.c
@@ -287,7 +287,7 @@ static void check_deinterleave_bytes(void)
int width, int height, int srcStride,
int dst1Stride, int dst2Stride);
 
-randomize_buffers(src, 2*MAX_STRIDE*MAX_HEIGHT+2);
+randomize_buffers(src, 2*MAX_STRIDE*MAX_HEIGHT);
 
 if (check_func(deinterleaveBytes, "deinterleave_bytes")) {
 for (int i = 0; i <= 16; i++) {
-- 
2.46.0

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

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


[FFmpeg-devel] [PATCH] avfilter/af_join: pass the correct input layouts to ff_channel_layouts_ref

2024-09-11 Thread James Almer
Should fix memory leaks show in fate-filter-join and fate-filter-crazychannels.

Signed-off-by: James Almer 
---
 libavfilter/af_join.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
index db0320aa70..0ea53248b6 100644
--- a/libavfilter/af_join.c
+++ b/libavfilter/af_join.c
@@ -215,7 +215,7 @@ static int join_query_formats(const AVFilterContext *ctx,
 
 for (i = 0; i < ctx->nb_inputs; i++) {
 layouts = ff_all_channel_layouts();
-if ((ret = ff_channel_layouts_ref(layouts, 
&cfg_in[0]->channel_layouts)) < 0)
+if ((ret = ff_channel_layouts_ref(layouts, 
&cfg_in[i]->channel_layouts)) < 0)
 return ret;
 }
 
-- 
2.46.0

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

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


[FFmpeg-devel] [PATCH v2 00/14] aarch64/vvc: Add SIMD

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

Patches 1~9 has been updated according to Martin's review.

Patches 10~14 are new.

I have created a PR on github:
https://github.com/quink-black/FFmpeg/pull/2

Zhao Zhili (14):
  aarch64/hevc: Simplify function prototypes by macro
  aarch64/hevc: Move epel/qpel to h26x directory
  aarch64/vvc: Add put_qpel_h_* and put_qpel_uni_h_*
  aarch64/vvc: Add put_pel/put_pel_uni/put_pel_uni_w
  aarch64/vvc: Add put_qpel_hx i8mm
  avcodec/hevc: ff_hevc_(qpel/epel)_filters are signed type
  aarch64/h26x: Remove duplicate b.eq instruction
  aarch64/vvc: Add put_qpel_vx
  aarch64/vvc: Add put_qpel_hv
  aarch64/vvc: Add sad
  aarch64/vvc: Add put_epel_h
  aarch64/vvc: Add put_epel_h i8mm
  aarch64/vvc: Add put_epel_hv
  aarch64/vvc: Add avg

 libavcodec/aarch64/Makefile   |   4 +-
 libavcodec/aarch64/h26x/dsp.h | 268 
 .../{hevcdsp_epel_neon.S => h26x/epel_neon.S} | 404 +---
 .../{hevcdsp_qpel_neon.S => h26x/qpel_neon.S} | 592 --
 libavcodec/aarch64/hevcdsp_init_aarch64.c | 227 ---
 libavcodec/aarch64/vvc/Makefile   |   4 +
 libavcodec/aarch64/vvc/dsp_init.c | 114 
 libavcodec/aarch64/vvc/inter.S| 163 +
 libavcodec/aarch64/vvc/sad.S  |  75 +++
 libavcodec/hevc/dsp_template.c|   4 +-
 10 files changed, 1480 insertions(+), 375 deletions(-)
 rename libavcodec/aarch64/{hevcdsp_epel_neon.S => h26x/epel_neon.S} (94%)
 rename libavcodec/aarch64/{hevcdsp_qpel_neon.S => h26x/qpel_neon.S} (91%)
 create mode 100644 libavcodec/aarch64/vvc/inter.S
 create mode 100644 libavcodec/aarch64/vvc/sad.S

-- 
2.42.0

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

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


[FFmpeg-devel] [PATCH v2 03/14] aarch64/vvc: Add put_qpel_h_* and put_qpel_uni_h_*

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

Just share hevc implementation.

checkasm --test=vvc_mc --benchmark:

put_luma_h_8_4x4_c:  0.2 ( 1.00x)
put_luma_h_8_4x4_neon:   0.2 ( 1.00x)
put_luma_h_8_8x8_c:  1.0 ( 1.00x)
put_luma_h_8_8x8_neon:   0.2 ( 4.33x)
put_luma_h_8_16x16_c:3.2 ( 1.00x)
put_luma_h_8_16x16_neon: 1.2 ( 2.63x)
put_luma_h_8_32x32_c:   13.7 ( 1.00x)
put_luma_h_8_32x32_neon: 4.0 ( 3.45x)
put_luma_h_8_64x64_c:   48.2 ( 1.00x)
put_luma_h_8_64x64_neon:15.7 ( 3.07x)
put_luma_h_8_128x128_c:203.5 ( 1.00x)
put_luma_h_8_128x128_neon:  62.0 ( 3.28x)
put_uni_h_luma_8_4x4_c:  0.2 ( 1.00x)
put_uni_h_luma_8_4x4_neon:   0.2 ( 1.00x)
put_uni_h_luma_8_8x8_c:  1.5 ( 1.00x)
put_uni_h_luma_8_8x8_neon:   0.2 ( 6.56x)
put_uni_h_luma_8_16x16_c:5.7 ( 1.00x)
put_uni_h_luma_8_16x16_neon: 1.2 ( 4.67x)
put_uni_h_luma_8_32x32_c:   24.0 ( 1.00x)
put_uni_h_luma_8_32x32_neon: 4.7 ( 5.07x)
put_uni_h_luma_8_64x64_c:   90.0 ( 1.00x)
put_uni_h_luma_8_64x64_neon:17.0 ( 5.30x)
put_uni_h_luma_8_128x128_c:357.7 ( 1.00x)
put_uni_h_luma_8_128x128_neon:  67.5 ( 5.30x)
---
 libavcodec/aarch64/h26x/dsp.h   |  13 ++
 libavcodec/aarch64/h26x/qpel_neon.S | 202 
 libavcodec/aarch64/vvc/Makefile |   1 +
 libavcodec/aarch64/vvc/dsp_init.c   |  14 ++
 4 files changed, 171 insertions(+), 59 deletions(-)

diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index 902286872d..f72746ce03 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -235,4 +235,17 @@ NEON8_FNPROTO(qpel_bi_hv, (uint8_t *dst, ptrdiff_t 
dststride,
 const uint8_t *src, ptrdiff_t srcstride, const int16_t *src2,
 int height, intptr_t mx, intptr_t my, int width), _i8mm);
 
+#undef NEON8_FNPROTO_PARTIAL_4
+#define NEON8_FNPROTO_PARTIAL_4(fn, args, ext) \
+void ff_vvc_put_##fn##_h4_8_neon##ext args;  \
+void ff_vvc_put_##fn##_h8_8_neon##ext args;  \
+void ff_vvc_put_##fn##_h16_8_neon##ext args; \
+void ff_vvc_put_##fn##_h32_8_neon##ext args;
+
+NEON8_FNPROTO_PARTIAL_4(qpel, (int16_t *dst, const uint8_t *_src, ptrdiff_t 
_srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width),)
+
+NEON8_FNPROTO_PARTIAL_4(qpel_uni, (uint8_t *_dst, ptrdiff_t _dststride, const 
uint8_t *_src,
+ptrdiff_t _srcstride, int height, const int8_t *hf, const int8_t *vf, 
int width),)
+
 #endif
diff --git a/libavcodec/aarch64/h26x/qpel_neon.S 
b/libavcodec/aarch64/h26x/qpel_neon.S
index 8ddaa32b70..a05009c9d6 100644
--- a/libavcodec/aarch64/h26x/qpel_neon.S
+++ b/libavcodec/aarch64/h26x/qpel_neon.S
@@ -21,7 +21,8 @@
  */
 
 #include "libavutil/aarch64/asm.S"
-#define MAX_PB_SIZE 64
+#define HEVC_MAX_PB_SIZE 64
+#define VVC_MAX_PB_SIZE 128
 
 const qpel_filters, align=4
 .byte   0,  0,  0,  0,  0,  0, 0,  0
@@ -44,6 +45,11 @@ endconst
 sxtlv0.8h, v0.8b
 .endm
 
+.macro vvc_load_filter m
+ld1 {v0.8b}, [\m]
+sxtlv0.8h, v0.8b
+.endm
+
 .macro load_qpel_filterb freg, xreg
 movrel  \xreg, qpel_filters_abs
 add \xreg, \xreg, \freg, lsl #3
@@ -212,22 +218,40 @@ function ff_hevc_put_hevc_h4_8_neon, export=0
 endfunc
 .endif
 
+.ifnc \type, qpel_bi
+function ff_vvc_put_\type\()_h4_8_neon, export=1
+vvc_load_filter mx
+sub src, src, #3
+mov mx, x30
+.ifc \type, qpel
+mov dststride, #(VVC_MAX_PB_SIZE << 1)
+lsl x13, srcstride, #1 // srcstridel
+mov x14, #(VVC_MAX_PB_SIZE << 2)
+.else
+lsl x14, dststride, #1 // dststridel
+lsl x13, srcstride, #1 // srcstridel
+.endif
+b   1f
+endfunc
+.endif // !qpel_bi
+
 function ff_hevc_put_hevc_\type\()_h4_8_neon, export=1
 load_filter mx
 .ifc \type, qpel_bi
-mov x16, #(MAX_PB_SIZE << 2) // src2bstridel
-add x15, x4, #(MAX_PB_SIZE << 1) // src2b
+mov x16, #(HEVC_MAX_PB_SIZE << 2) // src2bstridel
+add x15, x4, #(HEVC_MAX_PB_SIZE << 1) // src2b
 .endif
 sub src, src, #3
 mov mx, x30
 .ifc \type, qpel
-mov dststride, 

[FFmpeg-devel] [PATCH v2 01/14] aarch64/hevc: Simplify function prototypes by macro

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

---
 libavcodec/aarch64/hevcdsp_init_aarch64.c | 66 +++
 1 file changed, 18 insertions(+), 48 deletions(-)

diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c 
b/libavcodec/aarch64/hevcdsp_init_aarch64.c
index a90da0246e..26bbc8750f 100644
--- a/libavcodec/aarch64/hevcdsp_init_aarch64.c
+++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c
@@ -92,54 +92,24 @@ 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_transform_luma_4x4_neon_8(int16_t *coeffs);
-void ff_hevc_put_hevc_qpel_h4_8_neon(int16_t *dst, const uint8_t *_src, 
ptrdiff_t _srcstride, int height,
- intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h6_8_neon(int16_t *dst, const uint8_t *_src, 
ptrdiff_t _srcstride, int height,
- intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h8_8_neon(int16_t *dst, const uint8_t *_src, 
ptrdiff_t _srcstride, int height,
- intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h12_8_neon(int16_t *dst, const uint8_t *_src, 
ptrdiff_t _srcstride, int height,
-  intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h16_8_neon(int16_t *dst, const uint8_t *_src, 
ptrdiff_t _srcstride, int height,
-  intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h32_8_neon(int16_t *dst, const uint8_t *_src, 
ptrdiff_t _srcstride, int height,
-  intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_uni_h4_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
- ptrdiff_t _srcstride, int height, 
intptr_t mx, intptr_t my,
- int width);
-void ff_hevc_put_hevc_qpel_uni_h6_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
- ptrdiff_t _srcstride, int height, 
intptr_t mx, intptr_t my,
- int width);
-void ff_hevc_put_hevc_qpel_uni_h8_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
- ptrdiff_t _srcstride, int height, 
intptr_t mx, intptr_t my,
- int width);
-void ff_hevc_put_hevc_qpel_uni_h12_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
-  ptrdiff_t _srcstride, int height, 
intptr_t mx, intptr_t
-  my, int width);
-void ff_hevc_put_hevc_qpel_uni_h16_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
-  ptrdiff_t _srcstride, int height, 
intptr_t mx, intptr_t
-  my, int width);
-void ff_hevc_put_hevc_qpel_uni_h32_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
-  ptrdiff_t _srcstride, int height, 
intptr_t mx, intptr_t
-  my, int width);
-void ff_hevc_put_hevc_qpel_bi_h4_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
-ptrdiff_t _srcstride, const int16_t 
*src2, int height, intptr_t
-mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_bi_h6_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
-ptrdiff_t _srcstride, const int16_t 
*src2, int height, intptr_t
-mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_bi_h8_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
-ptrdiff_t _srcstride, const int16_t 
*src2, int height, intptr_t
-mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_bi_h12_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
- ptrdiff_t _srcstride, const int16_t 
*src2, int height, intptr_t
- mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_bi_h16_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
- ptrdiff_t _srcstride, const int16_t 
*src2, int height, intptr_t
- mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_bi_h32_8_neon(uint8_t *_dst, ptrdiff_t _dststride, 
const uint8_t *_src,
- ptrdiff_t _srcstride, const int16_t 
*src2, int height, intptr_t
- mx, intptr_t my, int width);
+
+#define NEON8_FNPROTO_PARTIAL_6(fn, args, ext) \

[FFmpeg-devel] [PATCH v2 02/14] aarch64/hevc: Move epel/qpel to h26x directory

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

So vvc can reuse the implementation.
---
 libavcodec/aarch64/Makefile   |   4 +-
 libavcodec/aarch64/h26x/dsp.h | 198 ++
 .../{hevcdsp_epel_neon.S => h26x/epel_neon.S} |   0
 .../{hevcdsp_qpel_neon.S => h26x/qpel_neon.S} |   0
 libavcodec/aarch64/hevcdsp_init_aarch64.c | 197 -
 5 files changed, 200 insertions(+), 199 deletions(-)
 rename libavcodec/aarch64/{hevcdsp_epel_neon.S => h26x/epel_neon.S} (100%)
 rename libavcodec/aarch64/{hevcdsp_qpel_neon.S => h26x/qpel_neon.S} (100%)

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index a01e665b55..9affb92789 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -71,6 +71,6 @@ NEON-OBJS-$(CONFIG_VP9_DECODER) += 
aarch64/vp9itxfm_16bpp_neon.o   \
 NEON-OBJS-$(CONFIG_HEVC_DECODER)+= aarch64/hevcdsp_deblock_neon.o  
\
aarch64/hevcdsp_idct_neon.o 
\
aarch64/hevcdsp_init_aarch64.o  
\
-   aarch64/hevcdsp_qpel_neon.o 
\
-   aarch64/hevcdsp_epel_neon.o 
\
+   aarch64/h26x/epel_neon.o
\
+   aarch64/h26x/qpel_neon.o
\
aarch64/h26x/sao_neon.o
diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index d3f7a4dfe3..902286872d 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -37,4 +37,202 @@ void ff_vvc_sao_edge_filter_16x16_8_neon(uint8_t *dst, 
const uint8_t *src, ptrdi
  const int16_t *sao_offset_val, int 
eo, int width, int height);
 void ff_vvc_sao_edge_filter_8x8_8_neon(uint8_t *dst, const uint8_t *src, 
ptrdiff_t stride_dst,
const int16_t *sao_offset_val, int eo, 
int width, int height);
+
+#define NEON8_FNPROTO_PARTIAL_6(fn, args, ext) \
+void ff_hevc_put_hevc_##fn##_h4_8_neon##ext args;  \
+void ff_hevc_put_hevc_##fn##_h6_8_neon##ext args;  \
+void ff_hevc_put_hevc_##fn##_h8_8_neon##ext args;  \
+void ff_hevc_put_hevc_##fn##_h12_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##_h16_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##_h32_8_neon##ext args;
+
+NEON8_FNPROTO_PARTIAL_6(qpel, (int16_t *dst, const uint8_t *_src, ptrdiff_t 
_srcstride, int height,
+intptr_t mx, intptr_t my, int width),)
+
+NEON8_FNPROTO_PARTIAL_6(qpel_uni, (uint8_t *_dst, ptrdiff_t _dststride, const 
uint8_t *_src,
+ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int 
width),)
+
+NEON8_FNPROTO_PARTIAL_6(qpel_bi, (uint8_t *_dst, ptrdiff_t _dststride, const 
uint8_t *_src,
+ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t
+mx, intptr_t my, int width),)
+
+#define NEON8_FNPROTO(fn, args, ext) \
+void ff_hevc_put_hevc_##fn##4_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##6_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##8_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##12_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##16_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##24_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##32_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##48_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##64_8_neon##ext args
+
+#define NEON8_FNPROTO_PARTIAL_4(fn, args, ext) \
+void ff_hevc_put_hevc_##fn##4_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##8_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##16_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##64_8_neon##ext args
+
+#define NEON8_FNPROTO_PARTIAL_5(fn, args, ext) \
+void ff_hevc_put_hevc_##fn##4_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##8_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##16_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##32_8_neon##ext args; \
+void ff_hevc_put_hevc_##fn##64_8_neon##ext args
+
+NEON8_FNPROTO(pel_pixels, (int16_t *dst,
+const uint8_t *src, ptrdiff_t srcstride,
+int height, intptr_t mx, intptr_t my, int width),);
+
+NEON8_FNPROTO(pel_bi_pixels, (uint8_t *dst, ptrdiff_t dststride,
+const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
+int height, intptr_t mx, intptr_t my, int width),);
+
+NEON8_FNPROTO(epel_bi_h, (uint8_t *dst, ptrdiff_t dststride,
+const uint8_t *src, ptrdiff_t srcstride, const int16_t *src2,
+int height, intptr_t mx, intptr_t my, int width),);
+
+NEON8_FNPROTO(epel_bi_v, (uint8_t *dst, ptrdiff_t dststride,
+const uint8_t *src, ptrdiff_t srcstride, const int16_t *src2,
+int height, intptr_t mx, intptr_t my, int width),);
+
+NEON8_FNPROTO(epel_bi_hv, (uint8_t *dst, ptrdiff_t dststride,
+const uint8_

[FFmpeg-devel] [PATCH v2 05/14] aarch64/vvc: Add put_qpel_hx i8mm

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

Benchmark on Android pixel 8 with -fno-vectorize

put_luma_h_8_4x4_c:  0.2 ( 1.00x)
put_luma_h_8_4x4_neon:   0.2 ( 1.00x)
put_luma_h_8_4x4_i8mm:   0.0 ( 0.00x)
put_luma_h_8_8x8_c:  1.5 ( 1.00x)
put_luma_h_8_8x8_neon:   0.5 ( 3.00x)
put_luma_h_8_8x8_i8mm:   0.5 ( 3.00x)
put_luma_h_8_16x16_c:6.2 ( 1.00x)
put_luma_h_8_16x16_neon: 2.0 ( 3.12x)
put_luma_h_8_16x16_i8mm: 1.5 ( 4.17x)
put_luma_h_8_32x32_c:   25.5 ( 1.00x)
put_luma_h_8_32x32_neon: 9.0 ( 2.83x)
put_luma_h_8_32x32_i8mm: 6.8 ( 3.78x)
put_luma_h_8_64x64_c:   99.8 ( 1.00x)
put_luma_h_8_64x64_neon:35.2 ( 2.83x)
put_luma_h_8_64x64_i8mm:27.2 ( 3.66x)
put_luma_h_8_128x128_c:422.0 ( 1.00x)
put_luma_h_8_128x128_neon: 138.5 ( 3.05x)
put_luma_h_8_128x128_i8mm: 109.2 ( 3.86x)
---
 libavcodec/aarch64/h26x/dsp.h   |  4 ++
 libavcodec/aarch64/h26x/qpel_neon.S | 68 ++---
 libavcodec/aarch64/vvc/dsp_init.c   |  9 
 3 files changed, 76 insertions(+), 5 deletions(-)

diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index 076d01b477..323a253257 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -270,4 +270,8 @@ NEON8_FNPROTO_PARTIAL_6(pel_uni_w_pixels, (uint8_t *_dst, 
ptrdiff_t _dststride,
 int height, int denom, int wx, int ox,
 const int8_t *hf, const int8_t *vf, int width),);
 
+NEON8_FNPROTO_PARTIAL_6(qpel_h, (int16_t * dst,
+const uint8_t *_src, ptrdiff_t _srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width), _i8mm);
+
 #endif
diff --git a/libavcodec/aarch64/h26x/qpel_neon.S 
b/libavcodec/aarch64/h26x/qpel_neon.S
index 47b3948f8b..1fa5a1dd0e 100644
--- a/libavcodec/aarch64/h26x/qpel_neon.S
+++ b/libavcodec/aarch64/h26x/qpel_neon.S
@@ -3516,6 +3516,17 @@ endfunc
 sub x1, x1, #3
 .endm
 
+.macro VVC_QPEL_H_HEADER
+ld1r{v31.2d}, [x4]
+sub x1, x1, #3
+.endm
+
+function ff_vvc_put_qpel_h4_8_neon_i8mm, export=1
+VVC_QPEL_H_HEADER
+mov x10, #VVC_MAX_PB_SIZE * 2
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_qpel_h4_8_neon_i8mm, export=1
 QPEL_H_HEADER
 mov x10, #HEVC_MAX_PB_SIZE * 2
@@ -3572,6 +3583,12 @@ function ff_hevc_put_hevc_qpel_h6_8_neon_i8mm, export=1
 ret
 endfunc
 
+function ff_vvc_put_qpel_h8_8_neon_i8mm, export=1
+VVC_QPEL_H_HEADER
+mov x10, #VVC_MAX_PB_SIZE * 2
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_qpel_h8_8_neon_i8mm, export=1
 QPEL_H_HEADER
 mov x10, #HEVC_MAX_PB_SIZE * 2
@@ -3656,6 +3673,12 @@ function ff_hevc_put_hevc_qpel_h12_8_neon_i8mm, export=1
 ret
 endfunc
 
+function ff_vvc_put_qpel_h16_8_neon_i8mm, export=1
+VVC_QPEL_H_HEADER
+mov x10, #VVC_MAX_PB_SIZE * 2
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_qpel_h16_8_neon_i8mm, export=1
 QPEL_H_HEADER
 mov x10, #HEVC_MAX_PB_SIZE * 2
@@ -3746,6 +3769,13 @@ function ff_hevc_put_hevc_qpel_h24_8_neon_i8mm, export=1
 ret
 endfunc
 
+function ff_vvc_put_qpel_h32_8_neon_i8mm, export=1
+VVC_QPEL_H_HEADER
+mov x10, #VVC_MAX_PB_SIZE * 2
+add x15, x0, #32
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_qpel_h32_8_neon_i8mm, export=1
 QPEL_H_HEADER
 mov x10, #HEVC_MAX_PB_SIZE * 2
@@ -3881,10 +3911,7 @@ function ff_hevc_put_hevc_qpel_h48_8_neon_i8mm, export=1
 ret
 endfunc
 
-function ff_hevc_put_hevc_qpel_h64_8_neon_i8mm, export=1
-QPEL_H_HEADER
-sub x2, x2, #64
-1:
+.macro put_qpel_h64_8_neon_i8mm
 ld1 {v16.16b, v17.16b, v18.16b, v19.16b}, [x1], #64
 ext v1.16b, v16.16b, v17.16b, #1
 ext v2.16b, v16.16b, v17.16b, #2
@@ -3975,11 +4002,42 @@ function ff_hevc_put_hevc_qpel_h64_8_neon_i8mm, export=1
 sqxtn2  v20.8h, v26.4s
 sqxtn   v21.4h, v23.4s
 sqxtn2  v21.8h, v27.4s
-stp q20, q21, [x0], #32
+stp q20, q21, [x0]
+add x0, x0, x10
+.endm
+
+function ff_vvc_put_qpel_h64_8_neon_i8mm, export=1
+VVC_QPEL_H_HEADER
+mov x10, #(VVC_MAX_PB_SIZE * 2 - 32 * 3)
+   

[FFmpeg-devel] [PATCH v2 04/14] aarch64/vvc: Add put_pel/put_pel_uni/put_pel_uni_w

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

put_luma_pixels_8_4x4_c: 0.2 ( 1.00x)
put_luma_pixels_8_4x4_neon:  0.2 ( 1.00x)
put_luma_pixels_8_8x8_c: 0.7 ( 1.00x)
put_luma_pixels_8_8x8_neon:  0.2 ( 3.22x)
put_luma_pixels_8_16x16_c:   2.2 ( 1.00x)
put_luma_pixels_8_16x16_neon:0.2 ( 9.89x)
put_luma_pixels_8_32x32_c:   8.2 ( 1.00x)
put_luma_pixels_8_32x32_neon:1.2 ( 6.71x)
put_luma_pixels_8_64x64_c:  33.7 ( 1.00x)
put_luma_pixels_8_64x64_neon:2.5 (13.63x)
put_luma_pixels_8_128x128_c:   145.5 ( 1.00x)
put_luma_pixels_8_128x128_neon: 10.2 (14.23x)
put_uni_pixels_luma_8_4x4_c: 0.5 ( 1.00x)
put_uni_pixels_luma_8_4x4_neon:  0.0 ( 0.00x)
put_uni_pixels_luma_8_8x8_c: 0.5 ( 1.00x)
put_uni_pixels_luma_8_8x8_neon:  0.2 ( 2.11x)
put_uni_pixels_luma_8_16x16_c:   1.2 ( 1.00x)
put_uni_pixels_luma_8_16x16_neon:0.2 ( 5.44x)
put_uni_pixels_luma_8_32x32_c:   3.0 ( 1.00x)
put_uni_pixels_luma_8_32x32_neon:0.5 ( 6.26x)
put_uni_pixels_luma_8_64x64_c:   3.0 ( 1.00x)
put_uni_pixels_luma_8_64x64_neon:1.7 ( 1.72x)
put_uni_pixels_luma_8_128x128_c: 6.5 ( 1.00x)
put_uni_pixels_luma_8_128x128_neon:  6.5 ( 1.00x)
---
 libavcodec/aarch64/h26x/dsp.h   |  22 
 libavcodec/aarch64/h26x/epel_neon.S | 189 +---
 libavcodec/aarch64/h26x/qpel_neon.S |  81 +++-
 libavcodec/aarch64/vvc/Makefile |   1 +
 libavcodec/aarch64/vvc/dsp_init.c   |  21 
 5 files changed, 241 insertions(+), 73 deletions(-)

diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index f72746ce03..076d01b477 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -248,4 +248,26 @@ NEON8_FNPROTO_PARTIAL_4(qpel, (int16_t *dst, const uint8_t 
*_src, ptrdiff_t _src
 NEON8_FNPROTO_PARTIAL_4(qpel_uni, (uint8_t *_dst, ptrdiff_t _dststride, const 
uint8_t *_src,
 ptrdiff_t _srcstride, int height, const int8_t *hf, const int8_t *vf, 
int width),)
 
+#undef NEON8_FNPROTO_PARTIAL_6
+#define NEON8_FNPROTO_PARTIAL_6(fn, args, ext) \
+void ff_vvc_put_##fn##4_8_neon##ext args; \
+void ff_vvc_put_##fn##8_8_neon##ext args; \
+void ff_vvc_put_##fn##16_8_neon##ext args; \
+void ff_vvc_put_##fn##32_8_neon##ext args; \
+void ff_vvc_put_##fn##64_8_neon##ext args; \
+void ff_vvc_put_##fn##128_8_neon##ext args
+
+NEON8_FNPROTO_PARTIAL_6(pel_pixels, (int16_t *dst,
+const uint8_t *src, ptrdiff_t srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width),);
+
+NEON8_FNPROTO_PARTIAL_6(pel_uni_pixels, (uint8_t *_dst, ptrdiff_t _dststride,
+const uint8_t *_src, ptrdiff_t _srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width),);
+
+NEON8_FNPROTO_PARTIAL_6(pel_uni_w_pixels, (uint8_t *_dst, ptrdiff_t _dststride,
+const uint8_t *_src, ptrdiff_t _srcstride,
+int height, int denom, int wx, int ox,
+const int8_t *hf, const int8_t *vf, int width),);
+
 #endif
diff --git a/libavcodec/aarch64/h26x/epel_neon.S 
b/libavcodec/aarch64/h26x/epel_neon.S
index 378b0f7fb2..8ca42a5c3a 100644
--- a/libavcodec/aarch64/h26x/epel_neon.S
+++ b/libavcodec/aarch64/h26x/epel_neon.S
@@ -19,7 +19,8 @@
  */
 
 #include "libavutil/aarch64/asm.S"
-#define MAX_PB_SIZE 64
+#define HEVC_MAX_PB_SIZE 64
+#define VVC_MAX_PB_SIZE 128
 
 const epel_filters, align=4
 .byte  0,  0,  0,  0
@@ -131,8 +132,13 @@ endconst
 b.ne1b
 .endm
 
+function ff_vvc_put_pel_pixels4_8_neon, export=1
+mov x7, #(VVC_MAX_PB_SIZE * 2)
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_pel_pixels4_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2)
+mov x7, #(HEVC_MAX_PB_SIZE * 2)
 1:  ld1 {v0.s}[0], [x1], x2
 ushll   v4.8h, v0.8b, #6
 subsw3, w3, #1
@@ -142,7 +148,7 @@ function ff_hevc_put_hevc_pel_pixels4_8_neon, export=1
 endfunc
 
 function ff_hevc_put_hevc_pel_pixels6_8_neon, export=1
-mov x7, #(MAX_PB_SIZE * 2 - 8)
+mov x7, #(HEVC_MAX_PB_SIZE * 2 - 8)
 1:  ld1 {v0.8b}, [x1], x2
 ushll   v4.8h, v0.8b, #6
 st1 {v4.d}[0], [x0], #8
@@ -152,8 +158,13 @@ function ff_hevc_put_hevc_pel_pixels6_8_neon, export=1
 ret
 endfunc
 
+function ff_vvc_put_pel_pixels8_8_neon, export=1
+mov x7, #(VVC_MAX_PB_SIZE * 2)
+

[FFmpeg-devel] [PATCH v2 06/14] avcodec/hevc: ff_hevc_(qpel/epel)_filters are signed type

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

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

diff --git a/libavcodec/hevc/dsp_template.c b/libavcodec/hevc/dsp_template.c
index aebccd1a0c..a0f79c2673 100644
--- a/libavcodec/hevc/dsp_template.c
+++ b/libavcodec/hevc/dsp_template.c
@@ -302,8 +302,8 @@ IDCT_DC(32)
 

 #define ff_hevc_pel_filters ff_hevc_qpel_filters
 #define DECL_HV_FILTER(f)  \
-const uint8_t *hf = ff_hevc_ ## f ## _filters[mx]; \
-const uint8_t *vf = ff_hevc_ ## f ## _filters[my];
+const int8_t *hf = ff_hevc_ ## f ## _filters[mx]; \
+const int8_t *vf = ff_hevc_ ## f ## _filters[my];
 
 #define FW_PUT(p, f, t)
   \
 static void FUNC(put_hevc_## f)(int16_t *dst, const uint8_t *src, ptrdiff_t 
srcstride, int height,\
-- 
2.42.0

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

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


[FFmpeg-devel] [PATCH v2 07/14] aarch64/h26x: Remove duplicate b.eq instruction

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

b.eq is added by calc_all after each calc.
---
 libavcodec/aarch64/h26x/qpel_neon.S | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/aarch64/h26x/qpel_neon.S 
b/libavcodec/aarch64/h26x/qpel_neon.S
index 1fa5a1dd0e..417d43e365 100644
--- a/libavcodec/aarch64/h26x/qpel_neon.S
+++ b/libavcodec/aarch64/h26x/qpel_neon.S
@@ -754,7 +754,6 @@ function ff_hevc_put_hevc_qpel_v4_8_neon, export=1
 calc_qpelb  v24, \src0, \src1, \src2, \src3, \src4, \src5, \src6, 
\src7
 st1 {v24.4h}, [x0], x9
 subsw3, w3, #1
-b.eq2f
 .endm
 1:  calc_all
 .purgem calc
-- 
2.42.0

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

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


[FFmpeg-devel] [PATCH v2 10/14] aarch64/vvc: Add sad

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

sad_8x16_c:  0.8 ( 1.00x)
sad_8x16_neon:   0.2 ( 3.00x)
sad_16x8_c:  0.5 ( 1.00x)
sad_16x8_neon:   0.2 ( 2.00x)
sad_16x16_c: 1.5 ( 1.00x)
sad_16x16_neon:  0.2 ( 6.00x)
---
 libavcodec/aarch64/vvc/Makefile   |  1 +
 libavcodec/aarch64/vvc/dsp_init.c |  5 +++
 libavcodec/aarch64/vvc/sad.S  | 75 +++
 3 files changed, 81 insertions(+)
 create mode 100644 libavcodec/aarch64/vvc/sad.S

diff --git a/libavcodec/aarch64/vvc/Makefile b/libavcodec/aarch64/vvc/Makefile
index a1c1f03e27..7ba13a2165 100644
--- a/libavcodec/aarch64/vvc/Makefile
+++ b/libavcodec/aarch64/vvc/Makefile
@@ -3,6 +3,7 @@ clean::
 
 OBJS-$(CONFIG_VVC_DECODER)  += aarch64/vvc/dsp_init.o
 NEON-OBJS-$(CONFIG_VVC_DECODER) += aarch64/vvc/alf.o \
+   aarch64/vvc/sad.o \
aarch64/h26x/epel_neon.o \
aarch64/h26x/qpel_neon.o \
aarch64/h26x/sao_neon.o
diff --git a/libavcodec/aarch64/vvc/dsp_init.c 
b/libavcodec/aarch64/vvc/dsp_init.c
index 934d918ffd..714d642634 100644
--- a/libavcodec/aarch64/vvc/dsp_init.c
+++ b/libavcodec/aarch64/vvc/dsp_init.c
@@ -39,6 +39,9 @@
 #include "alf_template.c"
 #undef BIT_DEPTH
 
+int ff_vvc_sad_neon(const int16_t *src0, const int16_t *src1, int dx, int dy,
+const int block_w, const int block_h);
+
 void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
 {
 int cpu_flags = av_get_cpu_flags();
@@ -125,4 +128,6 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const 
int bd)
 c->alf.filter[LUMA] = alf_filter_luma_12_neon;
 c->alf.filter[CHROMA] = alf_filter_chroma_12_neon;
 }
+
+c->inter.sad = ff_vvc_sad_neon;
 }
diff --git a/libavcodec/aarch64/vvc/sad.S b/libavcodec/aarch64/vvc/sad.S
new file mode 100644
index 00..beca876faf
--- /dev/null
+++ b/libavcodec/aarch64/vvc/sad.S
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2024 Zhao Zhili 
+ *
+ * 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"
+
+#define VVC_MAX_PB_SIZE 128
+
+function ff_vvc_sad_neon, export=1
+src0.req x0
+src1.req x1
+dx  .req w2
+dy  .req w3
+block_w .req w4
+block_h .req w5
+
+sub w7, dx, #4
+sub w8, dy, #4
+add w6, dx, dy, lsl #7
+add w7, w7, w8, lsl #7
+sxtwx6, w6
+sxtwx7, w7
+add src0, src0, x6, lsl #1
+sub src1, src1, x7, lsl #1
+
+cmp block_w, #16
+moviv16.4s, #0
+b.ge2f
+1:
+// block_w == 8
+ldr q0, [src0]
+ldr q2, [src1]
+subsblock_h, block_h, #2
+sabal   v16.4s, v0.4h, v2.4h
+sabal2  v16.4s, v0.8h, v2.8h
+
+add src0, src0, #(2 * VVC_MAX_PB_SIZE * 2)
+add src1, src1, #(2 * VVC_MAX_PB_SIZE * 2)
+b.ne1b
+b   4f
+2:
+// block_w == 16, no block_w > 16 according the spec
+moviv17.4s, #0
+3:
+ldp q0, q1, [src0], #(2 * VVC_MAX_PB_SIZE * 2)
+ldp q2, q3, [src1], #(2 * VVC_MAX_PB_SIZE * 2)
+subsblock_h, block_h, #2
+sabal   v16.4s, v0.4h, v2.4h
+sabal2  v16.4s, v0.8h, v2.8h
+sabal   v17.4s, v1.4h, v3.4h
+sabal2  v17.4s, v1.8h, v3.8h
+
+b.ne3b
+add v16.4s, v16.4s, v17.4s
+4:
+addvs16, v16.4s
+mov w0, v16.s[0]
+ret
+endfunc
-- 
2.42.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg

[FFmpeg-devel] [PATCH v2 09/14] aarch64/vvc: Add put_qpel_hv

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

With Apple M1 (no i8mm):

put_luma_hv_8_4x4_c: 2.2 ( 1.00x)
put_luma_hv_8_4x4_neon:  0.8 ( 3.00x)
put_luma_hv_8_8x8_c: 7.0 ( 1.00x)
put_luma_hv_8_8x8_neon:  0.8 ( 9.33x)
put_luma_hv_8_16x16_c:  22.8 ( 1.00x)
put_luma_hv_8_16x16_neon:2.5 ( 9.10x)
put_luma_hv_8_32x32_c:  84.8 ( 1.00x)
put_luma_hv_8_32x32_neon:9.5 ( 8.92x)
put_luma_hv_8_64x64_c: 333.0 ( 1.00x)
put_luma_hv_8_64x64_neon:   35.5 ( 9.38x)
put_luma_hv_8_128x128_c:  1294.5 ( 1.00x)
put_luma_hv_8_128x128_neon:137.8 ( 9.40x)

With Pixel 8 Pro:

put_luma_hv_8_4x4_c: 5.0 ( 1.00x)
put_luma_hv_8_4x4_neon:  0.8 ( 6.67x)
put_luma_hv_8_4x4_i8mm:  0.2 (20.00x)
put_luma_hv_8_8x8_c:13.2 ( 1.00x)
put_luma_hv_8_8x8_neon:  1.2 (10.60x)
put_luma_hv_8_8x8_i8mm:  1.2 (10.60x)
put_luma_hv_8_16x16_c:  44.2 ( 1.00x)
put_luma_hv_8_16x16_neon:4.5 ( 9.83x)
put_luma_hv_8_16x16_i8mm:4.2 (10.41x)
put_luma_hv_8_32x32_c: 160.8 ( 1.00x)
put_luma_hv_8_32x32_neon:   17.5 ( 9.19x)
put_luma_hv_8_32x32_i8mm:   16.0 (10.05x)
put_luma_hv_8_64x64_c: 611.2 ( 1.00x)
put_luma_hv_8_64x64_neon:   68.0 ( 8.99x)
put_luma_hv_8_64x64_i8mm:   62.2 ( 9.82x)
put_luma_hv_8_128x128_c:  2384.8 ( 1.00x)
put_luma_hv_8_128x128_neon:268.8 ( 8.87x)
put_luma_hv_8_128x128_i8mm:245.8 ( 9.70x)
---
 libavcodec/aarch64/h26x/dsp.h   |   8 ++
 libavcodec/aarch64/h26x/qpel_neon.S | 140 
 libavcodec/aarch64/vvc/dsp_init.c   |  14 +++
 3 files changed, 162 insertions(+)

diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index 881091f39a..c54906dde2 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -282,4 +282,12 @@ void ff_vvc_put_qpel_v8_8_neon(int16_t *dst, const uint8_t 
*_src,
ptrdiff_t _srcstride, int height,
const int8_t *hf, const int8_t *vf, int width);
 
+NEON8_FNPROTO_PARTIAL_6(qpel_hv, (int16_t *dst,
+const uint8_t *src, ptrdiff_t srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width),);
+
+NEON8_FNPROTO_PARTIAL_6(qpel_hv, (int16_t *dst,
+const uint8_t *src, ptrdiff_t srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width), _i8mm);
+
 #endif
diff --git a/libavcodec/aarch64/h26x/qpel_neon.S 
b/libavcodec/aarch64/h26x/qpel_neon.S
index a6a3b9549d..5c3f0263b6 100644
--- a/libavcodec/aarch64/h26x/qpel_neon.S
+++ b/libavcodec/aarch64/h26x/qpel_neon.S
@@ -4140,9 +4140,15 @@ endfunc
 DISABLE_I8MM
 #endif
 
+function vvc_put_qpel_hv4_8_end_neon
+ vvc_load_qpel_filterh x5
+ mov x7, #(VVC_MAX_PB_SIZE * 2)
+ b   1f
+endfunc
 
 function hevc_put_hevc_qpel_hv4_8_end_neon
 load_qpel_filterh x5, x4
+1:
 ldr d16, [sp]
 ldr d17, [sp, x7]
 add sp, sp, x7, lsl #1
@@ -4194,9 +4200,16 @@ function hevc_put_hevc_qpel_hv6_8_end_neon
 ret
 endfunc
 
+function vvc_put_qpel_hv8_8_end_neon
+vvc_load_qpel_filterh x5
+mov x7, #(VVC_MAX_PB_SIZE * 2)
+b   1f
+endfunc
+
 function hevc_put_hevc_qpel_hv8_8_end_neon
 mov x7, #128
 load_qpel_filterh x5, x4
+1:
 ldr q16, [sp]
 ldr q17, [sp, x7]
 add sp, sp, x7, lsl #1
@@ -4247,9 +4260,16 @@ function hevc_put_hevc_qpel_hv12_8_end_neon
 ret
 endfunc
 
+function vvc_put_qpel_hv16_8_end_neon
+vvc_load_qpel_filterh x5
+mov x7, #(VVC_MAX_PB_SIZE * 2)
+b   1f
+endfunc
+
 function hevc_put_hevc_qpel_hv16_8_end_neon
 mov x7, #128
 load_qpel_filterh x5, x4
+1:
 ld1 {v16.8h, v17.8h}, [sp], x7
 ld1 {v18.8h, v19.8h}, [sp], x7
 ld1 {v20.8h, v21.8h}, [sp], x7
@@ -4272,6 +4292,12 @@ function hevc_put_hevc_qpel_hv16_8_end_neon
 ret
 endfunc
 
+function vvc_put_qpel_hv32_8_end_neon
+vvc_load_qpel_filterh x5
+mov x7, #(VVC_MAX_PB_S

[FFmpeg-devel] [PATCH v2 11/14] aarch64/vvc: Add put_epel_h

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

put_chroma_h_8_4x4_c:0.2 ( 1.00x)
put_chroma_h_8_4x4_neon: 0.2 ( 1.00x)
put_chroma_h_8_8x8_c:0.8 ( 1.00x)
put_chroma_h_8_8x8_neon: 0.2 ( 3.00x)
put_chroma_h_8_16x16_c:  3.8 ( 1.00x)
put_chroma_h_8_16x16_neon:   0.8 ( 5.00x)
put_chroma_h_8_32x32_c: 12.5 ( 1.00x)
put_chroma_h_8_32x32_neon:   2.2 ( 5.56x)
put_chroma_h_8_64x64_c: 47.0 ( 1.00x)
put_chroma_h_8_64x64_neon:   8.8 ( 5.37x)
put_chroma_h_8_128x128_c:  200.2 ( 1.00x)
put_chroma_h_8_128x128_neon:31.8 ( 6.31x)
---
 libavcodec/aarch64/h26x/dsp.h   |  3 +++
 libavcodec/aarch64/h26x/epel_neon.S | 30 +
 libavcodec/aarch64/vvc/dsp_init.c   |  7 +++
 3 files changed, 40 insertions(+)

diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index c54906dde2..6978b900fe 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -248,6 +248,9 @@ NEON8_FNPROTO_PARTIAL_4(qpel, (int16_t *dst, const uint8_t 
*_src, ptrdiff_t _src
 NEON8_FNPROTO_PARTIAL_4(qpel_uni, (uint8_t *_dst, ptrdiff_t _dststride, const 
uint8_t *_src,
 ptrdiff_t _srcstride, int height, const int8_t *hf, const int8_t *vf, 
int width),)
 
+NEON8_FNPROTO_PARTIAL_4(epel, (int16_t *dst, const uint8_t *_src, ptrdiff_t 
_srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width),)
+
 #undef NEON8_FNPROTO_PARTIAL_6
 #define NEON8_FNPROTO_PARTIAL_6(fn, args, ext) \
 void ff_vvc_put_##fn##4_8_neon##ext args; \
diff --git a/libavcodec/aarch64/h26x/epel_neon.S 
b/libavcodec/aarch64/h26x/epel_neon.S
index 8ca42a5c3a..80a0b66a52 100644
--- a/libavcodec/aarch64/h26x/epel_neon.S
+++ b/libavcodec/aarch64/h26x/epel_neon.S
@@ -1375,6 +1375,18 @@ endfunc
 mov x10, #(HEVC_MAX_PB_SIZE * 2)
 .endm
 
+.macro VVC_EPEL_H_HEADER
+ld1r{v30.4s}, [x4]
+sub x1, x1, #1
+mov x10, #(VVC_MAX_PB_SIZE * 2)
+.endm
+
+function ff_vvc_put_epel_h4_8_neon, export=1
+VVC_EPEL_H_HEADER
+sxtlv0.8h,   v30.8b
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_epel_h4_8_neon, export=1
 EPEL_H_HEADER
 sxtlv0.8h,   v30.8b
@@ -1414,6 +1426,12 @@ function ff_hevc_put_hevc_epel_h6_8_neon, export=1
 ret
 endfunc
 
+function ff_vvc_put_epel_h8_8_neon, export=1
+VVC_EPEL_H_HEADER
+sxtlv0.8h,   v30.8b
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_epel_h8_8_neon, export=1
 EPEL_H_HEADER
 sxtlv0.8h,   v30.8b
@@ -1461,6 +1479,12 @@ function ff_hevc_put_hevc_epel_h12_8_neon, export=1
 ret
 endfunc
 
+function ff_vvc_put_epel_h16_8_neon, export=1
+VVC_EPEL_H_HEADER
+sxtlv0.8h,   v30.8b
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_epel_h16_8_neon, export=1
 EPEL_H_HEADER
 sxtlv0.8h,   v30.8b
@@ -1523,8 +1547,14 @@ function ff_hevc_put_hevc_epel_h24_8_neon, export=1
 ret
 endfunc
 
+function ff_vvc_put_epel_h32_8_neon, export=1
+VVC_EPEL_H_HEADER
+b   0f
+endfunc
+
 function ff_hevc_put_hevc_epel_h32_8_neon, export=1
 EPEL_H_HEADER
+0:
 ld1 {v1.8b}, [x1], #8
 sub x2,  x2,  w6, uxtw// decrement src stride
 mov w7,  w6   // original width
diff --git a/libavcodec/aarch64/vvc/dsp_init.c 
b/libavcodec/aarch64/vvc/dsp_init.c
index 714d642634..c8c13eb068 100644
--- a/libavcodec/aarch64/vvc/dsp_init.c
+++ b/libavcodec/aarch64/vvc/dsp_init.c
@@ -77,6 +77,13 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const 
int bd)
 c->inter.put[0][5][1][1] = ff_vvc_put_qpel_hv64_8_neon;
 c->inter.put[0][6][1][1] = ff_vvc_put_qpel_hv128_8_neon;
 
+c->inter.put[1][1][0][1] = ff_vvc_put_epel_h4_8_neon;
+c->inter.put[1][2][0][1] = ff_vvc_put_epel_h8_8_neon;
+c->inter.put[1][3][0][1] = ff_vvc_put_epel_h16_8_neon;
+c->inter.put[1][4][0][1] =
+c->inter.put[1][5][0][1] =
+c->inter.put[1][6][0][1] = ff_vvc_put_epel_h32_8_neon;
+
 c->inter.put_uni[0][1][0][0] = ff_vvc_put_pel_uni_pixels4_8_neon;
 c->inter.put_uni[0][2][0][0] = ff_vvc_put_pel_uni_pixels8_8_neon;
 c->inter.put_uni[0][3][0][0] = ff_vvc_put_pel_uni_pixels16_8_neon;
-- 
2.42.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

[FFmpeg-devel] [PATCH v2 12/14] aarch64/vvc: Add put_epel_h i8mm

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

put_chroma_h_8_4x4_c:0.4 ( 1.00x)
put_chroma_h_8_4x4_neon: 0.0 ( 0.00x)
put_chroma_h_8_4x4_i8mm: 0.1 ( 2.67x)
put_chroma_h_8_8x8_c:1.6 ( 1.00x)
put_chroma_h_8_8x8_neon: 0.1 (11.00x)
put_chroma_h_8_8x8_i8mm: 0.1 (11.00x)
put_chroma_h_8_16x16_c:  6.9 ( 1.00x)
put_chroma_h_8_16x16_neon:   1.1 ( 6.00x)
put_chroma_h_8_16x16_i8mm:   0.7 (10.62x)
put_chroma_h_8_32x32_c: 27.6 ( 1.00x)
put_chroma_h_8_32x32_neon:   4.7 ( 5.95x)
put_chroma_h_8_32x32_i8mm:   4.4 ( 6.28x)
put_chroma_h_8_64x64_c:116.2 ( 1.00x)
put_chroma_h_8_64x64_neon:  19.1 ( 6.07x)
put_chroma_h_8_64x64_i8mm:  17.1 ( 6.77x)
put_chroma_h_8_128x128_c:  466.6 ( 1.00x)
put_chroma_h_8_128x128_neon:81.4 ( 5.73x)
put_chroma_h_8_128x128_i8mm:71.7 ( 6.51x)
---
 libavcodec/aarch64/h26x/dsp.h   |  6 ++-
 libavcodec/aarch64/h26x/epel_neon.S | 60 ++---
 libavcodec/aarch64/vvc/dsp_init.c   |  7 
 3 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index 6978b900fe..90a42d7108 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -273,7 +273,11 @@ NEON8_FNPROTO_PARTIAL_6(pel_uni_w_pixels, (uint8_t *_dst, 
ptrdiff_t _dststride,
 int height, int denom, int wx, int ox,
 const int8_t *hf, const int8_t *vf, int width),);
 
-NEON8_FNPROTO_PARTIAL_6(qpel_h, (int16_t * dst,
+NEON8_FNPROTO_PARTIAL_6(qpel_h, (int16_t *dst,
+const uint8_t *_src, ptrdiff_t _srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width), _i8mm);
+
+NEON8_FNPROTO_PARTIAL_6(epel_h, (int16_t *dst,
 const uint8_t *_src, ptrdiff_t _srcstride, int height,
 const int8_t *hf, const int8_t *vf, int width), _i8mm);
 
diff --git a/libavcodec/aarch64/h26x/epel_neon.S 
b/libavcodec/aarch64/h26x/epel_neon.S
index 80a0b66a52..cad8f2a5f4 100644
--- a/libavcodec/aarch64/h26x/epel_neon.S
+++ b/libavcodec/aarch64/h26x/epel_neon.S
@@ -1910,6 +1910,12 @@ endfunc
 
 #if HAVE_I8MM
 ENABLE_I8MM
+
+function ff_vvc_put_epel_h4_8_neon_i8mm, export=1
+VVC_EPEL_H_HEADER
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_epel_h4_8_neon_i8mm, export=1
 EPEL_H_HEADER
 1:  ld1 {v4.8b}, [x1], x2
@@ -1953,6 +1959,11 @@ function ff_hevc_put_hevc_epel_h6_8_neon_i8mm, export=1
 ret
 endfunc
 
+function ff_vvc_put_epel_h8_8_neon_i8mm, export=1
+VVC_EPEL_H_HEADER
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_epel_h8_8_neon_i8mm, export=1
 EPEL_H_HEADER
 1:  ld1 {v4.16b}, [x1], x2
@@ -2003,6 +2014,11 @@ function ff_hevc_put_hevc_epel_h12_8_neon_i8mm, export=1
 ret
 endfunc
 
+function ff_vvc_put_epel_h16_8_neon_i8mm, export=1
+VVC_EPEL_H_HEADER
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_epel_h16_8_neon_i8mm, export=1
 EPEL_H_HEADER
 1:  ld1 {v0.16b, v1.16b}, [x1], x2
@@ -2077,6 +2093,11 @@ function ff_hevc_put_hevc_epel_h24_8_neon_i8mm, export=1
 ret
 endfunc
 
+function ff_vvc_put_epel_h32_8_neon_i8mm, export=1
+VVC_EPEL_H_HEADER
+b   1f
+endfunc
+
 function ff_hevc_put_hevc_epel_h32_8_neon_i8mm, export=1
 EPEL_H_HEADER
 1:  ld1 {v0.16b, v1.16b, v2.16b}, [x1], x2
@@ -2176,11 +2197,8 @@ function ff_hevc_put_hevc_epel_h48_8_neon_i8mm, export=1
 ret
 endfunc
 
-function ff_hevc_put_hevc_epel_h64_8_neon_i8mm, export=1
-EPEL_H_HEADER
-sub x2, x2, #64
-1:  ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x1], #64
-subsw3, w3, #1   // height
+.macro put_epel_h64_8_neon_i8mm
+ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x1], #64
 ext v4.16b, v0.16b, v1.16b, #1
 ext v5.16b, v0.16b, v1.16b, #2
 ext v6.16b, v0.16b, v1.16b, #3
@@ -2243,7 +2261,37 @@ function ff_hevc_put_hevc_epel_h64_8_neon_i8mm, export=1
 xtn2v22.8h, v26.4s
 xtn v23.4h, v23.4s
 xtn2v23.8h, v27.4s
-st4 {v20.8h, v21.8h, v22.8h, v23.8h}, [x0], #64
+st4 {v20.8h, v21.8h, v22.8h, v23.8h}, [x0], x10
+.endm
+
+function ff_vvc_put_epel_h64_8_neon_i8mm, export=1
+VVC_EPEL_H_HEADER
+mov x10, #(VVC_MAX_PB_SIZE * 2 - 64)
+sub x2, x2, #64
+  

[FFmpeg-devel] [PATCH v2 13/14] aarch64/vvc: Add put_epel_hv

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

On Apple M1:

put_chroma_hv_8_4x4_c:   1.7 ( 1.00x)
put_chroma_hv_8_4x4_neon:0.2 ( 7.67x)
put_chroma_hv_8_8x8_c:   5.5 ( 1.00x)
put_chroma_hv_8_8x8_neon:0.5 (11.53x)
put_chroma_hv_8_16x16_c:18.5 ( 1.00x)
put_chroma_hv_8_16x16_neon:  1.5 (12.53x)
put_chroma_hv_8_32x32_c:72.5 ( 1.00x)
put_chroma_hv_8_32x32_neon:  4.7 (15.34x)
put_chroma_hv_8_64x64_c:   274.0 ( 1.00x)
put_chroma_hv_8_64x64_neon: 18.5 (14.83x)
put_chroma_hv_8_128x128_c:1058.7 ( 1.00x)
put_chroma_hv_8_128x128_neon:   75.2 (14.07x)

On Android Pixel 8 Pro:

put_chroma_hv_8_4x4_c:   1.2 ( 1.00x)
put_chroma_hv_8_4x4_neon:0.0 ( 0.00x)
put_chroma_hv_8_4x4_i8mm:0.2 ( 5.00x)
put_chroma_hv_8_8x8_c:   4.0 ( 1.00x)
put_chroma_hv_8_8x8_neon:0.5 ( 8.00x)
put_chroma_hv_8_8x8_i8mm:0.5 ( 8.00x)
put_chroma_hv_8_16x16_c:15.2 ( 1.00x)
put_chroma_hv_8_16x16_neon:  2.5 ( 6.10x)
put_chroma_hv_8_16x16_i8mm:  2.2 ( 6.78x)
put_chroma_hv_8_32x32_c:61.0 ( 1.00x)
put_chroma_hv_8_32x32_neon:  9.8 ( 6.26x)
put_chroma_hv_8_32x32_i8mm:  8.5 ( 7.18x)
put_chroma_hv_8_64x64_c:   229.5 ( 1.00x)
put_chroma_hv_8_64x64_neon: 38.5 ( 5.96x)
put_chroma_hv_8_64x64_i8mm: 34.0 ( 6.75x)
put_chroma_hv_8_128x128_c: 919.8 ( 1.00x)
put_chroma_hv_8_128x128_neon:  154.5 ( 5.95x)
put_chroma_hv_8_128x128_i8mm:  140.0 ( 6.57x)
---
 libavcodec/aarch64/h26x/dsp.h   |   8 ++
 libavcodec/aarch64/h26x/epel_neon.S | 125 
 libavcodec/aarch64/vvc/dsp_init.c   |  14 
 3 files changed, 147 insertions(+)

diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index 90a42d7108..0fefb4d70f 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -297,4 +297,12 @@ NEON8_FNPROTO_PARTIAL_6(qpel_hv, (int16_t *dst,
 const uint8_t *src, ptrdiff_t srcstride, int height,
 const int8_t *hf, const int8_t *vf, int width), _i8mm);
 
+NEON8_FNPROTO_PARTIAL_6(epel_hv, (int16_t *dst,
+const uint8_t *src, ptrdiff_t srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width),);
+
+NEON8_FNPROTO_PARTIAL_6(epel_hv, (int16_t *dst,
+const uint8_t *src, ptrdiff_t srcstride, int height,
+const int8_t *hf, const int8_t *vf, int width), _i8mm);
+
 #endif
diff --git a/libavcodec/aarch64/h26x/epel_neon.S 
b/libavcodec/aarch64/h26x/epel_neon.S
index cad8f2a5f4..e44a448b1f 100644
--- a/libavcodec/aarch64/h26x/epel_neon.S
+++ b/libavcodec/aarch64/h26x/epel_neon.S
@@ -72,6 +72,11 @@ endconst
 sxtlv0.8h, v0.8b
 .endm
 
+.macro vvc_load_epel_filterh freg
+ld1 {v0.8b}, [\freg]
+sxtlv0.8h, v0.8b
+.endm
+
 .macro calc_epelh dst, src0, src1, src2, src3
 smull   \dst\().4s, \src0\().4h, v0.h[0]
 smlal   \dst\().4s, \src1\().4h, v0.h[1]
@@ -2299,10 +2304,16 @@ endfunc
 DISABLE_I8MM
 #endif
 
+function vvc_put_epel_hv4_8_end_neon
+vvc_load_epel_filterh x5
+mov x10, #(VVC_MAX_PB_SIZE * 2)
+b   0f
+endfunc
 
 function hevc_put_hevc_epel_hv4_8_end_neon
 load_epel_filterh x5, x4
 mov x10, #(HEVC_MAX_PB_SIZE * 2)
+0:
 ldr d16, [sp]
 ldr d17, [sp, x10]
 add sp, sp, x10, lsl #1
@@ -2339,9 +2350,16 @@ function hevc_put_hevc_epel_hv6_8_end_neon
 2:  ret
 endfunc
 
+function vvc_put_epel_hv8_8_end_neon
+vvc_load_epel_filterh x5
+mov x10, #(VVC_MAX_PB_SIZE * 2)
+b   0f
+endfunc
+
 function hevc_put_hevc_epel_hv8_8_end_neon
 load_epel_filterh x5, x4
 mov x10, #(HEVC_MAX_PB_SIZE * 2)
+0:
 ldr q16, [sp]
 ldr q17, [sp, x10]
 add sp, sp, x10, lsl #1
@@ -2379,9 +2397,16 @@ function hevc_put_hevc_epel_hv12_8_end_neon
 2:  ret
 endfunc
 
+function vvc_put_epel_hv16_8_end_neon
+vvc_load_epel_filterh x5
+mov x10, #(VVC_MAX_PB_SIZE * 2)
+b   0f
+endfunc
+
 function hevc_put_hevc_epel_hv16_8_end_neon
 load_epel_filterh x5, x4
   

[FFmpeg-devel] [PATCH v2 14/14] aarch64/vvc: Add avg

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

avg_8_2x2_c: 0.2 ( 1.00x)
avg_8_2x2_neon:  0.2 ( 1.00x)
avg_8_4x4_c: 0.2 ( 1.00x)
avg_8_4x4_neon:  0.2 ( 1.00x)
avg_8_8x8_c: 0.9 ( 1.00x)
avg_8_8x8_neon:  0.2 ( 5.29x)
avg_8_16x16_c:   3.7 ( 1.00x)
avg_8_16x16_neon:0.7 ( 5.44x)
avg_8_32x32_c:  14.9 ( 1.00x)
avg_8_32x32_neon:1.7 ( 8.91x)
avg_8_64x64_c:  59.7 ( 1.00x)
avg_8_64x64_neon:6.9 ( 8.62x)
avg_8_128x128_c:   254.7 ( 1.00x)
avg_8_128x128_neon: 26.9 ( 9.46x)
avg_10_2x2_c:0.2 ( 1.00x)
avg_10_2x2_neon: 0.2 ( 1.00x)
avg_10_4x4_c:0.2 ( 1.00x)
avg_10_4x4_neon: 0.2 ( 1.00x)
avg_10_8x8_c:0.9 ( 1.00x)
avg_10_8x8_neon: 0.2 ( 5.29x)
avg_10_16x16_c:  3.4 ( 1.00x)
avg_10_16x16_neon:   0.4 ( 8.06x)
avg_10_32x32_c: 13.9 ( 1.00x)
avg_10_32x32_neon:   1.9 ( 7.23x)
avg_10_64x64_c: 54.2 ( 1.00x)
avg_10_64x64_neon:   8.4 ( 6.43x)
avg_10_128x128_c:  232.4 ( 1.00x)
avg_10_128x128_neon:30.9 ( 7.52x)
avg_12_2x2_c:0.0 ( 0.00x)
avg_12_2x2_neon: 0.2 ( 0.00x)
avg_12_4x4_c:0.4 ( 1.00x)
avg_12_4x4_neon: 0.2 ( 2.43x)
avg_12_8x8_c:0.7 ( 1.00x)
avg_12_8x8_neon: 0.2 ( 3.86x)
avg_12_16x16_c:  3.7 ( 1.00x)
avg_12_16x16_neon:   0.4 ( 8.65x)
avg_12_32x32_c: 13.7 ( 1.00x)
avg_12_32x32_neon:   2.2 ( 6.29x)
avg_12_64x64_c: 53.9 ( 1.00x)
avg_12_64x64_neon:   7.7 ( 7.03x)
avg_12_128x128_c:  270.9 ( 1.00x)
avg_12_128x128_neon:30.4 ( 8.90x)
---
 libavcodec/aarch64/vvc/Makefile   |   1 +
 libavcodec/aarch64/vvc/dsp_init.c |  16 +++
 libavcodec/aarch64/vvc/inter.S| 163 ++
 3 files changed, 180 insertions(+)
 create mode 100644 libavcodec/aarch64/vvc/inter.S

diff --git a/libavcodec/aarch64/vvc/Makefile b/libavcodec/aarch64/vvc/Makefile
index 7ba13a2165..ed80338969 100644
--- a/libavcodec/aarch64/vvc/Makefile
+++ b/libavcodec/aarch64/vvc/Makefile
@@ -3,6 +3,7 @@ clean::
 
 OBJS-$(CONFIG_VVC_DECODER)  += aarch64/vvc/dsp_init.o
 NEON-OBJS-$(CONFIG_VVC_DECODER) += aarch64/vvc/alf.o \
+   aarch64/vvc/inter.o \
aarch64/vvc/sad.o \
aarch64/h26x/epel_neon.o \
aarch64/h26x/qpel_neon.o \
diff --git a/libavcodec/aarch64/vvc/dsp_init.c 
b/libavcodec/aarch64/vvc/dsp_init.c
index 4867491620..ad767d17e2 100644
--- a/libavcodec/aarch64/vvc/dsp_init.c
+++ b/libavcodec/aarch64/vvc/dsp_init.c
@@ -42,6 +42,16 @@
 int ff_vvc_sad_neon(const int16_t *src0, const int16_t *src1, int dx, int dy,
 const int block_w, const int block_h);
 
+void ff_vvc_avg_8_neon(uint8_t *dst, ptrdiff_t dst_stride,
+   const int16_t *src0, const int16_t *src1, int width,
+   int height);
+void ff_vvc_avg_10_neon(uint8_t *dst, ptrdiff_t dst_stride,
+   const int16_t *src0, const int16_t *src1, int width,
+   int height);
+void ff_vvc_avg_12_neon(uint8_t *dst, ptrdiff_t dst_stride,
+const int16_t *src0, const int16_t *src1, int width,
+int height);
+
 void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
 {
 int cpu_flags = av_get_cpu_flags();
@@ -112,6 +122,8 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const 
int bd)
 c->inter.put_uni_w[0][5][0][0] = ff_vvc_put_pel_uni_w_pixels64_8_neon;

[FFmpeg-devel] [PATCH v2 08/14] aarch64/vvc: Add put_qpel_vx

2024-09-11 Thread Zhao Zhili
From: Zhao Zhili 

put_luma_v_8_4x4_c:  1.0 ( 1.00x)
put_luma_v_8_4x4_neon:   0.0 ( 0.00x)
put_luma_v_8_8x8_c:  3.5 ( 1.00x)
put_luma_v_8_8x8_neon:   0.5 ( 7.00x)
put_luma_v_8_16x16_c:   13.8 ( 1.00x)
put_luma_v_8_16x16_neon: 1.2 (11.00x)
put_luma_v_8_32x32_c:   54.2 ( 1.00x)
put_luma_v_8_32x32_neon: 5.0 (10.85x)
put_luma_v_8_64x64_c:  217.5 ( 1.00x)
put_luma_v_8_64x64_neon:18.8 (11.60x)
put_luma_v_8_128x128_c:886.2 ( 1.00x)
put_luma_v_8_128x128_neon:  74.0 (11.98x)
---
 libavcodec/aarch64/h26x/dsp.h   |   8 +++
 libavcodec/aarch64/h26x/qpel_neon.S | 100 
 libavcodec/aarch64/vvc/dsp_init.c   |   7 ++
 3 files changed, 115 insertions(+)

diff --git a/libavcodec/aarch64/h26x/dsp.h b/libavcodec/aarch64/h26x/dsp.h
index 323a253257..881091f39a 100644
--- a/libavcodec/aarch64/h26x/dsp.h
+++ b/libavcodec/aarch64/h26x/dsp.h
@@ -274,4 +274,12 @@ NEON8_FNPROTO_PARTIAL_6(qpel_h, (int16_t * dst,
 const uint8_t *_src, ptrdiff_t _srcstride, int height,
 const int8_t *hf, const int8_t *vf, int width), _i8mm);
 
+void ff_vvc_put_qpel_v4_8_neon(int16_t *dst, const uint8_t *_src,
+   ptrdiff_t _srcstride, int height,
+   const int8_t *hf, const int8_t *vf, int width);
+
+void ff_vvc_put_qpel_v8_8_neon(int16_t *dst, const uint8_t *_src,
+   ptrdiff_t _srcstride, int height,
+   const int8_t *hf, const int8_t *vf, int width);
+
 #endif
diff --git a/libavcodec/aarch64/h26x/qpel_neon.S 
b/libavcodec/aarch64/h26x/qpel_neon.S
index 417d43e365..a6a3b9549d 100644
--- a/libavcodec/aarch64/h26x/qpel_neon.S
+++ b/libavcodec/aarch64/h26x/qpel_neon.S
@@ -86,6 +86,11 @@ endconst
 sxtlv0.8h, v0.8b
 .endm
 
+.macro vvc_load_qpel_filterh freg
+ld1 {v0.8b}, [\freg]
+sxtlv0.8h, v0.8b
+.endm
+
 .macro calc_qpelh dst, src0, src1, src2, src3, src4, src5, src6, src7, op, 
shift=6
 smull   \dst\().4s, \src0\().4h, v0.h[0]
 smlal   \dst\().4s, \src1\().4h, v0.h[1]
@@ -95,11 +100,15 @@ endconst
 smlal   \dst\().4s, \src5\().4h, v0.h[5]
 smlal   \dst\().4s, \src6\().4h, v0.h[6]
 smlal   \dst\().4s, \src7\().4h, v0.h[7]
+.ifc \op, sqxtn
+sqxtn   \dst\().4h, \dst\().4s
+.else
 .ifc \op, sshr
 sshr\dst\().4s, \dst\().4s, \shift
 .else
 \op \dst\().4h, \dst\().4s, \shift
 .endif
+.endif
 .endm
 
 .macro calc_qpelh2 dst, dstt, src0, src1, src2, src3, src4, src5, src6, src7, 
op, shift=6
@@ -111,11 +120,15 @@ endconst
 smlal2  \dstt\().4s, \src5\().8h, v0.h[5]
 smlal2  \dstt\().4s, \src6\().8h, v0.h[6]
 smlal2  \dstt\().4s, \src7\().8h, v0.h[7]
+.ifc \op, sqxtn2
+sqxtn2  \dst\().8h, \dstt\().4s
+.else
 .ifc \op, sshr
 sshr\dst\().4s, \dstt\().4s, \shift
 .else
 \op \dst\().8h, \dstt\().4s, \shift
 .endif
+.endif
 .endm
 
 .macro calc_all
@@ -1000,6 +1013,93 @@ function ff_hevc_put_hevc_qpel_v64_8_neon, export=1
 ret
 endfunc
 
+/* ff_hevc_put_hevc_qpel_vx require filter parameters be
+ * [-, +, -, +, +, -, +, -],
+ * vvc doesn't meet the requirement.
+ */
+function ff_vvc_put_qpel_v4_8_neon, export=1
+vvc_load_qpel_filterh x5
+sub x1, x1, x2, lsl #1
+mov x9, #(VVC_MAX_PB_SIZE * 2)
+sub x1, x1, x2
+ldr s16, [x1]
+ldr s17, [x1, x2]
+add x1, x1, x2, lsl #1
+ldr s18, [x1]
+ldr s19, [x1, x2]
+uxtlv16.8h, v16.8b
+uxtlv17.8h, v17.8b
+add x1, x1, x2, lsl #1
+ldr s20, [x1]
+ldr s21, [x1, x2]
+uxtlv18.8h, v18.8b
+uxtlv19.8h, v19.8b
+add x1, x1, x2, lsl #1
+ldr s22, [x1]
+add x1, x1, x2
+uxtlv20.8h, v20.8b
+uxtlv21.8h, v21.8b
+uxtlv22.8h, v22.8b
+.macro calc tmp, src0, src1, src2, src3, src4, src5, src6, src7
+ld1 {\tmp\().s}[0], [x1], x2
+uxtl\tmp\().8h, \tmp\().8b
+calc_qpelh  v24, \src0, \src1, \src2, \src3, \src4, \src5, \src6, 
\src7, sqxtn
+subsw3, w3, #1
+st1 {v24.4h}, [x0], x9
+.endm
+1:
+calc_all
+.pu

Re: [FFmpeg-devel] [PATCH] avfilter/af_join: pass the correct input layouts to ff_channel_layouts_ref

2024-09-11 Thread Anton Khirnov
Quoting James Almer (2024-09-11 19:40:09)
> Should fix memory leaks show in fate-filter-join and 
> fate-filter-crazychannels.
> 
> Signed-off-by: James Almer 
> ---
>  libavfilter/af_join.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
> index db0320aa70..0ea53248b6 100644
> --- a/libavfilter/af_join.c
> +++ b/libavfilter/af_join.c
> @@ -215,7 +215,7 @@ static int join_query_formats(const AVFilterContext *ctx,
>  
>  for (i = 0; i < ctx->nb_inputs; i++) {
>  layouts = ff_all_channel_layouts();
> -if ((ret = ff_channel_layouts_ref(layouts, 
> &cfg_in[0]->channel_layouts)) < 0)
> +if ((ret = ff_channel_layouts_ref(layouts, 
> &cfg_in[i]->channel_layouts)) < 0)

LGTM

/me facepalms

thanks for the fix

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

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


[FFmpeg-devel] [PATCH] lavfi/af_channelmap: fix channelmap_init error handling

2024-09-11 Thread Marvin Scholz
The channelmap_init function was returning success even on error after
7dc81d33c241b9e176ea85956e8317f29bc9e3c0 due to shadowing of the
outer ret variable.

Fixes CID1619297 Logically dead code
---
 libavfilter/af_channelmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index f5209a10cd..7a99ac7780 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -316,7 +316,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 presence_map = av_calloc(s->nch, sizeof(*presence_map));
 for (i = 0; i < s->nch; i++) {
 const int out_idx = s->map[i].out_channel_idx;
-int ret = check_idx_and_id(ctx, out_idx, s->map[i].out_channel, 
&s->output_layout, "out");
+ret = check_idx_and_id(ctx, out_idx, s->map[i].out_channel, 
&s->output_layout, "out");
 if (ret < 0)
 break;
 if (presence_map[out_idx]) {

base-commit: a15d2fdfd96c0ce711e0be3fe6c2f47b5a39b931
-- 
2.39.3 (Apple Git-146)
___
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] MAINTAINERS: add myself as vf_xfade_vulkan maintainer

2024-09-11 Thread Marvin Scholz
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5b6fbfdc48..036066de84 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -345,6 +345,7 @@ Filters:
   vf_scale.c[2] Michael Niedermayer
   vf_tonemap_opencl.c   Ruiling Song
   vf_yadif.c[2] Michael Niedermayer
+  vf_xfade_vulkan.c [2] Marvin Scholz (CC )
 
 Sources:
   vsrc_mandelbrot.c [2] Michael Niedermayer

base-commit: a15d2fdfd96c0ce711e0be3fe6c2f47b5a39b931
-- 
2.39.3 (Apple Git-146)
___
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/amfenc: Fix AV1 HDR metadata for delayed surfaces

2024-09-11 Thread Dmitrii Ovchinnikov
Thanks for the fix. merged.
___
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 2/4] libavformat/mxf: DNxUncompressed MXF related changes

2024-09-11 Thread Marton Balint



On Wed, 11 Sep 2024, Tomas Härdin wrote:


ons 2024-09-11 klockan 01:08 +0200 skrev martin schitter:



On 10.09.24 15:14, Tomas Härdin wrote:
> > +++ b/libavformat/mxf.c

> > +    { {
> > 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0E,0x04,0x02,0x01,0x02,
> > 0x1E,0x01,0x00 }, 16,  AV_CODEC_ID_DNXUC }, /*
> > DNxUncompressed/SMPTE RDD 50 */
> 
> Are really all 16 bytes significant?


I have to correct myself again:

This Entry in the "PictureEssenceCoding" list of 'mxf.c' should 
according to the specification look like:


+    { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03,0x07
,0x01,0x00 
}, 15,  AV_CODEC_ID_DNXUC }, /* DNxUncompressed/SMPTE RDD 50 */


The significant bit count is set to 15, because we do not support any
of 
the extended fix point format variants.


Ah, didn't know. But this happens often with ULs. One must carefully
read the wrapping spec!


Actually it should match 14 bytes, because byte 14 defines the codec 
being DNXUC. Byte 15 defines the "profile" of the codec (standard format, 
or extended fixed point formats), but from the demuxer's point of view it 
is irrelevant what profiles / codec features ffmpeg's own decoder 
supports. E.g. the user might use the demuxer only and decode the essence 
on its own.


Regards,
Marton






btw. there is an annoying flaw in the ffmpeg mxf parser:

The very common 'fill' boxes, which are used in DNxUncompressed files
to 
align 'pack' boxes on 265 byte boundaries, are not recognized by
ffmpegs 
mxf parser and generate lots of

"Dark key 06.0e.2b.34.01.01.01.02.03.01.02.10.01.00.00.00" warnings.


Patch welcome ;) But surely we already deal with KAG fill? Maybe the UL
for it just has too large a matching length.. But looking at
mxf_metadata_read_table[] and searching for "fill" it appears we don't?

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

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

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

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


Re: [FFmpeg-devel] [PATCH v5 1/4] libavcodec/dnxuc_parser: DNxUncompressed essence parser

2024-09-11 Thread Marton Balint




On Wed, 11 Sep 2024, Martin Schitter wrote:


This time only small corrections...


The order of the patches is wrong. Every point in a series must be 
compilable, and a patch in a series must only depend on earlier patches in 
the series.


So as a first patch you should add codec ID and codec desc, then you can 
add MXF demuxer support, then the parser and the decoder. And when adding 
the parser/decoder, also make the needed changes in the Makefile, not just 
as a separate patch.


Thanks,
Marton



---
libavcodec/dnxuc_parser.c | 124 ++
libavcodec/parsers.c  |   1 +
2 files changed, 125 insertions(+)
create mode 100644 libavcodec/dnxuc_parser.c

diff --git a/libavcodec/dnxuc_parser.c b/libavcodec/dnxuc_parser.c
new file mode 100644
index 000..55d5763
--- /dev/null
+++ b/libavcodec/dnxuc_parser.c
@@ -0,0 +1,124 @@
+/*
+ * Avid DNxUncomressed / SMPTE RDD 50 parser
+ * Copyright (c) 2024 Martin Schitter
+ *
+ * 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
+ */
+
+/*
+ This parser for DNxUncompressed video data is mostly based on
+ reverse engineering of output generated by DaVinci Resolve 19
+ but was later also checked against the SMPTE RDD 50 specification.
+
+ Limitations: Multiple image planes are not supported.
+*/
+
+#include "avcodec.h"
+#include "libavutil/intreadwrite.h"
+
+typedef struct DNxUcParseContext {
+uint32_t fourcc_tag;
+uint32_t width;
+uint32_t height;
+uint32_t nr_bytes;
+} DNxUcParseContext;
+
+/*
+DNxUncompressed frame data comes wrapped in nested boxes of metadata
+(box structure: len + fourcc marker + data):
+
+[0-4]   len of outer essence unit box (typically 37 bytes of header + frame 
data)
+[4-7]   fourcc 'pack'
+
+[8-11]  len of "signal info box" (always 21)
+[12-15] fourcc 'sinf'
+[16-19] frame width / line packing size
+[20-23] frame hight / nr of lines
+[24-27] fourcc pixel format indicator
+[28]frame_layout (0: progressive, 1: interlaced)
+
+[29-32] len of "signal data box" (nr of frame data bytes + 8)
+[33-36] fourcc 'sdat'
+[37-..] frame data
+
+A sequence of 'signal info'+'signal data' box pairs wrapped in
+'icmp'(=image component) boxes can be utilized to compose more
+complex multi plane images.
+This feature is only partially supported in the present implementation.
+We never pick more than the first pair of info and image data enclosed
+in this way.
+*/
+
+static int dnxuc_parse(AVCodecParserContext *s,
+AVCodecContext *avctx,
+const uint8_t **poutbuf, int *poutbuf_size,
+const uint8_t *buf, int buf_size)
+{
+char fourcc_buf[5];
+const int HEADER_SIZE = 37;
+int icmp_offset = 0;
+
+DNxUcParseContext *pc;
+pc = (DNxUcParseContext *) s->priv_data;
+
+if (!buf_size) {
+return 0;
+}
+if (buf_size > 16 && MKTAG('i','c','m','p') == AV_RL32(buf+12)){
+icmp_offset += 8;
+}
+if ( buf_size < 37 + icmp_offset /* check metadata structure expectations 
*/
+|| MKTAG('p','a','c','k') != AV_RL32(buf+4+icmp_offset)
+|| MKTAG('s','i','n','f') != AV_RL32(buf+12+icmp_offset)
+|| MKTAG('s','d','a','t') != AV_RL32(buf+33+icmp_offset)){
+av_log(avctx, AV_LOG_ERROR, "can't read DNxUncompressed 
metadata.\n");
+*poutbuf_size = 0;
+return buf_size;
+}
+
+pc->fourcc_tag = AV_RL32(buf+24+icmp_offset);
+pc->width = AV_RL32(buf+16+icmp_offset);
+pc->height = AV_RL32(buf+20+icmp_offset);
+pc->nr_bytes = AV_RL32(buf+29+icmp_offset) - 8;
+
+if (!avctx->codec_tag) {
+av_fourcc_make_string(fourcc_buf, pc->fourcc_tag);
+av_log(avctx, AV_LOG_INFO, "dnxuc_parser: '%s' %dx%d %dbpp %d\n",
+fourcc_buf,
+pc->width, pc->height,
+(pc->nr_bytes*8)/(pc->width*pc->height),
+pc->nr_bytes);
+avctx->codec_tag = pc->fourcc_tag;
+}
+
+if (pc->nr_bytes > buf_size - HEADER_SIZE + icmp_offset){
+av_log(avctx, AV_LOG_ERROR, "Insufficient size of image essence 
data.\n");
+*poutbuf_size = 0;
+return buf_size;
+}
+
+*poutbuf = buf + HEADER_SIZE + icmp_offset;
+*poutbuf_size = pc->nr_bytes;
+
+return buf_size;
+}
+
+const AVCodecParse

[FFmpeg-devel] [PATCH] configure: fix symbol prefix detection

2024-09-11 Thread Marvin Scholz
The symbol prefix check would incorrectly detect a bogus prefix in 
circumstances where sanitizers
instrument the build, like when configuring with the clang-asan toolchain where 
it would detect the
prefix as __odr_asan_gen_, which is obviously wrong.

To fix this, adjust the prefix detection to only detect a one-character prefix, 
which is the only case
that matters anywhere right now.
---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index d3bd46f382a..4ee513fdc35 100755
--- a/configure
+++ b/configure
@@ -6131,13 +6131,15 @@ enable_weak_pic() {
 enabled pic && enable_weak_pic
 
 test_cc 

[FFmpeg-devel] [PATCH v2] configure: fix symbol prefix detection

2024-09-11 Thread Marvin Scholz
The symbol prefix check would incorrectly detect a bogus prefix in 
circumstances where sanitizers
instrument the build, like when configuring with the clang-asan toolchain where 
it would detect the
prefix as __odr_asan_gen_, which is obviously wrong.

To fix this, adjust the prefix detection to only detect a one-character prefix, 
which is the only case
that matters anywhere right now.
---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index d3bd46f382a..7e84272b74b 100755
--- a/configure
+++ b/configure
@@ -6131,13 +6131,15 @@ enable_weak_pic() {
 enabled pic && enable_weak_pic
 
 test_cc 

Re: [FFmpeg-devel] [PATCH] libavformat/mxfdec.c: Recognize and Ignore MXF fill boxes

2024-09-11 Thread martin schitter



On 11.09.24 10:15, Tomas Härdin wrote:

This could also be done using mxf_metadata_read_table[] using a simple
stub callback.

Alternatively we could add some logic to the parsing loop that skips
KLVs whose key's entry in the table have read == NULL. The loop
termination condition would need to either change to checking if the
first byte of the UL is zero, or maybe just use FF_ARRAY_ELEMS. This
way we could add more keys to skip in the future. This is also possible
with the stub approach


Yes -- it could be done in many ways!

I have indeed chosen a very simple and trivial solution. experts, which 
are more familiar with this code base, may very likely see and even 
prefer more complex alternatives. But the trivial variant, which is very 
easy graspable by any developer, also has its value as long as it does 
its job.


But an elementary feature like 'fill' should be simply supported by any 
MXF demuxer in a suitable manner, otherwise it's IMHO a grave defect.



Also IS_KLV_KEY() seems wrong. It should skip the version byte I think
(I'd have to double-check the spec). That doesn't need to hold up this
patch of course


IS_KLV_KEY is just used as a trivial memcmp paraphrase for static keys:

 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))


> That doesn't need to hold up this patch of course

If you don't see any further objections, please just merge the patch and 
finally solve this issue by this trivial solution till someone actually 
contributes a better alternative.


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

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


Re: [FFmpeg-devel] [PATCH v2] avfilter/vf_libvmaf: Add metadata propagation support

2024-09-11 Thread Yigithan Yigit
Hi,

Thanks for feedbacks!


> On Aug 30, 2024, at 7:44 AM, Kyle Swanson  wrote:
> 
> Hi,
> 
> 
> On Mon, Aug 26, 2024 at 10:51=E2=80=AFAM Yigithan Yigit
> mailto:yigithanyigitde...@gmail.com>> wrote:
>> 
>> ---
>> libavfilter/vf_libvmaf.c | 328 ++-
>> 1 file changed, 326 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
>> index f655092b20..e6707aff53 100644
>> --- a/libavfilter/vf_libvmaf.c
>> +++ b/libavfilter/vf_libvmaf.c
>> @@ -27,8 +27,11 @@
>> #include "config_components.h"
>> 
>> #include 
>> +#include 
>> 
>> #include "libavutil/avstring.h"
>> +#include "libavutil/dict.h"
>> +#include "libavutil/frame.h"
>> #include "libavutil/mem.h"
>> #include "libavutil/opt.h"
>> #include "libavutil/pixdesc.h"
>> @@ -46,6 +49,31 @@
>> #include "libavutil/hwcontext_cuda_internal.h"
>> #endif
>> 
>> +#define VMAF_VERSION_INT_VER(major, minor, patch) \
>> +((major) * 1 + (minor) * 100 + (patch))
>> +
>> +#if VMAF_VERSION_INT_VER(VMAF_API_VERSION_MAJOR, VMAF_API_VERSION_MINOR,=
> VMAF_API_VERSION_PATCH) > VMAF_VERSION_INT_VER(3, 0, 0)
>> +#define CONFIG_LIBVMAF_METADATA_ENABLED 1
>> +#else
>> +#define CONFIG_LIBVMAF_METADATA_ENABLED 0
>> +#endif
> 
> You should be able to check pkg_cfg and set this
> CONFIG_LIBVMAF_METADATA_ENABLED define from the configure script.

Fixed locally.

> 
>> +
>> +#if CONFIG_LIBVMAF_METADATA_ENABLED
>> +#include 
>> +
>> +typedef struct FrameList {
>> +AVFrame *frame;
>> +unsigned frame_number;
>> +unsigned propagated_handlers_cnt;
>> +struct FrameList *next;
>> +} FrameList;
>> +
>> +typedef struct CallbackStruct {
>> +struct LIBVMAFContext *s;
>> +FrameList *frame_list;
>> +} CallbackStruct;
>> +#endif
>> +
>> typedef struct LIBVMAFContext {
>> const AVClass *class;
>> FFFrameSync fs;
>> @@ -56,8 +84,19 @@ typedef struct LIBVMAFContext {
>> int n_subsample;
>> char *model_cfg;
>> char *feature_cfg;
>> +#if CONFIG_LIBVMAF_METADATA_ENABLED
>> +char *metadata_feature_cfg;
>> +struct {
>> +VmafMetadataConfiguration *metadata_cfgs;
>> +unsigned metadata_cfg_cnt;
>> +} metadata_cfg_list;
>> +CallbackStruct *cb;
>> +atomic_uint outlink_eof;
>> +atomic_uint eof_frame;
>> +#endif
>> VmafContext *vmaf;
>> VmafModel **model;
>> +int flushed;
>> unsigned model_cnt;
>> unsigned frame_cnt;
>> unsigned bpc;
>> @@ -77,6 +116,9 @@ static const AVOption libvmaf_options[] =3D {
>> {"n_subsample", "Set interval for frame subsampling used when comput=
> ing vmaf.", OFFSET(n_subsample), AV_OPT_TYPE_INT, {.i64=3D1}, 1, UINT_M=
> AX, FLAGS},
>> {"model",  "Set the model to be used for computing vmaf.",  =
>OFFSET(model_cfg), AV_OPT_TYPE_STRING, {.str=3D"version=3Dv=
> maf_v0.6.1"}, 0, 1, FLAGS},
>> {"feature",  "Set the feature to be used for computing vmaf.",  =
>OFFSET(feature_cfg), AV_OPT_TYPE_STRING, {.str=3DNULL}, 0, =
> 1, FLAGS},
>> +#if CONFIG_LIBVMAF_METADATA_ENABLED
>> +{"metadata_handler",  "Set the feature to be propagated as metadata.=
> ",  OFFSET(metadata_feature_cfg), AV_OPT_TYPE_STRING, {.str=3D"=
> name=3Dvmaf"}, 0, 1, FLAGS},
> 
> Would be better to make this option a bool. When true, propagate all
> registered features and models. You can read the names during init,
> they should be available inside `parse_models()` and
> `parse_features()`.

Yes, but we design vmaf api for individual metrics. Using an identifier doesn’t 
work unfortunately and as far as I know there is no API for accessing 
individual features with identifiers. However I made a small patch for that. 
That brings more generic use case for the API.

https://github.com/Netflix/vmaf/pull/1387

> 
>> +#endif
>> { NULL }
>> };
>> 
>> @@ -105,6 +147,123 @@ static enum VmafPixelFormat pix_fmt_map(enum AVPixe=
> lFormat av_pix_fmt)
>> }
>> }
>> 
>> +#if CONFIG_LIBVMAF_METADATA_ENABLED
>> +static int add_to_frame_list(FrameList **head, AVFrame *frame, unsigned =
> frame_number)
>> +{
>> +FrameList *new_frame =3D av_malloc(sizeof(FrameList));
>> +if (!new_frame)
>> +return AVERROR(ENOMEM);
>> +
>> +new_frame->frame =3D frame;
>> +new_frame->frame_number =3D frame_number;
>> +new_frame->propagated_handlers_cnt =3D 0;
>> +new_frame->next =3D NULL;
>> +
>> +if (*head =3D=3D NULL) {
>> +*head =3D new_frame;
>> +} else {
>> +FrameList *current =3D *head;
>> +while (current->next !=3D NULL) {
>> +current =3D current->next;
>> +}
>> +current->next =3D new_frame;
>> +}
>> +
>> +return 0;
>> +}
>> +
>> +static int remove_from_frame_list(FrameList **frame_list, unsigned frame=
> _number)
>> +{
>> +FrameList *cur =3D *frame_list;
>> +FrameList *prev =3D NULL;
>> +
>> +while (cur) {
>> +if (cur->frame_number =3D=3D frame_number) {
>> +   

[FFmpeg-devel] [PATCH 01/10 v4] avutil/frame: add an LCEVC enhancement data payload side data type

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version

 doc/APIchanges  | 3 +++
 libavutil/frame.c   | 1 +
 libavutil/frame.h   | 6 ++
 libavutil/version.h | 2 +-
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 830a38cd69..5d7b5ab91c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavu 59.37.100 - frame.h
+  Add AV_FRAME_DATA_LCEVC.
+
 2024-09-xx - xx - lavc 61.13.100 - avcodec.h
   Add avcodec_get_supported_config() and enum AVCodecConfig; deprecate
   AVCodec.pix_fmts, AVCodec.sample_fmts, AVCodec.supported_framerates,
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 5cbfc6a48b..2758f90e27 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -46,6 +46,7 @@ static const AVSideDataDescriptor sd_props[] = {
 [AV_FRAME_DATA_DETECTION_BBOXES]= { "Bounding boxes for object 
detection and classification" },
 [AV_FRAME_DATA_DOVI_RPU_BUFFER] = { "Dolby Vision RPU Data" },
 [AV_FRAME_DATA_DOVI_METADATA]   = { "Dolby Vision Metadata" },
+[AV_FRAME_DATA_LCEVC]   = { "LCEVC NAL data" },
 [AV_FRAME_DATA_STEREO3D]= { "Stereo 3D",   
 AV_SIDE_DATA_PROP_GLOBAL },
 [AV_FRAME_DATA_REPLAYGAIN]  = { "AVReplayGain",
 AV_SIDE_DATA_PROP_GLOBAL },
 [AV_FRAME_DATA_DISPLAYMATRIX]   = { "3x3 displaymatrix",   
 AV_SIDE_DATA_PROP_GLOBAL },
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 60bb966f8b..5e0d8ae648 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -228,6 +228,12 @@ enum AVFrameSideDataType {
  * encoding.
  */
 AV_FRAME_DATA_VIDEO_HINT,
+
+/**
+ * Raw LCEVC payload data, as a uint8_t array, with NAL emulation
+ * bytes intact.
+ */
+AV_FRAME_DATA_LCEVC,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/version.h b/libavutil/version.h
index 25a6f5531b..7900379c12 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  36
+#define LIBAVUTIL_VERSION_MINOR  37
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.46.0

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

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


[FFmpeg-devel] [PATCH 02/10 v4] avcodec/h2645_sei: export raw LCEVC metadata

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version.

 libavcodec/h2645_sei.c | 34 ++
 libavcodec/h2645_sei.h |  5 +
 libavcodec/itut35.h|  2 ++
 3 files changed, 41 insertions(+)

diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 7c83747cd0..c46a563308 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -99,6 +99,20 @@ static int 
decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid
 }
 #endif
 
+static int decode_registered_user_data_lcevc(HEVCSEILCEVC *s,
+ GetByteContext *gb)
+{
+int size = bytestream2_get_bytes_left(gb);
+
+av_buffer_unref(&s->info);
+s->info = av_buffer_alloc(size);
+if (!s->info)
+return AVERROR(ENOMEM);
+
+bytestream2_get_bufferu(gb, s->info->data, size);
+return 0;
+}
+
 static int decode_registered_user_data_afd(H2645SEIAFD *h, GetByteContext *gb)
 {
 int flag;
@@ -142,6 +156,7 @@ static int decode_registered_user_data(H2645SEI *h, 
GetByteContext *gb,
 }
 
 if (country_code != ITU_T_T35_COUNTRY_CODE_US &&
+country_code != ITU_T_T35_COUNTRY_CODE_UK &&
 country_code != ITU_T_T35_COUNTRY_CODE_CN) {
 av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message 
(country_code = %d)\n",
@@ -173,6 +188,13 @@ static int decode_registered_user_data(H2645SEI *h, 
GetByteContext *gb,
 }
 break;
 }
+case ITU_T_T35_PROVIDER_CODE_LCEVC: {
+if (bytestream2_get_bytes_left(gb) < 2)
+return AVERROR_INVALIDDATA;
+
+bytestream2_skipu(gb, 1); // user_data_type_code
+return decode_registered_user_data_lcevc(&h->lcevc, gb);
+}
 #if CONFIG_HEVC_SEI
 case ITU_T_T35_PROVIDER_CODE_CUVA: {
 const uint16_t cuva_provider_oriented_code = 0x0005;
@@ -501,6 +523,10 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI 
*src)
 av_buffer_unref(&dst->unregistered.buf_ref[i]);
 dst->unregistered.nb_buf_ref = 0;
 
+ret = av_buffer_replace(&dst->lcevc.info, src->lcevc.info);
+if (ret < 0)
+return ret;
+
 if (src->unregistered.nb_buf_ref) {
 ret = av_reallocp_array(&dst->unregistered.buf_ref,
 src->unregistered.nb_buf_ref,
@@ -778,6 +804,13 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
 }
 }
 
+if (sei->lcevc.info) {
+HEVCSEILCEVC *lcevc = &sei->lcevc;
+ret = ff_frame_new_side_data_from_buf(avctx, frame, 
AV_FRAME_DATA_LCEVC, &lcevc->info);
+if (ret < 0)
+return ret;
+}
+
 if (sei->film_grain_characteristics.present) {
 H2645SEIFilmGrainCharacteristics *fgc = 
&sei->film_grain_characteristics;
 AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(frame);
@@ -875,6 +908,7 @@ void ff_h2645_sei_reset(H2645SEI *s)
 av_freep(&s->unregistered.buf_ref);
 av_buffer_unref(&s->dynamic_hdr_plus.info);
 av_buffer_unref(&s->dynamic_hdr_vivid.info);
+av_buffer_unref(&s->lcevc.info);
 
 s->ambient_viewing_environment.present = 0;
 s->mastering_display.present = 0;
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 488dbcad7e..598f78b585 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -50,6 +50,10 @@ typedef struct HEVCSEIDynamicHDRVivid {
 AVBufferRef *info;
 } HEVCSEIDynamicHDRVivid;
 
+typedef struct HEVCSEILCEVC {
+AVBufferRef *info;
+} HEVCSEILCEVC;
+
 typedef struct H2645SEIUnregistered {
 AVBufferRef **buf_ref;
 unsigned nb_buf_ref;
@@ -126,6 +130,7 @@ typedef struct H2645SEI {
 H2645SEIAFD afd;
 HEVCSEIDynamicHDRPlus  dynamic_hdr_plus; //< HEVC only
 HEVCSEIDynamicHDRVivid dynamic_hdr_vivid;//< HEVC only
+HEVCSEILCEVC lcevc;
 H2645SEIUnregistered unregistered;
 H2645SEIFramePacking frame_packing;
 H2645SEIDisplayOrientation display_orientation;
diff --git a/libavcodec/itut35.h b/libavcodec/itut35.h
index ffa7024981..a75ef37929 100644
--- a/libavcodec/itut35.h
+++ b/libavcodec/itut35.h
@@ -20,11 +20,13 @@
 #define AVCODEC_ITUT35_H
 
 #define ITU_T_T35_COUNTRY_CODE_CN 0x26
+#define ITU_T_T35_COUNTRY_CODE_UK 0xB4
 #define ITU_T_T35_COUNTRY_CODE_US 0xB5
 
 #define ITU_T_T35_PROVIDER_CODE_ATSC  0x31
 #define ITU_T_T35_PROVIDER_CODE_CUVA  0x04
 #define ITU_T_T35_PROVIDER_CODE_DOLBY 0x3B
+#define ITU_T_T35_PROVIDER_CODE_LCEVC 0x50
 #define ITU_T_T35_PROVIDER_CODE_SMTPE 0x3C
 
 #endif /* AVCODEC_ITUT35_H */
-- 
2.46.0

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

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


[FFmpeg-devel] [PATCH 03/10] avcodec: add an export_side_data flag to export picture enhancement layers

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges | 3 +++
 libavcodec/avcodec.h   | 6 ++
 libavcodec/options_table.h | 1 +
 libavcodec/version.h   | 2 +-
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5d7b5ab91c..f937be87cc 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavc 61.14.100 - avcodec.h
+  Adds a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data.
+
 2024-09-08 - xx - lavu 59.37.100 - frame.h
   Add AV_FRAME_DATA_LCEVC.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 376e130f7d..77ca8dee1f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -419,6 +419,12 @@ typedef struct RcOverride{
  */
 #define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)
 
+/**
+ * Decoding only.
+ * Do not apply picture enhancement layers, export them instead.
+ */
+#define AV_CODEC_EXPORT_DATA_ENHANCEMENTS (1 << 4)
+
 /**
  * The decoder will keep a reference to the frame and may reuse it later.
  */
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 33f1bce887..47da41b0ad 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -93,6 +93,7 @@ static const AVOption avcodec_options[] = {
 {"prft", "export Producer Reference Time through packet side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, 
A|V|S|E, .unit = "export_side_data"},
 {"venc_params", "export video encoding parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS}, INT_MIN, 
INT_MAX, V|D, .unit = "export_side_data"},
 {"film_grain", "export film grain parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_FILM_GRAIN}, INT_MIN, INT_MAX, 
V|D, .unit = "export_side_data"},
+{"enhancements", "export picture enhancement metadata through frame side 
data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_ENHANCEMENTS}, 
INT_MIN, INT_MAX, V|D, .unit = "export_side_data"},
 {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 
INT_MAX},
 {"g", "set the group of picture (GOP) size", OFFSET(gop_size), 
AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
 {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), 
AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 755c90bbc1..7531c6c42a 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  13
+#define LIBAVCODEC_VERSION_MINOR  14
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.46.0

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

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


[FFmpeg-devel] [PATCH 04/10 v2] avcodec/codec_id: add an LCEVC codec id for raw LCEVC data

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version.

 doc/APIchanges  | 3 +++
 libavcodec/codec_desc.c | 6 ++
 libavcodec/codec_id.h   | 1 +
 3 files changed, 10 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index f937be87cc..9d7480e5ee 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavc 61.14.100 - avcodec.h
+  Add AV_CODEC_ID_LCEVC.
+
 2024-09-08 - xx - lavc 61.14.100 - avcodec.h
   Adds a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data.
 
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index a28ef68061..03dea5751a 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3696,6 +3696,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .name  = "smpte_2038",
 .long_name = NULL_IF_CONFIG_SMALL("SMPTE ST 2038 VANC in MPEG-2 TS"),
 },
+{
+.id= AV_CODEC_ID_LCEVC,
+.type  = AVMEDIA_TYPE_DATA,
+.name  = "lcevc",
+.long_name = NULL_IF_CONFIG_SMALL("LCEVC (Low Complexity Enhancement 
Video Coding) / MPEG-5 LCEVC / MPEG-5 part 2"),
+},
 {
 .id= AV_CODEC_ID_MPEG2TS,
 .type  = AVMEDIA_TYPE_DATA,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 0ab1e34a61..0a8d3bed1e 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -589,6 +589,7 @@ enum AVCodecID {
 AV_CODEC_ID_TIMED_ID3,
 AV_CODEC_ID_BIN_DATA,
 AV_CODEC_ID_SMPTE_2038,
+AV_CODEC_ID_LCEVC,
 
 
 AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like 
AV_CODEC_ID_NONE) but lavf should attempt to identify it
-- 
2.46.0

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

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


[FFmpeg-devel] [PATCH 05/10 v2] avformat: add an LCEVC stream group

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
Added some documentation and an index field to easily find the enhancement
layer stream.

 doc/APIchanges |  5 +
 libavformat/avformat.c |  5 +
 libavformat/avformat.h | 27 +++
 libavformat/dump.c | 27 +++
 libavformat/options.c  | 29 -
 libavformat/version.h  |  4 ++--
 6 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 9d7480e5ee..c151041da1 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,11 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavf 61.5.100 - avformat.h
+  Add AVStreamGroupLCEVC
+  Add AV_STREAM_GROUP_PARAMS_LCEVC
+  Add AVStreamGroup.params.lcevc
+
 2024-09-08 - xx - lavc 61.14.100 - avcodec.h
   Add AV_CODEC_ID_LCEVC.
 
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index b4f20502fb..06dcde0565 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -104,6 +104,10 @@ void ff_free_stream_group(AVStreamGroup **pstg)
 av_freep(&stg->params.tile_grid->offsets);
 av_freep(&stg->params.tile_grid);
 break;
+case AV_STREAM_GROUP_PARAMS_LCEVC:
+av_opt_free(stg->params.lcevc);
+av_freep(&stg->params.lcevc);
+break;
 default:
 break;
 }
@@ -327,6 +331,7 @@ const char *avformat_stream_group_name(enum 
AVStreamGroupParamsType type)
 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT:return "IAMF Audio 
Element";
 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: return "IAMF Mix 
Presentation";
 case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid";
+case AV_STREAM_GROUP_PARAMS_LCEVC: return "LCEVC 
(Split video and enhancement)";
 }
 return NULL;
 }
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4a3fb00529..56c1c80289 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1084,11 +1084,37 @@ typedef struct AVStreamGroupTileGrid {
 int height;
 } AVStreamGroupTileGrid;
 
+/**
+ * AVStreamGroupLCEVC is meant to define the relation between video streams
+ * and a data stream containing LCEVC enhancement layer NALUs.
+ *
+ * No more than one stream of @ref AVCodecParameters.codec_type "codec_type"
+ * AVMEDIA_TYPE_DATA shall be present, and it must be of
+ * @ref AVCodecParameters.codec_id "codec_id" AV_CODEC_ID_LCEVC.
+ */
+typedef struct AVStreamGroupLCEVC {
+const AVClass *av_class;
+
+/**
+ * Index of the LCEVC data stream in AVStreamGroup.
+ */
+unsigned int lcevc_index;
+/**
+ * Width of the final stream for presentation.
+ */
+int width;
+/**
+ * Height of the final image for presentation.
+ */
+int height;
+} AVStreamGroupLCEVC;
+
 enum AVStreamGroupParamsType {
 AV_STREAM_GROUP_PARAMS_NONE,
 AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,
 AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,
 AV_STREAM_GROUP_PARAMS_TILE_GRID,
+AV_STREAM_GROUP_PARAMS_LCEVC,
 };
 
 struct AVIAMFAudioElement;
@@ -1130,6 +1156,7 @@ typedef struct AVStreamGroup {
 struct AVIAMFAudioElement *iamf_audio_element;
 struct AVIAMFMixPresentation *iamf_mix_presentation;
 struct AVStreamGroupTileGrid *tile_grid;
+struct AVStreamGroupLCEVC *lcevc;
 } params;
 
 /**
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 5e1f367742..f20c2c4953 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -789,6 +789,33 @@ static void dump_stream_group(const AVFormatContext *ic, 
uint8_t *printed,
 }
 break;
 }
+case AV_STREAM_GROUP_PARAMS_LCEVC: {
+const AVStreamGroupLCEVC *lcevc = stg->params.lcevc;
+AVCodecContext *avctx = avcodec_alloc_context3(NULL);
+const char *ptr = NULL;
+av_log(NULL, AV_LOG_INFO, " LCEVC:");
+if (avctx && stg->nb_streams && !avcodec_parameters_to_context(avctx, 
stg->streams[0]->codecpar)) {
+avctx->width  = lcevc->width;
+avctx->height = lcevc->height;
+avctx->coded_width  = lcevc->width;
+avctx->coded_height = lcevc->height;
+if (ic->dump_separator)
+av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
+buf[0] = 0;
+avcodec_string(buf, sizeof(buf), avctx, is_output);
+ptr = av_stristr(buf, " ");
+}
+avcodec_free_context(&avctx);
+if (ptr)
+av_log(NULL, AV_LOG_INFO, "%s", ptr);
+av_log(NULL, AV_LOG_INFO, "\n");
+for (int i = 0; i < stg->nb_streams; i++) {
+const AVStream *st = stg->streams[i];
+dump_stream_format(ic, st->index, i, index, is_output, 
AV_LOG_VERBOSE);
+printed[st->index] = 1;
+}
+break;
+}
 default:
 break;
 }

[FFmpeg-devel] [PATCH 06/10 v2] avformat/mov: support for LCEVC tracks

2024-09-11 Thread James Almer
Co-authored-by: V-Nova Team 
Signed-off-by: James Almer 
---
 libavformat/isom.h  |  3 ++
 libavformat/isom_tags.c |  2 +
 libavformat/mov.c   | 86 +
 3 files changed, 91 insertions(+)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 15e9466e41..4723397048 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -212,6 +212,8 @@ typedef struct MOVStreamContext {
 unsigned drefs_count;
 MOVDref *drefs;
 int dref_id;
+unsigned tref_flags;
+int tref_id;
 int timecode_track;
 int width;///< tkhd width
 int height;   ///< tkhd height
@@ -408,6 +410,7 @@ void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
 #define MOV_SAMPLE_DEPENDENCY_YES 0x1
 #define MOV_SAMPLE_DEPENDENCY_NO  0x2
 
+#define MOV_TREF_FLAG_ENHANCEMENT 0x1
 
 #define TAG_IS_AVCI(tag)\
 ((tag) == MKTAG('a', 'i', '5', 'p') ||  \
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index 058f0f2a59..5dd72d570e 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -290,6 +290,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 
 { AV_CODEC_ID_CFHD, MKTAG('C', 'F', 'H', 'D') },
 
+{ AV_CODEC_ID_LCEVC, MKTAG('l', 'v', 'c', '1') }, /* LCEVC raw payload */
+
 { AV_CODEC_ID_NONE, 0 },
 };
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d57c4f150b..e42f40e212 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2434,6 +2434,30 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_sbas(MOVContext* c, AVIOContext* pb, MOVAtom atom)
+{
+AVStream* st;
+MOVStreamContext* sc;
+
+if (c->fc->nb_streams < 1)
+return 0;
+
+/* For SBAS this should be fine - though beware if someone implements a
+ * tref atom processor that doesn't drop down to default then this may
+ * be lost. */
+if (atom.size > 4) {
+av_log(c->fc, AV_LOG_ERROR, "Only a single tref of type sbas is 
supported\n");
+return AVERROR_PATCHWELCOME;
+}
+
+st = c->fc->streams[c->fc->nb_streams - 1];
+sc = st->priv_data;
+sc->tref_id = avio_rb32(pb);
+sc->tref_flags |= MOV_TREF_FLAG_ENHANCEMENT;
+
+return 0;
+}
+
 /**
  * An strf atom is a BITMAPINFOHEADER struct. This struct is 40 bytes itself,
  * but can have extradata appended at the end after the 40 bytes belonging
@@ -4995,6 +5019,8 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
 sc->ffindex = st->index;
 c->trak_index = st->index;
+sc->tref_flags = 0;
+sc->tref_id = -1;
 sc->refcount = 1;
 
 if ((ret = mov_read_default(c, pb, atom)) < 0)
@@ -9052,6 +9078,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('a','v','c','C'), mov_read_glbl },
 { MKTAG('p','a','s','p'), mov_read_pasp },
 { MKTAG('c','l','a','p'), mov_read_clap },
+{ MKTAG('s','b','a','s'), mov_read_sbas },
 { MKTAG('s','i','d','x'), mov_read_sidx },
 { MKTAG('s','t','b','l'), mov_read_default },
 { MKTAG('s','t','c','o'), mov_read_stco },
@@ -9132,6 +9159,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('i','i','n','f'), mov_read_iinf },
 { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box 
*/
 { MKTAG('l','h','v','C'), mov_read_lhvc },
+{ MKTAG('l','v','c','C'), mov_read_glbl },
 #if CONFIG_IAMFDEC
 { MKTAG('i','a','c','b'), mov_read_iacb },
 #endif
@@ -10029,6 +10057,21 @@ static int mov_parse_tiles(AVFormatContext *s)
 return 0;
 }
 
+static AVStream *mov_find_reference_track(AVFormatContext *s, AVStream *st,
+  int first_index)
+{
+MOVStreamContext *sc = st->priv_data;
+
+if (sc->tref_id < 0)
+return NULL;
+
+for (int i = first_index; i < s->nb_streams; i++)
+if (s->streams[i]->id == sc->tref_id)
+return s->streams[i];
+
+return NULL;
+}
+
 static int mov_read_header(AVFormatContext *s)
 {
 MOVContext *mov = s->priv_data;
@@ -10154,6 +10197,49 @@ static int mov_read_header(AVFormatContext *s)
 }
 export_orphan_timecode(s);
 
+/* Create LCEVC stream groups. */
+for (i = 0; i < s->nb_streams; i++) {
+AVStreamGroup *stg;
+AVStream *st = s->streams[i];
+AVStream *st_base;
+MOVStreamContext *sc = st->priv_data;
+
+/* Find an enhancement stream. */
+if (!(sc->tref_flags & MOV_TREF_FLAG_ENHANCEMENT))
+continue;
+
+st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+
+stg = avformat_stream_group_create(s, AV_STREAM_GROUP_PARAMS_LCEVC, 
NULL);
+if (!stg)
+return AVERROR(ENOMEM);
+
+stg->id = st->id;
+stg->params.lcevc->width  = st->codecpar->width;
+stg->params.lcevc->height = st->codecpar->height;
+st->codecpar->width = 0;
+st->codecpar-

[FFmpeg-devel] [PATCH 10/10 v4] avcodec: add LCEVC decoding support via LCEVCdec

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
Somewhat improved the glue, making it all internal to decode.c and no longer
touching AVCodecInternal.

I also tried abstracting the delayed processing API in FrameDecodeData by
moving it into a standalone API, but the result was quite a bit of complexity
that may only become worth applying once there's more than just a few hwaccels
and LCEVC using it.

I can send a PoC of it if there's interest.

 configure |   5 +-
 doc/general_contents.texi |  13 ++
 libavcodec/Makefile   |   1 +
 libavcodec/avcodec_internal.h |   4 +
 libavcodec/decode.c   |  65 ++-
 libavcodec/lcevcdec.c | 318 ++
 libavcodec/lcevcdec.h |  42 +
 libavcodec/pthread_frame.c|   3 +
 8 files changed, 449 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/lcevcdec.c
 create mode 100644 libavcodec/lcevcdec.h

diff --git a/configure b/configure
index d3bd46f382..db9638a1ae 100755
--- a/configure
+++ b/configure
@@ -225,6 +225,7 @@ External library support:
   --enable-libcdio enable audio CD grabbing with libcdio [no]
   --enable-libcodec2   enable codec2 en/decoding using libcodec2 [no]
   --enable-libdav1denable AV1 decoding via libdav1d [no]
+  --enable-liblcevc-decenable LCEVC decoding via liblcevc-dec [no]
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
@@ -1914,6 +1915,7 @@ EXTERNAL_LIBRARY_LIST="
 libcelt
 libcodec2
 libdav1d
+liblcevc_dec
 libdc1394
 libflite
 libfontconfig
@@ -4027,7 +4029,7 @@ cws2fws_extralibs="zlib_extralibs"
 
 # libraries, in any order
 avcodec_deps="avutil"
-avcodec_suggest="libm stdatomic"
+avcodec_suggest="libm stdatomic liblcevc_dec"
 avdevice_deps="avformat avcodec avutil"
 avdevice_suggest="libm stdatomic"
 avfilter_deps="avutil"
@@ -6870,6 +6872,7 @@ enabled libcelt   && require libcelt celt/celt.h 
celt_decode -lcelt0 &&
 enabled libcaca   && require_pkg_config libcaca caca caca.h 
caca_create_canvas
 enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create 
-lcodec2
 enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.5.0" 
"dav1d/dav1d.h" dav1d_version
+enabled liblcevc_dec  && require_pkg_config liblcevc_dec "lcevc_dec >= 
2.0.0" "LCEVC/lcevc_dec.h" LCEVC_CreateDecoder
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& check_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index e7cf4f8239..5309db9ba8 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -245,6 +245,19 @@ Go to @url{https://github.com/google/liblc3/} and follow 
the instructions for
 installing the library.
 Then pass @code{--enable-liblc3} to configure to enable it.
 
+@section LCEVCdec
+
+FFmpeg can make use of the liblcevc_dec library for LCEVC enhacement layer
+decoding on supported bitstreams.
+
+Go to @url{https://github.com/v-novaltd/LCEVCdec} and follow the instructions
+for installing the library. Then pass @code{--enable-liblcevc-dec} to 
configure to
+enable it.
+
+@float NOTE
+LCEVCdec is under the BSD-3-Clause-Clear License.
+@end float
+
 @section OpenH264
 
 FFmpeg can make use of the OpenH264 library for H.264 decoding and encoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1d27e554c8..18663e332f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -46,6 +46,7 @@ OBJS = ac3_parser.o   
  \
get_buffer.o \
imgconvert.o \
jni.o\
+   lcevcdec.o   \
mathtables.o \
mediacodec.o \
mpeg12framerate.o\
diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h
index 31745b89b1..f4ec3595c5 100644
--- a/libavcodec/avcodec_internal.h
+++ b/libavcodec/avcodec_internal.h
@@ -68,6 +68,10 @@ void ff_decode_flush_buffers(struct AVCodecContext *avctx);
 void ff_encode_flush_buffers(struct AVCodecContext *avctx);
 
 struct AVCodecInternal *ff_decode_internal_alloc(void);
+void ff_decode_internal_sync(struct AVCodecContext *dst,
+ const struct AVCodecContext *src);
+void ff_decode_internal_uninit(struct AVCodecInternal *avci);
+
 struct AVCodecInternal *ff_encode_in

[FFmpeg-devel] [PATCH 07/10 v2] avcodec/packet: add an LCEVC enhancement data payload side data type

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version.

 doc/APIchanges   | 3 +++
 libavcodec/decode.c  | 1 +
 libavcodec/packet.c  | 1 +
 libavcodec/packet.h  | 6 ++
 libavcodec/version.h | 2 +-
 5 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index c151041da1..b71ceb010c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavc 61.15.100 - packet.h
+  Add AV_PKT_DATA_LCEVC.
+
 2024-09-08 - xx - lavf 61.5.100 - avformat.h
   Add AVStreamGroupLCEVC
   Add AV_STREAM_GROUP_PARAMS_LCEVC
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 27dba8a1f3..18ddd28690 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1434,6 +1434,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext 
*avctx,
 { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, 
AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
 { AV_PKT_DATA_S12M_TIMECODE,  AV_FRAME_DATA_S12M_TIMECODE 
},
 { AV_PKT_DATA_SKIP_SAMPLES,   AV_FRAME_DATA_SKIP_SAMPLES },
+{ AV_PKT_DATA_LCEVC,  AV_FRAME_DATA_LCEVC },
 };
 
 frame->pts  = pkt->pts;
diff --git a/libavcodec/packet.c b/libavcodec/packet.c
index 032f270777..381001fd65 100644
--- a/libavcodec/packet.c
+++ b/libavcodec/packet.c
@@ -306,6 +306,7 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM:   return "IAMF Demixing Info 
Parameter Data";
 case AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM: return "IAMF Recon Gain Info 
Parameter Data";
 case AV_PKT_DATA_FRAME_CROPPING: return "Frame Cropping";
+case AV_PKT_DATA_LCEVC:  return "LCEVC NAL data";
 }
 return NULL;
 }
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 13667ffa36..0a28010542 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -339,6 +339,12 @@ enum AVPacketSideDataType {
  */
 AV_PKT_DATA_FRAME_CROPPING,
 
+/**
+ * Raw LCEVC payload data, as a uint8_t array, with NAL emulation
+ * bytes intact.
+ */
+AV_PKT_DATA_LCEVC,
+
 /**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7531c6c42a..9b8c267529 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  14
+#define LIBAVCODEC_VERSION_MINOR  15
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.46.0

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

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


[FFmpeg-devel] [PATCH 08/10 v2] avcodec/decode: split ProgressFrame allocator into two functions

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version.

 libavcodec/decode.c| 11 +++
 libavcodec/progressframe.h | 16 ++--
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 18ddd28690..e4e92e34e4 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1725,7 +1725,7 @@ static void check_progress_consistency(const 
ProgressFrame *f)
 av_assert1(!f->progress || f->progress->f == f->f);
 }
 
-static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f)
+int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
 {
 FFRefStructPool *pool = avctx->internal->progress_frame_pool;
 
@@ -1743,9 +1743,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, 
ProgressFrame *f, int fl
 {
 int ret;
 
-ret = progress_frame_get(avctx, f);
-if (ret < 0)
-return ret;
+check_progress_consistency(f);
+if (!f->f) {
+ret = ff_progress_frame_alloc(avctx, f);
+if (ret < 0)
+return ret;
+}
 
 ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
 if (ret < 0) {
diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h
index 428a461659..32a345beec 100644
--- a/libavcodec/progressframe.h
+++ b/libavcodec/progressframe.h
@@ -102,12 +102,24 @@ void ff_progress_frame_report(ProgressFrame *f, int 
progress);
 void ff_progress_frame_await(const ProgressFrame *f, int progress);
 
 /**
- * This function sets up the ProgressFrame, i.e. gets ProgressFrame.f
- * and also calls ff_thread_get_buffer() on the frame.
+ * This function allocates ProgressFrame.f
+ * May be called before ff_progress_frame_get_buffer() in the cases where the
+ * AVFrame needs to be accessed before the ff_thread_get_buffer() call in
+ * ff_progress_frame_alloc().
  *
  * @note: This must only be called by codecs with the
  *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
  */
+int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
+
+/**
+ * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f
+ * if needed, and also calls ff_thread_get_buffer() on the frame.
+ *
+ * @note: This must only be called by codecs with the
+ *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
+ * @see ff_progress_frame_alloc
+ */
 int ff_progress_frame_get_buffer(struct AVCodecContext *avctx,
  ProgressFrame *f, int flags);
 
-- 
2.46.0

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

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


[FFmpeg-devel] [PATCH 09/10] avcodec/hevc/refs: ensure LCEVC SEI payloads are exported as frame side data before get_buffer() calls

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/hevc/refs.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index 09d759f936..a75153c462 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -86,6 +86,19 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
 if (frame->f)
 continue;
 
+ret = ff_progress_frame_alloc(s->avctx, &frame->tf);
+if (ret < 0)
+return NULL;
+
+// Add LCEVC SEI metadata here, as it's needed in get_buffer()
+if (s->sei.common.lcevc.info) {
+HEVCSEILCEVC *lcevc = &s->sei.common.lcevc;
+ret = ff_frame_new_side_data_from_buf(s->avctx, frame->tf.f,
+  AV_FRAME_DATA_LCEVC, 
&lcevc->info);
+if (ret < 0)
+goto fail;
+}
+
 ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
AV_GET_BUFFER_FLAG_REF);
 if (ret < 0)
-- 
2.46.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 2/4] libavformat/mxf: DNxUncompressed MXF related changes

2024-09-11 Thread martin schitter



On 11.09.24 21:41, Marton Balint wrote:

I have to correct myself again:

This Entry in the "PictureEssenceCoding" list of 'mxf.c' should 
according to the specification look like:


+
{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03,0x07
,0x01,0x00 }, 15,  AV_CODEC_ID_DNXUC }, /* DNxUncompressed/SMPTE 
RDD 50 */


The significant bit count is set to 15, because we do not support any
of the extended fix point format variants.


Ah, didn't know. But this happens often with ULs. One must carefully
read the wrapping spec!


Actually it should match 14 bytes, because byte 14 defines the codec 
being DNXUC. Byte 15 defines the "profile" of the codec (standard 
format, or extended fixed point formats), but from the demuxer's point 
of view it is irrelevant what profiles / codec features ffmpeg's own 
decoder supports. E.g. the user might use the demuxer only and decode 
the essence on its own.


Yes -- that's indeed a good point!

It also makes the error report for unsupported variants more expressive, 
when we only later deny processing in the decoders main dispatcher based 
on their unique fourcc entry.


I was just irritated by this statement in the standard:

  "A Picture Coding Variant code of 02h shall not be used with any
  standard float 10- or 12-bit component values. All other fourcc codes
  are permitted in either variant."

But this advice will only be of importance during muxing and encoding. 
Demux and decoding implementations can silently ignore these subtleties.


Martin

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

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


Re: [FFmpeg-devel] [PATCH v5 1/4] libavcodec/dnxuc_parser: DNxUncompressed essence parser

2024-09-11 Thread martin schitter




On 11.09.24 21:47, Marton Balint wrote:
The order of the patches is wrong. Every point in a series must be 
compilable, and a patch in a series must only depend on earlier patches 
in the series.


So as a first patch you should add codec ID and codec desc, then you can 
add MXF demuxer support, then the parser and the decoder. And when 
adding the parser/decoder, also make the needed changes in the Makefile, 
not just as a separate patch.


You're right! I already recognized this defect yesterday when I saw the 
patchwork results. :(


I'm really unhappy about all this troubles related to git jugging and 
commit history modification.


On one hand I understand the demand for better reviewable small chunks 
of code -- and really appreciate all enormous valuable feedback here on 
the list! --, but I also see the inevitable drawbacks of this kind of 
workflow.


I'm rather sure, that nobody had recognized, that beside tiny fixes and 
rearrangements of this last patch set one file simple got lost.


I therefore personally prefer to use git version control not so much as 
a utility to create fancy code rearrangements and cosmetic cleanup, but 
as tool to control immutable history and traceable actual code changes, 
which it was made for.


In case of horrible sloppy developers like me, this may even uncover and 
blame questionable professional qualities by just unforgiving document 
all this frequently corrected typos and ugly glitches. But at the end 
it's still a rather useful instrument to correct and overcome exactly 
this kind of flaws.


I'm therefor unsure, if I'll really follow your advice and waste even 
more time on this error-prone code juggling game or just squash all the 
changes again to a reliable working bundle satisfying the final 
dependencies?


These more structured little code components, which will always compile 
if applied one after the other, may indeed look useful and seducing, but 
they would have to work even if applied in reverse order if they really 
represent individual pickable entities.


Well -- I'll see what I can do to make everybody happy...

Martin

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

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


[FFmpeg-devel] [PATCH 1/2] avdevice/decklink_dec: fix leak on error

2024-09-11 Thread Marvin Scholz
In the early return when both draw_bars and signal_loss_action
options are used, the context allocated previously was not
properly freed.

Introduced in 9bcb86b0fa58f1a5a2a8613065349e26abadb329

Fixes CID1619296
---
 libavdevice/decklink_dec.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 54d698bc12a..9a817daf187 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1096,10 +1096,11 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 ctx->signal_loss_action = SIGNAL_LOSS_NONE;
 av_log(avctx, AV_LOG_WARNING, "Setting signal_loss_action to none 
because draw_bars is false\n");
 }
 if (!ctx->draw_bars && ctx->signal_loss_action != SIGNAL_LOSS_NONE) {
 av_log(avctx, AV_LOG_ERROR, "options draw_bars and signal_loss_action 
are mutually exclusive\n");
+av_freep(&ctx);
 return AVERROR(EINVAL);
 }
 ctx->audio_depth = cctx->audio_depth;
 if (cctx->raw_format > 0 && (unsigned int)cctx->raw_format < 
FF_ARRAY_ELEMS(decklink_raw_format_map))
 ctx->raw_format = decklink_raw_format_map[cctx->raw_format];

base-commit: 2e91532ead860651c135bdedd96b6112ff715529
-- 
2.46.0


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

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


[FFmpeg-devel] [PATCH 2/2] avdevice/decklink_dec: fix leaks on error

2024-09-11 Thread Marvin Scholz
In case of errors in this function, the allocated context
was not properly freed in several cases.
---
 libavdevice/decklink_dec.cpp | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 9a817daf187..418701e4e0c 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -1112,32 +1112,35 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 case 8:
 case 16:
 break;
 default:
 av_log(avctx, AV_LOG_ERROR, "Value of channels option must be one 
of 2, 8 or 16\n");
-return AVERROR(EINVAL);
+ret = AVERROR(EINVAL);
+goto error;
 }
 
 /* Check audio bit depth option for valid values: 16 or 32 */
 switch (cctx->audio_depth) {
 case 16:
 case 32:
 break;
 default:
 av_log(avctx, AV_LOG_ERROR, "Value for audio bit depth option must 
be either 16 or 32\n");
-return AVERROR(EINVAL);
+ret = AVERROR(EINVAL);
+goto error;
 }
 
 /* List available devices. */
 if (ctx->list_devices) {
 ff_decklink_list_devices_legacy(avctx, 1, 0);
-return AVERROR_EXIT;
+ret = AVERROR_EXIT;
+goto error;
 }
 
 ret = ff_decklink_init_device(avctx, avctx->url);
 if (ret < 0)
-return ret;
+goto error;
 
 /* Get input device. */
 if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != 
S_OK) {
 av_log(avctx, AV_LOG_ERROR, "Could not open input device from '%s'\n",
avctx->url);
@@ -1334,10 +1337,11 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 
 return 0;
 
 error:
 ff_decklink_cleanup(avctx);
+av_freep(&cctx->ctx);
 return ret;
 }
 
 int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt)
 {
-- 
2.46.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/2] lavu: Move vulkan_spirv to libavutil

2024-09-11 Thread Petro Mozil
Lynne has pushed multiple changes to vulkan usage in FFmpeg,
this is the patch with those changes. Main one is
the move to ff_vk_init.

Signed-off-by: Petro Mozil 
---
 libavcodec/Makefile  |   4 +
 libavcodec/vulkan_glslang.c  |  19 +++
 libavcodec/vulkan_shaderc.c  |  19 +++
 libavcodec/vulkan_spirv.h|  24 +++
 libavfilter/vulkan_glslang.c | 266 +---
 libavfilter/vulkan_shaderc.c | 111 +-
 libavfilter/vulkan_spirv.h   |  23 +--
 libavutil/Makefile   |   4 +
 libavutil/vulkan_glslang.c   | 283 +++
 libavutil/vulkan_shaderc.c   | 128 
 libavutil/vulkan_spirv.h |  45 ++
 11 files changed, 529 insertions(+), 397 deletions(-)
 create mode 100644 libavcodec/vulkan_glslang.c
 create mode 100644 libavcodec/vulkan_shaderc.c
 create mode 100644 libavcodec/vulkan_spirv.h
 create mode 100644 libavutil/vulkan_glslang.c
 create mode 100644 libavutil/vulkan_shaderc.c
 create mode 100644 libavutil/vulkan_spirv.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1d27e554c8..b6243bbc82 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -995,6 +995,10 @@ OBJS-$(CONFIG_VIDEOTOOLBOX)   += videotoolbox.o
 OBJS-$(CONFIG_VDPAU)  += vdpau.o
 OBJS-$(CONFIG_VULKAN) += vulkan.o vulkan_video.o
 
+# vulkan libs
+OBJS-$(CONFIG_LIBGLSLANG) += vulkan_glslang.o
+OBJS-$(CONFIG_LIBSHADERC) += vulkan_shaderc.o
+
 OBJS-$(CONFIG_AV1_D3D11VA_HWACCEL)+= dxva2_av1.o
 OBJS-$(CONFIG_AV1_DXVA2_HWACCEL)  += dxva2_av1.o
 OBJS-$(CONFIG_AV1_D3D12VA_HWACCEL)+= dxva2_av1.o d3d12va_av1.o
diff --git a/libavcodec/vulkan_glslang.c b/libavcodec/vulkan_glslang.c
new file mode 100644
index 00..9aa41567a3
--- /dev/null
+++ b/libavcodec/vulkan_glslang.c
@@ -0,0 +1,19 @@
+/*
+ * 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/vulkan_glslang.c"
diff --git a/libavcodec/vulkan_shaderc.c b/libavcodec/vulkan_shaderc.c
new file mode 100644
index 00..9f60bf4dfd
--- /dev/null
+++ b/libavcodec/vulkan_shaderc.c
@@ -0,0 +1,19 @@
+/*
+ * 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/vulkan_shaderc.c"
diff --git a/libavcodec/vulkan_spirv.h b/libavcodec/vulkan_spirv.h
new file mode 100644
index 00..a8aa10d46a
--- /dev/null
+++ b/libavcodec/vulkan_spirv.h
@@ -0,0 +1,24 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_VULKAN_SPIRV_H
+#define AVCODEC_VULKAN_SPIRV_H
+
+#include "libavutil/vulkan_spirv.h"
+
+#endif
diff --git a/libavfilter/vulkan_glslang.c b/libavfilter/vulkan_glslang.c
index 845a530ee0..9aa41567a3 100644
--- a/libavfilter/vulkan_glslang.c
+++ b/libavfilter/vulkan_glslang.c
@@ -16,268 +16,4 @@
 

Re: [FFmpeg-devel] [PATCH 10/10 v4] avcodec: add LCEVC decoding support via LCEVCdec

2024-09-11 Thread Jean-Baptiste Kempf
On Thu, 12 Sep 2024, at 02:59, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> Somewhat improved the glue, making it all internal to decode.c and no longer
> touching AVCodecInternal.

Seems a ton better, as far as I am concerned.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
https://jbkempf.com/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v6 2/5] libavformat/mxf: Add ULs for DNxUncompressed

2024-09-11 Thread Martin Schitter
---
 libavformat/mxf.c| 1 +
 libavformat/mxfdec.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index a73e40e..b6c1f17 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -61,6 +61,7 @@ const MXFCodecUL ff_mxf_codec_uls[] = {
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x71,0x00,0x00,0x00 
}, 13,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x03,0x02,0x00,0x00 
}, 14,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0E,0x04,0x02,0x01,0x02,0x04,0x01,0x00 
}, 16,  AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD Legacy Avid Media Composer 
MXF */
+{ { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03,0x07,0x01,0x00 
}, 14,  AV_CODEC_ID_DNXUC }, /* DNxUncompressed/SMPTE RDD 50 */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 
}, 14,   AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC Intra */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x31,0x11,0x01 
}, 14,   AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC SPS/PPS in-band */
 { { 
0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x02,0x01 
}, 16,   AV_CODEC_ID_V210 }, /* V210 */
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index ac63c0d..142b3e6 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1597,6 +1597,7 @@ static const MXFCodecUL 
mxf_picture_essence_container_uls[] = {
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 
}, 14,   AV_CODEC_ID_JPEG2000, NULL, 14, J2KWrap },
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x10,0x60,0x01 
}, 14,   AV_CODEC_ID_H264, NULL, 15 }, /* H.264 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x11,0x01,0x00 
}, 14,  AV_CODEC_ID_DNXHD, NULL, 14 }, /* VC-3 */
+{ { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1e,0x01,0x00 
}, 14,  AV_CODEC_ID_DNXUC, NULL, 14 }, /* DNxUncompressed / SMPTE RDD 50 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x12,0x01,0x00 
}, 14,AV_CODEC_ID_VC1, NULL, 14 }, /* VC-1 */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x14,0x01,0x00 
}, 14,   AV_CODEC_ID_TIFF, NULL, 14 }, /* TIFF */
 { { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x15,0x01,0x00 
}, 14,  AV_CODEC_ID_DIRAC, NULL, 14 }, /* VC-2 */
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH v6 1/5] libavcodec/: Add ID and desc entries for DNxUncompressed

2024-09-11 Thread Martin Schitter
Hopefully it's this time more acceptable...

Martin

---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 libavcodec/version.c| 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index a28ef68..27bf105 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1959,6 +1959,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("LEAD MCMP"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_DNXUC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "dnxuc",
+.long_name = NULL_IF_CONFIG_SMALL("DNxUncompressed / SMPTE RDD 50"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 0ab1e34..c8f8072 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -322,6 +322,7 @@ enum AVCodecID {
 AV_CODEC_ID_RTV1,
 AV_CODEC_ID_VMIX,
 AV_CODEC_ID_LEAD,
+AV_CODEC_ID_DNXUC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/version.c b/libavcodec/version.c
index 27f9432..03dd95e 100644
--- a/libavcodec/version.c
+++ b/libavcodec/version.c
@@ -31,7 +31,7 @@ const char av_codec_ffversion[] = "FFmpeg version " 
FFMPEG_VERSION;
 
 unsigned avcodec_version(void)
 {
-static_assert(AV_CODEC_ID_LEAD ==   269 &&
+static_assert(AV_CODEC_ID_DNXUC==   270 &&
   AV_CODEC_ID_PCM_SGA  == 65572 &&
   AV_CODEC_ID_ADPCM_XMD== 69683 &&
   AV_CODEC_ID_CBD2_DPCM== 81928 &&
-- 
2.45.2

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

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


[FFmpeg-devel] [PATCH v6 4/5] libavcodec/dnxucdec: DNxUncompressed decoder

2024-09-11 Thread Martin Schitter
---
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/dnxucdec.c  | 391 +
 3 files changed, 393 insertions(+)
 create mode 100644 libavcodec/dnxucdec.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 55444cb..b2f00af 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -325,6 +325,7 @@ OBJS-$(CONFIG_DFPWM_DECODER)   += dfpwmdec.o
 OBJS-$(CONFIG_DFPWM_ENCODER)   += dfpwmenc.o
 OBJS-$(CONFIG_DNXHD_DECODER)   += dnxhddec.o dnxhddata.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += dnxhdenc.o dnxhddata.o
+OBJS-$(CONFIG_DNXUC_DECODER)   += dnxucdec.o
 OBJS-$(CONFIG_DOLBY_E_DECODER) += dolby_e.o dolby_e_parse.o kbdwin.o
 OBJS-$(CONFIG_DPX_DECODER) += dpx.o
 OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d773ac3..1a3c084 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -93,6 +93,7 @@ extern const FFCodec ff_dfa_decoder;
 extern const FFCodec ff_dirac_decoder;
 extern const FFCodec ff_dnxhd_encoder;
 extern const FFCodec ff_dnxhd_decoder;
+extern const FFCodec ff_dnxuc_decoder;
 extern const FFCodec ff_dpx_encoder;
 extern const FFCodec ff_dpx_decoder;
 extern const FFCodec ff_dsicinvideo_decoder;
diff --git a/libavcodec/dnxucdec.c b/libavcodec/dnxucdec.c
new file mode 100644
index 000..8fffd0a
--- /dev/null
+++ b/libavcodec/dnxucdec.c
@@ -0,0 +1,391 @@
+/*
+ * Avid DNxUncomressed / SMPTE RDD 50 decoder
+ * Copyright (c) 2024 Martin Schitter
+ *
+ * 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
+ */
+
+/*
+ This decoder for DNxUncompressed video data is mostly based on
+ reverse engineering of output generated by DaVinci Resolve 19
+ but was later also checked against the SMPTE RDD 50 specification.
+
+ Not all DNxUncompressed pixel format variants are supported,
+ but at least an elementary base set is already usable:
+
+  - YUV 4:2:2 8/10/12bit
+  - RGB 8/10/12bit/half/float
+
+*/
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "decode.h"
+#include "libavutil/imgutils.h"
+#include "thread.h"
+
+static av_cold int dnxuc_decode_init(AVCodecContext *avctx)
+{
+return 0;
+}
+
+
+static int pass_though(AVCodecContext *avctx, AVFrame *frame, const AVPacket 
*avpkt)
+{
+/* there is no need to copy as the data already match
+ * a known pixel format */
+
+frame->buf[0] = av_buffer_ref(avpkt->buf);
+
+if (!frame->buf[0]) {
+return AVERROR(ENOMEM);
+}
+
+return av_image_fill_arrays(frame->data, frame->linesize, avpkt->data,
+   avctx->pix_fmt, avctx->width, avctx->height, 1);
+}
+
+static int float2planes(AVCodecContext *avctx, AVFrame *frame, const AVPacket 
*pkt)
+{
+int x, y, lw;
+const size_t sof = 4;
+
+lw = frame->width;
+
+for(y = 0; y < frame->height; y++){
+for(x = 0; x < frame->width; x++){
+memcpy(&frame->data[2][sof*(lw*y + x)], &pkt->data[sof* 3*(lw*y + 
x)], sof);
+memcpy(&frame->data[0][sof*(lw*y + x)], &pkt->data[sof*(3*(lw*y + 
x) + 1)], sof);
+memcpy(&frame->data[1][sof*(lw*y + x)], &pkt->data[sof*(3*(lw*y + 
x) + 2)], sof);
+}
+}
+return pkt->size;
+}
+
+static int half_add_alpha(AVCodecContext *avctx, AVFrame *frame, const 
AVPacket *pkt)
+{
+/* ffmpeg doesn't provide RGB half bit depth without alpha channel right 
now
+ * we simply add an opaque alpha layer as workaround */
+
+int x, y, lw;
+const size_t soh = 2;
+const uint16_t opaque = 0x3c00;
+
+lw = frame->width;
+
+for(y = 0; y < frame->height; y++){
+for(x = 0; x < frame->width; x++){
+memcpy(&frame->data[0][soh*4*(lw*y + x)], &pkt->data[soh*3*(lw*y + 
x)], soh*3);
+memcpy(&frame->data[0][soh*(4*(lw*y + x) + 3)], &opaque, soh);
+}
+}
+return pkt->size;
+}
+
+/* DNxUncompressed utilizes a very dense bitpack representation of 10bit and 
12bit pixel data.
+
+Lines of Image data, which look like in their ordinary 8bit counterpart, 
contain the most
+significant upper bits of the pixel data. These sections alternate with 
shorter segments in
+which the complementary least significant bits of

[FFmpeg-devel] [PATCH v6 3/5] libavcodec/dnxuc_parser: DNxUncompressed essence parser

2024-09-11 Thread Martin Schitter
---
 libavcodec/Makefile   |   1 +
 libavcodec/dnxuc_parser.c | 124 ++
 libavcodec/parsers.c  |   1 +
 3 files changed, 126 insertions(+)
 create mode 100644 libavcodec/dnxuc_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1d27e55..55444cb 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1185,6 +1185,7 @@ OBJS-$(CONFIG_DCA_PARSER)  += dca_parser.o 
dca_exss.o dca.o \
   dca_sample_rate_tab.o
 OBJS-$(CONFIG_DIRAC_PARSER)+= dirac_parser.o
 OBJS-$(CONFIG_DNXHD_PARSER)+= dnxhd_parser.o dnxhddata.o
+OBJS-$(CONFIG_DNXUC_PARSER)+= dnxuc_parser.o
 OBJS-$(CONFIG_DOLBY_E_PARSER)  += dolby_e_parser.o dolby_e_parse.o
 OBJS-$(CONFIG_DPX_PARSER)  += dpx_parser.o
 OBJS-$(CONFIG_DVAUDIO_PARSER)  += dvaudio_parser.o
diff --git a/libavcodec/dnxuc_parser.c b/libavcodec/dnxuc_parser.c
new file mode 100644
index 000..55d5763
--- /dev/null
+++ b/libavcodec/dnxuc_parser.c
@@ -0,0 +1,124 @@
+/*
+ * Avid DNxUncomressed / SMPTE RDD 50 parser
+ * Copyright (c) 2024 Martin Schitter
+ *
+ * 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
+ */
+
+/*
+ This parser for DNxUncompressed video data is mostly based on
+ reverse engineering of output generated by DaVinci Resolve 19
+ but was later also checked against the SMPTE RDD 50 specification.
+
+ Limitations: Multiple image planes are not supported.
+*/
+
+#include "avcodec.h"
+#include "libavutil/intreadwrite.h"
+
+typedef struct DNxUcParseContext {
+uint32_t fourcc_tag;
+uint32_t width;
+uint32_t height;
+uint32_t nr_bytes;
+} DNxUcParseContext;
+
+/*
+DNxUncompressed frame data comes wrapped in nested boxes of metadata
+(box structure: len + fourcc marker + data):
+
+[0-4]   len of outer essence unit box (typically 37 bytes of header + frame 
data)
+[4-7]   fourcc 'pack'
+
+[8-11]  len of "signal info box" (always 21)
+[12-15] fourcc 'sinf'
+[16-19] frame width / line packing size
+[20-23] frame hight / nr of lines
+[24-27] fourcc pixel format indicator
+[28]frame_layout (0: progressive, 1: interlaced)
+
+[29-32] len of "signal data box" (nr of frame data bytes + 8)
+[33-36] fourcc 'sdat'
+[37-..] frame data
+
+A sequence of 'signal info'+'signal data' box pairs wrapped in
+'icmp'(=image component) boxes can be utilized to compose more
+complex multi plane images.
+This feature is only partially supported in the present implementation.
+We never pick more than the first pair of info and image data enclosed
+in this way.
+*/
+
+static int dnxuc_parse(AVCodecParserContext *s,
+AVCodecContext *avctx,
+const uint8_t **poutbuf, int *poutbuf_size,
+const uint8_t *buf, int buf_size)
+{
+char fourcc_buf[5];
+const int HEADER_SIZE = 37;
+int icmp_offset = 0;
+
+DNxUcParseContext *pc;
+pc = (DNxUcParseContext *) s->priv_data;
+
+if (!buf_size) {
+return 0;
+}
+if (buf_size > 16 && MKTAG('i','c','m','p') == AV_RL32(buf+12)){
+icmp_offset += 8;
+}
+if ( buf_size < 37 + icmp_offset /* check metadata structure expectations 
*/
+|| MKTAG('p','a','c','k') != AV_RL32(buf+4+icmp_offset)
+|| MKTAG('s','i','n','f') != AV_RL32(buf+12+icmp_offset)
+|| MKTAG('s','d','a','t') != AV_RL32(buf+33+icmp_offset)){
+av_log(avctx, AV_LOG_ERROR, "can't read DNxUncompressed 
metadata.\n");
+*poutbuf_size = 0;
+return buf_size;
+}
+
+pc->fourcc_tag = AV_RL32(buf+24+icmp_offset);
+pc->width = AV_RL32(buf+16+icmp_offset);
+pc->height = AV_RL32(buf+20+icmp_offset);
+pc->nr_bytes = AV_RL32(buf+29+icmp_offset) - 8;
+
+if (!avctx->codec_tag) {
+av_fourcc_make_string(fourcc_buf, pc->fourcc_tag);
+av_log(avctx, AV_LOG_INFO, "dnxuc_parser: '%s' %dx%d %dbpp %d\n",
+fourcc_buf,
+pc->width, pc->height,
+(pc->nr_bytes*8)/(pc->width*pc->height),
+pc->nr_bytes);
+avctx->codec_tag = pc->fourcc_tag;
+}
+
+if (pc->nr_bytes > buf_size - HEADER_SIZE + icmp_offset){
+av_log(avctx, AV_LOG_ERROR, "Insufficient size of image essence 
da

[FFmpeg-devel] [PATCH v6 5/5] doc: DNxUncompressed Changelog and doc entries

2024-09-11 Thread Martin Schitter
---
 Changelog | 1 +
 doc/general_contents.texi | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Changelog b/Changelog
index 7237648..0464bee 100644
--- a/Changelog
+++ b/Changelog
@@ -20,6 +20,7 @@ version :
 - Intel QSV-accelerated VVC decoding
 - MediaCodec AAC/AMR-NB/AMR-WB/MP3 decoding
 - YUV colorspace negotiation for codecs and filters, obsoleting YUVJ
+- DNxUncompressed (SMPTE RDD 50) decoder
 
 
 version 7.0:
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index e7cf4f8..bb13857 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -619,6 +619,7 @@ library:
 @item raw DFPWM @tab X @tab X
 @item raw Dirac @tab X @tab X
 @item raw DNxHD @tab X @tab X
+@item raw DNxUncompressed   @tab   @tab X
 @item raw DTS   @tab X @tab X
 @item raw DTS-HD@tab   @tab X
 @item raw E-AC-3@tab X @tab X
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [PATCH v2] configure: fix symbol prefix detection

2024-09-11 Thread Martin Storsjö

On Wed, 11 Sep 2024, Marvin Scholz wrote:


The symbol prefix check would incorrectly detect a bogus prefix in 
circumstances where sanitizers
instrument the build, like when configuring with the clang-asan toolchain where 
it would detect the
prefix as __odr_asan_gen_, which is obviously wrong.

To fix this, adjust the prefix detection to only detect a one-character prefix, 
which is the only case
that matters anywhere right now.
---
configure | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index d3bd46f382a..7e84272b74b 100755
--- a/configure
+++ b/configure
@@ -6131,13 +6131,15 @@ enable_weak_pic() {
enabled pic && enable_weak_pic

test_cc <

Since we're checking for ff_extern$ in the substr match, would it be 
safest to include the $ in the initial ff_extern match as well? So if 
there's a _ff_extern$foo symbol listed first, that won't be matched?


// Martin

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

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