[FFmpeg-devel] [PATCH v3 2/2] avformat: deprecated av_get_frame_filename() and av_get_frame_filename2()
--- doc/APIchanges | 3 ++- libavfilter/vf_signature.c | 4 ++-- libavformat/avformat.h | 22 ++ libavformat/img2dec.c | 10 +- libavformat/segment.c | 4 ++-- libavformat/utils.c | 2 +- libavformat/version_major.h | 2 +- libavformat/webm_chunk.c| 4 ++-- 8 files changed, 33 insertions(+), 18 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 9f091f5ec5..cbab71a408 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -3,7 +3,8 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: 2024-09-xx - xx - lavf 61.7.100 - avformat.h - Add av_get_frame_filename3() + Deprecate av_get_frame_filename(), av_get_frame_filename2(), + and replace them with av_get_frame_filename3(). 2024-09-18 - xx - lavc 61.17.100 - packet.h Add AV_PKT_DATA_LCEVC. diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c index f419522ac6..37f3ff227e 100644 --- a/libavfilter/vf_signature.c +++ b/libavfilter/vf_signature.c @@ -562,7 +562,7 @@ static int export(AVFilterContext *ctx, StreamContext *sc, int input) if (sic->nb_inputs > 1) { /* error already handled */ -av_assert0(av_get_frame_filename(filename, sizeof(filename), sic->filename, input) == 0); +av_assert0(av_get_frame_filename3(filename, sizeof(filename), sic->filename, input, 0) == 0); } else { if (av_strlcpy(filename, sic->filename, sizeof(filename)) >= sizeof(filename)) return AVERROR(EINVAL); @@ -673,7 +673,7 @@ static av_cold int init(AVFilterContext *ctx) } /* check filename */ -if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && av_get_frame_filename(tmp, sizeof(tmp), sic->filename, 0) == -1) { +if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && av_get_frame_filename3(tmp, sizeof(tmp), sic->filename, 0, 0) == -1) { av_log(ctx, AV_LOG_ERROR, "The filename must contain %%d or %%0nd, if you have more than one input.\n"); return AVERROR(EINVAL); } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 1bc0e716dc..a407faecec 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2940,11 +2940,25 @@ void av_dump_format(AVFormatContext *ic, int av_get_frame_filename3(char *buf, int buf_size, const char *path, int64_t number, int flags); -int av_get_frame_filename2(char *buf, int buf_size, - const char *path, int number, int flags); +#if FF_API_AV_GET_FRAME_FILENAME2 +/** + * Like av_get_frame_filename3() but requires int-type number + * + * @deprecated use av_get_frame_filename3() with same arguments + */ +attribute_deprecated +int av_get_frame_filename2(char *buf, int buf_size, +const char *path, int number, int flags); -int av_get_frame_filename(char *buf, int buf_size, - const char *path, int number); +/** + * Like av_get_frame_filename3() but requires int-type number and doesn't accept flags + * + * @deprecated use av_get_frame_filename3() with flags=0 + */ +attribute_deprecated +int av_get_frame_filename(char *buf, int buf_size, +const char *path, int number); +#endif /** * Check whether filename actually is a numbered sequence generator. diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index 3389fa818e..df376ac612 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -122,7 +122,7 @@ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index /* find the first image */ for (first_index = start_index; first_index < start_index + start_index_range; first_index++) { -if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) { +if (av_get_frame_filename3(buf, sizeof(buf), path, first_index, 0) < 0) { *pfirst_index = *plast_index = 1; if (pb || avio_check(buf, AVIO_FLAG_READ) > 0) @@ -144,8 +144,8 @@ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index range1 = 1; else range1 = 2 * range; -if (av_get_frame_filename(buf, sizeof(buf), path, - last_index + range1) < 0) +if (av_get_frame_filename3(buf, sizeof(buf), path, + last_index + range1, 0) < 0) goto fail; if (avio_check(buf, AVIO_FLAG_READ) <= 0) break; @@ -434,9 +434,9 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) filename = s->globstate.gl_pathv[s->img_number]; #endif } else { -if (av_get_frame_filename(filename_bytes, sizeof(filename_bytes), +if (av_get_frame_filename3(filename_bytes, sizeof(filename_bytes),
[FFmpeg-devel] [PATCH v3 1/2] avformat/utils: added av_get_frame_filename3() (changed parameter int -> int64_t)
Resolves an integer overflow with the frame_pts option (issue 11194). Signed-off-by: Filip Mašić --- doc/APIchanges | 3 +++ libavformat/avformat.h | 7 +-- libavformat/img2enc.c | 6 ++ libavformat/utils.c| 12 +--- libavformat/version.h | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 81537fea09..9f091f5ec5 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-xx - xx - lavf 61.7.100 - avformat.h + Add av_get_frame_filename3() + 2024-09-18 - xx - lavc 61.17.100 - packet.h Add AV_PKT_DATA_LCEVC. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 56c1c80289..1bc0e716dc 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2932,11 +2932,14 @@ void av_dump_format(AVFormatContext *ic, * * @param buf destination buffer * @param buf_size destination buffer size - * @param path numbered sequence string - * @param number frame number + * @param path path with substitution template + * @param number the number to substitute * @param flags AV_FRAME_FILENAME_FLAGS_* * @return 0 if OK, -1 on format error */ +int av_get_frame_filename3(char *buf, int buf_size, + const char *path, int64_t number, int flags); + int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags); diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index 526a11e5ee..460e6a38bd 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -160,13 +160,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EINVAL); } } else if (img->frame_pts) { -if (av_get_frame_filename2(filename, sizeof(filename), s->url, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { +if (av_get_frame_filename3(filename, sizeof(filename), s->url, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames."); return AVERROR(EINVAL); } -} else if (av_get_frame_filename2(filename, sizeof(filename), s->url, - img->img_number, - AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { +} else if (av_get_frame_filename3(filename, sizeof(filename), s->url, img->img_number, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { if (img->img_number == img->start_img_number) { av_log(s, AV_LOG_WARNING, "The specified filename '%s' does not contain an image sequence pattern or a pattern is invalid.\n", s->url); av_log(s, AV_LOG_WARNING, diff --git a/libavformat/utils.c b/libavformat/utils.c index e9ded627ad..0a7ed1a013 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include "config.h" @@ -280,7 +281,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts) return (sec * 100) + usec; } -int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) +int av_get_frame_filename3(char *buf, int buf_size, const char *path, int64_t number, int flags) { const char *p; char *q, buf1[20], c; @@ -313,7 +314,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number percentd_found = 1; if (number < 0) nd += 1; -snprintf(buf1, sizeof(buf1), "%0*d", nd, number); +snprintf(buf1, sizeof(buf1), "%0*"PRId64, nd, number); len = strlen(buf1); if ((q - buf + len) > buf_size - 1) goto fail; @@ -338,9 +339,14 @@ fail: return -1; } +int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) +{ +return av_get_frame_filename3(buf, buf_size, path, number, flags); +} + int av_get_frame_filename(char *buf, int buf_size, const char *path, int number) { -return av_get_frame_filename2(buf, buf_size, path, number, 0); +return av_get_frame_filename3(buf, buf_size, path, number, 0); } void av_url_split(char *proto, int proto_size, diff --git a/libavformat/version.h b/libavformat/version.h index 4bde82abb4..70c554c19c 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 6 +#define LIBAVFORMAT_VERSION_MINOR 7 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- 2.46.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg
Re: [FFmpeg-devel] [PATCH v6 4/5] libavcodec/dnxucdec: DNxUncompressed decoder
All the mentioned issues are fixed in v9. Thanks for your accurate review! martin On 23.09.24 00:24, Marton Balint wrote: + for(y = 0; y < frame->height; y++){ + for(x = 0; x < frame->width; x++){ You might want to push variable declarations to the loop initializer expression, like "for (int y = 0; ..." This is true for all similar cases. + av_log(avctx, AV_LOG_ERROR, + "Insufficient size of AVPacket data (pkg size: %d needed: %d)\n", avpkt->size, needed); + return AVERROR_EXIT; AVERROR_INVALIDDATA + av_log(avctx, AV_LOG_ERROR, + "Image width must be a multiple of 2 for YUV 4:2:2 DNxUncompressed!\n"); + return AVERROR_EXIT; AVERROR_INVALIDDATA + av_log(avctx, AV_LOG_ERROR, + "Unsupported DNxUncompressed pixel format variant: '%s'\n", + fourcc_buf); + return AVERROR(ENOSYS); AVERROR_PATCHWELCOME ___ 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 v9 2/6] libavformat/mxf: Add ULs for DNxUncompressed
--- 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 24f4ed1..7460799 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1594,6 +1594,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,0x0d,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".
Re: [FFmpeg-devel] [PATCH] avcodec/cuviddec: Add handling HDR10+ sidedata on cuviddec.
> Its not possible for a decoder to save memory by scaling references. > Decoding would simply break. > Only way of saving memory while decoding is to simply get rid of output > frames as soon as possible. Maybe I didn't explain myself well, but if I set a breakpoint and step over the code while looking at nvidia-smi, I can show you that decoding the video with cuviddec leaving the "resize" option untouched (so decoding outputs frames at 1080p) uses over 100MB more GPU Memory than setting the "resize" flag to 640x360, and the decoding doesn't break at all (just tested it on my NVIDIA GeForce RTX 4070 Ti with ffmpeg 7.0.2, and we used to have similar results back when we were using ffmpeg 4.3.6). > NVDEC does not implement fixed-function downscaling, in fact none of the > desktop cards have any hardware dedicated to that. > As far as I know, scaling, deinterlacing, and generally all post-processing > is done on the compute engine via cuda. This is still pretty efficient > since the data can be shared between the decode/compute engines without > copy. This is a good point, and something I haven't verified but would be curious to check. Still, the biggest downside we see is GPU VRAM consumption, as explained above :( On Fri, Sep 20, 2024 at 9:34 PM Lynne via ffmpeg-devel < ffmpeg-devel@ffmpeg.org> wrote: > On 20/09/2024 20:41, Carlos Ruiz wrote: > >> It's just that the cuviddec decoder is more of a relic, from before the > >> native hwaccel existed. > >> The only reason it's not straight up deprecated is that it's sometimes > >> nice to have a "second opinion" when issues crop up, and there are a few > >> specific features like hardware-deinterlacing that can't be exposed via > >> the native hwaccel. > >> > >> But I'd normally not like to expand it even further and add complex and > >> large features to it. Whenever possible, the native nvdec hwaccel should > >> be used. > > > > As someone who recently switched from *_cuvid to * + hwaccel=cuda I have > to > > agree > > that the performance (timing-wise at least) has been very comparable for > > decoding. > > > > The only comment I'd like to make though, and this might be a bit of > > unpopular opinion > > based on some other threads I read, but there are huge advantages of > hwaccel > > accelerating not just decoding but also resizing (and I guess optionally > > cropping). > > I know that ideally a decoder should only decode, but think about a > common > > usecase > > in the AI world we live in: you get a bunch of simultaneous 4k (or 1080p) > > incoming > > rtsp streams and you want to decode the video and pass it through some ML > > model, > > e.g. in TensorRT (to stick with the Nvidia example). The native hevc > codec > > doesn't > > support resizing, so you decode video at full 4k on the gpu, which means > > allocating > > something like 5-10 surfaces at 3840x2160 which becomes 250MB of GPU > memory, > > and then you have immediately take all of those frames, pass them > through a > > filterchain, > > scale them down to e.g. 640x360, and waste CUDA cores instead of > leveraging > > the > > dedicated video downsizing inside the NVDEC chip. Now do that for 50 > camera > > streams > > and you'll quickly run out of GPU memory with a GPU utilization under 10% > > haha. > > > > This is exactly why I submitted a patch yesterday that would allow using > > the hevc > > codec with nvdec hwaccel, while resizing on the gpu like hevc_cuviddec > > does, and > > the memory (and GPU) consuption goes waaay down (e.g. 6MB of GPU VRAM > > instead of 250MB per camera). I know this is a different discussion but > > thought > > it was appropriate to share because deprecating cuviddec or rejecting my > > patch > > would leave part of the community out. > > > > > > On Fri, Sep 20, 2024 at 12:48 PM Timo Rothenpieler < > t...@rothenpieler.org> > > wrote: > > > >> On 20/09/2024 04:08, 김윤주 wrote: > >>> Does native decoder refer to hevc (hevcdec.c)? > >>> I tried using hevc and in environments with low CPU performance, > >> hevc_cuvid > >>> was much faster. > >>> So, I used hevc_cuvid for decoding but encountered an issue where > HDR10+ > >>> sidedata did not exist. > >>> That's why I wrote this patch. > >> > >> You did turn on hwaccel, right? > >> I don't see why the native decoder would be much slower at parsing then > >> nvidias parsers. > >> > >>> I thought that the original content's sidedata should be preserved even > >>> after decoding regardless of which decoder is used. > >>> And I thought hevc_cuvid was the only way to get Nvidia hwaccel > support. > >>> If I'm mistaken about anything, please let me know. > >> > >> It's just that the cuviddec decoder is more of a relic, from before the > >> native hwaccel existed. > >> The only reason it's not straight up deprecated is that it's sometimes > >> nice to have a "second opinion" when issues crop up, and there are a few > >> specific features like hardware-deinterlacing that can't be exposed via > >> the native hwaccel. > >>
[FFmpeg-devel] [PATCH 1/2] avformat/internal: Add ff_get_frame_filename
From: Zhao Zhili It's similar to av_get_frame_filename2 but with int64_t number support. Make av_get_frame_filename* a wrapper over ff_get_frame_filename. --- libavformat/internal.h | 16 libavformat/utils.c| 11 --- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 8e8971bfeb..0b200dafd4 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -745,6 +745,22 @@ void ff_format_set_url(AVFormatContext *s, char *url); */ int ff_match_url_ext(const char *url, const char *extensions); +/** + * Return in 'buf' the path with '%d' replaced by a number. + * + * Also handles the '%0nd' format where 'n' is the total number + * of digits and '%%'. + * + * @param buf destination buffer + * @param buf_size destination buffer size + * @param path numbered sequence string + * @param number any number like timestamp or frame number + * @param flags AV_FRAME_FILENAME_FLAGS_* + * @return 0 if OK, -1 on format error + */ +int ff_get_frame_filename(char *buf, int buf_size, const char *path, + int64_t number, int flags); + struct FFOutputFormat; struct FFInputFormat; void avpriv_register_devices(const struct FFOutputFormat * const o[], diff --git a/libavformat/utils.c b/libavformat/utils.c index e9ded627ad..e892e8bde7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -280,7 +280,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts) return (sec * 100) + usec; } -int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) +int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags) { const char *p; char *q, buf1[20], c; @@ -313,7 +313,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number percentd_found = 1; if (number < 0) nd += 1; -snprintf(buf1, sizeof(buf1), "%0*d", nd, number); +snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number); len = strlen(buf1); if ((q - buf + len) > buf_size - 1) goto fail; @@ -338,9 +338,14 @@ fail: return -1; } +int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) +{ +return ff_get_frame_filename(buf, buf_size, path, number, flags); +} + int av_get_frame_filename(char *buf, int buf_size, const char *path, int number) { -return av_get_frame_filename2(buf, buf_size, path, number, 0); +return ff_get_frame_filename(buf, buf_size, path, number, 0); } void av_url_split(char *proto, int proto_size, -- 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".
Re: [FFmpeg-devel] [PATCH v3 2/2] avformat: deprecated av_get_frame_filename() and av_get_frame_filename2()
> On Sep 23, 2024, at 18:18, Filip Mašić wrote: > > --- > doc/APIchanges | 3 ++- > libavfilter/vf_signature.c | 4 ++-- > libavformat/avformat.h | 22 ++ > libavformat/img2dec.c | 10 +- > libavformat/segment.c | 4 ++-- > libavformat/utils.c | 2 +- > libavformat/version_major.h | 2 +- > libavformat/webm_chunk.c| 4 ++-- > 8 files changed, 33 insertions(+), 18 deletions(-) The doc of av_get_frame_filename2 says explicitly `number` is `frame number`, I prefer fix img2enc.c over add another API: https://ffmpeg.org//pipermail/ffmpeg-devel/2024-September/333820.html > > diff --git a/doc/APIchanges b/doc/APIchanges > index 9f091f5ec5..cbab71a408 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -3,7 +3,8 @@ The last version increases of all libraries were on 2024-03-07 > API changes, most recent first: > > 2024-09-xx - xx - lavf 61.7.100 - avformat.h > - Add av_get_frame_filename3() > + Deprecate av_get_frame_filename(), av_get_frame_filename2(), > + and replace them with av_get_frame_filename3(). > > 2024-09-18 - xx - lavc 61.17.100 - packet.h > Add AV_PKT_DATA_LCEVC. > diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c > index f419522ac6..37f3ff227e 100644 > --- a/libavfilter/vf_signature.c > +++ b/libavfilter/vf_signature.c > @@ -562,7 +562,7 @@ static int export(AVFilterContext *ctx, StreamContext > *sc, int input) > > if (sic->nb_inputs > 1) { > /* error already handled */ > -av_assert0(av_get_frame_filename(filename, sizeof(filename), > sic->filename, input) == 0); > +av_assert0(av_get_frame_filename3(filename, sizeof(filename), > sic->filename, input, 0) == 0); > } else { > if (av_strlcpy(filename, sic->filename, sizeof(filename)) >= > sizeof(filename)) > return AVERROR(EINVAL); > @@ -673,7 +673,7 @@ static av_cold int init(AVFilterContext *ctx) > } > > /* check filename */ > -if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && > av_get_frame_filename(tmp, sizeof(tmp), sic->filename, 0) == -1) { > +if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && > av_get_frame_filename3(tmp, sizeof(tmp), sic->filename, 0, 0) == -1) { > av_log(ctx, AV_LOG_ERROR, "The filename must contain %%d or %%0nd, if > you have more than one input.\n"); > return AVERROR(EINVAL); > } > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 1bc0e716dc..a407faecec 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -2940,11 +2940,25 @@ void av_dump_format(AVFormatContext *ic, > int av_get_frame_filename3(char *buf, int buf_size, > const char *path, int64_t number, int flags); > > -int av_get_frame_filename2(char *buf, int buf_size, > - const char *path, int number, int flags); > +#if FF_API_AV_GET_FRAME_FILENAME2 > +/** > + * Like av_get_frame_filename3() but requires int-type number > + * > + * @deprecated use av_get_frame_filename3() with same arguments > + */ > +attribute_deprecated > +int av_get_frame_filename2(char *buf, int buf_size, > +const char *path, int number, int flags); > > -int av_get_frame_filename(char *buf, int buf_size, > - const char *path, int number); > +/** > + * Like av_get_frame_filename3() but requires int-type number and > doesn't accept flags > + * > + * @deprecated use av_get_frame_filename3() with flags=0 > + */ > +attribute_deprecated > +int av_get_frame_filename(char *buf, int buf_size, > +const char *path, int number); > +#endif > > /** > * Check whether filename actually is a numbered sequence generator. > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > index 3389fa818e..df376ac612 100644 > --- a/libavformat/img2dec.c > +++ b/libavformat/img2dec.c > @@ -122,7 +122,7 @@ static int find_image_range(AVIOContext *pb, int > *pfirst_index, int *plast_index > > /* find the first image */ > for (first_index = start_index; first_index < start_index + > start_index_range; first_index++) { > -if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) { > +if (av_get_frame_filename3(buf, sizeof(buf), path, first_index, 0) < > 0) { > *pfirst_index = > *plast_index = 1; > if (pb || avio_check(buf, AVIO_FLAG_READ) > 0) > @@ -144,8 +144,8 @@ static int find_image_range(AVIOContext *pb, int > *pfirst_index, int *plast_index > range1 = 1; > else > range1 = 2 * range; > -if (av_get_frame_filename(buf, sizeof(buf), path, > - last_index + range1) < 0) > +if (av_get_frame_filename3(buf, sizeof(buf), path, > + last_index + range1, 0) < 0) >
Re: [FFmpeg-devel] [PATCH v2] vulkan_encode: set the quality level in session parameters
On 23/09/2024 12:56, Víctor Manuel Jáquez Leal wrote: While running this command ./ffmpeg_g -loglevel debug -hwaccel vulkan -init_hw_device vulkan=vk:0,debug=1 -hwaccel_output_format vulkan -i input.y4m -vf 'format=nv12,hwupload' -c:v h264_vulkan -quality 2 output.mp4 -y It hit this validation error: Validation Error: [ VUID-vkCmdEncodeVideoKHR-None-08318 ] Object 0: handle = 0x8f8f, type = VK_OBJECT_TYPE_VIDEO_SESSION_KHR; Object 1: handle = 0xfdfd, type = VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR; | MessageID = 0x5dc3dd39 | vkCmdEncodeVideoKHR(): The currently configured encode quality level (2) for VkVideoSessionKHR 0x8f8f[] does not match the encode quality level (0) VkVideoSessionParametersKHR 0xfdfd[] was created with. The Vulkan spec states: The bound video session parameters object must have been created with the currently set video encode quality level for the bound video session at the time the command is executed on the device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdEncodeVideoKHR-None-08318) This patch adds a new function helper for creating session parameters, which also sets the quality level and it's called by the H.264 and H.265 Vulkan encoders. --- libavcodec/vulkan_encode.c | 34 + libavcodec/vulkan_encode.h | 6 ++ libavcodec/vulkan_encode_h264.c | 19 +- libavcodec/vulkan_encode_h265.c | 19 +- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c index 9a9258ce7b..d187b7cdd3 100644 --- a/libavcodec/vulkan_encode.c +++ b/libavcodec/vulkan_encode.c @@ -1023,3 +1023,37 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext * return 0; } + +int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, + void *codec_params_pnext) +{ +VkResult ret; +FFVulkanFunctions *vk = &ctx->s.vkfn; +FFVulkanContext *s = &ctx->s; + +VkVideoEncodeQualityLevelInfoKHR q_info; +VkVideoSessionParametersCreateInfoKHR session_params_create; + +q_info = (VkVideoEncodeQualityLevelInfoKHR) { +.sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR, +.pNext = codec_params_pnext, +.qualityLevel = ctx->opts.quality, +}; +session_params_create = (VkVideoSessionParametersCreateInfoKHR) { +.sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, +.pNext = &q_info, +.videoSession = ctx->common.session, +.videoSessionParametersTemplate = VK_NULL_HANDLE, +}; + +/* Create session parameters */ +ret = vk->CreateVideoSessionParametersKHR(s->hwctx->act_dev, &session_params_create, + s->hwctx->alloc, &ctx->session_params); +if (ret != VK_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Unable to create Vulkan video session parameters: %s!\n", + ff_vk_ret2str(ret)); +return AVERROR_EXTERNAL; +} + +return 0; +} diff --git a/libavcodec/vulkan_encode.h b/libavcodec/vulkan_encode.h index fd3499dd10..a7a02d5fd0 100644 --- a/libavcodec/vulkan_encode.h +++ b/libavcodec/vulkan_encode.h @@ -245,6 +245,12 @@ int ff_vulkan_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt); */ void ff_vulkan_encode_uninit(FFVulkanEncodeContext *ctx); +/** + * Create session parameters. + */ +int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, + void *codec_params_pnext); + /** * Paperwork. */ diff --git a/libavcodec/vulkan_encode_h264.c b/libavcodec/vulkan_encode_h264.c index af229afe52..9964ba5b8b 100644 --- a/libavcodec/vulkan_encode_h264.c +++ b/libavcodec/vulkan_encode_h264.c @@ -1005,7 +1005,6 @@ static av_cold int base_unit_to_vk(AVCodecContext *avctx, static int create_session_params(AVCodecContext *avctx) { int err; -VkResult ret; VulkanEncodeH264Context *enc = avctx->priv_data; FFVulkanEncodeContext *ctx = &enc->common; FFVulkanContext *s = &ctx->s; @@ -1015,7 +1014,6 @@ static int create_session_params(AVCodecContext *avctx) VkVideoEncodeH264SessionParametersAddInfoKHR h264_params_info; VkVideoEncodeH264SessionParametersCreateInfoKHR h264_params; -VkVideoSessionParametersCreateInfoKHR session_params_create; /* Convert it to Vulkan */ err = base_unit_to_vk(avctx, &vk_units); @@ -1044,23 +1042,8 @@ static int create_session_params(AVCodecContext *avctx) .maxStdPPSCount = 1, .pParametersAddInfo = &h264_params_info, }; -session_params_create = (VkVideoSessionParametersCreateInfoKHR) { -.sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, -.pNext = &h264_params, -
Re: [FFmpeg-devel] [PATCH] avcodec/nvdec: support resizing while decoding
> We don't really leverage these extra functions of NVDEC because it > breaks many assumptions about hwaccels, which are meant to be exact > decoders. Yeah I understand that, and expected this kind of feedback. Do you envision a way for hwaccels (perhaps in the future) to support some additional level of *hardware acceleration*, such as resizing and cropping? Let me try to motivate the rationale. Think about a common use case in the AI world we live in: you receive a bunch of simultaneous 4k (or 1080p) incoming rtsp streams and you want to decode the video and pass it through some ML model. The native hevc codec doesn't support resizing, so you decode video at full 4k on the gpu by leveraging the nvdec hwaccel, which allocates something like 5-10 surfaces at 3840x2160, totalling around 250MB of VRAM (GPU memory), and then you have to immediately take all of those frames, pass them through a filterchain, scale them down to e.g. 640x360. Leaving aside the waste of additional CUDA cores and added latency of having to synchronize the cuda stream twice (once to receive the frame out of the decoder, the second to pull from the filterchain), do this for 50 camera streams and you'll quickly run out of GPU memory with a GPU utilization under 10%... Instead, my patch allows decoding at 640x360 (or whatever you choose) directly, allocating only 6MB of GPU VRAM (instead of 250MB at 4k), so now you can fit 40x more video decoding streams in the same GPU card. I understand the challenges of allowing hwaccels to resize/crop as part of the decoding process and how it currently breaks the API in several ways I'm of course unfamiliar with. However, I'd love to help support this feature in the future, since it would add tremendous value and enable more efficient real-time Computer Vision pipelines to leverage the amazing framework FFmpeg is. > You cannot do that here. The frame size can change mid-stream, and > this would suppress any such change. > Additionally, if this code runs more then once, then the offset is > applied repeatedly without actually resetting width/height. Very good points! Indeed I'm not yet super familiar with the structure of the hevc codec implementation, nor with the available functions to reconfigure a hwaccel (I know the Video Codec SDK supports this, but have never implemented such functionality), but I see how this would break. Would you see value in me trying to figure out a way to support reconfiguring the codec if the width/height/cropping changes mid-stream or would you reject the patch/feature regardless? Thanks! On Fri, Sep 20, 2024 at 7:18 AM Hendrik Leppkes wrote: > On Fri, Sep 20, 2024 at 1:24 AM Carlos Ruiz > wrote: > > > > Hi! > > > > This is my first contribution to the project so please excuse any bad > > etiquette, I tried to read all the FAQs before posting. Would love to > start > > by thanking everyone for such an amazing framework you've built! > > > > Anyway, here's my proposed patch to support video resizing when using > NVDEC > > hwaccel to decode hevc video (I could look into a similar patch for h264, > > av1, etc if this looks useful). There's a bit more context/explanation in > > the commit description in the patch, but please let me know if the use > case > > isn't clear. > > > > We don't really leverage these extra functions of NVDEC because it > breaks many assumptions about hwaccels, which are meant to be exact > decoders. > If anything, just fudging the width/height is certainly an API > violation and will likely not be possible as it breaks many > assumptions in the code otherwise, see below. > > > --- > > libavcodec/hevc/hevcdec.c | 8 ++-- > > libavcodec/nvdec.c| 21 + > > 2 files changed, 23 insertions(+), 6 deletions(-) > > > > diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c > > index d915d74d22..d63fc5875f 100644 > > --- a/libavcodec/hevc/hevcdec.c > > +++ b/libavcodec/hevc/hevcdec.c > > @@ -351,8 +351,12 @@ static void export_stream_params(HEVCContext *s, > const > > HEVCSPS *sps) > > avctx->pix_fmt = sps->pix_fmt; > > avctx->coded_width = sps->width; > > avctx->coded_height= sps->height; > > -avctx->width = sps->width - ow->left_offset - > > ow->right_offset; > > -avctx->height = sps->height - ow->top_offset - > > ow->bottom_offset; > > +if (avctx->width <= 0 || avctx->height <= 0) { > > +avctx->width = sps->width; > > +avctx->height = sps->height; > > +} > > +avctx->width = avctx->width - ow->left_offset - > ow->right_offset; > > +avctx->height = avctx->height - ow->top_offset - > ow->bottom_offset; > > You cannot do that here. The frame size can change mid-stream, and > this would suppress any such change. > Additionally, if this code runs more then once, then the offset is > applied repeatedly without actually resetting width/height. > >
Re: [FFmpeg-devel] A change in r_frame_rate values after upgrade to FFmpeg 6.1
I understand that the r_frame_rate is the lowest framerate with which all timestamps can be represented accurately. And I know it is just a guess. But why did the logic behind the calculation change? Changes between 6.0 and 6.1: --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -2864,15 +2872,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) - AVRational time_base = avctx->framerate.num ? av_inv_q(av_mul_q(avctx->framerate, - (AVRational){avctx->ticks_per_frame, 1})) - /* NOHEADER check added to not break existing behavior */ - : ((ic->ctx_flags & AVFMTCTX_NOHEADER) ? (AVRational){0, 1} - : st->time_base); - if ( time_base.den * (int64_t) st->time_base.num - <= time_base.num * (uint64_t)avctx->ticks_per_frame * st->time_base.den) { - av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, -time_base.den, (int64_t)time_base.num * avctx->ticks_per_frame, INT_MAX); + const AVCodecDescriptor *desc = sti->codec_desc; + AVRational mul = (AVRational){ desc && (desc->props & AV_CODEC_PROP_FIELDS) ? 2 : 1, 1 }; + AVRational fr = av_mul_q(avctx->framerate, mul); + if (fr.num && fr.den && av_cmp_q(st->time_base, av_inv_q(fr)) <= 0) { + st->r_frame_rate = fr; } else { st->r_frame_rate.num = st->time_base.den; st->r_frame_rate.den = st->time_base.num; Proposed changes: diff --git a/libavformat/demux.c b/libavformat/demux.c index 6f640b92b1..9d58b440a9 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -2876,7 +2876,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) AVRational fr = av_mul_q(avctx->framerate, mul); if (fr.num && fr.den && av_cmp_q(st->time_base, av_inv_q(fr)) <= 0) { -st->r_frame_rate = fr; +av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, + fr.num, (int64_t)fr.den * mul.num, INT_MAX); } else { st->r_frame_rate.num = st->time_base.den; st->r_frame_rate.den = st->time_base.num; Antoni Bizoń From: ffmpeg-devel on behalf of Anton Khirnov Sent: Sunday, September 15, 2024 2:41 PM To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] A change in r_frame_rate values after upgrade to FFmpeg 6.1 Quoting Antoni Bizoń (2024-09-13 15:20:16) > Hello, > I recently upgraded FFmpeg to version 6.1 in my web application and > encountered a change while running my app's tests. After the upgrade, > ffprobe reported an r_frame_rate of 60/1 instead of the expected 30/1 > for two videos in my test suite. r_frame_rate does not mean what you probably think it means, and is actually NOT guaranteed to be a frame rate of anything. See if avg_frame_rate doesn't work better. -- 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 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 7/8] lavc/vvc_dec: Add hardware decode API
On Mon, 2024-09-23 at 06:37 +0200, Anton Khirnov wrote: > Quoting fei.w.wang-at-intel@ffmpeg.org (2024-09-18 09:10:30) > > static void export_frame_params(VVCContext *s, const > > VVCFrameContext *fc) > > { > > AVCodecContext *c = s->avctx; > > const VVCSPS *sps = fc->ps.sps; > > const VVCPPS *pps = fc->ps.pps; > > > > - c->pix_fmt = sps->pix_fmt; > > - c->coded_width = pps->width; > > - c->coded_height = pps->height; > > - c->width = pps->width - ((pps->r- > > >pps_conf_win_left_offset + pps->r->pps_conf_win_right_offset) << > > sps->hshift[CHROMA]); > > - c->height = pps->height - ((pps->r- > > >pps_conf_win_top_offset + pps->r->pps_conf_win_bottom_offset) << > > sps->vshift[CHROMA]); > > + // Reset HW config if pix_fmt/w/h change. > > + if (s->pix_fmt != sps->pix_fmt || c->coded_width != pps->width > > || c->coded_height != pps->height) { > > + c->coded_width = pps->width; > > + c->coded_height = pps->height; > > + c->pix_fmt = get_format(c, sps); > > + s->pix_fmt = sps->pix_fmt; > > s->pix_fmt is used to detect if frame pixel format is change which is samilar with vp9. Any concern on this? > > Also, get_format() can fail and return AV_PIX_FMT_NONE. Will fix this and FF_ prefix issue in another patch in next version. Thanks Fei > > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/3] aarch64/vvc: Add w_avg
From: Zhao Zhili w_avg_8_2x2_c: 0.0 ( 0.00x) w_avg_8_2x2_neon:0.0 ( 0.00x) w_avg_8_4x4_c: 0.2 ( 1.00x) w_avg_8_4x4_neon:0.0 ( 0.00x) w_avg_8_8x8_c: 1.2 ( 1.00x) w_avg_8_8x8_neon:0.2 ( 5.00x) w_avg_8_16x16_c: 4.2 ( 1.00x) w_avg_8_16x16_neon: 0.8 ( 5.67x) w_avg_8_32x32_c:16.2 ( 1.00x) w_avg_8_32x32_neon: 2.5 ( 6.50x) w_avg_8_64x64_c:64.5 ( 1.00x) w_avg_8_64x64_neon: 9.0 ( 7.17x) w_avg_8_128x128_c: 269.5 ( 1.00x) w_avg_8_128x128_neon: 35.5 ( 7.59x) w_avg_10_2x2_c: 0.2 ( 1.00x) w_avg_10_2x2_neon: 0.2 ( 1.00x) w_avg_10_4x4_c: 0.2 ( 1.00x) w_avg_10_4x4_neon: 0.2 ( 1.00x) w_avg_10_8x8_c: 1.0 ( 1.00x) w_avg_10_8x8_neon: 0.2 ( 4.00x) w_avg_10_16x16_c:4.2 ( 1.00x) w_avg_10_16x16_neon: 0.8 ( 5.67x) w_avg_10_32x32_c: 16.2 ( 1.00x) w_avg_10_32x32_neon: 2.5 ( 6.50x) w_avg_10_64x64_c: 66.2 ( 1.00x) w_avg_10_64x64_neon:10.0 ( 6.62x) w_avg_10_128x128_c:277.8 ( 1.00x) w_avg_10_128x128_neon: 39.8 ( 6.99x) w_avg_12_2x2_c: 0.0 ( 0.00x) w_avg_12_2x2_neon: 0.2 ( 0.00x) w_avg_12_4x4_c: 0.2 ( 1.00x) w_avg_12_4x4_neon: 0.0 ( 0.00x) w_avg_12_8x8_c: 1.2 ( 1.00x) w_avg_12_8x8_neon: 0.5 ( 2.50x) w_avg_12_16x16_c:4.8 ( 1.00x) w_avg_12_16x16_neon: 0.8 ( 6.33x) w_avg_12_32x32_c: 17.0 ( 1.00x) w_avg_12_32x32_neon: 2.8 ( 6.18x) w_avg_12_64x64_c: 64.0 ( 1.00x) w_avg_12_64x64_neon:10.0 ( 6.40x) w_avg_12_128x128_c:269.2 ( 1.00x) w_avg_12_128x128_neon: 42.0 ( 6.41x) --- libavcodec/aarch64/vvc/dsp_init.c | 34 +++ libavcodec/aarch64/vvc/inter.S| 99 +-- 2 files changed, 116 insertions(+), 17 deletions(-) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index ad767d17e2..b39ebb83fc 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -52,6 +52,37 @@ 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_w_avg_8_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + const int width, const int height, + uintptr_t w0_w1, uintptr_t offset_shift); +void ff_vvc_w_avg_10_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + const int width, const int height, + uintptr_t w0_w1, uintptr_t offset_shift); +void ff_vvc_w_avg_12_neon(uint8_t *_dst, const ptrdiff_t _dst_stride, + const int16_t *src0, const int16_t *src1, + const int width, const int height, + uintptr_t w0_w1, uintptr_t offset_shift); +/* When passing arguments to functions, Apple platforms diverge from the ARM64 + * standard ABI, that we can't implement the function directly in asm. + */ +#define W_AVG_FUN(bit_depth) \ +static void vvc_w_avg_ ## bit_depth(uint8_t *dst, const ptrdiff_t dst_stride, \ +const int16_t *src0, const int16_t *src1, const int width, const int height, \ +const int denom, const int w0, const int w1, const int o0, const int o1) \ +{ \ +const int shift = denom + FFMAX(3, 15 - bit_depth); \ +const int offset = ((o0 + o1) * (1 << (bit_depth - 8)) + 1) * (1 << (shift - 1)); \ +uintptr_t w0_w1 = ((uintptr_t)w0 << 32) | (uint32_t)w1; \ +
[FFmpeg-devel] [PATCH v2 3/3] aarch64/vvc: Add dmvr
From: Zhao Zhili dmvr_8_12x20_c: 2.2 ( 1.00x) dmvr_8_12x20_neon: 0.5 ( 4.50x) dmvr_8_20x12_c: 2.0 ( 1.00x) dmvr_8_20x12_neon: 0.2 ( 8.00x) dmvr_8_20x20_c: 3.2 ( 1.00x) dmvr_8_20x20_neon: 0.5 ( 6.50x) dmvr_12_12x20_c: 2.2 ( 1.00x) dmvr_12_12x20_neon: 0.5 ( 4.50x) dmvr_12_20x12_c: 2.2 ( 1.00x) dmvr_12_20x12_neon: 0.5 ( 4.50x) dmvr_12_20x20_c: 3.2 ( 1.00x) dmvr_12_20x20_neon: 0.8 ( 4.33x) --- libavcodec/aarch64/vvc/dsp_init.c | 4 ++ libavcodec/aarch64/vvc/inter.S| 94 ++- 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index 995e26d163..e9bb65bd0f 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -88,6 +88,8 @@ W_AVG_FUN(12) const uint8_t *_src, const ptrdiff_t _src_stride, const int height, \ const intptr_t mx, const intptr_t my, const int width); +DMVR_FUN(, 8) +DMVR_FUN(, 12) DMVR_FUN(hv_, 8) DMVR_FUN(hv_, 10) DMVR_FUN(hv_, 12) @@ -164,6 +166,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) c->inter.avg = ff_vvc_avg_8_neon; c->inter.w_avg = vvc_w_avg_8; +c->inter.dmvr[0][0] = ff_vvc_dmvr_8_neon; c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_8_neon; for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++) @@ -213,6 +216,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) } else if (bd == 12) { c->inter.avg = ff_vvc_avg_12_neon; c->inter.w_avg = vvc_w_avg_12; +c->inter.dmvr[0][0] = ff_vvc_dmvr_12_neon; c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_12_neon; c->alf.filter[LUMA] = alf_filter_luma_12_neon; diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S index a0bb356f07..1b3fb5b468 100644 --- a/libavcodec/aarch64/vvc/inter.S +++ b/libavcodec/aarch64/vvc/inter.S @@ -235,7 +235,7 @@ vvc_avg w_avg, 12 * x5: const intptr_t my * w6: const int width */ -function ff_vvc_dmvr_hv_8_neon, export=1 +function ff_vvc_dmvr_8_neon, export=1 dst .req x0 src .req x1 src_stride .req x2 @@ -243,6 +243,98 @@ function ff_vvc_dmvr_hv_8_neon, export=1 mx .req x4 my .req x5 width .req w6 + +sxtwx6, w6 +mov x7, #(VVC_MAX_PB_SIZE * 2 + 8) +cmp width, #16 +sub src_stride, src_stride, x6 +csetw15, gt // width > 16 +moviv16.8h, #2 // DMVR_SHIFT +sub x7, x7, x6, lsl #1 +1: +cbz w15, 2f +ldr q0, [src], #16 +uxtlv1.8h, v0.8b +uxtl2 v2.8h, v0.16b +ushlv1.8h, v1.8h, v16.8h +ushlv2.8h, v2.8h, v16.8h +stp q1, q2, [dst], #32 +b 3f +2: +ldr d0, [src], #8 +uxtlv1.8h, v0.8b +ushlv1.8h, v1.8h, v16.8h +str q1, [dst], #16 +3: +subsheight, height, #1 +ldr s3, [src], #4 +uxtlv4.8h, v3.8b +ushlv4.4h, v4.4h, v16.4h +st1 {v4.4h}, [dst], x7 + +add src, src, src_stride +b.ne1b + +ret +endfunc + +function ff_vvc_dmvr_12_neon, export=1 +sxtwx6, w6 +mov x7, #(VVC_MAX_PB_SIZE * 2 + 8) +cmp width, #16 +sub src_stride, src_stride, x6, lsl #1 +csetw15, gt // width > 16 +moviv16.4s, #2 // offset4 +sub x7, x7, x6, lsl #1 +1: +cbz w15, 2f +ldp q0, q1, [src], #32 +uxtlv2.4s, v0.4h +uxtl2 v3.4s, v0.8h +uxtlv4.4s, v1.4h +uxtl2 v5.4s, v1.8h +add v2.4s, v2.4s, v16.4s +add v3.4s, v3.4s, v16.4s +add v4.4s, v4.4s, v16.4s +add v5.4s, v5.4s, v16.4s +ushrv2.4s, v2.4s, #2 +ushrv3.4s, v3.4s, #2 +ushrv4.4s, v4.4s, #2 +ushrv5.4s, v5.4s, #2 +uqxtn v2.
[FFmpeg-devel] [PATCH v2 2/3] aarch64/vvc: Add dmvr_hv
From: Zhao Zhili dmvr_hv_8_12x20_c: 8.0 ( 1.00x) dmvr_hv_8_12x20_neon:1.2 ( 6.62x) dmvr_hv_8_20x12_c: 8.0 ( 1.00x) dmvr_hv_8_20x12_neon:0.9 ( 8.37x) dmvr_hv_8_20x20_c: 12.9 ( 1.00x) dmvr_hv_8_20x20_neon:1.7 ( 7.62x) dmvr_hv_10_12x20_c: 7.0 ( 1.00x) dmvr_hv_10_12x20_neon: 1.7 ( 4.09x) dmvr_hv_10_20x12_c: 7.0 ( 1.00x) dmvr_hv_10_20x12_neon: 1.7 ( 4.09x) dmvr_hv_10_20x20_c: 11.2 ( 1.00x) dmvr_hv_10_20x20_neon: 2.7 ( 4.15x) dmvr_hv_12_12x20_c: 6.5 ( 1.00x) dmvr_hv_12_12x20_neon: 1.7 ( 3.79x) dmvr_hv_12_20x12_c: 6.5 ( 1.00x) dmvr_hv_12_20x12_neon: 1.7 ( 3.79x) dmvr_hv_12_20x20_c: 10.2 ( 1.00x) dmvr_hv_12_20x20_neon: 2.2 ( 4.64x) --- libavcodec/aarch64/vvc/dsp_init.c | 12 ++ libavcodec/aarch64/vvc/inter.S| 307 ++ 2 files changed, 319 insertions(+) diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c index b39ebb83fc..995e26d163 100644 --- a/libavcodec/aarch64/vvc/dsp_init.c +++ b/libavcodec/aarch64/vvc/dsp_init.c @@ -83,6 +83,15 @@ W_AVG_FUN(8) W_AVG_FUN(10) W_AVG_FUN(12) +#define DMVR_FUN(fn, bd) \ +void ff_vvc_dmvr_ ## fn ## bd ## _neon(int16_t *dst, \ +const uint8_t *_src, const ptrdiff_t _src_stride, const int height, \ +const intptr_t mx, const intptr_t my, const int width); + +DMVR_FUN(hv_, 8) +DMVR_FUN(hv_, 10) +DMVR_FUN(hv_, 12) + void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) { int cpu_flags = av_get_cpu_flags(); @@ -155,6 +164,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) c->inter.avg = ff_vvc_avg_8_neon; c->inter.w_avg = vvc_w_avg_8; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_8_neon; for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++) c->sao.band_filter[i] = ff_h26x_sao_band_filter_8x8_8_neon; @@ -196,12 +206,14 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd) } else if (bd == 10) { c->inter.avg = ff_vvc_avg_10_neon; c->inter.w_avg = vvc_w_avg_10; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_10_neon; c->alf.filter[LUMA] = alf_filter_luma_10_neon; c->alf.filter[CHROMA] = alf_filter_chroma_10_neon; } else if (bd == 12) { c->inter.avg = ff_vvc_avg_12_neon; c->inter.w_avg = vvc_w_avg_12; +c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_12_neon; c->alf.filter[LUMA] = alf_filter_luma_12_neon; c->alf.filter[CHROMA] = alf_filter_chroma_12_neon; diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S index c4c6ab1a72..a0bb356f07 100644 --- a/libavcodec/aarch64/vvc/inter.S +++ b/libavcodec/aarch64/vvc/inter.S @@ -226,3 +226,310 @@ vvc_avg avg, 12 vvc_avg w_avg, 8 vvc_avg w_avg, 10 vvc_avg w_avg, 12 + +/* x0: int16_t *dst + * x1: const uint8_t *_src + * x2: const ptrdiff_t _src_stride + * w3: const int height + * x4: const intptr_t mx + * x5: const intptr_t my + * w6: const int width + */ +function ff_vvc_dmvr_hv_8_neon, export=1 +dst .req x0 +src .req x1 +src_stride .req x2 +height .req w3 +mx .req x4 +my .req x5 +width .req w6 +tmp0.req x7 +tmp1.req x8 + +sub sp, sp, #(VVC_MAX_PB_SIZE * 4) + +movrel x9, X(ff_vvc_inter_luma_dmvr_filters) +add x12, x9, mx, lsl #1 +ldrbw10, [x12] +ldrbw11, [x12, #1] +mov tmp0, sp +add tmp1, tmp0, #(VVC_MAX_PB_SIZE * 2) +// We know the value are positive +dup v0.8h, w10 // filter_x[0] +dup v1.8h, w11 // filter_x[1] + +add x12, x9, my, lsl #1 +ldrbw10, [x12] +ldrbw11, [x12, #1] +sxtwx6, w6 +moviv30.8h, #(1 << (8 - 7)) // offset1 +moviv31.8h, #8 // offset2 +dup v2.8h, w10 // filter_y[0] +dup v3.8h, w11 // filter_y[1] + +// Valid value for width can only be 8 + 4, 16 + 4 +cmp width, #16 +mov
[FFmpeg-devel] [PATCH v9 4/6] libavcodec/dnxucdec: DNxUncompressed decoder
--- 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 76366b3..87a9cc1 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 aa0fc47..d6ab5f0 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..b5bc795 --- /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 lw; +const size_t sof = 4; + +lw = frame->width; + +for(int y = 0; y < frame->height; y++){ +for(int 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 lw; +const size_t soh = 2; +const uint16_t opaque = 0x3c00; + +lw = frame->width; + +for(int y = 0; y < frame->height; y++){ +for(int 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 bit
[FFmpeg-devel] [PATCH v9 3/6] libavcodec/dnxuc_parser: DNxUncompressed essence parser
--- 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 936fc34..76366b3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1191,6 +1191,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 v9 5/6] doc: DNxUncompressed Changelog and doc entries
--- Changelog | 1 + doc/general_contents.texi | 1 + 2 files changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 49a16da..13e2ac0 100644 --- a/Changelog +++ b/Changelog @@ -19,6 +19,7 @@ version : - Cropping metadata parsing and writing in Matroska and MP4/MOV de/muxers - Intel QSV-accelerated VVC decoding - MediaCodec AAC/AMR-NB/AMR-WB/MP3 decoding +- DNxUncompressed (SMPTE RDD 50) decoder - YUV colorspace negotiation for codecs and filters, obsoleting the YUVJ pixel format - Vulkan H.264 encoder diff --git a/doc/general_contents.texi b/doc/general_contents.texi index 5f22ccd..1e0744b 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -632,6 +632,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".
[FFmpeg-devel] [PATCH v9 6/6] tests: Fate sample tests for DNxUncompressed
--- tests/Makefile | 1 + tests/fate/dnxuc.mak| 40 + tests/ref/fate/dnxuc-cb-rgb-10 | 8 ++ tests/ref/fate/dnxuc-cb-rgb-12 | 8 ++ tests/ref/fate/dnxuc-cb-rgb-8 | 8 ++ tests/ref/fate/dnxuc-cb-rgb-float | 8 ++ tests/ref/fate/dnxuc-cb-rgb-half| 8 ++ tests/ref/fate/dnxuc-cb-yuv422-10 | 8 ++ tests/ref/fate/dnxuc-cb-yuv422-12 | 8 ++ tests/ref/fate/dnxuc-cb-yuv422-8| 8 ++ tests/ref/fate/dnxuc-ramp-rgb-10| 8 ++ tests/ref/fate/dnxuc-ramp-rgb-12| 8 ++ tests/ref/fate/dnxuc-ramp-rgb-8 | 8 ++ tests/ref/fate/dnxuc-ramp-rgb-float | 8 ++ tests/ref/fate/dnxuc-ramp-rgb-half | 8 ++ tests/ref/fate/dnxuc-ramp-yuv422-10 | 8 ++ tests/ref/fate/dnxuc-ramp-yuv422-12 | 8 ++ tests/ref/fate/dnxuc-ramp-yuv422-8 | 8 ++ 18 files changed, 169 insertions(+) create mode 100644 tests/fate/dnxuc.mak create mode 100644 tests/ref/fate/dnxuc-cb-rgb-10 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-12 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-8 create mode 100644 tests/ref/fate/dnxuc-cb-rgb-float create mode 100644 tests/ref/fate/dnxuc-cb-rgb-half create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-10 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-12 create mode 100644 tests/ref/fate/dnxuc-cb-yuv422-8 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-10 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-12 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-8 create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-float create mode 100644 tests/ref/fate/dnxuc-ramp-rgb-half create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-10 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-12 create mode 100644 tests/ref/fate/dnxuc-ramp-yuv422-8 diff --git a/tests/Makefile b/tests/Makefile index 9b70145..e073915 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -172,6 +172,7 @@ include $(SRC_PATH)/tests/fate/dca.mak include $(SRC_PATH)/tests/fate/demux.mak include $(SRC_PATH)/tests/fate/dfa.mak include $(SRC_PATH)/tests/fate/dnxhd.mak +include $(SRC_PATH)/tests/fate/dnxuc.mak include $(SRC_PATH)/tests/fate/dpcm.mak include $(SRC_PATH)/tests/fate/dvvideo.mak include $(SRC_PATH)/tests/fate/ea.mak diff --git a/tests/fate/dnxuc.mak b/tests/fate/dnxuc.mak new file mode 100644 index 000..80ff0e9 --- /dev/null +++ b/tests/fate/dnxuc.mak @@ -0,0 +1,40 @@ +FATE_DNXUC_CB = fate-dnxuc-cb-rgb-8 \ +fate-dnxuc-cb-rgb-10 \ +fate-dnxuc-cb-rgb-12 \ +fate-dnxuc-cb-rgb-half \ +fate-dnxuc-cb-rgb-float \ +fate-dnxuc-cb-yuv422-8 \ +fate-dnxuc-cb-yuv422-10 \ +fate-dnxuc-cb-yuv422-12 + +FATE_DNXUC_RAMP = fate-dnxuc-ramp-rgb-8 \ +fate-dnxuc-ramp-rgb-10 \ +fate-dnxuc-ramp-rgb-12 \ +fate-dnxuc-ramp-rgb-half \ +fate-dnxuc-ramp-rgb-float \ +fate-dnxuc-ramp-yuv422-8 \ +fate-dnxuc-ramp-yuv422-10 \ +fate-dnxuc-ramp-yuv422-12 + +FATE_DNXUC-$(call FRAMECRC, MXF, DNXUC) += $(FATE_DNXUC_CB) $(FATE_DNXUC_RAMP) + +FATE_SAMPLES_FFMPEG += $(FATE_DNXUC-yes) +fate-dnxuc: $(FATE_DNXUC-yes) + +fate-dnxuc-cb-rgb-8: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_8.mxf +fate-dnxuc-cb-rgb-10: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_10.mxf +fate-dnxuc-cb-rgb-12: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_12.mxf +fate-dnxuc-cb-rgb-half: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_half.mxf +fate-dnxuc-cb-rgb-float: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_rgb_float.mxf +fate-dnxuc-cb-yuv422-8: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_yuv422_8.mxf +fate-dnxuc-cb-yuv422-10: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_yuv422_10.mxf +fate-dnxuc-cb-yuv422-12: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/cb_yuv422_12.mxf + +fate-dnxuc-ramp-rgb-8: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_8.mxf +fate-dnxuc-ramp-rgb-10: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_10.mxf +fate-dnxuc-ramp-rgb-12: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_12.mxf +fate-dnxuc-ramp-rgb-half: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_half.mxf +fate-dnxuc-ramp-rgb-float: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_rgb_float.mxf +fate-dnxuc-ramp-yuv422-8: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_yuv422_8.mxf +fate-dnxuc-ramp-yuv422-10: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_yuv422_10.mxf +fate-dnxuc-ramp-yuv422-12: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/dnxuc/ramp_yuv422_12.mxf diff --git a/tests/ref/fate/dnxu
[FFmpeg-devel] [PATCH v9 1/6] libavcodec/: Add ID and desc for DNxUncompressed
Patchset for DNxUncomprressed decoder. v9 includes changes to fix issues mentioned in Marton Balints review. --- 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 03dea57..2452a7b 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 0a8d3be..0abd036 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 v2] vulkan_encode: set the quality level in session parameters
While running this command ./ffmpeg_g -loglevel debug -hwaccel vulkan -init_hw_device vulkan=vk:0,debug=1 -hwaccel_output_format vulkan -i input.y4m -vf 'format=nv12,hwupload' -c:v h264_vulkan -quality 2 output.mp4 -y It hit this validation error: Validation Error: [ VUID-vkCmdEncodeVideoKHR-None-08318 ] Object 0: handle = 0x8f8f, type = VK_OBJECT_TYPE_VIDEO_SESSION_KHR; Object 1: handle = 0xfdfd, type = VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR; | MessageID = 0x5dc3dd39 | vkCmdEncodeVideoKHR(): The currently configured encode quality level (2) for VkVideoSessionKHR 0x8f8f[] does not match the encode quality level (0) VkVideoSessionParametersKHR 0xfdfd[] was created with. The Vulkan spec states: The bound video session parameters object must have been created with the currently set video encode quality level for the bound video session at the time the command is executed on the device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdEncodeVideoKHR-None-08318) This patch adds a new function helper for creating session parameters, which also sets the quality level and it's called by the H.264 and H.265 Vulkan encoders. --- libavcodec/vulkan_encode.c | 34 + libavcodec/vulkan_encode.h | 6 ++ libavcodec/vulkan_encode_h264.c | 19 +- libavcodec/vulkan_encode_h265.c | 19 +- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c index 9a9258ce7b..d187b7cdd3 100644 --- a/libavcodec/vulkan_encode.c +++ b/libavcodec/vulkan_encode.c @@ -1023,3 +1023,37 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext * return 0; } + +int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, + void *codec_params_pnext) +{ +VkResult ret; +FFVulkanFunctions *vk = &ctx->s.vkfn; +FFVulkanContext *s = &ctx->s; + +VkVideoEncodeQualityLevelInfoKHR q_info; +VkVideoSessionParametersCreateInfoKHR session_params_create; + +q_info = (VkVideoEncodeQualityLevelInfoKHR) { +.sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR, +.pNext = codec_params_pnext, +.qualityLevel = ctx->opts.quality, +}; +session_params_create = (VkVideoSessionParametersCreateInfoKHR) { +.sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, +.pNext = &q_info, +.videoSession = ctx->common.session, +.videoSessionParametersTemplate = VK_NULL_HANDLE, +}; + +/* Create session parameters */ +ret = vk->CreateVideoSessionParametersKHR(s->hwctx->act_dev, &session_params_create, + s->hwctx->alloc, &ctx->session_params); +if (ret != VK_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Unable to create Vulkan video session parameters: %s!\n", + ff_vk_ret2str(ret)); +return AVERROR_EXTERNAL; +} + +return 0; +} diff --git a/libavcodec/vulkan_encode.h b/libavcodec/vulkan_encode.h index fd3499dd10..a7a02d5fd0 100644 --- a/libavcodec/vulkan_encode.h +++ b/libavcodec/vulkan_encode.h @@ -245,6 +245,12 @@ int ff_vulkan_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt); */ void ff_vulkan_encode_uninit(FFVulkanEncodeContext *ctx); +/** + * Create session parameters. + */ +int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, + void *codec_params_pnext); + /** * Paperwork. */ diff --git a/libavcodec/vulkan_encode_h264.c b/libavcodec/vulkan_encode_h264.c index af229afe52..9964ba5b8b 100644 --- a/libavcodec/vulkan_encode_h264.c +++ b/libavcodec/vulkan_encode_h264.c @@ -1005,7 +1005,6 @@ static av_cold int base_unit_to_vk(AVCodecContext *avctx, static int create_session_params(AVCodecContext *avctx) { int err; -VkResult ret; VulkanEncodeH264Context *enc = avctx->priv_data; FFVulkanEncodeContext *ctx = &enc->common; FFVulkanContext *s = &ctx->s; @@ -1015,7 +1014,6 @@ static int create_session_params(AVCodecContext *avctx) VkVideoEncodeH264SessionParametersAddInfoKHR h264_params_info; VkVideoEncodeH264SessionParametersCreateInfoKHR h264_params; -VkVideoSessionParametersCreateInfoKHR session_params_create; /* Convert it to Vulkan */ err = base_unit_to_vk(avctx, &vk_units); @@ -1044,23 +1042,8 @@ static int create_session_params(AVCodecContext *avctx) .maxStdPPSCount = 1, .pParametersAddInfo = &h264_params_info, }; -session_params_create = (VkVideoSessionParametersCreateInfoKHR) { -.sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, -.pNext = &h264_params, -.videoSession = ctx->common.session, -.videoSessionParametersTemplate = NU
[FFmpeg-devel] [PATCH] vulkan_encode: set the quality level in session parameters
While running this command ./ffmpeg_g -loglevel debug -hwaccel vulkan -init_hw_device vulkan=vk:0,debug=1 -hwaccel_output_format vulkan -i input.y4m -vf 'format=nv12,hwupload' -c:v h264_vulkan -quality 2 output.mp4 -y It hit this validation error: Validation Error: [ VUID-vkCmdEncodeVideoKHR-None-08318 ] Object 0: handle = 0x8f8f, type = VK_OBJECT_TYPE_VIDEO_SESSION_KHR; Object 1: handle = 0xfdfd, type = VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR; | MessageID = 0x5dc3dd39 | vkCmdEncodeVideoKHR(): The currently configured encode quality level (2) for VkVideoSessionKHR 0x8f8f[] does not match the encode quality level (0) VkVideoSessionParametersKHR 0xfdfd[] was created with. The Vulkan spec states: The bound video session parameters object must have been created with the currently set video encode quality level for the bound video session at the time the command is executed on the device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdEncodeVideoKHR-None-08318) This patch adds a new function helper for creating session parameters, which also sets the quality level and it's called by the H.264 and H.265 Vulkan encoders. --- libavcodec/vulkan_encode.c | 34 + libavcodec/vulkan_encode.h | 6 ++ libavcodec/vulkan_encode_h264.c | 19 +- libavcodec/vulkan_encode_h265.c | 18 + 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c index 9a9258ce7b..05ac4eb2de 100644 --- a/libavcodec/vulkan_encode.c +++ b/libavcodec/vulkan_encode.c @@ -1023,3 +1023,37 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext * return 0; } + +int ff_vulkan_encode_create_session_params (AVCodecContext *avctx, FFVulkanEncodeContext *ctx, +void *codec_params_pnext) +{ +VkResult ret; +FFVulkanFunctions *vk = &ctx->s.vkfn; +FFVulkanContext *s = &ctx->s; + +VkVideoEncodeQualityLevelInfoKHR q_info; +VkVideoSessionParametersCreateInfoKHR session_params_create; + +q_info = (VkVideoEncodeQualityLevelInfoKHR) { +.sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR, +.pNext = codec_params_pnext, +.qualityLevel = ctx->opts.quality, +}; +session_params_create = (VkVideoSessionParametersCreateInfoKHR) { +.sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, +.pNext = &q_info, +.videoSession = ctx->common.session, +.videoSessionParametersTemplate = VK_NULL_HANDLE, +}; + +/* Create session parameters */ +ret = vk->CreateVideoSessionParametersKHR(s->hwctx->act_dev, &session_params_create, + s->hwctx->alloc, &ctx->session_params); +if (ret != VK_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Unable to create Vulkan video session parameters: %s!\n", + ff_vk_ret2str(ret)); +return AVERROR_EXTERNAL; +} + +return 0; +} diff --git a/libavcodec/vulkan_encode.h b/libavcodec/vulkan_encode.h index fd3499dd10..a7a02d5fd0 100644 --- a/libavcodec/vulkan_encode.h +++ b/libavcodec/vulkan_encode.h @@ -245,6 +245,12 @@ int ff_vulkan_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt); */ void ff_vulkan_encode_uninit(FFVulkanEncodeContext *ctx); +/** + * Create session parameters. + */ +int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, + void *codec_params_pnext); + /** * Paperwork. */ diff --git a/libavcodec/vulkan_encode_h264.c b/libavcodec/vulkan_encode_h264.c index af229afe52..72bed94e78 100644 --- a/libavcodec/vulkan_encode_h264.c +++ b/libavcodec/vulkan_encode_h264.c @@ -1005,7 +1005,6 @@ static av_cold int base_unit_to_vk(AVCodecContext *avctx, static int create_session_params(AVCodecContext *avctx) { int err; -VkResult ret; VulkanEncodeH264Context *enc = avctx->priv_data; FFVulkanEncodeContext *ctx = &enc->common; FFVulkanContext *s = &ctx->s; @@ -1015,7 +1014,6 @@ static int create_session_params(AVCodecContext *avctx) VkVideoEncodeH264SessionParametersAddInfoKHR h264_params_info; VkVideoEncodeH264SessionParametersCreateInfoKHR h264_params; -VkVideoSessionParametersCreateInfoKHR session_params_create; /* Convert it to Vulkan */ err = base_unit_to_vk(avctx, &vk_units); @@ -1044,23 +1042,8 @@ static int create_session_params(AVCodecContext *avctx) .maxStdPPSCount = 1, .pParametersAddInfo = &h264_params_info, }; -session_params_create = (VkVideoSessionParametersCreateInfoKHR) { -.sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, -.pNext = &h264_params, -.videoSession = ctx->common.session, -.videoSessionParametersTemplate = N
Re: [FFmpeg-devel] [PATCH] avcodec/videotoolbox: add AV1 hardware acceleration
> On Sep 21, 2024, at 05:39, Martin Storsjö wrote: > > From: Jan Ekström > > Co-authored-by: Ruslan Chernenko > Co-authored-by: Martin Storsjö > --- > This is a touched up version of Jan and Ruslan's patches for > AV1 hwaccel via videotoolbox; I tried to polish the code a little > by not overwriting avctx->extradata in > ff_videotoolbox_av1c_extradata_create, and by factorizing out a > new function ff_videotoolbox_buffer_append. LGTM, although I don’t have a device with AV1 support. > --- > configure | 4 ++ > libavcodec/Makefile | 1 + > libavcodec/av1dec.c | 10 +++ > libavcodec/hwaccels.h | 1 + > libavcodec/videotoolbox.c | 34 +++ > libavcodec/videotoolbox_av1.c | 112 ++ > libavcodec/vt_internal.h | 4 ++ > 7 files changed, 166 insertions(+) > create mode 100644 libavcodec/videotoolbox_av1.c > > diff --git a/configure b/configure > index 8fbf3772a8..bc244d7ca2 100755 > --- a/configure > +++ b/configure > @@ -2464,6 +2464,7 @@ TYPES_LIST=" > kCMVideoCodecType_HEVC > kCMVideoCodecType_HEVCWithAlpha > kCMVideoCodecType_VP9 > +kCMVideoCodecType_AV1 > kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange > kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange > kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange > @@ -3171,6 +3172,8 @@ av1_vaapi_hwaccel_deps="vaapi > VADecPictureParameterBufferAV1_bit_depth_idx" > av1_vaapi_hwaccel_select="av1_decoder" > av1_vdpau_hwaccel_deps="vdpau VdpPictureInfoAV1" > av1_vdpau_hwaccel_select="av1_decoder" > +av1_videotoolbox_hwaccel_deps="videotoolbox" > +av1_videotoolbox_hwaccel_select="av1_decoder" > av1_vulkan_hwaccel_deps="vulkan" > av1_vulkan_hwaccel_select="av1_decoder" > h263_vaapi_hwaccel_deps="vaapi" > @@ -6690,6 +6693,7 @@ enabled videotoolbox && { > check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVC > "-framework CoreMedia" > check_func_headers CoreMedia/CMFormatDescription.h > kCMVideoCodecType_HEVCWithAlpha "-framework CoreMedia" > check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_VP9 > "-framework CoreMedia" > +check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_AV1 > "-framework CoreMedia" > check_func_headers CoreVideo/CVPixelBuffer.h > kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo" > check_func_headers CoreVideo/CVPixelBuffer.h > kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange "-framework CoreVideo" > check_func_headers CoreVideo/CVPixelBuffer.h > kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange "-framework CoreVideo" > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 936fc3415a..fa6d30a8b3 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1007,6 +1007,7 @@ OBJS-$(CONFIG_AV1_D3D12VA_HWACCEL)+= > dxva2_av1.o d3d12va_av1.o > OBJS-$(CONFIG_AV1_NVDEC_HWACCEL) += nvdec_av1.o > OBJS-$(CONFIG_AV1_VAAPI_HWACCEL) += vaapi_av1.o > OBJS-$(CONFIG_AV1_VDPAU_HWACCEL) += vdpau_av1.o > +OBJS-$(CONFIG_AV1_VIDEOTOOLBOX_HWACCEL) += videotoolbox_av1.o > OBJS-$(CONFIG_AV1_VULKAN_HWACCEL) += vulkan_decode.o vulkan_av1.o > OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o > OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o > diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c > index 1d5b9ef4f4..0fad09af74 100644 > --- a/libavcodec/av1dec.c > +++ b/libavcodec/av1dec.c > @@ -541,6 +541,7 @@ static int get_pixel_format(AVCodecContext *avctx) > CONFIG_AV1_NVDEC_HWACCEL + \ > CONFIG_AV1_VAAPI_HWACCEL + \ > CONFIG_AV1_VDPAU_HWACCEL + \ > + CONFIG_AV1_VIDEOTOOLBOX_HWACCEL + \ > CONFIG_AV1_VULKAN_HWACCEL) > enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; > > @@ -568,6 +569,9 @@ static int get_pixel_format(AVCodecContext *avctx) > #if CONFIG_AV1_VDPAU_HWACCEL > *fmtp++ = AV_PIX_FMT_VDPAU; > #endif > +#if CONFIG_AV1_VIDEOTOOLBOX_HWACCEL > +*fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX; > +#endif > #if CONFIG_AV1_VULKAN_HWACCEL > *fmtp++ = AV_PIX_FMT_VULKAN; > #endif > @@ -592,6 +596,9 @@ static int get_pixel_format(AVCodecContext *avctx) > #if CONFIG_AV1_VDPAU_HWACCEL > *fmtp++ = AV_PIX_FMT_VDPAU; > #endif > +#if CONFIG_AV1_VIDEOTOOLBOX_HWACCEL > +*fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX; > +#endif > #if CONFIG_AV1_VULKAN_HWACCEL > *fmtp++ = AV_PIX_FMT_VULKAN; > #endif > @@ -1594,6 +1601,9 @@ const FFCodec ff_av1_decoder = { > #if CONFIG_AV1_VDPAU_HWACCEL > HWACCEL_VDPAU(av1), > #endif > +#if CONFIG_AV1_VIDEOTOOLBOX_HWACCEL > +HWACCEL_VIDEOTOOLBOX(av1), > +#endif > #if CONFIG_AV1_VULKAN_HWACCEL > HWACCEL_VULKAN(av1), > #endif > diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h > index 5171e4c7d7..2b9bdc8fc9 100644 > --- a/libavcodec/hwaccels.h > +++ b/libavcod
Re: [FFmpeg-devel] [PATCH 7/7] lavfi/buffersink: deprecate functions obsoleted by AV_BUFFERSINK_FLAG_PARAMS
Anton Khirnov (12024-09-23): > That is all av_buffersink_get_*() except type and frame_rate, for which > AVFrame does not currently have fields. NAK: an API that requires an allocated AVFrame to retrieve the parameters is significantly worst than the existing. -- Nicolas George ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/2] avformat/internal: Add ff_get_frame_filename
From: Zhao Zhili It's similar to av_get_frame_filename2 but with int64_t number support. Make av_get_frame_filename* a wrapper over ff_get_frame_filename. Co-authored-by: Filip Mašić --- libavformat/internal.h | 16 libavformat/utils.c| 11 --- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 8e8971bfeb..6c026f08a0 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -745,6 +745,22 @@ void ff_format_set_url(AVFormatContext *s, char *url); */ int ff_match_url_ext(const char *url, const char *extensions); +/** + * Return in 'buf' the path with '%d' replaced by a number. + * + * Also handles the '%0nd' format where 'n' is the total number + * of digits and '%%'. + * + * @param buf destination buffer + * @param buf_size destination buffer size + * @param path path with substitution template + * @param number the number to substitute + * @param flags AV_FRAME_FILENAME_FLAGS_* + * @return 0 if OK, -1 on format error + */ +int ff_get_frame_filename(char *buf, int buf_size, const char *path, + int64_t number, int flags); + struct FFOutputFormat; struct FFInputFormat; void avpriv_register_devices(const struct FFOutputFormat * const o[], diff --git a/libavformat/utils.c b/libavformat/utils.c index e9ded627ad..e892e8bde7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -280,7 +280,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts) return (sec * 100) + usec; } -int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) +int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags) { const char *p; char *q, buf1[20], c; @@ -313,7 +313,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number percentd_found = 1; if (number < 0) nd += 1; -snprintf(buf1, sizeof(buf1), "%0*d", nd, number); +snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number); len = strlen(buf1); if ((q - buf + len) > buf_size - 1) goto fail; @@ -338,9 +338,14 @@ fail: return -1; } +int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) +{ +return ff_get_frame_filename(buf, buf_size, path, number, flags); +} + int av_get_frame_filename(char *buf, int buf_size, const char *path, int number) { -return av_get_frame_filename2(buf, buf_size, path, number, 0); +return ff_get_frame_filename(buf, buf_size, path, number, 0); } void av_url_split(char *proto, int proto_size, -- 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".
Re: [FFmpeg-devel] A change in r_frame_rate values after upgrade to FFmpeg 6.1
On Mon, Sep 23, 2024 at 4:45 PM Kieran Kunhya via ffmpeg-devel < ffmpeg-devel@ffmpeg.org> wrote: > On Mon, Sep 23, 2024 at 3:27 PM Anton Khirnov wrote: > > > > Quoting Antoni Bizoń (2024-09-23 10:09:51) > > > I understand that the r_frame_rate is the lowest framerate with which > > > all timestamps can be represented accurately. And I know it is just a > > > guess. But why did the logic behind the calculation change? > > > > Because you're most likely using a codec like H.264 or MPEG-2 that > > allows individually coded fields. In that case the timebase must be > > accurate enough to represent the field rate (i.e. double the frame > > rate), but the code doing this was previously unreliable, so you'd > > sometimes get r_frame_rate equal to the frame rate rather than field > > rate. That is not the case anymore. > > This is bizarre and kafkaesque to say the least. > Should we schedule deprecation for one of the two fields? I agree it's confusing for end users to check in two fields. -- Vittorio ___ 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 7/7] lavfi/buffersink: deprecate functions obsoleted by AV_BUFFERSINK_FLAG_PARAMS
Anton Khirnov (12024-09-23): > I fail to see … > how that is a problem, since you need an allocated AVFrame > to use the buffersink API anyway. Not at the same point in code. > Not to mention that even if one allocates a dedicated AVFrame for the > parameters, the cost is trivial compared to actual filtering since it's > typically only done once per filtergraph. CPU time is not the only issue. > On the other hand, the cost of a bloated symbol table is paid by > everyone whether they use the functions or not. Benchmark? -- “I dont see why” isn't an argument. Proposing better is. ___ 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/7] lavfi/buffersink: add a flag for retrieving stream parameters
Anton Khirnov (12024-09-23): > This way, av_buffersink_get_frame_flags() can replace almost all > av_buffersink_get_*(), including some future parameters we will want to > export. > --- > doc/APIchanges | 1 + > libavfilter/buffersink.c | 47 > libavfilter/buffersink.h | 16 -- > 3 files changed, 62 insertions(+), 2 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index b392c756d7..5ddd7189f8 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -4,6 +4,7 @@ API changes, most recent first: > > 2024-09-xx - xx - lavfi 10.4.100 >Buffersink now sets AVFrame.time_base on the frames it outputs. > + Add AV_BUFFERSINK_FLAG_PARAMS. > > 2024-09-23 - xx - lavc 61.18.100 - avcodec.h >Add a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. > diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c > index 575075ff47..d9cd074f17 100644 > --- a/libavfilter/buffersink.c > +++ b/libavfilter/buffersink.c > @@ -128,8 +128,55 @@ static int get_frame_internal(AVFilterContext *ctx, > AVFrame *frame, int flags, i > } > } > > +static int get_frame_params(AVFilterContext *ctx, AVFrame *frame) > +{ > +FilterLink *l = ff_filter_link(ctx->inputs[0]); > +int ret = 0; > + > +frame->time_base = l->pub.time_base; > +frame->format= l->pub.format; > + > +switch (l->pub.type) { > +case AVMEDIA_TYPE_AUDIO: > +ret = av_channel_layout_copy(&frame->ch_layout, &l->pub.ch_layout); > +if (ret < 0) > +goto fail; > + > +frame->sample_rate = l->pub.sample_rate; > +break; > +case AVMEDIA_TYPE_VIDEO: > +frame->width= l->pub.w; > +frame->height = l->pub.h; > +frame->sample_aspect_ratio = l->pub.sample_aspect_ratio; > +frame->colorspace = l->pub.colorspace; > +frame->color_range = l->pub.color_range; > +break; > +default: av_assert0(0); > +} > + > +if (l->hw_frames_ctx) { > +frame->hw_frames_ctx = av_buffer_ref(l->hw_frames_ctx); > +if (!frame->hw_frames_ctx) { > +ret = AVERROR(ENOMEM); > +goto fail; > +} > +} > + > +return 0; > +fail: > +av_frame_unref(frame); > +return ret; > +} > + > int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, > AVFrame *frame, int flags) > { > +if (flags & AV_BUFFERSINK_FLAG_PARAMS) { > +if (flags & ~AV_BUFFERSINK_FLAG_PARAMS) > +return AVERROR(EINVAL); > + > +return get_frame_params(ctx, frame); > +} > + > return get_frame_internal(ctx, frame, flags, >ff_filter_link(ctx->inputs[0])->min_samples); > } > diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h > index 361d603679..9c4468af5b 100644 > --- a/libavfilter/buffersink.h > +++ b/libavfilter/buffersink.h > @@ -87,14 +87,26 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, > AVFrame *frame, int flag > * reference, but not remove it from the buffer. This is useful if you > * need only to read a video/samples buffer, without to fetch it. > */ > -#define AV_BUFFERSINK_FLAG_PEEK 1 > +#define AV_BUFFERSINK_FLAG_PEEK (1 << 0) > > /** > * Tell av_buffersink_get_buffer_ref() not to request a frame from its input. > * If a frame is already buffered, it is read (and removed from the buffer), > * but if no frame is present, return AVERROR(EAGAIN). > */ > -#define AV_BUFFERSINK_FLAG_NO_REQUEST 2 > +#define AV_BUFFERSINK_FLAG_NO_REQUEST (1 << 1) > + > +/** > + * Retrieve stream parameters rather than frame data. > + * > + * When this flag is set, av_buffersink_get_frame_flags() fills the non-data > + * fields of the supplied frame without causing any filtergraph activity. > + * > + * @note While frame data will be NULL, certain other allocated fields may be > + * filled (e.g. ch_layout, hw_frames_ctx), so the frame should still be > + * unreffed before reuse. > + */ > +#define AV_BUFFERSINK_FLAG_PARAMS (1 << 2) NAK, this is one of the worst API design I can think of for this task. > > /** > * Set the frame size for an audio buffer sink. -- Nicolas George ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/7] fftools/ffplay: use AV_BUFFERSINK_FLAG_PARAMS
Anton Khirnov (12024-09-23): > --- > fftools/ffplay.c | 20 +--- > 1 file changed, 17 insertions(+), 3 deletions(-) What an enhancement! -- “I dont see why” isn't an argument. ___ 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 2/2] avformat/img2enc: Fix integer truncation when frame_pts is enabled
From: Zhao Zhili --- libavformat/img2enc.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index 526a11e5ee..41638d92b8 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -160,13 +160,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EINVAL); } } else if (img->frame_pts) { -if (av_get_frame_filename2(filename, sizeof(filename), s->url, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { +if (ff_get_frame_filename(filename, sizeof(filename), s->url, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames."); return AVERROR(EINVAL); } -} else if (av_get_frame_filename2(filename, sizeof(filename), s->url, - img->img_number, - AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { +} else if (ff_get_frame_filename(filename, sizeof(filename), s->url, + img->img_number, + AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) { if (img->img_number == img->start_img_number) { av_log(s, AV_LOG_WARNING, "The specified filename '%s' does not contain an image sequence pattern or a pattern is invalid.\n", s->url); av_log(s, AV_LOG_WARNING, -- 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".
Re: [FFmpeg-devel] [PATCH 7/7] lavfi/buffersink: deprecate functions obsoleted by AV_BUFFERSINK_FLAG_PARAMS
Quoting Nicolas George (2024-09-23 17:56:47) > Anton Khirnov (12024-09-23): > > That is all av_buffersink_get_*() except type and frame_rate, for which > > AVFrame does not currently have fields. > > NAK: an API that requires an allocated AVFrame to retrieve the > parameters is significantly worst than the existing. I fail to see how that is a problem, since you need an allocated AVFrame to use the buffersink API anyway. Not to mention that even if one allocates a dedicated AVFrame for the parameters, the cost is trivial compared to actual filtering since it's typically only done once per filtergraph. On the other hand, the cost of a bloated symbol table is paid by everyone whether they use the functions or not. -- 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] avcodec/hevcdec: add support for sps_infer_scaling_list_flag == 1
Signed-off-by: James Almer --- Untested, as i can't find a sample that triggers this code. libavcodec/hevc/cabac.c | 3 ++- libavcodec/hevc/ps.c| 18 +- libavcodec/hevc/ps.h| 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c index 892dd1c215..ac2b52986e 100644 --- a/libavcodec/hevc/cabac.c +++ b/libavcodec/hevc/cabac.c @@ -1084,8 +1084,9 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps, dc_scale = 16; if (sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) { +const HEVCLayerContext *const l = &s->layers[sps->sps_scaling_list_ref_layer_id]; const ScalingList *sl = pps->scaling_list_data_present_flag ? -&pps->scaling_list : &sps->scaling_list; +&pps->scaling_list : &l->sps->scaling_list; int matrix_id = lc->cu.pred_mode != MODE_INTRA; matrix_id = 3 * matrix_id + c_idx; diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c index f18b88489b..64b3089967 100644 --- a/libavcodec/hevc/ps.c +++ b/libavcodec/hevc/ps.c @@ -1373,14 +1373,22 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, sps->scaling_list_enabled = get_bits1(gb); if (sps->scaling_list_enabled) { +int sps_infer_scaling_list_flag = 0; + set_default_scaling_list_data(&sps->scaling_list); -if (multi_layer_ext && get_bits1(gb)) { // sps_infer_scaling_list_flag -av_log(avctx, AV_LOG_ERROR, "sps_infer_scaling_list_flag=1 not supported\n"); -return AVERROR_PATCHWELCOME; -} +if (multi_layer_ext) +sps_infer_scaling_list_flag = get_bits1(gb); -if (get_bits1(gb)) { +sps->sps_scaling_list_ref_layer_id = 0; +if (sps_infer_scaling_list_flag) { +sps->sps_scaling_list_ref_layer_id = get_bits(gb, 6); +if (sps->sps_scaling_list_ref_layer_id >= HEVC_VPS_MAX_LAYERS) { +av_log(avctx, AV_LOG_ERROR, "Invalid value %d for sps_scaling_list_ref_layer_id", + sps->sps_scaling_list_ref_layer_id); +return AVERROR_INVALIDDATA; +} +} else if (get_bits1(gb)) { ret = scaling_list_data(gb, avctx, &sps->scaling_list, sps); if (ret < 0) return ret; diff --git a/libavcodec/hevc/ps.h b/libavcodec/hevc/ps.h index 6f5b1f8755..aa4326554c 100644 --- a/libavcodec/hevc/ps.h +++ b/libavcodec/hevc/ps.h @@ -277,6 +277,7 @@ typedef struct HEVCSPS { VUI vui; PTL ptl; +int sps_scaling_list_ref_layer_id; ScalingList scaling_list; unsigned int nb_st_rps; -- 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] avcodec/hevcdec: add support for sps_infer_scaling_list_flag == 1
Quoting James Almer (2024-09-23 18:35:35) > Signed-off-by: James Almer > --- > Untested, as i can't find a sample that triggers this code. > > libavcodec/hevc/cabac.c | 3 ++- > libavcodec/hevc/ps.c| 18 +- > libavcodec/hevc/ps.h| 1 + > 3 files changed, 16 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c > index 892dd1c215..ac2b52986e 100644 > --- a/libavcodec/hevc/cabac.c > +++ b/libavcodec/hevc/cabac.c > @@ -1084,8 +1084,9 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, > const HEVCPPS *pps, > dc_scale = 16; > > if (sps->scaling_list_enabled && !(transform_skip_flag && > log2_trafo_size > 2)) { > +const HEVCLayerContext *const l = > &s->layers[sps->sps_scaling_list_ref_layer_id]; > const ScalingList *sl = pps->scaling_list_data_present_flag ? > -&pps->scaling_list : &sps->scaling_list; > +&pps->scaling_list : &l->sps->scaling_list; You need to check that the layer is active and actually has an SPS. > int matrix_id = lc->cu.pred_mode != MODE_INTRA; > > matrix_id = 3 * matrix_id + c_idx; > diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c > index f18b88489b..64b3089967 100644 > --- a/libavcodec/hevc/ps.c > +++ b/libavcodec/hevc/ps.c > @@ -1373,14 +1373,22 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext > *gb, unsigned int *sps_id, > > sps->scaling_list_enabled = get_bits1(gb); > if (sps->scaling_list_enabled) { > +int sps_infer_scaling_list_flag = 0; > + > set_default_scaling_list_data(&sps->scaling_list); > > -if (multi_layer_ext && get_bits1(gb)) { // > sps_infer_scaling_list_flag > -av_log(avctx, AV_LOG_ERROR, "sps_infer_scaling_list_flag=1 not > supported\n"); > -return AVERROR_PATCHWELCOME; > -} > +if (multi_layer_ext) > +sps_infer_scaling_list_flag = get_bits1(gb); > > -if (get_bits1(gb)) { > +sps->sps_scaling_list_ref_layer_id = 0; > +if (sps_infer_scaling_list_flag) { > +sps->sps_scaling_list_ref_layer_id = get_bits(gb, 6); > +if (sps->sps_scaling_list_ref_layer_id >= HEVC_VPS_MAX_LAYERS) { This value is nuh_layer_id of the reference layer, but you're using it as an index into the VPS layer list. Mapping nuh_layer_id to VPS layer indices is done via vps->layer_idx. > +av_log(avctx, AV_LOG_ERROR, "Invalid value %d for > sps_scaling_list_ref_layer_id", > + sps->sps_scaling_list_ref_layer_id); > +return AVERROR_INVALIDDATA; > +} > +} else if (get_bits1(gb)) { > ret = scaling_list_data(gb, avctx, &sps->scaling_list, sps); > if (ret < 0) > return ret; > diff --git a/libavcodec/hevc/ps.h b/libavcodec/hevc/ps.h > index 6f5b1f8755..aa4326554c 100644 > --- a/libavcodec/hevc/ps.h > +++ b/libavcodec/hevc/ps.h > @@ -277,6 +277,7 @@ typedef struct HEVCSPS { > VUI vui; > PTL ptl; > > +int sps_scaling_list_ref_layer_id; Leading sps_ is redundant. Also might be better to store the index rather than layer id. Overall I'm not sure it's worth it to support something for which no samples are known to exist. -- 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] avcodec/hevcdec: add support for sps_infer_scaling_list_flag == 1
On 9/23/2024 2:07 PM, Anton Khirnov wrote: Quoting James Almer (2024-09-23 18:35:35) Signed-off-by: James Almer --- Untested, as i can't find a sample that triggers this code. libavcodec/hevc/cabac.c | 3 ++- libavcodec/hevc/ps.c| 18 +- libavcodec/hevc/ps.h| 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c index 892dd1c215..ac2b52986e 100644 --- a/libavcodec/hevc/cabac.c +++ b/libavcodec/hevc/cabac.c @@ -1084,8 +1084,9 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps, dc_scale = 16; if (sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) { +const HEVCLayerContext *const l = &s->layers[sps->sps_scaling_list_ref_layer_id]; const ScalingList *sl = pps->scaling_list_data_present_flag ? -&pps->scaling_list : &sps->scaling_list; +&pps->scaling_list : &l->sps->scaling_list; You need to check that the layer is active and actually has an SPS. int matrix_id = lc->cu.pred_mode != MODE_INTRA; matrix_id = 3 * matrix_id + c_idx; diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c index f18b88489b..64b3089967 100644 --- a/libavcodec/hevc/ps.c +++ b/libavcodec/hevc/ps.c @@ -1373,14 +1373,22 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, sps->scaling_list_enabled = get_bits1(gb); if (sps->scaling_list_enabled) { +int sps_infer_scaling_list_flag = 0; + set_default_scaling_list_data(&sps->scaling_list); -if (multi_layer_ext && get_bits1(gb)) { // sps_infer_scaling_list_flag -av_log(avctx, AV_LOG_ERROR, "sps_infer_scaling_list_flag=1 not supported\n"); -return AVERROR_PATCHWELCOME; -} +if (multi_layer_ext) +sps_infer_scaling_list_flag = get_bits1(gb); -if (get_bits1(gb)) { +sps->sps_scaling_list_ref_layer_id = 0; +if (sps_infer_scaling_list_flag) { +sps->sps_scaling_list_ref_layer_id = get_bits(gb, 6); +if (sps->sps_scaling_list_ref_layer_id >= HEVC_VPS_MAX_LAYERS) { This value is nuh_layer_id of the reference layer, but you're using it as an index into the VPS layer list. Mapping nuh_layer_id to VPS layer indices is done via vps->layer_idx. +av_log(avctx, AV_LOG_ERROR, "Invalid value %d for sps_scaling_list_ref_layer_id", + sps->sps_scaling_list_ref_layer_id); +return AVERROR_INVALIDDATA; +} +} else if (get_bits1(gb)) { ret = scaling_list_data(gb, avctx, &sps->scaling_list, sps); if (ret < 0) return ret; diff --git a/libavcodec/hevc/ps.h b/libavcodec/hevc/ps.h index 6f5b1f8755..aa4326554c 100644 --- a/libavcodec/hevc/ps.h +++ b/libavcodec/hevc/ps.h @@ -277,6 +277,7 @@ typedef struct HEVCSPS { VUI vui; PTL ptl; +int sps_scaling_list_ref_layer_id; Leading sps_ is redundant. Also might be better to store the index rather than layer id. Overall I'm not sure it's worth it to support something for which no samples are known to exist. Ok. We should request a sample then, and not just return PATCHWELCOME. 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] avcodec/videotoolbox: add AV1 hardware acceleration
On Mon, Sep 23, 2024 at 6:07 AM Zhao Zhili wrote: > > > > > On Sep 21, 2024, at 05:39, Martin Storsjö wrote: > > > > From: Jan Ekström > > > > Co-authored-by: Ruslan Chernenko > > Co-authored-by: Martin Storsjö > > --- > > This is a touched up version of Jan and Ruslan's patches for > > AV1 hwaccel via videotoolbox; I tried to polish the code a little > > by not overwriting avctx->extradata in > > ff_videotoolbox_av1c_extradata_create, and by factorizing out a > > new function ff_videotoolbox_buffer_append. > > LGTM, although I don’t have a device with AV1 support. I've asked for some testing from users with M3 MacBooks and it appears to have problems with certain resolutions (notably 4K). https://github.com/moonlight-stream/moonlight-qt/issues/1125 It's possible this is a Moonlight bug, but that seems unlikely because VideoToolbox HEVC decoding works fine at 4K and VideoToolbox AV1 works at 1080p and other resolutions. ___ 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 22/23] tests/fate/hevc: add a test for switching between single and multi-view
> On Sep 14, 2024, at 18:45, Anton Khirnov wrote: > > --- > tests/fate/hevc.mak | 10 ++ > tests/ref/fate/hevc-mv-switch | 172 ++ > 2 files changed, 182 insertions(+) > create mode 100644 tests/ref/fate/hevc-mv-switch Fate break on macOS. https://github.com/quink-black/FFmpeg/actions/runs/10999185735/job/30538808619 > > diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak > index df827d821f..2511730edf 100644 > --- a/tests/fate/hevc.mak > +++ b/tests/fate/hevc.mak > @@ -276,6 +276,16 @@ FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-pir > fate-hevc-mv-nuh-layer-id: CMD = framecrc -i > $(TARGET_SAMPLES)/hevc/mv_nuh_layer_id.bit -map 0:view:all > FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-mv-nuh-layer-id > > +# NB: $\ at the end of line joins lines without adding whitespace; > +# this trick is recommended by GNU make manual > +fate-hevc-mv-switch: INPUT = \ > +$(TARGET_SAMPLES)/hevc-conformance/LS_A_Orange_2.bit|$\ > +$(TARGET_SAMPLES)/hevc/mv_nuh_layer_id.bit|$\ > +$(TARGET_SAMPLES)/hevc-conformance/NoOutPrior_B_Qualcomm_1.bit|$\ > +$(TARGET_SAMPLES)/hevc-conformance/MVHEVCS_A.bit > +fate-hevc-mv-switch: CMD = framecrc -i "concat:$(INPUT)" -fps_mode > passthrough -map 0:vidx:0 -map 0:vidx:1 > +FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, CONCAT_PROTOCOL) += > fate-hevc-mv-switch > + > FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes) > FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes) > > diff --git a/tests/ref/fate/hevc-mv-switch b/tests/ref/fate/hevc-mv-switch > new file mode 100644 > index 00..0fc3630637 > --- /dev/null > +++ b/tests/ref/fate/hevc-mv-switch > @@ -0,0 +1,172 @@ > +#tb 0: 1/25 > +#media_type 0: video > +#codec_id 0: rawvideo > +#dimensions 0: 416x240 > +#sar 0: 0/1 > +#tb 1: 1/25 > +#media_type 1: video > +#codec_id 1: rawvideo > +#dimensions 1: 128x128 > +#sar 1: 0/1 > +0, 0, 0,1, 149760, 0x94a51701 > +0, 1, 1,1, 149760, 0x67c71885 > +0, 2, 2,1, 149760, 0x218f1751 > +0, 3, 3,1, 149760, 0x56951bef > +0, 4, 4,1, 149760, 0x76aec81e > +0, 5, 5,1, 149760, 0x20df61ac > +0, 6, 6,1, 149760, 0x2eacf616 > +0, 7, 7,1, 149760, 0x06322ce2 > +0, 8, 8,1, 149760, 0xf14aa104 > +0, 9, 9,1, 149760, 0xc948dcba > +1, 10, 10,1,24576, 0xf8f638da > +0, 11, 11,1, 149760, 0x674e34b1 > +1, 12, 12,1,24576, 0xd22675a4 > +0, 13, 13,1, 149760, 0x41d3acd6 > +1, 14, 14,1,24576, 0x60da42e6 > +0, 15, 15,1, 149760, 0x55a5b835 > +1, 16, 16,1,24576, 0xe0577f6e > +0, 17, 17,1, 149760, 0xc6958049 > +1, 18, 18,1,24576, 0x8d9944bd > +0, 19, 19,1, 149760, 0x94b37050 > +0, 20, 20,1, 149760, 0xed72a560 > +0, 21, 21,1, 149760, 0xd0ccac61 > +0, 22, 22,1, 149760, 0x6cc2d7fa > +0, 23, 23,1, 149760, 0x3a02b5ba > +0, 24, 24,1, 149760, 0xce7ef09c > +0, 25, 25,1, 149760, 0xa518fc05 > +0, 26, 26,1, 149760, 0x01d238fe > +0, 27, 27,1, 149760, 0x5f5012fa > +0, 28, 28,1, 149760, 0x5b8e7405 > +0, 29, 29,1, 149760, 0xcc2e5b33 > +0, 30, 30,1, 149760, 0x590a6890 > +0, 31, 31,1, 149760, 0x9c7b189f > +0, 32, 32,1, 149760, 0xd0752ef4 > +0, 33, 33,1, 149760, 0x367513ce > +0, 34, 34,1, 149760, 0xb64c209d > +0, 35, 35,1, 149760, 0x6e50994c > +0, 36, 36,1, 149760, 0x8276cce4 > +0, 37, 37,1, 149760, 0xb292ac8f > +0, 38, 38,1, 149760, 0x57de9d2c > +0, 39, 39,1, 149760, 0xe8533f38 > +0, 40, 40,1, 149760, 0xde9b536d > +0, 41, 41,1, 149760, 0x83173b1d > +0, 42, 42,1, 149760, 0x853a83a4 > +0, 43, 43,1, 149760, 0x481af1bf > +0, 44, 44,1, 149760, 0x27221abb > +0, 45, 45,1, 149760, 0x094eac00 > +0, 46, 46,1, 149760, 0x3f3a27c8 > +0, 47, 47,1, 149760, 0x8f19b2af > +0, 48, 48,1, 149760, 0x93e7e591 > +0, 49, 49,1, 149760, 0x0c531ab8 > +0, 50, 50,1, 149760, 0x3456ef8a > +0,
Re: [FFmpeg-devel] [PATCH] avcodec/videotoolbox: add AV1 hardware acceleration
> On Sep 24, 2024, at 01:24, Cameron Gutman wrote: > > On Mon, Sep 23, 2024 at 6:07 AM Zhao Zhili wrote: >> >> >> >>> On Sep 21, 2024, at 05:39, Martin Storsjö wrote: >>> >>> From: Jan Ekström >>> >>> Co-authored-by: Ruslan Chernenko >>> Co-authored-by: Martin Storsjö >>> --- >>> This is a touched up version of Jan and Ruslan's patches for >>> AV1 hwaccel via videotoolbox; I tried to polish the code a little >>> by not overwriting avctx->extradata in >>> ff_videotoolbox_av1c_extradata_create, and by factorizing out a >>> new function ff_videotoolbox_buffer_append. >> >> LGTM, although I don’t have a device with AV1 support. > > I've asked for some testing from users with M3 MacBooks and it > appears to have problems with certain resolutions (notably 4K). > > https://github.com/moonlight-stream/moonlight-qt/issues/1125 > > It's possible this is a Moonlight bug, but that seems unlikely > because VideoToolbox HEVC decoding works fine at 4K and > VideoToolbox AV1 works at 1080p and other resolutions. I can’t tell what’s going wrong from that bug report. Please test with ffmpeg and/or ffplay cmdline and share the results. > ___ > 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 22/23] tests/fate/hevc: add a test for switching between single and multi-view
Quoting Zhao Zhili (2024-09-23 19:49:40) > > > > On Sep 14, 2024, at 18:45, Anton Khirnov wrote: > > > > --- > > tests/fate/hevc.mak | 10 ++ > > tests/ref/fate/hevc-mv-switch | 172 ++ > > 2 files changed, 182 insertions(+) > > create mode 100644 tests/ref/fate/hevc-mv-switch > > Fate break on macOS. > > https://github.com/quink-black/FFmpeg/actions/runs/10999185735/job/30538808619 Could you please provide more information? I only see a red cross with "build and run all tests" at that link. -- 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 1/5] libavcodec/qsvenc: enable Alpha Encode for HEVC
From: Fei Wang This support alpha encode for HEVC introduced by Apple: https://developer.apple.com/videos/play/wwdc2019/506/ Currently, it only support RGBA video memory as input. RGB and alpha channel will be encoded in different layers with 4:2:0 color format. And set texture to shared to allow extract alpha channel internally: https://github.com/intel/libvpl/blob/5f6bd8a1e753c8f63a3fd8b36894d6968b808a6d/doc/spec/source/snippets/prg_encoding.c#L752 Example cmdline: ffmpeg.exe -v verbose -hwaccel qsv -hwaccel_output_format qsv -f rawvideo \ -pix_fmt bgra -s:v 1920x1080 -r:v 25 -i input.argb -vf \ 'format=bgra,hwupload=extra_hw_frames=120' -an -c:v hevc_qsv \ -alpha_encode 1 -y out.mp4 Signed-off-by: Fei Wang --- doc/encoders.texi | 4 ++ libavcodec/qsvenc.c | 79 +-- libavcodec/qsvenc.h | 9 - libavcodec/qsvenc_hevc.c | 3 ++ libavutil/hwcontext_qsv.c | 4 +- 5 files changed, 93 insertions(+), 6 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 0749417db4..6094434ed4 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -4036,6 +4036,10 @@ skip_frame metadata indicates the number of missed frames before the current frame. @end table +@item @var{alpha_encode} +Encode Alpha and RGB into different layers introduced by Apple: +https://developer.apple.com/videos/play/wwdc2019/506/. Only support on Windows +with RGBA video memory as input. @end table @subsection MPEG2 Options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 8200a14012..9af9932035 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -203,6 +203,9 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, #if QSV_HAVE_HE mfxExtHyperModeParam *exthypermodeparam = NULL; #endif +#if QSV_HAVE_AC +mfxExtAlphaChannelEncCtrl *extalphachannel = NULL; +#endif const char *tmp_str = NULL; @@ -220,6 +223,11 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, exthypermodeparam = (mfxExtHyperModeParam *)coding_opts[q->exthypermodeparam_idx]; #endif +#if QSV_HAVE_AC +if (q->extaplhachannel_idx > 0) +extalphachannel = (mfxExtAlphaChannelEncCtrl *)coding_opts[q->extaplhachannel_idx]; +#endif + av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); @@ -400,6 +408,23 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "\n"); } #endif + +#if QSV_HAVE_AC +if (extalphachannel) { +av_log(avctx, AV_LOG_VERBOSE, "AlphaChannel Encode: %s; ", print_threestate(extalphachannel->EnableAlphaChannelEncoding)); + +av_log(avctx, AV_LOG_VERBOSE, "Mode: "); +if (extalphachannel->AlphaChannelMode == MFX_ALPHA_MODE_PREMULTIPLIED) +av_log(avctx, AV_LOG_VERBOSE, "PREMULTIPLIED; "); +else if (extalphachannel->AlphaChannelMode == MFX_ALPHA_MODE_STRAIGHT) +av_log(avctx, AV_LOG_VERBOSE, "STRAIGHT; "); +else +av_log(avctx, AV_LOG_VERBOSE, "unknown; "); +av_log(avctx, AV_LOG_VERBOSE, "BitrateRatio: %d", extalphachannel->AlphaChannelBitrateRatio); + +av_log(avctx, AV_LOG_VERBOSE, "\n"); +} +#endif } static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, @@ -1150,7 +1175,8 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco3.MaxFrameSizeP = q->max_frame_size_p; if (sw_format == AV_PIX_FMT_BGRA && (q->profile == MFX_PROFILE_HEVC_REXT || -q->profile == MFX_PROFILE_UNKNOWN)) +q->profile == MFX_PROFILE_UNKNOWN) && +!q->alpha_encode) q->extco3.TargetChromaFormatPlus1 = MFX_CHROMAFORMAT_YUV444 + 1; q->extco3.ScenarioInfo = q->scenario; @@ -1282,6 +1308,37 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) } #endif +#if QSV_HAVE_AC + if (q->alpha_encode) { +if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 13)) { +mfxIMPL impl; +MFXQueryIMPL(q->session, &impl); + +if (MFX_IMPL_VIA_MASK(impl) != MFX_IMPL_VIA_D3D11) { +av_log(avctx, AV_LOG_ERROR, "Alpha Channel Encode requires D3D11VA \n"); +return AVERROR_UNKNOWN; +} + +if (q->param.mfx.CodecId != MFX_CODEC_HEVC) { +av_log(avctx, AV_LOG_ERROR, "Not supported encoder for Alpha Channel Encode. " +"Supported: hevc_qsv \n"); +return AVERROR_UNKNOWN; +} + +q->extaplhachannelparam.Header.BufferId = MFX_EXTBUFF_ALPHA_CHANNEL_ENC_CTRL; +q->extaplhachannelparam.Header.BufferSz = sizeof(q->extaplhachannelparam); +q->extaplhachannelp
[FFmpeg-devel] [PATCH 3/5] lavc/qsvenc: Support calculate encoded frame quality(MSE/PSNR) when encoding
From: Fei Wang Once the '-mse' option enabled, MSE/PSNR of each frame will be shown in VERBOSE debug level log. Signed-off-by: Fei Wang --- doc/encoders.texi| 4 + libavcodec/qsvenc.c | 162 +++ libavcodec/qsvenc.h | 12 +++ libavcodec/qsvenc_av1.c | 3 + libavcodec/qsvenc_h264.c | 3 + libavcodec/qsvenc_hevc.c | 3 + 6 files changed, 173 insertions(+), 14 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 85be976a46..7d1373e0e0 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3624,6 +3624,10 @@ ffmpeg -i input.mp4 -c:v h264_qsv -qsv_params "CodingOption1=1:CodingOption2=2" @end example This option allows fine-grained control over various encoder-specific settings provided by the QSV encoder. + +@item @var{mse} +Supported in h264_qsv, hevc_qsv, and av1_qsv on Windows. Output encoded +frame's quality(MSE/PSNR) information in VERBOSE log. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index dfef15fa5a..cd89656f74 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -95,6 +95,9 @@ typedef struct QSVPacket { AVPacketpkt; mfxSyncPoint *sync; mfxBitstream *bs; +int bs_buf_num; +int frameinfo_buf_idx; +int mse_buf_idx; } QSVPacket; static const char *print_profile(enum AVCodecID codec_id, mfxU16 profile) @@ -206,6 +209,9 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, #if QSV_HAVE_AC mfxExtAlphaChannelEncCtrl *extalphachannel = NULL; #endif +#if QSV_HAVE_MSE +mfxExtQualityInfoMode *extmse = NULL; +#endif const char *tmp_str = NULL; @@ -228,6 +234,11 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, extalphachannel = (mfxExtAlphaChannelEncCtrl *)coding_opts[q->extaplhachannel_idx]; #endif +#if QSV_HAVE_MSE +if (q->extmse_idx > 0) +extmse = (mfxExtQualityInfoMode *)coding_opts[q->extmse_idx]; +#endif + av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); @@ -425,6 +436,22 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "\n"); } #endif + +#if QSV_HAVE_MSE +if (extmse) { +av_log(avctx, AV_LOG_VERBOSE, "MSE: "); + +if (extmse->QualityInfoMode == MFX_QUALITY_INFO_LEVEL_FRAME) +av_log(avctx, AV_LOG_VERBOSE, "ON"); +else if (extmse->QualityInfoMode == MFX_QUALITY_INFO_DISABLE) +av_log(avctx, AV_LOG_VERBOSE, "OFF"); +else +av_log(avctx, AV_LOG_VERBOSE, "unknown"); + +av_log(avctx, AV_LOG_VERBOSE, "\n"); +} +#endif + } static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, @@ -522,6 +549,9 @@ static void dump_video_av1_param(AVCodecContext *avctx, QSVEncContext *q, #if QSV_HAVE_EXT_AV1_SCC mfxExtAV1ScreenContentTools *scc = (mfxExtAV1ScreenContentTools*)coding_opts[4]; #endif +#if QSV_HAVE_MSE +mfxExtQualityInfoMode *mse = (mfxExtQualityInfoMode*)coding_opts[5]; +#endif av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); @@ -602,6 +632,21 @@ static void dump_video_av1_param(AVCodecContext *avctx, QSVEncContext *q, print_threestate(scc->Palette), print_threestate(scc->IntraBlockCopy)); } #endif + +#if QSV_HAVE_MSE +if (mse) { +av_log(avctx, AV_LOG_VERBOSE, "MSE: "); + +if (mse->QualityInfoMode == MFX_QUALITY_INFO_LEVEL_FRAME) +av_log(avctx, AV_LOG_VERBOSE, "ON"); +else if (mse->QualityInfoMode == MFX_QUALITY_INFO_DISABLE) +av_log(avctx, AV_LOG_VERBOSE, "OFF"); +else +av_log(avctx, AV_LOG_VERBOSE, "unknown"); + +av_log(avctx, AV_LOG_VERBOSE, "\n"); +} +#endif } #endif @@ -1372,6 +1417,21 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) } #endif +#if QSV_HAVE_MSE +if (q->mse) { +if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 13)) { +q->extmseparam.Header.BufferId = MFX_EXTBUFF_ENCODED_QUALITY_INFO_MODE; +q->extmseparam.Header.BufferSz = sizeof(q->extmseparam); +q->extmseparam.QualityInfoMode = MFX_QUALITY_INFO_LEVEL_FRAME; +q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extmseparam; +} else { +av_log(avctx, AV_LOG_ERROR, + "This version of runtime doesn't support Mean Squared Error\n"); +return AVERROR_UNKNOWN; +} +} +#endif + if (!check_enc_param(avctx,q)) { av_log(avctx, AV_LOG_ERROR, "some encoding parameters are not supported by the QSV " @@ -1486,6 +1546,12 @@ static int qsv_retrieve_enc_av1_params(AVCodecContext *avctx,
[FFmpeg-devel] [PATCH 4/5] lavc/qsvenc: Add sliding window bitrate control for CBR
From: Fei Wang Sliding window bitrate control will provide a more stable bitrate when use CBR bitrate control mode. Signed-off-by: Fei Wang --- doc/encoders.texi| 9 + libavcodec/qsvenc.c | 25 + libavcodec/qsvenc.h | 11 +++ libavcodec/qsvenc_av1.c | 3 +++ libavcodec/qsvenc_h264.c | 3 +++ libavcodec/qsvenc_hevc.c | 3 +++ 6 files changed, 54 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 7d1373e0e0..b9f7f80e74 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3628,6 +3628,15 @@ This option allows fine-grained control over various encoder-specific settings p @item @var{mse} Supported in h264_qsv, hevc_qsv, and av1_qsv on Windows. Output encoded frame's quality(MSE/PSNR) information in VERBOSE log. + +@item @var{sw_size} +Number of frames used for sliding window(Only available for CBR bitrate +control mode on Windows). Range from 30 to 60 for AVC and HEVC. 30 to 120 for AV1. + +@item @var{sw_max_bitrate_factor} +Factor between bitrate and max bitrate for frames in sliding window. +Range from 1.1 to 2.0. + @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index cd89656f74..872a4d2cdf 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -398,6 +398,11 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSizeI: %d; ", co3->MaxFrameSizeI); av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSizeP: %d\n", co3->MaxFrameSizeP); av_log(avctx, AV_LOG_VERBOSE, "ScenarioInfo: %"PRId16"\n", co3->ScenarioInfo); +#if QSV_HAVE_SW +av_log(avctx, AV_LOG_VERBOSE, + "WinBRCSize: %"PRIu16"; WinBRCMaxAvgKbps: %"PRIu16"\n", + co3->WinBRCSize, co3->WinBRCMaxAvgKbps); +#endif } if (exthevctiles) { @@ -647,6 +652,12 @@ static void dump_video_av1_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "\n"); } #endif + +#if QSV_HAVE_SW +av_log(avctx, AV_LOG_VERBOSE, + "WinBRCSize: %"PRIu16"; WinBRCMaxAvgKbps: %"PRIu16"\n", + co3->WinBRCSize, co3->WinBRCMaxAvgKbps); +#endif } #endif @@ -1250,6 +1261,20 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco3.TransformSkip = MFX_CODINGOPTION_UNKNOWN; q->extco3.GPB = q->gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; } + +#if QSV_HAVE_SW +if ((avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC || +avctx->codec_id == AV_CODEC_ID_AV1) && q->sw_size) { +if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 13)) { +q->extco3.WinBRCSize = q->sw_size; +q->extco3.WinBRCMaxAvgKbps = (int)(q->sw_max_bitrate_factor * q->param.mfx.TargetKbps); +} else { +av_log(avctx, AV_LOG_ERROR, + "This version of runtime doesn't support sliding windows bitrate control\n"); +return AVERROR_UNKNOWN; +} +} +#endif q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco3; } diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 5aa0aae790..64c8cabbc7 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -24,6 +24,7 @@ #define AVCODEC_QSVENC_H #include +#include #include #include "libavutil/common.h" @@ -47,6 +48,7 @@ #define QSV_HAVE_HE QSV_VERSION_ATLEAST(2, 4) #define QSV_HAVE_AC QSV_VERSION_ATLEAST(2, 13) #define QSV_HAVE_MSEQSV_VERSION_ATLEAST(2, 13) +#define QSV_HAVE_SW QSV_VERSION_ATLEAST(2, 13) #else #define QSV_HAVE_AVBR 0 #define QSV_HAVE_VCM0 @@ -54,6 +56,7 @@ #define QSV_HAVE_HE 0 #define QSV_HAVE_AC 0 #define QSV_HAVE_MSE0 +#define QSV_HAVE_SW 0 #endif #define QSV_COMMON_OPTS \ @@ -158,6 +161,12 @@ { "mse", "Enable output MSE(Mean Squared Error) of each frame", OFFSET(qsv.mse), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, #endif +#if QSV_HAVE_SW +#define QSV_SW_OPTIONS \ +{ "sw_size", "Number of frames used for sliding window(Only available for CBR bitrate control mode)", OFFSET(qsv.sw_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },\ +{ "sw_max_bitrate_factor", "Factor between bitrate and max bitrate for frames in sliding window(Only available when sw_size is set)", OFFSET(qsv.sw_max_bitrate_factor), AV_OPT_TYPE_FLOAT, { .i64 = 0 }, 0, FLT_MAX, VE }, +#endif + extern const AVCodecHWConfigInternal *const ff_qsv_enc_hw_configs[]; typedef int SetEncodeCtrlCB (AVCodecContext *avctx, @@ -345,6 +354,8 @@ typedef struct QSVEncContext { int palette_mode; int intrabc; int mse; +int sw_size; +float sw_max_bitrate_factor; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); diff --git a/libavcodec/qsvenc_av1.c b/libavcodec/qsvenc_av1.c
[FFmpeg-devel] [PATCH 2/5] libavcodec/qsvenc: enable Screen Content Tool Encode for AV1
From: Fei Wang Screen Content Tool provides Intra Block Copy and Palette Mode when encoding. Signed-off-by: Fei Wang --- doc/encoders.texi | 6 ++ libavcodec/qsvenc.c | 43 + libavcodec/qsvenc.h | 9 - libavcodec/qsvenc_av1.c | 4 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 6094434ed4..85be976a46 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -4121,6 +4121,12 @@ than zero, then for I frames the value set by max_frame_size is ignored. @item @var{max_frame_size_p} Maximum encoded frame size for P frames in bytes. If this value is set as larger than zero, then for P frames the value set by max_frame_size is ignored. + +@item @var{palette_mode} +Use palette mode in Screen Content Tool. + +@item @var{intrabc} +Use intra block copy in Screen Content Tool. @end table @section snow diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 9af9932035..dfef15fa5a 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -519,6 +519,9 @@ static void dump_video_av1_param(AVCodecContext *avctx, QSVEncContext *q, mfxExtAV1BitstreamParam *av1_bs_param = (mfxExtAV1BitstreamParam *)coding_opts[1]; mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[2]; mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[3]; +#if QSV_HAVE_EXT_AV1_SCC +mfxExtAV1ScreenContentTools *scc = (mfxExtAV1ScreenContentTools*)coding_opts[4]; +#endif av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); @@ -591,6 +594,14 @@ static void dump_video_av1_param(AVCodecContext *avctx, QSVEncContext *q, print_threestate(av1_bs_param->WriteIVFHeaders)); av_log(avctx, AV_LOG_VERBOSE, "LowDelayBRC: %s\n", print_threestate(co3->LowDelayBRC)); av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d;\n", co2->MaxFrameSize); + +#if QSV_HAVE_EXT_AV1_SCC +if (scc) { +av_log(avctx, AV_LOG_VERBOSE, + "Palette: %s; IntraBlockCopy: %s\n", + print_threestate(scc->Palette), print_threestate(scc->IntraBlockCopy)); +} +#endif } #endif @@ -1339,6 +1350,28 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) } #endif +#if QSV_HAVE_EXT_AV1_SCC +if (q->palette_mode || q->intrabc) { +if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 13)) { +if (q->param.mfx.CodecId != MFX_CODEC_AV1) { +av_log(avctx, AV_LOG_ERROR, "Not supported encoder for Screen Content Tool Encode. " +"Supported: av1_qsv \n"); +return AVERROR_UNKNOWN; +} + +q->extsccparam.Header.BufferId = MFX_EXTBUFF_AV1_SCREEN_CONTENT_TOOLS; +q->extsccparam.Header.BufferSz = sizeof(q->extsccparam); +q->extsccparam.Palette = q->palette_mode ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; +q->extsccparam.IntraBlockCopy = q->intrabc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; +q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extsccparam; +} else { +av_log(avctx, AV_LOG_ERROR, + "This version of runtime doesn't support Screen Content Tool Encode\n"); +return AVERROR_UNKNOWN; +} +} +#endif + if (!check_enc_param(avctx,q)) { av_log(avctx, AV_LOG_ERROR, "some encoding parameters are not supported by the QSV " @@ -1446,11 +1479,21 @@ static int qsv_retrieve_enc_av1_params(AVCodecContext *avctx, QSVEncContext *q) .Header.BufferSz = sizeof(co3), }; +#if QSV_HAVE_EXT_AV1_SCC +mfxExtAV1ScreenContentTools scc_buf = { +.Header.BufferId = MFX_EXTBUFF_AV1_SCREEN_CONTENT_TOOLS, +.Header.BufferSz = sizeof(scc_buf), +}; +#endif + mfxExtBuffer *ext_buffers[] = { (mfxExtBuffer*)&av1_extend_tile_buf, (mfxExtBuffer*)&av1_bs_param, (mfxExtBuffer*)&co2, (mfxExtBuffer*)&co3, +#if QSV_HAVE_EXT_AV1_SCC +(mfxExtBuffer*)&scc_buf, +#endif }; if (!QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 5)) { diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 559d40c919..1e1474d37c 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -38,6 +38,7 @@ #define QSV_HAVE_EXT_VP9_TILES QSV_VERSION_ATLEAST(1, 29) #define QSV_HAVE_EXT_AV1_PARAM QSV_VERSION_ATLEAST(2, 5) +#define QSV_HAVE_EXT_AV1_SCC QSV_VERSION_ATLEAST(2, 13) #if defined(_WIN32) || defined(__CYGWIN__) #define QSV_HAVE_AVBR 1 @@ -193,10 +194,14 @@ typedef struct QSVEncContext { #if QSV_HAVE_AC mfxExtAlphaChannelEncCtrl extaplhachannelparam; #endif +#if QSV_HAVE_EXT_AV1_SCC +mfxExtAV1ScreenContentTools extsccparam; +#endif mfxExtVideoSignalInfo extvsi; -mfxExtBuffer *extparam_internal[5 + (
[FFmpeg-devel] [PATCH 5/5] Changelog: Add new entries for QSV encoder and bump lavc version
From: Fei Wang Signed-off-by: Fei Wang --- Changelog| 4 libavcodec/version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 49a16da7ca..3f9bfcdd4e 100644 --- a/Changelog +++ b/Changelog @@ -26,6 +26,10 @@ version : - stream specifiers in fftools can now match by stream disposition - LCEVC enhancement data exporting in H.26x and MP4/ISOBMFF - LCEVC filter +- Alpha encode for hevc_qsv encoder +- Screen Content Tool for av1_qsv encoder +- Encode frame quality capture for {h264, hevc, av1}_qsv encoder +- Sliding windows bitrate control for {h264, hevc, av1}_qsv encoder version 7.0: diff --git a/libavcodec/version.h b/libavcodec/version.h index 2618016a83..65bc52fb24 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 17 +#define LIBAVCODEC_VERSION_MINOR 18 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ -- 2.34.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 1/5] libavcodec/qsvenc: enable Alpha Encode for HEVC
Why should this be an option, as opposed to always being on when available? -- 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] libavcodec/qsvenc: enable Alpha Encode for HEVC
On Mon, 2024-09-23 at 09:21 +0200, Anton Khirnov wrote: > Why should this be an option, as opposed to always being on when > available? hevc_qsv also support encode RGBA by using regular Main 444 profile which will discard Alpha channel. So it's better to use an option to distinguish them. Thanks Fei > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/2] avformat: deprecated av_get_frame_filename() and av_get_frame_filename2()
I don't mind; whatever gets this merged the fastest is best for me. I wasn't aware there was an internal header, and I don't know why any of the av_get_frame_filename functions are exposed. I'll add some comments regardless: 1. Even though the function was previously externally documented as taking frame numbers, it has been used for timestamps internally for the past 7 years, so I think updating the external documentation to "any number" makes more sense. My patch deprecated all of the old APIs in favour of what we now think the new API should be. 2. Was there a reason you didn't update img2enc frame_pts to use the new internal function? 3. You might consider the documentation clarifications I made for the parameters: > + * @param path path with substitution template > + * @param number the number to substitute Thanks for the help with this. On Mon, 23 Sept 2024 at 13:18, Zhao Zhili wrote: > > > On Sep 23, 2024, at 18:18, Filip Mašić wrote: > > --- > doc/APIchanges | 3 ++- > libavfilter/vf_signature.c | 4 ++-- > libavformat/avformat.h | 22 ++ > libavformat/img2dec.c | 10 +- > libavformat/segment.c | 4 ++-- > libavformat/utils.c | 2 +- > libavformat/version_major.h | 2 +- > libavformat/webm_chunk.c| 4 ++-- > 8 files changed, 33 insertions(+), 18 deletions(-) > > > The doc of av_get_frame_filename2 says explicitly `number` is `frame > number`, > I prefer fix img2enc.c over add another API: > > https://ffmpeg.org//pipermail/ffmpeg-devel/2024-September/333820.html > > > diff --git a/doc/APIchanges b/doc/APIchanges > index 9f091f5ec5..cbab71a408 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -3,7 +3,8 @@ The last version increases of all libraries were on > 2024-03-07 > API changes, most recent first: > > 2024-09-xx - xx - lavf 61.7.100 - avformat.h > - Add av_get_frame_filename3() > + Deprecate av_get_frame_filename(), av_get_frame_filename2(), > + and replace them with av_get_frame_filename3(). > > 2024-09-18 - xx - lavc 61.17.100 - packet.h > Add AV_PKT_DATA_LCEVC. > diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c > index f419522ac6..37f3ff227e 100644 > --- a/libavfilter/vf_signature.c > +++ b/libavfilter/vf_signature.c > @@ -562,7 +562,7 @@ static int export(AVFilterContext *ctx, StreamContext > *sc, int input) > > if (sic->nb_inputs > 1) { > /* error already handled */ > -av_assert0(av_get_frame_filename(filename, sizeof(filename), > sic->filename, input) == 0); > +av_assert0(av_get_frame_filename3(filename, sizeof(filename), > sic->filename, input, 0) == 0); > } else { > if (av_strlcpy(filename, sic->filename, sizeof(filename)) >= > sizeof(filename)) > return AVERROR(EINVAL); > @@ -673,7 +673,7 @@ static av_cold int init(AVFilterContext *ctx) > } > > /* check filename */ > -if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && > av_get_frame_filename(tmp, sizeof(tmp), sic->filename, 0) == -1) { > +if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && > av_get_frame_filename3(tmp, sizeof(tmp), sic->filename, 0, 0) == -1) { > av_log(ctx, AV_LOG_ERROR, "The filename must contain %%d or %%0nd, > if you have more than one input.\n"); > return AVERROR(EINVAL); > } > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 1bc0e716dc..a407faecec 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -2940,11 +2940,25 @@ void av_dump_format(AVFormatContext *ic, > int av_get_frame_filename3(char *buf, int buf_size, > const char *path, int64_t number, int flags); > > -int av_get_frame_filename2(char *buf, int buf_size, > - const char *path, int number, int flags); > +#if FF_API_AV_GET_FRAME_FILENAME2 > +/** > + * Like av_get_frame_filename3() but requires int-type number > + * > + * @deprecated use av_get_frame_filename3() with same arguments > + */ > +attribute_deprecated > +int av_get_frame_filename2(char *buf, int buf_size, > +const char *path, int number, int flags); > > -int av_get_frame_filename(char *buf, int buf_size, > - const char *path, int number); > +/** > + * Like av_get_frame_filename3() but requires int-type number and > doesn't accept flags > + * > + * @deprecated use av_get_frame_filename3() with flags=0 > + */ > +attribute_deprecated > +int av_get_frame_filename(char *buf, int buf_size, > +const char *path, int number); > +#endif > > /** > * Check whether filename actually is a numbered sequence generator. > diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c > index 3389fa818e..df376ac612 100644 > --- a/libavformat/img2dec.c > +++ b/libavformat/img2dec.c > @@ -122,7 +122,7 @@ static int find_image_range(AVIOContext *pb, int > *pfirst_index, int *pl
Re: [FFmpeg-devel] A change in r_frame_rate values after upgrade to FFmpeg 6.1
Quoting Antoni Bizoń (2024-09-23 10:09:51) > I understand that the r_frame_rate is the lowest framerate with which > all timestamps can be represented accurately. And I know it is just a > guess. But why did the logic behind the calculation change? Because you're most likely using a codec like H.264 or MPEG-2 that allows individually coded fields. In that case the timebase must be accurate enough to represent the field rate (i.e. double the frame rate), but the code doing this was previously unreliable, so you'd sometimes get r_frame_rate equal to the frame rate rather than field rate. That is not the case anymore. -- 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 3/3] lavc/decode: merge stereo3d information from decoder with packet side data
On 9/23/2024 1:22 AM, Anton Khirnov wrote: Quoting James Almer (2024-09-23 04:17:46) On 9/22/2024 3:00 PM, Anton Khirnov wrote: The HEVC decoder will start setting stereoscopic view position (left or right) based on 3D Reference Displays Info SEI message in future commits. This information should be merged with container-derived stereo3D side data. After this set, a re-encode with the CLI will have information at the container level that may not be correct, like type and view. The same is true before this set as well, so I don't quite see your True, before this set the container level info from the source is passed through to the output, which may also be bogus. point. Yes, this set does not resolve the problem fully, but it still should be a step in the right direction. Yes, it is. 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 v2 7/8] lavc/vvc_dec: Add hardware decode API
Quoting Wang, Fei W (2024-09-23 10:40:14) > On Mon, 2024-09-23 at 06:37 +0200, Anton Khirnov wrote: > > Quoting fei.w.wang-at-intel@ffmpeg.org (2024-09-18 09:10:30) > > > static void export_frame_params(VVCContext *s, const > > > VVCFrameContext *fc) > > > { > > > AVCodecContext *c = s->avctx; > > > const VVCSPS *sps = fc->ps.sps; > > > const VVCPPS *pps = fc->ps.pps; > > > > > > - c->pix_fmt = sps->pix_fmt; > > > - c->coded_width = pps->width; > > > - c->coded_height = pps->height; > > > - c->width = pps->width - ((pps->r- > > > >pps_conf_win_left_offset + pps->r->pps_conf_win_right_offset) << > > > sps->hshift[CHROMA]); > > > - c->height = pps->height - ((pps->r- > > > >pps_conf_win_top_offset + pps->r->pps_conf_win_bottom_offset) << > > > sps->vshift[CHROMA]); > > > + // Reset HW config if pix_fmt/w/h change. > > > + if (s->pix_fmt != sps->pix_fmt || c->coded_width != pps->width > > > || c->coded_height != pps->height) { > > > + c->coded_width = pps->width; > > > + c->coded_height = pps->height; > > > + c->pix_fmt = get_format(c, sps); > > > + s->pix_fmt = sps->pix_fmt; > > > > > > s->pix_fmt is used to detect if frame pixel format is change which is > samilar with vp9. Any concern on this? Oh, I missed that the two lines assign to different structs. Never mind then. -- 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] Uncompressed MP4
Hello, I'm interested in implementing uncompressed MP4 parsing according to the newly released ISO/IEC 23001-17:2024. Would anyone be interested in further discussing this with me? Thanks, Devon Sookhoo ___ 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] A change in r_frame_rate values after upgrade to FFmpeg 6.1
On Mon, Sep 23, 2024 at 3:27 PM Anton Khirnov wrote: > > Quoting Antoni Bizoń (2024-09-23 10:09:51) > > I understand that the r_frame_rate is the lowest framerate with which > > all timestamps can be represented accurately. And I know it is just a > > guess. But why did the logic behind the calculation change? > > Because you're most likely using a codec like H.264 or MPEG-2 that > allows individually coded fields. In that case the timebase must be > accurate enough to represent the field rate (i.e. double the frame > rate), but the code doing this was previously unreliable, so you'd > sometimes get r_frame_rate equal to the frame rate rather than field > rate. That is not the case anymore. This is bizarre and kafkaesque to say the least. Kieran ___ 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/7] lavfi/buffersink: add a flag for retrieving stream parameters
This way, av_buffersink_get_frame_flags() can replace almost all av_buffersink_get_*(), including some future parameters we will want to export. --- doc/APIchanges | 1 + libavfilter/buffersink.c | 47 libavfilter/buffersink.h | 16 -- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index b392c756d7..5ddd7189f8 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -4,6 +4,7 @@ API changes, most recent first: 2024-09-xx - xx - lavfi 10.4.100 Buffersink now sets AVFrame.time_base on the frames it outputs. + Add AV_BUFFERSINK_FLAG_PARAMS. 2024-09-23 - xx - lavc 61.18.100 - avcodec.h Add a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 575075ff47..d9cd074f17 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -128,8 +128,55 @@ static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i } } +static int get_frame_params(AVFilterContext *ctx, AVFrame *frame) +{ +FilterLink *l = ff_filter_link(ctx->inputs[0]); +int ret = 0; + +frame->time_base = l->pub.time_base; +frame->format= l->pub.format; + +switch (l->pub.type) { +case AVMEDIA_TYPE_AUDIO: +ret = av_channel_layout_copy(&frame->ch_layout, &l->pub.ch_layout); +if (ret < 0) +goto fail; + +frame->sample_rate = l->pub.sample_rate; +break; +case AVMEDIA_TYPE_VIDEO: +frame->width= l->pub.w; +frame->height = l->pub.h; +frame->sample_aspect_ratio = l->pub.sample_aspect_ratio; +frame->colorspace = l->pub.colorspace; +frame->color_range = l->pub.color_range; +break; +default: av_assert0(0); +} + +if (l->hw_frames_ctx) { +frame->hw_frames_ctx = av_buffer_ref(l->hw_frames_ctx); +if (!frame->hw_frames_ctx) { +ret = AVERROR(ENOMEM); +goto fail; +} +} + +return 0; +fail: +av_frame_unref(frame); +return ret; +} + int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags) { +if (flags & AV_BUFFERSINK_FLAG_PARAMS) { +if (flags & ~AV_BUFFERSINK_FLAG_PARAMS) +return AVERROR(EINVAL); + +return get_frame_params(ctx, frame); +} + return get_frame_internal(ctx, frame, flags, ff_filter_link(ctx->inputs[0])->min_samples); } diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index 361d603679..9c4468af5b 100644 --- a/libavfilter/buffersink.h +++ b/libavfilter/buffersink.h @@ -87,14 +87,26 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flag * reference, but not remove it from the buffer. This is useful if you * need only to read a video/samples buffer, without to fetch it. */ -#define AV_BUFFERSINK_FLAG_PEEK 1 +#define AV_BUFFERSINK_FLAG_PEEK (1 << 0) /** * Tell av_buffersink_get_buffer_ref() not to request a frame from its input. * If a frame is already buffered, it is read (and removed from the buffer), * but if no frame is present, return AVERROR(EAGAIN). */ -#define AV_BUFFERSINK_FLAG_NO_REQUEST 2 +#define AV_BUFFERSINK_FLAG_NO_REQUEST (1 << 1) + +/** + * Retrieve stream parameters rather than frame data. + * + * When this flag is set, av_buffersink_get_frame_flags() fills the non-data + * fields of the supplied frame without causing any filtergraph activity. + * + * @note While frame data will be NULL, certain other allocated fields may be + * filled (e.g. ch_layout, hw_frames_ctx), so the frame should still be + * unreffed before reuse. + */ +#define AV_BUFFERSINK_FLAG_PARAMS (1 << 2) /** * Set the frame size for an audio buffer sink. -- 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".
[FFmpeg-devel] [PATCH 3/7] fftools/ffmpeg_filter: use AV_BUFFERSINK_FLAG_PARAMS
--- fftools/ffmpeg_filter.c | 96 ++--- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 81c4911b03..b4c0876fa6 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -197,13 +197,8 @@ typedef struct OutputFilterPriv { AVFilterContext*filter; -/* desired output stream properties */ -int format; -int width, height; -int sample_rate; -AVChannelLayout ch_layout; -enum AVColorSpace color_space; -enum AVColorRange color_range; +/* frame holding desired output stream parameters */ +AVFrame*params; // time base in which the output is sent to our downstream // does not need to match the filtersink's timebase @@ -212,8 +207,6 @@ typedef struct OutputFilterPriv { // to our downstream, so it cannot change anymore int tb_out_locked; -AVRational sample_aspect_ratio; - AVDictionary *sws_opts; AVDictionary *swr_opts; @@ -373,11 +366,11 @@ static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \ static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \ { \ -if (ofp->var == none && !ofp->supported_list) \ +if (ofp->params->var == none && !ofp->supported_list) \ return; \ av_bprintf(bprint, #name "="); \ -if (ofp->var != none) { \ -av_bprintf(bprint, printf_format, get_name(ofp->var)); \ +if (ofp->params->var != none) { \ +av_bprintf(bprint, printf_format, get_name(ofp->params->var)); \ } else { \ const type *p; \ \ @@ -399,7 +392,7 @@ DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats, DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0, "%d", ) -DEF_CHOOSE_FORMAT(color_spaces, enum AVColorSpace, color_space, color_spaces, +DEF_CHOOSE_FORMAT(color_spaces, enum AVColorSpace, colorspace, color_spaces, AVCOL_SPC_UNSPECIFIED, "%s", av_color_space_name); DEF_CHOOSE_FORMAT(color_ranges, enum AVColorRange, color_range, color_ranges, @@ -407,9 +400,9 @@ DEF_CHOOSE_FORMAT(color_ranges, enum AVColorRange, color_range, color_ranges, static void choose_channel_layouts(OutputFilterPriv *ofp, AVBPrint *bprint) { -if (av_channel_layout_check(&ofp->ch_layout)) { +if (av_channel_layout_check(&ofp->params->ch_layout)) { av_bprintf(bprint, "channel_layouts="); -av_channel_layout_describe_bprint(&ofp->ch_layout, bprint); +av_channel_layout_describe_bprint(&ofp->params->ch_layout, bprint); } else if (ofp->ch_layouts) { const AVChannelLayout *p; @@ -643,14 +636,15 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg, enum AVMediaType type) if (!ofp) return NULL; +ofp->params = av_frame_alloc(); +if (!ofp->params) +return NULL; + ofilter = &ofp->ofilter; ofilter->class= &ofilter_class; ofp->log_parent = fg; ofilter->graph= fg; ofilter->type = type; -ofp->format = -1; -ofp->color_space = AVCOL_SPC_UNSPECIFIED; -ofp->color_range = AVCOL_RANGE_UNSPECIFIED; ofp->index= fg->nb_outputs - 1; snprintf(ofp->log_name, sizeof(ofp->log_name), "%co%d", @@ -747,7 +741,7 @@ static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layout if (layout_requested->order != AV_CHANNEL_ORDER_UNSPEC) { /* Pass the layout through for all orders but UNSPEC */ -err = av_channel_layout_copy(&f->ch_layout, layout_requested); +err = av_channel_layout_copy(&f->params->ch_layout, layout_requested); if (err < 0) return err; return 0; @@ -757,7 +751,7 @@ static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layout if (!layouts_allowed) { /* Use the default native layout for the requested amount of channels when the encoder doesn't have a list of supported layouts */ -av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels); +av_channel_layout_default(&f->params->ch_
[FFmpeg-devel] [PATCH 4/7] lavd/lavfi: use AV_BUFFERSINK_FLAG_PARAMS
--- libavdevice/lavfi.c | 30 +++--- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index 3b77a7396a..ef7d1fef1a 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -102,6 +102,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) LavfiContext *lavfi = avctx->priv_data; AVFilterInOut *input_links = NULL, *output_links = NULL, *inout; const AVFilter *buffersink, *abuffersink; +AVFrame *params = NULL; enum AVMediaType type; int ret = 0, i, n; @@ -287,33 +288,39 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) } } +params = av_frame_alloc(); +if (!params) +FAIL(AVERROR(ENOMEM)); + /* fill each stream with the information in the corresponding sink */ for (i = 0; i < lavfi->nb_sinks; i++) { AVFilterContext *sink = lavfi->sinks[lavfi->stream_sink_map[i]]; -AVRational time_base = av_buffersink_get_time_base(sink); AVRational frame_rate = av_buffersink_get_frame_rate(sink); AVStream *st = avctx->streams[i]; AVCodecParameters *const par = st->codecpar; -avpriv_set_pts_info(st, 64, time_base.num, time_base.den); + +av_frame_unref(params); +ret = av_buffersink_get_frame_flags(sink, params, AV_BUFFERSINK_FLAG_PARAMS); +if (ret < 0) +goto end; + +avpriv_set_pts_info(st, 64, params->time_base.num, params->time_base.den); par->codec_type = av_buffersink_get_type(sink); +par->format = params->format; if (par->codec_type == AVMEDIA_TYPE_VIDEO) { par->codec_id = AV_CODEC_ID_WRAPPED_AVFRAME; -par->format = av_buffersink_get_format(sink); -par->width = av_buffersink_get_w(sink); -par->height = av_buffersink_get_h(sink); +par->width = params->width; +par->height = params->height; avctx->probesize = FFMAX(avctx->probesize, sizeof(AVFrame) * 30); st ->sample_aspect_ratio = -par->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(sink); +par->sample_aspect_ratio = params->sample_aspect_ratio; if (frame_rate.num > 0 && frame_rate.den > 0) { st->avg_frame_rate = frame_rate; st->r_frame_rate = frame_rate; } } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) { -par->sample_rate = av_buffersink_get_sample_rate(sink); -ret = av_buffersink_get_ch_layout(sink, &par->ch_layout); -if (ret < 0) -goto end; -par->format = av_buffersink_get_format(sink); +par->sample_rate = params->sample_rate; +FFSWAP(AVChannelLayout, par->ch_layout, params->ch_layout); par->codec_id= av_get_pcm_codec(par->format, -1); if (par->codec_id == AV_CODEC_ID_NONE) av_log(avctx, AV_LOG_ERROR, @@ -326,6 +333,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) goto end; end: +av_frame_free(¶ms); avfilter_inout_free(&input_links); avfilter_inout_free(&output_links); 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".
[FFmpeg-devel] [PATCH 1/7] lavfi/buffersink: set AVFrame.time_base
So the caller does not need to call av_buffersink_get_time_base() separately. --- doc/APIchanges | 3 +++ doc/examples/transcode.c | 1 - fftools/ffmpeg_filter.c | 2 -- fftools/ffplay.c | 10 ++ libavdevice/lavfi.c | 4 ++-- libavfilter/buffersink.c | 21 - libavfilter/version.h| 2 +- tools/uncoded_frame.c| 2 +- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 2273c3bce7..b392c756d7 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-xx - xx - lavfi 10.4.100 + Buffersink now sets AVFrame.time_base on the frames it outputs. + 2024-09-23 - xx - lavc 61.18.100 - avcodec.h Add a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c index cbe5088ef6..07d9ee9152 100644 --- a/doc/examples/transcode.c +++ b/doc/examples/transcode.c @@ -500,7 +500,6 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index) break; } -filter->filtered_frame->time_base = av_buffersink_get_time_base(filter->buffersink_ctx);; filter->filtered_frame->pict_type = AV_PICTURE_TYPE_NONE; ret = encode_write_frame(stream_index, 0); av_frame_unref(filter->filtered_frame); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 529e631781..81c4911b03 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2487,8 +2487,6 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, return 0; } -frame->time_base = av_buffersink_get_time_base(filter); - if (debug_ts) av_log(ofp, AV_LOG_INFO, "filter_raw -> pts:%s pts_time:%s time_base:%d/%d\n", av_ts2str(frame->pts), av_ts2timestr(frame->pts, &frame->time_base), diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 60d8874eab..4ea48e11bb 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2076,7 +2076,6 @@ static int audio_thread(void *arg) int last_serial = -1; int reconfigure; int got_frame = 0; -AVRational tb; int ret = 0; if (!frame) @@ -2087,8 +2086,6 @@ static int audio_thread(void *arg) goto the_end; if (got_frame) { -tb = (AVRational){1, frame->sample_rate}; - reconfigure = cmp_audio_fmts(is->audio_filter_src.fmt, is->audio_filter_src.ch_layout.nb_channels, frame->format, frame->ch_layout.nb_channels)|| @@ -2121,11 +2118,10 @@ static int audio_thread(void *arg) while ((ret = av_buffersink_get_frame_flags(is->out_audio_filter, frame, 0)) >= 0) { FrameData *fd = frame->opaque_ref ? (FrameData*)frame->opaque_ref->data : NULL; -tb = av_buffersink_get_time_base(is->out_audio_filter); if (!(af = frame_queue_peek_writable(&is->sampq))) goto the_end; -af->pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(tb); +af->pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(frame->time_base); af->pos = fd ? fd->pkt_pos : -1; af->serial = is->auddec.pkt_serial; af->duration = av_q2d((AVRational){frame->nb_samples, frame->sample_rate}); @@ -2164,7 +2160,6 @@ static int video_thread(void *arg) double pts; double duration; int ret; -AVRational tb = is->video_st->time_base; AVRational frame_rate = av_guess_frame_rate(is->ic, is->video_st, NULL); AVFilterGraph *graph = NULL; @@ -2242,9 +2237,8 @@ static int video_thread(void *arg) is->frame_last_filter_delay = av_gettime_relative() / 100.0 - is->frame_last_returned_time; if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0) is->frame_last_filter_delay = 0; -tb = av_buffersink_get_time_base(filt_out); duration = (frame_rate.num && frame_rate.den ? av_q2d((AVRational){frame_rate.den, frame_rate.num}) : 0); -pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(tb); +pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(frame->time_base); ret = queue_picture(is, frame, pts, duration, fd ? fd->pkt_pos : -1, is->viddec.pkt_serial); av_frame_unref(frame); if (is->videoq.serial != is->viddec.pkt_serial) diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index ce10d61f8a..3b77a7396a 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -384,7 +384,6 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) /* iterate through all the graph sinks. Select the sink with t
[FFmpeg-devel] [PATCH 5/7] fftools/ffplay: use AV_BUFFERSINK_FLAG_PARAMS
--- fftools/ffplay.c | 20 +--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 4ea48e11bb..ef45f12906 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2702,6 +2702,7 @@ static int stream_component_open(VideoState *is, int stream_index) case AVMEDIA_TYPE_AUDIO: { AVFilterContext *sink; +AVFrame *params = NULL; is->audio_filter_src.freq = avctx->sample_rate; ret = av_channel_layout_copy(&is->audio_filter_src.ch_layout, &avctx->ch_layout); @@ -2711,10 +2712,23 @@ static int stream_component_open(VideoState *is, int stream_index) if ((ret = configure_audio_filters(is, afilters, 0)) < 0) goto fail; sink = is->out_audio_filter; -sample_rate= av_buffersink_get_sample_rate(sink); -ret = av_buffersink_get_ch_layout(sink, &ch_layout); -if (ret < 0) + +params = av_frame_alloc(); +if (!params) { +ret = AVERROR(ENOMEM); goto fail; +} + +ret = av_buffersink_get_frame_flags(sink, params, AV_BUFFERSINK_FLAG_PARAMS); +if (ret < 0) { +av_frame_free(¶ms); +goto fail; +} + +sample_rate = params->sample_rate; +FFSWAP(AVChannelLayout, ch_layout, params->ch_layout); + +av_frame_free(¶ms); } /* prepare audio output */ -- 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".
[FFmpeg-devel] [PATCH 6/7] tools/uncoded_frame: use AV_BUFFERSINK_FLAG_PARAMS
--- tools/uncoded_frame.c | 37 ++--- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/tools/uncoded_frame.c b/tools/uncoded_frame.c index a17d406417..39818963d0 100644 --- a/tools/uncoded_frame.c +++ b/tools/uncoded_frame.c @@ -153,6 +153,13 @@ int main(int argc, char **argv) for (; i < nb_streams; i++) streams[i].mux = streams[0].mux; +frame = av_frame_alloc(); +if (!frame) { +ret = AVERROR(ENOMEM); +av_log(NULL, AV_LOG_ERROR, "Could not allocate frame\n"); +goto fail; +} + /* Create output device streams */ for (i = 0; i < nb_streams; i++) { st = &streams[i]; @@ -161,29 +168,34 @@ int main(int argc, char **argv) av_log(NULL, AV_LOG_ERROR, "Failed to create output stream\n"); goto fail; } + +ret = av_buffersink_get_frame_flags(st->sink, frame, AV_BUFFERSINK_FLAG_PARAMS); +if (ret < 0) +goto fail; + st->stream->codecpar->codec_type = av_buffersink_get_type(st->sink); -st->stream->time_base = av_buffersink_get_time_base(st->sink); +st->stream->time_base = frame->time_base; switch (av_buffersink_get_type(st->sink)) { case AVMEDIA_TYPE_VIDEO: st->stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; st->stream->avg_frame_rate = st->stream-> r_frame_rate = av_buffersink_get_frame_rate(st->sink); -st->stream->codecpar->width = av_buffersink_get_w(st->sink); -st->stream->codecpar->height = av_buffersink_get_h(st->sink); -st->stream->codecpar->sample_aspect_ratio = av_buffersink_get_sample_aspect_ratio(st->sink); -st->stream->codecpar->format = av_buffersink_get_format(st->sink); +st->stream->codecpar->width = frame->width; +st->stream->codecpar->height = frame->height; +st->stream->codecpar->sample_aspect_ratio = frame->sample_aspect_ratio; +st->stream->codecpar->format = frame->format; break; case AVMEDIA_TYPE_AUDIO: -ret = av_buffersink_get_ch_layout(st->sink, &st->stream->codecpar->ch_layout); -if (ret < 0) -goto fail; -st->stream->codecpar->sample_rate= av_buffersink_get_sample_rate(st->sink); -st->stream->codecpar->format = av_buffersink_get_format(st->sink); +FFSWAP(AVChannelLayout, st->stream->codecpar->ch_layout, frame->ch_layout); +st->stream->codecpar->sample_rate= frame->sample_rate; +st->stream->codecpar->format = frame->format; st->stream->codecpar->codec_id = av_get_pcm_codec(st->stream->codecpar->format, -1); break; default: av_assert0(!"reached"); } + +av_frame_unref(frame); } /* Init output devices */ @@ -222,11 +234,6 @@ int main(int argc, char **argv) for (i = 0; i < nb_streams; i++) { st = &streams[i]; while (1) { -if (!frame && !(frame = av_frame_alloc())) { -ret = AVERROR(ENOMEM); -av_log(NULL, AV_LOG_ERROR, "Could not allocate frame\n"); -goto fail; -} ret = av_buffersink_get_frame_flags(st->sink, frame, AV_BUFFERSINK_FLAG_NO_REQUEST); if (ret < 0) { -- 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".
[FFmpeg-devel] [PATCH 7/7] lavfi/buffersink: deprecate functions obsoleted by AV_BUFFERSINK_FLAG_PARAMS
That is all av_buffersink_get_*() except type and frame_rate, for which AVFrame does not currently have fields. --- doc/APIchanges | 12 +++- libavfilter/buffersink.c| 4 libavfilter/buffersink.h| 19 ++- libavfilter/version_major.h | 1 + 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5ddd7189f8..971750bfe7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -4,7 +4,17 @@ API changes, most recent first: 2024-09-xx - xx - lavfi 10.4.100 Buffersink now sets AVFrame.time_base on the frames it outputs. - Add AV_BUFFERSINK_FLAG_PARAMS. + Add AV_BUFFERSINK_FLAG_PARAMS; deprecate + - av_buffersink_get_time_base() + - av_buffersink_get_w() + - av_buffersink_get_h() + - av_buffersink_get_sample_aspect_ratio() + - av_buffersink_get_colorspace() + - av_buffersink_get_color_range() + - av_buffersink_get_channels() + - av_buffersink_get_channel_layout() + - av_buffersink_get_sample_rate() + - av_buffersink_get_hw_frames_ctx() 2024-09-23 - xx - lavc 61.18.100 - avcodec.h Add a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index d9cd074f17..e0c32d5f10 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -234,6 +234,7 @@ type av_buffersink_get_##field(const AVFilterContext *ctx) { \ } MAKE_AVFILTERLINK_ACCESSOR(enum AVMediaType , type ) +#if FF_API_BUFFERSINK_GET MAKE_AVFILTERLINK_ACCESSOR(AVRational , time_base ) MAKE_AVFILTERLINK_ACCESSOR(int , format ) @@ -244,6 +245,7 @@ MAKE_AVFILTERLINK_ACCESSOR(enum AVColorSpace, colorspace) MAKE_AVFILTERLINK_ACCESSOR(enum AVColorRange, color_range) MAKE_AVFILTERLINK_ACCESSOR(int , sample_rate) +#endif AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx) { @@ -252,6 +254,7 @@ AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx) return l->frame_rate; } +#if FF_API_BUFFERSINK_GET AVBufferRef* av_buffersink_get_hw_frames_ctx(const AVFilterContext *ctx) { FilterLink *l = ff_filter_link(ctx->inputs[0]); @@ -277,6 +280,7 @@ int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out *out = ch_layout; return 0; } +#endif #define CHECK_LIST_SIZE(field) \ if (buf->field ## _size % sizeof(*buf->field)) { \ diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index 9c4468af5b..ef5aae8857 100644 --- a/libavfilter/buffersink.h +++ b/libavfilter/buffersink.h @@ -124,22 +124,39 @@ void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size); */ enum AVMediaType av_buffersink_get_type(const AVFilterContext *ctx); +AVRational av_buffersink_get_frame_rate (const AVFilterContext *ctx); + +#if FF_API_BUFFERSINK_GET +/** + * @deprecated Use av_buffersink_get_frame_flags() with AV_BUFFERSINK_FLAG_PARAMS + */ +attribute_deprecated AVRational av_buffersink_get_time_base (const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_format (const AVFilterContext *ctx); -AVRational av_buffersink_get_frame_rate (const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_w (const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_h (const AVFilterContext *ctx); +attribute_deprecated AVRational av_buffersink_get_sample_aspect_ratio (const AVFilterContext *ctx); +attribute_deprecated enum AVColorSpace av_buffersink_get_colorspace (const AVFilterContext *ctx); +attribute_deprecated enum AVColorRange av_buffersink_get_color_range(const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_channels(const AVFilterContext *ctx); +attribute_deprecated int av_buffersink_get_ch_layout (const AVFilterContext *ctx, AVChannelLayout *ch_layout); +attribute_deprecated int av_buffersink_get_sample_rate (const AVFilterContext *ctx); +attribute_deprecated AVBufferRef *av_buffersink_get_hw_frames_ctx (const AVFilterContext *ctx); +#endif /** @} */ diff --git a/libavfilter/version_major.h b/libavfilter/version_major.h index c5e660eeda..0ca3b0e358 100644 --- a/libavfilter/version_major.h +++ b/libavfilter/version_major.h @@ -36,5 +36,6 @@ */ #define FF_API_LINK_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11) +#define FF_API_BUFFERSINK_GET (LIBAVFILTER_VERSION_MAJOR < 11) #endif /* AVFILTER_VERSION_MAJOR_H */ -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsu
Re: [FFmpeg-devel] A change in r_frame_rate values after upgrade to FFmpeg 6.1
Quoting Kieran Kunhya via ffmpeg-devel (2024-09-23 16:45:30) > On Mon, Sep 23, 2024 at 3:27 PM Anton Khirnov wrote: > > > > Quoting Antoni Bizoń (2024-09-23 10:09:51) > > > I understand that the r_frame_rate is the lowest framerate with which > > > all timestamps can be represented accurately. And I know it is just a > > > guess. But why did the logic behind the calculation change? > > > > Because you're most likely using a codec like H.264 or MPEG-2 that > > allows individually coded fields. In that case the timebase must be > > accurate enough to represent the field rate (i.e. double the frame > > rate), but the code doing this was previously unreliable, so you'd > > sometimes get r_frame_rate equal to the frame rate rather than field > > rate. That is not the case anymore. > > This is bizarre and kafkaesque to say the least. As far as I'm concerned, r_frame_rate is a mistake and should never have existed. But since it does exist, it's better for the calculation to at least not depend on whether the lavf internal decoder has been opened during avformat_find_stream_info() or not (which used to be the case). -- 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] Use the correct Vulkan NULL type
On 22/09/2024 20:40, nihil-admirari via ffmpeg-devel wrote: From: nihil-admirari <50202386+nihil-admir...@users.noreply.github.com> Fixes build issue for Win32 targets --- libavcodec/vulkan_encode_h264.c | 2 +- libavcodec/vulkan_encode_h265.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vulkan_encode_h264.c b/libavcodec/vulkan_encode_h264.c index af229af..a67e177 100644 --- a/libavcodec/vulkan_encode_h264.c +++ b/libavcodec/vulkan_encode_h264.c @@ -1048,7 +1048,7 @@ static int create_session_params(AVCodecContext *avctx) .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, .pNext = &h264_params, .videoSession = ctx->common.session, -.videoSessionParametersTemplate = NULL, +.videoSessionParametersTemplate = VK_NULL_HANDLE, }; /* Create session parameters */ diff --git a/libavcodec/vulkan_encode_h265.c b/libavcodec/vulkan_encode_h265.c index 3cb7a3b..2082cec 100644 --- a/libavcodec/vulkan_encode_h265.c +++ b/libavcodec/vulkan_encode_h265.c @@ -1201,7 +1201,7 @@ static int create_session_params(AVCodecContext *avctx) .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR, .pNext = &h265_params, .videoSession = ctx->common.session, -.videoSessionParametersTemplate = NULL, +.videoSessionParametersTemplate = VK_NULL_HANDLE, }; /* Create session parameters */ Thanks for sending the patch. 2bcc124e1a49e27b6a42b1d0ab1cac23568c3ca2, addressed this in a neater way, so I merged it instead of these 2 patches. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key 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] avformat/libsrt: Adding support for multiple clients as a server
> On Sep 19, 2024, at 21:46, nicolas.d...@gmail.com wrote: > > From: Nicolas Jorge Dato > > When in listener mode and writing, now libsrt supports multiple clients > configured with the max_clients parameter. > > When max_clients=1 (default), it behaves as before. > When max_clientes > 1, after accepting the first client it launches > a thread to listen for more clients, and a launches a new thread for > each client. > --- > libavformat/libsrt.c | 297 ++- > 1 file changed, 265 insertions(+), 32 deletions(-) > > diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > index 9e860abccd..c9392e6996 100644 > --- a/libavformat/libsrt.c > +++ b/libavformat/libsrt.c > @@ -21,8 +21,11 @@ > * Haivision Open SRT (Secure Reliable Transport) protocol > */ > > +#include > +#include > #include The implementation isn't portable. Although FFmpeg has ffserver once upon a time, the IO in libavformat isn’t designed to be used as a server. I'm afraid a real server (e.g, srs-simple realtime server) is more appropriate than stretch libavformat. > > +#include "libavutil/fifo.h" > #include "libavutil/mem.h" > #include "libavutil/opt.h" > #include "libavutil/parseutils.h" > @@ -51,10 +54,22 @@ enum SRTMode { > SRT_MODE_RENDEZVOUS = 2 > }; > > -typedef struct SRTContext { > -const AVClass *class; > +typedef struct SRTClientContext { > +int set; > +int ended; > +URLContext *h; > +pthread_t thread; > +int payload_size; > int fd; > int eid; > +sem_t msg; > +AVFifo *fifo; > +} SRTClientContext; > + > +typedef struct SRTContext { > +const AVClass *class; > +int *fd; > +int *eid; > int64_t rw_timeout; > int64_t listen_timeout; > int recv_buffer_size; > @@ -93,6 +108,13 @@ typedef struct SRTContext { > SRT_TRANSTYPE transtype; > int linger; > int tsbpd; > +pthread_mutex_t accept_mutex; > +pthread_t accept_thread; > +int listen_fd; > +int listen_eid; > +SRTClientContext *client_context; > +int max_clients; > +int close_threads; > } SRTContext; > > #define D AV_OPT_FLAG_DECODING_PARAM > @@ -146,6 +168,7 @@ static const AVOption libsrt_options[] = { > { "file", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRTT_FILE }, > INT_MIN, INT_MAX, .flags = D|E, .unit = "transtype" }, > { "linger", "Number of seconds that the socket waits for unsent > data when closing", OFFSET(linger), AV_OPT_TYPE_INT, { .i64 = > -1 }, -1, INT_MAX, .flags = D|E }, > { "tsbpd", "Timestamp-based packet delivery", > OFFSET(tsbpd),AV_OPT_TYPE_BOOL, { .i64 = -1 > }, -1, 1, .flags = D|E }, > +{ "max_clients","Maximum simultaneous clients when mode=listener and > writing packages", OFFSET(max_clients), AV_OPT_TYPE_INT, { .i64 = 1 > }, 1, INT_MAX, .flags = E }, > { NULL } > }; > > @@ -235,13 +258,159 @@ static int libsrt_network_wait_fd_timeout(URLContext > *h, int eid, int write, int > } > } > > -static int libsrt_listen(int eid, int fd, const struct sockaddr *addr, > socklen_t addrlen, URLContext *h, int64_t timeout) > +static int libsrt_accept(int fd, URLContext *h) > { > int ret; > -int reuse = 1; > /* Max streamid length plus an extra space for the terminating null > character */ > char streamid[513]; > int streamid_len = sizeof(streamid); > + > +ret = srt_accept(fd, NULL, NULL); > +if (ret < 0) > +return libsrt_neterrno(h); > +if (libsrt_socket_nonblock(ret, 1) < 0) > +av_log(h, AV_LOG_DEBUG, "libsrt_socket_nonblock failed\n"); > +if (!libsrt_getsockopt(h, ret, SRTO_STREAMID, "SRTO_STREAMID", streamid, > &streamid_len)) > +/* Note: returned streamid_len doesn't count the terminating null > character */ > +av_log(h, AV_LOG_VERBOSE, "accept streamid [%s], length %d\n", > streamid, streamid_len); > + > +return ret; > +} > + > +static int libsrt_write_common(URLContext *h, int fd, int eid, const uint8_t > *buf, int size) > +{ > +int ret; > + > +if (!(h->flags & AVIO_FLAG_NONBLOCK)) { > +ret = libsrt_network_wait_fd_timeout(h, eid, 1, h->rw_timeout, > &h->interrupt_callback); > +if (ret) > +return ret; > +} > + > +ret = srt_sendmsg(fd, buf, size, -1, 1); > +if (ret < 0) { > +ret = libsrt_neterrno(h); > +} > + > +return ret; > +} > + > +static void *libsrt_client_thread(void *_SRTClientContext) > +{ > +SRTClientContext *c = _SRTClientContext; > +URLContext *h = c->h; > +SRTContext *s = h->priv_data; > +uint8_t *buf; > +int ret; > + > +buf = av_malloc(c->payload_size); > +if (buf == NULL) { > +av_log(h, AV_LOG_ERROR, "%s\n", av_err2str(AVERROR(ENOMEM)); > +return NULL; > +} > +while (!s->close_threads) { > +sem_wait(&c->msg); > +while (!s->close_threads &
[FFmpeg-devel] [PATCH 01/14] swscale/range_convert: call arch-specific init functions from main init function
This commit also fixes the issue that the call to ff_sws_init_range_convert() from sws_init_swscale() was not setting up the arch-specific optimizations. --- libswscale/aarch64/swscale.c | 5 - libswscale/loongarch/swscale_init_loongarch.c | 1 - libswscale/riscv/swscale.c| 7 --- libswscale/swscale.c | 10 ++ libswscale/swscale_internal.h | 1 + libswscale/utils.c| 10 +- libswscale/x86/swscale.c | 2 -- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index eb907284e7..863627d7c3 100644 --- a/libswscale/aarch64/swscale.c +++ b/libswscale/aarch64/swscale.c @@ -225,6 +225,9 @@ void ff_chrRangeToJpeg_neon(int16_t *dstU, int16_t *dstV, int width); av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c) { +int cpu_flags = av_get_cpu_flags(); + +if (have_neon(cpu_flags)) { if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->dstBpc <= 14) { if (c->srcRange) { @@ -236,6 +239,7 @@ av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c) } } } +} } av_cold void ff_sws_init_swscale_aarch64(SwsContext *c) @@ -296,6 +300,5 @@ av_cold void ff_sws_init_swscale_aarch64(SwsContext *c) default: break; } -ff_sws_init_range_convert_aarch64(c); } } diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c index 2a95ede6d9..88ad21a103 100644 --- a/libswscale/loongarch/swscale_init_loongarch.c +++ b/libswscale/loongarch/swscale_init_loongarch.c @@ -95,7 +95,6 @@ av_cold void ff_sws_init_swscale_loongarch(SwsContext *c) } } #endif // #if HAVE_LASX -ff_sws_init_range_convert_loongarch(c); } av_cold void rgb2rgb_init_loongarch(void) diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c index c452d93e5d..ad579308c5 100644 --- a/libswscale/riscv/swscale.c +++ b/libswscale/riscv/swscale.c @@ -26,9 +26,11 @@ void ff_range_chr_to_jpeg_16_rvv(int16_t *, int16_t *, int); void ff_range_lum_from_jpeg_16_rvv(int16_t *, int); void ff_range_chr_from_jpeg_16_rvv(int16_t *, int16_t *, int); -av_cold static void ff_sws_init_range_convert_riscv(SwsContext *c, int flags) +av_cold void ff_sws_init_range_convert_riscv(SwsContext *c) { #if HAVE_RVV +int flags = av_get_cpu_flags(); + static const struct { void (*lum)(int16_t *, int); void (*chr)(int16_t *, int16_t *, int); @@ -67,9 +69,9 @@ RVV_INPUT(rgba32); av_cold void ff_sws_init_swscale_riscv(SwsContext *c) { +#if HAVE_RVV int flags = av_get_cpu_flags(); -#if HAVE_RVV if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) { switch (c->srcFormat) { case AV_PIX_FMT_ABGR: @@ -122,5 +124,4 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c) } } #endif -ff_sws_init_range_convert_riscv(c, flags); } diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 8b6a3a84b4..7f47dab4b6 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -554,6 +554,16 @@ av_cold void ff_sws_init_range_convert(SwsContext *c) } } } + +#if ARCH_AARCH64 +ff_sws_init_range_convert_aarch64(c); +#elif ARCH_LOONGARCH64 +ff_sws_init_range_convert_loongarch(c); +#elif ARCH_RISCV +ff_sws_init_range_convert_riscv(c); +#elif ARCH_X86 +ff_sws_init_range_convert_x86(c); +#endif } static av_cold void sws_init_swscale(SwsContext *c) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 50127d288f..66be22ac05 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -697,6 +697,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY); av_cold void ff_sws_init_range_convert(SwsContext *c); av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c); av_cold void ff_sws_init_range_convert_loongarch(SwsContext *c); +av_cold void ff_sws_init_range_convert_riscv(SwsContext *c); av_cold void ff_sws_init_range_convert_x86(SwsContext *c); SwsFunc ff_yuv2rgb_init_x86(SwsContext *c); diff --git a/libswscale/utils.c b/libswscale/utils.c index c3154d82c1..4dec29ad96 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1078,16 +1078,8 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], c->srcRange = srcRange; c->dstRange = dstRange; -if (need_reinit) { +if (need_reinit) ff_sws_init_range_convert(c); -#if ARCH_AARCH64 -ff_sws_init_range_convert_aarch64(c); -#elif ARCH_LOONGARCH64 -ff_sws_init_range_convert_loongarch(c); -#elif ARCH_X86 -ff_sws_init_range_convert_x86(c); -#endif -} c->dstFormatBpp = av_get_bits_per_pixel(desc_dst); c->srcFormatBpp = av_get_bits_per
[FFmpeg-devel] [PATCH 00/14] swscale/range_convert: fix mpeg ranges in yuv range conversion for non-8-bit pixel formats
There is an issue with the constants used in YUV to YUV range conversion, where the upper bound is not respected when converting to mpeg range. With this patchset, the constants are calculated at runtime, depending on the bit depth. This approach also allows us to more easily understand how the constants are derived. NOTE: simd optimizations for x86 and aarch64 have been updated, but riscv and loongarch are still missing (and therefore disabled). NOTE2: the same issue still exists in rgb2yuv conversions, which is not addressed in this patchset. Ramiro Polla (14): swscale/range_convert: call arch-specific init functions from main init function swscale/range_convert: drop redundant conditionals from arch-specific init functions swscale/range_convert: indent after previous commit checkasm: use FF_ARRAY_ELEMS instead of hardcoding size of arrays checkasm/sw_range_convert: use YUV pixel formats instead of YUVJ checkasm/sw_range_convert: reduce number of input sizes tested checkasm/sw_range_convert: only run benchmarks on largest input width checkasm/sw_range_convert: test all supported bit depths checkasm/sw_range_convert: indent after previous couple of commits swscale/range_convert: fix mpeg ranges in yuv range conversion for non-8-bit pixel formats swscale/x86/range_convert: update sse2 and avx2 range_convert functions to new API swscale/x86: add sse2, sse4, and avx2 {lum,chr}ConvertRange16 swscale/aarch64/range_convert: update neon range_convert functions to new API swscale/aarch64: add neon {lum,chr}ConvertRange16 libswscale/aarch64/range_convert_neon.S | 141 +--- libswscale/aarch64/swscale.c | 41 +++- libswscale/hscale.c | 8 +- libswscale/loongarch/swscale_init_loongarch.c | 35 ++- libswscale/riscv/swscale.c| 12 +- libswscale/swscale.c | 119 +-- libswscale/swscale_internal.h | 13 +- libswscale/utils.c| 10 +- libswscale/x86/range_convert.asm | 201 ++ libswscale/x86/swscale.c | 56 +++-- tests/checkasm/sw_gbrp.c | 15 +- tests/checkasm/sw_range_convert.c | 192 - tests/checkasm/sw_scale.c | 11 +- .../fate/filter-alphaextract_alphamerge_rgb | 100 - tests/ref/fate/filter-pixdesc-gray10be| 2 +- tests/ref/fate/filter-pixdesc-gray10le| 2 +- tests/ref/fate/filter-pixdesc-gray12be| 2 +- tests/ref/fate/filter-pixdesc-gray12le| 2 +- tests/ref/fate/filter-pixdesc-gray14be| 2 +- tests/ref/fate/filter-pixdesc-gray14le| 2 +- tests/ref/fate/filter-pixdesc-gray16be| 2 +- tests/ref/fate/filter-pixdesc-gray16le| 2 +- tests/ref/fate/filter-pixdesc-gray9be | 2 +- tests/ref/fate/filter-pixdesc-gray9le | 2 +- tests/ref/fate/filter-pixdesc-ya16be | 2 +- tests/ref/fate/filter-pixdesc-ya16le | 2 +- tests/ref/fate/filter-pixdesc-yuvj411p| 2 +- tests/ref/fate/filter-pixdesc-yuvj420p| 2 +- tests/ref/fate/filter-pixdesc-yuvj422p| 2 +- tests/ref/fate/filter-pixdesc-yuvj440p| 2 +- tests/ref/fate/filter-pixdesc-yuvj444p| 2 +- tests/ref/fate/filter-pixfmts-copy| 34 +-- tests/ref/fate/filter-pixfmts-crop| 34 +-- tests/ref/fate/filter-pixfmts-field | 34 +-- tests/ref/fate/filter-pixfmts-fieldorder | 30 +-- tests/ref/fate/filter-pixfmts-hflip | 34 +-- tests/ref/fate/filter-pixfmts-il | 34 +-- tests/ref/fate/filter-pixfmts-lut | 18 +- tests/ref/fate/filter-pixfmts-null| 34 +-- tests/ref/fate/filter-pixfmts-pad | 22 +- tests/ref/fate/filter-pixfmts-pullup | 10 +- tests/ref/fate/filter-pixfmts-rotate | 4 +- tests/ref/fate/filter-pixfmts-scale | 34 +-- tests/ref/fate/filter-pixfmts-swapuv | 10 +- .../ref/fate/filter-pixfmts-tinterlace_cvlpf | 8 +- .../ref/fate/filter-pixfmts-tinterlace_merge | 8 +- tests/ref/fate/filter-pixfmts-tinterlace_pad | 8 +- tests/ref/fate/filter-pixfmts-tinterlace_vlpf | 8 +- tests/ref/fate/filter-pixfmts-transpose | 28 +-- tests/ref/fate/filter-pixfmts-vflip | 34 +-- tests/ref/fate/fitsenc-gray | 2 +- tests/ref/fate/fitsenc-gray16be | 10 +- tests/ref/fate/gifenc-gray| 186 tests/ref/fate/idroq-video-encode | 2 +- tests/ref/fate/jpg-icc| 8 +- tests/ref/fate/sws-yuv-colorspace | 2 +- tests/ref/fate/sws-yuv-range | 2 +- tests/ref/fate/vvc-conformance-SCALING_A_1| 128 +-- tests/ref/lavf/gray16be.fits |
[FFmpeg-devel] [PATCH 10/14] swscale/range_convert: fix mpeg ranges in yuv range conversion for non-8-bit pixel formats
There is an issue with the constants used in YUV to YUV range conversion, where the upper bound is not respected when converting to mpeg range. With this commit, the constants are calculated at runtime, depending on the bit depth. This approach also allows us to more easily understand how the constants are derived. For bit depths <= 14, the number of fixed point bits has been set to 14 for all conversions, to simplify the code. For bit depths > 14, the number of fixed points bits has been raised and set to 18, to allow for the conversion to be accurate enough for the mpeg range to be respected. The convert functions now take the conversion constants (amax, coeff, and offset) as function arguments. For bit depths <= 14, amax is 16-bit and offset is 32-bit. For bit depths > 14, amax is 32-bit and offset is 64-bit. NOTE: all simd optimizations for range_convert have been disabled. they will be re-enabled when they are fixed for each sub-arch. NOTE2: the same issue still exists in rgb2yuv conversions, which is not addressed in this commit. --- libswscale/aarch64/swscale.c | 2 + libswscale/hscale.c | 8 +- libswscale/loongarch/swscale_init_loongarch.c | 2 + libswscale/riscv/swscale.c| 2 + libswscale/swscale.c | 109 -- libswscale/swscale_internal.h | 12 +- libswscale/x86/swscale.c | 2 + tests/checkasm/sw_range_convert.c | 80 +++- .../fate/filter-alphaextract_alphamerge_rgb | 100 +- tests/ref/fate/filter-pixdesc-gray10be| 2 +- tests/ref/fate/filter-pixdesc-gray10le| 2 +- tests/ref/fate/filter-pixdesc-gray12be| 2 +- tests/ref/fate/filter-pixdesc-gray12le| 2 +- tests/ref/fate/filter-pixdesc-gray14be| 2 +- tests/ref/fate/filter-pixdesc-gray14le| 2 +- tests/ref/fate/filter-pixdesc-gray16be| 2 +- tests/ref/fate/filter-pixdesc-gray16le| 2 +- tests/ref/fate/filter-pixdesc-gray9be | 2 +- tests/ref/fate/filter-pixdesc-gray9le | 2 +- tests/ref/fate/filter-pixdesc-ya16be | 2 +- tests/ref/fate/filter-pixdesc-ya16le | 2 +- tests/ref/fate/filter-pixdesc-yuvj411p| 2 +- tests/ref/fate/filter-pixdesc-yuvj420p| 2 +- tests/ref/fate/filter-pixdesc-yuvj422p| 2 +- tests/ref/fate/filter-pixdesc-yuvj440p| 2 +- tests/ref/fate/filter-pixdesc-yuvj444p| 2 +- tests/ref/fate/filter-pixfmts-copy| 34 ++-- tests/ref/fate/filter-pixfmts-crop| 34 ++-- tests/ref/fate/filter-pixfmts-field | 34 ++-- tests/ref/fate/filter-pixfmts-fieldorder | 30 +-- tests/ref/fate/filter-pixfmts-hflip | 34 ++-- tests/ref/fate/filter-pixfmts-il | 34 ++-- tests/ref/fate/filter-pixfmts-lut | 18 +- tests/ref/fate/filter-pixfmts-null| 34 ++-- tests/ref/fate/filter-pixfmts-pad | 22 +-- tests/ref/fate/filter-pixfmts-pullup | 10 +- tests/ref/fate/filter-pixfmts-rotate | 4 +- tests/ref/fate/filter-pixfmts-scale | 34 ++-- tests/ref/fate/filter-pixfmts-swapuv | 10 +- .../ref/fate/filter-pixfmts-tinterlace_cvlpf | 8 +- .../ref/fate/filter-pixfmts-tinterlace_merge | 8 +- tests/ref/fate/filter-pixfmts-tinterlace_pad | 8 +- tests/ref/fate/filter-pixfmts-tinterlace_vlpf | 8 +- tests/ref/fate/filter-pixfmts-transpose | 28 +-- tests/ref/fate/filter-pixfmts-vflip | 34 ++-- tests/ref/fate/fitsenc-gray | 2 +- tests/ref/fate/fitsenc-gray16be | 10 +- tests/ref/fate/gifenc-gray| 186 +- tests/ref/fate/idroq-video-encode | 2 +- tests/ref/fate/jpg-icc| 8 +- tests/ref/fate/sws-yuv-colorspace | 2 +- tests/ref/fate/sws-yuv-range | 2 +- tests/ref/fate/vvc-conformance-SCALING_A_1| 128 ++-- tests/ref/lavf/gray16be.fits | 4 +- tests/ref/lavf/gray16be.pam | 4 +- tests/ref/lavf/gray16be.png | 6 +- tests/ref/lavf/jpg| 6 +- tests/ref/lavf/smjpeg | 6 +- tests/ref/pixfmt/yuvj420p | 2 +- tests/ref/pixfmt/yuvj422p | 2 +- tests/ref/pixfmt/yuvj440p | 2 +- tests/ref/pixfmt/yuvj444p | 2 +- tests/ref/seek/lavf-jpg | 8 +- tests/ref/seek/vsynth_lena-mjpeg | 40 ++-- tests/ref/seek/vsynth_lena-roqvideo | 2 +- tests/ref/vsynth/vsynth1-amv | 8 +- tests/ref/vsynth/vsynth1-mjpeg| 6 +- tests/ref/vsynth/vsynth1-mjpeg-422| 6 +- tests/ref/vsynth/vsynth1-mjpeg-444| 6
[FFmpeg-devel] [PATCH 08/14] checkasm/sw_range_convert: test all supported bit depths
This commit also reduces the number of times ff_sws_init_scale() gets called (only once per bit depth), and the number of times randomize_buffers() gets called (only if the function must be checked). Benchmarks are only performed on bit depths 8 and 16 (since they are different functions, and not only different constants). --- tests/checkasm/sw_range_convert.c | 94 +-- 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c index e97388d14a..e3e5096729 100644 --- a/tests/checkasm/sw_range_convert.c +++ b/tests/checkasm/sw_range_convert.c @@ -28,6 +28,33 @@ #include "checkasm.h" +static const enum AVPixelFormat pixel_formats[] = { +AV_PIX_FMT_YUV444P, +AV_PIX_FMT_YUV444P9, +AV_PIX_FMT_YUV444P10, +AV_PIX_FMT_YUV444P12, +AV_PIX_FMT_YUV444P14, +AV_PIX_FMT_YUV444P16, +}; + +static void randomize_buffers(int16_t *buf0, int16_t *buf1, int bit_depth, int width) +{ +int32_t *buf0_32 = (int32_t *) buf0; +int32_t *buf1_32 = (int32_t *) buf1; +int mask = (1 << bit_depth) - 1; +int src_shift = bit_depth <= 14 ? 15 - bit_depth : 19 - bit_depth; +for (int i = 0; i < width; i++) { +int32_t r = rnd() & mask; +if (bit_depth == 16) { +buf0_32[i] = r << src_shift; +buf1_32[i] = r << src_shift; +} else { +buf0[i] = r << src_shift; +buf1[i] = r << src_shift; +} +} +} + static void check_lumConvertRange(int from) { const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg"; @@ -35,8 +62,8 @@ static void check_lumConvertRange(int from) static const int input_sizes[] = {8, LARGEST_INPUT_SIZE}; struct SwsContext *ctx; -LOCAL_ALIGNED_32(int16_t, dst0, [LARGEST_INPUT_SIZE]); -LOCAL_ALIGNED_32(int16_t, dst1, [LARGEST_INPUT_SIZE]); +LOCAL_ALIGNED_32(int16_t, dst0, [LARGEST_INPUT_SIZE * 2]); +LOCAL_ALIGNED_32(int16_t, dst1, [LARGEST_INPUT_SIZE * 2]); declare_func(void, int16_t *dst, int width); @@ -44,28 +71,31 @@ static void check_lumConvertRange(int from) if (sws_init_context(ctx, NULL, NULL) < 0) fail(); -ctx->srcFormat = AV_PIX_FMT_YUV444P; -ctx->dstFormat = AV_PIX_FMT_YUV444P; ctx->srcRange = from; ctx->dstRange = !from; +for (int pfi = 0; pfi < FF_ARRAY_ELEMS(pixel_formats); pfi++) { +enum AVPixelFormat pix_fmt = pixel_formats[pfi]; +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); +int bit_depth = desc->comp[0].depth; +int sample_size = bit_depth == 16 ? sizeof(int32_t) : sizeof(int16_t); +ctx->srcFormat = pix_fmt; +ctx->dstFormat = pix_fmt; +ctx->dstBpc = bit_depth; +ff_sws_init_scale(ctx); for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { int width = input_sizes[dstWi]; -for (int i = 0; i < width; i++) { -uint8_t r = rnd(); -dst0[i] = (int16_t) r << 7; -dst1[i] = (int16_t) r << 7; -} -ff_sws_init_scale(ctx); -if (check_func(ctx->lumConvertRange, "%s_%d", func_str, width)) { +if (check_func(ctx->lumConvertRange, "%s%d_%d", func_str, bit_depth, width)) { +randomize_buffers(dst0, dst1, bit_depth, width); call_ref(dst0, width); call_new(dst1, width); -if (memcmp(dst0, dst1, width * sizeof(int16_t))) +if (memcmp(dst0, dst1, width * sample_size)) fail(); -if (width == LARGEST_INPUT_SIZE) +if (width == LARGEST_INPUT_SIZE && (bit_depth == 8 || bit_depth == 16)) bench_new(dst1, width); } } +} sws_freeContext(ctx); } @@ -78,10 +108,10 @@ static void check_chrConvertRange(int from) static const int input_sizes[] = {8, LARGEST_INPUT_SIZE}; struct SwsContext *ctx; -LOCAL_ALIGNED_32(int16_t, dstU0, [LARGEST_INPUT_SIZE]); -LOCAL_ALIGNED_32(int16_t, dstV0, [LARGEST_INPUT_SIZE]); -LOCAL_ALIGNED_32(int16_t, dstU1, [LARGEST_INPUT_SIZE]); -LOCAL_ALIGNED_32(int16_t, dstV1, [LARGEST_INPUT_SIZE]); +LOCAL_ALIGNED_32(int16_t, dstU0, [LARGEST_INPUT_SIZE * 2]); +LOCAL_ALIGNED_32(int16_t, dstV0, [LARGEST_INPUT_SIZE * 2]); +LOCAL_ALIGNED_32(int16_t, dstU1, [LARGEST_INPUT_SIZE * 2]); +LOCAL_ALIGNED_32(int16_t, dstV1, [LARGEST_INPUT_SIZE * 2]); declare_func(void, int16_t *dstU, int16_t *dstV, int width); @@ -89,31 +119,33 @@ static void check_chrConvertRange(int from) if (sws_init_context(ctx, NULL, NULL) < 0) fail(); -ctx->srcFormat = AV_PIX_FMT_YUV444P; -ctx->dstFormat = AV_PIX_FMT_YUV444P; ctx->srcRange = from; ctx->dstRange = !from; +for (int pfi = 0; pfi < FF_ARRAY_ELEMS(pixel_formats); pfi++) { +enum AVPixelFormat pix_fmt = pixel_formats[pfi]; +const AVPixFmtDescriptor *desc = av_pix_fmt_des
[FFmpeg-devel] [PATCH 12/14] swscale/x86: add sse2, sse4, and avx2 {lum, chr}ConvertRange16
chrRangeFromJpeg16_1920_c:3893.0 ( 1.00x) chrRangeFromJpeg16_1920_sse2: 3249.0 ( 1.20x) chrRangeFromJpeg16_1920_avx2: 1636.0 ( 2.38x) chrRangeToJpeg16_1920_c: 7731.0 ( 1.00x) chrRangeToJpeg16_1920_sse2: 4722.8 ( 1.64x) chrRangeToJpeg16_1920_sse4: 3715.0 ( 2.08x) chrRangeToJpeg16_1920_avx2: 1859.0 ( 4.16x) lumRangeFromJpeg16_1920_c:2385.5 ( 1.00x) lumRangeFromJpeg16_1920_sse2: 1636.0 ( 1.46x) lumRangeFromJpeg16_1920_avx2: 839.8 ( 2.84x) lumRangeToJpeg16_1920_c: 3533.0 ( 1.00x) lumRangeToJpeg16_1920_sse2: 2362.2 ( 1.50x) lumRangeToJpeg16_1920_sse4: 1861.0 ( 1.90x) lumRangeToJpeg16_1920_avx2:946.0 ( 3.73x) --- libswscale/x86/range_convert.asm | 133 ++- libswscale/x86/swscale.c | 50 +--- 2 files changed, 149 insertions(+), 34 deletions(-) diff --git a/libswscale/x86/range_convert.asm b/libswscale/x86/range_convert.asm index d1aff63d7c..83dbe6c4b8 100644 --- a/libswscale/x86/range_convert.asm +++ b/libswscale/x86/range_convert.asm @@ -25,20 +25,28 @@ SECTION .text ;- ; lumConvertRange ; -; void ff_lumRangeToJpeg_(int16_t *dst, int width, -; int amax, int coeff, int64_t offset); -; void ff_lumRangeFromJpeg_(int16_t *dst, int width, -;int amax, int coeff, int64_t offset); +; void ff_lumRangeToJpeg{8,16}_(int16_t *dst, int width, +;int amax, int coeff, int64_t offset); +; void ff_lumRangeFromJpeg{8,16}_(int16_t *dst, int width, +; int amax, int coeff, int64_t offset); ; ;- -%macro LUMCONVERTRANGE 1 +%macro LUMCONVERTRANGE 2 %ifidni %1,To -cglobal lumRange%1Jpeg, 5, 5, 6, dst, width, amax, coeff, offset +%if %2 == 16 +cglobal lumRange%1Jpeg%2, 5, 5, 5, dst, width, amax, coeff, offset +%elif %2 == 8 +cglobal lumRange%1Jpeg%2, 5, 5, 6, dst, width, amax, coeff, offset +%endif ; %2 == 8/16 %else -cglobal lumRange%1Jpeg, 5, 5, 5, dst, width, amax, coeff, offset +cglobal lumRange%1Jpeg%2, 5, 5, 5, dst, width, amax, coeff, offset %endif +%if %2 == 16 +shl widthd, 2 +%elif %2 == 8 shl widthd, 1 +%endif ; %2 == 8/16 movdxm2, coeffd VBROADCASTSS m2, xm2 %if ARCH_X86_64 @@ -46,16 +54,40 @@ cglobal lumRange%1Jpeg, 5, 5, 5, dst, width, amax, coeff, offset %else movqxm3, offsetm %endif +%if %2 == 16 +VBROADCASTSD m3, xm3 +%elif %2 == 8 VBROADCASTSS m3, xm3 pxor m4, m4 +%endif ; %2 == 8/16 %ifidni %1,To +%if %2 == 16 +movdxm4, amaxd +VBROADCASTSS m4, xm4 +%elif %2 == 8 movdxm5, amaxd SPLATW m5, xm5 +%endif ; %2 == 8/16 %endif adddstq, widthq neg widthq .loop: movu m0, [dstq+widthq] +%if %2 == 16 +%ifidni %1,To +PMINSD m0, m4, m1 +%endif +pshufd m1, m0, 0xb1 +pmuludq m0, m2 +pmuludq m1, m2 +paddqm0, m3 +paddqm1, m3 +psrlqm0, 18 +psrlqm1, 18 +pshufd m0, m0, 0xd8 +pshufd m1, m1, 0xd8 +punpckldqm0, m1 +%elif %2 == 8 %ifidni %1,To pminsw m0, m5 %endif @@ -68,6 +100,7 @@ cglobal lumRange%1Jpeg, 5, 5, 5, dst, width, amax, coeff, offset psradm0, 14 psradm1, 14 packssdw m0, m1 +%endif ; %2 == 8/16 movu [dstq+widthq], m0 add widthq, mmsize jl .loop @@ -77,20 +110,28 @@ cglobal lumRange%1Jpeg, 5, 5, 5, dst, width, amax, coeff, offset ;- ; chrConvertRange ; -; void ff_chrRangeToJpeg_(int16_t *dstU, int16_t *dstV, int width, -; int amax, int coeff, int64_t offset); -; void ff_chrRangeFromJpeg_(int16_t *dstU, int16_t *dstV, int width, -;int amax, int coeff, int64_t offset); +; void ff_chrRangeToJpeg{8,16}_(int16_t *dstU, int16_t *dstV, int width, +;int amax, int coeff, int64_t offset); +; void ff_chrRangeFromJpeg{8,16}_(int16_t *dstU, int16_t *dstV, int width, +; int amax, int coeff, int64_t offset); ; ;- -%macro CHRCONVERTRANGE 1 +%macro CHRCONVERTRANGE 2 %ifidni %1,To -cglobal chrRange%1Jpeg, 6, 6,
[FFmpeg-devel] [PATCH 11/14] swscale/x86/range_convert: update sse2 and avx2 range_convert functions to new API
chrRangeFromJpeg8_1920_c: 3874.8 ( 1.00x) chrRangeFromJpeg8_1920_sse2: 1493.8 ( 2.59x) chrRangeFromJpeg8_1920_avx2: 741.8 ( 5.22x) chrRangeToJpeg8_1920_c: 5232.8 ( 1.00x) chrRangeToJpeg8_1920_sse2:1673.3 ( 3.13x) chrRangeToJpeg8_1920_avx2: 850.6 ( 6.15x) lumRangeFromJpeg8_1920_c: 2416.3 ( 1.00x) lumRangeFromJpeg8_1920_sse2: 760.1 ( 3.18x) lumRangeFromJpeg8_1920_avx2: 379.6 ( 6.37x) lumRangeToJpeg8_1920_c: 3121.1 ( 1.00x) lumRangeToJpeg8_1920_sse2: 870.1 ( 3.59x) lumRangeToJpeg8_1920_avx2: 434.8 ( 7.18x) --- libswscale/x86/range_convert.asm | 112 ++- libswscale/x86/swscale.c | 14 ++-- 2 files changed, 73 insertions(+), 53 deletions(-) diff --git a/libswscale/x86/range_convert.asm b/libswscale/x86/range_convert.asm index 97c7525448..d1aff63d7c 100644 --- a/libswscale/x86/range_convert.asm +++ b/libswscale/x86/range_convert.asm @@ -20,55 +20,53 @@ %include "libavutil/x86/x86util.asm" -SECTION_RODATA - -chr_to_mult:times 4 dw 4663, 0 -chr_to_offset: times 4 dd -9289992 -%define chr_to_shift 12 - -chr_from_mult: times 4 dw 1799, 0 -chr_from_offset:times 4 dd 4081085 -%define chr_from_shift 11 - -lum_to_mult:times 4 dw 19077, 0 -lum_to_offset: times 4 dd -39057361 -%define lum_to_shift 14 - -lum_from_mult: times 4 dw 14071, 0 -lum_from_offset:times 4 dd 33561947 -%define lum_from_shift 14 - SECTION .text -; NOTE: there is no need to clamp the input when converting to jpeg range -; (like we do in the C code) because packssdw will saturate the output. - ;- ; lumConvertRange ; -; void ff_lumRangeToJpeg_(int16_t *dst, int width); -; void ff_lumRangeFromJpeg_(int16_t *dst, int width); +; void ff_lumRangeToJpeg_(int16_t *dst, int width, +; int amax, int coeff, int64_t offset); +; void ff_lumRangeFromJpeg_(int16_t *dst, int width, +;int amax, int coeff, int64_t offset); ; ;- -%macro LUMCONVERTRANGE 4 -cglobal %1, 2, 2, 5, dst, width +%macro LUMCONVERTRANGE 1 +%ifidni %1,To +cglobal lumRange%1Jpeg, 5, 5, 6, dst, width, amax, coeff, offset +%else +cglobal lumRange%1Jpeg, 5, 5, 5, dst, width, amax, coeff, offset +%endif shl widthd, 1 -VBROADCASTI128 m2, [%2] -VBROADCASTI128 m3, [%3] +movdxm2, coeffd +VBROADCASTSS m2, xm2 +%if ARCH_X86_64 +movqxm3, offsetq +%else +movqxm3, offsetm +%endif +VBROADCASTSS m3, xm3 pxor m4, m4 +%ifidni %1,To +movdxm5, amaxd +SPLATW m5, xm5 +%endif adddstq, widthq neg widthq .loop: movu m0, [dstq+widthq] +%ifidni %1,To +pminsw m0, m5 +%endif punpckhwdm1, m0, m4 punpcklwdm0, m4 pmaddwd m0, m2 pmaddwd m1, m2 padddm0, m3 padddm1, m3 -psradm0, %4 -psradm1, %4 +psradm0, 14 +psradm1, 14 packssdw m0, m1 movu [dstq+widthq], m0 add widthq, mmsize @@ -79,23 +77,43 @@ cglobal %1, 2, 2, 5, dst, width ;- ; chrConvertRange ; -; void ff_chrRangeToJpeg_(int16_t *dstU, int16_t *dstV, int width); -; void ff_chrRangeFromJpeg_(int16_t *dstU, int16_t *dstV, int width); +; void ff_chrRangeToJpeg_(int16_t *dstU, int16_t *dstV, int width, +; int amax, int coeff, int64_t offset); +; void ff_chrRangeFromJpeg_(int16_t *dstU, int16_t *dstV, int width, +;int amax, int coeff, int64_t offset); ; ;- -%macro CHRCONVERTRANGE 4 -cglobal %1, 3, 3, 7, dstU, dstV, width +%macro CHRCONVERTRANGE 1 +%ifidni %1,To +cglobal chrRange%1Jpeg, 6, 6, 8, dstU, dstV, width, amax, coeff, offset +%else +cglobal chrRange%1Jpeg, 6, 6, 7, dstU, dstV, width, amax, coeff, offset +%endif shl widthd, 1 -VBROADCASTI128 m4, [%2] -VBROADCASTI128 m5, [%3] +movdxm4, coeffd +VBROADCASTSS m4, xm4 +%if ARCH_X86_64 +movqxm5, offsetq +%else +movqxm5, offsetm +%endif +VBROADCASTSS m5, xm5 pxor m6, m6 +%ifidni %1,To +movdxm7, amaxd +SPLATW m7, xm7 +%endif add dstUq, widthq add
[FFmpeg-devel] [PATCH 06/14] checkasm/sw_range_convert: reduce number of input sizes tested
Reduce input sizes to 8 (to test that the function works with widths smaller than the vector length) and 1920 (raising the largest input size to improve benchmark results). --- tests/checkasm/sw_range_convert.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c index 8c8af995e7..df27b6c81e 100644 --- a/tests/checkasm/sw_range_convert.c +++ b/tests/checkasm/sw_range_convert.c @@ -31,8 +31,8 @@ static void check_lumConvertRange(int from) { const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg"; -#define LARGEST_INPUT_SIZE 512 -static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; +#define LARGEST_INPUT_SIZE 1920 +static const int input_sizes[] = {8, LARGEST_INPUT_SIZE}; struct SwsContext *ctx; LOCAL_ALIGNED_32(int16_t, dst0, [LARGEST_INPUT_SIZE]); @@ -73,8 +73,8 @@ static void check_lumConvertRange(int from) static void check_chrConvertRange(int from) { const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg"; -#define LARGEST_INPUT_SIZE 512 -static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; +#define LARGEST_INPUT_SIZE 1920 +static const int input_sizes[] = {8, LARGEST_INPUT_SIZE}; struct SwsContext *ctx; LOCAL_ALIGNED_32(int16_t, dstU0, [LARGEST_INPUT_SIZE]); -- 2.30.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 07/14] checkasm/sw_range_convert: only run benchmarks on largest input width
--- tests/checkasm/sw_range_convert.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c index df27b6c81e..e97388d14a 100644 --- a/tests/checkasm/sw_range_convert.c +++ b/tests/checkasm/sw_range_convert.c @@ -62,6 +62,7 @@ static void check_lumConvertRange(int from) call_new(dst1, width); if (memcmp(dst0, dst1, width * sizeof(int16_t))) fail(); +if (width == LARGEST_INPUT_SIZE) bench_new(dst1, width); } } @@ -109,6 +110,7 @@ static void check_chrConvertRange(int from) if (memcmp(dstU0, dstU1, width * sizeof(int16_t)) || memcmp(dstV0, dstV1, width * sizeof(int16_t))) fail(); +if (width == LARGEST_INPUT_SIZE) bench_new(dstU1, dstV1, width); } } -- 2.30.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 04/14] checkasm: use FF_ARRAY_ELEMS instead of hardcoding size of arrays
--- tests/checkasm/sw_gbrp.c | 15 --- tests/checkasm/sw_range_convert.c | 8 ++-- tests/checkasm/sw_scale.c | 11 --- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/tests/checkasm/sw_gbrp.c b/tests/checkasm/sw_gbrp.c index d843730f3e..744dfb9dab 100644 --- a/tests/checkasm/sw_gbrp.c +++ b/tests/checkasm/sw_gbrp.c @@ -71,7 +71,6 @@ static void check_output_yuv2gbrp(void) #define FILTER_SIZES 4 static const int filter_sizes[] = {1, 4, 8, 16}; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; uint8_t *dst0[4]; uint8_t *dst1[4]; @@ -138,7 +137,7 @@ static void check_output_yuv2gbrp(void) for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { for (fsi = 0; fsi < FILTER_SIZES; fsi++) { -for (isi = 0; isi < INPUT_SIZES; isi++ ) { +for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); ctx->dstFormat = planar_fmts[fmi]; @@ -185,7 +184,6 @@ static void check_output_yuv2gbrp(void) } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES static void check_input_planar_rgb_to_y(void) { @@ -194,7 +192,6 @@ static void check_input_planar_rgb_to_y(void) int fmi, isi; int dstW, byte_size; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; const uint8_t *src[4]; int32_t rgb2yuv[9] = {0}; @@ -226,7 +223,7 @@ static void check_input_planar_rgb_to_y(void) fail(); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { -for (isi = 0; isi < INPUT_SIZES; isi++ ) { +for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); ctx->srcFormat = planar_fmts[fmi]; ctx->dstFormat = AV_PIX_FMT_YUVA444P16; @@ -253,7 +250,6 @@ static void check_input_planar_rgb_to_y(void) } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES static void check_input_planar_rgb_to_uv(void) { @@ -262,7 +258,6 @@ static void check_input_planar_rgb_to_uv(void) int fmi, isi; int dstW, byte_size; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; const uint8_t *src[4]; int32_t rgb2yuv[9] = {0}; @@ -297,7 +292,7 @@ static void check_input_planar_rgb_to_uv(void) fail(); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { -for (isi = 0; isi < INPUT_SIZES; isi++ ) { +for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); ctx->srcFormat = planar_fmts[fmi]; ctx->dstFormat = AV_PIX_FMT_YUVA444P16; @@ -326,7 +321,6 @@ static void check_input_planar_rgb_to_uv(void) } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES static void check_input_planar_rgb_to_a(void) { @@ -335,7 +329,6 @@ static void check_input_planar_rgb_to_a(void) int fmi, isi; int dstW, byte_size; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; const uint8_t *src[4]; int32_t rgb2yuv[9] = {0}; @@ -367,7 +360,7 @@ static void check_input_planar_rgb_to_a(void) fail(); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { -for (isi = 0; isi < INPUT_SIZES; isi++ ) { +for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) continue; diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c index 08029103d1..1f04988097 100644 --- a/tests/checkasm/sw_range_convert.c +++ b/tests/checkasm/sw_range_convert.c @@ -32,7 +32,6 @@ static void check_lumConvertRange(int from) { const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg"; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; struct SwsContext *ctx; @@ -50,7 +49,7 @@ static void check_lumConvertRange(int from) ctx->srcRange = from; ctx->dstRange = !from; -for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) { +for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { int width = input_sizes[dstWi]; for (int i = 0; i < width; i++) { uint8_t r = rnd(); @@ -70,13 +69,11 @@ static void check_lumConvertRange(int from) sws_freeContext(ctx); } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES static void check_chrConvertRange(int from) { const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg"; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
[FFmpeg-devel] [PATCH 03/14] swscale/range_convert: indent after previous commit
--- libswscale/loongarch/swscale_init_loongarch.c | 32 +-- libswscale/swscale.c | 8 ++--- libswscale/x86/swscale.c | 12 +++ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c index 9f12f5e166..de75ffc6dc 100644 --- a/libswscale/loongarch/swscale_init_loongarch.c +++ b/libswscale/loongarch/swscale_init_loongarch.c @@ -29,27 +29,27 @@ av_cold void ff_sws_init_range_convert_loongarch(SwsContext *c) int cpu_flags = av_get_cpu_flags(); if (have_lsx(cpu_flags)) { -if (c->dstBpc <= 14) { -if (c->srcRange) { -c->lumConvertRange = lumRangeFromJpeg_lsx; -c->chrConvertRange = chrRangeFromJpeg_lsx; -} else { -c->lumConvertRange = lumRangeToJpeg_lsx; -c->chrConvertRange = chrRangeToJpeg_lsx; -} +if (c->dstBpc <= 14) { +if (c->srcRange) { +c->lumConvertRange = lumRangeFromJpeg_lsx; +c->chrConvertRange = chrRangeFromJpeg_lsx; +} else { +c->lumConvertRange = lumRangeToJpeg_lsx; +c->chrConvertRange = chrRangeToJpeg_lsx; } +} } #if HAVE_LASX if (have_lasx(cpu_flags)) { -if (c->dstBpc <= 14) { -if (c->srcRange) { -c->lumConvertRange = lumRangeFromJpeg_lasx; -c->chrConvertRange = chrRangeFromJpeg_lasx; -} else { -c->lumConvertRange = lumRangeToJpeg_lasx; -c->chrConvertRange = chrRangeToJpeg_lasx; -} +if (c->dstBpc <= 14) { +if (c->srcRange) { +c->lumConvertRange = lumRangeFromJpeg_lasx; +c->chrConvertRange = chrRangeFromJpeg_lasx; +} else { +c->lumConvertRange = lumRangeToJpeg_lasx; +c->chrConvertRange = chrRangeToJpeg_lasx; } +} } #endif // #if HAVE_LASX } diff --git a/libswscale/swscale.c b/libswscale/swscale.c index df9d3e5ae3..18e213b21b 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -555,13 +555,13 @@ av_cold void ff_sws_init_range_convert(SwsContext *c) } #if ARCH_AARCH64 -ff_sws_init_range_convert_aarch64(c); +ff_sws_init_range_convert_aarch64(c); #elif ARCH_LOONGARCH64 -ff_sws_init_range_convert_loongarch(c); +ff_sws_init_range_convert_loongarch(c); #elif ARCH_RISCV -ff_sws_init_range_convert_riscv(c); +ff_sws_init_range_convert_riscv(c); #elif ARCH_X86 -ff_sws_init_range_convert_x86(c); +ff_sws_init_range_convert_x86(c); #endif } } diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index 7ecb1f6542..a836de734c 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -474,12 +474,12 @@ RANGE_CONVERT_FUNCS_DECL(avx2); av_cold void ff_sws_init_range_convert_x86(SwsContext *c) { -int cpu_flags = av_get_cpu_flags(); -if (EXTERNAL_AVX2_FAST(cpu_flags)) { -RANGE_CONVERT_FUNCS(avx2); -} else if (EXTERNAL_SSE2(cpu_flags)) { -RANGE_CONVERT_FUNCS(sse2); -} +int cpu_flags = av_get_cpu_flags(); +if (EXTERNAL_AVX2_FAST(cpu_flags)) { +RANGE_CONVERT_FUNCS(avx2); +} else if (EXTERNAL_SSE2(cpu_flags)) { +RANGE_CONVERT_FUNCS(sse2); +} } av_cold void ff_sws_init_swscale_x86(SwsContext *c) -- 2.30.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 09/14] checkasm/sw_range_convert: indent after previous couple of commits
--- tests/checkasm/sw_range_convert.c | 48 +++ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c index e3e5096729..01c4549e53 100644 --- a/tests/checkasm/sw_range_convert.c +++ b/tests/checkasm/sw_range_convert.c @@ -83,19 +83,19 @@ static void check_lumConvertRange(int from) ctx->dstFormat = pix_fmt; ctx->dstBpc = bit_depth; ff_sws_init_scale(ctx); -for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { -int width = input_sizes[dstWi]; -if (check_func(ctx->lumConvertRange, "%s%d_%d", func_str, bit_depth, width)) { -randomize_buffers(dst0, dst1, bit_depth, width); -call_ref(dst0, width); -call_new(dst1, width); -if (memcmp(dst0, dst1, width * sample_size)) -fail(); -if (width == LARGEST_INPUT_SIZE && (bit_depth == 8 || bit_depth == 16)) -bench_new(dst1, width); +for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { +int width = input_sizes[dstWi]; +if (check_func(ctx->lumConvertRange, "%s%d_%d", func_str, bit_depth, width)) { +randomize_buffers(dst0, dst1, bit_depth, width); +call_ref(dst0, width); +call_new(dst1, width); +if (memcmp(dst0, dst1, width * sample_size)) +fail(); +if (width == LARGEST_INPUT_SIZE && (bit_depth == 8 || bit_depth == 16)) +bench_new(dst1, width); +} } } -} sws_freeContext(ctx); } @@ -131,21 +131,21 @@ static void check_chrConvertRange(int from) ctx->dstFormat = pix_fmt; ctx->dstBpc = bit_depth; ff_sws_init_scale(ctx); -for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { -int width = input_sizes[dstWi]; -if (check_func(ctx->chrConvertRange, "%s%d_%d", func_str, bit_depth, width)) { -randomize_buffers(dstU0, dstU1, bit_depth, width); -randomize_buffers(dstV0, dstV1, bit_depth, width); -call_ref(dstU0, dstV0, width); -call_new(dstU1, dstV1, width); -if (memcmp(dstU0, dstU1, width * sample_size) || -memcmp(dstV0, dstV1, width * sample_size)) -fail(); -if (width == LARGEST_INPUT_SIZE && (bit_depth == 8 || bit_depth == 16)) -bench_new(dstU1, dstV1, width); +for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { +int width = input_sizes[dstWi]; +if (check_func(ctx->chrConvertRange, "%s%d_%d", func_str, bit_depth, width)) { +randomize_buffers(dstU0, dstU1, bit_depth, width); +randomize_buffers(dstV0, dstV1, bit_depth, width); +call_ref(dstU0, dstV0, width); +call_new(dstU1, dstV1, width); +if (memcmp(dstU0, dstU1, width * sample_size) || +memcmp(dstV0, dstV1, width * sample_size)) +fail(); +if (width == LARGEST_INPUT_SIZE && (bit_depth == 8 || bit_depth == 16)) +bench_new(dstU1, dstV1, width); +} } } -} sws_freeContext(ctx); } -- 2.30.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 02/14] swscale/range_convert: drop redundant conditionals from arch-specific init functions
These conditions are already checked for in the main init function. --- libswscale/aarch64/swscale.c | 2 -- libswscale/loongarch/swscale_init_loongarch.c | 4 libswscale/riscv/swscale.c| 3 +-- libswscale/swscale.c | 2 +- libswscale/x86/swscale.c | 2 -- 5 files changed, 2 insertions(+), 11 deletions(-) diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index 863627d7c3..653144dbca 100644 --- a/libswscale/aarch64/swscale.c +++ b/libswscale/aarch64/swscale.c @@ -228,7 +228,6 @@ av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c) int cpu_flags = av_get_cpu_flags(); if (have_neon(cpu_flags)) { -if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->dstBpc <= 14) { if (c->srcRange) { c->lumConvertRange = ff_lumRangeFromJpeg_neon; @@ -239,7 +238,6 @@ av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c) } } } -} } av_cold void ff_sws_init_swscale_aarch64(SwsContext *c) diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c index 88ad21a103..9f12f5e166 100644 --- a/libswscale/loongarch/swscale_init_loongarch.c +++ b/libswscale/loongarch/swscale_init_loongarch.c @@ -29,7 +29,6 @@ av_cold void ff_sws_init_range_convert_loongarch(SwsContext *c) int cpu_flags = av_get_cpu_flags(); if (have_lsx(cpu_flags)) { -if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->dstBpc <= 14) { if (c->srcRange) { c->lumConvertRange = lumRangeFromJpeg_lsx; @@ -39,11 +38,9 @@ av_cold void ff_sws_init_range_convert_loongarch(SwsContext *c) c->chrConvertRange = chrRangeToJpeg_lsx; } } -} } #if HAVE_LASX if (have_lasx(cpu_flags)) { -if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->dstBpc <= 14) { if (c->srcRange) { c->lumConvertRange = lumRangeFromJpeg_lasx; @@ -53,7 +50,6 @@ av_cold void ff_sws_init_range_convert_loongarch(SwsContext *c) c->chrConvertRange = chrRangeToJpeg_lasx; } } -} } #endif // #if HAVE_LASX } diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c index ad579308c5..fc592c39d5 100644 --- a/libswscale/riscv/swscale.c +++ b/libswscale/riscv/swscale.c @@ -39,8 +39,7 @@ av_cold void ff_sws_init_range_convert_riscv(SwsContext *c) { ff_range_lum_from_jpeg_16_rvv, ff_range_chr_from_jpeg_16_rvv }, }; -if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat) && -c->dstBpc <= 14 && +if (c->dstBpc <= 14 && (flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) { bool from = c->srcRange != 0; diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 7f47dab4b6..df9d3e5ae3 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -553,7 +553,6 @@ av_cold void ff_sws_init_range_convert(SwsContext *c) c->chrConvertRange = chrRangeToJpeg16_c; } } -} #if ARCH_AARCH64 ff_sws_init_range_convert_aarch64(c); @@ -564,6 +563,7 @@ av_cold void ff_sws_init_range_convert(SwsContext *c) #elif ARCH_X86 ff_sws_init_range_convert_x86(c); #endif +} } static av_cold void sws_init_swscale(SwsContext *c) diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index c82311d87b..7ecb1f6542 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -474,14 +474,12 @@ RANGE_CONVERT_FUNCS_DECL(avx2); av_cold void ff_sws_init_range_convert_x86(SwsContext *c) { -if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { int cpu_flags = av_get_cpu_flags(); if (EXTERNAL_AVX2_FAST(cpu_flags)) { RANGE_CONVERT_FUNCS(avx2); } else if (EXTERNAL_SSE2(cpu_flags)) { RANGE_CONVERT_FUNCS(sse2); } -} } av_cold void ff_sws_init_swscale_x86(SwsContext *c) -- 2.30.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 05/14] checkasm/sw_range_convert: use YUV pixel formats instead of YUVJ
We are already setting the range, so we can use regular YUV pixel formats instead of YUVJ. --- tests/checkasm/sw_range_convert.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c index 1f04988097..8c8af995e7 100644 --- a/tests/checkasm/sw_range_convert.c +++ b/tests/checkasm/sw_range_convert.c @@ -44,8 +44,8 @@ static void check_lumConvertRange(int from) if (sws_init_context(ctx, NULL, NULL) < 0) fail(); -ctx->srcFormat = from ? AV_PIX_FMT_YUVJ444P : AV_PIX_FMT_YUV444P; -ctx->dstFormat = from ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; +ctx->srcFormat = AV_PIX_FMT_YUV444P; +ctx->dstFormat = AV_PIX_FMT_YUV444P; ctx->srcRange = from; ctx->dstRange = !from; @@ -88,8 +88,8 @@ static void check_chrConvertRange(int from) if (sws_init_context(ctx, NULL, NULL) < 0) fail(); -ctx->srcFormat = from ? AV_PIX_FMT_YUVJ444P : AV_PIX_FMT_YUV444P; -ctx->dstFormat = from ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; +ctx->srcFormat = AV_PIX_FMT_YUV444P; +ctx->dstFormat = AV_PIX_FMT_YUV444P; ctx->srcRange = from; ctx->dstRange = !from; -- 2.30.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 14/14] swscale/aarch64: add neon {lum, chr}ConvertRange16
A55 A76 chrRangeFromJpeg16_1920_c: 28848.5 6325.2 chrRangeFromJpeg16_1920_neon: 8433.0 ( 3.42x) 3365.8 ( 1.88x) chrRangeToJpeg16_1920_c: 36558.7 9479.0 chrRangeToJpeg16_1920_neon: 9395.5 ( 3.89x) 4083.8 ( 2.32x) lumRangeFromJpeg16_1920_c: 15390.0 4430.5 lumRangeFromJpeg16_1920_neon: 4588.7 ( 3.35x) 1814.5 ( 2.44x) lumRangeToJpeg16_1920_c: 19223.0 6014.8 lumRangeToJpeg16_1920_neon: 5306.0 ( 3.62x) 2050.8 ( 2.93x) --- libswscale/aarch64/range_convert_neon.S | 94 ++--- libswscale/aarch64/swscale.c| 36 +++--- 2 files changed, 112 insertions(+), 18 deletions(-) diff --git a/libswscale/aarch64/range_convert_neon.S b/libswscale/aarch64/range_convert_neon.S index 3454ee4932..067e524195 100644 --- a/libswscale/aarch64/range_convert_neon.S +++ b/libswscale/aarch64/range_convert_neon.S @@ -20,13 +20,41 @@ #include "libavutil/aarch64/asm.S" -.macro lumConvertRange fromto -function ff_lumRange\fromto\()Jpeg_neon, export=1 +.macro lumConvertRange fromto, bit_depth +function ff_lumRange\fromto\()Jpeg\bit_depth\()_neon, export=1 // x0 int16_t *dst // w1 int width // w2 int amax // w3 int coeff // x4 int64_t offset +.if \bit_depth == 16 +.ifc \fromto, To +dup v24.4s, w2 +.endif +dup v25.4s, w3 +dup v26.2d, x4 +1: +ld1 {v0.4s, v1.4s}, [x0] +.ifc \fromto, To +sminv0.4s, v0.4s, v24.4s +sminv1.4s, v1.4s, v24.4s +.endif +mov v16.16b, v26.16b +mov v17.16b, v26.16b +mov v18.16b, v26.16b +mov v19.16b, v26.16b +smlal v16.2d, v0.2s, v25.2s +smlal2 v17.2d, v0.4s, v25.4s +smlal v18.2d, v1.2s, v25.2s +smlal2 v19.2d, v1.4s, v25.4s +shrnv0.2s, v16.2d, 18 +shrn2 v0.4s, v17.2d, 18 +shrnv1.2s, v18.2d, 18 +shrn2 v1.4s, v19.2d, 18 +subsw1, w1, #8 +st1 {v0.4s, v1.4s}, [x0], #32 +b.gt1b +.else .ifc \fromto, To dup v24.8h, w2 .endif @@ -48,18 +76,63 @@ function ff_lumRange\fromto\()Jpeg_neon, export=1 subsw1, w1, #8 st1 {v0.8h}, [x0], #16 b.gt1b +.endif ret endfunc .endm -.macro chrConvertRange fromto -function ff_chrRange\fromto\()Jpeg_neon, export=1 +.macro chrConvertRange fromto, bit_depth +function ff_chrRange\fromto\()Jpeg\bit_depth\()_neon, export=1 // x0 int16_t *dstU // x1 int16_t *dstV // w2 int width // w3 int amax // w4 int coeff // x5 int64_t offset +.if \bit_depth == 16 +.ifc \fromto, To +dup v24.4s, w3 +.endif +dup v25.4s, w4 +dup v26.2d, x5 +1: +ld1 {v0.4s, v1.4s}, [x0] +ld1 {v2.4s, v3.4s}, [x1] +.ifc \fromto, To +sminv0.4s, v0.4s, v24.4s +sminv1.4s, v1.4s, v24.4s +sminv2.4s, v2.4s, v24.4s +sminv3.4s, v3.4s, v24.4s +.endif +mov v16.16b, v26.16b +mov v17.16b, v26.16b +mov v18.16b, v26.16b +mov v19.16b, v26.16b +mov v20.16b, v26.16b +mov v21.16b, v26.16b +mov v22.16b, v26.16b +mov v23.16b, v26.16b +smlal v16.2d, v0.2s, v25.2s +smlal2 v17.2d, v0.4s, v25.4s +smlal v18.2d, v1.2s, v25.2s +smlal2 v19.2d, v1.4s, v25.4s +smlal v20.2d, v2.2s, v25.2s +smlal2 v21.2d, v2.4s, v25.4s +smlal v22.2d, v3.2s, v25.2s +smlal2 v23.2d, v3.4s, v25.4s +shrnv0.2s, v16.2d, 18 +shrn2 v0.4s, v17.2d, 18 +shrnv1.2s, v18.2d, 18 +shrn2 v1.4s, v19.2d, 18 +shrnv2.2s, v20.2d, 18 +shrn2 v2.4s, v21.2d, 18 +shrnv3.2s, v22.2d, 18 +shrn2 v3.4s, v23.2d, 18 +subsw2, w2, #8 +st1 {v0.4s, v1.4s}, [x0], #32 +st1 {v2.4s, v3.4s}, [x1], #32 +b.gt1b +.else .ifc \fromto, To dup v24.8h, w3 .endif @@ -92,11 +165,16 @@ function ff_chrRange\fromto\()Jpeg_neon, export=1 st1 {v0.8h}, [x0], #16 st1 {v1.8h}, [x1], #16 b.gt1b +.endif ret endfunc .endm -lumConvertRange To -chrConvertRange To -lumConvertRange From -chrConvertRange From +lumConvertRange To,8 +lumConvertRange To, 16 +chrConvertRange To,8 +
[FFmpeg-devel] [PATCH 13/14] swscale/aarch64/range_convert: update neon range_convert functions to new API
A55 A76 chrRangeFromJpeg8_1920_c: 28842.4 6346.5 chrRangeFromJpeg8_1920_neon: 5310.9 ( 5.43x) 2264.2 ( 2.80x) chrRangeToJpeg8_1920_c: 36520.7 9514.0 chrRangeToJpeg8_1920_neon: 6033.2 ( 6.05x) 2645.5 ( 3.60x) lumRangeFromJpeg8_1920_c: 15387.2 .5 lumRangeFromJpeg8_1920_neon: 3148.9 ( 4.89x) 1108.0 ( 4.01x) lumRangeToJpeg8_1920_c: 19226.4 6015.5 lumRangeToJpeg8_1920_neon: 3866.7 ( 4.97x) 1344.8 ( 4.47x) --- libswscale/aarch64/range_convert_neon.S | 63 + libswscale/aarch64/swscale.c| 14 +++--- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/libswscale/aarch64/range_convert_neon.S b/libswscale/aarch64/range_convert_neon.S index 30991ab2a6..3454ee4932 100644 --- a/libswscale/aarch64/range_convert_neon.S +++ b/libswscale/aarch64/range_convert_neon.S @@ -20,20 +20,21 @@ #include "libavutil/aarch64/asm.S" -.macro lumConvertRange name, max, mult, offset, shift -function ff_\name, export=1 -.if \max != 0 -mov w3, #\max -dup v24.8h, w3 +.macro lumConvertRange fromto +function ff_lumRange\fromto\()Jpeg_neon, export=1 +// x0 int16_t *dst +// w1 int width +// w2 int amax +// w3 int coeff +// x4 int64_t offset +.ifc \fromto, To +dup v24.8h, w2 .endif -mov w3, #\mult dup v25.4s, w3 -movzw3, #(\offset & 0x) -movkw3, #((\offset >> 16) & 0x), lsl #16 -dup v26.4s, w3 +dup v26.4s, w4 1: ld1 {v0.8h}, [x0] -.if \max != 0 +.ifc \fromto, To sminv0.8h, v0.8h, v24.8h .endif mov v16.16b, v26.16b @@ -42,8 +43,8 @@ function ff_\name, export=1 sxtl2 v22.4s, v0.8h mla v16.4s, v20.4s, v25.4s mla v18.4s, v22.4s, v25.4s -shrnv0.4h, v16.4s, #\shift -shrn2 v0.8h, v18.4s, #\shift +shrnv0.4h, v16.4s, 14 +shrn2 v0.8h, v18.4s, 14 subsw1, w1, #8 st1 {v0.8h}, [x0], #16 b.gt1b @@ -51,21 +52,23 @@ function ff_\name, export=1 endfunc .endm -.macro chrConvertRange name, max, mult, offset, shift -function ff_\name, export=1 -.if \max != 0 -mov w3, #\max +.macro chrConvertRange fromto +function ff_chrRange\fromto\()Jpeg_neon, export=1 +// x0 int16_t *dstU +// x1 int16_t *dstV +// w2 int width +// w3 int amax +// w4 int coeff +// x5 int64_t offset +.ifc \fromto, To dup v24.8h, w3 .endif -mov w3, #\mult -dup v25.4s, w3 -movzw3, #(\offset & 0x) -movkw3, #((\offset >> 16) & 0x), lsl #16 -dup v26.4s, w3 +dup v25.4s, w4 +dup v26.4s, w5 1: ld1 {v0.8h}, [x0] ld1 {v1.8h}, [x1] -.if \max != 0 +.ifc \fromto, To sminv0.8h, v0.8h, v24.8h sminv1.8h, v1.8h, v24.8h .endif @@ -81,10 +84,10 @@ function ff_\name, export=1 mla v17.4s, v21.4s, v25.4s mla v18.4s, v22.4s, v25.4s mla v19.4s, v23.4s, v25.4s -shrnv0.4h, v16.4s, #\shift -shrnv1.4h, v17.4s, #\shift -shrn2 v0.8h, v18.4s, #\shift -shrn2 v1.8h, v19.4s, #\shift +shrnv0.4h, v16.4s, 14 +shrnv1.4h, v17.4s, 14 +shrn2 v0.8h, v18.4s, 14 +shrn2 v1.8h, v19.4s, 14 subsw2, w2, #8 st1 {v0.8h}, [x0], #16 st1 {v1.8h}, [x1], #16 @@ -93,7 +96,7 @@ function ff_\name, export=1 endfunc .endm -lumConvertRange lumRangeToJpeg_neon, 30189, 19077, -39057361, 14 -chrConvertRange chrRangeToJpeg_neon, 30775, 4663, -9289992, 12 -lumConvertRange lumRangeFromJpeg_neon, 0, 14071, 33561947, 14 -chrConvertRange chrRangeFromJpeg_neon, 0, 1799, 4081085, 11 +lumConvertRange To +chrConvertRange To +lumConvertRange From +chrConvertRange From diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index 21788cad5d..55fb81c1e3 100644 --- a/libswscale/aarch64/swscale.c +++ b/libswscale/aarch64/swscale.c @@ -218,14 +218,17 @@ NEON_INPUT(bgra32); NEON_INPUT(rgb24); NEON_INPUT(rgba32); -void ff_lumRangeFromJpeg_neon(int16_t *dst, int width); -void ff_chrRangeFromJpeg_neon(int16_t *dstU, int16_t *dstV, int width); -void ff_lumRangeToJpeg_neon(int16_t *dst, int width); -void ff_chrRangeToJpeg_neon(int16_t *dstU, int16_t *dstV, int width); +void ff_lumRangeFromJpeg_neon(int16_t *dst, int width, + int amax
Re: [FFmpeg-devel] [PATCH 2/4] aarch64/vvc: Add apply_bdof
Drop patch 2/4 for now. It needs more polish. See patch v2 https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333800.html > On Sep 22, 2024, at 01:41, Zhao Zhili wrote: > > From: Zhao Zhili > > apply_bdof_8_8x16_c:18.7 ( 1.00x) > apply_bdof_8_8x16_neon: 9.7 ( 1.93x) > apply_bdof_8_16x8_c:20.0 ( 1.00x) > apply_bdof_8_16x8_neon: 9.5 ( 2.11x) > apply_bdof_8_16x16_c: 36.7 ( 1.00x) > apply_bdof_8_16x16_neon:19.0 ( 1.94x) > apply_bdof_10_8x16_c: 18.0 ( 1.00x) > apply_bdof_10_8x16_neon:10.0 ( 1.80x) > apply_bdof_10_16x8_c: 18.0 ( 1.00x) > apply_bdof_10_16x8_neon: 9.5 ( 1.90x) > apply_bdof_10_16x16_c: 35.5 ( 1.00x) > apply_bdof_10_16x16_neon: 19.0 ( 1.87x) > apply_bdof_12_8x16_c: 17.5 ( 1.00x) > apply_bdof_12_8x16_neon: 9.7 ( 1.80x) > apply_bdof_12_16x8_c: 18.2 ( 1.00x) > apply_bdof_12_16x8_neon: 9.5 ( 1.92x) > apply_bdof_12_16x16_c: 34.5 ( 1.00x) > apply_bdof_12_16x16_neon: 18.7 ( 1.84x) > --- > libavcodec/aarch64/vvc/dsp_init.c| 9 + > libavcodec/aarch64/vvc/inter.S | 351 +++ > libavcodec/aarch64/vvc/of_template.c | 70 ++ > 3 files changed, 430 insertions(+) > create mode 100644 libavcodec/aarch64/vvc/of_template.c > > diff --git a/libavcodec/aarch64/vvc/dsp_init.c > b/libavcodec/aarch64/vvc/dsp_init.c > index b39ebb83fc..03a4c62310 100644 > --- a/libavcodec/aarch64/vvc/dsp_init.c > +++ b/libavcodec/aarch64/vvc/dsp_init.c > @@ -27,16 +27,22 @@ > #include "libavcodec/vvc/dec.h" > #include "libavcodec/vvc/ctu.h" > > +#define BDOF_BLOCK_SIZE 16 > +#define BDOF_MIN_BLOCK_SIZE 4 > + > #define BIT_DEPTH 8 > #include "alf_template.c" > +#include "of_template.c" > #undef BIT_DEPTH > > #define BIT_DEPTH 10 > #include "alf_template.c" > +#include "of_template.c" > #undef BIT_DEPTH > > #define BIT_DEPTH 12 > #include "alf_template.c" > +#include "of_template.c" > #undef BIT_DEPTH > > int ff_vvc_sad_neon(const int16_t *src0, const int16_t *src1, int dx, int dy, > @@ -155,6 +161,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, > const int bd) > > c->inter.avg = ff_vvc_avg_8_neon; > c->inter.w_avg = vvc_w_avg_8; > +c->inter.apply_bdof = apply_bdof_8; > > for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++) > c->sao.band_filter[i] = ff_h26x_sao_band_filter_8x8_8_neon; > @@ -196,12 +203,14 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, > const int bd) > } else if (bd == 10) { > c->inter.avg = ff_vvc_avg_10_neon; > c->inter.w_avg = vvc_w_avg_10; > +c->inter.apply_bdof = apply_bdof_10; > > c->alf.filter[LUMA] = alf_filter_luma_10_neon; > c->alf.filter[CHROMA] = alf_filter_chroma_10_neon; > } else if (bd == 12) { > c->inter.avg = ff_vvc_avg_12_neon; > c->inter.w_avg = vvc_w_avg_12; > +c->inter.apply_bdof = apply_bdof_12; > > c->alf.filter[LUMA] = alf_filter_luma_12_neon; > c->alf.filter[CHROMA] = alf_filter_chroma_12_neon; > diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S > index 49e1050aee..8cfacef44f 100644 > --- a/libavcodec/aarch64/vvc/inter.S > +++ b/libavcodec/aarch64/vvc/inter.S > @@ -21,6 +21,8 @@ > #include "libavutil/aarch64/asm.S" > > #define VVC_MAX_PB_SIZE 128 > +#define BDOF_BLOCK_SIZE 16 > +#define BDOF_MIN_BLOCK_SIZE 4 > > .macro vvc_avg type, bit_depth > > @@ -211,6 +213,13 @@ function ff_vvc_\type\()_\bit_depth\()_neon, export=1 > 32: > ret > endfunc > + > +.unreq dst > +.unreq dst_stride > +.unreq src0 > +.unreq src1 > +.unreq width > +.unreq height > .endm > > vvc_avg avg, 8 > @@ -219,3 +228,345 @@ vvc_avg avg, 12 > vvc_avg w_avg, 8 > vvc_avg w_avg, 10 > vvc_avg w_avg, 12 > + > +function ff_vvc_prof_grad_filter_8x_neon, export=1 > +gh .req x0 > +gv .req x1 > +gstride .req x2 > +src .req x3 > +src_stride .req x4 > +width .req w5 > +height .req w6 > + > +lsl src_stride, src_stride, #1 > +neg x7, src_stride > +1: > +mov x10, src > +mov w11, width > +mov x12, gh > +mov x13, gv > +2: > +ldurq0, [x10, #2] > +ldurq1, [x10, #-2] > +subsw11, w11, #8 > +ldr
[FFmpeg-devel] [PATCH v2 1/2] avformat/internal: Add ff_get_frame_filename
From: Zhao Zhili It's similar to av_get_frame_filename2 but with int64_t number support. Make av_get_frame_filename* a wrapper over ff_get_frame_filename. Co-authored-by: Filip Mašić --- libavformat/internal.h | 16 libavformat/utils.c| 11 --- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 8e8971bfeb..6c026f08a0 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -745,6 +745,22 @@ void ff_format_set_url(AVFormatContext *s, char *url); */ int ff_match_url_ext(const char *url, const char *extensions); +/** + * Return in 'buf' the path with '%d' replaced by a number. + * + * Also handles the '%0nd' format where 'n' is the total number + * of digits and '%%'. + * + * @param buf destination buffer + * @param buf_size destination buffer size + * @param path path with substitution template + * @param number the number to substitute + * @param flags AV_FRAME_FILENAME_FLAGS_* + * @return 0 if OK, -1 on format error + */ +int ff_get_frame_filename(char *buf, int buf_size, const char *path, + int64_t number, int flags); + struct FFOutputFormat; struct FFInputFormat; void avpriv_register_devices(const struct FFOutputFormat * const o[], diff --git a/libavformat/utils.c b/libavformat/utils.c index e9ded627ad..e892e8bde7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -280,7 +280,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts) return (sec * 100) + usec; } -int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) +int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags) { const char *p; char *q, buf1[20], c; @@ -313,7 +313,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number percentd_found = 1; if (number < 0) nd += 1; -snprintf(buf1, sizeof(buf1), "%0*d", nd, number); +snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number); len = strlen(buf1); if ((q - buf + len) > buf_size - 1) goto fail; @@ -338,9 +338,14 @@ fail: return -1; } +int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) +{ +return ff_get_frame_filename(buf, buf_size, path, number, flags); +} + int av_get_frame_filename(char *buf, int buf_size, const char *path, int number) { -return av_get_frame_filename2(buf, buf_size, path, number, 0); +return ff_get_frame_filename(buf, buf_size, path, number, 0); } void av_url_split(char *proto, int proto_size, -- 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".
Re: [FFmpeg-devel] [PATCH v3 2/2] avformat: deprecated av_get_frame_filename() and av_get_frame_filename2()
> On Sep 23, 2024, at 22:25, Filip Mašić wrote: > > I don't mind; whatever gets this merged the fastest is best for me. I > wasn't aware there was an internal header, and I don't know why any of the > av_get_frame_filename functions are exposed. I'll add some comments > regardless: > > 1. Even though the function was previously externally documented as taking > frame numbers, it has been used for timestamps internally for the past 7 > years, so I think updating the external documentation to "any number" makes > more sense. My patch deprecated all of the old APIs in favour of what we > now think the new API should be. It’s a bug of img2enc no one noticed. We try to reduce API changes if possible. > > 2. Was there a reason you didn't update img2enc frame_pts to use the new > internal function? Well, git send-email broken suddenly to send patch 2/2. I’m trying to figure out why. > > 3. You might consider the documentation clarifications I made for the > parameters: >> + * @param path path with substitution template >> + * @param number the number to substitute I have added it to patch v2 1/2 and add co-authored-by you. By the way, please don’t top-post. 0001-avformat-internal-Add-ff_get_frame_filename.patch Description: Binary data 0002-avformat-img2enc-Fix-integer-truncation-when-frame_p.patch Description: Binary data > > Thanks for the help with this. > > On Mon, 23 Sept 2024 at 13:18, Zhao Zhili wrote: > >> >> >> On Sep 23, 2024, at 18:18, Filip Mašić wrote: >> >> --- >> doc/APIchanges | 3 ++- >> libavfilter/vf_signature.c | 4 ++-- >> libavformat/avformat.h | 22 ++ >> libavformat/img2dec.c | 10 +- >> libavformat/segment.c | 4 ++-- >> libavformat/utils.c | 2 +- >> libavformat/version_major.h | 2 +- >> libavformat/webm_chunk.c| 4 ++-- >> 8 files changed, 33 insertions(+), 18 deletions(-) >> >> >> The doc of av_get_frame_filename2 says explicitly `number` is `frame >> number`, >> I prefer fix img2enc.c over add another API: >> >> https://ffmpeg.org//pipermail/ffmpeg-devel/2024-September/333820.html >> >> >> diff --git a/doc/APIchanges b/doc/APIchanges >> index 9f091f5ec5..cbab71a408 100644 >> --- a/doc/APIchanges >> +++ b/doc/APIchanges >> @@ -3,7 +3,8 @@ The last version increases of all libraries were on >> 2024-03-07 >> API changes, most recent first: >> >> 2024-09-xx - xx - lavf 61.7.100 - avformat.h >> - Add av_get_frame_filename3() >> + Deprecate av_get_frame_filename(), av_get_frame_filename2(), >> + and replace them with av_get_frame_filename3(). >> >> 2024-09-18 - xx - lavc 61.17.100 - packet.h >> Add AV_PKT_DATA_LCEVC. >> diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c >> index f419522ac6..37f3ff227e 100644 >> --- a/libavfilter/vf_signature.c >> +++ b/libavfilter/vf_signature.c >> @@ -562,7 +562,7 @@ static int export(AVFilterContext *ctx, StreamContext >> *sc, int input) >> >>if (sic->nb_inputs > 1) { >>/* error already handled */ >> -av_assert0(av_get_frame_filename(filename, sizeof(filename), >> sic->filename, input) == 0); >> +av_assert0(av_get_frame_filename3(filename, sizeof(filename), >> sic->filename, input, 0) == 0); >>} else { >>if (av_strlcpy(filename, sic->filename, sizeof(filename)) >= >> sizeof(filename)) >>return AVERROR(EINVAL); >> @@ -673,7 +673,7 @@ static av_cold int init(AVFilterContext *ctx) >>} >> >>/* check filename */ >> -if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && >> av_get_frame_filename(tmp, sizeof(tmp), sic->filename, 0) == -1) { >> +if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && >> av_get_frame_filename3(tmp, sizeof(tmp), sic->filename, 0, 0) == -1) { >>av_log(ctx, AV_LOG_ERROR, "The filename must contain %%d or %%0nd, >> if you have more than one input.\n"); >>return AVERROR(EINVAL); >>} >> diff --git a/libavformat/avformat.h b/libavformat/avformat.h >> index 1bc0e716dc..a407faecec 100644 >> --- a/libavformat/avformat.h >> +++ b/libavformat/avformat.h >> @@ -2940,11 +2940,25 @@ void av_dump_format(AVFormatContext *ic, >> int av_get_frame_filename3(char *buf, int buf_size, >> const char *path, int64_t number, int flags); >> >> -int av_get_frame_filename2(char *buf, int buf_size, >> - const char *path, int number, int flags); >> +#if FF_API_AV_GET_FRAME_FILENAME2 >> +/** >> + * Like av_get_frame_filename3() but requires int-type number >> + * >> + * @deprecated use av_get_frame_filename3() with same arguments >> + */ >> +attribute_deprecated >> +int av_get_frame_filename2(char *buf, int buf_size, >> +const char *path, int number, int flags); >> >> -int av_get_frame_filename(char *buf, int buf_size, >> - const char *path, int number); >> +/** >> + * Like av_get_frame_filename3(
Re: [FFmpeg-devel] mediacodec and qsv not really hwaccels ?
On Di, 2024-09-24 at 00:53 +0300, Andrew Randrianasulu wrote: > I tried to trivially add qsv/mediacodec decode to cinelerra-gg, but > discovered that I can't use it like vaapi/vdpau/cuda because (?) > qsv/mediacodec not listed in > > ffmpeg/libavcodec/hwconfig.h > and (for h264) in > ffmpeg/libavcodec/h264dec.c > > so on decoding I get (in termux, cingg compiled with system ffmpeg) > > > Decoder h264 does not support device type mediacodec. > > HW device init failed, using SW decode. > file:/data/data/com.termux/files/home/20210419_055507A.mp4 > err: Operation not permitted > > yet ffmpeg -hwaccel show > > ~/cinelerra/cinelerra-5.1 $ ffmpeg -hwaccels > > ffmpeg version 6.1.2 Copyright (c) 2000-2024 the FFmpeg developers > > built with Android (12027248, +pgo, +bolt, +lto, +mlgo, based on r522817) > clang version 18.0.1 ( > https://android.googlesource.com/toolchain/llvm-project > d8003a456d14a3deb8054cdaa529ffbf02d9b262) configuration: --arch=aarch64 > --as=aarch64-linux-android-clang --cc=aarch64-linux-android-clang > --cxx=aarch64-linux-android-clang++ --nm=llvm-nm > --pkg-config=/home/builder/.termux-build/_cache/android-r27-api-24-v1/bin/pkg- > config > --strip=llvm-strip --cross-prefix=aarch64-linux-android- --disable-indevs > --disable-outdevs --enable-indev=lavfi --disable-static --disable-symver > --enable-cross-compile --enable-gnutls --enable-gpl --enable-version3 > --enable-jni --enable-lcms2 --enable-libaom --enable-libass > --enable-libbluray --enable-libdav1d --enable-libfontconfig > --enable-libfreetype --enable-libfribidi --enable-libgme > --enable-libharfbuzz --enable-libmp3lame --enable-libopencore-amrnb > --enable-libopencore-amrwb --enable-libopenmpt --enable-libopus > --enable-librav1e --enable-libsoxr --enable-libsrt --enable-libssh > --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab > --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx > --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 > --enable-libxvid --enable-libzimg --enable-mediacodec --enable-opencl > --enable-shared --prefix=/data/data/com.termux/files/usr > --target-os=android --extra-libs=-landroid-glob --disable-vulkan > --enable-neon --disable-libfdk-aac libavutil 58. > 29.100 / 58. 29.100 > > libavcodec 60. 31.102 / 60. 31.102 > > libavformat 60. 16.100 / 60. 16.100 > > libavdevice 60. 3.100 / 60. 3.100 > > libavfilter 9. 12.100 / 9. 12.100 > > libswscale 7. 5.100 / 7. 5.100 > > libswresample 4. 12.100 / 4. 12.100 > > libpostproc 57. 3.100 / 57. 3.100 > > Hardware acceleration methods: > opencl > mediacodec > > === > > is it oversight or some more fundamental limitation? vaapi/cuda/vdpau is used to accelerate the native decoders in FFmpeg, however for mediacodec/qsv, there are corresponding decoders. For example, both qsv and vaapi are enabled when running configuration, you may get all supported qsv decoders with the command below: $ ffmpeg -decoders 2>/dev/null | grep qsv VD av1_qsv AV1 video (Intel Quick Sync Video acceleration) (codec av1) VD h264_qsv H264 video (Intel Quick Sync Video acceleration) (codec h264) VD hevc_qsv HEVC video (Intel Quick Sync Video acceleration) (codec hevc) VD mjpeg_qsvMJPEG video (Intel Quick Sync Video acceleration) (codec mjpeg) VD mpeg2_qsvMPEG2VIDEO video (Intel Quick Sync Video acceleration) (codec mpeg2video) VD vc1_qsv VC1 video (Intel Quick Sync Video acceleration) (codec vc1) VD vp8_qsv VP8 video (Intel Quick Sync Video acceleration) (codec vp8) VD vp9_qsv VP9 video (Intel Quick Sync Video acceleration) (codec vp9) However for vaapi, you will get nothing, $ ffmpeg -decoders 2>/dev/null | grep vaapi Thanks Haihao ___ 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] A change in r_frame_rate values after upgrade to FFmpeg 6.1
On Mon, Sep 23, 2024 at 08:30:09PM +0100, Kieran Kunhya via ffmpeg-devel wrote: > > On Mon, Sep 23, 2024 at 4:45 PM Kieran Kunhya via ffmpeg-devel > > wrote: > >> > >> On Mon, Sep 23, 2024 at 3:27 PM Anton Khirnov wrote: > >> > > >> > Quoting Antoni Bizoń (2024-09-23 10:09:51) > >> > > I understand that the r_frame_rate is the lowest framerate with which > >> > > all timestamps can be represented accurately. And I know it is just a > >> > > guess. But why did the logic behind the calculation change? > >> > > >> > Because you're most likely using a codec like H.264 or MPEG-2 that > >> > allows individually coded fields. In that case the timebase must be > >> > accurate enough to represent the field rate (i.e. double the frame > >> > rate), but the code doing this was previously unreliable, so you'd > >> > sometimes get r_frame_rate equal to the frame rate rather than field > >> > rate. That is not the case anymore. > >> > >> This is bizarre and kafkaesque to say the least. > > > > > > Should we schedule deprecation for one of the two fields? I agree it's > > confusing for end users to check in two fields. > > avg_frame_rate implies it's not precise in some way. An "average" is precissely one number (once the type of average is defined) Maybe you are thinkin of "approximate" instead of "average" > I think the OP is > correct here that the behaviour makes no sense. > If something says frame_rate it's the rate of frames, not the rate of > fields or anything else. The documentation says: * This is the lowest framerate with which all timestamps can be * represented accurately (it is the least common multiple of all * framerates in the stream). Note, this value is just a guess! * For example, if the time base is 1/9 and all frames have either * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Homeopathy is like voting while filling the ballot out with transparent ink. Sometimes the outcome one wanted occurs. Rarely its worse than filling out a ballot properly. 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] avcodec/videotoolbox: add AV1 hardware acceleration
On Mon, Sep 23, 2024 at 12:43 PM Zhao Zhili wrote: > > > > > On Sep 24, 2024, at 01:24, Cameron Gutman wrote: > > > > On Mon, Sep 23, 2024 at 6:07 AM Zhao Zhili wrote: > >> > >> > >> > >>> On Sep 21, 2024, at 05:39, Martin Storsjö wrote: > >>> > >>> From: Jan Ekström > >>> > >>> Co-authored-by: Ruslan Chernenko > >>> Co-authored-by: Martin Storsjö > >>> --- > >>> This is a touched up version of Jan and Ruslan's patches for > >>> AV1 hwaccel via videotoolbox; I tried to polish the code a little > >>> by not overwriting avctx->extradata in > >>> ff_videotoolbox_av1c_extradata_create, and by factorizing out a > >>> new function ff_videotoolbox_buffer_append. > >> > >> LGTM, although I don’t have a device with AV1 support. > > > > I've asked for some testing from users with M3 MacBooks and it > > appears to have problems with certain resolutions (notably 4K). > > > > https://github.com/moonlight-stream/moonlight-qt/issues/1125 > > > > It's possible this is a Moonlight bug, but that seems unlikely > > because VideoToolbox HEVC decoding works fine at 4K and > > VideoToolbox AV1 works at 1080p and other resolutions. > > I can’t tell what’s going wrong from that bug report. Please test > with ffmpeg and/or ffplay cmdline and share the results. > I'm debugging this blind since I don't have hardware either, but I think we're mishandling Tile Group OBUs in this patch. Comparing working vs non-working logs, it looks like the encoder is using 2x1 tiling when encoding 4K and 1x1 for smaller unaffected resolutions. Working: [av1 @ 0x14f7b14c0] Frame 0: size 1280x720 upscaled 1280 render 1280x720 subsample 2x2 bitdepth 10 tiles 1x1. [av1 @ 0x14f7b14c0] Total OBUs on this packet: 4. [av1 @ 0x14f7b14c0] OBU idx:0, type:2, content available:1. [av1 @ 0x14f7b14c0] OBU idx:1, type:1, content available:1. [av1 @ 0x14f7b14c0] OBU idx:2, type:6, content available:1. [av1 @ 0x14f7b14c0] Format videotoolbox_vld chosen by get_format(). [av1 @ 0x14f7b14c0] Format videotoolbox_vld requires hwaccel av1_videotoolbox initialisation. [av1 @ 0x14f7b14c0] AV1 decode get format: videotoolbox_vld. Broken: [av1 @ 0x15128b530] Frame 0: size 3840x2160 upscaled 3840 render 3840x2160 subsample 2x2 bitdepth 10 tiles 2x1. [av1 @ 0x15128b530] Total OBUs on this packet: 4. [av1 @ 0x15128b530] OBU idx:0, type:2, content available:1. [av1 @ 0x15128b530] OBU idx:1, type:1, content available:1. [av1 @ 0x15128b530] OBU idx:2, type:3, content available:1. [av1 @ 0x15128b530] Format videotoolbox_vld chosen by get_format(). [av1 @ 0x15128b530] Format videotoolbox_vld requires hwaccel av1_videotoolbox initialisation. [av1 @ 0x15128b530] AV1 decode get format: videotoolbox_vld. [av1 @ 0x15128b530] OBU idx:3, type:4, content available:1. [av1 @ 0x15128b530] vt decoder cb: output image buffer is null: -17694 [av1 @ 0x15128b530] HW accel end frame fail. In the broken case, instead of a Frame OBU, we get a Frame Header OBU and a Tile Group OBU. To handle Tile Group OBUs, av1dec.c calls decode_slice() function, but videotoolbox_av1_decode_slice() in this patch simply returns without appending the OBU data to bitstream buffer. It looks like other AV1 hwaccels ignore the data buffer provided in the start_frame() callback and instead append to their bitstream buffers in decode_slice() instead. Maybe that's what we should do here too? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] doc: Add email URLs for Fate samples-request
--- MAINTAINERS| 7 +-- doc/developer.texi | 2 +- doc/fate.texi | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 036066d..04a4a05 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -61,8 +61,11 @@ API tests [0] Communication = -website (S: https://git.ffmpeg.org/ffmpeg-web) Deby Barbara Lepage -fate.ffmpeg.org (L: fate-ad...@ffmpeg.org) (W: https://fate.ffmpeg.org) (P: https://ffmpeg.org/fate.html) (S: https://git.ffmpeg.org/fateserver) Timo Rothenpieler +website (T: https://git.ffmpeg.org/ffmpeg-web) Deby Barbara Lepage +fate.ffmpeg.org (W: https://fate.ffmpeg.org) (P: https://ffmpeg.org/fate.html) +(T: https://git.ffmpeg.org/fateserver) Timo Rothenpieler +(L: samples-requ...@ffmpeg.org) Upload requests +(L: fate-ad...@ffmpeg.org) Key registration for permanent write access Trac bug tracker(W: https://trac.ffmpeg.org) Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos Patchwork [2] (W: https://patchwork.ffmpeg.org) Andriy Gelman mailing lists (W: https://ffmpeg.org/contact.html#MailingLists) Baptiste Coudurier diff --git a/doc/developer.texi b/doc/developer.texi index 41b2193..b732560 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -876,7 +876,7 @@ accordingly]. @section Adding files to the fate-suite dataset -If you need a sample uploaded send a mail to samples-request. +If you need a sample uploaded send a mail to @email{samples-request@@ffmpeg.org}. When there is no muxer or encoder available to generate test media for a specific test then the media has to be included in the fate-suite. diff --git a/doc/fate.texi b/doc/fate.texi index 17644ce..6f6df3a 100644 --- a/doc/fate.texi +++ b/doc/fate.texi @@ -172,7 +172,7 @@ the synchronisation of the samples directory. @chapter Uploading new samples to the fate suite -If you need a sample uploaded send a mail to samples-request. +If you need a sample uploaded send a mail to @email{samples-request@@ffmpeg.org}. This is for developers who have an account on the fate suite server. If you upload new samples, please make sure they are as small as possible, -- 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] doc: Add email URLs for Fate samples-request
On 24.09.24 00:31, Michael Niedermayer wrote: Btw.: the fate info and the "webserver"-entry one line above use (S:...)-entries, which aren't mentioned as a possible variant in the descriptive top section of MAINTAINERS. Shouldn't these be (T:...)- or (W: ...)-entries or the (S: ...) kind be added as another option to the describtion? they should be T: feel free to send a patch fixing that, or ill fix it later Done -fate.ffmpeg.org (L: fate-ad...@ffmpeg.org) (W: https://fate.ffmpeg.org) (P: https://ffmpeg.org/fate.html) (S: https://git.ffmpeg.org/fateserver) Timo Rothenpieler +fate.ffmpeg.org (L: fate-ad...@ffmpeg.org) (L: samples-requ...@ffmpeg.org) (W: https://fate.ffmpeg.org) (P: https://ffmpeg.org/fate.html) (S: https://git.ffmpeg.org/fateserver) Timo Rothenpieler I think this should possible use more than 1 line also as there are 2 "L:" there should be a note when to use which I hope, that's better now. Fixed line breaks would make the first few sections with all long list of names in general much more readable. 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] A change in r_frame_rate values after upgrade to FFmpeg 6.1
On Mon, Sep 23, 2024 at 09:56:52PM +0200, Anton Khirnov wrote: > Quoting Kieran Kunhya via ffmpeg-devel (2024-09-23 21:30:09) > > > On Mon, Sep 23, 2024 at 4:45 PM Kieran Kunhya via ffmpeg-devel > > > wrote: [...] > > I think the OP is correct here that the behaviour makes no sense. If > > something says frame_rate it's the rate of frames, not the rate of > > fields or anything else. > > As I said previously in this thread, r_frame_rate is NOT a frame rate. > Yes, it is horribly named. It is also unknowable without analysing the > entire stream, For containers that have an index its possible to compute this exactly For video streams that follow a standard which restricts frame durations, the value can also be found exactly (if one assumes the whole stream complies to that standard) thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. 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] [RFC] 7.1 Release
On Fri, Aug 23, 2024 at 03:43:54PM -0400, Neal Gompa wrote: > On Wed, Aug 14, 2024 at 11:11 AM Michael Niedermayer > wrote: > > > > Hi all > > > > Are there any upcoming LTS releases that want to/could include FFmpeg 7.1 ? > > If so please reply here and list the date before which we would have to > > finish the 7.1 release so it can be included with no problems > > > > Otherwise, are there any preferrances of the general/approximate release > > date? > > > > I'd like to get it in for Fedora 41 / EPEL for RHEL 10. Fedora 41 > final freeze is October 15, I'd prefer it to be available by around > October 1. RHEL 10 beta is expected around early November. Given that we are still having blocking issues and thus cannot yet branch 7.1, I wonder about this a bit maybe james can comment about the expected timeline for LCEVC ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire 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] A change in r_frame_rate values after upgrade to FFmpeg 6.1
On Mon, Sep 23, 2024 at 8:56 PM Anton Khirnov wrote: > > Quoting Kieran Kunhya via ffmpeg-devel (2024-09-23 21:30:09) > > > On Mon, Sep 23, 2024 at 4:45 PM Kieran Kunhya via ffmpeg-devel > > > wrote: > > >> > > >> On Mon, Sep 23, 2024 at 3:27 PM Anton Khirnov wrote: > > >> > > > >> > Quoting Antoni Bizoń (2024-09-23 10:09:51) > > >> > > I understand that the r_frame_rate is the lowest framerate with which > > >> > > all timestamps can be represented accurately. And I know it is just a > > >> > > guess. But why did the logic behind the calculation change? > > >> > > > >> > Because you're most likely using a codec like H.264 or MPEG-2 that > > >> > allows individually coded fields. In that case the timebase must be > > >> > accurate enough to represent the field rate (i.e. double the frame > > >> > rate), but the code doing this was previously unreliable, so you'd > > >> > sometimes get r_frame_rate equal to the frame rate rather than field > > >> > rate. That is not the case anymore. > > >> > > >> This is bizarre and kafkaesque to say the least. > > > > > > > > > Should we schedule deprecation for one of the two fields? I agree it's > > > confusing for end users to check in two fields. > > > > avg_frame_rate implies it's not precise in some way. > > You might have heard of certain cases where inter-frame intervals are > not constant, then there is no precisely defined frame rate. When the > stream is CFR, avg_frame_rate should be precise. Let's look at the first result for avg_frame_rate where people are taking the name to be something else: https://github.com/eugeneware/ffprobe/issues/7 The OP wants a framerate, yet the API takes them down a massive rabbit hole of voodoo to serve edge cases. Do you really want edge cases to be treated as first class citizens to the detriment of the majority? There are CFR streams, there are flags to say things are CFR. Regards, Kieran Kunhya ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] mediacodec and qsv not really hwaccels ?
I tried to trivially add qsv/mediacodec decode to cinelerra-gg, but discovered that I can't use it like vaapi/vdpau/cuda because (?) qsv/mediacodec not listed in ffmpeg/libavcodec/hwconfig.h and (for h264) in ffmpeg/libavcodec/h264dec.c so on decoding I get (in termux, cingg compiled with system ffmpeg) Decoder h264 does not support device type mediacodec. HW device init failed, using SW decode. file:/data/data/com.termux/files/home/20210419_055507A.mp4 err: Operation not permitted yet ffmpeg -hwaccel show ~/cinelerra/cinelerra-5.1 $ ffmpeg -hwaccels ffmpeg version 6.1.2 Copyright (c) 2000-2024 the FFmpeg developers built with Android (12027248, +pgo, +bolt, +lto, +mlgo, based on r522817) clang version 18.0.1 ( https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262) configuration: --arch=aarch64 --as=aarch64-linux-android-clang --cc=aarch64-linux-android-clang --cxx=aarch64-linux-android-clang++ --nm=llvm-nm --pkg-config=/home/builder/.termux-build/_cache/android-r27-api-24-v1/bin/pkg-config --strip=llvm-strip --cross-prefix=aarch64-linux-android- --disable-indevs --disable-outdevs --enable-indev=lavfi --disable-static --disable-symver --enable-cross-compile --enable-gnutls --enable-gpl --enable-version3 --enable-jni --enable-lcms2 --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libharfbuzz --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenmpt --enable-libopus --enable-librav1e --enable-libsoxr --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-mediacodec --enable-opencl --enable-shared --prefix=/data/data/com.termux/files/usr --target-os=android --extra-libs=-landroid-glob --disable-vulkan --enable-neon --disable-libfdk-aac libavutil 58. 29.100 / 58. 29.100 libavcodec 60. 31.102 / 60. 31.102 libavformat60. 16.100 / 60. 16.100 libavdevice60. 3.100 / 60. 3.100 libavfilter 9. 12.100 / 9. 12.100 libswscale 7. 5.100 / 7. 5.100 libswresample 4. 12.100 / 4. 12.100 libpostproc57. 3.100 / 57. 3.100 Hardware acceleration methods: opencl mediacodec === is it oversight or some more fundamental limitation? ___ 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/7] avcodec/ilbcdec: Initialize tempbuff2
Fixes: Use of uninitialized value Fixes: 71350/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-6322020827070464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/ilbcdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c index ba1da168bc0..7fea39b43ca 100644 --- a/libavcodec/ilbcdec.c +++ b/libavcodec/ilbcdec.c @@ -658,7 +658,7 @@ static void get_codebook(int16_t * cbvec, /* (o) Constructed codebook vector * int16_t k, base_size; int16_t lag; /* Stack based */ -int16_t tempbuff2[SUBL + 5]; +int16_t tempbuff2[SUBL + 5] = {0}; /* Determine size of codebook sections */ base_size = lMem - cbveclen + 1; -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/7] avcodec/eatgq: Check bytestream2_get_buffer() for failure
Fixes: Use of uninitialized memory Fixes: 71546/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGQ_fuzzer-5607656650244096 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/eatgq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index 190c57f1c00..57129dce51e 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -178,7 +178,8 @@ static int tgq_decode_mb(TgqContext *s, GetByteContext *gbyte, dc[4] = bytestream2_get_byte(gbyte); dc[5] = bytestream2_get_byte(gbyte); } else if (mode == 6) { -bytestream2_get_buffer(gbyte, dc, 6); +if (bytestream2_get_buffer(gbyte, dc, 6) != 6) +return AVERROR_INVALIDDATA; } else if (mode == 12) { for (i = 0; i < 6; i++) { dc[i] = bytestream2_get_byte(gbyte); -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/7] avformat/mxfdec: Check avio_read() success in mxf_decrypt_triplet()
Fixes: Use of uninitialized memory Fixes: 71444/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5448597561212928 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mxfdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 24f4ed1c33d..b232c45f47d 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -671,7 +671,8 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv if (size < 32 || size - 32 < orig_size || (int)orig_size != orig_size) return AVERROR_INVALIDDATA; avio_read(pb, ivec, 16); -avio_read(pb, tmpbuf, 16); +if (avio_read(pb, tmpbuf, 16) != 16) +return AVERROR_INVALIDDATA; if (mxf->aesc) av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1); if (memcmp(tmpbuf, checkv, 16)) -- 2.46.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/7] avcodec/eatgq: move array to where it is used
Signed-off-by: Michael Niedermayer --- libavcodec/eatgq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index d326c053907..190c57f1c00 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -156,7 +156,6 @@ static int tgq_decode_mb(TgqContext *s, GetByteContext *gbyte, { int mode; int i; -int8_t dc[6]; mode = bytestream2_get_byte(gbyte); if (mode > 12) { @@ -173,6 +172,7 @@ static int tgq_decode_mb(TgqContext *s, GetByteContext *gbyte, tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y); bytestream2_skip(gbyte, mode); } else { +int8_t dc[6]; if (mode == 3) { memset(dc, bytestream2_get_byte(gbyte), 4); dc[4] = bytestream2_get_byte(gbyte); -- 2.46.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 7/7] avcodec/hevc/hevcdec: initialize qp_y_tab
This does not replicate on my setup, thus this is a blind fix based on ossfuzz trace Fixes: use of uninitialized value Fixes: 71747/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5427736120721408 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/hevc/hevcdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index d915d74d22e..0b50bbd2754 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -127,7 +127,7 @@ static int pic_arrays_init(HEVCLayerContext *l, const HEVCSPS *sps) l->filter_slice_edges = av_mallocz(ctb_count); l->tab_slice_address = av_malloc_array(pic_size_in_ctb, sizeof(*l->tab_slice_address)); -l->qp_y_tab = av_malloc_array(pic_size_in_ctb, +l->qp_y_tab = av_calloc(pic_size_in_ctb, sizeof(*l->qp_y_tab)); if (!l->qp_y_tab || !l->filter_slice_edges || !l->tab_slice_address) goto fail; -- 2.46.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 5/7] avformat/qcp: Check for read failure in header
Fixes: Use of uninitialized value Fixes: 71551/clusterfuzz-testcase-minimized-ffmpeg_dem_QCP_fuzzer-4647386712965120 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/qcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/qcp.c b/libavformat/qcp.c index fdf18618d23..13a479a11e6 100644 --- a/libavformat/qcp.c +++ b/libavformat/qcp.c @@ -105,7 +105,8 @@ static int qcp_read_header(AVFormatContext *s) st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; -avio_read(pb, buf, 16); +if (avio_read(pb, buf, 16) != 16) +return AVERROR_INVALIDDATA; if (is_qcelp_13k_guid(buf)) { st->codecpar->codec_id = AV_CODEC_ID_QCELP; } else if (!memcmp(buf, guid_evrc, 16)) { -- 2.46.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 6/7] avcodec/get_bits: dont add a null to a 0
Fixes: undefined behavior Fixes: 71747/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5427736120721408 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/get_bits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h index fe2f6378b45..beeff87a79b 100644 --- a/libavcodec/get_bits.h +++ b/libavcodec/get_bits.h @@ -528,7 +528,7 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer, s->buffer = buffer; s->size_in_bits = bit_size; s->size_in_bits_plus8 = bit_size + 8; -s->buffer_end = buffer + buffer_size; +s->buffer_end = buffer ? buffer + buffer_size : NULL; s->index = 0; return ret; -- 2.46.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] A change in r_frame_rate values after upgrade to FFmpeg 6.1
Quoting Kieran Kunhya via ffmpeg-devel (2024-09-23 21:30:09) > > On Mon, Sep 23, 2024 at 4:45 PM Kieran Kunhya via ffmpeg-devel > > wrote: > >> > >> On Mon, Sep 23, 2024 at 3:27 PM Anton Khirnov wrote: > >> > > >> > Quoting Antoni Bizoń (2024-09-23 10:09:51) > >> > > I understand that the r_frame_rate is the lowest framerate with which > >> > > all timestamps can be represented accurately. And I know it is just a > >> > > guess. But why did the logic behind the calculation change? > >> > > >> > Because you're most likely using a codec like H.264 or MPEG-2 that > >> > allows individually coded fields. In that case the timebase must be > >> > accurate enough to represent the field rate (i.e. double the frame > >> > rate), but the code doing this was previously unreliable, so you'd > >> > sometimes get r_frame_rate equal to the frame rate rather than field > >> > rate. That is not the case anymore. > >> > >> This is bizarre and kafkaesque to say the least. > > > > > > Should we schedule deprecation for one of the two fields? I agree it's > > confusing for end users to check in two fields. > > avg_frame_rate implies it's not precise in some way. You might have heard of certain cases where inter-frame intervals are not constant, then there is no precisely defined frame rate. When the stream is CFR, avg_frame_rate should be precise. > I think the OP is correct here that the behaviour makes no sense. If > something says frame_rate it's the rate of frames, not the rate of > fields or anything else. As I said previously in this thread, r_frame_rate is NOT a frame rate. Yes, it is horribly named. It is also unknowable without analysing the entire stream, and of (to put it very mildly) extremely questionable utility, which is why I've argued for removing it since forever. But this is how it has always worked. The only thing that's changed is that now its behaviour is consistent across different files. -- 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 22/23] tests/fate/hevc: add a test for switching between single and multi-view
On 9/23/2024 3:41 PM, Anton Khirnov wrote: Quoting Zhao Zhili (2024-09-23 19:49:40) On Sep 14, 2024, at 18:45, Anton Khirnov wrote: --- tests/fate/hevc.mak | 10 ++ tests/ref/fate/hevc-mv-switch | 172 ++ 2 files changed, 182 insertions(+) create mode 100644 tests/ref/fate/hevc-mv-switch Fate break on macOS. https://github.com/quink-black/FFmpeg/actions/runs/10999185735/job/30538808619 Could you please provide more information? I only see a red cross with "build and run all tests" at that link. It takes a while to load, but eventually you'll get the build and fate run logs. Here's the relevant part in any case: https://pastebin.com/raw/2NqgcKqK 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 v2] avfilter/vf_libvmaf: Add metadata propagation support
Hi, > Could we somehow get the AVFrame pointer in your custom callback data > or the VmafMetadata data? When all of the expected metadata is written > then you'll know you're ready to forward the frame through the > filtergraph. Doing it this way hopefully avoids a lot of the code and > traversing through linked lists looking for AVFrame pointers as you've > done. Thanks for the suggestion! I think main difficulty of the implementation is sending non-monotical vmaf frames in order. Tracking the written metadata is not enough in my opinion. We need some kind of structure that need to put frames in order before they sent or it should need to send in order somehow. I have been working on kinda similar solution for couple of days that I did with linked list but with using av_fifo instead of my implementation. It looks working fine. Tests are welcome. https://github.com/yigithanyigit/FFmpeg/pull/3/files NOTE: This implementation uses small vmaf patch that I mentioned earlier in the thread. Thanks, Yigithan ___ 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] A change in r_frame_rate values after upgrade to FFmpeg 6.1
> On Mon, Sep 23, 2024 at 4:45 PM Kieran Kunhya via ffmpeg-devel > wrote: >> >> On Mon, Sep 23, 2024 at 3:27 PM Anton Khirnov wrote: >> > >> > Quoting Antoni Bizoń (2024-09-23 10:09:51) >> > > I understand that the r_frame_rate is the lowest framerate with which >> > > all timestamps can be represented accurately. And I know it is just a >> > > guess. But why did the logic behind the calculation change? >> > >> > Because you're most likely using a codec like H.264 or MPEG-2 that >> > allows individually coded fields. In that case the timebase must be >> > accurate enough to represent the field rate (i.e. double the frame >> > rate), but the code doing this was previously unreliable, so you'd >> > sometimes get r_frame_rate equal to the frame rate rather than field >> > rate. That is not the case anymore. >> >> This is bizarre and kafkaesque to say the least. > > > Should we schedule deprecation for one of the two fields? I agree it's > confusing for end users to check in two fields. avg_frame_rate implies it's not precise in some way. I think the OP is correct here that the behaviour makes no sense. If something says frame_rate it's the rate of frames, not the rate of fields or anything else. Kieran ___ 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] doc: Add email URLs for Fate samples-request
On Fri, Sep 20, 2024 at 12:27:19PM +0200, Martin Schitter wrote: > v2 adds the address as a second (L: ...)-entry > to the Fate info in MAINTAINERS. > > I'm not sure if this is correct because I couldn't find other lines, > where the same kind of entry gets used twice. > > Btw.: the fate info and the "webserver"-entry one line above use > (S:...)-entries, which aren't mentioned as a possible variant in the > descriptive top section of MAINTAINERS. Shouldn't these be (T:...)- > or (W: ...)-entries or the (S: ...) kind be added as another option > to the describtion? they should be T: feel free to send a patch fixing that, or ill fix it later > > martin > > --- > MAINTAINERS| 2 +- > doc/developer.texi | 2 +- > doc/fate.texi | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/MAINTAINERS b/MAINTAINERS > index 036066d..7d7ef36 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -62,7 +62,7 @@ Communication > = > > website (S: > https://git.ffmpeg.org/ffmpeg-web) Deby Barbara Lepage > -fate.ffmpeg.org (L: fate-ad...@ffmpeg.org) (W: > https://fate.ffmpeg.org) (P: https://ffmpeg.org/fate.html) (S: > https://git.ffmpeg.org/fateserver) Timo Rothenpieler > +fate.ffmpeg.org (L: fate-ad...@ffmpeg.org) (L: > samples-requ...@ffmpeg.org) (W: https://fate.ffmpeg.org) (P: > https://ffmpeg.org/fate.html) (S: https://git.ffmpeg.org/fateserver) Timo > Rothenpieler I think this should possible use more than 1 line also as there are 2 "L:" there should be a note when to use which thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin 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 v2] swscale/aarch64: Fix rgb24toyv12 only works with aligned width
> On Sep 18, 2024, at 21:11, Zhao Zhili wrote: > > From: Zhao Zhili > > Since c0666d8b, rgb24toyv12 is broken for width non-aligned to 16. > Add a simple wrapper to handle the non-aligned part. > > Signed-off-by: Zhao Zhili > Co-authored-by: johzzy > --- > v2: test width 2 and 540 > > libswscale/aarch64/rgb2rgb.c | 23 ++- > tests/checkasm/sw_rgb.c | 2 +- > 2 files changed, 23 insertions(+), 2 deletions(-) > > diff --git a/libswscale/aarch64/rgb2rgb.c b/libswscale/aarch64/rgb2rgb.c > index d978a6f173..20a25033cb 100644 > --- a/libswscale/aarch64/rgb2rgb.c > +++ b/libswscale/aarch64/rgb2rgb.c > @@ -27,9 +27,30 @@ > #include "libswscale/swscale.h" > #include "libswscale/swscale_internal.h" > > +// Only handle width aligned to 16 > void ff_rgb24toyv12_neon(const uint8_t *src, uint8_t *ydst, uint8_t *udst, > uint8_t *vdst, int width, int height, int lumStride, > int chromStride, int srcStride, int32_t *rgb2yuv); > + > +static void rgb24toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, > +uint8_t *vdst, int width, int height, int lumStride, > +int chromStride, int srcStride, int32_t *rgb2yuv) > +{ > +int width_align = width & (~15); > + > +if (width_align > 0) > +ff_rgb24toyv12_neon(src, ydst, udst, vdst, width_align, height, > +lumStride, chromStride, srcStride, rgb2yuv); > +if (width_align < width) { > +src += width_align * 3; > +ydst += width_align; > +udst += width_align / 2; > +vdst += width_align / 2; > +ff_rgb24toyv12_c(src, ydst, udst, vdst, width - width_align, height, > +lumStride, chromStride, srcStride, rgb2yuv); > +} > +} > + > void ff_interleave_bytes_neon(const uint8_t *src1, const uint8_t *src2, > uint8_t *dest, int width, int height, > int src1Stride, int src2Stride, int dstStride); > @@ -42,7 +63,7 @@ av_cold void rgb2rgb_init_aarch64(void) > int cpu_flags = av_get_cpu_flags(); > > if (have_neon(cpu_flags)) { > -ff_rgb24toyv12 = ff_rgb24toyv12_neon; > +ff_rgb24toyv12 = rgb24toyv12; > interleaveBytes = ff_interleave_bytes_neon; > deinterleaveBytes = ff_deinterleave_bytes_neon; > } > diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c > index af9434073a..7a6d621375 100644 > --- a/tests/checkasm/sw_rgb.c > +++ b/tests/checkasm/sw_rgb.c > @@ -129,7 +129,7 @@ static int cmp_off_by_n(const uint8_t *ref, const uint8_t > *test, size_t n, int a > > static void check_rgb24toyv12(struct SwsContext *ctx) > { > -static const int input_sizes[] = {16, 128, 512, MAX_LINE_SIZE, > -MAX_LINE_SIZE}; > +static const int input_sizes[] = {2, 16, 128, 540, MAX_LINE_SIZE, > -MAX_LINE_SIZE}; > > LOCAL_ALIGNED_32(uint8_t, src, [BUFSIZE * 3]); > LOCAL_ALIGNED_32(uint8_t, buf_y_0, [BUFSIZE]); > -- > 2.42.0 > Applied. ___ 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".