Re: [FFmpeg-devel] [PATCH v22 02/10] avcodec/evc_parser: Added parser implementation for EVC format

2023-05-29 Thread Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff Engineer/Samsung Electronics



> -Original Message-
> From: ffmpeg-devel  On Behalf Of James
> Almer
> Sent: piątek, 19 maja 2023 17:24
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v22 02/10] avcodec/evc_parser: Added
> parser implementation for EVC format
> 
> On 5/19/2023 7:31 AM, Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff
> Engineer/Samsung Electronics wrote:
> >
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel  On Behalf Of
> >> James Almer
> >> Sent: środa, 10 maja 2023 22:21
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCH v22 02/10] avcodec/evc_parser:
> >> Added parser implementation for EVC format
> >>
> >> On 4/27/2023 9:02 AM, Dawid Kozinski wrote:
> >>> - Added constants definitions for EVC parser
> >>> - Provided NAL units parsing following ISO_IEC_23094-1
> >>> - EVC parser registration
> >>>
> >>> Signed-off-by: Dawid Kozinski 
> >>> ---
> >>>libavcodec/Makefile |1 +
> >>>libavcodec/evc.h|  155 
> >>>libavcodec/evc_parser.c | 1497
> >> +++
> >>>libavcodec/parsers.c|1 +
> >>>4 files changed, 1654 insertions(+)
> >>>create mode 100644 libavcodec/evc.h
> >>>create mode 100644 libavcodec/evc_parser.c
> >>
> >> There seems to have been a regression in this version compared to v20.
> >> Try to compile with the libxevd decoder disabled and open a raw file
> >> (not
> > mp4).
> >>
> >> Whereas with v20 i was getting
> >>
> >>> Input #0, evc, from 'akiyo_cif.evc':
> >>>Duration: N/A, bitrate: N/A
> >>>Stream #0:0: Video: evc (Baseline), none, 352x288, 25 fps, 25
> >>> tbr, 1200k tbn
> >>
> >> I'm now getting
> >>
> >>> Input #0, evc, from 'akiyo_cif.evc':
> >>>Duration: N/A, bitrate: N/A
> >>>Stream #0:0: Video: evc (Baseline), none, 555902582x0, 25 fps, 25
> >>> tbr, 1200k tbn
> >>
> >> It seems that the problem showed up because you moved the parameter
> >> sets
> > to
> >> stack to skip allocating them, and you no longer check if they exist
> >> or
> > were
> >> parsed by looking at slice_pic_parameter_set_id and such.
> >>
> >> That aside, i looked at the EVC spec and noticed that the "raw"
> >> format in
> > Annex-
> >> B is unlike that of H.26{4,5,6}: There's no start code, and instead
> > there's a NAL
> >> size prefix, which sounds like the isobmff way of encapsulating NALUs.
> >> I also noticed that the syntax for nal_unit() contains an
> >> emulation_prevention_three_byte element, but there's no explanation
> >> for it
> > in
> >> the semantics section. Its existence in H.26* is to prevent parsers
> >> from misinterpreting a sequence of two or more zeroes as a potential
> >> start
> > code, but
> >> that's clearly not the case here, so why is it defined and present at all?
> >>
> >> What this means is that the parser can't be made to assemble an AU.
> >> If you
> > feed
> >> it data starting from the middle of a NAL, it will not be able to
> >> sync to
> > the start
> >> of the next NAL because all it looks for is a four byte size value
> >> and
> > will accept
> >> the very first four bytes its fed as one.
> >> Since i doubt the spec can be changed at this point to amend this
> > oversight, the
> >> AU assembling will have to occur in the evc demuxer, much like we do
> >> with
> > AV1
> >> (both raw obu and Annex-B formats as defined in the corresponding
> >> spec),
> > and
> >> the parser be limited to parse fully assembled NALs with
> > parse_nal_units().
> >
> > According to your last EVC review:
> > We have re-implemented the EVC demuxer to assemble Access Units (AUs)
> > and pass them further, while the EVC parser is limited to parsing
> > complete NAL units provided in consecutive AUs.
> >
> > However, before we create a new patchset, we would like to discuss
> > some things because we believe this solution is not optimal.
> >
> > According to the EVC documentation, "Each access unit contains a set
> > of VCL NAL units that together compose a primary coded picture."
> > This means that to find the boundaries of an AU, we need to identify
> > all the NAL units that contain data for a single encoded picture.
> > In our case, to determine whether the next VCL NAL unit contains data
> > for the same picture as the previous VCL NAL unit or for a different
> > encoded picture, we need information contained in the NAL units. We
> > need to extract certain data from NAL units like SPS and PPS, as well
> > as from the Slice Headers of VCL NAL units.
> > In other words, this implies that parsing NAL units is required for
> > this purpose.
> >
> > It may not be as extensive parsing as in the EVC parser, but still,
> > there is a significant amount of parsing involved, which adds some overhead.
> > Another question is whether the demuxer is the appropriate place for
> > parsing NAL units? I guess it's not.
> >
> > Perhaps it would be better if the demuxer prepared complete NAL units
> > instead of complete AUs. The EVC parser would then receive co

[FFmpeg-devel] [PATCH] lavfi/vf_libplacebo: require v5.278 for importing

2023-05-29 Thread Niklas Haas
From: Niklas Haas 

Importing Vulkan device on older versions no longer works due to the
lavu vulkan API changes (specifically, the switch to planar textures by
default). Additionally, importing on versions that don't suppirt
lock/unlock_queue is unsafe with the advent of the threaded vulkan
hwaccel. As a plus, saves us some annoying #ifdef boilerplate.

I will raise the minimum vf_libplacebo version globally on the next
stable release of libplacebo, and remove all of these checks.
---
 libavfilter/vf_libplacebo.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 2b8dac09b06..0a849f86762 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -544,23 +544,15 @@ fail:
 return err;
 }
 
-#if PL_API_VER >= 201
-# if PL_API_VER >= 278
+#if PL_API_VER >= 278
 static void lock_queue(void *priv, uint32_t qf, uint32_t qidx)
-# else
-static void lock_queue(void *priv, int qf, int qidx)
-# endif
 {
 AVHWDeviceContext *avhwctx = priv;
 const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
 hwctx->lock_queue(avhwctx, qf, qidx);
 }
 
-# if PL_API_VER >= 278
 static void unlock_queue(void *priv, uint32_t qf, uint32_t qidx)
