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 1/4] avcodec/ass: Faster ff_ass_add_rect()
@ 2021-12-17 21:51 Michael Niedermayer
  2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: Use ff_ass_add_rect2() Michael Niedermayer
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Michael Niedermayer @ 2021-12-17 21:51 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/ass.c | 32 ++++++++++++++++++++++++++------
 libavcodec/ass.h |  7 +++++++
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/libavcodec/ass.c b/libavcodec/ass.c
index 725e4d42ba1..d0a4d678bb4 100644
--- a/libavcodec/ass.c
+++ b/libavcodec/ass.c
@@ -114,17 +114,30 @@ char *ff_ass_get_dialog(int readorder, int layer, const char *style,
                        speaker ? speaker : "", text);
 }
 
-int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
+int ff_ass_add_rect2(AVSubtitle *sub, const char *dialog,
                     int readorder, int layer, const char *style,
-                    const char *speaker)
+                    const char *speaker, size_t *nb_rect_allocated)
 {
-    AVSubtitleRect **rects, *rect;
+    AVSubtitleRect **rects = sub->rects, *rect;
     char *ass_str;
+    uint64_t new_nb = 0;
 
-    rects = av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*sub->rects));
-    if (!rects)
+    if (nb_rect_allocated && *nb_rect_allocated <= sub->num_rects) {
+        new_nb = sub->num_rects + sub->num_rects/16LL + 1;
+    } else if (!nb_rect_allocated)
+        new_nb = sub->num_rects + 1LL;
+    if (new_nb > SIZE_MAX)
         return AVERROR(ENOMEM);
-    sub->rects = rects;
+
+    if (new_nb) {
+        rects = av_realloc_array(rects, new_nb, sizeof(*sub->rects));
+        if (!rects)
+            return AVERROR(ENOMEM);
+        if (nb_rect_allocated)
+            *nb_rect_allocated = new_nb;
+        sub->rects = rects;
+    }
+
     rect       = av_mallocz(sizeof(*rect));
     if (!rect)
         return AVERROR(ENOMEM);
@@ -137,6 +150,13 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
     return 0;
 }
 
+int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
+                    int readorder, int layer, const char *style,
+                    const char *speaker)
+{
+    return ff_ass_add_rect2(sub, dialog, readorder, layer, style, speaker, NULL);
+}
+
 void ff_ass_decoder_flush(AVCodecContext *avctx)
 {
     FFASSDecoderContext *s = avctx->priv_data;
diff --git a/libavcodec/ass.h b/libavcodec/ass.h
index 2c260e4e785..784f46c42c5 100644
--- a/libavcodec/ass.h
+++ b/libavcodec/ass.h
@@ -118,6 +118,13 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
                     int readorder, int layer, const char *style,
                     const char *speaker);
 
