Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 0/2] fftools/resman: remove redundant includes, use inflate loop
@ 2025-05-31  1:50 ffmpegagent
  2025-05-31  1:50 ` [FFmpeg-devel] [PATCH 1/2] fftools/resman: remove unused includes, fix declaration softworkz
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: ffmpegagent @ 2025-05-31  1:50 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

and other cosmetic fixes.

As per review by Ramiro Polla in message: "Re: [FFmpeg-devel]
[FFmpeg-cvslog] fftools/resources: Add resource manager files with
build-time compression"

softworkz (2):
  fftools/resman: remove unused includes, fix declaration
  fftools/resman: use inflate loop with increasing buffer size

 fftools/resources/resman.c | 43 +++++++++++++++++++++++---------------
 fftools/resources/resman.h | 10 +--------
 2 files changed, 27 insertions(+), 26 deletions(-)


base-commit: 27c5e4b39afb272638ab907a710e7db4f867266d
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-90%2Fsoftworkz%2Fsubmit_resman_fixes-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-90/softworkz/submit_resman_fixes-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/90
-- 
ffmpeg-codebot
_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH 1/2] fftools/resman: remove unused includes, fix declaration
  2025-05-31  1:50 [FFmpeg-devel] [PATCH 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
@ 2025-05-31  1:50 ` softworkz
  2025-05-31  1:50 ` [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with increasing buffer size softworkz
  2025-05-31  3:58 ` [FFmpeg-devel] [PATCH v2 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
  2 siblings, 0 replies; 12+ messages in thread
From: softworkz @ 2025-05-31  1:50 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/resources/resman.c |  7 +++----
 fftools/resources/resman.h | 10 +---------
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/fftools/resources/resman.c b/fftools/resources/resman.c
index a9e21626fa..f098bd6687 100644
--- a/fftools/resources/resman.c
+++ b/fftools/resources/resman.c
@@ -34,7 +34,6 @@
 #include "resman.h"
 #include "fftools/ffmpeg_filter.h"
 #include "libavutil/avassert.h"
-#include "libavutil/pixdesc.h"
 #include "libavutil/dict.h"
 #include "libavutil/common.h"
 
@@ -61,7 +60,7 @@ typedef struct ResourceManagerContext {
 
 static AVMutex mutex = AV_MUTEX_INITIALIZER;
 
-ResourceManagerContext *resman_ctx = NULL;
+static ResourceManagerContext *resman_ctx = NULL;
 
 
 #if CONFIG_RESOURCE_COMPRESSION
@@ -77,7 +76,7 @@ static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in
     memset(&strm, 0, sizeof(strm));
 
     // Allocate output buffer with extra byte for null termination
-    buf = (uint8_t *)av_mallocz(chunk + 1);
+    buf = av_mallocz(chunk + 1);
     if (!buf) {
         av_log(ctx, AV_LOG_ERROR, "Failed to allocate decompression buffer\n");
         return AVERROR(ENOMEM);
@@ -156,7 +155,7 @@ void ff_resman_uninit(void)
 }
 
 
-char *ff_resman_get_string(FFResourceId resource_id)
+const char *ff_resman_get_string(FFResourceId resource_id)
 {
     ResourceManagerContext *ctx               = get_resman_context();
     FFResourceDefinition resource_definition = { 0 };
diff --git a/fftools/resources/resman.h b/fftools/resources/resman.h
index 6485db5091..dfe6b324e4 100644
--- a/fftools/resources/resman.h
+++ b/fftools/resources/resman.h
@@ -21,14 +21,6 @@
 #ifndef FFTOOLS_RESOURCES_RESMAN_H
 #define FFTOOLS_RESOURCES_RESMAN_H
 
-#include <stdint.h>
-
-#include "config.h"
-#include "fftools/ffmpeg.h"
-#include "libavutil/avutil.h"
-#include "libavutil/bprint.h"
-#include "fftools/textformat/avtextformat.h"
-
 typedef enum {
     FF_RESOURCE_GRAPH_CSS,
     FF_RESOURCE_GRAPH_HTML,
@@ -45,6 +37,6 @@ typedef struct FFResourceDefinition {
 
 void ff_resman_uninit(void);
 
-char *ff_resman_get_string(FFResourceId resource_id);
+const char *ff_resman_get_string(FFResourceId resource_id);
 
 #endif /* FFTOOLS_RESOURCES_RESMAN_H */
-- 
ffmpeg-codebot

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with increasing buffer size
  2025-05-31  1:50 [FFmpeg-devel] [PATCH 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
  2025-05-31  1:50 ` [FFmpeg-devel] [PATCH 1/2] fftools/resman: remove unused includes, fix declaration softworkz
@ 2025-05-31  1:50 ` softworkz
  2025-05-31  2:38   ` Kieran Kunhya via ffmpeg-devel
  2025-05-31  3:58 ` [FFmpeg-devel] [PATCH v2 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
  2 siblings, 1 reply; 12+ messages in thread
From: softworkz @ 2025-05-31  1:50 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/resources/resman.c | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/fftools/resources/resman.c b/fftools/resources/resman.c
index f098bd6687..0dae272c89 100644
--- a/fftools/resources/resman.c
+++ b/fftools/resources/resman.c
@@ -76,7 +76,7 @@ static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in
     memset(&strm, 0, sizeof(strm));
 
     // Allocate output buffer with extra byte for null termination
-    buf = av_mallocz(chunk + 1);
+    buf = av_realloc(NULL, chunk + 1);
     if (!buf) {
         av_log(ctx, AV_LOG_ERROR, "Failed to allocate decompression buffer\n");
         return AVERROR(ENOMEM);
@@ -92,21 +92,31 @@ static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in
 
     strm.avail_in  = in_len;
     strm.next_in   = in;
-    strm.avail_out = chunk;
-    strm.next_out  = buf;
 
-    ret = inflate(&strm, Z_FINISH);
-    if (ret != Z_OK && ret != Z_STREAM_END) {
-        av_log(ctx, AV_LOG_ERROR, "Inflate failed: %d, %s\n", ret, strm.msg);
-        inflateEnd(&strm);
-        av_free(buf);
-        return (ret == Z_STREAM_END) ? Z_OK : ((ret == Z_OK) ? Z_BUF_ERROR : ret);
-    }
+    do {
+        strm.avail_out = chunk - strm.total_out;
+        strm.next_out  = buf + strm.total_out;
 
-    if (strm.avail_out == 0) {
-        // TODO: Error or loop decoding?
-        av_log(ctx, AV_LOG_WARNING, "Decompression buffer may be too small\n");
-    }
+        ret = inflate(&strm, Z_FINISH);
+        if (ret != Z_OK && ret != Z_STREAM_END && ret != Z_BUF_ERROR) {
+            av_log(ctx, AV_LOG_ERROR, "Inflate failed: %d, %s\n", ret, strm.msg);
+            inflateEnd(&strm);
+            av_free(buf);
+            return AVERROR(EINVAL);
+        }
+
+        if (strm.avail_out == 0) {
+            chunk *= 8;
+            uint8_t *tmp_buf = av_realloc(buf, chunk + 1);
+            if (!tmp_buf) {
+                inflateEnd(&strm);
+                av_free(buf);
+                return AVERROR(ENOMEM);
+            }
+
+            buf = tmp_buf;
+        }
+    } while (ret != Z_STREAM_END);
 
     *out_len = chunk - strm.avail_out;
     buf[*out_len] = 0; // Ensure null termination
-- 
ffmpeg-codebot
_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with increasing buffer size
  2025-05-31  1:50 ` [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with increasing buffer size softworkz
@ 2025-05-31  2:38   ` Kieran Kunhya via ffmpeg-devel
  2025-05-31  2:45     ` softworkz .
  0 siblings, 1 reply; 12+ messages in thread
From: Kieran Kunhya via ffmpeg-devel @ 2025-05-31  2:38 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Kieran Kunhya

>
>         }
> +
> +        if (strm.avail_out == 0) {
> +            chunk *= 8;
>


*8 seems high

+            uint8_t *tmp_buf = av_realloc(buf, chunk + 1);
> +            if (!tmp_buf) {
> +                inflateEnd(&strm);
> +                av_free(buf);
> +                return AVERROR(ENOMEM);
> +            }
> +
> +            buf = tmp_buf;
> +        }
> +    } while (ret != Z_STREAM_END);
>
>      *out_len = chunk - strm.avail_out;
>      buf[*out_len] = 0; // Ensure null termination
> --
> ffmpeg-codebot
> _______________________________________________
> 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".
>
_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with increasing buffer size
  2025-05-31  2:38   ` Kieran Kunhya via ffmpeg-devel
@ 2025-05-31  2:45     ` softworkz .
  2025-05-31  3:57       ` softworkz .
  0 siblings, 1 reply; 12+ messages in thread
From: softworkz . @ 2025-05-31  2:45 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Kieran Kunhya



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Kieran
> Kunhya via ffmpeg-devel
> Sent: Samstag, 31. Mai 2025 04:39
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Cc: Kieran Kunhya <kieran618@googlemail.com>
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with
> increasing buffer size
> 
> >
> >         }
> > +
> > +        if (strm.avail_out == 0) {
> > +            chunk *= 8;
> >
> 
> 
> *8 seems high

This would use 512kB when 64kB doesn't suffice. We're far away
from 64kB, so it's just hypothetical.
But granted - this happens usually just once during runtime for
a resource and memory is more valuable than the inflate CPU cost,
so I'm inclined to agree.

2* or 4* ?


Regards,
sw
_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with increasing buffer size
  2025-05-31  2:45     ` softworkz .
@ 2025-05-31  3:57       ` softworkz .
  0 siblings, 0 replies; 12+ messages in thread
From: softworkz . @ 2025-05-31  3:57 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Kieran Kunhya



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of softworkz .
> Sent: Samstag, 31. Mai 2025 04:46
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Cc: Kieran Kunhya <kieran618@googlemail.com>
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with
> increasing buffer size
> 
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Kieran
> > Kunhya via ffmpeg-devel
> > Sent: Samstag, 31. Mai 2025 04:39
> > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> > Cc: Kieran Kunhya <kieran618@googlemail.com>
> > Subject: Re: [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop
> with
> > increasing buffer size
> >
> > >
> > >         }
> > > +
> > > +        if (strm.avail_out == 0) {
> > > +            chunk *= 8;
> > >
> >
> >
> > *8 seems high
> 
> This would use 512kB when 64kB doesn't suffice. We're far away
> from 64kB, so it's just hypothetical.
> But granted - this happens usually just once during runtime for
> a resource and memory is more valuable than the inflate CPU cost,
> so I'm inclined to agree.
> 
> 2* or 4* ?
> 
> 
> Regards,
> sw
> _______________________________________________

Scratch that. Let's make it perfect instead. 

Please see V2.

Thanks
sw
_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH v2 0/2] fftools/resman: remove redundant includes, use inflate loop
  2025-05-31  1:50 [FFmpeg-devel] [PATCH 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
  2025-05-31  1:50 ` [FFmpeg-devel] [PATCH 1/2] fftools/resman: remove unused includes, fix declaration softworkz
  2025-05-31  1:50 ` [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with increasing buffer size softworkz
@ 2025-05-31  3:58 ` ffmpegagent
  2025-05-31  3:58   ` [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused includes, fix declaration softworkz
  2025-05-31  3:58   ` [FFmpeg-devel] [PATCH v2 2/2] fftools/resman: uncompress to actual-size memory buffers softworkz
  2 siblings, 2 replies; 12+ messages in thread
From: ffmpegagent @ 2025-05-31  3:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

and other cosmetic fixes.

As per review by Ramiro Polla in message: "Re: [FFmpeg-devel]
[FFmpeg-cvslog] fftools/resources: Add resource manager files with
build-time compression"

V2

 * Use two-pass decompression to return resources in actual-size memory
   buffers
   (in response to comment by Kieran)

.

softworkz (2):
  fftools/resman: remove unused includes, fix declaration
  fftools/resman: uncompress to actual-size memory buffers

 fftools/resources/resman.c | 56 ++++++++++++++++++++++++++------------
 fftools/resources/resman.h | 10 +------
 2 files changed, 39 insertions(+), 27 deletions(-)


base-commit: 27c5e4b39afb272638ab907a710e7db4f867266d
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-90%2Fsoftworkz%2Fsubmit_resman_fixes-v2
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-90/softworkz/submit_resman_fixes-v2
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/90

Range-diff vs v1:

 1:  4d7af186ce = 1:  4d7af186ce fftools/resman: remove unused includes, fix declaration
 2:  48fc3a6810 ! 2:  32cd61ebd4 fftools/resman: use inflate loop with increasing buffer size
     @@ Metadata
      Author: softworkz <softworkz@hotmail.com>
      
       ## Commit message ##
     -    fftools/resman: use inflate loop with increasing buffer size
     +    fftools/resman: uncompress to actual-size memory buffers
      
          Signed-off-by: softworkz <softworkz@hotmail.com>
      
       ## fftools/resources/resman.c ##
     -@@ fftools/resources/resman.c: static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in
     -     memset(&strm, 0, sizeof(strm));
     +@@ fftools/resources/resman.c: static ResourceManagerContext *resman_ctx = NULL;
     + 
     + static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in_len, char **out, size_t *out_len)
     + {
     +-    z_stream strm;
     +-    unsigned chunk = 65534;
     ++    z_stream strm = { 0 };
     ++    uint8_t dummy[4096];
     ++    size_t uncompressed_size;
     +     int ret;
     +     uint8_t *buf;
     + 
     +     *out = NULL;
     +-    memset(&strm, 0, sizeof(strm));
     ++
     ++    // 15 + 16 tells zlib to detect GZIP or zlib automatically
     ++    ret = inflateInit2(&strm, 15 + 16);
     ++    if (ret != Z_OK) {
     ++        av_log(ctx, AV_LOG_ERROR, "Error during zlib initialization: %s\n", strm.msg);
     ++        return AVERROR(ENOSYS);
     ++    }
     ++
     ++    strm.avail_in  = in_len;
     ++    strm.next_in   = in;
     ++
     ++    do {
     ++        strm.avail_out = sizeof(dummy);
     ++        strm.next_out  = dummy;
     ++
     ++        ret = inflate(&strm, Z_NO_FLUSH);
     ++        if (ret != Z_OK && ret != Z_STREAM_END) {
     ++            av_log(ctx, AV_LOG_ERROR, "Inflate failed (1): %d, %s\n", ret, strm.msg);
     ++            inflateEnd(&strm);
     ++            return AVERROR(EINVAL);
     ++        }
     ++    } while (ret != Z_STREAM_END);
     ++
     ++    uncompressed_size = strm.total_out;
       
           // Allocate output buffer with extra byte for null termination
      -    buf = av_mallocz(chunk + 1);
     -+    buf = av_realloc(NULL, chunk + 1);
     ++    buf = av_mallocz(uncompressed_size + 1);
           if (!buf) {
               av_log(ctx, AV_LOG_ERROR, "Failed to allocate decompression buffer\n");
     ++        inflateEnd(&strm);
               return AVERROR(ENOMEM);
     -@@ fftools/resources/resman.c: static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in
     +     }
     + 
     +-    // 15 + 16 tells zlib to detect GZIP or zlib automatically
     +-    ret = inflateInit2(&strm, 15 + 16);
     ++    ret = inflateReset(&strm);
     +     if (ret != Z_OK) {
     +-        av_log(ctx, AV_LOG_ERROR, "Error during zlib initialization: %s\n", strm.msg);
     ++        av_log(ctx, AV_LOG_ERROR, "inflateReset failed: %s\n", strm.msg);
     +         av_free(buf);
     +         return AVERROR(ENOSYS);
     +     }
       
           strm.avail_in  = in_len;
           strm.next_in   = in;
      -    strm.avail_out = chunk;
     --    strm.next_out  = buf;
     ++    strm.avail_out = uncompressed_size;
     +     strm.next_out  = buf;
       
     --    ret = inflate(&strm, Z_FINISH);
     --    if (ret != Z_OK && ret != Z_STREAM_END) {
     +     ret = inflate(&strm, Z_FINISH);
     +     if (ret != Z_OK && ret != Z_STREAM_END) {
      -        av_log(ctx, AV_LOG_ERROR, "Inflate failed: %d, %s\n", ret, strm.msg);
     --        inflateEnd(&strm);
     --        av_free(buf);
     ++        av_log(ctx, AV_LOG_ERROR, "Inflate failed (2): %d, %s\n", ret, strm.msg);
     +         inflateEnd(&strm);
     +         av_free(buf);
      -        return (ret == Z_STREAM_END) ? Z_OK : ((ret == Z_OK) ? Z_BUF_ERROR : ret);
     --    }
     -+    do {
     -+        strm.avail_out = chunk - strm.total_out;
     -+        strm.next_out  = buf + strm.total_out;
     ++        return AVERROR(EINVAL);
     +     }
       
      -    if (strm.avail_out == 0) {
      -        // TODO: Error or loop decoding?
      -        av_log(ctx, AV_LOG_WARNING, "Decompression buffer may be too small\n");
      -    }
     -+        ret = inflate(&strm, Z_FINISH);
     -+        if (ret != Z_OK && ret != Z_STREAM_END && ret != Z_BUF_ERROR) {
     -+            av_log(ctx, AV_LOG_ERROR, "Inflate failed: %d, %s\n", ret, strm.msg);
     -+            inflateEnd(&strm);
     -+            av_free(buf);
     -+            return AVERROR(EINVAL);
     -+        }
     -+
     -+        if (strm.avail_out == 0) {
     -+            chunk *= 8;
     -+            uint8_t *tmp_buf = av_realloc(buf, chunk + 1);
     -+            if (!tmp_buf) {
     -+                inflateEnd(&strm);
     -+                av_free(buf);
     -+                return AVERROR(ENOMEM);
     -+            }
     -+
     -+            buf = tmp_buf;
     -+        }
     -+    } while (ret != Z_STREAM_END);
     ++    av_assert0(strm.avail_out == 0);
       
     -     *out_len = chunk - strm.avail_out;
     +-    *out_len = chunk - strm.avail_out;
     ++    *out_len = uncompressed_size;
           buf[*out_len] = 0; // Ensure null termination
     + 
     +     inflateEnd(&strm);

-- 
ffmpeg-codebot
_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused includes, fix declaration
  2025-05-31  3:58 ` [FFmpeg-devel] [PATCH v2 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
@ 2025-05-31  3:58   ` softworkz
  2025-06-02  1:28     ` Michael Niedermayer
  2025-05-31  3:58   ` [FFmpeg-devel] [PATCH v2 2/2] fftools/resman: uncompress to actual-size memory buffers softworkz
  1 sibling, 1 reply; 12+ messages in thread
From: softworkz @ 2025-05-31  3:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/resources/resman.c |  7 +++----
 fftools/resources/resman.h | 10 +---------
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/fftools/resources/resman.c b/fftools/resources/resman.c
index a9e21626fa..f098bd6687 100644
--- a/fftools/resources/resman.c
+++ b/fftools/resources/resman.c
@@ -34,7 +34,6 @@
 #include "resman.h"
 #include "fftools/ffmpeg_filter.h"
 #include "libavutil/avassert.h"
-#include "libavutil/pixdesc.h"
 #include "libavutil/dict.h"
 #include "libavutil/common.h"
 
@@ -61,7 +60,7 @@ typedef struct ResourceManagerContext {
 
 static AVMutex mutex = AV_MUTEX_INITIALIZER;
 
-ResourceManagerContext *resman_ctx = NULL;
+static ResourceManagerContext *resman_ctx = NULL;
 
 
 #if CONFIG_RESOURCE_COMPRESSION
@@ -77,7 +76,7 @@ static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in
     memset(&strm, 0, sizeof(strm));
 
     // Allocate output buffer with extra byte for null termination
-    buf = (uint8_t *)av_mallocz(chunk + 1);
+    buf = av_mallocz(chunk + 1);
     if (!buf) {
         av_log(ctx, AV_LOG_ERROR, "Failed to allocate decompression buffer\n");
         return AVERROR(ENOMEM);
@@ -156,7 +155,7 @@ void ff_resman_uninit(void)
 }
 
 
-char *ff_resman_get_string(FFResourceId resource_id)
+const char *ff_resman_get_string(FFResourceId resource_id)
 {
     ResourceManagerContext *ctx               = get_resman_context();
     FFResourceDefinition resource_definition = { 0 };
diff --git a/fftools/resources/resman.h b/fftools/resources/resman.h
index 6485db5091..dfe6b324e4 100644
--- a/fftools/resources/resman.h
+++ b/fftools/resources/resman.h
@@ -21,14 +21,6 @@
 #ifndef FFTOOLS_RESOURCES_RESMAN_H
 #define FFTOOLS_RESOURCES_RESMAN_H
 
-#include <stdint.h>
-
-#include "config.h"
-#include "fftools/ffmpeg.h"
-#include "libavutil/avutil.h"
-#include "libavutil/bprint.h"
-#include "fftools/textformat/avtextformat.h"
-
 typedef enum {
     FF_RESOURCE_GRAPH_CSS,
     FF_RESOURCE_GRAPH_HTML,
@@ -45,6 +37,6 @@ typedef struct FFResourceDefinition {
 
 void ff_resman_uninit(void);
 
-char *ff_resman_get_string(FFResourceId resource_id);
+const char *ff_resman_get_string(FFResourceId resource_id);
 
 #endif /* FFTOOLS_RESOURCES_RESMAN_H */
-- 
ffmpeg-codebot

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH v2 2/2] fftools/resman: uncompress to actual-size memory buffers
  2025-05-31  3:58 ` [FFmpeg-devel] [PATCH v2 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
  2025-05-31  3:58   ` [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused includes, fix declaration softworkz
@ 2025-05-31  3:58   ` softworkz
  1 sibling, 0 replies; 12+ messages in thread
From: softworkz @ 2025-05-31  3:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/resources/resman.c | 51 +++++++++++++++++++++++++++-----------
 1 file changed, 36 insertions(+), 15 deletions(-)

diff --git a/fftools/resources/resman.c b/fftools/resources/resman.c
index f098bd6687..e3e082abbf 100644
--- a/fftools/resources/resman.c
+++ b/fftools/resources/resman.c
@@ -67,48 +67,69 @@ static ResourceManagerContext *resman_ctx = NULL;
 
 static int decompress_gzip(ResourceManagerContext *ctx, uint8_t *in, unsigned in_len, char **out, size_t *out_len)
 {
-    z_stream strm;
-    unsigned chunk = 65534;
+    z_stream strm = { 0 };
+    uint8_t dummy[4096];
+    size_t uncompressed_size;
     int ret;
     uint8_t *buf;
 
     *out = NULL;
-    memset(&strm, 0, sizeof(strm));
+
+    // 15 + 16 tells zlib to detect GZIP or zlib automatically
+    ret = inflateInit2(&strm, 15 + 16);
+    if (ret != Z_OK) {
+        av_log(ctx, AV_LOG_ERROR, "Error during zlib initialization: %s\n", strm.msg);
+        return AVERROR(ENOSYS);
+    }
+
+    strm.avail_in  = in_len;
+    strm.next_in   = in;
+
+    do {
+        strm.avail_out = sizeof(dummy);
+        strm.next_out  = dummy;
+
+        ret = inflate(&strm, Z_NO_FLUSH);
+        if (ret != Z_OK && ret != Z_STREAM_END) {
+            av_log(ctx, AV_LOG_ERROR, "Inflate failed (1): %d, %s\n", ret, strm.msg);
+            inflateEnd(&strm);
+            return AVERROR(EINVAL);
+        }
+    } while (ret != Z_STREAM_END);
+
+    uncompressed_size = strm.total_out;
 
     // Allocate output buffer with extra byte for null termination
-    buf = av_mallocz(chunk + 1);
+    buf = av_mallocz(uncompressed_size + 1);
     if (!buf) {
         av_log(ctx, AV_LOG_ERROR, "Failed to allocate decompression buffer\n");
+        inflateEnd(&strm);
         return AVERROR(ENOMEM);
     }
 
-    // 15 + 16 tells zlib to detect GZIP or zlib automatically
-    ret = inflateInit2(&strm, 15 + 16);
+    ret = inflateReset(&strm);
     if (ret != Z_OK) {
-        av_log(ctx, AV_LOG_ERROR, "Error during zlib initialization: %s\n", strm.msg);
+        av_log(ctx, AV_LOG_ERROR, "inflateReset failed: %s\n", strm.msg);
         av_free(buf);
         return AVERROR(ENOSYS);
     }
 
     strm.avail_in  = in_len;
     strm.next_in   = in;
-    strm.avail_out = chunk;
+    strm.avail_out = uncompressed_size;
     strm.next_out  = buf;
 
     ret = inflate(&strm, Z_FINISH);
     if (ret != Z_OK && ret != Z_STREAM_END) {
-        av_log(ctx, AV_LOG_ERROR, "Inflate failed: %d, %s\n", ret, strm.msg);
+        av_log(ctx, AV_LOG_ERROR, "Inflate failed (2): %d, %s\n", ret, strm.msg);
         inflateEnd(&strm);
         av_free(buf);
-        return (ret == Z_STREAM_END) ? Z_OK : ((ret == Z_OK) ? Z_BUF_ERROR : ret);
+        return AVERROR(EINVAL);
     }
 
-    if (strm.avail_out == 0) {
-        // TODO: Error or loop decoding?
-        av_log(ctx, AV_LOG_WARNING, "Decompression buffer may be too small\n");
-    }
+    av_assert0(strm.avail_out == 0);
 
-    *out_len = chunk - strm.avail_out;
+    *out_len = uncompressed_size;
     buf[*out_len] = 0; // Ensure null termination
 
     inflateEnd(&strm);
-- 
ffmpeg-codebot
_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused includes, fix declaration
  2025-05-31  3:58   ` [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused includes, fix declaration softworkz
@ 2025-06-02  1:28     ` Michael Niedermayer
  2025-06-02  1:42       ` softworkz .
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Niedermayer @ 2025-06-02  1:28 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1513 bytes --]

Hi softworkz

On Sat, May 31, 2025 at 03:58:44AM +0000, softworkz wrote:
> From: softworkz <softworkz@hotmail.com>
> 
> Signed-off-by: softworkz <softworkz@hotmail.com>
> ---
>  fftools/resources/resman.c |  7 +++----
>  fftools/resources/resman.h | 10 +---------
>  2 files changed, 4 insertions(+), 13 deletions(-)

seems to breaks build

fftools/resources/resman.c:60:8: error: unknown type name ‘AVMutex’
   60 | static AVMutex mutex = AV_MUTEX_INITIALIZER;
      |        ^~~~~~~
fftools/resources/resman.c:60:24: error: ‘AV_MUTEX_INITIALIZER’ undeclared here (not in a function)
   60 | static AVMutex mutex = AV_MUTEX_INITIALIZER;
      |                        ^~~~~~~~~~~~~~~~~~~~
fftools/resources/resman.c: In function ‘get_resman_context’:
fftools/resources/resman.c:123:5: error: implicit declaration of function ‘ff_mutex_lock’ [-Werror=implicit-function-declaration]
  123 |     ff_mutex_lock(&mutex);
      |     ^~~~~~~~~~~~~
fftools/resources/resman.c:138:5: error: implicit declaration of function ‘ff_mutex_unlock’ [-Werror=implicit-function-declaration]
  138 |     ff_mutex_unlock(&mutex);
      |     ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make: *** [ffbuild/common.mak:81: fftools/resources/resman.o] Error 1
make: *** Waiting for unfinished jobs....


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

No great genius has ever existed without some touch of madness. -- Aristotle

[-- 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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused includes, fix declaration
  2025-06-02  1:28     ` Michael Niedermayer
@ 2025-06-02  1:42       ` softworkz .
  2025-06-02  3:28         ` softworkz .
  0 siblings, 1 reply; 12+ messages in thread
From: softworkz . @ 2025-06-02  1:42 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Michael
> Niedermayer
> Sent: Montag, 2. Juni 2025 03:28
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused
> includes, fix declaration
> 
> Hi softworkz
> 
> On Sat, May 31, 2025 at 03:58:44AM +0000, softworkz wrote:
> > From: softworkz <softworkz@hotmail.com>
> >
> > Signed-off-by: softworkz <softworkz@hotmail.com>
> > ---
> >  fftools/resources/resman.c |  7 +++----
> >  fftools/resources/resman.h | 10 +---------
> >  2 files changed, 4 insertions(+), 13 deletions(-)
> 
> seems to breaks build
> 
> fftools/resources/resman.c:60:8: error: unknown type name ‘AVMutex’
>    60 | static AVMutex mutex = AV_MUTEX_INITIALIZER;
>       |        ^~~~~~~
> fftools/resources/resman.c:60:24: error: ‘AV_MUTEX_INITIALIZER’ undeclared
> here (not in a function)
>    60 | static AVMutex mutex = AV_MUTEX_INITIALIZER;
>       |                        ^~~~~~~~~~~~~~~~~~~~
> fftools/resources/resman.c: In function ‘get_resman_context’:
> fftools/resources/resman.c:123:5: error: implicit declaration of function
> ‘ff_mutex_lock’ [-Werror=implicit-function-declaration]
>   123 |     ff_mutex_lock(&mutex);
>       |     ^~~~~~~~~~~~~
> fftools/resources/resman.c:138:5: error: implicit declaration of function
> ‘ff_mutex_unlock’ [-Werror=implicit-function-declaration]
>   138 |     ff_mutex_unlock(&mutex);
>       |     ^~~~~~~~~~~~~~~
> cc1: some warnings being treated as errors
> make: *** [ffbuild/common.mak:81: fftools/resources/resman.o] Error 1
> make: *** Waiting for unfinished jobs....
> 
> 
> [...]
> --

Thanks!

Seems it got broken due to changes in master. On submission,
all builds were successful:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/4d7af186ce9f8a8d3b12cdc2c979ea54320eed96.1748663925.git.ffmpegagent@gmail.com/

Will post an update.

Thanks
sw

_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused includes, fix declaration
  2025-06-02  1:42       ` softworkz .
@ 2025-06-02  3:28         ` softworkz .
  0 siblings, 0 replies; 12+ messages in thread
From: softworkz . @ 2025-06-02  3:28 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of softworkz .
> Sent: Montag, 2. Juni 2025 03:43
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused
> includes, fix declaration
> 
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Michael
> > Niedermayer
> > Sent: Montag, 2. Juni 2025 03:28
> > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused
> > includes, fix declaration
> >
> > Hi softworkz
> >
> > On Sat, May 31, 2025 at 03:58:44AM +0000, softworkz wrote:
> > > From: softworkz <softworkz@hotmail.com>
> > >
> > > Signed-off-by: softworkz <softworkz@hotmail.com>
> > > ---
> > >  fftools/resources/resman.c |  7 +++----
> > >  fftools/resources/resman.h | 10 +---------
> > >  2 files changed, 4 insertions(+), 13 deletions(-)
> >
> > seems to breaks build
> >
> > fftools/resources/resman.c:60:8: error: unknown type name ‘AVMutex’
> >    60 | static AVMutex mutex = AV_MUTEX_INITIALIZER;
> >       |        ^~~~~~~
> > fftools/resources/resman.c:60:24: error: ‘AV_MUTEX_INITIALIZER’ undeclared
> > here (not in a function)
> >    60 | static AVMutex mutex = AV_MUTEX_INITIALIZER;
> >       |                        ^~~~~~~~~~~~~~~~~~~~
> > fftools/resources/resman.c: In function ‘get_resman_context’:
> > fftools/resources/resman.c:123:5: error: implicit declaration of function
> > ‘ff_mutex_lock’ [-Werror=implicit-function-declaration]
> >   123 |     ff_mutex_lock(&mutex);
> >       |     ^~~~~~~~~~~~~
> > fftools/resources/resman.c:138:5: error: implicit declaration of function
> > ‘ff_mutex_unlock’ [-Werror=implicit-function-declaration]
> >   138 |     ff_mutex_unlock(&mutex);
> >       |     ^~~~~~~~~~~~~~~
> > cc1: some warnings being treated as errors
> > make: *** [ffbuild/common.mak:81: fftools/resources/resman.o] Error 1
> > make: *** Waiting for unfinished jobs....
> >
> >
> > [...]
> > --
> 
> Thanks!
> 
> Seems it got broken due to changes in master. On submission,
> all builds were successful:
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/4d7af186ce9f8a8d3b12cdc2c979
> ea54320eed96.1748663925.git.ffmpegagent@gmail.com/
> 
> Will post an update.
> _______________________________________________

No I won't. This set is obsolete and superseded by
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=14663

sw
_______________________________________________
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] 12+ messages in thread

end of thread, other threads:[~2025-06-02  3:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-31  1:50 [FFmpeg-devel] [PATCH 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
2025-05-31  1:50 ` [FFmpeg-devel] [PATCH 1/2] fftools/resman: remove unused includes, fix declaration softworkz
2025-05-31  1:50 ` [FFmpeg-devel] [PATCH 2/2] fftools/resman: use inflate loop with increasing buffer size softworkz
2025-05-31  2:38   ` Kieran Kunhya via ffmpeg-devel
2025-05-31  2:45     ` softworkz .
2025-05-31  3:57       ` softworkz .
2025-05-31  3:58 ` [FFmpeg-devel] [PATCH v2 0/2] fftools/resman: remove redundant includes, use inflate loop ffmpegagent
2025-05-31  3:58   ` [FFmpeg-devel] [PATCH v2 1/2] fftools/resman: remove unused includes, fix declaration softworkz
2025-06-02  1:28     ` Michael Niedermayer
2025-06-02  1:42       ` softworkz .
2025-06-02  3:28         ` softworkz .
2025-05-31  3:58   ` [FFmpeg-devel] [PATCH v2 2/2] fftools/resman: uncompress to actual-size memory buffers softworkz

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