-# else
-static void unlock_queue(void *priv, int qf, int qidx)
-# endif
 {
 AVHWDeviceContext *avhwctx = priv;
 const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
@@ -576,6 +568,7 @@ static int init_vulkan(AVFilterContext *avctx, const 
AVVulkanDeviceContext *hwct
 size_t buf_len;
 
 if (hwctx) {
+#if PL_API_VER >= 278
 /* Import libavfilter vulkan context into libplacebo */
 s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params(
 .instance   = hwctx->inst,
@@ -585,11 +578,9 @@ static int init_vulkan(AVFilterContext *avctx, const 
AVVulkanDeviceContext *hwct
 .extensions = hwctx->enabled_dev_extensions,
 .num_extensions = hwctx->nb_enabled_dev_extensions,
 .features   = &hwctx->device_features,
-#if PL_API_VER >= 201
 .lock_queue = lock_queue,
 .unlock_queue   = unlock_queue,
 .queue_ctx  = avctx->hw_device_ctx->data,
-#endif
 .queue_graphics = {
 .index = hwctx->queue_family_index,
 .count = hwctx->nb_graphics_queues,
@@ -605,6 +596,13 @@ static int init_vulkan(AVFilterContext *avctx, const 
AVVulkanDeviceContext *hwct
 /* This is the highest version created by hwcontext_vulkan.c */
 .max_api_version = VK_API_VERSION_1_3,
 ));
+#else
+av_log(s, AV_LOG_ERROR, "libplacebo version %s too old to import "
+   "Vulkan device, remove it or upgrade libplacebo to >= 5.278\n",
+   PL_VERSION);
+err = AVERROR_EXTERNAL;
+goto fail;
+#endif
 } else {
 s->vulkan = pl_vulkan_create(s->log, pl_vulkan_params(
 .queue_count = 0, /* enable all queues for parallelization */
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH] avformat/rtcenc: Add WHIP muxer support for subsecond latency streaming

2023-05-29 Thread Steven Liu
Co-authored-by: winlin 
Co-authored-by: yangrtc 
Co-authored-by: cloudwebrtc 
Co-authored-by: Haibo Chen <495810...@qq.com>
Signed-off-by: Steven Liu 
---
 configure|1 +
 doc/muxers.texi  |   50 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/http.c   |6 +
 libavformat/http.h   |2 +
 libavformat/rtcenc.c | 2208 ++
 7 files changed, 2269 insertions(+)
 create mode 100644 libavformat/rtcenc.c

diff --git a/configure b/configure
index 495493aa0e..526ddc0bd6 100755
--- a/configure
+++ b/configure
@@ -3483,6 +3483,7 @@ ogg_demuxer_select="dirac_parse"
 ogv_muxer_select="ogg_muxer"
 opus_muxer_select="ogg_muxer"
 psp_muxer_select="mov_muxer"
+rtc_muxer_deps_any="openssl"
 rtp_demuxer_select="sdp_demuxer"
 rtp_mpegts_muxer_select="mpegts_muxer rtp_muxer"
 rtpdec_select="asf_demuxer mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol 
srtp"
diff --git a/doc/muxers.texi b/doc/muxers.texi
index 31fca17dd6..00052f51b4 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1333,6 +1333,56 @@ Set custom HTTP headers, can override built in default 
headers. Applicable only
 
 @end table
 
+@anchor{rtc}
+@section rtc
+
+WebRTC (Real-Time Communication) muxer that supports sub-second latency 
streaming according to
+the WHIP (WebRTC-HTTP ingestion protocol) specification.
+
+It uses HTTP as a signaling protocol to exchange SDP capabilities and ICE lite 
candidates. Then,
+it uses STUN binding requests and responses to establish a session over UDP. 
Subsequently, it
+initiates a DTLS handshake to exchange the SRTP encryption keys. Lastly, it 
splits video and
+audio frames into RTP packets and encrypts them using SRTP.
+
+Ensure that you use H.264 without B frames and Opus for the audio codec. For 
example, to convert
+an input file with @command{ffmpeg} to WebRTC:
+@example
+ffmpeg -re -i input.mp4 -acodec libopus -ar 48000 -ac 2 \
+  -vcodec libx264 -profile:v baseline -tune zerolatency -threads 1 -bf 0 \
+  -f rtc "http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream";
+@end example
+
+For this example, we have employed low latency options, resulting in an 
end-to-end latency of
+approximately 150ms.
+
+@subsection Options
+
+This muxer supports the following options:
+
+@table @option
+
+@item ice_arq_max @var{size}
+Set the maximum number of retransmissions for the ICE ARQ mechanism.
+Default value is 5.
+
+@item ice_arq_timeout @var{size}
+Set the start timeout in milliseconds for the ICE ARQ mechanism.
+Default value is 30.
+
+@item dtls_arq_max @var{size}
+Set the maximum number of retransmissions for the DTLS ARQ mechanism.
+Default value is 5.
+
+@item dtls_arq_timeout @var{size}
+Set the start timeout in milliseconds for the DTLS ARQ mechanism.
+Default value is 50.
+
+@item pkt_size @var{size}
+Set the maximum size, in bytes, of RTP packets that send out.
+Default value is 1500.
+
+@end table
+
 @anchor{ico}
 @section ico
 
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f8ad7c6a11..2a76e613b0 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -493,6 +493,7 @@ OBJS-$(CONFIG_RSD_DEMUXER)   += rsd.o
 OBJS-$(CONFIG_RPL_DEMUXER)   += rpl.o
 OBJS-$(CONFIG_RSO_DEMUXER)   += rsodec.o rso.o pcm.o
 OBJS-$(CONFIG_RSO_MUXER) += rsoenc.o rso.o rawenc.o
+OBJS-$(CONFIG_RTC_MUXER) += rtcenc.o avc.o http.o srtp.o
 OBJS-$(CONFIG_RTP_MPEGTS_MUXER)  += rtpenc_mpegts.o
 OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_aac.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index efdb34e29d..56e852e5ea 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -392,6 +392,7 @@ extern const AVInputFormat  ff_rpl_demuxer;
 extern const AVInputFormat  ff_rsd_demuxer;
 extern const AVInputFormat  ff_rso_demuxer;
 extern const FFOutputFormat ff_rso_muxer;
+extern const FFOutputFormat ff_rtc_muxer;
 extern const AVInputFormat  ff_rtp_demuxer;
 extern const FFOutputFormat ff_rtp_muxer;
 extern const FFOutputFormat ff_rtp_mpegts_muxer;
diff --git a/libavformat/http.c b/libavformat/http.c
index 0817aafb5b..6f509656b5 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -530,6 +530,12 @@ int ff_http_averror(int status_code, int default_averror)
 return default_averror;
 }
 
+const char* ff_http_get_new_location(URLContext *h)
+{
+HTTPContext *s = h->priv_data;
+return s->new_location;
+}
+
 static int http_write_reply(URLContext* h, int status_code)
 {
 int ret, body = 0, reply_code, message_len;
diff --git a/libavformat/http.h b/libavformat/http.h
index 5f650ef143..d1b691826b 100644
--- a/libavformat/http.h
+++ b/libavformat/http.h
@@ -62,4 +62,6 @@ int ff_http_do_new_request2(URLContext *h, const char *uri, 
AVDictionary **optio
 
 int ff_http_averror(int status_code, int default_averror);

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/h264_mp4toannexb_bsf: refactor start_code_size handling

2023-05-29 Thread zhilizhao(赵志立)
Ping for the patchset.

> On May 20, 2023, at 00:41, Zhao Zhili  wrote:
> 
> From: Zhao Zhili 
> 
> start_code_size depends on whether PS comes from out-of-band or
> in-band. Make the code more readable.
> ---
> libavcodec/h264_mp4toannexb_bsf.c | 34 ---
> 1 file changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/h264_mp4toannexb_bsf.c 
> b/libavcodec/h264_mp4toannexb_bsf.c
> index d11be455c2..7dce1ae9b6 100644
> --- a/libavcodec/h264_mp4toannexb_bsf.c
> +++ b/libavcodec/h264_mp4toannexb_bsf.c
> @@ -43,10 +43,26 @@ typedef struct H264BSFContext {
> int  extradata_parsed;
> } H264BSFContext;
> 
> +enum PsSource {
> +PS_OUT_OF_BAND = -1,
> +PS_NONE = 0,
> +PS_IN_BAND = 1,
> +};
> +
> static void count_or_copy(uint8_t **out, uint64_t *out_size,
> -  const uint8_t *in, int in_size, int ps, int copy)
> +  const uint8_t *in, int in_size, enum PsSource ps, 
> int copy)
> {
> -uint8_t start_code_size = ps < 0 ? 0 : *out_size == 0 || ps ? 4 : 3;
> +uint8_t start_code_size;
> +
> +if (ps == PS_OUT_OF_BAND)
> +/* start code already present in out-of-band ps data, so don't need 
> to
> + * add it manually again
> + */
> +start_code_size = 0;
> +else if (ps == PS_IN_BAND || *out_size == 0)
> +start_code_size = 4;
> +else
> +start_code_size = 3;
> 
> if (copy) {
> memcpy(*out + start_code_size, in, in_size);
> @@ -202,6 +218,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
> AVPacket *opkt)
> 
> do {
> uint32_t nal_size = 0;
> +enum PsSource ps;
> 
> /* possible overread ok due to padding */
> for (int i = 0; i < s->length_size; i++)
> @@ -230,7 +247,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
> AVPacket *opkt)
> if (!s->sps_size) {
> LOG_ONCE(ctx, AV_LOG_WARNING, "SPS not present in the 
> stream, nor in AVCC, stream may be unreadable\n");
> } else {
> -count_or_copy(&out, &out_size, s->sps, s->sps_size, 
> -1, j);
> +count_or_copy(&out, &out_size, s->sps, s->sps_size, 
> PS_OUT_OF_BAND, j);
> sps_seen = 1;
> }
> }
> @@ -246,19 +263,22 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
> AVPacket *opkt)
> if (new_idr && unit_type == H264_NAL_IDR_SLICE && !sps_seen && 
> !pps_seen) {
> if (ctx->par_out->extradata)
> count_or_copy(&out, &out_size, ctx->par_out->extradata,
> -  ctx->par_out->extradata_size, -1, j);
> +  ctx->par_out->extradata_size, 
> PS_OUT_OF_BAND, j);
> new_idr = 0;
> /* if only SPS has been seen, also insert PPS */
> } else if (new_idr && unit_type == H264_NAL_IDR_SLICE && sps_seen 
> && !pps_seen) {
> if (!s->pps_size) {
> LOG_ONCE(ctx, AV_LOG_WARNING, "PPS not present in the 
> stream, nor in AVCC, stream may be unreadable\n");
> } else {
> -count_or_copy(&out, &out_size, s->pps, s->pps_size, -1, 
> j);
> +count_or_copy(&out, &out_size, s->pps, s->pps_size, 
> PS_OUT_OF_BAND, j);
> }
> }
> 
> -count_or_copy(&out, &out_size, buf, nal_size,
> -  unit_type == H264_NAL_SPS || unit_type == 
> H264_NAL_PPS, j);
> +if (unit_type == H264_NAL_SPS || unit_type == H264_NAL_PPS)
> +ps = PS_IN_BAND;
> +else
> +ps = PS_NONE;
> +count_or_copy(&out, &out_size, buf, nal_size, ps, j);
> if (!new_idr && unit_type == H264_NAL_SLICE) {
> new_idr  = 1;
> sps_seen = 0;
> -- 
> 2.25.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
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] [Internet][PATCH 1/6] avcodec/cbs: add API to discard units by AVDiscard

2023-05-29 Thread zhilizhao(赵志立)
Ping. Any comments on the idea?

> On May 18, 2023, at 05:23, Zhao Zhili  wrote:
> 
> From: Zhao Zhili 
> 
> ---
> libavcodec/cbs.c  | 21 +
> libavcodec/cbs.h  | 17 +
> libavcodec/cbs_internal.h |  6 ++
> 3 files changed, 44 insertions(+)
> 
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 504197e06d..cf5211249b 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -1026,3 +1026,24 @@ int ff_cbs_make_unit_writable(CodedBitstreamContext 
> *ctx,
> av_buffer_unref(&ref);
> return 0;
> }
> +
> +void ff_cbs_discard_units(CodedBitstreamContext *ctx,
> +  CodedBitstreamFragment *frag,
> +  enum AVDiscard skip,
> +  int flags)
> +{
> +if (!ctx->codec->discarded_unit)
> +return;
> +
> +for (int i = frag->nb_units - 1; i >= 0; i--) {
> +if (ctx->codec->discarded_unit(ctx, &frag->units[i], skip)) {
> +// discard all units
> +if (!(flags & DISCARD_FLAG_KEEP_NON_VCL)) {
> +ff_cbs_fragment_free(frag);
> +return;
> +}
> +
> +ff_cbs_delete_unit(frag, i);
> +}
> +}
> +}
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index ee21623dac..b4131db5fe 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -26,6 +26,7 @@
> 
> #include "codec_id.h"
> #include "codec_par.h"
> +#include "defs.h"
> #include "packet.h"
> 
> 
> @@ -432,5 +433,21 @@ int ff_cbs_make_unit_refcounted(CodedBitstreamContext 
> *ctx,
> int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
>   CodedBitstreamUnit *unit);
> 
> +enum CbsDiscardFlags {
> +DISCARD_FLAG_NONE = 0,
> +
> +/**
> + * keep non-vcl units even if the picture has been dropped.
> + */
> +DISCARD_FLAG_KEEP_NON_VCL = 0x01,
> +};
> +
> +/**
> + * Discard units accroding to 'skip'.
> + */
> +void ff_cbs_discard_units(CodedBitstreamContext *ctx,
> +  CodedBitstreamFragment *frag,
> +  enum AVDiscard skip,
> +  int flags);
> 
> #endif /* AVCODEC_CBS_H */
> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
> index e585c77934..077954eee5 100644
> --- a/libavcodec/cbs_internal.h
> +++ b/libavcodec/cbs_internal.h
> @@ -133,6 +133,12 @@ typedef struct CodedBitstreamType {
>   CodedBitstreamUnit *unit,
>   PutBitContext *pbc);
> 
> +// Return 1 when the unit should be dropped according to 'skip',
> +// 0 otherwise.
> +int (*discarded_unit)(CodedBitstreamContext *ctx,
> +  const CodedBitstreamUnit *unit,
> +  enum AVDiscard skip);
> +
> // Read the data from all of frag->units and assemble it into
> // a bitstream for the whole fragment.
> int (*assemble_fragment)(CodedBitstreamContext *ctx,
> -- 
> 2.25.1
> 
> 
> 
> 

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

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


Re: [FFmpeg-devel] [PATCH v23 01/10] avcodec/evc: MPEG-5 EVC codec registration

2023-05-29 Thread James Almer

On 5/26/2023 7:30 AM, Dawid Kozinski wrote:

Added prerequisites that must be met before providing support for the MPEG-5 
EVC codec
- Added new entry to codec IDs list
- Added new entry to the codec descriptor list
- Bumped libavcodec minor version
- Added profiles for EVC codec

Signed-off-by: Dawid Kozinski 
---
  libavcodec/avcodec.h| 3 +++
  libavcodec/codec_desc.c | 8 
  libavcodec/codec_id.h   | 1 +
  libavcodec/profiles.c   | 6 ++
  libavcodec/profiles.h   | 1 +
  libavcodec/version.h| 2 +-
  6 files changed, 20 insertions(+), 1 deletion(-)


I'll apply this to reduce the amount of patches you need to resend.
___
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 v23 02/10] avcodec/evc_parser: Added parser implementation for EVC format

2023-05-29 Thread James Almer

On 5/26/2023 7:31 AM, Dawid Kozinski wrote:

+static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+int next;
+EVCParserContext *ev = s->priv_data;
+ParseContext *pc = &ev->pc;
+
+if (avctx->extradata && !ev->parsed_extradata) {
+decode_extradata(s, avctx, avctx->extradata, avctx->extradata_size);
+ev->parsed_extradata = 1;
+}
+
+if (s->flags & PARSER_FLAG_COMPLETE_FRAMES)
+next = buf_size;
+else {


As the parser no longer has the job to assemble an AU, this code below 
and evc_find_frame_end() can be removed.


And like i said in my last review, you can share the NALU parsing code 
between this parser and the frame_merge bsf, to reduce code duplication, 
as they both reside in libavcodec.
Simply put it in a new file called for example evc_parse.{c,h}. You can 
follow he example from h26* parsers, which define and reuse 
ff_h***_decode_nal_*ps().



+next = evc_find_frame_end(s, buf, buf_size, avctx);
+if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
+*poutbuf  = NULL;
+*poutbuf_size = 0;
+return buf_size;
+}
+}

___
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] fftools/ffmpeg: rework setting sub2video parameters

2023-05-29 Thread Anton Khirnov
Set them in ifilter_parameters_from_dec(), similarly to audio/video
streams. This reduces the extent to which sub2video filters need to be
treated specially.
---
You can also get the updated tree from ffmpeg_sub2video in my repo
---
 fftools/ffmpeg.c|  6 ++---
 fftools/ffmpeg_demux.c  | 21 +++
 fftools/ffmpeg_filter.c | 58 -
 3 files changed, 41 insertions(+), 44 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 4624960c17..e9e60407d2 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -153,9 +153,9 @@ static int sub2video_get_blank_frame(InputStream *ist)
 AVFrame *frame = ist->sub2video.frame;
 
 av_frame_unref(frame);
-ist->sub2video.frame->width  = ist->dec_ctx->width  ? ist->dec_ctx->width  
: ist->sub2video.w;
-ist->sub2video.frame->height = ist->dec_ctx->height ? ist->dec_ctx->height 
: ist->sub2video.h;
-ist->sub2video.frame->format = AV_PIX_FMT_RGB32;
+frame->width  = ist->sub2video.w;
+frame->height = ist->sub2video.h;
+frame->format = AV_PIX_FMT_RGB32;
 if ((ret = av_frame_get_buffer(frame, 0)) < 0)
 return ret;
 memset(frame->data[0], 0, frame->height * frame->linesize[0]);
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 561b4b0002..817ccbbedc 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1228,6 +1228,27 @@ static void add_input_streams(const OptionsContext *o, 
Demuxer *d)
 av_log(ist, AV_LOG_FATAL, "Invalid canvas size: %s.\n", 
canvas_size);
 exit_program(1);
 }
+
+/* Compute the size of the canvas for the subtitles stream.
+   If the subtitles codecpar has set a size, use it. Otherwise use 
the
+   maximum dimensions of the video streams in the same file. */
+ist->sub2video.w = ist->dec_ctx->width;
+ist->sub2video.h = ist->dec_ctx->height;
+if (!(ist->sub2video.w && ist->sub2video.h)) {
+for (int j = 0; j < ic->nb_streams; j++) {
+AVCodecParameters *par1 = ic->streams[j]->codecpar;
+if (par1->codec_type == AVMEDIA_TYPE_VIDEO) {
+ist->sub2video.w = FFMAX(ist->sub2video.w, 
par1->width);
+ist->sub2video.h = FFMAX(ist->sub2video.h, 
par1->height);
+}
+}
+}
+
+if (!(ist->sub2video.w && ist->sub2video.h)) {
+ist->sub2video.w = FFMAX(ist->sub2video.w, 720);
+ist->sub2video.h = FFMAX(ist->sub2video.h, 576);
+}
+
 break;
 }
 case AVMEDIA_TYPE_ATTACHMENT:
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 2a73e3a3e3..4b5ccf50bd 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -458,13 +458,13 @@ static int ifilter_bind_ist(InputFilter *ifilter, 
InputStream *ist)
 InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
 int ret;
 
+ifp->ist = ist;
+ifp->type_src= ist->st->codecpar->codec_type;
+
 ret = ist_filter_add(ist, ifilter, filtergraph_is_simple(ifilter->graph));
 if (ret < 0)
 return ret;
 
-ifp->ist = ist;
-ifp->type_src= ist->st->codecpar->codec_type;
-
 return 0;
 }
 
@@ -1110,38 +1110,6 @@ void check_filter_outputs(void)
 
 static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
 {
-InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
-AVFormatContext *avf = input_files[ist->file_index]->ctx;
-int i, w, h;
-
-/* Compute the size of the canvas for the subtitles stream.
-   If the subtitles codecpar has set a size, use it. Otherwise use the
-   maximum dimensions of the video streams in the same file. */
-w = ifp->width;
-h = ifp->height;
-if (!(w && h)) {
-for (i = 0; i < avf->nb_streams; i++) {
-if (avf->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
-w = FFMAX(w, avf->streams[i]->codecpar->width);
-h = FFMAX(h, avf->streams[i]->codecpar->height);
-}
-}
-if (!(w && h)) {
-w = FFMAX(w, 720);
-h = FFMAX(h, 576);
-}
-av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h);
-}
-ist->sub2video.w = ifp->width  = w;
-ist->sub2video.h = ifp->height = h;
-
-ifp->width  = ist->dec_ctx->width  ? ist->dec_ctx->width  : 
ist->sub2video.w;
-ifp->height = ist->dec_ctx->height ? ist->dec_ctx->height : 
ist->sub2video.h;
-
-/* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
-   palettes for all rectangles are identical or compatible */
-ifp->format = AV_PIX_FMT_RGB32;
-
 ist->sub2video.frame = av_frame_alloc();
 if (!ist->sub2video.frame)
 return AVERROR(ENOMEM);
@@ -1525,7 +1493,7 @@ int ifilter_parameters_from_dec(InputFilter

Re: [FFmpeg-devel] [PATCH] avformat/rtcenc: Add WHIP muxer support for subsecond latency streaming

2023-05-29 Thread Michael Niedermayer
On Mon, May 29, 2023 at 07:50:39PM +0800, Steven Liu wrote:
> Co-authored-by: winlin 
> Co-authored-by: yangrtc 
> Co-authored-by: cloudwebrtc 
> Co-authored-by: Haibo Chen <495810...@qq.com>
> Signed-off-by: Steven Liu 
> ---
>  configure|1 +
>  doc/muxers.texi  |   50 +
>  libavformat/Makefile |1 +
>  libavformat/allformats.c |1 +
>  libavformat/http.c   |6 +
>  libavformat/http.h   |2 +
>  libavformat/rtcenc.c | 2208 ++
>  7 files changed, 2269 insertions(+)
>  create mode 100644 libavformat/rtcenc.c

breaks build:

CC  libavformat/rtcenc.o
libavformat/rtcenc.c:30:2: error: #error "OpenSSL version 1.1.1b or newer is 
required"
 #error "OpenSSL version 1.1.1b or newer is required"
  ^
libavformat/rtcenc.c: In function ‘dtls_context_init’:
libavformat/rtcenc.c:210:34: error: implicit declaration of function 
‘EVP_EC_gen’; did you mean ‘EVP_PBE_get’? 
[-Werror=implicit-function-declaration]
 ctx->dtls_pkey = dtls_pkey = EVP_EC_gen(curve);
  ^~
  EVP_PBE_get
libavformat/rtcenc.c:210:32: warning: assignment makes pointer from integer 
without a cast [-Wint-conversion]
 ctx->dtls_pkey = dtls_pkey = EVP_EC_gen(curve);
^
cc1: some warnings being treated as errors
ffbuild/common.mak:81: recipe for target 'libavformat/rtcenc.o' failed
make: *** [libavformat/rtcenc.o] Error 1

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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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

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


Re: [FFmpeg-devel] [PATCH v23 04/10] avformat/evc_demuxer: Added demuxer to handle reading EVC video files

2023-05-29 Thread James Almer

On 5/26/2023 7:31 AM, Dawid Kozinski wrote:

+static int get_temporal_id(const uint8_t *bits, int bits_size)
+{
+int temporal_id = 0;
+short t = 0;
+
+if (bits_size >= EVC_NALU_HEADER_SIZE) {
+unsigned char *p = (unsigned char *)bits;
+// forbidden_zero_bit
+if ((p[0] & 0x80) != 0)
+return -1;
+
+for (int i = 0; i < EVC_NALU_HEADER_SIZE; i++)
+t = (t << 8) | p[i];


I think this can be replaced with AV_RB16.


+
+temporal_id = (t >> 6) & 0x0007;
+}
+
+return temporal_id;
+}


[...]


+static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size)
+{
+uint32_t nalu_len = 0;
+
+if (bits_size >= EVC_NALU_LENGTH_PREFIX_SIZE) {
+
+int t = 0;
+unsigned char *p = (unsigned char *)bits;
+
+for (int i = 0; i < EVC_NALU_LENGTH_PREFIX_SIZE; i++)
+t = (t << 8) | p[i];


AV_RB32.


+
+nalu_len = t;
+if (nalu_len == 0)   // Invalid bitstream size
+return 0;
+}
+
+return nalu_len;
+}


[...]


+static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
+{
+EVCMergeContext *ctx = bsf->priv_data;
+AVPacket *in = ctx->in;
+
+int free_space = 0;
+size_t  nalu_size = 0;
+uint8_t *nalu = NULL;
+int au_end_found = 0;
+int err;
+
+err = ff_bsf_get_packet_ref(bsf, in);
+if (err < 0)
+return err;
+
+nalu_size = read_nal_unit_length(in->data, EVC_NALU_LENGTH_PREFIX_SIZE);
+if(nalu_size <= 0) {
+av_packet_unref(in);
+return AVERROR_INVALIDDATA;
+}
+
+nalu = in->data + EVC_NALU_LENGTH_PREFIX_SIZE;
+nalu_size = in->size - EVC_NALU_LENGTH_PREFIX_SIZE;
+
+// NAL unit parsing needed to determine if end of AU was found
+err = parse_nal_unit(nalu, nalu_size, bsf);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "NAL Unit parsing error\n");
+av_packet_unref(in);
+
+return err;
+}
+
+au_end_found = end_of_access_unit_found(bsf);
+
+free_space = ctx->au_buffer.capacity - ctx->au_buffer.data_size;
+while( free_space < in->size ) {
+ctx->au_buffer.capacity *= 2;
+free_space = ctx->au_buffer.capacity - ctx->au_buffer.data_size;
+
+if(free_space >= in->size) {
+ctx->au_buffer.data = av_realloc(ctx->au_buffer.data, 
ctx->au_buffer.capacity);
+}
+}
+
+memcpy(ctx->au_buffer.data + ctx->au_buffer.data_size, in->data, in->size);