+/**
+ * Add an ASS dialog to a subtitle.
+ */
+int ff_ass_add_rect2(AVSubtitle *sub, const char *dialog,
+                     int readorder, int layer, const char *style,
+                     const char *speaker, size_t *nb_rect_allocated);
+
 /**
  * Helper to flush a text subtitles decoder making use of the
  * FFASSDecoderContext.
-- 
2.17.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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: Use ff_ass_add_rect2()
  2021-12-17 21:51 [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Michael Niedermayer
@ 2021-12-17 21:51 ` Michael Niedermayer
  2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 3/4] avcodec/tiff: Pass max_pixels to mjpeg context Michael Niedermayer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Michael Niedermayer @ 2021-12-17 21:51 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Fixes: Timeout
Fixes: 42258/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CCAPTION_fuzzer-5540144118104064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/ccaption_dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 27c61527f6e..2cd5b0aef0d 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -850,6 +850,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
     int len = avpkt->size;
     int ret = 0;
     int i;
+    size_t nb_rect_allocated = 0;
 
     for (i = 0; i < len; i += 3) {
         uint8_t hi, cc_type = bptr[i] & 1;
@@ -886,7 +887,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
                                                      AV_TIME_BASE_Q, ms_tb);
             else
                 sub->end_display_time = -1;
-            ret = ff_ass_add_rect(sub, ctx->buffer[bidx].str, ctx->readorder++, 0, NULL, NULL);
+            ret = ff_ass_add_rect2(sub, ctx->buffer[bidx].str, ctx->readorder++, 0, NULL, NULL, &nb_rect_allocated);
             if (ret < 0)
                 return ret;
             ctx->last_real_time = sub->pts;
-- 
2.17.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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH 3/4] avcodec/tiff: Pass max_pixels to mjpeg context
  2021-12-17 21:51 [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Michael Niedermayer
  2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: Use ff_ass_add_rect2() Michael Niedermayer
@ 2021-12-17 21:51 ` Michael Niedermayer
  2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions Michael Niedermayer
  2021-12-17 22:15 ` [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Andreas Rheinhardt
  3 siblings, 0 replies; 11+ messages in thread
From: Michael Niedermayer @ 2021-12-17 21:51 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/tiff.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 870e0666aa3..9af602eef70 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -2155,6 +2155,7 @@ static av_cold int tiff_init(AVCodecContext *avctx)
     s->avctx_mjpeg->flags2 = avctx->flags2;
     s->avctx_mjpeg->dct_algo = avctx->dct_algo;
     s->avctx_mjpeg->idct_algo = avctx->idct_algo;
+    s->avctx_mjpeg->max_pixels = avctx->max_pixels;
     ret = avcodec_open2(s->avctx_mjpeg, codec, NULL);
     if (ret < 0) {
         return ret;
-- 
2.17.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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions
  2021-12-17 21:51 [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Michael Niedermayer
  2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: Use ff_ass_add_rect2() Michael Niedermayer
  2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 3/4] avcodec/tiff: Pass max_pixels to mjpeg context Michael Niedermayer
@ 2021-12-17 21:51 ` Michael Niedermayer
  2021-12-20  9:51   ` Anton Khirnov
  2021-12-17 22:15 ` [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Andreas Rheinhardt
  3 siblings, 1 reply; 11+ messages in thread
From: Michael Niedermayer @ 2021-12-17 21:51 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Fixes: OOM
Fixes: 42263/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5653333619113984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/tiff.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 9af602eef70..60773d59ed0 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -724,13 +724,14 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame,
 static int dng_decode_strip(AVCodecContext *avctx, AVFrame *frame)
 {
     TiffContext *s = avctx->priv_data;
+    int ret = ff_set_dimensions(s->avctx_mjpeg, s->width, s->height);
+
+    if (ret < 0)
+        return ret;
 
     s->jpgframe->width  = s->width;
     s->jpgframe->height = s->height;
 
-    s->avctx_mjpeg->width = s->width;
-    s->avctx_mjpeg->height = s->height;
-
     return dng_decode_jpeg(avctx, frame, s->stripsize, 0, 0, s->width, s->height);
 }
 
@@ -971,14 +972,14 @@ static int dng_decode_tiles(AVCodecContext *avctx, AVFrame *frame,
     int has_width_leftover, has_height_leftover;
     int tile_x = 0, tile_y = 0;
     int pos_x = 0, pos_y = 0;
-    int ret;
+    int ret = ff_set_dimensions(s->avctx_mjpeg, s->tile_width, s->tile_length);
+
+    if (ret < 0)
+        return ret;
 
     s->jpgframe->width  = s->tile_width;
     s->jpgframe->height = s->tile_length;
 
-    s->avctx_mjpeg->width = s->tile_width;
-    s->avctx_mjpeg->height = s->tile_length;
-
     has_width_leftover = (s->width % s->tile_width != 0);
     has_height_leftover = (s->height % s->tile_length != 0);
 
-- 
2.17.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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect()
  2021-12-17 21:51 [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Michael Niedermayer
                   ` (2 preceding siblings ...)
  2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions Michael Niedermayer
@ 2021-12-17 22:15 ` Andreas Rheinhardt
  2021-12-18 14:27   ` Michael Niedermayer
  3 siblings, 1 reply; 11+ messages in thread
From: Andreas Rheinhardt @ 2021-12-17 22:15 UTC (permalink / raw)
  To: ffmpeg-devel

Michael Niedermayer:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ass.c | 32 ++++++++++++++++++++++++++------
>  libavcodec/ass.h |  7 +++++++
>  2 files changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/ass.c b/libavcodec/ass.c
> index 725e4d42ba1..d0a4d678bb4 100644
> --- a/libavcodec/ass.c
> +++ b/libavcodec/ass.c
> @@ -114,17 +114,30 @@ char *ff_ass_get_dialog(int readorder, int layer, const char *style,
>                         speaker ? speaker : "", text);
>  }
>  
> -int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
> +int ff_ass_add_rect2(AVSubtitle *sub, const char *dialog,
>                      int readorder, int layer, const char *style,
> -                    const char *speaker)
> +                    const char *speaker, size_t *nb_rect_allocated)
>  {
> -    AVSubtitleRect **rects, *rect;
> +    AVSubtitleRect **rects = sub->rects, *rect;
>      char *ass_str;
> +    uint64_t new_nb = 0;
>  
> -    rects = av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*sub->rects));
> -    if (!rects)
> +    if (nb_rect_allocated && *nb_rect_allocated <= sub->num_rects) {
> +        new_nb = sub->num_rects + sub->num_rects/16LL + 1;
> +    } else if (!nb_rect_allocated)
> +        new_nb = sub->num_rects + 1LL;
> +    if (new_nb > SIZE_MAX)
>          return AVERROR(ENOMEM);

AVSubtitle.num_rects is unsigned, so this number should always be
bounded by UINT_MAX (and nb_rect_allocated can be a pointer to unsigned,
too).
(Feels like I should resurrect my old av_fast_realloc_array:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200101132758.4452-1-andreas.rheinhardt@gmail.com/)

> -    sub->rects = rects;
> +
> +    if (new_nb) {
> +        rects = av_realloc_array(rects, new_nb, sizeof(*sub->rects));
> +        if (!rects)
> +            return AVERROR(ENOMEM);
> +        if (nb_rect_allocated)
> +            *nb_rect_allocated = new_nb;
> +        sub->rects = rects;
> +    }
> +
>      rect       = av_mallocz(sizeof(*rect));
>      if (!rect)
>          return AVERROR(ENOMEM);
> @@ -137,6 +150,13 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
>      return 0;
>  }
>  
> +int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
> +                    int readorder, int layer, const char *style,
> +                    const char *speaker)
> +{
> +    return ff_ass_add_rect2(sub, dialog, readorder, layer, style, speaker, NULL);
> +}
> +
>  void ff_ass_decoder_flush(AVCodecContext *avctx)
>  {
>      FFASSDecoderContext *s = avctx->priv_data;
> diff --git a/libavcodec/ass.h b/libavcodec/ass.h
> index 2c260e4e785..784f46c42c5 100644
> --- a/libavcodec/ass.h
> +++ b/libavcodec/ass.h
> @@ -118,6 +118,13 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
>                      int readorder, int layer, const char *style,
>                      const char *speaker);
>  
> +/**
> + * Add an ASS dialog to a subtitle.
> + */
> +int ff_ass_add_rect2(AVSubtitle *sub, const char *dialog,
> +                     int readorder, int layer, const char *style,
> +                     const char *speaker, size_t *nb_rect_allocated);
> +
>  /**
>   * Helper to flush a text subtitles decoder making use of the
>   * FFASSDecoderContext.
> 

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

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect()
  2021-12-17 22:15 ` [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Andreas Rheinhardt
@ 2021-12-18 14:27   ` Michael Niedermayer
  2021-12-18 16:21     ` Andreas Rheinhardt
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Niedermayer @ 2021-12-18 14:27 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


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

On Fri, Dec 17, 2021 at 11:15:06PM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/ass.c | 32 ++++++++++++++++++++++++++------
> >  libavcodec/ass.h |  7 +++++++
> >  2 files changed, 33 insertions(+), 6 deletions(-)
> > 
> > diff --git a/libavcodec/ass.c b/libavcodec/ass.c
> > index 725e4d42ba1..d0a4d678bb4 100644
> > --- a/libavcodec/ass.c
> > +++ b/libavcodec/ass.c
> > @@ -114,17 +114,30 @@ char *ff_ass_get_dialog(int readorder, int layer, const char *style,
> >                         speaker ? speaker : "", text);
> >  }
> >  
> > -int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
> > +int ff_ass_add_rect2(AVSubtitle *sub, const char *dialog,
> >                      int readorder, int layer, const char *style,
> > -                    const char *speaker)
> > +                    const char *speaker, size_t *nb_rect_allocated)
> >  {
> > -    AVSubtitleRect **rects, *rect;
> > +    AVSubtitleRect **rects = sub->rects, *rect;
> >      char *ass_str;
> > +    uint64_t new_nb = 0;
> >  
> > -    rects = av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*sub->rects));
> > -    if (!rects)
> > +    if (nb_rect_allocated && *nb_rect_allocated <= sub->num_rects) {
> > +        new_nb = sub->num_rects + sub->num_rects/16LL + 1;
> > +    } else if (!nb_rect_allocated)
> > +        new_nb = sub->num_rects + 1LL;
> > +    if (new_nb > SIZE_MAX)
> >          return AVERROR(ENOMEM);
> 
> AVSubtitle.num_rects is unsigned, so this number should always be
> bounded by UINT_MAX (and nb_rect_allocated can be a pointer to unsigned,
> too).

i had that initially but then wanted to move to better types but missed
this, changed it back locally

thx

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

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data

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

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect()
  2021-12-18 14:27   ` Michael Niedermayer
@ 2021-12-18 16:21     ` Andreas Rheinhardt
  0 siblings, 0 replies; 11+ messages in thread
From: Andreas Rheinhardt @ 2021-12-18 16:21 UTC (permalink / raw)
  To: ffmpeg-devel

Michael Niedermayer:
> On Fri, Dec 17, 2021 at 11:15:06PM +0100, Andreas Rheinhardt wrote:
>> Michael Niedermayer:
>>> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>>> ---
>>>  libavcodec/ass.c | 32 ++++++++++++++++++++++++++------
>>>  libavcodec/ass.h |  7 +++++++
>>>  2 files changed, 33 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/libavcodec/ass.c b/libavcodec/ass.c
>>> index 725e4d42ba1..d0a4d678bb4 100644
>>> --- a/libavcodec/ass.c
>>> +++ b/libavcodec/ass.c
>>> @@ -114,17 +114,30 @@ char *ff_ass_get_dialog(int readorder, int layer, const char *style,
>>>                         speaker ? speaker : "", text);
>>>  }
>>>  
>>> -int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
>>> +int ff_ass_add_rect2(AVSubtitle *sub, const char *dialog,
>>>                      int readorder, int layer, const char *style,
>>> -                    const char *speaker)
>>> +                    const char *speaker, size_t *nb_rect_allocated)
>>>  {
>>> -    AVSubtitleRect **rects, *rect;
>>> +    AVSubtitleRect **rects = sub->rects, *rect;
>>>      char *ass_str;
>>> +    uint64_t new_nb = 0;
>>>  
>>> -    rects = av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*sub->rects));
>>> -    if (!rects)
>>> +    if (nb_rect_allocated && *nb_rect_allocated <= sub->num_rects) {
>>> +        new_nb = sub->num_rects + sub->num_rects/16LL + 1;
>>> +    } else if (!nb_rect_allocated)
>>> +        new_nb = sub->num_rects + 1LL;
>>> +    if (new_nb > SIZE_MAX)
>>>          return AVERROR(ENOMEM);
>>
>> AVSubtitle.num_rects is unsigned, so this number should always be
>> bounded by UINT_MAX (and nb_rect_allocated can be a pointer to unsigned,
>> too).
> 
> i had that initially but then wanted to move to better types but missed
> this, changed it back locally
> 
Simply changing it back is wrong, because it might happen that the old
num_rects is < UINT_MAX with new_nb > UINT_MAX. In this case one should
clip new_nb to UINT_MAX.
(This case can't happen currently: The loop in ccaption_dec can lead to
at most INT_MAX/3 rects; the other two ff_ass_add_rect() can bring this
to at most INT_MAX/3 + 2.)

- 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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions
  2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions Michael Niedermayer
@ 2021-12-20  9:51   ` Anton Khirnov
  2021-12-20 10:50     ` Michael Niedermayer
  0 siblings, 1 reply; 11+ messages in thread
From: Anton Khirnov @ 2021-12-20  9:51 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting Michael Niedermayer (2021-12-17 22:51:55)
> Fixes: OOM

This is very non-obvious and could use more explanation.

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions
  2021-12-20  9:51   ` Anton Khirnov
@ 2021-12-20 10:50     ` Michael Niedermayer
  2021-12-20 14:32       ` Anton Khirnov
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Niedermayer @ 2021-12-20 10:50 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


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

On Mon, Dec 20, 2021 at 10:51:56AM +0100, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2021-12-17 22:51:55)
> > Fixes: OOM
> 
> This is very non-obvious and could use more explanation.

I guess its obvious to me as ive seen this bug more than once
the problem is that directly setting width/height leaves
coded_w/h unset, then something sets coded_w/h and next time
width/height is set again it is unrelated to the still set
coded_w/h and theres a FFMAX() between coded_w and width
so the image allocated is much bigger
ff_set_dimension() breaks this chain by setting both width and
coded_width 

should i add this long explanation above to the commit message
or something shorter like
"sets coded_width / coded_height too to keep them consistent with
 width / height"
 
thx

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

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2


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

* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions
  2021-12-20 10:50     ` Michael Niedermayer
@ 2021-12-20 14:32       ` Anton Khirnov
  2021-12-23 13:56         ` Michael Niedermayer
  0 siblings, 1 reply; 11+ messages in thread
From: Anton Khirnov @ 2021-12-20 14:32 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting Michael Niedermayer (2021-12-20 11:50:21)
> On Mon, Dec 20, 2021 at 10:51:56AM +0100, Anton Khirnov wrote:
> > Quoting Michael Niedermayer (2021-12-17 22:51:55)
> > > Fixes: OOM
> > 
> > This is very non-obvious and could use more explanation.
> 
> I guess its obvious to me as ive seen this bug more than once
> the problem is that directly setting width/height leaves
> coded_w/h unset, then something sets coded_w/h and next time
> width/height is set again it is unrelated to the still set
> coded_w/h and theres a FFMAX() between coded_w and width
> so the image allocated is much bigger
> ff_set_dimension() breaks this chain by setting both width and
> coded_width 
> 
> should i add this long explanation above to the commit message
> or something shorter like
> "sets coded_width / coded_height too to keep them consistent with
>  width / height"

Either is fine with me.

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions
  2021-12-20 14:32       ` Anton Khirnov
@ 2021-12-23 13:56         ` Michael Niedermayer
  0 siblings, 0 replies; 11+ messages in thread
From: Michael Niedermayer @ 2021-12-23 13:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


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

On Mon, Dec 20, 2021 at 03:32:05PM +0100, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2021-12-20 11:50:21)
> > On Mon, Dec 20, 2021 at 10:51:56AM +0100, Anton Khirnov wrote:
> > > Quoting Michael Niedermayer (2021-12-17 22:51:55)
> > > > Fixes: OOM
> > > 
> > > This is very non-obvious and could use more explanation.
> > 
> > I guess its obvious to me as ive seen this bug more than once
> > the problem is that directly setting width/height leaves
> > coded_w/h unset, then something sets coded_w/h and next time
> > width/height is set again it is unrelated to the still set
> > coded_w/h and theres a FFMAX() between coded_w and width
> > so the image allocated is much bigger
> > ff_set_dimension() breaks this chain by setting both width and
> > coded_width 
> > 
> > should i add this long explanation above to the commit message
> > or something shorter like
> > "sets coded_width / coded_height too to keep them consistent with
> >  width / height"
> 
> Either is fine with me.

ok will use the shorter and apply the 2 tiff patches

thx

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

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.

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

end of thread, other threads:[~2021-12-23 13:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-17 21:51 [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Michael Niedermayer
2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: Use ff_ass_add_rect2() Michael Niedermayer
2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 3/4] avcodec/tiff: Pass max_pixels to mjpeg context Michael Niedermayer
2021-12-17 21:51 ` [FFmpeg-devel] [PATCH 4/4] avcodec/tiff: Use ff_set_dimensions() for setting up mjpeg context dimensions Michael Niedermayer
2021-12-20  9:51   ` Anton Khirnov
2021-12-20 10:50     ` Michael Niedermayer
2021-12-20 14:32       ` Anton Khirnov
2021-12-23 13:56         ` Michael Niedermayer
2021-12-17 22:15 ` [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() Andreas Rheinhardt
2021-12-18 14:27   ` Michael Niedermayer
2021-12-18 16:21     ` Andreas Rheinhardt

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