[FFmpeg-devel] [PATCH v2 09-10] lavc/hevc_ps: reduce the size of ShortTermRPS.used
It is currently an array of 32 uint8_t, each storing a single flag. A single uint32_t is sufficient. Reduces sizeof(HEVCSPS) by 1792 bytes. --- libavcodec/hevc_ps.c | 33 +++-- libavcodec/hevc_ps.h | 2 +- libavcodec/hevc_refs.c | 6 +++--- libavcodec/vulkan_hevc.c | 13 + 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index a6b0021bc3..76fe507e7b 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -107,6 +107,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, int k = 0; int i; +rps->used= 0; rps->rps_predict = 0; if (rps != sps->st_rps && sps->nb_st_rps) @@ -114,6 +115,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, if (rps->rps_predict) { const ShortTermRPS *rps_ridx; +uint8_t used[32] = { 0 }; int delta_rps; if (is_slice_header) { @@ -139,13 +141,13 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } delta_rps = (1 - (rps->delta_rps_sign << 1)) * rps->abs_delta_rps; for (i = 0; i <= rps_ridx->num_delta_pocs; i++) { -int used = rps->used[k] = get_bits1(gb); +used[k] = get_bits1(gb); rps->use_delta_flag = 0; -if (!used) +if (!used[k]) rps->use_delta_flag = get_bits1(gb); -if (used || rps->use_delta_flag) { +if (used[k] || rps->use_delta_flag) { if (i < rps_ridx->num_delta_pocs) delta_poc = delta_rps + rps_ridx->delta_poc[i]; else @@ -157,7 +159,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } } -if (k >= FF_ARRAY_ELEMS(rps->used)) { +if (k >= FF_ARRAY_ELEMS(used)) { av_log(avctx, AV_LOG_ERROR, "Invalid num_delta_pocs: %d\n", k); return AVERROR_INVALIDDATA; @@ -167,35 +169,38 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, rps->num_negative_pics = k0; // sort in increasing order (smallest first) if (rps->num_delta_pocs != 0) { -int used, tmp; +int u, tmp; for (i = 1; i < rps->num_delta_pocs; i++) { delta_poc = rps->delta_poc[i]; -used = rps->used[i]; +u = used[i]; for (k = i - 1; k >= 0; k--) { tmp = rps->delta_poc[k]; if (delta_poc < tmp) { rps->delta_poc[k + 1] = tmp; -rps->used[k + 1] = rps->used[k]; +used[k + 1] = used[k]; rps->delta_poc[k] = delta_poc; -rps->used[k] = used; +used[k] = u; } } } } if ((rps->num_negative_pics >> 1) != 0) { -int used; +int u; k = rps->num_negative_pics - 1; // flip the negative values to largest first for (i = 0; i < rps->num_negative_pics >> 1; i++) { delta_poc = rps->delta_poc[i]; -used = rps->used[i]; +u = used[i]; rps->delta_poc[i] = rps->delta_poc[k]; -rps->used[i] = rps->used[k]; +used[i] = used[k]; rps->delta_poc[k] = delta_poc; -rps->used[k] = used; +used[k] = u; k--; } } + +for (unsigned i = 0; i < FF_ARRAY_ELEMS(used); i++) +rps->used |= used[i] * (1 << i); } else { unsigned int nb_positive_pics; @@ -222,7 +227,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } prev -= delta_poc; rps->delta_poc[i] = prev; -rps->used[i] = get_bits1(gb); +rps->used|= get_bits1(gb) * (1 << i); } prev = 0; for (i = 0; i < nb_positive_pics; i++) { @@ -235,7 +240,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } prev += delta_poc; rps->delta_poc[rps->num_negative_pics + i] = prev; -rps->used[rps->num_negative_pics + i] = get_bits1(gb); +rps->used |= get_bits1(gb) * (1 << (rps->num_negative_pics + i)); } } } diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index 1d3bdca4c6..ed6372c747 100644 --- a/libavcodec/hevc_ps.h
Re: [FFmpeg-devel] [PATCH v4 1/4] doc: Explain what "context" means
On Tue, May 28, 2024 at 07:24:55PM +0200, Stefano Sabatini wrote: > > I think we start with different assumptions: you assume that most of > the readers are familiar with OOP jargon, and that they will leverage > the OOP jargon to understand the FFmpeg API. I think this is Not exactly. I'm saying the document has two equally valid use cases: 1. non-OOP developers, who need us to add new information to their brains 2. OOP developers, who need us to replace existing information in their brains So it's not a matter of "leveraging OOP" jargon so much as "calling out OOP assumptions". For example, I originally assumed AVClass was to FFmpeg as the Object struct[1] is to GObject, and struggled to take anything onboard until that been explicitly debunked. You may even be able to see that opinion gradually eroding in each rewrite of the context document. But actually, two groups is probably over-simplifying. Another group would be people coming from other C projects, who have incompatible ideas about contexts that would never occur to us. Or Fortran developers, who (according to the first link on Google[2]) can be expected to understand modules but not objects. > misleading: historically what defined FFmpeg is its minimalistic > approach, in this case we don't want the user, familiar with C, to be > familiar with OOP in order to use and understand the FFmpeg API, as > this is simply not necessary as FFmpeg is plain C language. > > In fact, if this might help with some users, this will probably > confuse all the others. Even more, if we adopt the FFmpeg jargon to > OOP (using "context") we are adding more confusion, as now the OOP > reader will have to adopt the FFmpeg jargon applied to OOP. > > My advice is to move all the content to OOP to a dedicated section, or > to make the references to OOP jargon as less as possible, to not get > in the way with the non-OOP reader. Earlier versions of the document probably drew too strong an analogy with OOP, but I suspect the problem may be simpler in the latest draft. The majority of OOP references explain how things are different to OOP - it might be possible to make these more readable, but they can't be moved or removed, because replacing information involves calling out the old information first. Only the first few OOP references draw the analogy in the positive, aiming to show OOP devs how this is similar but different. Given the OOP vs. non-OOP distinction is too simplistic, the solution might be to start the document with a collection of code samples - a generic C function, a Python object, a JavaScript event listener, and an FFmpeg sample. That would show how "context" is a name for a broad concept you've probably used before, without singling out OOP. It would also reinforce the idea of the document as a buffet of concepts - don't like the OOP example? Never mind, here are some procedural ones for you to enjoy. > > > Aside: if FFmpeg had a blog, I could turn this discussion into a great post > > called something like "reflections on object- vs. context-oriented > > development". > > But the project's voice is more objective than that, so this document is > > limited > > to discussing the subset of issues that relate specifically to the FFmpeg > > API. > > One option would be the wiki: > http://trac.ffmpeg.org/ > > but probably a personal blog entry would be better, given that this > would not be reference material but more as an article (since the API > and its own philosophy is a moving target). > > > > > On Sat, May 25, 2024 at 01:00:14PM +0200, Stefano Sabatini wrote: > > > > +Some functions fit awkwardly within FFmpeg's context idiom. For > > > > example, > > > > +av_ambient_viewing_environment_create_side_data() creates an > > > > +AVAmbientViewingEnvironment context, then adds it to the side-data of > > > > an > > > > +AVFrame context. > > > > > > To go back to this unfitting example, can you state what would be > > > fitting in this case? > > > > "Awkwardly" probably isn't the right word to use, but that's a language > > choice > > we can come back to. > > > > The problem with FFmpeg's interface isn't that any one part is illogical, > > it's that different parts of the interface follow incompatible logic. > > > > It's hard to give specific examples, because any given learner's journey > > looks > > like a random walk through the API, and you can always say "well nobody else > > would have that problem". But if everyone has a different problem, that > > means > > everyone has *a* problem, even though there's no localised code fix. > > Fine, but can you propose the signature of the functions that you > would consider optimal in this case? I think we largely agree on this, but since you ask - The code solution would be to pick a rule and rewrite the entire codebase to fit that rule. I don't have a strong opinion about what the rule is, but one example might be "the first context parameter to a function must be that fu
Re: [FFmpeg-devel] [PATCH v4 1/4] doc: Explain what "context" means
Posting this separately, as these are practical "how does FFmpeg work" issues vaguely inspired by recent discussions. *How do namespaces work in FFmpeg?* We've talked a bit about function namespaces recently. One reason I've suggested they're a weak signal is because they aren't really addressed in the documentation. How about adding something like this to the context doc: Most FFmpeg functions are grouped into namespaces, usually indicated by prefixes (e.g. `av_format_*`) but sometimes indicated by infixes (e.g. av_alloc_format_context()). Namespaces group functions by *topic*, which doesn't always correlate with *context*. For example, `av_find_*` functions search for information across various contexts. *Should external API devs treat Sw{r,s}Context as AVClass context structures?* This is probably an uninteresting edge case, but just to be sure... The website says Sw{r,s}Context start with AVClass[1], they have _get_class functions, are shown in `ffmpeg -h full`, and I haven't found anything that says to treat them differently to e.g. AVCodecContext. So I'm pretty sure these are AVClass context structures, at least as far as internal devs are concerned. But their definitions are only in the private interface, so the layout is just an implementation detail that can change without even a major version bump. AVFrame used to have a _get_class function despite never having an actual AVClass member, so that's not a signal to external API devs. And `URLContext` appears in `ffmpeg -h full` despite having being made private long ago, so that's not much of a signal either. My guess is that the above should be addressed with a patch like: +/** + * @brief Context for SWResampler + * + * @note The public ABI only guarantees this is an AVOptions-enabled struct. + * Its size and other members are not a part of the public ABI. + * + * @see + * - @ref Context + */ struct SwrContext { Let me know if the above is on the right track. If so, I'll queue up a patch for after the context document is done. *Are AVOptions just command-line options?* I have trouble with statements like "AVOptions is a framework for options", both because it's circular and because the term "option" is too broad to be meaningful. I've previously pushed the word "reflection" on the assumption that options can be used anywhere variables are used. For example, imagine a decoder that could be reconfigured on-the-fly to reduce CPU usage at the cost of displaying blurier images. That can't be part of the public interface because it's codec-specific, but I could imagine updating some kind of "output_quality" AVOption as a user slides a slider up and down. But the CLI tools are largely non-interactive, so have I just misunderstood? How about saying "AVOptions is a framework for command-line options"? [1] https://ffmpeg.org/doxygen/trunk/structSwrContext.html ___ 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/6] lavf/tls_mbedtls: handle more error codes for
From e8b5b6dee2d29690d1ae18090659120399b84e7c Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 13 May 2024 20:22:44 +0200 Subject: [PATCH v2 1/6] lavf/tls_mbedtls: handle more error codes for human-readable message Signed-off-by: sfan5 --- libavformat/tls_mbedtls.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c index 1a182e735e..1226e3780b 100644 --- a/libavformat/tls_mbedtls.c +++ b/libavformat/tls_mbedtls.c @@ -138,6 +138,9 @@ static void handle_handshake_error(URLContext *h, int ret) case MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE: av_log(h, AV_LOG_ERROR, "TLS handshake failed.\n"); break; +case MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION: +av_log(h, AV_LOG_ERROR, "TLS protocol version mismatch.\n"); +break; #endif case MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE: av_log(h, AV_LOG_ERROR, "A fatal alert message was received from the peer, has the peer a correct certificate?\n"); @@ -145,6 +148,9 @@ static void handle_handshake_error(URLContext *h, int ret) case MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED: av_log(h, AV_LOG_ERROR, "No CA chain is set, but required to operate. Was the CA correctly set?\n"); break; +case MBEDTLS_ERR_SSL_INTERNAL_ERROR: +av_log(h, AV_LOG_ERROR, "Internal error encountered.\n"); +break; case MBEDTLS_ERR_NET_CONN_RESET: av_log(h, AV_LOG_ERROR, "TLS handshake was aborted by peer.\n"); break; -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/6] lavf/tls_mbedtls: add missing call to psa_crypto_init
From 18142d98aed9e48a78a37590341bf48f1fe2339e Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 13 May 2024 20:24:43 +0200 Subject: [PATCH v2 2/6] lavf/tls_mbedtls: add missing call to psa_crypto_init This is mandatory depending on configuration or at least with mbedTLS 3.6.0. Signed-off-by: sfan5 --- libavformat/tls_mbedtls.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c index 1226e3780b..1a61fc57d6 100644 --- a/libavformat/tls_mbedtls.c +++ b/libavformat/tls_mbedtls.c @@ -26,6 +26,9 @@ #include #include #include +#ifdef MBEDTLS_PSA_CRYPTO_C +#include +#endif #include "avformat.h" #include "internal.h" @@ -184,6 +187,13 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op if ((ret = ff_tls_open_underlying(shr, h, uri, options)) < 0) goto fail; +#ifdef MBEDTLS_PSA_CRYPTO_C +if ((ret = psa_crypto_init()) != PSA_SUCCESS) { +av_log(h, AV_LOG_ERROR, "psa_crypto_init returned %d\n", ret); +goto fail; +} +#endif + mbedtls_ssl_init(&tls_ctx->ssl_context); mbedtls_ssl_config_init(&tls_ctx->ssl_config); mbedtls_entropy_init(&tls_ctx->entropy_context); -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 3/6] lavf/tls_mbedtls: hook up debug message callback
From f51387a129e93af13751237ec2c6e25ad07c8dc4 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 13 May 2024 20:26:16 +0200 Subject: [PATCH v2 3/6] lavf/tls_mbedtls: hook up debug message callback Unfortunately this won't work out-of-the-box because mbedTLS only provides a global (not per-context) debug toggle. Signed-off-by: sfan5 --- libavformat/tls_mbedtls.c | 17 + 1 file changed, 17 insertions(+) diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c index 1a61fc57d6..f53e918e04 100644 --- a/libavformat/tls_mbedtls.c +++ b/libavformat/tls_mbedtls.c @@ -26,6 +26,7 @@ #include #include #include +#include #ifdef MBEDTLS_PSA_CRYPTO_C #include #endif @@ -36,6 +37,7 @@ #include "tls.h" #include "libavutil/mem.h" #include "libavutil/parseutils.h" +#include "libavutil/avstring.h" typedef struct TLSContext { const AVClass *class; @@ -112,6 +114,13 @@ static int mbedtls_recv(void *ctx, unsigned char *buf, size_t len) return handle_transport_error(h, "ffurl_read", MBEDTLS_ERR_SSL_WANT_READ, ret); } +static void mbedtls_debug(void *ctx, int lvl, const char *file, int line, const char *msg) +{ +URLContext *h = (URLContext*) ctx; +int av_lvl = lvl >= 4 ? AV_LOG_TRACE : AV_LOG_DEBUG; +av_log(h, av_lvl, "%s:%d: %s", av_basename(file), line, msg); +} + static void handle_pk_parse_error(URLContext *h, int ret) { switch (ret) { @@ -201,6 +210,14 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op mbedtls_x509_crt_init(&tls_ctx->ca_cert); mbedtls_pk_init(&tls_ctx->priv_key); +if (av_log_get_level() >= AV_LOG_DEBUG) { +mbedtls_ssl_conf_dbg(&tls_ctx->ssl_config, mbedtls_debug, shr->tcp); +/* + * Note: we can't call mbedtls_debug_set_threshold() here because + * it's global state. The user is thus expected to manage this. + */ +} + // load trusted CA if (shr->ca_file) { if ((ret = mbedtls_x509_crt_parse_file(&tls_ctx->ca_cert, shr->ca_file)) != 0) { -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 4/6] lavf/tls_mbedtls: fix handling of certification
From d561732d7c05d820baeb9c8bff5e8a4b133fe624 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 13 May 2024 20:27:17 +0200 Subject: [PATCH v2 4/6] lavf/tls_mbedtls: fix handling of certification validation failures We manually check the verification status after the handshake has completed using mbedtls_ssl_get_verify_result(). However with VERIFY_REQUIRED mbedtls_ssl_handshake() already returns an error, so this code is never reached. Fix that by using VERIFY_OPTIONAL, which performs the verification but does not abort the handshake. Signed-off-by: sfan5 --- libavformat/tls_mbedtls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c index f53e918e04..ef447e12a5 100644 --- a/libavformat/tls_mbedtls.c +++ b/libavformat/tls_mbedtls.c @@ -266,8 +266,9 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op goto fail; } +// not VERIFY_REQUIRED because we manually check after handshake mbedtls_ssl_conf_authmode(&tls_ctx->ssl_config, - shr->verify ? MBEDTLS_SSL_VERIFY_REQUIRED : MBEDTLS_SSL_VERIFY_NONE); + shr->verify ? MBEDTLS_SSL_VERIFY_OPTIONAL : MBEDTLS_SSL_VERIFY_NONE); mbedtls_ssl_conf_rng(&tls_ctx->ssl_config, mbedtls_ctr_drbg_random, &tls_ctx->ctr_drbg_context); mbedtls_ssl_conf_ca_chain(&tls_ctx->ssl_config, &tls_ctx->ca_cert, NULL); -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 5/6] lavf/tls_mbedtls: handle session ticket error code as
From 87bf4c7de225036b5e4458c9de2de4b941f8f9b6 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 13 May 2024 20:29:10 +0200 Subject: [PATCH v2 5/6] lavf/tls_mbedtls: handle session ticket error code as no-op When TLSv1.3 and session tickets are enabled mbedtls_ssl_read() will return an error code to inform about a received session ticket. This can simply be handled like EAGAIN instead of errornously aborting the connection. ref: https://github.com/Mbed-TLS/mbedtls/issues/8749 Signed-off-by: sfan5 --- libavformat/tls_mbedtls.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c index ef447e12a5..9be817af5e 100644 --- a/libavformat/tls_mbedtls.c +++ b/libavformat/tls_mbedtls.c @@ -325,6 +325,9 @@ static int handle_tls_error(URLContext *h, const char* func_name, int ret) switch (ret) { case MBEDTLS_ERR_SSL_WANT_READ: case MBEDTLS_ERR_SSL_WANT_WRITE: +#ifdef MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET +case MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET: +#endif return AVERROR(EAGAIN); case MBEDTLS_ERR_NET_SEND_FAILED: case MBEDTLS_ERR_NET_RECV_FAILED: -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 6/6] lavf/tls_mbedtls: add workaround for TLSv1.3 vs.
From 98dd9aac129fbdf07f83da16b7307cb775ff8e66 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 17 May 2024 10:06:42 +0200 Subject: [PATCH v2 6/6] lavf/tls_mbedtls: add workaround for TLSv1.3 vs. verify=0 As of mbedTLS 3.6.0 TLSv1.3 is enabled by default and certificate verification is now mandatory. Our default configuration does not do verification, so downgrade to 1.2 in these situations to avoid breaking it. ref: https://github.com/Mbed-TLS/mbedtls/issues/7075 Signed-off-by: sfan5 --- libavformat/tls_mbedtls.c | 12 1 file changed, 12 insertions(+) diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c index 9be817af5e..fbad23ab8c 100644 --- a/libavformat/tls_mbedtls.c +++ b/libavformat/tls_mbedtls.c @@ -163,6 +163,10 @@ static void handle_handshake_error(URLContext *h, int ret) case MBEDTLS_ERR_SSL_INTERNAL_ERROR: av_log(h, AV_LOG_ERROR, "Internal error encountered.\n"); break; +case MBEDTLS_ERR_X509_CERT_VERIFY_FAILED: +// This error only happens with TLSv1.3, we normally use mbedtls_ssl_get_verify_result(). +av_log(h, AV_LOG_ERROR, "Certificate verification failed.\n"); +break; case MBEDTLS_ERR_NET_CONN_RESET: av_log(h, AV_LOG_ERROR, "TLS handshake was aborted by peer.\n"); break; @@ -266,6 +270,14 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op goto fail; } +#ifdef MBEDTLS_SSL_PROTO_TLS1_3 +// mbedTLS does not allow disabling certificate verification with TLSv1.3 (yes, really). +if (!shr->verify) { +av_log(h, AV_LOG_INFO, "Forcing TLSv1.2 because certificate verification is disabled\n"); +mbedtls_ssl_conf_max_tls_version(&tls_ctx->ssl_config, MBEDTLS_SSL_VERSION_TLS1_2); +} +#endif + // not VERIFY_REQUIRED because we manually check after handshake mbedtls_ssl_conf_authmode(&tls_ctx->ssl_config, shr->verify ? MBEDTLS_SSL_VERIFY_OPTIONAL : MBEDTLS_SSL_VERIFY_NONE); -- 2.45.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 v4 1/4] doc: Explain what "context" means
On Wed, May 29, 2024 at 12:50 PM Andrew Sayers wrote: > Posting this separately, as these are practical "how does FFmpeg work" > issues > vaguely inspired by recent discussions. > > > *How do namespaces work in FFmpeg?* > > We've talked a bit about function namespaces recently. One reason I've > suggested they're a weak signal is because they aren't really addressed in > the > documentation. How about adding something like this to the context doc: > > Most FFmpeg functions are grouped into namespaces, usually indicated by > prefixes (e.g. `av_format_*`) but sometimes indicated by infixes > (e.g. av_alloc_format_context()). Namespaces group functions by > *topic*, > which doesn't always correlate with *context*. For example, > `av_find_*` > functions search for information across various contexts. > > > *Should external API devs treat Sw{r,s}Context as AVClass context > structures?* > > This is probably an uninteresting edge case, but just to be sure... > > The website says Sw{r,s}Context start with AVClass[1], they have _get_class > functions, are shown in `ffmpeg -h full`, and I haven't found anything > that says > to treat them differently to e.g. AVCodecContext. So I'm pretty sure these > are AVClass context structures, at least as far as internal devs are > concerned. > > But their definitions are only in the private interface, so the layout is > just > an implementation detail that can change without even a major version bump. > AVFrame used to have a _get_class function despite never having an actual > AVClass member, so that's not a signal to external API devs. And > `URLContext` > appears in `ffmpeg -h full` despite having being made private long ago, > so that's not much of a signal either. > > My guess is that the above should be addressed with a patch like: > > +/** > + * @brief Context for SWResampler > + * > + * @note The public ABI only guarantees this is an AVOptions-enabled > struct. > + * Its size and other members are not a part of the public ABI. > + * > + * @see > + * - @ref Context > + */ > struct SwrContext { > > Let me know if the above is on the right track. If so, I'll queue up a > patch > for after the context document is done. > > > *Are AVOptions just command-line options?* > > I have trouble with statements like "AVOptions is a framework for options", > both because it's circular and because the term "option" is too broad to be > meaningful. > > I've previously pushed the word "reflection" on the assumption that options > can be used anywhere variables are used. For example, imagine a decoder > that > could be reconfigured on-the-fly to reduce CPU usage at the cost of > displaying > blurier images. That can't be part of the public interface because it's > codec-specific, but I could imagine updating some kind of "output_quality" > AVOption as a user slides a slider up and down. > > But the CLI tools are largely non-interactive, so have I just > misunderstood? > > How about saying "AVOptions is a framework for command-line options"? > ffmpeg is cli tool libavfilter is library AVOptions is certainly and primarily not framework for command-line options. > > [1] https://ffmpeg.org/doxygen/trunk/structSwrContext.html > ___ > 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] avcodec/mediacodec: Add support of dynamic bitrate
Thanks for the response. On Wed, 2024-05-29 at 12:19 +0800, Zhao Zhili wrote: > > 在 2024年5月29日,上午5:56,Dmitrii Okunev 写道: > > > > MediaCodec supports parameter "video-bitrate" to change the bitrate > > on fly. This commit adds capability to use it. > > > > It adds option -bitrate_ctrl_socket to the encoder which makes > > the encoder to create an UNIX socket and listen for messages > > to change the bitrate. > > Thank you for your contribution. However, libavcodec as a library has a clear > define of margin, IO such as socket cannot be put into libavcodec. > Reconfigure bitrate should be done via libavcodec API. This was the last resort, I tried to find another solution before posting this patch. But of course I'll gladly adapt the solution: could you give examples/pointers on how to change values via libavcodec API on fly in ffmpeg? Best regards, Dmitrii. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavfilter/signature_lookup: fix jaccard distance
Actually, the jaccard distance is defined as D = 1 - intersect / union. Additionally, the distance value is compared against a constant that must be between 0 and 1, which is not the case here. Both facts together has led to the fact, that the function always returned a matching course signature. To leave the constant intact and to avoid floating point computation, this commit multiplies with 1 << 16 making the constant effectively 9000 / (1<<16) =~ 0.14. Reported-by: Sachin Tilloo Reviewed-by: Sachin Tilloo Tested-by: Sachin Tilloo --- libavfilter/signature_lookup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c index b39a3e225b..b90b63f3f2 100644 --- a/libavfilter/signature_lookup.c +++ b/libavfilter/signature_lookup.c @@ -127,9 +127,10 @@ static int get_jaccarddist(SignatureContext *sc, CoarseSignature *first, CoarseS { int jaccarddist, i, composdist = 0, cwthcount = 0; for (i = 0; i < 5; i++) { -if ((jaccarddist = intersection_word(first->data[i], second->data[i])) > 0) { +if ((jaccarddist = (1 << 16) * intersection_word(first->data[i], second->data[i])) > 0) { jaccarddist /= FFMAX(union_word(first->data[i], second->data[i]), 1); } +jaccarddist = (1 << 16) - jaccarddist; if (jaccarddist >= sc->thworddist) { if (++cwthcount > 2) { /* more than half (5/2) of distances are too wide */ -- 2.43.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 v1 2/2][GSoC 2024] tests/checkasm/vvc_mc: for SAD, only test valid subblock sizes
On Wed, May 29, 2024 at 3:10 AM Stone Chen wrote: > According to the VVC specification (section 8.5.1), the maximum > width/height of a subblock passed for DMVR SAD is 16. This along with > previous constraint requiring width * height >= 128 means that 8x16, 16x8, > and 16x16 are the only allowed sizes Applied. Thank you, Stone. > > This changes check_vvc_sad() to only test and benchmark those sizes. > --- > tests/checkasm/vvc_mc.c | 12 +++- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c > index 1e889e2cff..09cac82edb 100644 > --- a/tests/checkasm/vvc_mc.c > +++ b/tests/checkasm/vvc_mc.c > @@ -337,11 +337,12 @@ static void check_vvc_sad(void) > memset(src1, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t)); > > randomize_pixels(src0, src1, MAX_CTU_SIZE * MAX_CTU_SIZE * 4); > - for (int h = 8; h <= MAX_CTU_SIZE; h *= 2) { > -for (int w = 8; w <= MAX_CTU_SIZE; w *= 2) { > +for (int h = 8; h <= 16; h *= 2) { > +for (int w = 8; w <= 16; w *= 2) { > for(int offy = 0; offy <= 4; offy++) { > for(int offx = 0; offx <= 4; offx++) { > -if(check_func(c.inter.sad, "sad_%dx%d", w, h)) { > +if(w * h >= 128) { > +if(check_func(c.inter.sad, "sad_%dx%d", w, h)) { > int result0; > int result1; > > @@ -350,13 +351,14 @@ static void check_vvc_sad(void) > > if (result1 != result0) > fail(); > -if(w == h && offx == 0 && offy == 0) > +if(offx == 0 && offy == 0) > bench_new(src0 + PIXEL_STRIDE * 2 + 2, src1 + > PIXEL_STRIDE * 2 + 2, offx, offy, w, h); > +} > } > } > } > } > - } > +} > > report("sad"); > } > -- > 2.45.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 mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] tests/checkasm/vvc_mc: fix indentation
Signed-off-by: James Almer --- tests/checkasm/vvc_mc.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c index 09cac82edb..40be837d68 100644 --- a/tests/checkasm/vvc_mc.c +++ b/tests/checkasm/vvc_mc.c @@ -341,8 +341,10 @@ static void check_vvc_sad(void) for (int w = 8; w <= 16; w *= 2) { for(int offy = 0; offy <= 4; offy++) { for(int offx = 0; offx <= 4; offx++) { -if(w * h >= 128) { -if(check_func(c.inter.sad, "sad_%dx%d", w, h)) { +if (w * h < 128) +continue; + +if (check_func(c.inter.sad, "sad_%dx%d", w, h)) { int result0; int result1; @@ -353,7 +355,6 @@ static void check_vvc_sad(void) fail(); if(offx == 0 && offy == 0) bench_new(src0 + PIXEL_STRIDE * 2 + 2, src1 + PIXEL_STRIDE * 2 + 2, offx, offy, w, h); -} } } } -- 2.45.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/2] tests/checkasm/vvc_mc: don't zero the SAD buffers
They will be filled immediately after. Signed-off-by: James Almer --- tests/checkasm/vvc_mc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c index 40be837d68..bc6b580f42 100644 --- a/tests/checkasm/vvc_mc.c +++ b/tests/checkasm/vvc_mc.c @@ -333,9 +333,6 @@ static void check_vvc_sad(void) declare_func(int, const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h); ff_vvc_dsp_init(&c, bit_depth); -memset(src0, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t)); -memset(src1, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t)); - randomize_pixels(src0, src1, MAX_CTU_SIZE * MAX_CTU_SIZE * 4); for (int h = 8; h <= 16; h *= 2) { for (int w = 8; w <= 16; w *= 2) { -- 2.45.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 v4 1/4] doc: Explain what "context" means
On Wed, May 29, 2024 at 01:06:30PM +0200, Paul B Mahol wrote: > On Wed, May 29, 2024 at 12:50 PM Andrew Sayers > wrote: > [...] > > *Are AVOptions just command-line options?* > > > > I have trouble with statements like "AVOptions is a framework for options", > > both because it's circular and because the term "option" is too broad to be > > meaningful. > > > > I've previously pushed the word "reflection" on the assumption that options > > can be used anywhere variables are used. For example, imagine a decoder > > that > > could be reconfigured on-the-fly to reduce CPU usage at the cost of > > displaying > > blurier images. That can't be part of the public interface because it's > > codec-specific, but I could imagine updating some kind of "output_quality" > > AVOption as a user slides a slider up and down. > > > > But the CLI tools are largely non-interactive, so have I just > > misunderstood? > > > > How about saying "AVOptions is a framework for command-line options"? > > > > ffmpeg is cli tool > > libavfilter is library > > AVOptions is certainly and primarily not framework for command-line options. "Command-line option" might be the wrong word, but I've just checked write_number() in libavutil/opt.c, and it seems to do non-atomic updates without locking anything. That suggests I was indeed wrong to think it could be used on-the-fly - maybe "initial configuration options" would be a better term? Possibly with a warning somewhere about how AVOptions is not reentrant? ___ 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/4] lavu/float_dsp: add double-precision scalar product
The function pointer is appended to the structure for backward binary compatibility. Fortunately, this is allocated by libavutil, not by the user, so increasing the structure size is safe. --- doc/APIchanges| 3 +++ libavutil/float_dsp.c | 12 libavutil/float_dsp.h | 14 ++ libavutil/version.h | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 60f056b863..50c51c664f 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-05-29 - xx - lavu 59.21.100 - float_dsp.h + Add AVFloatDSPContext.scalarproduct_double. + 2024-05-23 - xx - lavu 59.20.100 - channel_layout.h Add av_channel_layout_ambisonic_order(). diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c index e9fb023466..1c5bb05636 100644 --- a/libavutil/float_dsp.c +++ b/libavutil/float_dsp.c @@ -132,6 +132,17 @@ float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len) return p; } +static double ff_scalarproduct_double_c(const double *v1, const double *v2, +size_t len) +{ +double p = 0.0; + +for (size_t i = 0; i < len; i++) +p += v1[i] * v2[i]; + +return p; +} + av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) { AVFloatDSPContext *fdsp = av_mallocz(sizeof(AVFloatDSPContext)); @@ -149,6 +160,7 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) fdsp->vector_fmul_reverse = vector_fmul_reverse_c; fdsp->butterflies_float = butterflies_float_c; fdsp->scalarproduct_float = avpriv_scalarproduct_float_c; +fdsp->scalarproduct_double = ff_scalarproduct_double_c; #if ARCH_AARCH64 ff_float_dsp_init_aarch64(fdsp); diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h index 342a8715c5..b6b5b0a3b3 100644 --- a/libavutil/float_dsp.h +++ b/libavutil/float_dsp.h @@ -19,6 +19,8 @@ #ifndef AVUTIL_FLOAT_DSP_H #define AVUTIL_FLOAT_DSP_H +#include + typedef struct AVFloatDSPContext { /** * Calculate the entry wise product of two vectors of floats and store the result in @@ -187,6 +189,18 @@ typedef struct AVFloatDSPContext { */ void (*vector_dmul)(double *dst, const double *src0, const double *src1, int len); + +/** + * Calculate the scalar product of two vectors of doubles. + * + * @param v1 first vector + * @param v2 second vector + * @param len length of vectors + * + * @return inner product of the vectors + */ +double (*scalarproduct_double)(const double *v1, const double *v2, + size_t len); } AVFloatDSPContext; /** diff --git a/libavutil/version.h b/libavutil/version.h index 9c7146c228..9d08d56884 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 20 +#define LIBAVUTIL_VERSION_MINOR 21 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.45.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/4] lavf: get rid of bespoke double scalar products
--- libavfilter/aap_template.c | 14 +- libavfilter/anlms_template.c | 16 ++-- libavfilter/arls_template.c | 14 +- 3 files changed, 4 insertions(+), 40 deletions(-) diff --git a/libavfilter/aap_template.c b/libavfilter/aap_template.c index ea9c815a89..0e0580fb32 100644 --- a/libavfilter/aap_template.c +++ b/libavfilter/aap_template.c @@ -36,18 +36,6 @@ #define fn2(a,b) fn3(a,b) #define fn(a) fn2(a, SAMPLE_FORMAT) -#if DEPTH == 64 -static double scalarproduct_double(const double *v1, const double *v2, int len) -{ -double p = 0.0; - -for (int i = 0; i < len; i++) -p += v1[i] * v2[i]; - -return p; -} -#endif - static ftype fn(fir_sample)(AudioAPContext *s, ftype sample, ftype *delay, ftype *coeffs, ftype *tmp, int *offset) { @@ -60,7 +48,7 @@ static ftype fn(fir_sample)(AudioAPContext *s, ftype sample, ftype *delay, #if DEPTH == 32 output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); #else -output = scalarproduct_double(delay, tmp, s->kernel_size); +output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size); #endif if (--(*offset) < 0) diff --git a/libavfilter/anlms_template.c b/libavfilter/anlms_template.c index b25df4fa18..a8d1dbfe0f 100644 --- a/libavfilter/anlms_template.c +++ b/libavfilter/anlms_template.c @@ -33,18 +33,6 @@ #define fn2(a,b) fn3(a,b) #define fn(a) fn2(a, SAMPLE_FORMAT) -#if DEPTH == 64 -static double scalarproduct_double(const double *v1, const double *v2, int len) -{ -double p = 0.0; - -for (int i = 0; i < len; i++) -p += v1[i] * v2[i]; - -return p; -} -#endif - static ftype fn(fir_sample)(AudioNLMSContext *s, ftype sample, ftype *delay, ftype *coeffs, ftype *tmp, int *offset) { @@ -58,7 +46,7 @@ static ftype fn(fir_sample)(AudioNLMSContext *s, ftype sample, ftype *delay, #if DEPTH == 32 output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); #else -output = scalarproduct_double(delay, tmp, s->kernel_size); +output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size); #endif if (--(*offset) < 0) @@ -85,7 +73,7 @@ static ftype fn(process_sample)(AudioNLMSContext *s, ftype input, ftype desired, #if DEPTH == 32 sum = s->fdsp->scalarproduct_float(delay, delay, s->kernel_size); #else -sum = scalarproduct_double(delay, delay, s->kernel_size); +sum = s->fdsp->scalarproduct_double(delay, delay, s->kernel_size); #endif norm = s->eps + sum; b = mu * e / norm; diff --git a/libavfilter/arls_template.c b/libavfilter/arls_template.c index d8b19d89a5..c67b48cf6f 100644 --- a/libavfilter/arls_template.c +++ b/libavfilter/arls_template.c @@ -39,18 +39,6 @@ #define fn2(a,b) fn3(a,b) #define fn(a) fn2(a, SAMPLE_FORMAT) -#if DEPTH == 64 -static double scalarproduct_double(const double *v1, const double *v2, int len) -{ -double p = 0.0; - -for (int i = 0; i < len; i++) -p += v1[i] * v2[i]; - -return p; -} -#endif - static ftype fn(fir_sample)(AudioRLSContext *s, ftype sample, ftype *delay, ftype *coeffs, ftype *tmp, int *offset) { @@ -64,7 +52,7 @@ static ftype fn(fir_sample)(AudioRLSContext *s, ftype sample, ftype *delay, #if DEPTH == 32 output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); #else -output = scalarproduct_double(delay, tmp, s->kernel_size); +output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size); #endif if (--(*offset) < 0) -- 2.45.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/4] checkasm/float_dsp: add double-precision scalar product
--- tests/checkasm/float_dsp.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/tests/checkasm/float_dsp.c b/tests/checkasm/float_dsp.c index cadfa65e2a..296db1cff9 100644 --- a/tests/checkasm/float_dsp.c +++ b/tests/checkasm/float_dsp.c @@ -278,6 +278,22 @@ static void test_scalarproduct_float(const float *src0, const float *src1) bench_new(src0, src1, LEN); } +static void test_scalarproduct_double(const double *src0, const double *src1) +{ +double cprod, oprod; + +declare_func_float(double, const double *, const double *, size_t); + +cprod = call_ref(src0, src1, LEN); +oprod = call_new(src0, src1, LEN); +if (!double_near_abs_eps(cprod, oprod, ARBITRARY_SCALARPRODUCT_CONST)) { +fprintf(stderr, "%- .12f - %- .12f = % .12g\n", +cprod, oprod, cprod - oprod); +fail(); +} +bench_new(src0, src1, LEN); +} + void checkasm_check_float_dsp(void) { LOCAL_ALIGNED_32(float, src0, [LEN]); @@ -334,6 +350,9 @@ void checkasm_check_float_dsp(void) if (check_func(fdsp->scalarproduct_float, "scalarproduct_float")) test_scalarproduct_float(src3, src4); report("scalarproduct_float"); +if (check_func(fdsp->scalarproduct_double, "scalarproduct_double")) +test_scalarproduct_double(dbl_src0, dbl_src1); +report("scalarproduct_double"); av_freep(&fdsp); } -- 2.45.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/4] lavc/float_dsp: R-V V scalarproduct_double
C908: scalarproduct_double_c: 39.2 scalarproduct_double_rvv_f64: 10.5 X60: scalarproduct_double_c: 35.0 scalarproduct_double_rvv_f64: 5.2 --- libavutil/riscv/float_dsp_init.c | 3 +++ libavutil/riscv/float_dsp_rvv.S | 21 + 2 files changed, 24 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index 585f237225..155496fa6b 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -46,6 +46,8 @@ void ff_vector_dmac_scalar_rvv(double *dst, const double *src, double mul, int len); void ff_vector_dmul_scalar_rvv(double *dst, const double *src, double mul, int len); +double ff_scalarproduct_double_rvv(const double *v1, const double *v2, + size_t len); av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) { @@ -68,6 +70,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) fdsp->vector_dmul = ff_vector_dmul_rvv; fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_rvv; fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_rvv; +fdsp->scalarproduct_double = ff_scalarproduct_double_rvv; } } #endif diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index 7cfc890bc2..4379534af7 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -237,3 +237,24 @@ NOHWD mv a2, a3 ret endfunc + +func ff_scalarproduct_double_rvv, zve64f +vsetvli t0, zero, e64, m8, ta, ma +vmv.v.x v8, zero +vmv.s.x v0, zero +1: +vsetvli t0, a2, e64, m8, tu, ma +vle64.v v16, (a0) +sub a2, a2, t0 +vle64.v v24, (a1) +sh3add a0, t0, a0 +vfmacc.vvv8, v16, v24 +sh3add a1, t0, a1 +bnez a2, 1b + +vsetvli t0, zero, e64, m8, ta, ma +vfredusum.vs v0, v8, v0 +vfmv.f.s fa0, v0 +NOHWD fmv.x.w a0, fa0 +ret +endfunc -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avcodec/x86/vvc/vvc_alf: fix integer overflow
From: Wu Jianhua Some tests fails with certain seeds tests/checkasm/checkasm 2325607578 --test=vvc_alf checkasm: using random seed 2325607578 AVX2: vvc_alf_filter_luma_120x20_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x24_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x28_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x32_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x36_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x40_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x44_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x48_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x52_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x56_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x60_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x64_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x68_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x72_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x76_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x80_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x84_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x88_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x92_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x96_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x100_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x104_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x108_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x112_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x116_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x120_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x124_12_avx2 (vvc_alf.c:104) vvc_alf_filter_luma_120x128_12_avx2 (vvc_alf.c:104) - vvc_alf.alf_filter [FAILED] - vvc_alf.alf_classify [OK] checkasm: 28 of 9216 tests have failed Reported-by: James Almer Signed-off-by: Wu Jianhua --- libavcodec/x86/vvc/vvc_alf.asm | 13 + 1 file changed, 13 insertions(+) diff --git a/libavcodec/x86/vvc/vvc_alf.asm b/libavcodec/x86/vvc/vvc_alf.asm index 71e821c27b..91f158bac9 100644 --- a/libavcodec/x86/vvc/vvc_alf.asm +++ b/libavcodec/x86/vvc/vvc_alf.asm @@ -278,7 +278,9 @@ SECTION .text psrad m0, SHIFT + 3 psrad m1, SHIFT + 3 %%shift_end: +%if ps == 1 packssdw m0, m0, m1 +%endif %endmacro ; FILTER_VB(line) @@ -356,7 +358,18 @@ SECTION .text FILTER_VB xq +; sum += curr +%if ps == 1 paddw m0, m2 +%else +vpunpcklqdq m11, m2, m2 +vpunpckhqdq m12, m2, m2 +vpunpcklwd m11, m11, m14 +vpunpcklwd m12, m12, m14 +paddd m0, m11 +paddd m1, m12 +packssdw m0, m0, m1 +%endif ; clip to pixel CLIPW m0, m14, m15 -- 2.44.0.windows.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/3] avcodec/x86/vvc/vvc_alf: use xq to match ptrdiff_t
From: Wu Jianhua Signed-off-by: Wu Jianhua --- libavcodec/x86/vvc/vvc_alf.asm | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/x86/vvc/vvc_alf.asm b/libavcodec/x86/vvc/vvc_alf.asm index 91f158bac9..8bb698955c 100644 --- a/libavcodec/x86/vvc/vvc_alf.asm +++ b/libavcodec/x86/vvc/vvc_alf.asm @@ -421,7 +421,7 @@ cglobal vvc_alf_filter_%2_%1bpc, 11, 15, 16, 0-0x28, dst, dst_stride, src, src_s .loop: pushsrcq pushdstq -xor xd, xd +xor xq, xq .loop_w: LOAD_PARAMS @@ -429,8 +429,8 @@ cglobal vvc_alf_filter_%2_%1bpc, 11, 15, 16, 0-0x28, dst, dst_stride, src, src_s add srcq, 16 * ps add dstq, 16 * ps -add xd, 16 -cmp xd, widthd +add xq, 16 +cmp xq, widthq jl .loop_w pop dstq @@ -439,7 +439,7 @@ cglobal vvc_alf_filter_%2_%1bpc, 11, 15, 16, 0-0x28, dst, dst_stride, src, src_s lea dstq, [dstq + 4 * dst_strideq] lea filterq, [filterq + 2 * strideq] -leaclipq, [clipq + 2 * strideq] +leaclipq, [clipq + 2 * strideq] sub vb_posq, 4 sub heightq, 4 -- 2.44.0.windows.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/3] tests/checkasm/vvc_alf: change alf step size to 8
From: Wu Jianhua >From Benjamin Bross: > for ALF where functions are in increments of 4 while 8 should be sufficient > according to the spec. Signed-off-by: Wu Jianhua --- tests/checkasm/vvc_alf.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c index f35fd2cd3e..84b0f9da15 100644 --- a/tests/checkasm/vvc_alf.c +++ b/tests/checkasm/vvc_alf.c @@ -90,8 +90,8 @@ static void check_alf_filter(VVCDSPContext *c, const int bit_depth) randomize_buffers2(filter, LUMA_PARAMS_SIZE, 1); randomize_buffers2(clip, LUMA_PARAMS_SIZE, 0); -for (int h = 4; h <= MAX_CTU_SIZE; h += 4) { -for (int w = 4; w <= MAX_CTU_SIZE; w += 4) { +for (int h = 4; h <= MAX_CTU_SIZE; h += 8) { +for (int w = 4; w <= MAX_CTU_SIZE; w += 8) { const int ctu_size = MAX_CTU_SIZE; if (check_func(c->alf.filter[LUMA], "vvc_alf_filter_luma_%dx%d_%d", w, h, bit_depth)) { const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_LUMA; @@ -142,8 +142,8 @@ static void check_alf_classify(VVCDSPContext *c, const int bit_depth) randomize_buffers(src0, src1, SRC_BUF_SIZE); -for (int h = 4; h <= MAX_CTU_SIZE; h += 4) { -for (int w = 4; w <= MAX_CTU_SIZE; w += 4) { +for (int h = 4; h <= MAX_CTU_SIZE; h += 8) { +for (int w = 4; w <= MAX_CTU_SIZE; w += 8) { const int id_size = w * h / ALF_BLOCK_SIZE / ALF_BLOCK_SIZE * sizeof(int); const int vb_pos = MAX_CTU_SIZE - ALF_BLOCK_SIZE; if (check_func(c->alf.classify, "vvc_alf_classify_%dx%d_%d", w, h, bit_depth)) { -- 2.44.0.windows.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] swscale: [loongarch] Fix undeclared functions prob.
Ping. > 2024年5月15日 16:57,金波 写道: > > Look good to me. > > 2024-05-08 18:07:49 "yinshiyou-hf" 写道: >> Compile with '--disable-lasx', ‘lumRangeFromJpeg_lasx’ undeclared. >> --- >> libswscale/loongarch/swscale_init_loongarch.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/libswscale/loongarch/swscale_init_loongarch.c >> b/libswscale/loongarch/swscale_init_loongarch.c >> index 3a5a7ee856..4af62ad9f8 100644 >> --- a/libswscale/loongarch/swscale_init_loongarch.c >> +++ b/libswscale/loongarch/swscale_init_loongarch.c >> @@ -41,6 +41,7 @@ av_cold void >> ff_sws_init_range_convert_loongarch(SwsContext *c) >> } >> } >> } >> +#if HAVE_LASX >> if (have_lasx(cpu_flags)) { >> if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { >> if (c->dstBpc <= 14) { >> @@ -54,6 +55,7 @@ av_cold void >> ff_sws_init_range_convert_loongarch(SwsContext *c) >> } >> } >> } >> +#endif // #if HAVE_LASX >> } >> >> av_cold void ff_sws_init_swscale_loongarch(SwsContext *c) >> -- >> 2.20.1 >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] lavu/lls: R-V V update_lls
update_lls_8_c:7.5 update_lls_8_rvv_f64: 4.2 update_lls_12_c: 14.5 update_lls_12_rvv_f64: 5.7 --- libavutil/lls.c| 4 ++- libavutil/lls.h| 1 + libavutil/riscv/Makefile | 4 ++- libavutil/riscv/lls_init.c | 57 ++ libavutil/riscv/lls_rvv.S | 39 ++ 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 libavutil/riscv/lls_init.c create mode 100644 libavutil/riscv/lls_rvv.S diff --git a/libavutil/lls.c b/libavutil/lls.c index c1e038daf1..d300ae7a60 100644 --- a/libavutil/lls.c +++ b/libavutil/lls.c @@ -117,7 +117,9 @@ av_cold void avpriv_init_lls(LLSModel *m, int indep_count) m->indep_count = indep_count; m->update_lls = update_lls; m->evaluate_lls = evaluate_lls; -#if ARCH_X86 +#if ARCH_RISCV +ff_init_lls_riscv(m); +#elif ARCH_X86 ff_init_lls_x86(m); #endif } diff --git a/libavutil/lls.h b/libavutil/lls.h index 0709275822..7acef4eff8 100644 --- a/libavutil/lls.h +++ b/libavutil/lls.h @@ -57,6 +57,7 @@ typedef struct LLSModel { } LLSModel; void avpriv_init_lls(LLSModel *m, int indep_count); +void ff_init_lls_riscv(LLSModel *m); void ff_init_lls_x86(LLSModel *m); void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order); diff --git a/libavutil/riscv/Makefile b/libavutil/riscv/Makefile index 1597154ba5..7e9a51194b 100644 --- a/libavutil/riscv/Makefile +++ b/libavutil/riscv/Makefile @@ -1,5 +1,7 @@ OBJS += riscv/float_dsp_init.o \ riscv/fixed_dsp_init.o \ +riscv/lls_init.o \ riscv/cpu.o RVV-OBJS += riscv/float_dsp_rvv.o \ -riscv/fixed_dsp_rvv.o +riscv/fixed_dsp_rvv.o \ +riscv/lls_rvv.o diff --git a/libavutil/riscv/lls_init.c b/libavutil/riscv/lls_init.c new file mode 100644 index 00..b1317dc925 --- /dev/null +++ b/libavutil/riscv/lls_init.c @@ -0,0 +1,57 @@ +/* + * Copyright © 2024 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavutil/lls.h" + +void ff_lls_update_covariance_rvv(double covar[][36], const double *var, + int count); +double ff_scalarproduct_double_rvv(const double *, const double *, size_t); + +static void ff_lls_update_rvv(struct LLSModel *m, const double *var) +{ +ff_lls_update_covariance_rvv(m->covariance, var, m->indep_count + 1); +} + +static double ff_lls_evaluate_rvv(struct LLSModel *m, const double *var, + int order) +{ +return ff_scalarproduct_double_rvv(m->coeff[order], var, order + 1); +} + +av_cold void ff_init_lls_riscv(LLSModel *m) +{ +#if HAVE_RVV +int flags = av_get_cpu_flags(); + +if ((flags & AV_CPU_FLAG_RVB_ADDR) && (flags & AV_CPU_FLAG_RVV_F64)) { +if ((flags & AV_CPU_FLAG_RVB_BASIC) && +ff_get_rv_vlenb() > m->indep_count) +m->update_lls = ff_lls_update_rvv; +m->evaluate_lls = ff_lls_evaluate_rvv; +} +#endif +} diff --git a/libavutil/riscv/lls_rvv.S b/libavutil/riscv/lls_rvv.S new file mode 100644 index 00..e0e6f1008e --- /dev/null +++ b/libavutil/riscv/lls_rvv.S @@ -0,0 +1,39 @@ +/* + * Copyright © 2024 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "asm.S" + +func ff_lls_update_covariance_rvv, zve64d, zbb +vtype_vli t0, a2, t
[FFmpeg-devel] [PATCH] checkasm: add linear least square tests
--- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + tests/checkasm/lls.c | 101 ++ tests/fate/checkasm.mak | 1 + 5 files changed, 105 insertions(+) create mode 100644 tests/checkasm/lls.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 1dc770e9da..6eb94d10d5 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -71,6 +71,7 @@ CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS) AVUTILOBJS += av_tx.o AVUTILOBJS += fixed_dsp.o AVUTILOBJS += float_dsp.o +AVUTILOBJS += lls.o CHECKASMOBJS-$(CONFIG_AVUTIL) += $(AVUTILOBJS) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 97c9b9fdd4..d7aa2a9c09 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -254,6 +254,7 @@ static const struct { #if CONFIG_AVUTIL { "fixed_dsp", checkasm_check_fixed_dsp }, { "float_dsp", checkasm_check_float_dsp }, +{ "lls", checkasm_check_lls }, { "av_tx", checkasm_check_av_tx }, #endif { NULL } diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index a42645c4ae..211d7f52e6 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -105,6 +105,7 @@ void checkasm_check_huffyuvdsp(void); void checkasm_check_idctdsp(void); void checkasm_check_jpeg2000dsp(void); void checkasm_check_llauddsp(void); +void checkasm_check_lls(void); void checkasm_check_llviddsp(void); void checkasm_check_llviddspenc(void); void checkasm_check_lpc(void); diff --git a/tests/checkasm/lls.c b/tests/checkasm/lls.c new file mode 100644 index 00..a2e8f11f99 --- /dev/null +++ b/tests/checkasm/lls.c @@ -0,0 +1,101 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include "libavutil/lls.h" +#include "checkasm.h" + +#define randomize_buffer(buf) \ +do { \ +double bmg[2], stddev = 10.0; \ + \ +for (size_t i = 0; i < MAX_VARS; i += 2) { \ +av_bmg_get(&checkasm_lfg, bmg);\ +buf[i] = bmg[0] * stddev; \ +buf[i + 1] = bmg[1] * stddev; \ +} \ +} while(0); + +static void test_update(LLSModel *lls, const double *var) +{ +double refcovar[MAX_VARS][MAX_VARS]; +declare_func(void, LLSModel *, const double *); + +call_ref(lls, var); + +for (size_t i = 0; i < MAX_VARS; i++) +for (size_t j = 0; j < MAX_VARS; j++) +refcovar[i][j] = lls->covariance[i][j]; + +memset(lls->covariance, 0, sizeof (lls->covariance)); +call_new(lls, var); + +for (size_t i = 0; i < lls->indep_count; i++) +for (size_t j = i; j < lls->indep_count; j++) +if (!double_near_abs_eps(refcovar[i][j], lls->covariance[i][j], + 2 * DBL_EPSILON)) { +fprintf(stderr, "%zu, %zu: %- .12f - %- .12f = % .12g\n", i, j, +refcovar[i][j], lls->covariance[i][j], +refcovar[i][j] - lls->covariance[i][j]); +fail(); +} + +bench_new(lls, var); +} + +#define EPS 0.2 +static void test_evaluate(LLSModel *lls, const double *param, int order) +{ +double refprod, newprod; +declare_func_float(double, LLSModel *, const double *, int); + +refprod = call_ref(lls, param, order); +newprod = call_new(lls, param, order); + +if (!double_near_abs_eps(refprod, newprod, EPS)) { +fprintf(stderr, "%- .12f - %- .12f = % .12g\n", +refprod, newprod, refprod - newprod); +fail(); +} + +if (order == lls->indep_count) +bench_new(lls, param, order); +} + +void checkasm_check_lls(void) +{ +static const unsigned char counts[] = { 8, 12, MAX_VARS, }; + +for (size_t i = 0; i < FF_ARRAY_ELEMS(counts); i++) { +LOCAL_ALIGNED_32(double, var, [MAX_VARS]); +LOCAL_ALIGNED_32(double, param, [MAX_VARS]); +LLSModel lls; + +avpriv_init_lls(&lls, counts[i]
Re: [FFmpeg-devel] [PATCH 1/4] lavu/float_dsp: add double-precision scalar product
Rémi Denis-Courmont: > The function pointer is appended to the structure for backward binary > compatibility. Fortunately, this is allocated by libavutil, not by the > user, so increasing the structure size is safe. > --- > doc/APIchanges| 3 +++ > libavutil/float_dsp.c | 12 > libavutil/float_dsp.h | 14 ++ > libavutil/version.h | 2 +- > 4 files changed, 30 insertions(+), 1 deletion(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index 60f056b863..50c51c664f 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-05-29 - xx - lavu 59.21.100 - float_dsp.h > + Add AVFloatDSPContext.scalarproduct_double. float_dsp.h is not a public header (the allocator is avpriv: avpriv_float_dsp_alloc), so there must not be an APIchanges entry for this. > + > 2024-05-23 - xx - lavu 59.20.100 - channel_layout.h >Add av_channel_layout_ambisonic_order(). > > diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c > index e9fb023466..1c5bb05636 100644 > --- a/libavutil/float_dsp.c > +++ b/libavutil/float_dsp.c > @@ -132,6 +132,17 @@ float avpriv_scalarproduct_float_c(const float *v1, > const float *v2, int len) > return p; > } > > +static double ff_scalarproduct_double_c(const double *v1, const double *v2, Don't use an ff_ prefix for a static function. > +size_t len) > +{ > +double p = 0.0; > + > +for (size_t i = 0; i < len; i++) > +p += v1[i] * v2[i]; > + > +return p; > +} > + > av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) > { > AVFloatDSPContext *fdsp = av_mallocz(sizeof(AVFloatDSPContext)); > @@ -149,6 +160,7 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int > bit_exact) > fdsp->vector_fmul_reverse = vector_fmul_reverse_c; > fdsp->butterflies_float = butterflies_float_c; > fdsp->scalarproduct_float = avpriv_scalarproduct_float_c; > +fdsp->scalarproduct_double = ff_scalarproduct_double_c; > > #if ARCH_AARCH64 > ff_float_dsp_init_aarch64(fdsp); > diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h > index 342a8715c5..b6b5b0a3b3 100644 > --- a/libavutil/float_dsp.h > +++ b/libavutil/float_dsp.h > @@ -19,6 +19,8 @@ > #ifndef AVUTIL_FLOAT_DSP_H > #define AVUTIL_FLOAT_DSP_H > > +#include > + > typedef struct AVFloatDSPContext { > /** > * Calculate the entry wise product of two vectors of floats and store > the result in > @@ -187,6 +189,18 @@ typedef struct AVFloatDSPContext { > */ > void (*vector_dmul)(double *dst, const double *src0, const double *src1, > int len); > + > +/** > + * Calculate the scalar product of two vectors of doubles. > + * > + * @param v1 first vector > + * @param v2 second vector Are these supposed to obey additional alignment beyond that imposed by double? (Does your RISC-V implementation require it?) > + * @param len length of vectors > + * > + * @return inner product of the vectors > + */ > +double (*scalarproduct_double)(const double *v1, const double *v2, > + size_t len); > } AVFloatDSPContext; > > /** > diff --git a/libavutil/version.h b/libavutil/version.h > index 9c7146c228..9d08d56884 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -79,7 +79,7 @@ > */ > > #define LIBAVUTIL_VERSION_MAJOR 59 > -#define LIBAVUTIL_VERSION_MINOR 20 > +#define LIBAVUTIL_VERSION_MINOR 21 > #define LIBAVUTIL_VERSION_MICRO 100 > > #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ ___ 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/4] lavf: get rid of bespoke double scalar products
Rémi Denis-Courmont: > --- > libavfilter/aap_template.c | 14 +- > libavfilter/anlms_template.c | 16 ++-- > libavfilter/arls_template.c | 14 +- > 3 files changed, 4 insertions(+), 40 deletions(-) > > diff --git a/libavfilter/aap_template.c b/libavfilter/aap_template.c > index ea9c815a89..0e0580fb32 100644 > --- a/libavfilter/aap_template.c > +++ b/libavfilter/aap_template.c > @@ -36,18 +36,6 @@ > #define fn2(a,b) fn3(a,b) > #define fn(a) fn2(a, SAMPLE_FORMAT) > > -#if DEPTH == 64 > -static double scalarproduct_double(const double *v1, const double *v2, int > len) > -{ > -double p = 0.0; > - > -for (int i = 0; i < len; i++) > -p += v1[i] * v2[i]; > - > -return p; > -} > -#endif > - > static ftype fn(fir_sample)(AudioAPContext *s, ftype sample, ftype *delay, > ftype *coeffs, ftype *tmp, int *offset) > { > @@ -60,7 +48,7 @@ static ftype fn(fir_sample)(AudioAPContext *s, ftype > sample, ftype *delay, > #if DEPTH == 32 > output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); > #else > -output = scalarproduct_double(delay, tmp, s->kernel_size); > +output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size); > #endif > > if (--(*offset) < 0) > diff --git a/libavfilter/anlms_template.c b/libavfilter/anlms_template.c > index b25df4fa18..a8d1dbfe0f 100644 > --- a/libavfilter/anlms_template.c > +++ b/libavfilter/anlms_template.c > @@ -33,18 +33,6 @@ > #define fn2(a,b) fn3(a,b) > #define fn(a) fn2(a, SAMPLE_FORMAT) > > -#if DEPTH == 64 > -static double scalarproduct_double(const double *v1, const double *v2, int > len) > -{ > -double p = 0.0; > - > -for (int i = 0; i < len; i++) > -p += v1[i] * v2[i]; > - > -return p; > -} > -#endif > - > static ftype fn(fir_sample)(AudioNLMSContext *s, ftype sample, ftype *delay, > ftype *coeffs, ftype *tmp, int *offset) > { > @@ -58,7 +46,7 @@ static ftype fn(fir_sample)(AudioNLMSContext *s, ftype > sample, ftype *delay, > #if DEPTH == 32 > output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); > #else > -output = scalarproduct_double(delay, tmp, s->kernel_size); > +output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size); > #endif > > if (--(*offset) < 0) > @@ -85,7 +73,7 @@ static ftype fn(process_sample)(AudioNLMSContext *s, ftype > input, ftype desired, > #if DEPTH == 32 > sum = s->fdsp->scalarproduct_float(delay, delay, s->kernel_size); > #else > -sum = scalarproduct_double(delay, delay, s->kernel_size); > +sum = s->fdsp->scalarproduct_double(delay, delay, s->kernel_size); > #endif > norm = s->eps + sum; > b = mu * e / norm; > diff --git a/libavfilter/arls_template.c b/libavfilter/arls_template.c > index d8b19d89a5..c67b48cf6f 100644 > --- a/libavfilter/arls_template.c > +++ b/libavfilter/arls_template.c > @@ -39,18 +39,6 @@ > #define fn2(a,b) fn3(a,b) > #define fn(a) fn2(a, SAMPLE_FORMAT) > > -#if DEPTH == 64 > -static double scalarproduct_double(const double *v1, const double *v2, int > len) > -{ > -double p = 0.0; > - > -for (int i = 0; i < len; i++) > -p += v1[i] * v2[i]; > - > -return p; > -} > -#endif > - > static ftype fn(fir_sample)(AudioRLSContext *s, ftype sample, ftype *delay, > ftype *coeffs, ftype *tmp, int *offset) > { > @@ -64,7 +52,7 @@ static ftype fn(fir_sample)(AudioRLSContext *s, ftype > sample, ftype *delay, > #if DEPTH == 32 > output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); > #else > -output = scalarproduct_double(delay, tmp, s->kernel_size); > +output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size); > #endif > > if (--(*offset) < 0) 1. lavf is libavformat; libavfilter is lavfi. 2. Do you intend to use this outside of lavfi? - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] lavu/float_dsp: add double-precision scalar product
Le keskiviikkona 29. toukokuuta 2024, 18.44.13 EEST Andreas Rheinhardt a écrit : > > +static double ff_scalarproduct_double_c(const double *v1, > Don't use an ff_ prefix for a static function. I can see over 300 such identifiers in the code base (many but not all inline), and I don't see why that would be a problem. > > + > > +/** > > + * Calculate the scalar product of two vectors of doubles. > > + * > > + * @param v1 first vector > > + * @param v2 second vector > > Are these supposed to obey additional alignment beyond that imposed by > double? The C and RISC-V implementations require the natural alignment of double, 64- bit. If somebody wants to increase the required alignment(s), they are free to audit the call sites and update the comments accordingly, since this won't be an ABI break. > (Does your RISC-V implementation require it?) -- Rémi Denis-Courmont http://www.remlab.net/ ___ 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/4] lavf: get rid of bespoke double scalar products
Le keskiviikkona 29. toukokuuta 2024, 18.46.05 EEST Andreas Rheinhardt a écrit : > 2. Do you intend to use this outside of lavfi? Yes. -- Rémi Denis-Courmont http://www.remlab.net/ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] lavc/float_dsp: R-V V scalarproduct_double
Rémi Denis-Courmont: > C908: > scalarproduct_double_c: 39.2 > scalarproduct_double_rvv_f64: 10.5 > > X60: > scalarproduct_double_c: 35.0 > scalarproduct_double_rvv_f64: 5.2 > --- > libavutil/riscv/float_dsp_init.c | 3 +++ > libavutil/riscv/float_dsp_rvv.S | 21 + > 2 files changed, 24 insertions(+) > > diff --git a/libavutil/riscv/float_dsp_init.c > b/libavutil/riscv/float_dsp_init.c > index 585f237225..155496fa6b 100644 > --- a/libavutil/riscv/float_dsp_init.c > +++ b/libavutil/riscv/float_dsp_init.c > @@ -46,6 +46,8 @@ void ff_vector_dmac_scalar_rvv(double *dst, const double > *src, double mul, > int len); > void ff_vector_dmul_scalar_rvv(double *dst, const double *src, double mul, > int len); > +double ff_scalarproduct_double_rvv(const double *v1, const double *v2, > + size_t len); > > av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) > { > @@ -68,6 +70,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext > *fdsp) > fdsp->vector_dmul = ff_vector_dmul_rvv; > fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_rvv; > fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_rvv; > +fdsp->scalarproduct_double = ff_scalarproduct_double_rvv; > } > } > #endif > diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S > index 7cfc890bc2..4379534af7 100644 > --- a/libavutil/riscv/float_dsp_rvv.S > +++ b/libavutil/riscv/float_dsp_rvv.S > @@ -237,3 +237,24 @@ NOHWD mv a2, a3 > > ret > endfunc > + > +func ff_scalarproduct_double_rvv, zve64f > +vsetvli t0, zero, e64, m8, ta, ma > +vmv.v.x v8, zero > +vmv.s.x v0, zero > +1: > +vsetvli t0, a2, e64, m8, tu, ma > +vle64.v v16, (a0) > +sub a2, a2, t0 > +vle64.v v24, (a1) > +sh3add a0, t0, a0 > +vfmacc.vvv8, v16, v24 > +sh3add a1, t0, a1 > +bnez a2, 1b > + > +vsetvli t0, zero, e64, m8, ta, ma > +vfredusum.vs v0, v8, v0 > +vfmv.f.s fa0, v0 > +NOHWD fmv.x.w a0, fa0 > +ret > +endfunc s/lavc/lavu/ ___ 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/4] lavu/float_dsp: add double-precision scalar product
On 5/29/2024 12:51 PM, Rémi Denis-Courmont wrote: Le keskiviikkona 29. toukokuuta 2024, 18.44.13 EEST Andreas Rheinhardt a écrit : +static double ff_scalarproduct_double_c(const double *v1, Don't use an ff_ prefix for a static function. I can see over 300 such identifiers in the code base (many but not all inline), and I don't see why that would be a problem. + +/** + * Calculate the scalar product of two vectors of doubles. + * + * @param v1 first vector + * @param v2 second vector Are these supposed to obey additional alignment beyond that imposed by double? The C and RISC-V implementations require the natural alignment of double, 64- bit. If somebody wants to increase the required alignment(s), they are free to audit the call sites and update the comments accordingly, since this won't be an ABI break. Current users seem to all pass AVFrame audio buffers, so 32 byte alignment should be fine. And length should be a multiple of 16. So basically, same as all other double dsp functions in floatdsp. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 1/4] doc: Explain what "context" means
On date Wednesday 2024-05-29 11:50:40 +0100, Andrew Sayers wrote: > Posting this separately, as these are practical "how does FFmpeg work" issues > vaguely inspired by recent discussions. > > > *How do namespaces work in FFmpeg?* > > We've talked a bit about function namespaces recently. One reason I've > suggested they're a weak signal is because they aren't really addressed in the > documentation. How about adding something like this to the context doc: > > Most FFmpeg functions are grouped into namespaces, usually indicated by > prefixes (e.g. `av_format_*`) but sometimes indicated by infixes > (e.g. av_alloc_format_context()). Namespaces group functions by *topic*, > which doesn't always correlate with *context*. For example, `av_find_*` > functions search for information across various contexts. > > > *Should external API devs treat Sw{r,s}Context as AVClass context structures?* > > This is probably an uninteresting edge case, but just to be sure... > > The website says Sw{r,s}Context start with AVClass[1], they have _get_class > functions, are shown in `ffmpeg -h full`, and I haven't found anything that > says > to treat them differently to e.g. AVCodecContext. So I'm pretty sure these > are AVClass context structures, at least as far as internal devs are > concerned. It impacts the user as this changes the API. I guess when AVClass was removed from AVFrame that was done with a major bump to advertise an API break. > But their definitions are only in the private interface, so the layout is just > an implementation detail that can change without even a major version bump. > AVFrame used to have a _get_class function despite never having an actual > AVClass member, so that's not a signal to external API devs. And `URLContext` > appears in `ffmpeg -h full` despite having being made private long ago, > so that's not much of a signal either. > > My guess is that the above should be addressed with a patch like: > > +/** > + * @brief Context for SWResampler > + * > + * @note The public ABI only guarantees this is an AVOptions-enabled struct. > + * Its size and other members are not a part of the public ABI. This looks redundant to me, this is true for all the opaque structus, and we don't want to repeat this again and again (this is a feature of the C language, not of the API itself). > + * > + * @see > + * - @ref Context > + */ > struct SwrContext { > > Let me know if the above is on the right track. If so, I'll queue up a patch > for after the context document is done. Better to treat this as a separate patch anyway. > *Are AVOptions just command-line options?* No, in fact this is not about comman-line options at all. > > I have trouble with statements like "AVOptions is a framework for options", > both because it's circular and because the term "option" is too broad to be > meaningful. AVOptions (or better the av_opt API) is a system to set fields/properties/options on an enabled struct. This is a high level API since it allows multiple options setting, validation, setting from a dictionary etc., and enables to abstract the struct field name (since the option names might be different from the field name). > > I've previously pushed the word "reflection" on the assumption that options > can be used anywhere variables are used. For example, imagine a decoder that > could be reconfigured on-the-fly to reduce CPU usage at the cost of displaying > blurier images. That can't be part of the public interface because it's > codec-specific, but I could imagine updating some kind of "output_quality" > AVOption as a user slides a slider up and down. > > But the CLI tools are largely non-interactive, so have I just misunderstood? > > How about saying "AVOptions is a framework for command-line options"? It is not about CLI options, although you can use introspection to get the supported options and build an interface to set them. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/x86/vvc/vvc_alf: fix integer overflow
toq...@outlook.com: > From: Wu Jianhua > > Some tests fails with certain seeds > > tests/checkasm/checkasm 2325607578 --test=vvc_alf > checkasm: using random seed 2325607578 > AVX2: > vvc_alf_filter_luma_120x20_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x24_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x28_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x32_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x36_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x40_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x44_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x48_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x52_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x56_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x60_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x64_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x68_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x72_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x76_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x80_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x84_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x88_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x92_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x96_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x100_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x104_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x108_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x112_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x116_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x120_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x124_12_avx2 (vvc_alf.c:104) > vvc_alf_filter_luma_120x128_12_avx2 (vvc_alf.c:104) > - vvc_alf.alf_filter [FAILED] > - vvc_alf.alf_classify [OK] > checkasm: 28 of 9216 tests have failed > > Reported-by: James Almer > Signed-off-by: Wu Jianhua > --- > libavcodec/x86/vvc/vvc_alf.asm | 13 + > 1 file changed, 13 insertions(+) > > diff --git a/libavcodec/x86/vvc/vvc_alf.asm b/libavcodec/x86/vvc/vvc_alf.asm > index 71e821c27b..91f158bac9 100644 > --- a/libavcodec/x86/vvc/vvc_alf.asm > +++ b/libavcodec/x86/vvc/vvc_alf.asm > @@ -278,7 +278,9 @@ SECTION .text > psrad m0, SHIFT + 3 > psrad m1, SHIFT + 3 > %%shift_end: > +%if ps == 1 > packssdw m0, m0, m1 > +%endif > %endmacro > > ; FILTER_VB(line) > @@ -356,7 +358,18 @@ SECTION .text > > FILTER_VB xq > > +; sum += curr > +%if ps == 1 > paddw m0, m2 > +%else > +vpunpcklqdq m11, m2, m2 > +vpunpckhqdq m12, m2, m2 > +vpunpcklwd m11, m11, m14 > +vpunpcklwd m12, m12, m14 > +paddd m0, m11 > +paddd m1, m12 > +packssdw m0, m0, m1 > +%endif > > ; clip to pixel > CLIPW m0, m14, m15 Can this happen with real inputs (like when called from the decoder)? If not, then the test needs to be made more realistic. Anyway, what is the performance impact of this? - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] Empty arch/ directories
Hi, It is not likely we will get anyone to step up to do DSP work for arguably dead architectures like SPARC, Blackfin, etc. Maybe is it time to remove those directories that just contain a README now? Sean McGovern ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 2/5] lavc/vp9dsp: R-V V mc bilin h v
From: sunyuechi C908: vp9_avg_bilin_4h_8bpp_c: 5.2 vp9_avg_bilin_4h_8bpp_rvv_i64: 2.2 vp9_avg_bilin_4v_8bpp_c: 5.5 vp9_avg_bilin_4v_8bpp_rvv_i64: 2.2 vp9_avg_bilin_8h_8bpp_c: 20.0 vp9_avg_bilin_8h_8bpp_rvv_i64: 4.5 vp9_avg_bilin_8v_8bpp_c: 21.0 vp9_avg_bilin_8v_8bpp_rvv_i64: 4.2 vp9_avg_bilin_16h_8bpp_c: 78.2 vp9_avg_bilin_16h_8bpp_rvv_i64: 9.0 vp9_avg_bilin_16v_8bpp_c: 82.0 vp9_avg_bilin_16v_8bpp_rvv_i64: 9.0 vp9_avg_bilin_32h_8bpp_c: 325.5 vp9_avg_bilin_32h_8bpp_rvv_i64: 26.2 vp9_avg_bilin_32v_8bpp_c: 326.2 vp9_avg_bilin_32v_8bpp_rvv_i64: 26.2 vp9_avg_bilin_64h_8bpp_c: 1265.7 vp9_avg_bilin_64h_8bpp_rvv_i64: 91.5 vp9_avg_bilin_64v_8bpp_c: 1317.0 vp9_avg_bilin_64v_8bpp_rvv_i64: 91.2 vp9_put_bilin_4h_8bpp_c: 4.5 vp9_put_bilin_4h_8bpp_rvv_i64: 1.7 vp9_put_bilin_4v_8bpp_c: 4.7 vp9_put_bilin_4v_8bpp_rvv_i64: 1.7 vp9_put_bilin_8h_8bpp_c: 17.0 vp9_put_bilin_8h_8bpp_rvv_i64: 3.5 vp9_put_bilin_8v_8bpp_c: 18.0 vp9_put_bilin_8v_8bpp_rvv_i64: 3.5 vp9_put_bilin_16h_8bpp_c: 65.2 vp9_put_bilin_16h_8bpp_rvv_i64: 7.5 vp9_put_bilin_16v_8bpp_c: 85.7 vp9_put_bilin_16v_8bpp_rvv_i64: 7.5 vp9_put_bilin_32h_8bpp_c: 257.5 vp9_put_bilin_32h_8bpp_rvv_i64: 23.5 vp9_put_bilin_32v_8bpp_c: 274.5 vp9_put_bilin_32v_8bpp_rvv_i64: 23.5 vp9_put_bilin_64h_8bpp_c: 1040.5 vp9_put_bilin_64h_8bpp_rvv_i64: 82.5 vp9_put_bilin_64v_8bpp_c: 1108.7 vp9_put_bilin_64v_8bpp_rvv_i64: 82.2 --- libavcodec/riscv/vp9_mc_rvv.S | 60 ++ libavcodec/riscv/vp9dsp.h | 12 +++ libavcodec/riscv/vp9dsp_init.c | 21 3 files changed, 87 insertions(+), 6 deletions(-) diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S index 7cb38ec94a..9611aba0ed 100644 --- a/libavcodec/riscv/vp9_mc_rvv.S +++ b/libavcodec/riscv/vp9_mc_rvv.S @@ -53,6 +53,66 @@ func ff_vp9_avg\len\()_rvv, zve32x endfunc .endm +.macro bilin_load dst, op, type, mn +.ifc \type,v +add t5, a2, a3 +.else +addit5, a2, 1 +.endif +vle8.v v8, (a2) +vle8.v v0, (t5) +vwmulu.vx v16, v0, \mn +vwmaccsu.vx v16, t1, v8 +vwadd.wxv16, v16, t4 +vnsra.wiv16, v16, 4 +vadd.vv \dst, v16, v8 +.ifc \op,avg +vle8.v v16, (a0) +vaaddu.vv \dst, \dst, v16 +.endif +.endm + +.macro bilin_h_v op, type, mn +func ff_\op\()_vp9_bilin_4\type\()_rvv, zve32x +vsetvlstatic8 4, t0, 64 +.Lbilin_\type\op: +.ifc \op,avg +csrwi vxrm, 0 +.endif +li t4, 8 +neg t1, \mn +1: +addia4, a4, -1 +bilin_load v0, \op, \type, \mn +vse8.v v0, (a0) +add a2, a2, a3 +add a0, a0, a1 +bneza4, 1b + +ret +endfunc +.endm + .irp len, 64, 32, 16, 8, 4 copy_avg \len .endr + +bilin_h_v put, h, a5 +bilin_h_v avg, h, a5 +bilin_h_v put, v, a6 +bilin_h_v avg, v, a6 + +.macro func_bilin_h_v len, op, type +func ff_\op\()_vp9_bilin_\len\()\type\()_rvv, zve32x +vsetvlstatic8 \len, t0, 64 +j .Lbilin_\type\()\op +endfunc +.endm + +.irp len, 64, 32, 16, 8 +.irp op, put, avg +.irp type, h, v +func_bilin_h_v \len, \op, \type +.endr +.endr +.endr diff --git a/libavcodec/riscv/vp9dsp.h b/libavcodec/riscv/vp9dsp.h index ff8431591c..8fb326dae0 100644 --- a/libavcodec/riscv/vp9dsp.h +++ b/libavcodec/riscv/vp9dsp.h @@ -113,27 +113,27 @@ void ff_avg_8tap_##type##_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \ int h, int mx, int my); #define VP9_BILINEAR_RISCV_RVV_FUNC(SIZE) \ -void ff_put_bilin_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_put_vp9_bilin_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my);\ \ -void ff_put_bilin_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_put_vp9_bilin_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my);\ \ -void ff_put_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride,\ +void ff_put_vp9_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride,\ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); \ \ -void ff_avg_bilin_##SIZE##h_
[FFmpeg-devel] [PATCH v3 4/5] lavc/vp9dsp: R-V V mc tap h v
From: sunyuechi C908 X60 vp9_avg_8tap_smooth_4h_8bpp_c : 13.0 11.2 vp9_avg_8tap_smooth_4h_8bpp_rvv_i32:5.04.2 vp9_avg_8tap_smooth_4v_8bpp_c : 13.7 12.5 vp9_avg_8tap_smooth_4v_8bpp_rvv_i32:5.04.2 vp9_avg_8tap_smooth_8h_8bpp_c : 49.5 42.2 vp9_avg_8tap_smooth_8h_8bpp_rvv_i32:9.28.5 vp9_avg_8tap_smooth_8v_8bpp_c : 66.5 45.0 vp9_avg_8tap_smooth_8v_8bpp_rvv_i32:9.58.5 vp9_avg_8tap_smooth_16h_8bpp_c : 192.7 166.5 vp9_avg_8tap_smooth_16h_8bpp_rvv_i32 : 21.2 18.7 vp9_avg_8tap_smooth_16v_8bpp_c : 192.2 175.7 vp9_avg_8tap_smooth_16v_8bpp_rvv_i32 : 21.5 19.0 vp9_avg_8tap_smooth_32h_8bpp_c : 780.2 663.7 vp9_avg_8tap_smooth_32h_8bpp_rvv_i32 : 83.5 60.0 vp9_avg_8tap_smooth_32v_8bpp_c : 770.5 689.2 vp9_avg_8tap_smooth_32v_8bpp_rvv_i32 : 67.2 60.0 vp9_avg_8tap_smooth_64h_8bpp_c : 3115.5 2647.2 vp9_avg_8tap_smooth_64h_8bpp_rvv_i32 : 283.5 119.2 vp9_avg_8tap_smooth_64v_8bpp_c : 3082.2 2729.0 vp9_avg_8tap_smooth_64v_8bpp_rvv_i32 : 305.2 119.0 vp9_put_8tap_smooth_4h_8bpp_c : 11.29.7 vp9_put_8tap_smooth_4h_8bpp_rvv_i32:4.24.0 vp9_put_8tap_smooth_4v_8bpp_c : 11.7 10.7 vp9_put_8tap_smooth_4v_8bpp_rvv_i32:4.24.0 vp9_put_8tap_smooth_8h_8bpp_c : 42.0 37.5 vp9_put_8tap_smooth_8h_8bpp_rvv_i32:8.57.7 vp9_put_8tap_smooth_8v_8bpp_c : 44.2 38.7 vp9_put_8tap_smooth_8v_8bpp_rvv_i32:8.57.7 vp9_put_8tap_smooth_16h_8bpp_c : 165.7 147.2 vp9_put_8tap_smooth_16h_8bpp_rvv_i32 : 19.5 17.5 vp9_put_8tap_smooth_16v_8bpp_c : 169.0 149.7 vp9_put_8tap_smooth_16v_8bpp_rvv_i32 : 19.7 17.5 vp9_put_8tap_smooth_32h_8bpp_c : 659.7 586.7 vp9_put_8tap_smooth_32h_8bpp_rvv_i32 : 64.2 57.2 vp9_put_8tap_smooth_32v_8bpp_c : 680.5 591.2 vp9_put_8tap_smooth_32v_8bpp_rvv_i32 : 64.2 57.2 vp9_put_8tap_smooth_64h_8bpp_c : 2681.5 2339.0 vp9_put_8tap_smooth_64h_8bpp_rvv_i32 : 255.5 114.2 vp9_put_8tap_smooth_64v_8bpp_c : 2709.7 2348.7 vp9_put_8tap_smooth_64v_8bpp_rvv_i32 : 255.5 114.0 --- libavcodec/riscv/vp9_mc_rvv.S | 204 + libavcodec/riscv/vp9dsp.h | 72 libavcodec/riscv/vp9dsp_init.c | 37 +- 3 files changed, 288 insertions(+), 25 deletions(-) diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S index 990271736b..53dd833dac 100644 --- a/libavcodec/riscv/vp9_mc_rvv.S +++ b/libavcodec/riscv/vp9_mc_rvv.S @@ -36,6 +36,18 @@ .endif .endm +.macro vsetvlstatic16 len +.ifc \len,4 +vsetvli zero, zero, e16, mf2, ta, ma +.elseif \len == 8 +vsetvli zero, zero, e16, m1, ta, ma +.elseif \len == 16 +vsetvli zero, zero, e16, m2, ta, ma +.else +vsetvli zero, zero, e16, m4, ta, ma +.endif +.endm + .macro copy_avg len func ff_vp9_avg\len\()_rvv, zve32x csrwi vxrm, 0 @@ -127,8 +139,200 @@ func ff_\op\()_vp9_bilin_4hv_rvv, zve32x endfunc .endm +.macro epel_filter name, type, regtype +lla \regtype\()2, ff_vp9_subpel_filters + +.ifc \name,regular +addi\regtype\()2, \regtype\()2, 16*8*2 +.endif +.ifc \name,sharp +addi\regtype\()2, \regtype\()2, 16*8*2*2 +.endif + +.ifc \type,v +slli\regtype\()0, a6, 4 +.else +slli\regtype\()0, a5, 4 +.endif +add \regtype\()0, \regtype\()0, \regtype\()2 + +lh \regtype\()1, 2(\regtype\()0) +lh \regtype\()2, 4(\regtype\()0) +lh \regtype\()3, 6(\regtype\()0) +lh \regtype\()4, 8(\regtype\()0) +lh \regtype\()5, 10(\regtype\()0) +lh \regtype\()6, 12(\regtype\()0) + +.ifc \regtype,t +lh a7, 14(\regtype\()0) +.else +lh s7, 14(\regtype\()0) +.endif +lh \regtype\()0, 0(\regtype\()0) +.endm + +.macro epel_load dst, len, op, name, type, from_mem, regtype +li a5, 64 +.ifc \from_mem, 1 +vle8.v v22, (a2) +.ifc \type,v +sub a2, a2, a3 +vle8.v v20, (a2) +sh1add a2, a3, a2 +vle8.v v24, (a2) +ad
[FFmpeg-devel] [PATCH v3 1/5] lavc/vp9dsp: R-V V rename ff_avg to ff_vp9_avg
From: sunyuechi Avoid potential naming conflicts --- libavcodec/riscv/vp9_mc_rvv.S | 4 ++-- libavcodec/riscv/vp9dsp.h | 4 ++-- libavcodec/riscv/vp9dsp_init.c | 8 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S index 7811cd9928..7cb38ec94a 100644 --- a/libavcodec/riscv/vp9_mc_rvv.S +++ b/libavcodec/riscv/vp9_mc_rvv.S @@ -37,9 +37,9 @@ .endm .macro copy_avg len -func ff_avg\len\()_rvv, zve32x +func ff_vp9_avg\len\()_rvv, zve32x csrwi vxrm, 0 -vsetvlstatic8 \len t0 64 +vsetvlstatic8 \len, t0, 64 1: vle8.v v8, (a2) vle8.v v16, (a0) diff --git a/libavcodec/riscv/vp9dsp.h b/libavcodec/riscv/vp9dsp.h index 79330b4968..ff8431591c 100644 --- a/libavcodec/riscv/vp9dsp.h +++ b/libavcodec/riscv/vp9dsp.h @@ -138,11 +138,11 @@ void ff_avg_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride,\ int h, int mx, int my); #define VP9_COPY_AVG_RISCV_RVV_FUNC(SIZE) \ -void ff_copy##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride,\ +void ff_vp9_copy##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride,\ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); \ \ -void ff_avg##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_vp9_avg##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c index 6bfe23563a..454dcd963f 100644 --- a/libavcodec/riscv/vp9dsp_init.c +++ b/libavcodec/riscv/vp9dsp_init.c @@ -52,10 +52,10 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, int bpp) if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) { #define init_fpel(idx1, sz) \ -dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_avg##sz##_rvv; \ -dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_avg##sz##_rvv; \ -dsp->mc[idx1][FILTER_8TAP_SHARP ][1][0][0] = ff_avg##sz##_rvv; \ -dsp->mc[idx1][FILTER_BILINEAR][1][0][0] = ff_avg##sz##_rvv +dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_vp9_avg##sz##_rvv; \ +dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_vp9_avg##sz##_rvv; \ +dsp->mc[idx1][FILTER_8TAP_SHARP ][1][0][0] = ff_vp9_avg##sz##_rvv; \ +dsp->mc[idx1][FILTER_BILINEAR][1][0][0] = ff_vp9_avg##sz##_rvv init_fpel(0, 64); init_fpel(1, 32); -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 5/5] lavc/vp9dsp: R-V V mc tap hv
From: sunyuechi C908 X60 vp9_avg_8tap_smooth_4hv_8bpp_c : 32.0 28.2 vp9_avg_8tap_smooth_4hv_8bpp_rvv_i32 : 15.0 13.2 vp9_avg_8tap_smooth_8hv_8bpp_c : 98.0 86.2 vp9_avg_8tap_smooth_8hv_8bpp_rvv_i32 : 23.7 21.0 vp9_avg_8tap_smooth_16hv_8bpp_c: 355.5 297.0 vp9_avg_8tap_smooth_16hv_8bpp_rvv_i32 : 62.7 41.2 vp9_avg_8tap_smooth_32hv_8bpp_c: 1273.0 1099.7 vp9_avg_8tap_smooth_32hv_8bpp_rvv_i32 : 133.7 119.2 vp9_avg_8tap_smooth_64hv_8bpp_c: 4933.0 4240.5 vp9_avg_8tap_smooth_64hv_8bpp_rvv_i32 : 506.7 227.0 vp9_put_8tap_smooth_4hv_8bpp_c : 30.2 27.0 vp9_put_8tap_smooth_4hv_8bpp_rvv_i32 : 14.5 12.7 vp9_put_8tap_smooth_8hv_8bpp_c : 91.2 81.2 vp9_put_8tap_smooth_8hv_8bpp_rvv_i32 : 22.7 20.2 vp9_put_8tap_smooth_16hv_8bpp_c: 329.2 277.7 vp9_put_8tap_smooth_16hv_8bpp_rvv_i32 : 44.7 40.0 vp9_put_8tap_smooth_32hv_8bpp_c: 1183.7 1022.7 vp9_put_8tap_smooth_32hv_8bpp_rvv_i32 : 130.7 116.5 vp9_put_8tap_smooth_64hv_8bpp_c: 4502.7 3954.5 vp9_put_8tap_smooth_64hv_8bpp_rvv_i32 : 496.0 224.7 --- libavcodec/riscv/vp9_mc_rvv.S | 75 ++ libavcodec/riscv/vp9dsp_init.c | 8 2 files changed, 83 insertions(+) diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S index 53dd833dac..fed698c802 100644 --- a/libavcodec/riscv/vp9_mc_rvv.S +++ b/libavcodec/riscv/vp9_mc_rvv.S @@ -323,6 +323,77 @@ func ff_\op\()_vp9_8tap_\name\()_\len\()\type\()_rvv\vlen\(), zve32x endfunc .endm +#if __riscv_xlen == 64 +.macro epel_hv_once len, name, op +sub a2, a2, a3 +sub a2, a2, a3 +sub a2, a2, a3 +.irp n,0,2,4,6,8,10,12,14 +epel_load_inc v\n, \len, put, \name, h, 1, t +.endr +addia4, a4, -1 +1: +addia4, a4, -1 +epel_load v30, \len, \op, \name, v, 0, s +vse8.v v30, (a0) +vmv.v.v v0, v2 +vmv.v.v v2, v4 +vmv.v.v v4, v6 +vmv.v.v v6, v8 +vmv.v.v v8, v10 +vmv.v.v v10, v12 +vmv.v.v v12, v14 +epel_load v14, \len, put, \name, h, 1, t +add a2, a2, a3 +add a0, a0, a1 +bneza4, 1b +epel_load v30, \len, \op, \name, v, 0, s +vse8.v v30, (a0) +.endm + +.macro epel_hv op, name, len, vlen +func ff_\op\()_vp9_8tap_\name\()_\len\()hv_rvv\vlen\(), zve32x +addisp, sp, -64 +.irp n,0,1,2,3,4,5,6,7 +sd s\n, \n\()<<3(sp) +.endr +.if \len == 64 && \vlen < 256 +addisp, sp, -48 +.irp n,0,1,2,3,4,5 +sd a\n, \n\()<<3(sp) +.endr +.endif +.ifc \op,avg +csrwi vxrm, 0 +.endif +epel_filter \name, h, t +epel_filter \name, v, s +.if \vlen < 256 +vsetvlstatic8 \len, a6, 32, m2 +.else +vsetvlstatic8 \len, a6, 64, m2 +.endif +epel_hv_once\len, \name, \op +.if \len == 64 && \vlen < 256 +.irp n,0,1,2,3,4,5 +ld a\n, \n\()<<3(sp) +.endr +addisp, sp, 48 +addia0, a0, 32 +addia2, a2, 32 +epel_filter \name, h, t +epel_hv_once\len, \name, \op +.endif +.irp n,0,1,2,3,4,5,6,7 +ld s\n, \n\()<<3(sp) +.endr +addisp, sp, 64 + +ret +endfunc +.endm +#endif + .irp len, 64, 32, 16, 8, 4 copy_avg \len .irp op, put, avg @@ -331,6 +402,10 @@ endfunc epel \len, \op, \name, \type, 128 epel \len, \op, \name, \type, 256 .endr +#if __riscv_xlen == 64 +epel_hv \op, \name, \len, 128 +epel_hv \op, \name, \len, 256 +#endif .endr .endr .endr diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c index 5f759e6bc8..6b39ad8ee0 100644 --- a/libavcodec/riscv/vp9dsp_init.c +++ b/libavcodec/riscv/vp9dsp_init.c @@ -118,6 +118,10 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, int bpp) if (flags & AV_CPU_FLAG_RVB_ADDR) { init_subpel2(0, 0, 1, v, put, 128); init_subpel2(1, 0, 1, v, avg, 128); +# if __riscv_xlen == 64 +init_subpel2(0, 1, 1, hv, put, 128); +init_subpel2(1, 1, 1, hv, avg, 128); +# endif
[FFmpeg-devel] [PATCH v3 3/5] lavc/vp9dsp: R-V V mc bilin hv
From: sunyuechi C908: vp9_avg_bilin_4hv_8bpp_c: 11.0 vp9_avg_bilin_4hv_8bpp_rvv_i64: 3.7 vp9_avg_bilin_8hv_8bpp_c: 38.7 vp9_avg_bilin_8hv_8bpp_rvv_i64: 7.2 vp9_avg_bilin_16hv_8bpp_c: 147.0 vp9_avg_bilin_16hv_8bpp_rvv_i64: 14.2 vp9_avg_bilin_32hv_8bpp_c: 574.5 vp9_avg_bilin_32hv_8bpp_rvv_i64: 42.7 vp9_avg_bilin_64hv_8bpp_c: 2311.5 vp9_avg_bilin_64hv_8bpp_rvv_i64: 201.7 vp9_put_bilin_4hv_8bpp_c: 10.0 vp9_put_bilin_4hv_8bpp_rvv_i64: 3.2 vp9_put_bilin_8hv_8bpp_c: 35.2 vp9_put_bilin_8hv_8bpp_rvv_i64: 6.5 vp9_put_bilin_16hv_8bpp_c: 133.7 vp9_put_bilin_16hv_8bpp_rvv_i64: 13.0 vp9_put_bilin_32hv_8bpp_c: 538.2 vp9_put_bilin_32hv_8bpp_rvv_i64: 39.7 vp9_put_bilin_64hv_8bpp_c: 2114.0 vp9_put_bilin_64hv_8bpp_rvv_i64: 153.7 --- libavcodec/riscv/vp9_mc_rvv.S | 38 +- libavcodec/riscv/vp9dsp_init.c | 10 + 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S index 9611aba0ed..990271736b 100644 --- a/libavcodec/riscv/vp9_mc_rvv.S +++ b/libavcodec/riscv/vp9_mc_rvv.S @@ -93,6 +93,40 @@ func ff_\op\()_vp9_bilin_4\type\()_rvv, zve32x endfunc .endm +.macro bilin_hv op +func ff_\op\()_vp9_bilin_4hv_rvv, zve32x +vsetvlstatic8 4, t0, 64 +.Lbilin_hv\op: +.ifc \op,avg +csrwi vxrm, 0 +.endif +neg t1, a5 +neg t2, a6 +li t4, 8 +bilin_load v24, put, h, a5 +add a2, a2, a3 +1: +addia4, a4, -1 +bilin_load v4, put, h, a5 +vwmulu.vx v16, v4, a6 +vwmaccsu.vx v16, t2, v24 +vwadd.wxv16, v16, t4 +vnsra.wiv16, v16, 4 +vadd.vv v0, v16, v24 +.ifc \op,avg +vle8.v v16, (a0) +vaaddu.vv v0, v0, v16 +.endif +vse8.v v0, (a0) +vmv.v.v v24, v4 +add a2, a2, a3 +add a0, a0, a1 +bneza4, 1b + +ret +endfunc +.endm + .irp len, 64, 32, 16, 8, 4 copy_avg \len .endr @@ -101,6 +135,8 @@ bilin_h_v put, h, a5 bilin_h_v avg, h, a5 bilin_h_v put, v, a6 bilin_h_v avg, v, a6 +bilin_hv put +bilin_hv avg .macro func_bilin_h_v len, op, type func ff_\op\()_vp9_bilin_\len\()\type\()_rvv, zve32x @@ -111,7 +147,7 @@ endfunc .irp len, 64, 32, 16, 8 .irp op, put, avg -.irp type, h, v +.irp type, h, v, hv func_bilin_h_v \len, \op, \type .endr .endr diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c index 9606d8545f..b3700dfb08 100644 --- a/libavcodec/riscv/vp9dsp_init.c +++ b/libavcodec/riscv/vp9dsp_init.c @@ -83,6 +83,16 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, int bpp) dsp->mc[4][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_4h_rvv; dsp->mc[4][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_4v_rvv; dsp->mc[4][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_4h_rvv; +dsp->mc[0][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_64hv_rvv; +dsp->mc[0][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_64hv_rvv; +dsp->mc[1][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_32hv_rvv; +dsp->mc[1][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_32hv_rvv; +dsp->mc[2][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_16hv_rvv; +dsp->mc[2][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_16hv_rvv; +dsp->mc[3][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_8hv_rvv; +dsp->mc[3][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_8hv_rvv; +dsp->mc[4][FILTER_BILINEAR ][0][1][1] = ff_put_vp9_bilin_4hv_rvv; +dsp->mc[4][FILTER_BILINEAR ][1][1][1] = ff_avg_vp9_bilin_4hv_rvv; #undef init_fpel } -- 2.45.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 v3 4/5] lavc/vp9dsp: R-V V mc tap h v
A portion has been modified according to the previous review, but there are still some parts that haven't been updated > Similarly, it > should be possible to share most of the horizontal and vertical code (maybe > also for bilinear. not just EPel) with separate load/store then inner > procedures. The H.263 loop filter already does that though with almost no > overhead, though > H.263 is obviously simpler than VP9. > > A French philosopher famously said that Perfect is the ennemy of Good. > Generally, as with VVC, nested repetition macros for finely specialised > functions tend to generate way too much byte code, and this ends up being > worse rather than better in the big picture. Here, bilin is modified with reference to your vp8 modification method, but there are some issues with epel. I want to share most of the horizontal and vertical code like h263, but because there are different types (op/name/len), such changes seem hard. Trying to make similar modifications for bilin also seems some hard , maybe leaving it for future optimization :'( > It should be possible to spare one ADDI by using just AUIPC here, and folding > the immediate offset into the LB's below (see also H.263 loop filter). I'm not sure where the problem lies, but for smooth it works, but for sharp, regular, it gives this error: dangerous relocation: %pcrel_lo overflow with an addend, the value of %pcrel_hi is 0xa5000 without any addend, but may be 0xa6000 after adding the %pcrel_lo addend 于2024年5月30日周四 01:16写道: > From: sunyuechi > > C908 X60 > vp9_avg_8tap_smooth_4h_8bpp_c : 13.0 11.2 > vp9_avg_8tap_smooth_4h_8bpp_rvv_i32:5.04.2 > vp9_avg_8tap_smooth_4v_8bpp_c : 13.7 12.5 > vp9_avg_8tap_smooth_4v_8bpp_rvv_i32:5.04.2 > vp9_avg_8tap_smooth_8h_8bpp_c : 49.5 42.2 > vp9_avg_8tap_smooth_8h_8bpp_rvv_i32:9.28.5 > vp9_avg_8tap_smooth_8v_8bpp_c : 66.5 45.0 > vp9_avg_8tap_smooth_8v_8bpp_rvv_i32:9.58.5 > vp9_avg_8tap_smooth_16h_8bpp_c : 192.7 166.5 > vp9_avg_8tap_smooth_16h_8bpp_rvv_i32 : 21.2 18.7 > vp9_avg_8tap_smooth_16v_8bpp_c : 192.2 175.7 > vp9_avg_8tap_smooth_16v_8bpp_rvv_i32 : 21.5 19.0 > vp9_avg_8tap_smooth_32h_8bpp_c : 780.2 663.7 > vp9_avg_8tap_smooth_32h_8bpp_rvv_i32 : 83.5 60.0 > vp9_avg_8tap_smooth_32v_8bpp_c : 770.5 689.2 > vp9_avg_8tap_smooth_32v_8bpp_rvv_i32 : 67.2 60.0 > vp9_avg_8tap_smooth_64h_8bpp_c : 3115.5 2647.2 > vp9_avg_8tap_smooth_64h_8bpp_rvv_i32 : 283.5 119.2 > vp9_avg_8tap_smooth_64v_8bpp_c : 3082.2 2729.0 > vp9_avg_8tap_smooth_64v_8bpp_rvv_i32 : 305.2 119.0 > vp9_put_8tap_smooth_4h_8bpp_c : 11.29.7 > vp9_put_8tap_smooth_4h_8bpp_rvv_i32:4.24.0 > vp9_put_8tap_smooth_4v_8bpp_c : 11.7 10.7 > vp9_put_8tap_smooth_4v_8bpp_rvv_i32:4.24.0 > vp9_put_8tap_smooth_8h_8bpp_c : 42.0 37.5 > vp9_put_8tap_smooth_8h_8bpp_rvv_i32:8.57.7 > vp9_put_8tap_smooth_8v_8bpp_c : 44.2 38.7 > vp9_put_8tap_smooth_8v_8bpp_rvv_i32:8.57.7 > vp9_put_8tap_smooth_16h_8bpp_c : 165.7 147.2 > vp9_put_8tap_smooth_16h_8bpp_rvv_i32 : 19.5 17.5 > vp9_put_8tap_smooth_16v_8bpp_c : 169.0 149.7 > vp9_put_8tap_smooth_16v_8bpp_rvv_i32 : 19.7 17.5 > vp9_put_8tap_smooth_32h_8bpp_c : 659.7 586.7 > vp9_put_8tap_smooth_32h_8bpp_rvv_i32 : 64.2 57.2 > vp9_put_8tap_smooth_32v_8bpp_c : 680.5 591.2 > vp9_put_8tap_smooth_32v_8bpp_rvv_i32 : 64.2 57.2 > vp9_put_8tap_smooth_64h_8bpp_c : 2681.5 2339.0 > vp9_put_8tap_smooth_64h_8bpp_rvv_i32 : 255.5 114.2 > vp9_put_8tap_smooth_64v_8bpp_c : 2709.7 2348.7 > vp9_put_8tap_smooth_64v_8bpp_rvv_i32 : 255.5 114.0 > --- > libavcodec/riscv/vp9_mc_rvv.S | 204 + > libavcodec/riscv/vp9dsp.h | 72 > libavcodec/riscv/vp9dsp_init.c | 37 +- > 3 files changed, 288 insertions(+), 25 deletions(-) > > diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S > index 990271736b..53dd833dac 100644 > --- a/libavcodec/riscv/vp9_mc_rvv.S > +++ b/libavcodec/riscv/vp9_mc_rvv.S > @@ -36,6 +36,18 @@ > .endif > .endm > > +.macro vsetvlstatic16 len > +.ifc \len,4 > +vsetvli zero, zero, e16, mf2, ta, ma > +.elseif \len == 8 > +vsetvli zero, zero, e16, m1,
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/x86/vvc/vvc_alf: fix integer overflow
Hi, On Wed, May 29, 2024 at 11:38 AM wrote: > +%else > +vpunpcklqdq m11, m2, m2 > +vpunpckhqdq m12, m2, m2 > +vpunpcklwd m11, m11, m14 > +vpunpcklwd m12, m12, m14 > +paddd m0, m11 > +paddd m1, m12 > +packssdw m0, m0, m1 > +%endif > punpcklqdq a, src, src punpckhqdq b, src, src punpcklwd a, a, zero punpcklwd b, b, zero is the same as punpcklwd a, src, zero punpckhwd b, src, zero Also, the whole thing just emulates a saturated add. Can't you use paddsw instead of paddw and be done with it? To add to Andreas' question: is saturating here normatively required? Ronald ___ 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] checkasm/vc1dsp: add missing vc1_inv_trans_8x8 test
--- tests/checkasm/vc1dsp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/checkasm/vc1dsp.c b/tests/checkasm/vc1dsp.c index f18f0f8251..440fad9b05 100644 --- a/tests/checkasm/vc1dsp.c +++ b/tests/checkasm/vc1dsp.c @@ -295,6 +295,7 @@ static void check_inv_trans_adding(void) VC1DSPContext h; const test tests[] = { +VC1DSP_SIZED_TEST(vc1_inv_trans_8x8, 8, 8) VC1DSP_SIZED_TEST(vc1_inv_trans_8x4, 8, 4) VC1DSP_SIZED_TEST(vc1_inv_trans_4x8, 4, 8) VC1DSP_SIZED_TEST(vc1_inv_trans_4x4, 4, 4) -- 2.45.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] [PATCHv4] checkasm/lpc: test compute_autocorr
Also restrict length to even values, matching real uses. This test is disabled, known broken, on x86. --- tests/checkasm/lpc.c | 57 +--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index 592e34c03d..cb15e8245b 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -16,6 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "libavutil/avassert.h" #include "libavutil/mem_internal.h" #include "libavcodec/lpc.h" @@ -30,7 +31,7 @@ } \ } while (0) -#define EPS 0.005 +#define EPS 0.0001 static void test_window(int len) { @@ -57,10 +58,51 @@ static void test_window(int len) bench_new(src, len, dst1); } +#if !ARCH_X86 +static void test_compute_autocorr(ptrdiff_t len, int lag) +{ +const double eps = EPS * (double)len; +LOCAL_ALIGNED(32, double, src, [5000 + 2 + MAX_LPC_ORDER]); +LOCAL_ALIGNED(16, double, dst0, [MAX_LPC_ORDER + 1]); +LOCAL_ALIGNED(16, double, dst1, [MAX_LPC_ORDER + 1]); + +declare_func(void, const double *in, ptrdiff_t len, int lag, double *out); + +av_assert0(lag >= 0 && lag <= MAX_LPC_ORDER); + +for (int i = 0; i < MAX_LPC_ORDER; i++) +src[i] = 0.; + +src += MAX_LPC_ORDER; + +for (int i = 0; i < 5000 + 2; i++) { +src[i] = (double)rnd() / (double)UINT_MAX; +} + +call_ref(src, len, lag, dst0); +call_new(src, len, lag, dst1); + +for (size_t i = 0; i <= lag; i++) { +if (!double_near_abs_eps(dst0[i], dst1[i], eps)) { +fprintf(stderr, "%zu: %- .12f - %- .12f = % .12g\n", +i, dst0[i], dst1[i], dst0[i] - dst1[i]); +fail(); +break; +} +} + +bench_new(src, 4608, lag, dst1); +} +#endif + void checkasm_check_lpc(void) { LPCContext ctx; -int len = rnd() % 5000; +int len = 2000 + (rnd() % 1500) * 2; +#if !ARCH_X86 +static const int lags[] = { 8, 12, }; +#endif + ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { @@ -72,6 +114,15 @@ void checkasm_check_lpc(void) test_window(len | 1); } report("apply_welch_window_odd"); - ff_lpc_end(&ctx); + +#if !ARCH_X86 +for (size_t i = 0; i < FF_ARRAY_ELEMS(lags); i++) { +ff_lpc_init(&ctx, len, lags[i], FF_LPC_TYPE_DEFAULT); +if (check_func(ctx.lpc_compute_autocorr, "autocorr_%d", lags[i])) +test_compute_autocorr(len, lags[i]); +ff_lpc_end(&ctx); +} +report("compute_autocorr"); +#endif } -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] 回复: [PATCH 1/3] avcodec/x86/vvc/vvc_alf: fix integer overflow
Ronald S. Bultje: > 发件人: Ronald S. Bultje > 发送时间: 2024年5月29日 10:51 > 收件人: FFmpeg development discussions and patches > 抄送: James Almer; Wu Jianhua > 主题: Re: [FFmpeg-devel] [PATCH 1/3] avcodec/x86/vvc/vvc_alf: fix integer > overflow > > Hi, > > On Wed, May 29, 2024 at 11:38 AM > mailto:toq...@outlook.com>> wrote: > +%else > +vpunpcklqdq m11, m2, m2 > +vpunpckhqdq m12, m2, m2 > +vpunpcklwd m11, m11, m14 > +vpunpcklwd m12, m12, m14 > +paddd m0, m11 > +paddd m1, m12 > +packssdw m0, m0, m1 > +%endif > > punpcklqdq a, src, src > punpckhqdq b, src, src > punpcklwd a, a, zero > punpcklwd b, b, zero > > is the same as > > punpcklwd a, src, zero > punpckhwd b, src, zero Thank you for pointing out this. This modification is really helpful for my improvement! Andreas: >Can this happen with real inputs (like when called from the decoder)? If > not, then the test needs to be made more realistic. > Anyway, what is the performance impact of this? I didn't have a unit test, but the average FPS looks no change. Ronald: > Also, the whole thing just emulates a saturated add. Can't you use paddsw > instead of paddw and be done with it? To add to Andreas' question: is > saturating here normatively required? We didn't have any sample that failed for this issue except for the checksum with specific seeds. I think we can keep not changing it until a real sample has something wrong. @Nuomi to get more details. ___ 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] [PATCHv4] checkasm/lpc: test compute_autocorr
Rémi Denis-Courmont: > Also restrict length to even values, matching real uses. It seems to me that the flac encoder can use odd values (namely if the user set an odd frame_size option or if it gets fed an odd number of samples in which case the last frame will have an odd number of samples). > This test is disabled, known broken, on x86. > --- > tests/checkasm/lpc.c | 57 +--- > 1 file changed, 54 insertions(+), 3 deletions(-) > > diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c > index 592e34c03d..cb15e8245b 100644 > --- a/tests/checkasm/lpc.c > +++ b/tests/checkasm/lpc.c > @@ -16,6 +16,7 @@ > * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > */ > > +#include "libavutil/avassert.h" > #include "libavutil/mem_internal.h" > > #include "libavcodec/lpc.h" > @@ -30,7 +31,7 @@ > } \ > } while (0) > > -#define EPS 0.005 > +#define EPS 0.0001 > > static void test_window(int len) > { > @@ -57,10 +58,51 @@ static void test_window(int len) > bench_new(src, len, dst1); > } > > +#if !ARCH_X86 > +static void test_compute_autocorr(ptrdiff_t len, int lag) > +{ > +const double eps = EPS * (double)len; > +LOCAL_ALIGNED(32, double, src, [5000 + 2 + MAX_LPC_ORDER]); > +LOCAL_ALIGNED(16, double, dst0, [MAX_LPC_ORDER + 1]); > +LOCAL_ALIGNED(16, double, dst1, [MAX_LPC_ORDER + 1]); > + > +declare_func(void, const double *in, ptrdiff_t len, int lag, double > *out); > + > +av_assert0(lag >= 0 && lag <= MAX_LPC_ORDER); > + > +for (int i = 0; i < MAX_LPC_ORDER; i++) > +src[i] = 0.; > + > +src += MAX_LPC_ORDER; > + > +for (int i = 0; i < 5000 + 2; i++) { > +src[i] = (double)rnd() / (double)UINT_MAX; > +} > + > +call_ref(src, len, lag, dst0); > +call_new(src, len, lag, dst1); > + > +for (size_t i = 0; i <= lag; i++) { > +if (!double_near_abs_eps(dst0[i], dst1[i], eps)) { > +fprintf(stderr, "%zu: %- .12f - %- .12f = % .12g\n", > +i, dst0[i], dst1[i], dst0[i] - dst1[i]); > +fail(); > +break; > +} > +} > + > +bench_new(src, 4608, lag, dst1); > +} > +#endif > + > void checkasm_check_lpc(void) > { > LPCContext ctx; > -int len = rnd() % 5000; > +int len = 2000 + (rnd() % 1500) * 2; > +#if !ARCH_X86 > +static const int lags[] = { 8, 12, }; > +#endif > + > ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); > > if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { > @@ -72,6 +114,15 @@ void checkasm_check_lpc(void) > test_window(len | 1); > } > report("apply_welch_window_odd"); > - > ff_lpc_end(&ctx); > + > +#if !ARCH_X86 > +for (size_t i = 0; i < FF_ARRAY_ELEMS(lags); i++) { > +ff_lpc_init(&ctx, len, lags[i], FF_LPC_TYPE_DEFAULT); > +if (check_func(ctx.lpc_compute_autocorr, "autocorr_%d", lags[i])) > +test_compute_autocorr(len, lags[i]); > +ff_lpc_end(&ctx); > +} > +report("compute_autocorr"); > +#endif > } ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 3/5] lavc/vp9dsp: R-V V mc bilin hv
Le keskiviikkona 29. toukokuuta 2024, 20.15.38 EEST u...@foxmail.com a écrit : > From: sunyuechi > > C908: > vp9_avg_bilin_4hv_8bpp_c: 11.0 > vp9_avg_bilin_4hv_8bpp_rvv_i64: 3.7 > vp9_avg_bilin_8hv_8bpp_c: 38.7 > vp9_avg_bilin_8hv_8bpp_rvv_i64: 7.2 > vp9_avg_bilin_16hv_8bpp_c: 147.0 > vp9_avg_bilin_16hv_8bpp_rvv_i64: 14.2 > vp9_avg_bilin_32hv_8bpp_c: 574.5 > vp9_avg_bilin_32hv_8bpp_rvv_i64: 42.7 > vp9_avg_bilin_64hv_8bpp_c: 2311.5 > vp9_avg_bilin_64hv_8bpp_rvv_i64: 201.7 > vp9_put_bilin_4hv_8bpp_c: 10.0 > vp9_put_bilin_4hv_8bpp_rvv_i64: 3.2 > vp9_put_bilin_8hv_8bpp_c: 35.2 > vp9_put_bilin_8hv_8bpp_rvv_i64: 6.5 > vp9_put_bilin_16hv_8bpp_c: 133.7 > vp9_put_bilin_16hv_8bpp_rvv_i64: 13.0 > vp9_put_bilin_32hv_8bpp_c: 538.2 > vp9_put_bilin_32hv_8bpp_rvv_i64: 39.7 > vp9_put_bilin_64hv_8bpp_c: 2114.0 > vp9_put_bilin_64hv_8bpp_rvv_i64: 153.7 > --- > libavcodec/riscv/vp9_mc_rvv.S | 38 +- > libavcodec/riscv/vp9dsp_init.c | 10 + > 2 files changed, 47 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S > index 9611aba0ed..990271736b 100644 > --- a/libavcodec/riscv/vp9_mc_rvv.S > +++ b/libavcodec/riscv/vp9_mc_rvv.S > @@ -93,6 +93,40 @@ func ff_\op\()_vp9_bilin_4\type\()_rvv, zve32x > endfunc > .endm > > +.macro bilin_hv op > +func ff_\op\()_vp9_bilin_4hv_rvv, zve32x > +vsetvlstatic8 4, t0, 64 > +.Lbilin_hv\op: > +.ifc \op,avg > +csrwi vxrm, 0 > +.endif > +neg t1, a5 > +neg t2, a6 > +li t4, 8 > +bilin_load v24, put, h, a5 > +add a2, a2, a3 > +1: > +addia4, a4, -1 > +bilin_load v4, put, h, a5 > +vwmulu.vx v16, v4, a6 > +vwmaccsu.vx v16, t2, v24 > +vwadd.wxv16, v16, t4 > +vnsra.wiv16, v16, 4 > +vadd.vv v0, v16, v24 > +.ifc \op,avg > +vle8.v v16, (a0) > +vaaddu.vv v0, v0, v16 > +.endif > +vse8.v v0, (a0) > +vmv.v.v v24, v4 Copying vectors is rarely justified - mostly only before destructive instructions such as FMA. If a4 is even (?), this should be faster by unrolling to two rows per iteration. > +add a2, a2, a3 > +add a0, a0, a1 > +bneza4, 1b > + > +ret > +endfunc > +.endm > + > .irp len, 64, 32, 16, 8, 4 > copy_avg \len > .endr > @@ -101,6 +135,8 @@ bilin_h_v put, h, a5 > bilin_h_v avg, h, a5 > bilin_h_v put, v, a6 > bilin_h_v avg, v, a6 > +bilin_hv put > +bilin_hv avg > > .macro func_bilin_h_v len, op, type > func ff_\op\()_vp9_bilin_\len\()\type\()_rvv, zve32x > @@ -111,7 +147,7 @@ endfunc > > .irp len, 64, 32, 16, 8 > .irp op, put, avg > -.irp type, h, v > +.irp type, h, v, hv > func_bilin_h_v \len, \op, \type > .endr > .endr > diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c > index 9606d8545f..b3700dfb08 100644 > --- a/libavcodec/riscv/vp9dsp_init.c > +++ b/libavcodec/riscv/vp9dsp_init.c > @@ -83,6 +83,16 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext > *dsp, int bpp) dsp->mc[4][FILTER_BILINEAR ][0][1][0] = > ff_put_vp9_bilin_4h_rvv; dsp->mc[4][FILTER_BILINEAR ][1][0][1] = > ff_avg_vp9_bilin_4v_rvv; dsp->mc[4][FILTER_BILINEAR ][1][1][0] = > ff_avg_vp9_bilin_4h_rvv; +dsp->mc[0][FILTER_BILINEAR ][0][1][1] = > ff_put_vp9_bilin_64hv_rvv; +dsp->mc[0][FILTER_BILINEAR ][1][1][1] = > ff_avg_vp9_bilin_64hv_rvv; +dsp->mc[1][FILTER_BILINEAR ][0][1][1] = > ff_put_vp9_bilin_32hv_rvv; +dsp->mc[1][FILTER_BILINEAR ][1][1][1] = > ff_avg_vp9_bilin_32hv_rvv; +dsp->mc[2][FILTER_BILINEAR ][0][1][1] = > ff_put_vp9_bilin_16hv_rvv; +dsp->mc[2][FILTER_BILINEAR ][1][1][1] = > ff_avg_vp9_bilin_16hv_rvv; +dsp->mc[3][FILTER_BILINEAR ][0][1][1] = > ff_put_vp9_bilin_8hv_rvv; +dsp->mc[3][FILTER_BILINEAR ][1][1][1] = > ff_avg_vp9_bilin_8hv_rvv; +dsp->mc[4][FILTER_BILINEAR ][0][1][1] = > ff_put_vp9_bilin_4hv_rvv; +dsp->mc[4][FILTER_BILINEAR ][1][1][1] = > ff_avg_vp9_bilin_4hv_rvv; > > #undef init_fpel > } -- 雷米‧德尼-库尔蒙 http://www.remlab.net/ ___ 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 4/5] lavc/vp9dsp: R-V V mc tap h v
Le keskiviikkona 29. toukokuuta 2024, 20.15.39 EEST u...@foxmail.com a écrit : > From: sunyuechi > > C908 X60 > vp9_avg_8tap_smooth_4h_8bpp_c : 13.0 11.2 > vp9_avg_8tap_smooth_4h_8bpp_rvv_i32:5.04.2 > vp9_avg_8tap_smooth_4v_8bpp_c : 13.7 12.5 > vp9_avg_8tap_smooth_4v_8bpp_rvv_i32:5.04.2 > vp9_avg_8tap_smooth_8h_8bpp_c : 49.5 42.2 > vp9_avg_8tap_smooth_8h_8bpp_rvv_i32:9.28.5 > vp9_avg_8tap_smooth_8v_8bpp_c : 66.5 45.0 > vp9_avg_8tap_smooth_8v_8bpp_rvv_i32:9.58.5 > vp9_avg_8tap_smooth_16h_8bpp_c : 192.7 166.5 > vp9_avg_8tap_smooth_16h_8bpp_rvv_i32 : 21.2 18.7 > vp9_avg_8tap_smooth_16v_8bpp_c : 192.2 175.7 > vp9_avg_8tap_smooth_16v_8bpp_rvv_i32 : 21.5 19.0 > vp9_avg_8tap_smooth_32h_8bpp_c : 780.2 663.7 > vp9_avg_8tap_smooth_32h_8bpp_rvv_i32 : 83.5 60.0 > vp9_avg_8tap_smooth_32v_8bpp_c : 770.5 689.2 > vp9_avg_8tap_smooth_32v_8bpp_rvv_i32 : 67.2 60.0 > vp9_avg_8tap_smooth_64h_8bpp_c : 3115.5 2647.2 > vp9_avg_8tap_smooth_64h_8bpp_rvv_i32 : 283.5 119.2 > vp9_avg_8tap_smooth_64v_8bpp_c : 3082.2 2729.0 > vp9_avg_8tap_smooth_64v_8bpp_rvv_i32 : 305.2 119.0 > vp9_put_8tap_smooth_4h_8bpp_c : 11.29.7 > vp9_put_8tap_smooth_4h_8bpp_rvv_i32:4.24.0 > vp9_put_8tap_smooth_4v_8bpp_c : 11.7 10.7 > vp9_put_8tap_smooth_4v_8bpp_rvv_i32:4.24.0 > vp9_put_8tap_smooth_8h_8bpp_c : 42.0 37.5 > vp9_put_8tap_smooth_8h_8bpp_rvv_i32:8.57.7 > vp9_put_8tap_smooth_8v_8bpp_c : 44.2 38.7 > vp9_put_8tap_smooth_8v_8bpp_rvv_i32:8.57.7 > vp9_put_8tap_smooth_16h_8bpp_c : 165.7 147.2 > vp9_put_8tap_smooth_16h_8bpp_rvv_i32 : 19.5 17.5 > vp9_put_8tap_smooth_16v_8bpp_c : 169.0 149.7 > vp9_put_8tap_smooth_16v_8bpp_rvv_i32 : 19.7 17.5 > vp9_put_8tap_smooth_32h_8bpp_c : 659.7 586.7 > vp9_put_8tap_smooth_32h_8bpp_rvv_i32 : 64.2 57.2 > vp9_put_8tap_smooth_32v_8bpp_c : 680.5 591.2 > vp9_put_8tap_smooth_32v_8bpp_rvv_i32 : 64.2 57.2 > vp9_put_8tap_smooth_64h_8bpp_c : 2681.5 2339.0 > vp9_put_8tap_smooth_64h_8bpp_rvv_i32 : 255.5 114.2 > vp9_put_8tap_smooth_64v_8bpp_c : 2709.7 2348.7 > vp9_put_8tap_smooth_64v_8bpp_rvv_i32 : 255.5 114.0 > --- > libavcodec/riscv/vp9_mc_rvv.S | 204 + > libavcodec/riscv/vp9dsp.h | 72 > libavcodec/riscv/vp9dsp_init.c | 37 +- > 3 files changed, 288 insertions(+), 25 deletions(-) > > diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S > index 990271736b..53dd833dac 100644 > --- a/libavcodec/riscv/vp9_mc_rvv.S > +++ b/libavcodec/riscv/vp9_mc_rvv.S > @@ -36,6 +36,18 @@ > .endif > .endm > > +.macro vsetvlstatic16 len > +.ifc \len,4 > +vsetvli zero, zero, e16, mf2, ta, ma > +.elseif \len == 8 > +vsetvli zero, zero, e16, m1, ta, ma > +.elseif \len == 16 > +vsetvli zero, zero, e16, m2, ta, ma > +.else > +vsetvli zero, zero, e16, m4, ta, ma > +.endif > +.endm > + > .macro copy_avg len > func ff_vp9_avg\len\()_rvv, zve32x > csrwi vxrm, 0 > @@ -127,8 +139,200 @@ func ff_\op\()_vp9_bilin_4hv_rvv, zve32x > endfunc > .endm > > +.macro epel_filter name, type, regtype > +lla \regtype\()2, ff_vp9_subpel_filters > + > +.ifc \name,regular > +addi\regtype\()2, \regtype\()2, 16*8*2 You can directly LLA filters + 16 * 8 * 2 and save one add. Same below. You can also use .equ to alias the filter addresses, and avoid if's. > +.endif > +.ifc \name,sharp > +addi\regtype\()2, \regtype\()2, 16*8*2*2 > +.endif > + > +.ifc \type,v > +slli\regtype\()0, a6, 4 > +.else > +slli\regtype\()0, a5, 4 > +.endif Use a macro parameter for the stride register. > +add \regtype\()0, \regtype\()0, \regtype\()2 > + > +lh \regtype\()1, 2(\regtype\()0) > +lh \regtype\()2, 4(\regtype\()0) > +lh \regtype\()3, 6(\regtype\()0) > +lh \regtype\()4, 8(\regtype\()0) > +lh \regtype\()5, 10(\regtype\()0) > +lh \regtype\()6, 12(\regtype\()0) > + > +.ifc \regtype,t > +lh
Re: [FFmpeg-devel] [PATCHv4] checkasm/lpc: test compute_autocorr
Le keskiviikkona 29. toukokuuta 2024, 22.55.13 EEST Andreas Rheinhardt a écrit : > It seems to me that the flac encoder can use odd values (namely if the > user set an odd frame_size option or if it gets fed an odd number of > samples in which case the last frame will have an odd number of samples). As noted earlier the C code seems to assume that len is even, and fixing it is outside the scope of this patch. -- Rémi Denis-Courmont http://www.remlab.net/ ___ 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] [PATCHv4] checkasm/lpc: test compute_autocorr
Rémi Denis-Courmont: > Le keskiviikkona 29. toukokuuta 2024, 22.55.13 EEST Andreas Rheinhardt a > écrit > : >> It seems to me that the flac encoder can use odd values (namely if the >> user set an odd frame_size option or if it gets fed an odd number of >> samples in which case the last frame will have an odd number of samples). > > As noted earlier the C code seems to assume that len is even, and fixing it > is > outside the scope of this patch. > I never said you should fix it, but you should not claim in your commit message that the actual code is not used with odd lengths. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCHv4] checkasm/lpc: test compute_autocorr
On 5/29/2024 4:42 PM, Rémi Denis-Courmont wrote: Also restrict length to even values, matching real uses. This test is disabled, known broken, on x86. --- tests/checkasm/lpc.c | 57 +--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index 592e34c03d..cb15e8245b 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -16,6 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "libavutil/avassert.h" #include "libavutil/mem_internal.h" #include "libavcodec/lpc.h" @@ -30,7 +31,7 @@ } \ } while (0) -#define EPS 0.005 +#define EPS 0.0001 static void test_window(int len) { @@ -57,10 +58,51 @@ static void test_window(int len) bench_new(src, len, dst1); } +#if !ARCH_X86 +static void test_compute_autocorr(ptrdiff_t len, int lag) +{ +const double eps = EPS * (double)len; +LOCAL_ALIGNED(32, double, src, [5000 + 2 + MAX_LPC_ORDER]); +LOCAL_ALIGNED(16, double, dst0, [MAX_LPC_ORDER + 1]); +LOCAL_ALIGNED(16, double, dst1, [MAX_LPC_ORDER + 1]); + +declare_func(void, const double *in, ptrdiff_t len, int lag, double *out); + +av_assert0(lag >= 0 && lag <= MAX_LPC_ORDER); + +for (int i = 0; i < MAX_LPC_ORDER; i++) +src[i] = 0.; + +src += MAX_LPC_ORDER; + +for (int i = 0; i < 5000 + 2; i++) { +src[i] = (double)rnd() / (double)UINT_MAX; +} + +call_ref(src, len, lag, dst0); +call_new(src, len, lag, dst1); + +for (size_t i = 0; i <= lag; i++) { +if (!double_near_abs_eps(dst0[i], dst1[i], eps)) { +fprintf(stderr, "%zu: %- .12f - %- .12f = % .12g\n", +i, dst0[i], dst1[i], dst0[i] - dst1[i]); +fail(); +break; +} +} + +bench_new(src, 4608, lag, dst1); +} +#endif + void checkasm_check_lpc(void) { LPCContext ctx; -int len = rnd() % 5000; +int len = 2000 + (rnd() % 1500) * 2; Instead of changing how len is generated, which will break known existing results for specific seeds in other tests, alter the value when passing it to test_compute_autocorr(), like apply_welch_window_{even,odd}() do. +#if !ARCH_X86 +static const int lags[] = { 8, 12, }; +#endif + ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { @@ -72,6 +114,15 @@ void checkasm_check_lpc(void) test_window(len | 1); } report("apply_welch_window_odd"); - ff_lpc_end(&ctx); + +#if !ARCH_X86 +for (size_t i = 0; i < FF_ARRAY_ELEMS(lags); i++) { +ff_lpc_init(&ctx, len, lags[i], FF_LPC_TYPE_DEFAULT); +if (check_func(ctx.lpc_compute_autocorr, "autocorr_%d", lags[i])) +test_compute_autocorr(len, lags[i]); +ff_lpc_end(&ctx); +} +report("compute_autocorr"); +#endif } ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/x86/vvc/vvc_alf: fix integer overflow
Hi, On Wed, May 29, 2024 at 3:44 PM Wu Jianhua wrote: > Ronald S. Bultje: > > On Wed, May 29, 2024 at 11:38 AM toq...@outlook.com>> wrote: > > +%else > > +vpunpcklqdq m11, m2, m2 > > +vpunpckhqdq m12, m2, m2 > > +vpunpcklwd m11, m11, m14 > > +vpunpcklwd m12, m12, m14 > > +paddd m0, m11 > > +paddd m1, m12 > > +packssdw m0, m0, m1 > > +%endif > > > [..] > > Also, the whole thing just emulates a saturated add. Can't you use paddsw > instead of paddw and be done with it? To add to Andreas' question: is > saturating here normatively required? > > We didn't have any sample that failed for this issue except for the > checksum with specific seeds. I think we can keep not changing it until a > real sample has something wrong. > > @Nuomi to get more details. > I think "just" replacing paddw with paddsw is correct, since the input pixels are 12bit (so they could be either unsigned or signed), the filtered output is the result of packssdw (so signed words), and the desired output is 12bit pixels anyway, anything greater than that is clipped to 12bit range. So to me, it seems paddsw is a cheaper way to accomplish the same thing. Ronald ___ 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/6] avformat/dump: print Frame Cropping side data info
Signed-off-by: James Almer --- libavformat/dump.c | 21 + 1 file changed, 21 insertions(+) diff --git a/libavformat/dump.c b/libavformat/dump.c index 059fb84522..610965cf81 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -431,6 +431,23 @@ static void dump_s12m_timecode(void *ctx, const AVStream *st, const AVPacketSide } } +static void dump_cropping(void *ctx, const AVPacketSideData *sd) +{ +uint32_t top, bottom, left, right; + +if (sd->size != sizeof(uint32_t) * 4) { +av_log(ctx, AV_LOG_ERROR, "invalid data\n"); +return; +} + +top= AV_RL32(sd->data + 0); +bottom = AV_RL32(sd->data + 4); +left = AV_RL32(sd->data + 8); +right = AV_RL32(sd->data + 12); + +av_log(ctx, AV_LOG_INFO, "%d/%d/%d/%d", left, right, top, bottom); +} + static void dump_sidedata(void *ctx, const AVStream *st, const char *indent, int log_level) { @@ -505,6 +522,10 @@ static void dump_sidedata(void *ctx, const AVStream *st, const char *indent, case AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT: dump_ambient_viewing_environment_metadata(ctx, sd); break; +case AV_PKT_DATA_FRAME_CROPPING: +av_log(ctx, AV_LOG_INFO, "Frame cropping: "); +dump_cropping(ctx, sd); +break; default: av_log(ctx, log_level, "unknown side data type %d " "(%"SIZE_SPECIFIER" bytes)", sd->type, sd->size); -- 2.45.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/6] avformat/matroskadec: export cropping values
Signed-off-by: James Almer --- libavformat/matroskadec.c | 53 +++ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 2f07e11d87..a30bac786b 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -213,7 +213,13 @@ typedef struct MatroskaTrackVideo { uint64_t display_height; uint64_t pixel_width; uint64_t pixel_height; +uint64_t cropped_width; +uint64_t cropped_height; EbmlBin color_space; +uint64_t pixel_cropt; +uint64_t pixel_cropl; +uint64_t pixel_cropb; +uint64_t pixel_cropr; uint64_t display_unit; uint64_t interlaced; uint64_t field_order; @@ -527,10 +533,10 @@ static EbmlSyntax matroska_track_video[] = { { MATROSKA_ID_VIDEOALPHAMODE, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, alpha_mode), { .u = 0 } }, { MATROSKA_ID_VIDEOCOLOR, EBML_NEST, 0, sizeof(MatroskaTrackVideoColor), offsetof(MatroskaTrackVideo, color), { .n = matroska_track_video_color } }, { MATROSKA_ID_VIDEOPROJECTION, EBML_NEST, 0, 0, offsetof(MatroskaTrackVideo, projection), { .n = matroska_track_video_projection } }, -{ MATROSKA_ID_VIDEOPIXELCROPB, EBML_NONE }, -{ MATROSKA_ID_VIDEOPIXELCROPT, EBML_NONE }, -{ MATROSKA_ID_VIDEOPIXELCROPL, EBML_NONE }, -{ MATROSKA_ID_VIDEOPIXELCROPR, EBML_NONE }, +{ MATROSKA_ID_VIDEOPIXELCROPB, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, pixel_cropb), {.u = 0 } }, +{ MATROSKA_ID_VIDEOPIXELCROPT, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, pixel_cropt), {.u = 0 } }, +{ MATROSKA_ID_VIDEOPIXELCROPL, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, pixel_cropl), {.u = 0 } }, +{ MATROSKA_ID_VIDEOPIXELCROPR, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, pixel_cropr), {.u = 0 } }, { MATROSKA_ID_VIDEODISPLAYUNIT,EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, display_unit), { .u= MATROSKA_VIDEO_DISPLAYUNIT_PIXELS } }, { MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, interlaced), { .u = MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED } }, { MATROSKA_ID_VIDEOFIELDORDER, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, field_order), { .u = MATROSKA_VIDEO_FIELDORDER_UNDETERMINED } }, @@ -2963,14 +2969,30 @@ static int mkv_parse_video(MatroskaTrack *track, AVStream *st, if (track->video.display_unit < MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN) { if (track->video.display_width && track->video.display_height && -par->height < INT64_MAX / track->video.display_width / display_width_mul && -par->width < INT64_MAX / track->video.display_height / display_height_mul) +track->video.cropped_height < INT64_MAX / track->video.display_width / display_width_mul && +track->video.cropped_width < INT64_MAX / track->video.display_height / display_height_mul) av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, - par->height * track->video.display_width * display_width_mul, - par->width * track->video.display_height * display_height_mul, + track->video.cropped_height * track->video.display_width * display_width_mul, + track->video.cropped_width * track->video.display_height * display_height_mul, INT_MAX); } +if (track->video.cropped_width != track->video.pixel_width || +track->video.cropped_height != track->video.pixel_height) { +uint8_t *cropping; +AVPacketSideData *sd = av_packet_side_data_new(&st->codecpar->coded_side_data, + &st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING, + sizeof(uint32_t) * 4, 0); +if (!sd) +return AVERROR(ENOMEM); + +cropping = sd->data; +bytestream_put_le32(&cropping, track->video.pixel_cropt); +bytestream_put_le32(&cropping, track->video.pixel_cropb); +bytestream_put_le32(&cropping, track->video.pixel_cropl); +bytestream_put_le32(&cropping, track->video.pixel_cropr); +} if (par->codec_id != AV_CODEC_ID_HEVC) sti->need_parsing = AVSTREAM_PARSE_HEADERS; @@ -3136,10 +3158,21 @@ static int matroska_parse_tracks(AVFormatContext *s) track->default_duration = default_duration; } } +track->video.cropped_width = track->video.pixel_width; +track->video.cropped_height = track->video.pixel_height; +if (track->video.display_unit == 0) { +if (track->video.pixel_cropl >= INT_MAX - track->video.pixel_cropr || +track->video.pixel_
[FFmpeg-devel] [PATCH 4/6] avformat/matroskaenc: support writing cropping values
Signed-off-by: James Almer --- libavformat/matroskaenc.c | 44 --- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 76c542d50b..37a6a5b4f8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1755,8 +1755,10 @@ static int mkv_write_track_video(AVFormatContext *s, MatroskaMuxContext *mkv, const AVDictionaryEntry *tag; int display_width_div = 1, display_height_div = 1; uint8_t color_space[4], projection_private[20]; +const AVPacketSideData *sd; EBML_WRITER(MAX_FIELD_ORDER_ELEMS + MAX_STEREO_MODE_ELEMS + MAX_VIDEO_COLOR_ELEMS + MAX_VIDEO_PROJECTION_ELEMS + 8); +int cropped_width = par->width, cropped_height = par->height; int ret; ebml_writer_open_master(&writer, MATROSKA_ID_TRACKVIDEO); @@ -1779,25 +1781,53 @@ static int mkv_write_track_video(AVFormatContext *s, MatroskaMuxContext *mkv, (tag = av_dict_get( s->metadata, "alpha_mode", NULL, 0))) && strtol(tag->value, NULL, 0)) ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEOALPHAMODE, 1); +sd = av_packet_side_data_get(st->codecpar->coded_side_data, + st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING); +if (sd && sd->size == sizeof(uint32_t) * 4) { +uint32_t top, bottom, left, right; + +top= AV_RL32(sd->data + 0); +bottom = AV_RL32(sd->data + 4); +left = AV_RL32(sd->data + 8); +right = AV_RL32(sd->data + 12); + +if (left >= INT_MAX - right || +top >= INT_MAX - bottom || +(left + right) >= par->width || +(top + bottom) >= par->height) { +av_log(s, AV_LOG_ERROR, "Invalid cropping dimensions in stream side data\n"); +return AVERROR(EINVAL); +} + +ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEOPIXELCROPB, bottom); +ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEOPIXELCROPT, top); +ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEOPIXELCROPL, left); +ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEOPIXELCROPR, right); + +cropped_width -= left + right; +cropped_height -= top + bottom; +} + // write DisplayWidth and DisplayHeight, they contain the size of // a single source view and/or the display aspect ratio if (st->sample_aspect_ratio.num) { -int64_t d_width = av_rescale(par->width, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); +int64_t d_width = av_rescale(cropped_width, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); if (d_width > INT_MAX) { av_log(s, AV_LOG_ERROR, "Overflow in display width\n"); return AVERROR(EINVAL); } -if (d_width != par->width || display_width_div != 1 || display_height_div != 1) { +if (d_width != cropped_width || display_width_div != 1 || display_height_div != 1) { if (IS_WEBM(mkv) || display_width_div != 1 || display_height_div != 1) { ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEODISPLAYWIDTH, d_width / display_width_div); ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEODISPLAYHEIGHT, - par->height / display_height_div); + cropped_height / display_height_div); } else { AVRational display_aspect_ratio; av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, -par->width * (int64_t)st->sample_aspect_ratio.num, -par->height * (int64_t)st->sample_aspect_ratio.den, +cropped_width * (int64_t)st->sample_aspect_ratio.num, +cropped_height * (int64_t)st->sample_aspect_ratio.den, 1024 * 1024); ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEODISPLAYWIDTH, display_aspect_ratio.num); @@ -1809,9 +1839,9 @@ static int mkv_write_track_video(AVFormatContext *s, MatroskaMuxContext *mkv, } } else if (display_width_div != 1 || display_height_div != 1) { ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEODISPLAYWIDTH, - par->width / display_width_div); + cropped_width / display_width_div); ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEODISPLAYHEIGHT, - par->height / display_height_div); + cropped_height / display_height_div); } else if (!IS_WEBM(mkv)) ebml_writer_add_uint(&writer, MATROSKA_ID_VIDEODISPLAYUNIT, MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN); -- 2.45.1
[FFmpeg-devel] [PATCH 1/6] avcodec/packet: add a decoded frame cropping side data type
Signed-off-by: James Almer --- libavcodec/packet.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavcodec/packet.h b/libavcodec/packet.h index a9a41576da..9dee035690 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -330,6 +330,20 @@ enum AVPacketSideDataType { */ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT, +/** + * The number of pixels to discard from the + * top/bottom/left/right border of the decoded frame to obtain the sub-rectangle + * intended for presentation. + * + * @code + * u32le crop_top + * u32le crop_bottom + * u32le crop_left + * u32le crop_right + * @endcode + */ +AV_PKT_DATA_FRAME_CROPPING, + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may -- 2.45.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/6] fftools/ffmpeg: support applying container level cropping
Signed-off-by: James Almer --- fftools/ffmpeg.h| 7 +++ fftools/ffmpeg_demux.c | 16 fftools/ffmpeg_filter.c | 11 +++ fftools/ffmpeg_opt.c| 3 +++ 4 files changed, 37 insertions(+) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fe75706afd..f908e16549 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -155,6 +155,7 @@ typedef struct OptionsContext { SpecifierOptList hwaccel_devices; SpecifierOptList hwaccel_output_formats; SpecifierOptList autorotate; +SpecifierOptList apply_cropping; /* output options */ StreamMap *stream_maps; @@ -239,6 +240,7 @@ enum IFilterFlags { IFILTER_FLAG_AUTOROTATE = (1 << 0), IFILTER_FLAG_REINIT = (1 << 1), IFILTER_FLAG_CFR= (1 << 2), +IFILTER_FLAG_CROP = (1 << 3), }; typedef struct InputFilterOptions { @@ -254,6 +256,11 @@ typedef struct InputFilterOptions { * accurate */ AVRational framerate; +unsigned crop_top; +unsigned crop_bottom; +unsigned crop_left; +unsigned crop_right; + int sub2video_width; int sub2video_height; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1ca8d804ae..4178b8f840 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -66,6 +66,7 @@ typedef struct DemuxStream { int have_sub2video; int reinit_filters; int autorotate; +int apply_cropping; int wrap_correction_done; @@ -1000,11 +1001,20 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, ist->filters[ist->nb_filters - 1] = ifilter; if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { +const AVPacketSideData *sd = av_packet_side_data_get(ist->st->codecpar->coded_side_data, + ist->st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING); if (ist->framerate.num > 0 && ist->framerate.den > 0) { opts->framerate = ist->framerate; opts->flags |= IFILTER_FLAG_CFR; } else opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL); +if (sd && sd->size == sizeof(uint32_t) * 4) { +opts->crop_top= AV_RL32(sd->data + 0); +opts->crop_bottom = AV_RL32(sd->data + 4); +opts->crop_left = AV_RL32(sd->data + 8); +opts->crop_right = AV_RL32(sd->data + 12); +} } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* Compute the size of the canvas for the subtitles stream. If the subtitles codecpar has set a size, use it. Otherwise use the @@ -1059,6 +1069,7 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, return AVERROR(ENOMEM); opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ds->autorotate) | + IFILTER_FLAG_CROP * !!(ds->apply_cropping) | IFILTER_FLAG_REINIT * !!(ds->reinit_filters); return ds->sch_idx_dec; @@ -1241,6 +1252,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->autorotate = 1; MATCH_PER_STREAM_OPT(autorotate, i, ds->autorotate, ic, st); +ds->apply_cropping = 1; +MATCH_PER_STREAM_OPT(apply_cropping, i, ds->apply_cropping, ic, st); + MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); if (codec_tag) { uint32_t tag = strtol(codec_tag, &next, 0); @@ -1362,6 +1376,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->dec_opts.flags |= DECODER_FLAG_BITEXACT * !!o->bitexact; +av_dict_set_int(&ds->decoder_opts, "apply_cropping", ds->apply_cropping, 0); + /* Attached pics are sparse, therefore we would not want to delay their decoding * till EOF. */ if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 12cca684b4..a31fa1be7f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1701,6 +1701,17 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, desc = av_pix_fmt_desc_get(ifp->format); av_assert0(desc); +if ((ifp->opts.flags & IFILTER_FLAG_CROP) && +!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { +char crop_buf[64]; +snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d", + ifp->opts.crop_left, ifp->opts.crop_right, + ifp->opts.crop_top, ifp->opts.crop_bottom); +ret = insert_filter(&last_filter, &pad_idx, "crop", crop_buf); +if (ret < 0) +return ret; +} + // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph ifp->displaymatrix_
[FFmpeg-devel] [PATCH 6/6] fftools/ffplay: support applying container level cropping
Signed-off-by: James Almer --- fftools/ffplay.c | 25 + 1 file changed, 25 insertions(+) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 1d0511b254..47e2865abb 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -32,6 +32,7 @@ #include "libavutil/avstring.h" #include "libavutil/channel_layout.h" +#include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" @@ -346,6 +347,7 @@ static const char **vfilters_list = NULL; static int nb_vfilters = 0; static char *afilters = NULL; static int autorotate = 1; +static int apply_cropping = 1; static int find_stream_info = 1; static int filter_nbthreads = 0; static int enable_vulkan = 0; @@ -1947,6 +1949,28 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c last_filter = filt_ctx; \ } while (0) +if (apply_cropping) { +const AVPacketSideData *sd = av_packet_side_data_get(is->video_st->codecpar->coded_side_data, + is->video_st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING); + +if (sd && sd->size == sizeof(uint32_t) * 4) { +char crop_buf[64]; +int top= AV_RL32(sd->data + 0); +int bottom = AV_RL32(sd->data + 4); +int left = AV_RL32(sd->data + 8); +int right = AV_RL32(sd->data + 12); + +if (top < 0 || bottom < 0 || left < 0 || right < 0) { +ret = AVERROR(EINVAL); +goto fail; +} + +snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d", left, right, top, bottom); +INSERT_FILT("crop", crop_buf); +} +} + if (autorotate) { double theta = 0.0; int32_t *displaymatrix = NULL; @@ -3691,6 +3715,7 @@ static const OptionDef options[] = { { "scodec", OPT_TYPE_STRING, OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" }, { "vcodec", OPT_TYPE_STRING, OPT_EXPERT, { &video_codec_name }, "force video decoder","decoder_name" }, { "autorotate", OPT_TYPE_BOOL,0, { &autorotate }, "automatically rotate video", "" }, +{ "apply_cropping", OPT_TYPE_BOOL,0, { &apply_cropping }, "apply container level frame cropping", "" }, { "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT, { &find_stream_info }, "read and decode the streams to fill missing information with heuristics" }, { "filter_threads", OPT_TYPE_INT,OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" }, -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/5] lavu/common.h: Fix UB in av_clipl_int32_c()
The entire patchset passes FATE /Tomas From c000b8a5e90883f28ce6c58960227e5825ac20d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Wed, 15 May 2024 21:03:47 +0200 Subject: [PATCH 1/5] lavu/common.h: Fix UB in av_clipl_int32_c() Found by value analysis --- libavutil/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/common.h b/libavutil/common.h index 3e4c339893..ac68c0cfff 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -252,8 +252,8 @@ static av_always_inline av_const int16_t av_clip_int16_c(int a) */ static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a) { -if ((a+0x8000u) & ~UINT64_C(0x)) return (int32_t)((a>>63) ^ 0x7FFF); -else return (int32_t)a; +if ((a+UINT64_C(0x8000)) & ~UINT64_C(0x)) return (int32_t)((a>>63) ^ 0x7FFF); +else return (int32_t)a; } /** -- 2.39.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 2/5] lavu/common.h: Fix UB in av_clip_intp2_c()
From 7b18f24c0bedfeebcdfb23ea837cea8d4c35cf30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 16 May 2024 16:33:44 +0200 Subject: [PATCH 2/5] lavu/common.h: Fix UB in av_clip_intp2_c() Found by value analysis --- libavutil/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/common.h b/libavutil/common.h index ac68c0cfff..715f0a594c 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -264,7 +264,7 @@ static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a) */ static av_always_inline av_const int av_clip_intp2_c(int a, int p) { -if (((unsigned)a + (1 << p)) & ~((2 << p) - 1)) +if (((unsigned)a + (1U << p)) & ~((2U << p) - 1)) return (a >> 31) ^ ((1 << p) - 1); else return a; -- 2.39.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 3/5] lavu/common.h: Fix UB in av_clip_uintp2_c()
From f81730f8facc54ef23df79ac8d33075403b4f76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 16 May 2024 16:37:58 +0200 Subject: [PATCH 3/5] lavu/common.h: Fix UB in av_clip_uintp2_c() Found by value analysis --- libavutil/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/common.h b/libavutil/common.h index 715f0a594c..8a3c4d2fcf 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -278,8 +278,8 @@ static av_always_inline av_const int av_clip_intp2_c(int a, int p) */ static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p) { -if (a & ~((1<> 31 & ((1<> 31 & ((1U<___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/5] lavu/intmath.h: Fix UB in ff_ctz_c() and ff_ctzll_c()
From f9a12089bc98dde0ccc2487d1442ec6ddb7705f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 16 May 2024 18:10:58 +0200 Subject: [PATCH 4/5] lavu/intmath.h: Fix UB in ff_ctz_c() and ff_ctzll_c() Found by value analysis --- libavutil/intmath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/intmath.h b/libavutil/intmath.h index c54d23b7bf..52e11a8d5f 100644 --- a/libavutil/intmath.h +++ b/libavutil/intmath.h @@ -119,7 +119,7 @@ static av_always_inline av_const int ff_ctz_c(int v) 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; -return debruijn_ctz32[(uint32_t)((v & -v) * 0x077CB531U) >> 27]; +return debruijn_ctz32[(uint32_t)((v & -(uint32_t)v) * 0x077CB531U) >> 27]; } #endif @@ -135,7 +135,7 @@ static av_always_inline av_const int ff_ctzll_c(long long v) 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10, 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12 }; -return debruijn_ctz64[(uint64_t)((v & -v) * 0x022FDD63CC95386DU) >> 58]; +return debruijn_ctz64[(uint64_t)((v & -(uint64_t)v) * 0x022FDD63CC95386DU) >> 58]; } #endif -- 2.39.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 5/5] lavu/mathematics: Return early if either a or b is zero
This doesn't really fix anything, it just makes the value analysis easier. I don't feel strongly about it. /Tomas From cf9c56d7d4d7325d51ba6d99259431be7fca1f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Mon, 20 May 2024 14:46:01 +0200 Subject: [PATCH 5/5] lavu/mathematics: Return early if either a or b is zero This removes the need to check b further down --- libavutil/mathematics.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c index 61aeb7c029..06f6e61e78 100644 --- a/libavutil/mathematics.c +++ b/libavutil/mathematics.c @@ -71,6 +71,9 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) rnd -= AV_ROUND_PASS_MINMAX; } +if (a == 0 || b == 0) +return 0; + if (a < 0) return -(uint64_t)av_rescale_rnd(-FFMAX(a, -INT64_MAX), b, c, rnd ^ ((rnd >> 1) & 1)); @@ -85,7 +88,7 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) else { int64_t ad = a / c; int64_t a2 = (a % c * b + r) / c; -if (ad >= INT32_MAX && b && ad > (INT64_MAX - a2) / b) +if (ad >= INT32_MAX && ad > (INT64_MAX - a2) / b) return INT64_MIN; return ad * b + a2; } -- 2.39.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 2/5] lavu/common.h: Fix UB in av_clip_intp2_c()
Tomas Härdin: > static av_always_inline av_const int av_clip_intp2_c(int a, int p) > { > -if (((unsigned)a + (1 << p)) & ~((2 << p) - 1)) > +if (((unsigned)a + (1U << p)) & ~((2U << p) - 1)) > return (a >> 31) ^ ((1 << p) - 1); > else > return a; This will support p == 30 (but not 31); but the first change is not UB in this range. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/5] lavu/common.h: Fix UB in av_clipl_int32_c()
Tomas Härdin: > */ > static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a) > { > -if ((a+0x8000u) & ~UINT64_C(0x)) return (int32_t)((a>>63) ^ > 0x7FFF); > -else return (int32_t)a; > +if ((a+UINT64_C(0x8000)) & ~UINT64_C(0x)) return > (int32_t)((a>>63) ^ 0x7FFF); > +else return (int32_t)a; IMO (uint64_t)a + 0x8000 is more readable. (Maybe it would even be good to use >> 32 instead of ~UINT64_C(0x)?) - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/5] lavu/common.h: Fix UB in av_clip_intp2_c()
tor 2024-05-30 klockan 00:24 +0200 skrev Andreas Rheinhardt: > Tomas Härdin: > > static av_always_inline av_const int av_clip_intp2_c(int a, int p) > > { > > - if (((unsigned)a + (1 << p)) & ~((2 << p) - 1)) > > + if (((unsigned)a + (1U << p)) & ~((2U << p) - 1)) > > return (a >> 31) ^ ((1 << p) - 1); > > else > > return a; > > This will support p == 30 (but not 31); but the first change is not > UB > in this range. p=31 is most definitely UB before this change. 1<<31 is signed overflow with 32-bit int. The compiler has therefore been allowed to do whatever for p=31 up until this point. To me it seems the intent of the code is preserved Personally I dislike bithacks because they are difficult to verify. A good enough compiler will gain peephole optimizations for them sooner or later anyway /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] git problems
Hi all It seems the security update (https://ubuntu.com/security/notices/USN-6793-1) broke public git We use gitolite that runs under its own user and serve git through apache which runs under a different user. Apache has only read access to the repositories Since the security update that stoped working, the logs are full of messages telling that we need to add the repositories to safe.directory (the commands suggested dont work and seem to mix up \t with a tab but thats besides the point) once the repository is added to safe.directory, which ive done with https://git.ffmpeg.org/michael.git the error is gone and everything looks fine in the logs on the server but it still doesnt work. (i have not touched ffmpeg.git config as i first wanted to test this) So like i just said on IRC. i hope some of the other root admins will have some more insight here. Or if you (yes YOU!) want to help or know something please speak up. This is totally not my area and i think other people could find the issue with less effort in less time and it would be more efficient if i work on FFmpeg instead where the return per hour of my time should be much greater. Also gitweb and git over ssh seem uneffected and theres github If people want i could downgrade git OR upgrade git to latest git ignoring official ubuntu packages otherwise, i intend to leave this for someone else to investigate and rather work on FFmpeg which just seems like a much better use of my time thx -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus 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".
[FFmpeg-devel] [PATCH] avcodec/packet: remove reference to old AV_SIDE_DATA_PARAM_CHANGE_ values
They were forgotten in 65ddc74988245a01421a63c5cffa4d900c47117c. Signed-off-by: James Almer --- libavcodec/packet.h | 4 1 file changed, 4 deletions(-) diff --git a/libavcodec/packet.h b/libavcodec/packet.h index a9a41576da..f05deb7950 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -59,10 +59,6 @@ enum AVPacketSideDataType { * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: * @code * u32le param_flags - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) - * s32le channel_count - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) - * u64le channel_layout * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) * s32le sample_rate * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/nutdec: Don't create inconsistent side data
Forgotten in 65ddc74988245a01421a63c5cffa4d900c47117c. Signed-off-by: Andreas Rheinhardt --- libavformat/nutdec.c | 4 1 file changed, 4 deletions(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 0bb7f154db..94b49d3eba 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -973,10 +973,6 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height)) ); -if (channels) -bytestream_put_le32(&dst, channels); -if (channel_layout) -bytestream_put_le64(&dst, channel_layout); if (sample_rate) bytestream_put_le32(&dst, sample_rate); if (width || height){ -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avformat/nutdec: Don't create inconsistent side data
Forgotten in 65ddc74988245a01421a63c5cffa4d900c47117c. Signed-off-by: Andreas Rheinhardt --- libavformat/nutdec.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 0bb7f154db..a962576f06 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -966,17 +966,13 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int } if (channels || channel_layout || sample_rate || width || height) { -uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 28); +uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 16); if (!dst) return AVERROR(ENOMEM); bytestream_put_le32(&dst, AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height)) ); -if (channels) -bytestream_put_le32(&dst, channels); -if (channel_layout) -bytestream_put_le64(&dst, channel_layout); if (sample_rate) bytestream_put_le32(&dst, sample_rate); if (width || height){ -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] avformat/nutdec: Don't create inconsistent side data
Forgotten in 65ddc74988245a01421a63c5cffa4d900c47117c. Signed-off-by: Andreas Rheinhardt --- libavformat/nutdec.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 0bb7f154db..34b7e3cb9a 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -881,8 +881,6 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int int count = ffio_read_varlen(bc); int skip_start = 0; int skip_end = 0; -int channels = 0; -int64_t channel_layout = 0; int sample_rate = 0; int width = 0; int height = 0; @@ -930,7 +928,7 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int AV_WB64(dst, v64); dst += 8; } else if (!strcmp(name, "ChannelLayout") && value_len == 8) { -channel_layout = avio_rl64(bc); +// Ignored continue; } else { av_log(s, AV_LOG_WARNING, "Unknown data %s / %s\n", name, type_str); @@ -952,7 +950,7 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int } else if (!strcmp(name, "SkipEnd")) { skip_end = value; } else if (!strcmp(name, "Channels")) { -channels = value; +// Ignored } else if (!strcmp(name, "SampleRate")) { sample_rate = value; } else if (!strcmp(name, "Width")) { @@ -965,18 +963,14 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int } } -if (channels || channel_layout || sample_rate || width || height) { -uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 28); +if (sample_rate || width || height) { +uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 16); if (!dst) return AVERROR(ENOMEM); bytestream_put_le32(&dst, AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height)) ); -if (channels) -bytestream_put_le32(&dst, channels); -if (channel_layout) -bytestream_put_le64(&dst, channel_layout); if (sample_rate) bytestream_put_le32(&dst, sample_rate); if (width || height){ -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3] avformat/nutdec: Don't create inconsistent side data
On 5/29/2024 9:14 PM, Andreas Rheinhardt wrote: Forgotten in 65ddc74988245a01421a63c5cffa4d900c47117c. Signed-off-by: Andreas Rheinhardt --- libavformat/nutdec.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 0bb7f154db..34b7e3cb9a 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -881,8 +881,6 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int int count = ffio_read_varlen(bc); int skip_start = 0; int skip_end = 0; -int channels = 0; -int64_t channel_layout = 0; int sample_rate = 0; int width = 0; int height = 0; @@ -930,7 +928,7 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int AV_WB64(dst, v64); dst += 8; } else if (!strcmp(name, "ChannelLayout") && value_len == 8) { -channel_layout = avio_rl64(bc); +// Ignored continue; } else { av_log(s, AV_LOG_WARNING, "Unknown data %s / %s\n", name, type_str); @@ -952,7 +950,7 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int } else if (!strcmp(name, "SkipEnd")) { skip_end = value; } else if (!strcmp(name, "Channels")) { -channels = value; +// Ignored } else if (!strcmp(name, "SampleRate")) { sample_rate = value; } else if (!strcmp(name, "Width")) { @@ -965,18 +963,14 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int } } -if (channels || channel_layout || sample_rate || width || height) { -uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 28); +if (sample_rate || width || height) { +uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 16); if (!dst) return AVERROR(ENOMEM); bytestream_put_le32(&dst, AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height)) ); -if (channels) -bytestream_put_le32(&dst, channels); -if (channel_layout) -bytestream_put_le64(&dst, channel_layout); if (sample_rate) bytestream_put_le32(&dst, sample_rate); if (width || height){ LGTM. Should be backported 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".
Re: [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: support applying container level cropping
On 29/05/2024 23:46, James Almer wrote: Signed-off-by: James Almer --- fftools/ffmpeg.h| 7 +++ fftools/ffmpeg_demux.c | 16 fftools/ffmpeg_filter.c | 11 +++ fftools/ffmpeg_opt.c| 3 +++ 4 files changed, 37 insertions(+) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fe75706afd..f908e16549 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -155,6 +155,7 @@ typedef struct OptionsContext { SpecifierOptList hwaccel_devices; SpecifierOptList hwaccel_output_formats; SpecifierOptList autorotate; +SpecifierOptList apply_cropping; /* output options */ StreamMap *stream_maps; @@ -239,6 +240,7 @@ enum IFilterFlags { IFILTER_FLAG_AUTOROTATE = (1 << 0), IFILTER_FLAG_REINIT = (1 << 1), IFILTER_FLAG_CFR= (1 << 2), +IFILTER_FLAG_CROP = (1 << 3), }; typedef struct InputFilterOptions { @@ -254,6 +256,11 @@ typedef struct InputFilterOptions { * accurate */ AVRational framerate; +unsigned crop_top; +unsigned crop_bottom; +unsigned crop_left; +unsigned crop_right; + int sub2video_width; int sub2video_height; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1ca8d804ae..4178b8f840 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -66,6 +66,7 @@ typedef struct DemuxStream { int have_sub2video; int reinit_filters; int autorotate; +int apply_cropping; int wrap_correction_done; @@ -1000,11 +1001,20 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, ist->filters[ist->nb_filters - 1] = ifilter; if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { +const AVPacketSideData *sd = av_packet_side_data_get(ist->st->codecpar->coded_side_data, + ist->st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING); if (ist->framerate.num > 0 && ist->framerate.den > 0) { opts->framerate = ist->framerate; opts->flags |= IFILTER_FLAG_CFR; } else opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL); +if (sd && sd->size == sizeof(uint32_t) * 4) { +opts->crop_top= AV_RL32(sd->data + 0); +opts->crop_bottom = AV_RL32(sd->data + 4); +opts->crop_left = AV_RL32(sd->data + 8); +opts->crop_right = AV_RL32(sd->data + 12); +} } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* Compute the size of the canvas for the subtitles stream. If the subtitles codecpar has set a size, use it. Otherwise use the @@ -1059,6 +1069,7 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, return AVERROR(ENOMEM); opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ds->autorotate) | + IFILTER_FLAG_CROP * !!(ds->apply_cropping) | IFILTER_FLAG_REINIT * !!(ds->reinit_filters); return ds->sch_idx_dec; @@ -1241,6 +1252,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->autorotate = 1; MATCH_PER_STREAM_OPT(autorotate, i, ds->autorotate, ic, st); +ds->apply_cropping = 1; +MATCH_PER_STREAM_OPT(apply_cropping, i, ds->apply_cropping, ic, st); + MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); if (codec_tag) { uint32_t tag = strtol(codec_tag, &next, 0); @@ -1362,6 +1376,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->dec_opts.flags |= DECODER_FLAG_BITEXACT * !!o->bitexact; +av_dict_set_int(&ds->decoder_opts, "apply_cropping", ds->apply_cropping, 0); + /* Attached pics are sparse, therefore we would not want to delay their decoding * till EOF. */ if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 12cca684b4..a31fa1be7f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1701,6 +1701,17 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, desc = av_pix_fmt_desc_get(ifp->format); av_assert0(desc); +if ((ifp->opts.flags & IFILTER_FLAG_CROP) && +!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { +char crop_buf[64]; +snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d", + ifp->opts.crop_left, ifp->opts.crop_right, + ifp->opts.crop_top, ifp->opts.crop_bottom); +ret = insert_filter(&last_filter, &pad_idx, "crop", crop_buf); +if (ret < 0) +return ret; +
Re: [FFmpeg-devel] [PATCH 1/6] avcodec/packet: add a decoded frame cropping side data type
On 29/05/2024 23:46, James Almer wrote: Signed-off-by: James Almer --- libavcodec/packet.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavcodec/packet.h b/libavcodec/packet.h index a9a41576da..9dee035690 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -330,6 +330,20 @@ enum AVPacketSideDataType { */ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT, +/** + * The number of pixels to discard from the + * top/bottom/left/right border of the decoded frame to obtain the sub-rectangle + * intended for presentation. + * + * @code + * u32le crop_top + * u32le crop_bottom + * u32le crop_left + * u32le crop_right + * @endcode + */ +AV_PKT_DATA_FRAME_CROPPING, + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may Shouldn't this be propagated to the frame's crop fields, and back from the crop fields to the packet side-data? 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 5/6] fftools/ffmpeg: support applying container level cropping
On 5/29/2024 10:01 PM, Lynne via ffmpeg-devel wrote: On 29/05/2024 23:46, James Almer wrote: Signed-off-by: James Almer --- fftools/ffmpeg.h | 7 +++ fftools/ffmpeg_demux.c | 16 fftools/ffmpeg_filter.c | 11 +++ fftools/ffmpeg_opt.c | 3 +++ 4 files changed, 37 insertions(+) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fe75706afd..f908e16549 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -155,6 +155,7 @@ typedef struct OptionsContext { SpecifierOptList hwaccel_devices; SpecifierOptList hwaccel_output_formats; SpecifierOptList autorotate; + SpecifierOptList apply_cropping; /* output options */ StreamMap *stream_maps; @@ -239,6 +240,7 @@ enum IFilterFlags { IFILTER_FLAG_AUTOROTATE = (1 << 0), IFILTER_FLAG_REINIT = (1 << 1), IFILTER_FLAG_CFR = (1 << 2), + IFILTER_FLAG_CROP = (1 << 3), }; typedef struct InputFilterOptions { @@ -254,6 +256,11 @@ typedef struct InputFilterOptions { * accurate */ AVRational framerate; + unsigned crop_top; + unsigned crop_bottom; + unsigned crop_left; + unsigned crop_right; + int sub2video_width; int sub2video_height; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1ca8d804ae..4178b8f840 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -66,6 +66,7 @@ typedef struct DemuxStream { int have_sub2video; int reinit_filters; int autorotate; + int apply_cropping; int wrap_correction_done; @@ -1000,11 +1001,20 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, ist->filters[ist->nb_filters - 1] = ifilter; if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { + const AVPacketSideData *sd = av_packet_side_data_get(ist->st->codecpar->coded_side_data, + ist->st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING); if (ist->framerate.num > 0 && ist->framerate.den > 0) { opts->framerate = ist->framerate; opts->flags |= IFILTER_FLAG_CFR; } else opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL); + if (sd && sd->size == sizeof(uint32_t) * 4) { + opts->crop_top = AV_RL32(sd->data + 0); + opts->crop_bottom = AV_RL32(sd->data + 4); + opts->crop_left = AV_RL32(sd->data + 8); + opts->crop_right = AV_RL32(sd->data + 12); + } } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* Compute the size of the canvas for the subtitles stream. If the subtitles codecpar has set a size, use it. Otherwise use the @@ -1059,6 +1069,7 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, return AVERROR(ENOMEM); opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ds->autorotate) | + IFILTER_FLAG_CROP * !!(ds->apply_cropping) | IFILTER_FLAG_REINIT * !!(ds->reinit_filters); return ds->sch_idx_dec; @@ -1241,6 +1252,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->autorotate = 1; MATCH_PER_STREAM_OPT(autorotate, i, ds->autorotate, ic, st); + ds->apply_cropping = 1; + MATCH_PER_STREAM_OPT(apply_cropping, i, ds->apply_cropping, ic, st); + MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); if (codec_tag) { uint32_t tag = strtol(codec_tag, &next, 0); @@ -1362,6 +1376,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->dec_opts.flags |= DECODER_FLAG_BITEXACT * !!o->bitexact; + av_dict_set_int(&ds->decoder_opts, "apply_cropping", ds->apply_cropping, 0); + /* Attached pics are sparse, therefore we would not want to delay their decoding * till EOF. */ if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 12cca684b4..a31fa1be7f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1701,6 +1701,17 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, desc = av_pix_fmt_desc_get(ifp->format); av_assert0(desc); + if ((ifp->opts.flags & IFILTER_FLAG_CROP) && + !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { + char crop_buf[64]; + snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d", + ifp->opts.crop_left, ifp->opts.crop_right, + ifp->opts.crop_top, ifp->opts.crop_bottom); + ret = insert_filter(&last_filter, &pad_idx, "crop", crop_buf); + if (ret < 0) +
Re: [FFmpeg-devel] git problems
On Thu, May 30, 2024 at 01:30:09AM +0200, Michael Niedermayer wrote: > Hi all > > It seems the security update (https://ubuntu.com/security/notices/USN-6793-1) > broke public git > > We use gitolite that runs under its own user and serve git through apache > which runs under a different user. > Apache has only read access to the repositories > > Since the security update that stoped working, the logs are full of messages > telling that we need to add the repositories to safe.directory > (the commands suggested dont work and seem to mix up \t with a tab but thats > besides the point) > once the repository is added to safe.directory, which ive done with > https://git.ffmpeg.org/michael.git > the error is gone and everything looks fine in the logs on the server but it > still > doesnt work. (i have not touched ffmpeg.git config as i first wanted to test > this) > > So like i just said on IRC. i hope some of the other root admins will have > some more insight here. Or if you (yes YOU!) want to help or know something > please speak up. > > This is totally not my area and i think other people could find the issue > with less effort in less time and it would be more efficient if i work > on FFmpeg instead where the return per hour of my time should be much greater. > > Also gitweb and git over ssh seem uneffected and theres github > > If people want i could downgrade git OR > upgrade git to latest git ignoring official ubuntu packages > otherwise, i intend to leave this for someone else to investigate and rather > work on FFmpeg which just seems like a much better use of my time after talking with raz and BtbN ive downgraded git to the prevous one raz will look at it tomorrow thx to raz and timo [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The misfortune of the wise is better than the prosperity of the fool. -- Epicurus signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/6] avcodec/packet: add a decoded frame cropping side data type
On 5/29/2024 10:02 PM, Lynne via ffmpeg-devel wrote: On 29/05/2024 23:46, James Almer wrote: Signed-off-by: James Almer --- libavcodec/packet.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavcodec/packet.h b/libavcodec/packet.h index a9a41576da..9dee035690 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -330,6 +330,20 @@ enum AVPacketSideDataType { */ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT, + /** + * The number of pixels to discard from the + * top/bottom/left/right border of the decoded frame to obtain the sub-rectangle + * intended for presentation. + * + * @code + * u32le crop_top + * u32le crop_bottom + * u32le crop_left + * u32le crop_right + * @endcode + */ + AV_PKT_DATA_FRAME_CROPPING, + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may Shouldn't this be propagated to the frame's crop fields, and back from the crop fields to the packet side-data? We no longer use frames and packets to communicate global side data, and we can't use frame cropping values as global metadata for the container's header because there's codec level cropping too (like h264 to remove padding coded at certain dimensions) in them. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 1/3] avutil/hwcontext_videotoolbox: Unset undefined values
When mapping AVFrame properties to the CVBuffer attachments, it is necessary to properly delete undefined attachments, else we can leave incorrect values in there guessed from VideoToolbox for example, leading to inconsistent results where the AVFrame and CVBuffer differ in metadata. Ref #10884 --- libavutil/hwcontext_videotoolbox.c | 76 -- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c index 9f82b104c3..0af2ab822f 100644 --- a/libavutil/hwcontext_videotoolbox.c +++ b/libavutil/hwcontext_videotoolbox.c @@ -342,8 +342,10 @@ static int vt_pixbuf_set_par(void *log_ctx, CFNumberRef num = NULL, den = NULL; AVRational avpar = src->sample_aspect_ratio; -if (avpar.num == 0) +if (avpar.num == 0) { +CVBufferRemoveAttachment(pixbuf, kCVImageBufferPixelAspectRatioKey); return 0; +} av_reduce(&avpar.num, &avpar.den, avpar.num, avpar.den, @@ -423,7 +425,10 @@ static int vt_pixbuf_set_chromaloc(void *log_ctx, kCVImageBufferChromaLocationTopFieldKey, loc, kCVAttachmentMode_ShouldPropagate); -} +} else +CVBufferRemoveAttachment( +pixbuf, +kCVImageBufferChromaLocationTopFieldKey); return 0; } @@ -534,52 +539,53 @@ static int vt_pixbuf_set_colorspace(void *log_ctx, Float32 gamma = 0; colormatrix = av_map_videotoolbox_color_matrix_from_av(src->colorspace); -if (!colormatrix && src->colorspace != AVCOL_SPC_UNSPECIFIED) -av_log(log_ctx, AV_LOG_WARNING, "Color space %s is not supported.\n", av_color_space_name(src->colorspace)); +if (colormatrix) +CVBufferSetAttachment(pixbuf, kCVImageBufferYCbCrMatrixKey, +colormatrix, kCVAttachmentMode_ShouldPropagate); +else { +CVBufferRemoveAttachment(pixbuf, kCVImageBufferYCbCrMatrixKey); +if (src->colorspace != AVCOL_SPC_UNSPECIFIED) +av_log(log_ctx, AV_LOG_WARNING, +"Color space %s is not supported.\n", +av_color_space_name(src->colorspace)); +} colorpri = av_map_videotoolbox_color_primaries_from_av(src->color_primaries); -if (!colorpri && src->color_primaries != AVCOL_PRI_UNSPECIFIED) -av_log(log_ctx, AV_LOG_WARNING, "Color primaries %s is not supported.\n", av_color_primaries_name(src->color_primaries)); +if (colorpri) +CVBufferSetAttachment(pixbuf, kCVImageBufferColorPrimariesKey, +colorpri, kCVAttachmentMode_ShouldPropagate); +else { +CVBufferRemoveAttachment(pixbuf, kCVImageBufferColorPrimariesKey); +if (src->color_primaries != AVCOL_SPC_UNSPECIFIED) +av_log(log_ctx, AV_LOG_WARNING, +"Color primaries %s is not supported.\n", +av_color_primaries_name(src->color_primaries)); +} colortrc = av_map_videotoolbox_color_trc_from_av(src->color_trc); -if (!colortrc && src->color_trc != AVCOL_TRC_UNSPECIFIED) -av_log(log_ctx, AV_LOG_WARNING, "Color transfer function %s is not supported.\n", av_color_transfer_name(src->color_trc)); +if (colortrc) +CVBufferSetAttachment(pixbuf, kCVImageBufferTransferFunctionKey, +colorpri, kCVAttachmentMode_ShouldPropagate); +else { +CVBufferRemoveAttachment(pixbuf, kCVImageBufferTransferFunctionKey); +if (src->color_trc != AVCOL_TRC_UNSPECIFIED) +av_log(log_ctx, AV_LOG_WARNING, +"Color transfer function %s is not supported.\n", +av_color_transfer_name(src->color_trc)); +} if (src->color_trc == AVCOL_TRC_GAMMA22) gamma = 2.2; else if (src->color_trc == AVCOL_TRC_GAMMA28) gamma = 2.8; -if (colormatrix) { -CVBufferSetAttachment( -pixbuf, -kCVImageBufferYCbCrMatrixKey, -colormatrix, -kCVAttachmentMode_ShouldPropagate); -} -if (colorpri) { -CVBufferSetAttachment( -pixbuf, -kCVImageBufferColorPrimariesKey, -colorpri, -kCVAttachmentMode_ShouldPropagate); -} -if (colortrc) { -CVBufferSetAttachment( -pixbuf, -kCVImageBufferTransferFunctionKey, -colortrc, -kCVAttachmentMode_ShouldPropagate); -} if (gamma != 0) { CFNumberRef gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma); -CVBufferSetAttachment( -pixbuf, -kCVImageBufferGammaLevelKey, -gamma_level, -kCVAttachmentMode_ShouldPropagate); +CVBufferSetAttachment(pixbuf, kCVImageBufferGammaLevelKey, +gamma_level, kCVAttachmentMode_ShouldPropagate); CFRelease(gamma_level); -} +} else +CVBufferRemoveAttachment(pixbuf, kCVImageBufferGammaLevelKey); return 0; } base-comm
[FFmpeg-devel] [PATCH v3 2/3] avutil/hwcontext_videotoolbox: Update documentation
The documentation was not clear at all what specifically the function does, so it was left unspecified if it will unset or not touch attachments it could not map from the AVFrame. The documentation of the return value was wrong as well. --- libavutil/hwcontext_videotoolbox.h | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_videotoolbox.h b/libavutil/hwcontext_videotoolbox.h index 600e9f2c8d..d35cfbb6c1 100644 --- a/libavutil/hwcontext_videotoolbox.h +++ b/libavutil/hwcontext_videotoolbox.h @@ -90,8 +90,15 @@ CFStringRef av_map_videotoolbox_color_primaries_from_av(enum AVColorPrimaries pr CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteristic trc); /** - * Update a CVPixelBufferRef's metadata to based on an AVFrame. - * Returns 0 if no known equivalent was found. + * Set CVPixelBufferRef's metadata based on an AVFrame. + * + * Sets/unsets the CVPixelBuffer attachments to match as closely as possible the + * AVFrame metadata. To prevent inconsistent attachments, the attachments for properties + * that could not be matched or are unspecified in the given AVFrame are unset. So if + * any attachments already covered by AVFrame metadata need to be set to a specific + * value, this should happen after calling this function. + * + * Returns < 0 in case of an error. */ int av_vt_pixbuf_set_attachments(void *log_ctx, CVPixelBufferRef pixbuf, const struct AVFrame *src); -- 2.39.3 (Apple Git-146) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 3/3] avutil/hwcontext_videotoolbox: Set CVBuffer CGColorSpace
In addition to the other properties, try to obtain the right CGColorSpace and set it as well, else it could lead to a CVBuffer tagged as BT.2020 but with a CGColorSpace indicating BT.709. Therefore it is essential for consistency to set a colorspace according to the other values, or if none can be obtained (for example because the other values are all unspecified) unset it as well. Fix #10884 --- libavutil/hwcontext_videotoolbox.c | 16 1 file changed, 16 insertions(+) diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c index 0af2ab822f..953155ce32 100644 --- a/libavutil/hwcontext_videotoolbox.c +++ b/libavutil/hwcontext_videotoolbox.c @@ -535,6 +535,7 @@ CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteri static int vt_pixbuf_set_colorspace(void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src) { +CGColorSpaceRef colorspace = NULL; CFStringRef colormatrix = NULL, colorpri = NULL, colortrc = NULL; Float32 gamma = 0; @@ -587,6 +588,21 @@ static int vt_pixbuf_set_colorspace(void *log_ctx, } else CVBufferRemoveAttachment(pixbuf, kCVImageBufferGammaLevelKey); +if (__builtin_available(macOS 10.8, iOS 10, *)) { +CFDictionaryRef attachments = CVBufferCopyAttachments(pixbuf, kCVAttachmentMode_ShouldPropagate); +if (attachments) { +colorspace = CVImageBufferCreateColorSpaceFromAttachments(attachments); +CFRelease(attachments); +} +} + +if (colorspace) { +CVBufferSetAttachment(pixbuf, kCVImageBufferCGColorSpaceKey, +colorspace, kCVAttachmentMode_ShouldPropagate); +CFRelease(colorspace); +} else +CVBufferRemoveAttachment(pixbuf, kCVImageBufferCGColorSpaceKey); + return 0; } -- 2.39.3 (Apple Git-146) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 00/10] aacdec: add a native xHE-AAC decoder
This commit adds a decoder for the frequency-domain part of USAC. Changes over version 4: - Actually reset entropy decoding upon configuration. - Support for LFE channels. Lynne (10): channel_layout: add new channel positions supported by xHE-AAC aacdec: move from scalefactor ranged arrays to flat arrays aacdec: expose channel layout related functions aacdec: expose decode_tns aacdec_dsp: implement 768-point transform and windowing aactab: add deemphasis tables for USAC aactab: add tables for the new USAC arithmetic coder aactab: add new scalefactor offset tables for 96/768pt windows aacdec: add a decoder for AAC USAC (xHE-AAC) fate: add tests for xHE-AAC libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 371 +++--- libavcodec/aac/aacdec.h | 219 +++- libavcodec/aac/aacdec_ac.c | 208 libavcodec/aac/aacdec_ac.h | 54 + libavcodec/aac/aacdec_dsp_template.c | 162 ++- libavcodec/aac/aacdec_fixed.c|2 + libavcodec/aac/aacdec_float.c|4 + libavcodec/aac/aacdec_latm.h | 14 +- libavcodec/aac/aacdec_lpd.c | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1608 ++ libavcodec/aac/aacdec_usac.h | 37 + libavcodec/aactab.c | 560 + libavcodec/aactab.h | 22 + libavcodec/sinewin_fixed_tablegen.c |2 + libavcodec/sinewin_fixed_tablegen.h |4 + libavutil/channel_layout.c |4 + libavutil/channel_layout.h |8 + tests/fate/aac.mak |8 + 20 files changed, 3286 insertions(+), 235 deletions(-) create mode 100644 libavcodec/aac/aacdec_ac.c create mode 100644 libavcodec/aac/aacdec_ac.h create mode 100644 libavcodec/aac/aacdec_lpd.c create mode 100644 libavcodec/aac/aacdec_lpd.h create mode 100644 libavcodec/aac/aacdec_usac.c create mode 100644 libavcodec/aac/aacdec_usac.h -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 01/10] channel_layout: add new channel positions supported by xHE-AAC
apichanges will be updated upon merging, as well as a version bump. --- libavutil/channel_layout.c | 4 libavutil/channel_layout.h | 8 2 files changed, 12 insertions(+) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 98839b7250..2d6963b6df 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -75,6 +75,10 @@ static const struct channel_name channel_names[] = { [AV_CHAN_BOTTOM_FRONT_CENTER ] = { "BFC", "bottom front center" }, [AV_CHAN_BOTTOM_FRONT_LEFT] = { "BFL", "bottom front left" }, [AV_CHAN_BOTTOM_FRONT_RIGHT ] = { "BFR", "bottom front right"}, +[AV_CHAN_SIDE_SURROUND_LEFT ] = { "SSL", "side surround left"}, +[AV_CHAN_SIDE_SURROUND_RIGHT ] = { "SSR", "side surround right" }, +[AV_CHAN_TOP_SURROUND_LEFT] = { "TTL", "top surround left" }, +[AV_CHAN_TOP_SURROUND_RIGHT ] = { "TTR", "top surround right"}, }; void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index b26b601065..3a96c2d9b8 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -79,6 +79,10 @@ enum AVChannel { AV_CHAN_BOTTOM_FRONT_CENTER, AV_CHAN_BOTTOM_FRONT_LEFT, AV_CHAN_BOTTOM_FRONT_RIGHT, +AV_CHAN_SIDE_SURROUND_LEFT, ///< +90 degrees, Lss, SiL +AV_CHAN_SIDE_SURROUND_RIGHT,///< -90 degrees, Rss, SiR +AV_CHAN_TOP_SURROUND_LEFT, ///< +110 degrees, Lvs, TpLS +AV_CHAN_TOP_SURROUND_RIGHT, ///< -110 degrees, Rvs, TpRS /** Channel is empty can be safely skipped. */ AV_CHAN_UNUSED = 0x200, @@ -195,6 +199,10 @@ enum AVChannelOrder { #define AV_CH_BOTTOM_FRONT_CENTER(1ULL << AV_CHAN_BOTTOM_FRONT_CENTER ) #define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT) #define AV_CH_BOTTOM_FRONT_RIGHT (1ULL << AV_CHAN_BOTTOM_FRONT_RIGHT ) +#define AV_CH_SIDE_SURROUND_LEFT (1ULL << AV_CHAN_SIDE_SURROUND_LEFT ) +#define AV_CH_SIDE_SURROUND_RIGHT(1ULL << AV_CHAN_SIDE_SURROUND_RIGHT ) +#define AV_CH_TOP_SURROUND_LEFT (1ULL << AV_CHAN_TOP_SURROUND_LEFT) +#define AV_CH_TOP_SURROUND_RIGHT (1ULL << AV_CHAN_TOP_SURROUND_RIGHT ) /** * @} -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 02/10] aacdec: move from scalefactor ranged arrays to flat arrays
AAC uses an unconventional system to send scalefactors (the volume+quantization value for each band). Each window is split into either 1 or 8 blocks (long vs short), and transformed separately from one another, with the coefficients for each being also completely independent. The scalefactors slightly increase from 64 (long) to 128 (short) to accomodate better per-block-per-band volume for each window. To reduce overhead, the codec signals scalefactor sizes in an obtuse way, where each group's scalefactor types are sent via a variable length decoding, with a range. But our decoder was written in a way where those ranges were carried through the entire decoder, and to actually read them you had to use the range. Instead of having a dedicated array with a range for each scalefactor, just let the decoder directly index each scalefactor. This also switches the form of quantized scalefactors to the format the spec uses, where for intensity stereo and regular, scalefactors are stored in a scalefactor - 100 form, rather than as-is. USAC gets rid of the complex scalefactor handling. This commit permits for code sharing between both. --- libavcodec/aac/aacdec.c | 100 --- libavcodec/aac/aacdec.h | 5 +- libavcodec/aac/aacdec_dsp_template.c | 95 ++--- 3 files changed, 83 insertions(+), 117 deletions(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 7457fe6c97..35722f9b9b 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1412,13 +1412,13 @@ fail: * * @return Returns error status. 0 - OK, !0 - error */ -static int decode_band_types(AACDecContext *ac, enum BandType band_type[120], - int band_type_run_end[120], GetBitContext *gb, - IndividualChannelStream *ics) +static int decode_band_types(AACDecContext *ac, SingleChannelElement *sce, + GetBitContext *gb) { -int g, idx = 0; +IndividualChannelStream *ics = &sce->ics; const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5; -for (g = 0; g < ics->num_window_groups; g++) { + +for (int g = 0; g < ics->num_window_groups; g++) { int k = 0; while (k < ics->max_sfb) { uint8_t sect_end = k; @@ -1442,10 +1442,8 @@ static int decode_band_types(AACDecContext *ac, enum BandType band_type[120], return AVERROR_INVALIDDATA; } } while (sect_len_incr == (1 << bits) - 1); -for (; k < sect_end; k++) { -band_type[idx] = sect_band_type; -band_type_run_end[idx++] = sect_end; -} +for (; k < sect_end; k++) +sce->band_type[g*ics->max_sfb + k] = sect_band_type; } } return 0; @@ -1461,69 +1459,59 @@ static int decode_band_types(AACDecContext *ac, enum BandType band_type[120], * * @return Returns error status. 0 - OK, !0 - error */ -static int decode_scalefactors(AACDecContext *ac, int sfo[120], - GetBitContext *gb, - unsigned int global_gain, - IndividualChannelStream *ics, - enum BandType band_type[120], - int band_type_run_end[120]) +static int decode_scalefactors(AACDecContext *ac, SingleChannelElement *sce, + GetBitContext *gb, unsigned int global_gain) { -int g, i, idx = 0; +IndividualChannelStream *ics = &sce->ics; int offset[3] = { global_gain, global_gain - NOISE_OFFSET, 0 }; int clipped_offset; int noise_flag = 1; -for (g = 0; g < ics->num_window_groups; g++) { -for (i = 0; i < ics->max_sfb;) { -int run_end = band_type_run_end[idx]; -switch (band_type[idx]) { + +for (int g = 0; g < ics->num_window_groups; g++) { +for (int sfb = 0; sfb < ics->max_sfb; sfb++) { +switch (sce->band_type[g*ics->max_sfb + sfb]) { case ZERO_BT: -for (; i < run_end; i++, idx++) -sfo[idx] = 0; +sce->sfo[g*ics->max_sfb + sfb] = 0; break; case INTENSITY_BT: /* fallthrough */ case INTENSITY_BT2: -for (; i < run_end; i++, idx++) { -offset[2] += get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - SCALE_DIFF_ZERO; -clipped_offset = av_clip(offset[2], -155, 100); -if (offset[2] != clipped_offset) { -avpriv_request_sample(ac->avctx, - "If you heard an audible artifact, there may be a bug in the decoder. " - "Clipped intensity stereo position (%d -> %d)", - offset[2], clipped_offset);
[FFmpeg-devel] [PATCH v5 03/10] aacdec: expose channel layout related functions
--- libavcodec/aac/aacdec.c | 73 - libavcodec/aac/aacdec.h | 19 +-- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 35722f9b9b..40554ff9e4 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -111,10 +111,6 @@ Parametric Stereo. */ -static int output_configure(AACDecContext *ac, -uint8_t layout_map[MAX_ELEM_ID*4][3], int tags, -enum OCStatus oc_type, int get_new_frame); - #define overread_err "Input buffer exhausted before END element found\n" static int count_channels(uint8_t (*layout)[3], int tags) @@ -447,8 +443,8 @@ static void pop_output_configuration(AACDecContext *ac) if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) { ac->oc[1] = ac->oc[0]; ac->avctx->ch_layout = ac->oc[1].ch_layout; -output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 0); +ff_aac_output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, +ac->oc[1].status, 0); } } @@ -458,7 +454,7 @@ static void pop_output_configuration(AACDecContext *ac) * * @return Returns error status. 0 - OK, !0 - error */ -static int output_configure(AACDecContext *ac, +int ff_aac_output_configure(AACDecContext *ac, uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags, enum OCStatus oc_type, int get_new_frame) { @@ -547,7 +543,7 @@ static av_cold void flush(AVCodecContext *avctx) * * @return Returns error status. 0 - OK, !0 - error */ -static int set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, +int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, uint8_t (*layout_map)[3], int *tags, int channel_config) @@ -587,7 +583,7 @@ static int set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, return 0; } -static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) +ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id) { /* For PCE based channel configurations map the channels solely based * on tags. */ @@ -603,11 +599,11 @@ static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n"); -if (set_default_channel_config(ac, ac->avctx, layout_map, - &layout_map_tags, 2) < 0) +if (ff_aac_set_default_channel_config(ac, ac->avctx, layout_map, + &layout_map_tags, 2) < 0) return NULL; -if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) +if (ff_aac_output_configure(ac, layout_map, layout_map_tags, +OC_TRIAL_FRAME, 1) < 0) return NULL; ac->oc[1].m4ac.chan_config = 2; @@ -627,8 +623,8 @@ static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT; layout_map[0][1] = 0; layout_map[1][1] = 1; -if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) +if (ff_aac_output_configure(ac, layout_map, layout_map_tags, +OC_TRIAL_FRAME, 1) < 0) return NULL; if (ac->oc[1].m4ac.sbr) @@ -877,8 +873,8 @@ static int decode_ga_specific_config(AACDecContext *ac, AVCodecContext *avctx, if (tags < 0) return tags; } else { -if ((ret = set_default_channel_config(ac, avctx, layout_map, - &tags, channel_config))) +if ((ret = ff_aac_set_default_channel_config(ac, avctx, layout_map, + &tags, channel_config))) return ret; } @@ -887,7 +883,7 @@ static int decode_ga_specific_config(AACDecContext *ac, AVCodecContext *avctx, } else if (m4ac->sbr == 1 && m4ac->ps == -1) m4ac->ps = 1; -if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) +if (ac && (ret = ff_aac_output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) return ret; if (extension_flag) { @@ -967,11 +963,11 @@ static int decode_eld_specific_config(AACDecContext *ac, AVCodecContext *avctx, skip_bits_long(gb, 8 * len); } -if ((ret = set_default_channel_config(ac, avctx, layout_map, - &tags, channel_config))) +if ((ret = ff_aac_set_default_channel_config
[FFmpeg-devel] [PATCH v5 04/10] aacdec: expose decode_tns
USAC has the same syntax, with one minor change we can check for. --- libavcodec/aac/aacdec.c | 6 +++--- libavcodec/aac/aacdec.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 40554ff9e4..a7e5b2a369 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1542,7 +1542,7 @@ static int decode_pulses(Pulse *pulse, GetBitContext *gb, * * @return Returns error status. 0 - OK, !0 - error */ -static int decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, +int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics) { int w, filt, i, coef_len, coef_res, coef_compress; @@ -1690,7 +1690,7 @@ int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce, } tns->present = get_bits1(gb); if (tns->present && !er_syntax) { -ret = decode_tns(ac, tns, gb, ics); +ret = ff_aac_decode_tns(ac, tns, gb, ics); if (ret < 0) goto fail; } @@ -1704,7 +1704,7 @@ int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce, // I see no textual basis in the spec for this occurring after SSR gain // control, but this is what both reference and real implmentations do if (tns->present && er_syntax) { -ret = decode_tns(ac, tns, gb, ics); +ret = ff_aac_decode_tns(ac, tns, gb, ics); if (ret < 0) goto fail; } diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index bea0578e92..499bd8eefc 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -351,6 +351,9 @@ int ff_aac_decode_init_fixed(AVCodecContext *avctx); int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce, GetBitContext *gb, int common_window, int scale_flag); +int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, + GetBitContext *gb, const IndividualChannelStream *ics); + int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, uint8_t (*layout_map)[3], int *tags, -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 05/10] aacdec_dsp: implement 768-point transform and windowing
Required for USAC --- libavcodec/aac/aacdec.c | 4 ++ libavcodec/aac/aacdec.h | 5 +++ libavcodec/aac/aacdec_dsp_template.c | 67 libavcodec/aac/aacdec_fixed.c| 2 + libavcodec/aac/aacdec_float.c| 4 ++ libavcodec/sinewin_fixed_tablegen.c | 2 + libavcodec/sinewin_fixed_tablegen.h | 4 ++ 7 files changed, 88 insertions(+) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index a7e5b2a369..6f37ac5361 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1113,10 +1113,12 @@ static av_cold int decode_close(AVCodecContext *avctx) } } +av_tx_uninit(&ac->mdct96); av_tx_uninit(&ac->mdct120); av_tx_uninit(&ac->mdct128); av_tx_uninit(&ac->mdct480); av_tx_uninit(&ac->mdct512); +av_tx_uninit(&ac->mdct768); av_tx_uninit(&ac->mdct960); av_tx_uninit(&ac->mdct1024); av_tx_uninit(&ac->mdct_ltp); @@ -1145,10 +1147,12 @@ static av_cold int init_dsp(AVCodecContext *avctx) if (ret < 0) \ return ret +MDCT_INIT(ac->mdct96, ac->mdct96_fn, 96, 1.0/96); MDCT_INIT(ac->mdct120, ac->mdct120_fn, 120, 1.0/120); MDCT_INIT(ac->mdct128, ac->mdct128_fn, 128, 1.0/128); MDCT_INIT(ac->mdct480, ac->mdct480_fn, 480, 1.0/480); MDCT_INIT(ac->mdct512, ac->mdct512_fn, 512, 1.0/512); +MDCT_INIT(ac->mdct768, ac->mdct768_fn, 768, 1.0/768); MDCT_INIT(ac->mdct960, ac->mdct960_fn, 960, 1.0/960); MDCT_INIT(ac->mdct1024, ac->mdct1024_fn, 1024, 1.0/1024); #undef MDCT_INIT diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index 499bd8eefc..8d1eb74066 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -245,6 +245,7 @@ typedef struct AACDecDSP { ChannelElement *cce, int index); void (*imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce); +void (*imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce); @@ -290,18 +291,22 @@ struct AACDecContext { * @name Computed / set up during initialization * @{ */ +AVTXContext *mdct96; AVTXContext *mdct120; AVTXContext *mdct128; AVTXContext *mdct480; AVTXContext *mdct512; +AVTXContext *mdct768; AVTXContext *mdct960; AVTXContext *mdct1024; AVTXContext *mdct_ltp; +av_tx_fn mdct96_fn; av_tx_fn mdct120_fn; av_tx_fn mdct128_fn; av_tx_fn mdct480_fn; av_tx_fn mdct512_fn; +av_tx_fn mdct768_fn; av_tx_fn mdct960_fn; av_tx_fn mdct1024_fn; av_tx_fn mdct_ltp_fn; diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c index e69970472c..59a69d88f3 100644 --- a/libavcodec/aac/aacdec_dsp_template.c +++ b/libavcodec/aac/aacdec_dsp_template.c @@ -383,6 +383,71 @@ static void AAC_RENAME(imdct_and_windowing)(AACDecContext *ac, SingleChannelElem } } +/** + * Conduct IMDCT and windowing for 768-point frames. + */ +static void AAC_RENAME(imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce) +{ +IndividualChannelStream *ics = &sce->ics; +INTFLOAT *in= sce->AAC_RENAME(coeffs); +INTFLOAT *out = sce->AAC_RENAME(output); +INTFLOAT *saved = sce->AAC_RENAME(saved); +const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96); +const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(aac_kbd_long_768) : AAC_RENAME(sine_768); +const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96); +INTFLOAT *buf = ac->AAC_RENAME(buf_mdct); +INTFLOAT *temp = ac->AAC_RENAME(temp); +int i; + +// imdct +if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { +for (i = 0; i < 8; i++) +ac->mdct96_fn(ac->mdct96, buf + i * 96, in + i * 96, sizeof(INTFLOAT)); +} else { +ac->mdct768_fn(ac->mdct768, buf, in, sizeof(INTFLOAT)); +} + +/* window overlapping + * NOTE: To simplify the overlapping code, all 'meaningless' short to long + * and long to short transitions are considered to be short to short + * transitions. This leaves just two cases (long to long and short to short) + * with a little special sauce for EIGHT_SHORT_SEQUENCE. + */ + +if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && +(ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { +ac->fdsp->vector_fmul_window(out, saved, bu
[FFmpeg-devel] [PATCH v5 06/10] aactab: add deemphasis tables for USAC
--- libavcodec/aactab.c | 25 + libavcodec/aactab.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index 3718b81a07..8ce5e43974 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -3377,3 +3377,28 @@ const DECLARE_ALIGNED(32, int, ff_aac_eld_window_480_fixed)[1800] = { 0xffecff1c, 0xffed391e, 0xffed740c, 0xffedafb1, 0xffedebe1, 0xffee287d, 0xffee654e, 0xffeea23f, }; + +/* As specified by ISO/IEC 23003 */ +#define USAC_EMPH_COEFF 0.68 + +DECLARE_ALIGNED(16, const float, ff_aac_deemph_weights)[16] = { +USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF, + +0, +USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF, + +0, +0, +USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF, + +0, +0, +0, +USAC_EMPH_COEFF, +}; diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h index e1a2d8b9a1..91262380d4 100644 --- a/libavcodec/aactab.h +++ b/libavcodec/aactab.h @@ -64,6 +64,8 @@ DECLARE_ALIGNED(32, extern const float, ff_aac_eld_window_480)[1800]; DECLARE_ALIGNED(32, extern const int, ff_aac_eld_window_480_fixed)[1800]; // @} +extern const float ff_aac_deemph_weights[16]; + /* Initializes data shared between float decoder and encoder. */ void ff_aac_float_common_init(void); -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 08/10] aactab: add new scalefactor offset tables for 96/768pt windows
--- libavcodec/aactab.c | 117 libavcodec/aactab.h | 4 ++ 2 files changed, 121 insertions(+) diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index dfb2dfd98d..18afa69bad 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -154,6 +154,10 @@ const uint8_t ff_aac_num_swb_960[] = { 40, 40, 46, 49, 49, 49, 46, 46, 42, 42, 42, 40, 40 }; +const uint8_t ff_aac_num_swb_768[] = { +37, 37, 41, 43, 43, 43, 43, 43, 39, 39, 39, 37, 37 +}; + const uint8_t ff_aac_num_swb_512[] = { 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0, 0 }; @@ -170,6 +174,10 @@ const uint8_t ff_aac_num_swb_120[] = { 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15 }; +const uint8_t ff_aac_num_swb_96[] = { +12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14 +}; + const uint8_t ff_aac_pred_sfb_max[] = { 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34, 34 }; @@ -1806,6 +1814,99 @@ static const uint16_t swb_offset_120_8[] = 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 120 }; +static const uint16_t swb_offset_768_96[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, +40, 44, 48, 52, 56, 64, 72, 80, 88, 96, +108, 120, 132, 144, 156, 172, 188, 212, 240, 276, +320, 384, 448, 512, 576, 640, 704, 768 +}; + +static const uint16_t swb_offset_768_64[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, +44, 48, 52, 56, 64, 72, 80, 88, 100, 112, 124, +140, 156, 172, 192, 216, 240, 268, 304, 344, 384, 424, +464, 504, 544, 584, 624, 664, 704, 744, 768 +}; + +static const uint16_t swb_offset_768_48[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, +56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, +196, 216, 240, 264, 292, 320, 352, 384, 416, 448, 480, 512, +544, 576, 608, 640, 672, 704, 736, 768 +}; + +static const uint16_t swb_offset_768_32[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, +56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, +196, 216, 240, 264, 292, 320, 352, 384, 416, 448, 480, 512, +544, 576, 608, 640, 672, 704, 736, 768 +}; + +static const uint16_t swb_offset_768_24[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, +52, 60, 68, 76, 84, 92, 100, 108, 116, 124, 136, 148, +160, 172, 188, 204, 220, 240, 260, 284, 308, 336, 364, 396, +432, 468, 508, 552, 600, 652, 704, 768 +}; + +static const uint16_t swb_offset_768_16[] = +{ +0, 8, 16, 24, 32, 40, 48, 56, 64, +72, 80, 88, 100, 112, 124, 136, 148, 160, +172, 184, 196, 212, 228, 244, 260, 280, 300, +320, 344, 368, 396, 424, 456, 492, 532, 572, +616, 664, 716, 768 +}; + +static const uint16_t swb_offset_768_8[] = +{ +0, 12, 24, 36, 48, 60, 72, 84, 96, 108, +120, 132, 144, 156, 172, 188, 204, 220, 236, 252, +268, 288, 308, 328, 348, 372, 396, 420, 448, 476, +508, 544, 580, 620, 664, 712, 764, 768 +}; + +static const uint16_t swb_offset_96_96[] = +{ +0, 4, 8, 12, 16, 20, 24, +32, 40, 48, 64, 92, 96 +}; + +static const uint16_t swb_offset_96_64[] = +{ +0, 4, 8, 12, 16, 20, 24, +32, 40, 48, 64, 92, 96 +}; + +static const uint16_t swb_offset_96_48[] = +{ +0, 4, 8, 12, 16, 20, 28, +36, 44, 56, 68, 80, 96 +}; + +static const uint16_t swb_offset_96_24[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, +36, 44, 52, 64, 76, 92, 96 +}; + +static const uint16_t swb_offset_96_16[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, +32, 40, 48, 60, 72, 88, 96 +}; + +static const uint16_t swb_offset_96_8[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, +36, 44, 52, 60, 72, 88, 96 +}; + const uint16_t * const ff_swb_offset_1024[] = { swb_offset_1024_96, swb_offset_1024_96, swb_offset_1024_64, swb_offset_1024_48, swb_offset_1024_48, swb_offset_1024_32, @@ -1822,6 +1923,14 @@ const uint16_t * const ff_swb_offset_960[] = { swb_offset_960_8 }; +const uint16_t * const ff_swb_offset_768[] = { +swb_offset_768_96, swb_offset_768_96, swb_offset_768_64, +swb_offset_768_48, swb_offset_768_48, swb_offset_768_32, +swb_offset_768_24, swb_offset_768_24, swb_offset_768_16, +swb_offset_768_16, swb_offset_768_16, swb_offset_768_8, +swb_offset_768_8 +}; + const uint16_t * const ff_swb_offset_512[] = { NULL, NULL, NULL, swb_offset_512_48, swb_offset_512_48, swb_offset_512_32, @@ -1856,6 +1965,14 @@ const uint16_t * const ff_swb_offset_120[] = { swb_offset_120_8 }; +const uint16_t * const ff_swb_offset_96[] = { +swb_offset_96_96, swb_offset_96_96, swb_offset_96_96, +swb_offset_96_48, swb_offset_96_48, swb_offset_96_48, +swb_offset_96_24, swb_offset_96_24, swb_offset_96_16, +swb_offset_96_16, swb_offset_96_16, swb_offset_96_8, +swb_offset_96_8 +}; + // @} /* @name ff_tns_max_bands diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
[FFmpeg-devel] [PATCH v5 09/10] aacdec: add a decoder for AAC USAC (xHE-AAC)
This commit adds a decoder for the frequency-domain part of USAC. What works: - Mono - Stereo (no prediction) - Stereo (mid/side coding) - Stereo (complex prediction) What's left: - Speech coding Known issues: - Desync with certain sequences - Preroll crossover missing (shouldn't matter, bitrate adaptation only) --- libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 188 +-- libavcodec/aac/aacdec.h | 187 +++ libavcodec/aac/aacdec_ac.c | 208 libavcodec/aac/aacdec_ac.h | 54 + libavcodec/aac/aacdec_dsp_template.c |4 +- libavcodec/aac/aacdec_latm.h | 14 +- libavcodec/aac/aacdec_lpd.c | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1608 ++ libavcodec/aac/aacdec_usac.h | 37 + libavcodec/aactab.c | 42 + libavcodec/aactab.h | 10 + 13 files changed, 2510 insertions(+), 76 deletions(-) create mode 100644 libavcodec/aac/aacdec_ac.c create mode 100644 libavcodec/aac/aacdec_ac.h create mode 100644 libavcodec/aac/aacdec_lpd.c create mode 100644 libavcodec/aac/aacdec_lpd.h create mode 100644 libavcodec/aac/aacdec_usac.c create mode 100644 libavcodec/aac/aacdec_usac.h diff --git a/libavcodec/aac/Makefile b/libavcodec/aac/Makefile index c3e525d373..70b1dca274 100644 --- a/libavcodec/aac/Makefile +++ b/libavcodec/aac/Makefile @@ -2,6 +2,7 @@ clean:: $(RM) $(CLEANSUFFIXES:%=libavcodec/aac/%) OBJS-$(CONFIG_AAC_DECODER) += aac/aacdec.o aac/aacdec_tab.o \ -aac/aacdec_float.o +aac/aacdec_float.o aac/aacdec_usac.o \ +aac/aacdec_ac.o aac/aacdec_lpd.o OBJS-$(CONFIG_AAC_FIXED_DECODER)+= aac/aacdec.o aac/aacdec_tab.o \ aac/aacdec_fixed.o diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 6f37ac5361..2b8322fc68 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -40,6 +40,7 @@ #include "aacdec.h" #include "aacdec_tab.h" +#include "aacdec_usac.h" #include "libavcodec/aac.h" #include "libavcodec/aac_defines.h" @@ -535,6 +536,8 @@ static av_cold void flush(AVCodecContext *avctx) } } } + +ff_aac_usac_reset_state(ac, &ac->oc[1]); } /** @@ -993,13 +996,14 @@ static int decode_eld_specific_config(AACDecContext *ac, AVCodecContext *avctx, */ static int decode_audio_specific_config_gb(AACDecContext *ac, AVCodecContext *avctx, - MPEG4AudioConfig *m4ac, + OutputConfiguration *oc, GetBitContext *gb, int get_bit_alignment, int sync_extension) { int i, ret; GetBitContext gbc = *gb; +MPEG4AudioConfig *m4ac = &oc->m4ac; MPEG4AudioConfig m4ac_bak = *m4ac; if ((i = ff_mpeg4audio_get_config_gb(m4ac, &gbc, sync_extension, avctx)) < 0) { @@ -1033,14 +1037,22 @@ static int decode_audio_specific_config_gb(AACDecContext *ac, case AOT_ER_AAC_LC: case AOT_ER_AAC_LD: if ((ret = decode_ga_specific_config(ac, avctx, gb, get_bit_alignment, -m4ac, m4ac->chan_config)) < 0) + &oc->m4ac, m4ac->chan_config)) < 0) return ret; break; case AOT_ER_AAC_ELD: if ((ret = decode_eld_specific_config(ac, avctx, gb, - m4ac, m4ac->chan_config)) < 0) + &oc->m4ac, m4ac->chan_config)) < 0) +return ret; +break; +#if CONFIG_AAC_DECODER +case AOT_USAC_NOSBR: /* fallthrough */ +case AOT_USAC: +if ((ret = ff_aac_usac_config_decode(ac, avctx, gb, + oc, m4ac->chan_config)) < 0) return ret; break; +#endif default: avpriv_report_missing_feature(avctx, "Audio object type %s%d", @@ -1060,7 +1072,7 @@ static int decode_audio_specific_config_gb(AACDecContext *ac, static int decode_audio_specific_config(AACDecContext *ac, AVCodecContext *avctx, -MPEG4AudioConfig *m4ac, +OutputConfiguration *oc, const uint8_t *data, int64_t bit_size, int sync_extension) { @@ -1080,7 +1092,7 @@ static int decode_audio_specific_config(AACDecContext *ac, if ((ret = init_get_bits(&gb, data, bit_size)) < 0) return re
[FFmpeg-devel] [PATCH v5 07/10] aactab: add tables for the new USAC arithmetic coder
--- libavcodec/aactab.c | 376 libavcodec/aactab.h | 6 + 2 files changed, 382 insertions(+) diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index 8ce5e43974..dfb2dfd98d 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -1193,6 +1193,382 @@ const uint16_t *const ff_aac_codebook_vector_idx[] = { codebook_vector10_idx, }; +const uint16_t ff_aac_ac_msb_cdfs[64][17] = { +{ 708, 706, 579, 569, 568, 567, 479, 469, +297, 138,97,91,72,52,38,34, 0, }, +{ 7619, 6917, 6519, 6412, 5514, 5003, 4683, 4563, + 3907, 3297, 3125, 3060, 2904, 2718, 2631, 2590, 0, }, +{ 7263, 4888, 4810, 4803, 1889, 415, 335, 327, +195,72,52,49,36,20,15,14, 0, }, +{ 3626, 2197, 2188, 2187, 582,57,47,46, + 30,12, 9, 8, 6, 4, 3, 2, 0, }, +{ 7806, 5541, 5451, 5441, 2720, 834, 691, 674, +487, 243, 179, 167, 139,98,77,70, 0, }, +{ 6684, 4101, 4058, 4055, 1748, 426, 368, 364, +322, 257, 235, 232, 228, 222, 217, 215, 0, }, +{ 9162, 5964, 5831, 5819, 3269, 866, 658, 638, +535, 348, 258, 244, 234, 214, 195, 186, 0, }, +{ 10638, 8491, 8365, 8351, 4418, 2067, 1859, 1834, + 1190, 601, 495, 478, 356, 217, 174, 164, 0, }, +{ 13389, 10514, 10032, 9961, 7166, 3488, 2655, 2524, + 2015, 1140, 760, 672, 585, 426, 325, 283, 0, }, +{ 14861, 12788, 12115, 11952, 9987, 6657, 5323, 4984, + 4324, 3001, 2205, 1943, 1764, 1394, 1115, 978, 0, }, +{ 12876, 10004, 9661, 9610, 7107, 3435, 2711, 2595, + 2257, 1508, 1059, 952, 893, 753, 609, 538, 0, }, +{ 15125, 13591, 13049, 12874, 11192, 8543, 7406, 7023, + 6291, 4922, 4104, 3769, 3465, 2890, 2486, 2275, 0, }, +{ 14574, 13106, 12731, 12638, 10453, 7947, 7233, 7037, + 6031, 4618, 4081, 3906, 3465, 2802, 2476, 2349, 0, }, +{ 15070, 13179, 12517, 12351, 10742, 7657, 6200, 5825, + 5264, 3998, 3014, 2662, 2510, 2153, 1799, 1564, 0, }, +{ 15542, 14466, 14007, 13844, 12489, 10409, 9481, 9132, + 8305, 6940, 6193, 5867, 5458, 4743, 4291, 4047, 0, }, +{ 15165, 14384, 14084, 13934, 12911, 11485, 10844, 10513, + 10002, 8993, 8380, 8051, 7711, 7036, 6514, 6233, 0, }, +{ 15642, 14279, 13625, 13393, 12348, 9971, 8405, 7858, + 7335, 6119, 4918, 4376, 4185, 3719, 3231, 2860, 0, }, +{ 13408, 13407, 11471, 11218, 11217, 11216, 9473, 9216, + 6480, 3689, 2857, 2690, 2256, 1732, 1405, 1302, 0, }, +{ 16098, 15584, 15191, 14931, 14514, 13578, 12703, 12103, + 11830, 11172, 10475, 9867, 9695, 9281, 8825, 8389, 0, }, +{ 15844, 14873, 14277, 13996, 13230, 11535, 10205, 9543, + 9107, 8086, 7085, 6419, 6214, 5713, 5195, 4731, 0, }, +{ 16131, 15720, 15443, 15276, 14848, 13971, 13314, 12910, + 12591, 11874, 11225, 10788, 10573, 10077, 9585, 9209, 0, }, +{ 16331, 16330, 12283, 11435, 11434, 11433, 8725, 8049, + 6065, 4138, 3187, 2842, 2529, 2171, 1907, 1745, 0, }, +{ 16011, 15292, 14782, 14528, 14008, 12767, 11556, 10921, + 10591, 9759, 8813, 8043, 7855, 7383, 6863, 6282, 0, }, +{ 16380, 16379, 15159, 14610, 14609, 14608, 12859, 12111, + 11046, 9536, 8348, 7713, 7216, 6533, 5964, 5546, 0, }, +{ 16367, 16333, 16294, 16253, 16222, 16143, 16048, 15947, + 15915, 15832, 15731, 15619, 15589, 15512, 15416, 15310, 0, }, +{ 15967, 15319, 14937, 14753, 14010, 12638, 11787, 11360, + 10805, 9706, 8934, 8515, 8166, 7456, 6911, 6575, 0, }, +{ 4906, 3005, 2985, 2984, 875, 102,83,81, + 47,17,12,11, 8, 5, 4, 3, 0, }, +{ 7217, 4346, 4269, 4264, 1924, 428, 340, 332, +280, 203, 179, 175, 171, 164, 159, 157, 0, }, +{ 16010, 15415, 15032, 14805, 14228, 13043, 12168, 11634, + 11265, 10419, 9645, 9110, 8892, 8378, 7850, 7437, 0, }, +{ 8573, 5218, 5046, 5032, 2787, 771, 555, 533, +443, 286, 218, 205, 197, 181, 168, 162, 0, }, +{ 11474, 8095, 7822, 7796, 4632, 1443, 1046, 1004, +748, 351, 218, 194, 167, 121,93,83, 0, }, +{ 16152, 15764, 15463, 15264, 14925, 14189, 13536, 13070, + 12846, 12314, 11763, 11277, 11131, 10777, 10383, 10011, 0, }, +{ 14187, 11654, 11043, 10919, 8498, 4885, 3778, 3552, + 2947, 1835, 1283, 1134, 998, 749, 585, 514, 0, }, +{ 14162, 11527, 10759, 10557, 8601, 5417, 4105, 3753, + 3286, 2353, 1708, 1473, 1370, 1148, 959, 840, 0, }, +{ 16205, 15902, 15669, 15498, 15213, 14601, 14068, 13674, +
[FFmpeg-devel] [PATCH v5 10/10] fate: add tests for xHE-AAC
Starting off small with a few features. Samples and reference decoded files copied from the official ISO reference suite. FATE files: https://files.lynne.ee/xhe_refs/ --- tests/fate/aac.mak | 8 1 file changed, 8 insertions(+) diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak index 817944773d..ff58392ad9 100644 --- a/tests/fate/aac.mak +++ b/tests/fate/aac.mak @@ -62,6 +62,14 @@ FATE_AAC += fate-aac-ap05_48 fate-aac-ap05_48: CMD = pcm -i $(TARGET_SAMPLES)/aac/ap05_48.mp4 fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16 +FATE_AAC += fate-aac-fd_2_c1_ms_0x01 +fate-aac-fd_2_c1_ms_0x01: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x01.mp4 +fate-aac-fd_2_c1_ms_0x01: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x01.s16 + +FATE_AAC += fate-aac-fd_2_c1_ms_0x04 +fate-aac-fd_2_c1_ms_0x04: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x04.mp4 +fate-aac-fd_2_c1_ms_0x04: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x04.s16 + FATE_AAC += fate-aac-er_ad6000np_44_ep0 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i $(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44.s16 -- 2.43.0.381.gb435a96ce8 ___ 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] lavu/common.h: Fix UB in av_clipl_int32_c()
Hi, Le 30 mai 2024 01:13:14 GMT+03:00, "Tomas Härdin" a écrit : >The entire patchset passes FATE Is the version in riscv/intmath.h safe? It looks to me that the GCC codegen for not only RV64 but also AArch{32,64} and x86-64 is better than this. ___ 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".