This is including the Annex-B's nal_unit_lenght value into the assembled 
packet. I assume libxevd expects this? Also, is it defined as part of 
the ISOBMFF encapsulation? Patch 07/10 does not seem to strip it.

___
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 v23 05/10] avcodec/evc_encoder: Provided support for EVC encoder

2023-05-29 Thread James Almer

On 5/26/2023 7:32 AM, Dawid Kozinski wrote:

- Added EVC encoder wrapper
- Changes in project configuration file and libavcodec Makefile
- Added documentation for xeve wrapper

Signed-off-by: Dawid Kozinski
---
  configure |   4 +
  doc/encoders.texi |  69 +
  doc/general_contents.texi |  11 +
  libavcodec/Makefile   |   1 +
  libavcodec/allcodecs.c|   1 +
  libavcodec/libxeve.c  | 616 ++
  6 files changed, 702 insertions(+)
  create mode 100644 libavcodec/libxeve.c


Does libxeve provide a function to retrieve global headers, which you 
can export as extradata? If so, it would be nice to use it, so the muxer 
doesn't need to generate it from the first packet.

___
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] [BUGGY EXAMPLE] doc/examples/transcode: does not work

2023-05-29 Thread Paul B Mahol
It errors on time_base, somehow it becomes 0/1.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute of H.264

