* [FFmpeg-devel] [PATCH 1/2] avcodec/asvenc: Don't use FF_INPUT_BUFFER_MIN_SIZE
@ 2025-04-11 18:57 Andreas Rheinhardt
2025-04-12 0:05 ` Michael Niedermayer
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Rheinhardt @ 2025-04-11 18:57 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 29 bytes --]
Patches attached.
- Andreas
[-- Attachment #2: 0001-avcodec-asvenc-Don-t-use-FF_INPUT_BUFFER_MIN_SIZE.patch --]
[-- Type: text/x-patch, Size: 1131 bytes --]
From e2ca8a7268f0d6071d170b1d99e5a264392e1b2e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Fri, 11 Apr 2025 00:36:59 +0200
Subject: [PATCH 1/2] avcodec/asvenc: Don't use FF_INPUT_BUFFER_MIN_SIZE
ASV-1/2 does not really have a header and so using
FF_INPUT_BUFFER_MIN_SIZE is wasteful as well as ugly
(such bounds should be codec-specific).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/asvenc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index 9218a41021..e7d931cca9 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -271,8 +271,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return ret;
}
- if ((ret = ff_alloc_packet(avctx, pkt, c->mb_height * c->mb_width * MAX_MB_SIZE +
- FF_INPUT_BUFFER_MIN_SIZE)) < 0)
+ ret = ff_alloc_packet(avctx, pkt, c->mb_height * c->mb_width * MAX_MB_SIZE + 3);
+ if (ret < 0)
return ret;
init_put_bits(&a->pb, pkt->data, pkt->size);
--
2.45.2
[-- Attachment #3: 0002-avcodec-asvenc-Use-tighter-MAX_MB_SIZE-constant.patch --]
[-- Type: text/x-patch, Size: 1392 bytes --]
From 653e8d3da311b56914fb8888e80b56507ee5fe38 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Fri, 11 Apr 2025 00:38:59 +0200
Subject: [PATCH 2/2] avcodec/asvenc: Use tighter MAX_MB_SIZE constant
Also document the constant.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/asvenc.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index e7d931cca9..52666ee547 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -50,6 +50,14 @@ typedef struct ASVEncContext {
int q_intra_matrix[64];
} ASVEncContext;
+enum {
+ ASV1_MAX_BLOCK_SIZE = 8 + 10 * FFMAX(2 /* skip */, 5 /* ccp */ + 4 * 11 /* level */) + 5,
+ ASV1_MAX_MB_SIZE = 6 * ASV1_MAX_BLOCK_SIZE,
+ ASV2_MAX_BLOCK_SIZE = 4 + 8 + 16 * (6 /* ccp */ + 4 * 13 /* level */),
+ ASV2_MAX_MB_SIZE = 6 * ASV2_MAX_BLOCK_SIZE,
+ MAX_MB_SIZE = (FFMAX(ASV1_MAX_MB_SIZE, ASV2_MAX_MB_SIZE) + 7) / 8
+};
+
static inline void asv1_put_level(PutBitContext *pb, int level)
{
unsigned int index = level + 3;
@@ -177,8 +185,6 @@ static inline void asv2_encode_block(ASVEncContext *a, int16_t block[64])
}
}
-#define MAX_MB_SIZE (30 * 16 * 16 * 3 / 2 / 8)
-
static inline int encode_mb(ASVEncContext *a, int16_t block[6][64])
{
int i;
--
2.45.2
[-- Attachment #4: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/asvenc: Don't use FF_INPUT_BUFFER_MIN_SIZE
2025-04-11 18:57 [FFmpeg-devel] [PATCH 1/2] avcodec/asvenc: Don't use FF_INPUT_BUFFER_MIN_SIZE Andreas Rheinhardt
@ 2025-04-12 0:05 ` Michael Niedermayer
0 siblings, 0 replies; 2+ messages in thread
From: Michael Niedermayer @ 2025-04-12 0:05 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2340 bytes --]
On Fri, Apr 11, 2025 at 08:57:09PM +0200, Andreas Rheinhardt wrote:
> Patches attached.
>
> - Andreas
> asvenc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> f02ccdc5e7ec0835b2af195734590d1e3f294d33 0001-avcodec-asvenc-Don-t-use-FF_INPUT_BUFFER_MIN_SIZE.patch
> From e2ca8a7268f0d6071d170b1d99e5a264392e1b2e Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Date: Fri, 11 Apr 2025 00:36:59 +0200
> Subject: [PATCH 1/2] avcodec/asvenc: Don't use FF_INPUT_BUFFER_MIN_SIZE
>
> ASV-1/2 does not really have a header and so using
> FF_INPUT_BUFFER_MIN_SIZE is wasteful as well as ugly
ok
> (such bounds should be codec-specific).
If the time this costs cannot be used for more valuable work
[...]
> asvenc.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
> 32d062bcc89be62b21c93f9d4e9005b195206aa8 0002-avcodec-asvenc-Use-tighter-MAX_MB_SIZE-constant.patch
> From 653e8d3da311b56914fb8888e80b56507ee5fe38 Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Date: Fri, 11 Apr 2025 00:38:59 +0200
> Subject: [PATCH 2/2] avcodec/asvenc: Use tighter MAX_MB_SIZE constant
>
> Also document the constant.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/asvenc.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
> index e7d931cca9..52666ee547 100644
> --- a/libavcodec/asvenc.c
> +++ b/libavcodec/asvenc.c
> @@ -50,6 +50,14 @@ typedef struct ASVEncContext {
> int q_intra_matrix[64];
> } ASVEncContext;
>
> +enum {
> + ASV1_MAX_BLOCK_SIZE = 8 + 10 * FFMAX(2 /* skip */, 5 /* ccp */ + 4 * 11 /* level */) + 5,
> + ASV1_MAX_MB_SIZE = 6 * ASV1_MAX_BLOCK_SIZE,
> + ASV2_MAX_BLOCK_SIZE = 4 + 8 + 16 * (6 /* ccp */ + 4 * 13 /* level */),
> + ASV2_MAX_MB_SIZE = 6 * ASV2_MAX_BLOCK_SIZE,
> + MAX_MB_SIZE = (FFMAX(ASV1_MAX_MB_SIZE, ASV2_MAX_MB_SIZE) + 7) / 8
> +};
beautifull
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-12 0:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-11 18:57 [FFmpeg-devel] [PATCH 1/2] avcodec/asvenc: Don't use FF_INPUT_BUFFER_MIN_SIZE Andreas Rheinhardt
2025-04-12 0:05 ` Michael Niedermayer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git