diff mbox series

[FFmpeg-devel,2/5] avcodec/ffv1enc: Move slice termination into threads

Message ID 20241010204528.1714687-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avcodec/ffv1enc: allow manually specifying the crc type | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Oct. 10, 2024, 8:45 p.m. UTC
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/ffv1enc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Michael Niedermayer Oct. 14, 2024, 8:31 p.m. UTC | #1
On Thu, Oct 10, 2024 at 10:45:25PM +0200, Michael Niedermayer wrote:
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ffv1enc.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)

will apply, should be a tiny bit faster

[...]
diff mbox series

Patch

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 430e2161a3b..3a431f41365 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1105,6 +1105,13 @@  retry:
         ret = encode_rgb_frame(f, sc, planes, width, height, p->linesize);
     }
 
+    if (f->ac != AC_GOLOMB_RICE) {
+        sc->ac_byte_count = ff_rac_terminate(&sc->c, 1);
+    } else {
+        flush_put_bits(&sc->pb); // FIXME: nicer padding
+        sc->ac_byte_count += put_bytes_output(&sc->pb);
+    }
+
     if (ret < 0) {
         av_assert0(sc->slice_coding_mode == 0);
         if (f->version < 4 || !f->ac) {
@@ -1229,14 +1236,7 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     buf_p = pkt->data;
     for (i = 0; i < f->slice_count; i++) {
         FFV1SliceContext *sc = &f->slices[i];
-        int bytes;
-
-        if (f->ac != AC_GOLOMB_RICE) {
-            bytes = ff_rac_terminate(&sc->c, 1);
-        } else {
-            flush_put_bits(&sc->pb); // FIXME: nicer padding
-            bytes = sc->ac_byte_count + put_bytes_output(&sc->pb);
-        }
+        int bytes = sc->ac_byte_count;
         if (i > 0 || f->version > 2) {
             av_assert0(bytes < pkt->size / f->slice_count);
             memmove(buf_p, sc->c.bytestream_start, bytes);