2023-05-29 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavformat/hlsenc.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 871afb571b..1e0848ce3d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -355,9 +355,19 @@ static void write_codec_attr(AVStream *st, VariantStream 
*vs)
 
 if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
 uint8_t *data = st->codecpar->extradata;
-if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 && 
(data[4] & 0x1F) == 7) {
+if (data) {
+const uint8_t *p;
+
+if (AV_RB32(data) == 0x01 && (data[4] & 0x1F) == 7)
+p = &data[5];
+else if (AV_RB24(data) == 0x01 && (data[3] & 0x1F) == 7)
+p = &data[4];
+else if (data[0] == 0x01)  /* avcC */
+p = &data[1];
+else
+goto fail;
 snprintf(attr, sizeof(attr),
- "avc1.%02x%02x%02x", data[5], data[6], data[7]);
+ "avc1.%02x%02x%02x", p[0], p[1], p[2]);
 } else {
 goto fail;
 }
-- 
2.25.1

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

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute of H.264

2023-05-29 Thread Anton Khirnov
Quoting Zhao Zhili (2023-05-30 00:16:05)
>Subject: Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute of 
>H.264

"fix bug" commit message are not very useful

-- 
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] avformat/hlsenc: fix CODECS attribute of H.264

2023-05-29 Thread Zhao Zhili

> 在 2023年5月29日,22:46,Anton Khirnov  写道:
> 
> Quoting Zhao Zhili (2023-05-30 00:16:05)
>> Subject: Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute of 
>> H.264
> 
> "fix bug" commit message are not very useful

However, CODECS attribute is a particular detail for HLS. Any suggestions to 
make it more clear and not too verbose?

> 
> -- 
> 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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute of H.264

2023-05-29 Thread Anton Khirnov
Quoting Zhao Zhili (2023-05-29 17:08:50)
> 
> > 在 2023年5月29日,22:46,Anton Khirnov  写道:
> > 
> > Quoting Zhao Zhili (2023-05-30 00:16:05)
> >> Subject: Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute 
> >> of H.264
> > 
> > "fix bug" commit message are not very useful
> 
> However, CODECS attribute is a particular detail for HLS. Any suggestions to 
> make it more clear and not too verbose?

Keep the first line as is, but add a commit message body that says at
least what the problem was. Possibly also how it's being fixed, if it is
not obvious.

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

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


Re: [FFmpeg-devel] [PATCH 1/5] avcodec/h264_mp4toannexb_bsf: refactor start_code_size handling

2023-05-29 Thread myp...@gmail.com
On Fri, May 19, 2023 at 4:41 PM Zhao Zhili  wrote:
>
> From: Zhao Zhili 
>
> start_code_size depends on whether PS comes from out-of-band or
> in-band. Make the code more readable.
> ---
>  libavcodec/h264_mp4toannexb_bsf.c | 34 ---
>  1 file changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/h264_mp4toannexb_bsf.c 
> b/libavcodec/h264_mp4toannexb_bsf.c
> index d11be455c2..7dce1ae9b6 100644
> --- a/libavcodec/h264_mp4toannexb_bsf.c
> +++ b/libavcodec/h264_mp4toannexb_bsf.c
> @@ -43,10 +43,26 @@ typedef struct H264BSFContext {
>  int  extradata_parsed;
>  } H264BSFContext;
>
> +enum PsSource {
> +PS_OUT_OF_BAND = -1,
> +PS_NONE = 0,
> +PS_IN_BAND = 1,
> +};
> +
>  static void count_or_copy(uint8_t **out, uint64_t *out_size,
> -  const uint8_t *in, int in_size, int ps, int copy)
> +  const uint8_t *in, int in_size, enum PsSource ps, 
> int copy)
>  {
> -uint8_t start_code_size = ps < 0 ? 0 : *out_size == 0 || ps ? 4 : 3;
> +uint8_t start_code_size;
> +
> +if (ps == PS_OUT_OF_BAND)
> +/* start code already present in out-of-band ps data, so don't need 
> to
> + * add it manually again
> + */
> +start_code_size = 0;
> +else if (ps == PS_IN_BAND || *out_size == 0)
> +start_code_size = 4;
> +else
> +start_code_size = 3;
I prefer the original style, they are shorter and more concise
>
>  if (copy) {
>  memcpy(*out + start_code_size, in, in_size);
> @@ -202,6 +218,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
> AVPacket *opkt)
>
>  do {
>  uint32_t nal_size = 0;
> +enum PsSource ps;
>
>  /* possible overread ok due to padding */
>  for (int i = 0; i < s->length_size; i++)
> @@ -230,7 +247,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
> AVPacket *opkt)
>  if (!s->sps_size) {
>  LOG_ONCE(ctx, AV_LOG_WARNING, "SPS not present in 
> the stream, nor in AVCC, stream may be unreadable\n");
>  } else {
> -count_or_copy(&out, &out_size, s->sps, s->sps_size, 
> -1, j);
> +count_or_copy(&out, &out_size, s->sps, s->sps_size, 
> PS_OUT_OF_BAND, j);
>  sps_seen = 1;
>  }
>  }
> @@ -246,19 +263,22 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
> AVPacket *opkt)
>  if (new_idr && unit_type == H264_NAL_IDR_SLICE && !sps_seen && 
> !pps_seen) {
>  if (ctx->par_out->extradata)
>  count_or_copy(&out, &out_size, ctx->par_out->extradata,
> -  ctx->par_out->extradata_size, -1, j);
> +  ctx->par_out->extradata_size, 
> PS_OUT_OF_BAND, j);
>  new_idr = 0;
>  /* if only SPS has been seen, also insert PPS */
>  } else if (new_idr && unit_type == H264_NAL_IDR_SLICE && 
> sps_seen && !pps_seen) {
>  if (!s->pps_size) {
>  LOG_ONCE(ctx, AV_LOG_WARNING, "PPS not present in the 
> stream, nor in AVCC, stream may be unreadable\n");
>  } else {
> -count_or_copy(&out, &out_size, s->pps, s->pps_size, -1, 
> j);
> +count_or_copy(&out, &out_size, s->pps, s->pps_size, 
> PS_OUT_OF_BAND, j);
>  }
>  }
>
> -count_or_copy(&out, &out_size, buf, nal_size,
> -  unit_type == H264_NAL_SPS || unit_type == 
> H264_NAL_PPS, j);
> +if (unit_type == H264_NAL_SPS || unit_type == H264_NAL_PPS)
> +ps = PS_IN_BAND;
> +else
> +ps = PS_NONE;
> +count_or_copy(&out, &out_size, buf, nal_size, ps, j);
>  if (!new_idr && unit_type == H264_NAL_SLICE) {
>  new_idr  = 1;
>  sps_seen = 0;
> --
> 2.25.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



-- 
===
Jun zhao/赵军
+++
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2] avformat/imf: clean-up logging * remove log to NULL * remove extraneous logging

2023-05-29 Thread pal
From: Pierre-Anthony Lemieux 

---
 libavformat/imf.h   |   6 +-
 libavformat/imf_cpl.c   | 179 +++-
 libavformat/imfdec.c|   2 +-
 libavformat/tests/imf.c |   4 +-
 4 files changed, 91 insertions(+), 100 deletions(-)

diff --git a/libavformat/imf.h b/libavformat/imf.h
index 70ed007312..ef124bf412 100644
--- a/libavformat/imf.h
+++ b/libavformat/imf.h
@@ -140,6 +140,7 @@ typedef struct FFIMFCPL {
 
 /**
  * Parse an IMF CompositionPlaylist element into the FFIMFCPL data structure.
+ * @param[in] log_ctx Logging context (points to an instance of AVClass). May 
be NULL.
  * @param[in] doc An XML document from which the CPL is read.
  * @param[out] cpl Pointer to a memory area (allocated by the client), where 
the
  *  function writes a pointer to the newly constructed FFIMFCPL structure (or
@@ -147,10 +148,11 @@ typedef struct FFIMFCPL {
  *  the FFIMFCPL structure using ff_imf_cpl_free().
  * @return A non-zero value in case of an error.
  */
-int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl);
+int ff_imf_parse_cpl_from_xml_dom(void *log_ctx, xmlDocPtr doc, FFIMFCPL 
**cpl);
 
 /**
  * Parse an IMF Composition Playlist document into the FFIMFCPL data structure.
+ * @param[in] log_ctx Logging context (points to an instance of AVClass). May 
be NULL.
  * @param[in] in The context from which the CPL is read.
  * @param[out] cpl Pointer to a memory area (allocated by the client), where 
the
  * function writes a pointer to the newly constructed FFIMFCPL structure (or
@@ -158,7 +160,7 @@ int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL 
**cpl);
  * the FFIMFCPL structure using ff_imf_cpl_free().
  * @return A non-zero value in case of an error.
  */
-int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl);
+int ff_imf_parse_cpl(void *log_ctx, AVIOContext *in, FFIMFCPL **cpl);
 
 /**
  * Allocates and initializes an FFIMFCPL data structure.
diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
index a7cf5fa360..fe975c2f0c 100644
--- a/libavformat/imf_cpl.c
+++ b/libavformat/imf_cpl.c
@@ -76,10 +76,8 @@ int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid)
 
 xmlChar *element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
 ret = av_uuid_urn_parse(element_text, uuid);
-if (ret) {
-av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n");
+if (ret)
 ret = AVERROR_INVALIDDATA;
-}
 xmlFree(element_text);
 
 return ret;
@@ -90,10 +88,8 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational 
*rational)
 int ret = 0;
 
 xmlChar *element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
-if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2) {
-av_log(NULL, AV_LOG_ERROR, "Invalid rational number\n");
+if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2)
 ret = AVERROR_INVALIDDATA;
-}
 xmlFree(element_text);
 
 return ret;
@@ -104,10 +100,8 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t 
*number)
 int ret = 0;
 
 xmlChar *element_text = xmlNodeListGetString(element->doc, 
element->xmlChildrenNode, 1);
-if (sscanf(element_text, "%" PRIu32, number) != 1) {
-av_log(NULL, AV_LOG_ERROR, "Invalid unsigned 32-bit integer");
+if (sscanf(element_text, "%" PRIu32, number) != 1)
 ret = AVERROR_INVALIDDATA;
-}
 xmlFree(element_text);
 
 return ret;
@@ -181,10 +175,8 @@ static int fill_content_title(xmlNodePtr cpl_element, 
FFIMFCPL *cpl)
 {
 xmlNodePtr element = NULL;
 
-if (!(element = ff_imf_xml_get_child_element_by_name(cpl_element, 
"ContentTitle"))) {
-av_log(NULL, AV_LOG_ERROR, "ContentTitle element not found in the IMF 
CPL\n");
+if (!(element = ff_imf_xml_get_child_element_by_name(cpl_element, 
"ContentTitle")))
 return AVERROR_INVALIDDATA;
-}
 cpl->content_title_utf8 = xmlNodeListGetString(cpl_element->doc,
element->xmlChildrenNode,
1);
@@ -242,22 +234,15 @@ static int fill_timecode(xmlNodePtr cpl_element, FFIMFCPL 
*cpl)
return 0;
 
 element = ff_imf_xml_get_child_element_by_name(tc_element, 
"TimecodeDropFrame");
-if (!element) {
-av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\
-a TimecodeDropFrame child element\n");
+if (!element)
 return AVERROR_INVALIDDATA;
-}
 
-if (ff_imf_xml_read_boolean(element, &df)) {
-av_log(NULL, AV_LOG_ERROR, "TimecodeDropFrame element is invalid\n");
+if (ff_imf_xml_read_boolean(element, &df))
 return AVERROR_INVALIDDATA;
-}
+
 element = ff_imf_xml_get_child_element_by_name(tc_element, 
"TimecodeStartAddress");
-if (!element) {
-av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\
- 

Re: [FFmpeg-devel] [PATCH] Optimization: support for libx264's mb_info

2023-05-29 Thread Carotti, Elias
Hi Stefano, hi all,
please find the updated patch according to the suggestions. Now it is
possible to specify whether the rectangles refer to the part we want to
hint as P_SKIP or to the rest portion of the frame.
Best,
Elias
 


On Mon, 2023-05-22 at 09:19 +, Carotti, Elias wrote:
> Hi Stefano,
> thanks for checking the patch.
> Please find it attached in the required format.
> Best,
> Elias
> 
> 
> On Mon, 2023-05-22 at 01:17 +0200, Stefano Sabatini wrote:
> > CAUTION: This email originated from outside of the organization. Do
> > not click links or open attachments unless you can confirm the
> > sender
> > and know the content is safe.
> > 
> > 
> > 
> > On date Friday 2023-05-19 10:19:03 +, Carotti, Elias wrote:
> > > 
> > > Hi again,
> > > I am sending this patch again (I had missed a check for NULL),
> > > could
> > > somebody please have a look at it?
> > > 
> > > It is mainly an optimization when the encoder knows in advance
> > > that
> > > only portions of the whole frame changed and which areas actually
> > > did.
> > > 
> > > The patch allows a user to pass down information to libx264
> > > information
> > > about which parts of a frame changed (with respect to the
> > > preceding
> > > one) to be exploited as a hint for P_SKIP-ing macroblocks which
> > > didn't
> > > change.
> > > This information is encoded in the mb_info field of the
> > > x264_param_t
> > > much like the quant_offsets which are already used for the
> > > AV_FRAME_DATA_REGIONS_OF_INTEREST side information.
> > 
> > Please send a git format-patch (complete with commit log
> > information)
> > to simplify integration.
> > 
> > [...]
> > > diff --git a/libavutil/mb_info.h b/libavutil/mb_info.h
> > > new file mode 100644
> > > index 00..918cf167aa
> > > --- /dev/null
> > > +++ b/libavutil/mb_info.h
> > > @@ -0,0 +1,46 @@
> > [...]
> > > +#ifndef AVUTIL_MB_INFO_H
> > > +#define AVUTIL_MB_INFO_H
> > > +
> > > +#include 
> > > +#include 
> > > +#include "libavutil/avassert.h"
> > > +#include "libavutil/frame.h"
> > > +
> > 
> > > +typedef struct _AVMBInfoRect {
> > 
> > nit: strip the _ before the struct name
> > 
> > > +    uint32_t x, y;
> > > +    uint32_t width, height;
> > > +} AVMBInfoRect;
> > > +
> > > +/**
> > > + * Allocate memory for a vector of AVMBInfoRect in the given
> > > AVFrame
> > > + * {@code frame} as AVFrameSideData of type
> > > AV_FRAME_DATA_MB_INFO.
> > 
> > > + * The side data contains a list of rectangles for the portions
> > > of
> > > the frame
> > > + * which changed from the last encoded one. The rest will be
> > > hinted to be
> > > + * P_SKIP-ped.  Portions of the rects which are not on
> > > macroblock
> > > boundaries
> > > + * are not handled as P_SKIPS.
> > > + */
> > 
> > > +AVMBInfoRect *av_mb_info_create_side_data(AVFrame *frame,
> > > +  AVMBInfoRect *rects,
> > > +  size_t num_rects);
> > 
> > Probably this can be generalized with a flag defining the hinting
> > type
> > (you might want either to specify the constant or non-constant
> > rects),
> > in fact this data is pretty macro-block agnostic.
> > 
> > What about AVVideoHintInfo containing a hint (CONSTANT, VARIANT)
> > and
> > a
> > list of rects?
> > ___
> > 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".
> 
> 
> 
> 
> NICE SRL, viale Monte Grappa 3/5, 20124 Milano, Italia, Registro
> delle Imprese di Milano Monza Brianza Lodi REA n. 2096882, Capitale
> Sociale: 10.329,14 EUR i.v., Cod. Fisc. e P.IVA 01133050052, Societa
> con Socio Unico
> 
> 
> ___
> 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".




NICE SRL, viale Monte Grappa 3/5, 20124 Milano, Italia, Registro delle Imprese 
di Milano Monza Brianza Lodi REA n. 2096882, Capitale Sociale: 10.329,14 EUR 
i.v., Cod. Fisc. e P.IVA 01133050052, Societa con Socio Unico


From 7cb97ee977197e310a932b2d7a53bf5c6e0e Mon Sep 17 00:00:00 2001
From: Elias Carotti 
Date: Wed, 19 Apr 2023 11:49:39 +0200
Subject: [PATCH] Add support for libx264's MB_INFO

libx264's x264_image_properties_t, which is passed to the encoding function,
contains a field to pass down information on the portions of the frame which
changed with respect to the previous one (used for prediction) to mark
unchanged macroblocks P_SKIP.
---
 libavcodec/libx264.c| 81 +
 libavutil/Makefile  |  4 ++
 libavutil/frame.h   | 10 +
 libavutil/video_hint_info.c | 89 +
 libavutil/video_hint_info.h | 87 +

[FFmpeg-devel] [PATCH] lavfi: add noise_vulkan filter

2023-05-29 Thread Lynne
Patch attached

>From 06985c12d8280f1d953a60b6e56b40d85debd849 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Mon, 29 May 2023 20:47:46 +0200
Subject: [PATCH] lavfi: add noise_vulkan filter

---
 configure |  1 +
 doc/filters.texi  | 43 
 libavfilter/Makefile  |  1 +
 libavfilter/allfilters.c  |  1 +
 libavfilter/vsrc_testsrc_vulkan.c | 85 +--
 5 files changed, 126 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 495493aa0e..a4cc214e76 100755
--- a/configure
+++ b/configure
@@ -3707,6 +3707,7 @@ negate_filter_deps="lut_filter"
 nlmeans_opencl_filter_deps="opencl"
 nlmeans_vulkan_filter_deps="vulkan spirv_compiler"
 nnedi_filter_deps="gpl"
+noise_vulkan_filter_deps="vulkan spirv_compiler"
 ocr_filter_deps="libtesseract"
 ocv_filter_deps="libopencv"
 openclsrc_filter_deps="opencl"
diff --git a/doc/filters.texi b/doc/filters.texi
index c47e88e5d4..1f2828e450 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -27469,6 +27469,49 @@ Must be odd number in range [0, 99].
 
 @end table
 
+@section noise_vulkan
+
+Video source that creates a Vulkan frame containing TV static/white noise.
+Useful for benchmarking, or overlaying.
+
+It accepts the following parameters:
+
+@table @option
+@item size
+The size of the output frame. Default value is @code{1920x1080}.
+
+@item rate
+The framerate to output at. Default value is @code{60} frames per second.
+
+@item duration
+The video duration. Default value is @code{-0.01}.
+
+@item sar
+The video signal aspect ratio. Default value is @code{1/1}.
+
+@item format
+The pixel format of the output Vulkan frames. Default value is @code{yuv444p}.
+
+@item out_range
+Set the output YCbCr sample range.
+
+This allows the autodetected value to be overridden as well as allows forcing
+a specific value used for the output and encoder. If not specified, the
+range depends on the pixel format. Possible values:
+
+@table @samp
+@item auto/unknown
+Choose automatically.
+
+@item jpeg/full/pc
+Set full range (0-255 in case of 8-bit luma).
+
+@item mpeg/limited/tv
+Set "MPEG" range (16-235 in case of 8-bit luma).
+@end table
+
+@end table
+
 @section overlay_vulkan
 
 Overlay one video on top of another.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 18935b1616..ff059cfab4 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -395,6 +395,7 @@ OBJS-$(CONFIG_NLMEANS_VULKAN_FILTER) += vf_nlmeans_vulkan.o vulkan.o vul
 OBJS-$(CONFIG_NNEDI_FILTER)  += vf_nnedi.o
 OBJS-$(CONFIG_NOFORMAT_FILTER)   += vf_format.o
 OBJS-$(CONFIG_NOISE_FILTER)  += vf_noise.o
+OBJS-$(CONFIG_NOISE_VULKAN_FILTER)   += vsrc_testsrc_vulkan.o vulkan.o vulkan_filter.o
 OBJS-$(CONFIG_NORMALIZE_FILTER)  += vf_normalize.o
 OBJS-$(CONFIG_NULL_FILTER)   += vf_null.o
 OBJS-$(CONFIG_OCR_FILTER)+= vf_ocr.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f1f781101b..22f59e3ecf 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -550,6 +550,7 @@ extern const AVFilter ff_vsrc_haldclutsrc;
 extern const AVFilter ff_vsrc_life;
 extern const AVFilter ff_vsrc_mandelbrot;
 extern const AVFilter ff_vsrc_mptestsrc;
+extern const AVFilter ff_vsrc_noise_vulkan;
 extern const AVFilter ff_vsrc_nullsrc;
 extern const AVFilter ff_vsrc_openclsrc;
 extern const AVFilter ff_vsrc_pal75bars;
diff --git a/libavfilter/vsrc_testsrc_vulkan.c b/libavfilter/vsrc_testsrc_vulkan.c
index 7eacb57c80..12ac556fff 100644
--- a/libavfilter/vsrc_testsrc_vulkan.c
+++ b/libavfilter/vsrc_testsrc_vulkan.c
@@ -29,10 +29,12 @@
 
 enum TestSrcVulkanMode {
 TESTSRC_COLOR,
+TESTSRC_NOISE,
 };
 
 typedef struct TestSrcVulkanPushData {
 float color_comp[4];
+uint32_t frame_nb;
 } TestSrcVulkanPushData;
 
 typedef struct TestSrcVulkanContext {
@@ -63,6 +65,23 @@ typedef struct TestSrcVulkanContext {
 AVFrame *picref;///< cached reference containing the painted picture
 } TestSrcVulkanContext;
 
+static const char noise_fn[] = {
+C(0, vec4 noise_fn(inout uvec4 s)  )
+C(0, { )
+C(1, s = 1664525u * s + uvec4(1013904223u);)
+C(1, s.x += s.y * s.w; )
+C(1, s.y += s.z * s.x; )
+C(1, s.z += s.x * s.y; )
+C(1, s.w += s.y * s.z; )
+C(1, s ^= s >> 16u;)
+C(1, s.x += s.y * s.w; )
+C(1, s.y += s.z * s.x; )
+C(1, 

[FFmpeg-devel] [PATCH v1 1/3] lavfi/vaapi: Add function to get surface ID from AVFrame

2023-05-29 Thread Fei Wang
Signed-off-by: Fei Wang 
---
 libavfilter/vaapi_vpp.c | 10 ++
 libavfilter/vaapi_vpp.h |  5 +
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index a323dab8b8..10d31977c6 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -518,7 +518,6 @@ int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
  AVFrame *output_frame)
 {
 VAAPIVPPContext *ctx = avctx->priv;
-VASurfaceID input_surface;
 int err;
 
 ctx->input_region = (VARectangle) {
@@ -534,10 +533,8 @@ int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
 output_frame->crop_left   = 0;
 output_frame->crop_right  = 0;
 
-input_surface = (VASurfaceID)(uintptr_t)input_frame->data[3],
-
 *params = (VAProcPipelineParameterBuffer) {
-.surface = input_surface,
+.surface = ff_vaapi_vpp_get_surface_id(input_frame),
 .surface_region  = &ctx->input_region,
 .output_region   = NULL,
 .output_background_color = VAAPI_VPP_BACKGROUND_BLACK,
@@ -623,7 +620,6 @@ int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx,
  AVFrame *output_frame)
 {
 VAAPIVPPContext *ctx = avctx->priv;
-VASurfaceID output_surface;
 VABufferID *params_ids;
 VAStatus vas;
 int err;
@@ -635,10 +631,8 @@ int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx,
 for (int i = 0; i < cout; i++)
 params_ids[i] = VA_INVALID_ID;
 
-output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3];
-
 vas = vaBeginPicture(ctx->hwctx->display,
- ctx->va_context, output_surface);
+ ctx->va_context, 
ff_vaapi_vpp_get_surface_id(output_frame));
 if (vas != VA_STATUS_SUCCESS) {
 av_log(avctx, AV_LOG_ERROR, "Failed to attach new picture: "
"%d (%s).\n", vas, vaErrorStr(vas));
diff --git a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h
index ead07036dc..cc845b854c 100644
--- a/libavfilter/vaapi_vpp.h
+++ b/libavfilter/vaapi_vpp.h
@@ -27,6 +27,11 @@
 
 #include "avfilter.h"
 
+static inline VASurfaceID ff_vaapi_vpp_get_surface_id(const AVFrame *frame)
+{
+return (uintptr_t)frame->data[3];
+}
+
 // ARGB black, for VAProcPipelineParameterBuffer.output_background_color.
 #define VAAPI_VPP_BACKGROUND_BLACK 0xff00
 
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH v1 2/3] lavfi/vaapi: Add some debug message

2023-05-29 Thread Fei Wang
Signed-off-by: Fei Wang 
---
 libavfilter/vaapi_vpp.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index 10d31977c6..4de19564e9 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -554,6 +554,10 @@ int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
 if (err < 0)
 return err;
 
+av_log(avctx, AV_LOG_DEBUG, "Filter frame from surface %#x to %#x.\n",
+   ff_vaapi_vpp_get_surface_id(input_frame),
+   ff_vaapi_vpp_get_surface_id(output_frame));
+
 return 0;
 }
 
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH v1 3/3] lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode

2023-05-29 Thread Fei Wang
Signed-off-by: Fei Wang 
---
 libavfilter/vaapi_vpp.c| 15 ---
 libavfilter/vaapi_vpp.h|  2 ++
 libavfilter/vf_misc_vaapi.c|  9 +
 libavfilter/vf_procamp_vaapi.c | 10 ++
 libavfilter/vf_scale_vaapi.c   |  9 +
 5 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index 4de19564e9..cf2592e068 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -95,6 +95,7 @@ int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
 int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
 {
 AVFilterContext *avctx = outlink->src;
+AVFilterLink   *inlink = avctx->inputs[0];
 VAAPIVPPContext *ctx   = avctx->priv;
 AVVAAPIHWConfig *hwconfig = NULL;
 AVHWFramesConstraints *constraints = NULL;
@@ -111,6 +112,17 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
 if (!ctx->output_height)
 ctx->output_height = avctx->inputs[0]->h;
 
+outlink->w = ctx->output_width;
+outlink->h = ctx->output_height;
+
+if (ctx->passthrough) {
+if (inlink->hw_frames_ctx)
+outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
+av_log(ctx, AV_LOG_VERBOSE, "Using VAAPI filter passthrough mode.\n");
+
+return 0;
+}
+
 av_assert0(ctx->input_frames);
 ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);
 if (!ctx->device_ref) {
@@ -214,9 +226,6 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
 return AVERROR(EIO);
 }
 
-outlink->w = ctx->output_width;
-outlink->h = ctx->output_height;
-
 if (ctx->build_filter_params) {
 err = ctx->build_filter_params(avctx);
 if (err < 0)
diff --git a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h
index cc845b854c..6764ab0c39 100644
--- a/libavfilter/vaapi_vpp.h
+++ b/libavfilter/vaapi_vpp.h
@@ -56,6 +56,8 @@ typedef struct VAAPIVPPContext {
 VABufferID filter_buffers[VAProcFilterCount];
 intnb_filter_buffers;
 
+int passthrough;
+
 int (*build_filter_params)(AVFilterContext *avctx);
 
 void (*pipeline_uninit)(AVFilterContext *avctx);
diff --git a/libavfilter/vf_misc_vaapi.c b/libavfilter/vf_misc_vaapi.c
index db3e69679a..0a4c174ab9 100644
--- a/libavfilter/vf_misc_vaapi.c
+++ b/libavfilter/vf_misc_vaapi.c
@@ -131,6 +131,9 @@ static int misc_vaapi_filter_frame(AVFilterLink *inlink, 
AVFrame *input_frame)
av_get_pix_fmt_name(input_frame->format),
input_frame->width, input_frame->height, input_frame->pts);
 
+if (vpp_ctx->passthrough)
+return ff_filter_frame(outlink, input_frame);
+
 if (vpp_ctx->va_context == VA_INVALID_ID)
 return AVERROR(EINVAL);
 
@@ -176,11 +179,14 @@ fail:
 static av_cold int denoise_vaapi_init(AVFilterContext *avctx)
 {
 VAAPIVPPContext *vpp_ctx = avctx->priv;
+DenoiseVAAPIContext *ctx = avctx->priv;
 
 ff_vaapi_vpp_ctx_init(avctx);
 vpp_ctx->pipeline_uninit = ff_vaapi_vpp_pipeline_uninit;
 vpp_ctx->build_filter_params = denoise_vaapi_build_filter_params;
 vpp_ctx->output_format   = AV_PIX_FMT_NONE;
+if (!ctx->denoise)
+vpp_ctx->passthrough = 1;
 
 return 0;
 }
@@ -188,11 +194,14 @@ static av_cold int denoise_vaapi_init(AVFilterContext 
*avctx)
 static av_cold int sharpness_vaapi_init(AVFilterContext *avctx)
 {
 VAAPIVPPContext *vpp_ctx = avctx->priv;
+SharpnessVAAPIContext *ctx = avctx->priv;
 
 ff_vaapi_vpp_ctx_init(avctx);
 vpp_ctx->pipeline_uninit = ff_vaapi_vpp_pipeline_uninit;
 vpp_ctx->build_filter_params = sharpness_vaapi_build_filter_params;
 vpp_ctx->output_format   = AV_PIX_FMT_NONE;
+if (!ctx->sharpness)
+vpp_ctx->passthrough = 1;
 
 return 0;
 }
diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
index 4a3b9d0766..82c446dc76 100644
--- a/libavfilter/vf_procamp_vaapi.c
+++ b/libavfilter/vf_procamp_vaapi.c
@@ -136,6 +136,9 @@ static int procamp_vaapi_filter_frame(AVFilterLink *inlink, 
AVFrame *input_frame
av_get_pix_fmt_name(input_frame->format),
input_frame->width, input_frame->height, input_frame->pts);
 
+if (vpp_ctx->passthrough)
+return ff_filter_frame(outlink, input_frame);
+
 if (vpp_ctx->va_context == VA_INVALID_ID)
 return AVERROR(EINVAL);
 
@@ -179,11 +182,18 @@ fail:
 static av_cold int procamp_vaapi_init(AVFilterContext *avctx)
 {
 VAAPIVPPContext *vpp_ctx = avctx->priv;
+ProcampVAAPIContext *ctx = avctx->priv;
+float eps = 0.0001;
 
 ff_vaapi_vpp_ctx_init(avctx);
 vpp_ctx->pipeline_uninit = ff_vaapi_vpp_pipeline_uninit;
 vpp_ctx->build_filter_params = procamp_vaapi_build_filter_params;
 vpp_ctx->output_format   = AV_PIX_FMT_NONE;
+if (fabs(ctx->saturation - SATURATION_DEFAULT) < eps &&
+fabs(ctx->bright - BRIGHTNESS_DEFAULT) < eps &&
+fabs(ctx->contrast - CONTRAST_DEFAULT)

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute of H.264

2023-05-29 Thread Lance Wang
On Mon, May 29, 2023 at 10:16 PM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> Signed-off-by: Zhao Zhili 
> ---
>  libavformat/hlsenc.c | 14 --
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 871afb571b..1e0848ce3d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -355,9 +355,19 @@ static void write_codec_attr(AVStream *st,
> VariantStream *vs)
>
>  if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
>  uint8_t *data = st->codecpar->extradata;
> -if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 &&
> (data[4] & 0x1F) == 7) {
> +if (data) {
> +const uint8_t *p;
> +
> +if (AV_RB32(data) == 0x01 && (data[4] & 0x1F) == 7)
> +p = &data[5];
> +else if (AV_RB24(data) == 0x01 && (data[3] & 0x1F) == 7)
> +p = &data[4];
> +else if (data[0] == 0x01)  /* avcC */
> +p = &data[1];
> +else
> +goto fail;
>

how to reproduce the issue? I recall mpegts is annex b format and sps/pps
start code is 4 byte always.


>  snprintf(attr, sizeof(attr),
> - "avc1.%02x%02x%02x", data[5], data[6], data[7]);
> + "avc1.%02x%02x%02x", p[0], p[1], p[2]);
>  } else {
>  goto fail;
>  }
> --
> 2.25.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] libavfilter: add vf_xfade_vulkan

2023-05-29 Thread Marvin Scholz
This is an initial version of vf_xfade_vulkan based
on vf_xfade_opencl, for now only fade and wipeleft
transitions are supported.
---
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_xfade_vulkan.c | 441 ++
 3 files changed, 443 insertions(+)
 create mode 100644 libavfilter/vf_xfade_vulkan.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 18935b1616..ff149a3733 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -552,6 +552,7 @@ OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_XCORRELATE_FILTER) += vf_convolve.o framesync.o
 OBJS-$(CONFIG_XFADE_FILTER)  += vf_xfade.o
 OBJS-$(CONFIG_XFADE_OPENCL_FILTER)   += vf_xfade_opencl.o opencl.o 
opencl/xfade.o
+OBJS-$(CONFIG_XFADE_VULKAN_FILTER)   += vf_xfade_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_XMEDIAN_FILTER)+= vf_xmedian.o framesync.o
 OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o yadif_common.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f1f781101b..6593e4eb83 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -519,6 +519,7 @@ extern const AVFilter ff_vf_xbr;
 extern const AVFilter ff_vf_xcorrelate;
 extern const AVFilter ff_vf_xfade;
 extern const AVFilter ff_vf_xfade_opencl;
+extern const AVFilter ff_vf_xfade_vulkan;
 extern const AVFilter ff_vf_xmedian;
 extern const AVFilter ff_vf_xstack;
 extern const AVFilter ff_vf_yadif;
diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
new file mode 100644
index 00..4a47c68fb4
--- /dev/null
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -0,0 +1,441 @@
+/*
+ * 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/random_seed.h"
+#include "libavutil/opt.h"
+#include "vulkan_filter.h"
+#include "vulkan_spirv.h"
+#include "filters.h"
+#include "internal.h"
+
+#define IN_A 0
+#define IN_B 1
+
+enum XFadeTransitions {
+FADE,
+WIPELEFT,
+NB_TRANSITIONS,
+};
+
+typedef struct XFadeParameters {
+float progress;
+} XFadeParameters;
+
+typedef struct XFadeVulkanContext {
+FFVulkanContext vkctx;
+
+int transition;
+int64_t duration;
+int64_t offset;
+
+int initialized;
+FFVulkanPipelinepl;
+FFVkExecPoole;
+FFVkQueueFamilyCtx  qf;
+FFVkSPIRVShader shd;
+VkSampler   sampler;
+
+int64_t duration_pts;
+int64_t offset_pts;
+int64_t first_pts;
+int64_t last_pts;
+int64_t pts;
+int xfade_is_over;
+int need_second;
+int eof[2];
+AVFrame *xf[2];
+} XFadeVulkanContext;
+
+static const char transition_fade[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, mix(b, a, progress)); 
)
+C(0, } 
)
+};
+
+static const char transition_wipeleft[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, ivec2 size = imageSize(output_images[idx]);   
)
+C(1, int  s = int(size.x * progress);  
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, pos.x > s ? b : a);   
)
+C(0, } 
)
+};
+
+static av_cold int init_filter(AVFilterContext *avctx)
+{
+int e

[FFmpeg-devel] [PATCH v2] libavfilter: add vf_xfade_vulkan

2023-05-29 Thread Marvin Scholz
This is an initial version of vf_xfade_vulkan based
on vf_xfade_opencl, for now only fade and wipeleft
transitions are supported.
---

Changes to v1:
 - Added proper configure _deps to require vulkan and
   the spirv compiler

This should fix the Patchwork build failure.

 configure |   1 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_xfade_vulkan.c | 441 ++
 4 files changed, 444 insertions(+)
 create mode 100644 libavfilter/vf_xfade_vulkan.c

diff --git a/configure b/configure
index 495493aa0e..a7c5897fd8 100755
--- a/configure
+++ b/configure
@@ -3777,6 +3777,7 @@ scale_vulkan_filter_deps="vulkan spirv_compiler"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
 xfade_opencl_filter_deps="opencl"
+xfade_vulkan_filter_deps="vulkan spirv_compiler"
 yadif_cuda_filter_deps="ffnvcodec"
 yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
 yadif_videotoolbox_filter_deps="metal corevideo videotoolbox"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 18935b1616..ff149a3733 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -552,6 +552,7 @@ OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_XCORRELATE_FILTER) += vf_convolve.o framesync.o
 OBJS-$(CONFIG_XFADE_FILTER)  += vf_xfade.o
 OBJS-$(CONFIG_XFADE_OPENCL_FILTER)   += vf_xfade_opencl.o opencl.o 
opencl/xfade.o
+OBJS-$(CONFIG_XFADE_VULKAN_FILTER)   += vf_xfade_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_XMEDIAN_FILTER)+= vf_xmedian.o framesync.o
 OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o yadif_common.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f1f781101b..6593e4eb83 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -519,6 +519,7 @@ extern const AVFilter ff_vf_xbr;
 extern const AVFilter ff_vf_xcorrelate;
 extern const AVFilter ff_vf_xfade;
 extern const AVFilter ff_vf_xfade_opencl;
+extern const AVFilter ff_vf_xfade_vulkan;
 extern const AVFilter ff_vf_xmedian;
 extern const AVFilter ff_vf_xstack;
 extern const AVFilter ff_vf_yadif;
diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
new file mode 100644
index 00..4a47c68fb4
--- /dev/null
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -0,0 +1,441 @@
+/*
+ * 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/random_seed.h"
+#include "libavutil/opt.h"
+#include "vulkan_filter.h"
+#include "vulkan_spirv.h"
+#include "filters.h"
+#include "internal.h"
+
+#define IN_A 0
+#define IN_B 1
+
+enum XFadeTransitions {
+FADE,
+WIPELEFT,
+NB_TRANSITIONS,
+};
+
+typedef struct XFadeParameters {
+float progress;
+} XFadeParameters;
+
+typedef struct XFadeVulkanContext {
+FFVulkanContext vkctx;
+
+int transition;
+int64_t duration;
+int64_t offset;
+
+int initialized;
+FFVulkanPipelinepl;
+FFVkExecPoole;
+FFVkQueueFamilyCtx  qf;
+FFVkSPIRVShader shd;
+VkSampler   sampler;
+
+int64_t duration_pts;
+int64_t offset_pts;
+int64_t first_pts;
+int64_t last_pts;
+int64_t pts;
+int xfade_is_over;
+int need_second;
+int eof[2];
+AVFrame *xf[2];
+} XFadeVulkanContext;
+
+static const char transition_fade[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0, { 
)
+C(1, vec4 a = texture(a_images[idx], pos); 
)
+C(1, vec4 b = texture(b_images[idx], pos); 
)
+C(1, imageStore(output_images[idx], pos, mix(b, a, progress)); 
)
+C(0, } 
)
+};
+
+static const char transition_wipeleft[] = {
+C(0, void transition(int idx, ivec2 pos, float progress)   
)
+C(0

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/h264_mp4toannexb_bsf: refactor start_code_size handling

2023-05-29 Thread zhilizhao(赵志立)

> On May 29, 2023, at 23:54, myp...@gmail.com wrote:
> 
> On Fri, May 19, 2023 at 4:41 PM Zhao Zhili  wrote:
>> 
>> From: Zhao Zhili 
>> 
>> start_code_size depends on whether PS comes from out-of-band or
>> in-band. Make the code more readable.
>> ---
>> libavcodec/h264_mp4toannexb_bsf.c | 34 ---
>> 1 file changed, 27 insertions(+), 7 deletions(-)
>> 
>> diff --git a/libavcodec/h264_mp4toannexb_bsf.c 
>> b/libavcodec/h264_mp4toannexb_bsf.c
>> index d11be455c2..7dce1ae9b6 100644
>> --- a/libavcodec/h264_mp4toannexb_bsf.c
>> +++ b/libavcodec/h264_mp4toannexb_bsf.c
>> @@ -43,10 +43,26 @@ typedef struct H264BSFContext {
>> int  extradata_parsed;
>> } H264BSFContext;
>> 
>> +enum PsSource {
>> +PS_OUT_OF_BAND = -1,
>> +PS_NONE = 0,
>> +PS_IN_BAND = 1,
>> +};
>> +
>> static void count_or_copy(uint8_t **out, uint64_t *out_size,
>> -  const uint8_t *in, int in_size, int ps, int copy)
>> +  const uint8_t *in, int in_size, enum PsSource ps, 
>> int copy)
>> {
>> -uint8_t start_code_size = ps < 0 ? 0 : *out_size == 0 || ps ? 4 : 3;
>> +uint8_t start_code_size;
>> +
>> +if (ps == PS_OUT_OF_BAND)
>> +/* start code already present in out-of-band ps data, so don't need 
>> to
>> + * add it manually again
>> + */
>> +start_code_size = 0;
>> +else if (ps == PS_IN_BAND || *out_size == 0)
>> +start_code_size = 4;
>> +else
>> +start_code_size = 3;
> I prefer the original style, they are shorter and more concise

It takes a little time to figure out what two ternary do in a
single statement, it takes more time to figure out why, and
multiple ternaries is hard to write comments properly.

Multiple ternaries in a single statement works in simple cases.
For current situation, I prefer ‘if-else’.

>> 
>> if (copy) {
>> memcpy(*out + start_code_size, in, in_size);
>> @@ -202,6 +218,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
>> AVPacket *opkt)
>> 
>> do {
>> uint32_t nal_size = 0;
>> +enum PsSource ps;
>> 
>> /* possible overread ok due to padding */
>> for (int i = 0; i < s->length_size; i++)
>> @@ -230,7 +247,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
>> AVPacket *opkt)
>> if (!s->sps_size) {
>> LOG_ONCE(ctx, AV_LOG_WARNING, "SPS not present in 
>> the stream, nor in AVCC, stream may be unreadable\n");
>> } else {
>> -count_or_copy(&out, &out_size, s->sps, s->sps_size, 
>> -1, j);
>> +count_or_copy(&out, &out_size, s->sps, s->sps_size, 
>> PS_OUT_OF_BAND, j);
>> sps_seen = 1;
>> }
>> }
>> @@ -246,19 +263,22 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
>> AVPacket *opkt)
>> if (new_idr && unit_type == H264_NAL_IDR_SLICE && !sps_seen && 
>> !pps_seen) {
>> if (ctx->par_out->extradata)
>> count_or_copy(&out, &out_size, ctx->par_out->extradata,
>> -  ctx->par_out->extradata_size, -1, j);
>> +  ctx->par_out->extradata_size, 
>> PS_OUT_OF_BAND, j);
>> new_idr = 0;
>> /* if only SPS has been seen, also insert PPS */
>> } else if (new_idr && unit_type == H264_NAL_IDR_SLICE && 
>> sps_seen && !pps_seen) {
>> if (!s->pps_size) {
>> LOG_ONCE(ctx, AV_LOG_WARNING, "PPS not present in the 
>> stream, nor in AVCC, stream may be unreadable\n");
>> } else {
>> -count_or_copy(&out, &out_size, s->pps, s->pps_size, -1, 
>> j);
>> +count_or_copy(&out, &out_size, s->pps, s->pps_size, 
>> PS_OUT_OF_BAND, j);
>> }
>> }
>> 
>> -count_or_copy(&out, &out_size, buf, nal_size,
>> -  unit_type == H264_NAL_SPS || unit_type == 
>> H264_NAL_PPS, j);
>> +if (unit_type == H264_NAL_SPS || unit_type == H264_NAL_PPS)
>> +ps = PS_IN_BAND;
>> +else
>> +ps = PS_NONE;
>> +count_or_copy(&out, &out_size, buf, nal_size, ps, j);
>> if (!new_idr && unit_type == H264_NAL_SLICE) {
>> new_idr  = 1;
>> sps_seen = 0;
>> --
>> 2.25.1
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
> 
> 
> -- 
> ===
> Jun zhao/赵军
> +++
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https:/

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute of H.264

2023-05-29 Thread zhilizhao(赵志立)


> On May 30, 2023, at 09:03, Lance Wang  wrote:
> 
> On Mon, May 29, 2023 at 10:16 PM Zhao Zhili  wrote:
> 
>> From: Zhao Zhili 
>> 
>> Signed-off-by: Zhao Zhili 
>> ---
>> libavformat/hlsenc.c | 14 --
>> 1 file changed, 12 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 871afb571b..1e0848ce3d 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -355,9 +355,19 @@ static void write_codec_attr(AVStream *st,
>> VariantStream *vs)
>> 
>> if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
>> uint8_t *data = st->codecpar->extradata;
>> -if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 &&
>> (data[4] & 0x1F) == 7) {
>> +if (data) {
>> +const uint8_t *p;
>> +
>> +if (AV_RB32(data) == 0x01 && (data[4] & 0x1F) == 7)
>> +p = &data[5];
>> +else if (AV_RB24(data) == 0x01 && (data[3] & 0x1F) == 7)
>> +p = &data[4];
>> +else if (data[0] == 0x01)  /* avcC */
>> +p = &data[1];
>> +else
>> +goto fail;
>> 
> 
> how to reproduce the issue? I recall mpegts is annex b format and sps/pps
> start code is 4 byte always.

For example:

ffmpeg -i foo.mp4 -c copy -hls_playlist_type vod -master_pl_name bar.m3u8 
test.m3u8

1. The input of hls muxer can be avcc

2. The output of hls muxer can be avcc too, with fmp4 segments.

3. Start code of SPS/PPS should be 0 0 0 1, however, 0 0 1 exist in wild.
ff_isom_write_avcc() does the same:

/* check for H.264 start code */
if (AV_RB32(data) != 0x0001 &&
AV_RB24(data) != 0x01) {
avio_write(pb, data, len);
return 0;
}

ff_isom_write_avcc() can be used here, and get/create CODECS attribute can be
shared by multiple muxers. I won't go that further by now.


> 
> 
>> snprintf(attr, sizeof(attr),
>> - "avc1.%02x%02x%02x", data[5], data[6], data[7]);
>> + "avc1.%02x%02x%02x", p[0], p[1], p[2]);
>> } else {
>> goto fail;
>> }
>> --
>> 2.25.1
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>> 
> ___
> ffmpeg-devel 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] avformat/hlsenc: fix CODECS attribute of H.264

2023-05-29 Thread Lance Wang
On Tue, May 30, 2023 at 11:09 AM "zhilizhao(赵志立)" 
wrote:

>
>
> > On May 30, 2023, at 09:03, Lance Wang  wrote:
> >
> > On Mon, May 29, 2023 at 10:16 PM Zhao Zhili 
> wrote:
> >
> >> From: Zhao Zhili 
> >>
> >> Signed-off-by: Zhao Zhili 
> >> ---
> >> libavformat/hlsenc.c | 14 --
> >> 1 file changed, 12 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> >> index 871afb571b..1e0848ce3d 100644
> >> --- a/libavformat/hlsenc.c
> >> +++ b/libavformat/hlsenc.c
> >> @@ -355,9 +355,19 @@ static void write_codec_attr(AVStream *st,
> >> VariantStream *vs)
> >>
> >> if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
> >> uint8_t *data = st->codecpar->extradata;
> >> -if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1
> &&
> >> (data[4] & 0x1F) == 7) {
> >> +if (data) {
> >> +const uint8_t *p;
> >> +
> >> +if (AV_RB32(data) == 0x01 && (data[4] & 0x1F) == 7)
> >> +p = &data[5];
> >> +else if (AV_RB24(data) == 0x01 && (data[3] & 0x1F) == 7)
> >> +p = &data[4];
> >> +else if (data[0] == 0x01)  /* avcC */
> >> +p = &data[1];
> >> +else
> >> +goto fail;
> >>
> >
> > how to reproduce the issue? I recall mpegts is annex b format and sps/pps
> > start code is 4 byte always.
>
> For example:
>
> ffmpeg -i foo.mp4 -c copy -hls_playlist_type vod -master_pl_name bar.m3u8
> test.m3u8
>
> 1. The input of hls muxer can be avcc
>
> 2. The output of hls muxer can be avcc too, with fmp4 segments.
>
>
Yes, this is the case. I had to add mp4toannexb bsf after the copy for avcc
input.  If we
don't add the format conversion, hevc may  have the same issue I guess.
Also we should
check the size of extradata.



> 3. Start code of SPS/PPS should be 0 0 0 1, however, 0 0 1 exist in wild.
> ff_isom_write_avcc() does the same:
>
> /* check for H.264 start code */
> if (AV_RB32(data) != 0x0001 &&
> AV_RB24(data) != 0x01) {
> avio_write(pb, data, len);
> return 0;
> }
>
> ff_isom_write_avcc() can be used here, and get/create CODECS attribute can
> be
> shared by multiple muxers. I won't go that further by now.
>
>
The next NALU checking is for SPS only, so one more byte is zero_byte. It's
required by specs:

zero_byte is a single byte equal to 0x00.

When any of the following conditions are true, the zero_byte syntax element
shall be present:

   -

   –  the nal_unit_type within the nal_unit( ) is equal to 7 (sequence
   parameter set) or 8 (picture parameter set),
   -

   –  the byte stream NAL unit syntax structure contains the first NAL unit
   of an access unit in decoding order, as specified in clause 7.4.1.2.3.





>
> >
> >
> >> snprintf(attr, sizeof(attr),
> >> - "avc1.%02x%02x%02x", data[5], data[6], data[7]);
> >> + "avc1.%02x%02x%02x", p[0], p[1], p[2]);
> >> } else {
> >> goto fail;
> >> }
> >> --
> >> 2.25.1
> >>
> >> ___
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> >>
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix CODECS attribute of H.264

2023-05-29 Thread zhilizhao(赵志立)


> On May 30, 2023, at 12:44, Lance Wang  wrote:
> 
> On Tue, May 30, 2023 at 11:09 AM "zhilizhao(赵志立)" 
> wrote:
> 
>> 
>> 
>>> On May 30, 2023, at 09:03, Lance Wang  wrote:
>>> 
>>> On Mon, May 29, 2023 at 10:16 PM Zhao Zhili 
>> wrote:
>>> 
 From: Zhao Zhili 
 
 Signed-off-by: Zhao Zhili 
 ---
 libavformat/hlsenc.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)
 
 diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
 index 871afb571b..1e0848ce3d 100644
 --- a/libavformat/hlsenc.c
 +++ b/libavformat/hlsenc.c
 @@ -355,9 +355,19 @@ static void write_codec_attr(AVStream *st,
 VariantStream *vs)
 
if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
uint8_t *data = st->codecpar->extradata;
 -if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1
>> &&
 (data[4] & 0x1F) == 7) {
 +if (data) {
 +const uint8_t *p;
 +
 +if (AV_RB32(data) == 0x01 && (data[4] & 0x1F) == 7)
 +p = &data[5];
 +else if (AV_RB24(data) == 0x01 && (data[3] & 0x1F) == 7)
 +p = &data[4];
 +else if (data[0] == 0x01)  /* avcC */
 +p = &data[1];
 +else
 +goto fail;
 
>>> 
>>> how to reproduce the issue? I recall mpegts is annex b format and sps/pps
>>> start code is 4 byte always.
>> 
>> For example:
>> 
>> ffmpeg -i foo.mp4 -c copy -hls_playlist_type vod -master_pl_name bar.m3u8
>> test.m3u8
>> 
>> 1. The input of hls muxer can be avcc
>> 
>> 2. The output of hls muxer can be avcc too, with fmp4 segments.
>> 
>> 
> Yes, this is the case. I had to add mp4toannexb bsf after the copy for avcc
> input.  If we
> don't add the format conversion, hevc may  have the same issue I guess.

Use mp4toannexb for TS segments is a good practice, but not for
fmp4.

No comments on hevc.

> Also we should
> check the size of extradata.

extradata has a AV_INPUT_BUFFER_PADDING_SIZE, so not necessary.

> 
> 
> 
>> 3. Start code of SPS/PPS should be 0 0 0 1, however, 0 0 1 exist in wild.
>> ff_isom_write_avcc() does the same:
>> 
>>/* check for H.264 start code */
>>if (AV_RB32(data) != 0x0001 &&
>>AV_RB24(data) != 0x01) {
>>avio_write(pb, data, len);
>>return 0;
>>}
>> 
>> ff_isom_write_avcc() can be used here, and get/create CODECS attribute can
>> be
>> shared by multiple muxers. I won't go that further by now.
>> 
>> 
> The next NALU checking is for SPS only, so one more byte is zero_byte. It's
> required by specs:
> 
> zero_byte is a single byte equal to 0x00.
> 
> When any of the following conditions are true, the zero_byte syntax element
> shall be present:
> 
>   -
> 
>   –  the nal_unit_type within the nal_unit( ) is equal to 7 (sequence
>   parameter set) or 8 (picture parameter set),
>   -
> 
>   –  the byte stream NAL unit syntax structure contains the first NAL unit
>   of an access unit in decoding order, as specified in clause 7.4.1.2.3.

Yes, but it’s not the first time people don’t follow spec.


> 
> 
> 
>> 
>>> 
>>> 
snprintf(attr, sizeof(attr),
 - "avc1.%02x%02x%02x", data[5], data[6], data[7]);
 + "avc1.%02x%02x%02x", p[0], p[1], p[2]);
} else {
goto fail;
}
 --
 2.25.1
 
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 
 To unsubscribe, visit link above, or email
 ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
 
>>> ___
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>> 
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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


Re: [FFmpeg-devel] [PATCH v5] lavc/h264chroma: RISC-V V add motion compensation for 8x8 chroma blocks

2023-05-29 Thread Rémi Denis-Courmont
Hi,

Unless somebody else comes up with additional comments, you don't need to do 
anything.

As the FFmpeg RISC-V maintainer, whatever that entails, I figure that I am 
expected, by default, to merge your patch but I have not sorted out commit 
access yet. But anyhow, there's not much *you* can do now than wait.
___
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".