[FFmpeg-devel] [PATCH v3 3/8] avcodec/movtextenc: Don't presume every style to have a font
Fixes segfaults in the absence of fonts; this can happen because the file didn't contain any or because the allocation of the font-string failed. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextenc.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 81e8c2e802..dcdbf16e08 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -298,10 +298,14 @@ static int encode_sample_description(AVCodecContext *avctx) // is avaiable in the ASS header if (style && ass->styles_count) { // Find unique font names -av_dynarray_add(&s->fonts, &s->font_count, style->font_name); -font_names_total_len += strlen(style->font_name); +if (style->font_name) { +av_dynarray_add(&s->fonts, &s->font_count, style->font_name); +font_names_total_len += strlen(style->font_name); +} for (i = 0; i < ass->styles_count; i++) { int found = 0; +if (!ass->styles[i].font_name) +continue; for (j = 0; j < s->font_count; j++) { if (!strcmp(s->fonts[j], ass->styles[i].font_name)) { found = 1; -- 2.25.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 1/8] avcodec/movtextenc: Fix potential use of uninitialized value
Background colour was never initialized if no style was available. Use a sane default of zero (i.e. completely transparent). Fixes Coverity issue #1461471. Signed-off-by: Andreas Rheinhardt --- No change for this patch since last time; I am just resending all because I have added a few patches that I intend to backport and that therefore should be applied before "Simplify writing to AVBPrint". libavcodec/movtextenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 5f60b8db61..11db240ab7 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -205,7 +205,7 @@ static int encode_sample_description(AVCodecContext *avctx) ASS *ass; ASSStyle *style; int i, j; -uint32_t tsmb_size, tsmb_type, back_color, style_color; +uint32_t tsmb_size, tsmb_type, back_color = 0, style_color; uint16_t style_start, style_end, fontID, count; int font_names_total_len = 0; MovTextContext *s = avctx->priv_data; -- 2.25.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 2/8] avcodec/movtextenc: Reset array counter after freeing array
Otherwise the mov_text encoder can segfault when given subtitles with more than one AVSubtitleRect if one of the first nb_rects - 1 rects contained a style attribute. Signed-off-by: Andreas Rheinhardt --- The earlier commit message claimed to be about a muxer in avcodec/movtextdec. I still don't know whether the STYL_BOX flag should be reset or not. libavcodec/movtextenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 11db240ab7..81e8c2e802 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -102,6 +102,7 @@ static void mov_text_cleanup(MovTextContext *s) av_freep(&s->style_attributes[j]); } av_freep(&s->style_attributes); +s->count = 0; } if (s->style_attributes_temp) { *s->style_attributes_temp = s->d; -- 2.25.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/8] avcodec/movtextenc: Fix undefined left shifts outside the range of int
Signed-off-by: Andreas Rheinhardt --- Alternatively one could also change the types of the colors in ASSStyle (ass_split.h) to uint32_t. libavcodec/movtextenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 73d998d080..42fdf98042 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -45,7 +45,7 @@ #define DEFAULT_STYLE_COLOR0x #define DEFAULT_STYLE_FLAG 0x00 -#define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 0xff)) +#define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((uint32_t)(c) >> 16) & 0xff)) #define FONTSIZE_SCALE(s,fs) ((fs) * (s)->font_scale_factor + 0.5) #define av_bprint_append_any(buf, data, size) av_bprint_append_data(buf, ((const char*)data), size) -- 2.25.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 7/8] avcodec/movtextenc: Remove redundant function parameters
It makes no sense to call the functions to write styl, hlit or hclr boxes with a different box name than "styl", "hlit" or "hclr". Therefore this commit inlines these values in the functions, removes the function parameter containing the box's name and removes the (non obsolete) box names from the list of boxes. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextenc.c | 23 +++ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 908b2bfde5..2082dc9b25 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -92,8 +92,7 @@ typedef struct { } MovTextContext; typedef struct { -uint32_t type; -void (*encode)(MovTextContext *s, uint32_t tsmb_type); +void (*encode)(MovTextContext *s); } Box; static void mov_text_cleanup(MovTextContext *s) @@ -102,13 +101,13 @@ static void mov_text_cleanup(MovTextContext *s) s->style_attributes_temp = s->d; } -static void encode_styl(MovTextContext *s, uint32_t tsmb_type) +static void encode_styl(MovTextContext *s) { if ((s->box_flags & STYL_BOX) && s->count) { uint8_t buf[12], *p = buf; bytestream_put_be32(&p, s->count * STYLE_RECORD_SIZE + SIZE_ADD); -bytestream_put_be32(&p, tsmb_type); +bytestream_put_be32(&p, MKBETAG('s','t','y','l')); bytestream_put_be16(&p, s->count); /*The above three attributes are hard coded for now but will come from ASS style in the future*/ @@ -130,13 +129,13 @@ static void encode_styl(MovTextContext *s, uint32_t tsmb_type) mov_text_cleanup(s); } -static void encode_hlit(MovTextContext *s, uint32_t tsmb_type) +static void encode_hlit(MovTextContext *s) { if (s->box_flags & HLIT_BOX) { uint8_t buf[12], *p = buf; bytestream_put_be32(&p, 12); -bytestream_put_be32(&p, tsmb_type); +bytestream_put_be32(&p, MKBETAG('h','l','i','t')); bytestream_put_be16(&p, s->hlit.start); bytestream_put_be16(&p, s->hlit.end); @@ -144,13 +143,13 @@ static void encode_hlit(MovTextContext *s, uint32_t tsmb_type) } } -static void encode_hclr(MovTextContext *s, uint32_t tsmb_type) +static void encode_hclr(MovTextContext *s) { if (s->box_flags & HCLR_BOX) { uint8_t buf[12], *p = buf; bytestream_put_be32(&p, 12); -bytestream_put_be32(&p, tsmb_type); +bytestream_put_be32(&p, MKBETAG('h','c','l','r')); bytestream_put_be32(&p, s->hclr.color); av_bprint_append_any(&s->buffer, buf, 12); @@ -158,9 +157,9 @@ static void encode_hclr(MovTextContext *s, uint32_t tsmb_type) } static const Box box_types[] = { -{ MKBETAG('s','t','y','l'), encode_styl }, -{ MKBETAG('h','l','i','t'), encode_hlit }, -{ MKBETAG('h','c','l','r'), encode_hclr }, +{ encode_styl }, +{ encode_hlit }, +{ encode_hclr }, }; const static size_t box_count = FF_ARRAY_ELEMS(box_types); @@ -682,7 +681,7 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, #endif for (j = 0; j < box_count; j++) { -box_types[j].encode(s, box_types[j].type); +box_types[j].encode(s); } } -- 2.25.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 4/8] avcodec/movtextenc: Fix memleak on (re)allocation error
Up until now, the mov_text encoder used the dynamic array API for its list of style attributes; it used the (horrible) av_dynarray_add() which works with an array of pointers; on error it frees its array but not the buffers referenced by the pointers said array contains. It also returns no error code, encouraging not to check for errors. These properties imply that this function may only be used if the buffers referenced by the list either need not be freed at all or if they are freed by other means (i.e. if the list contains non-ownership pointers). In this case, the style attributes are owned by the pointers of the dynamic list. Ergo the old style attributes leak on a subsequent reallocation failure. But given that the (re)allocation isn't checked for success, the style attribute intended to be added to the list also leaks because the only pointer to it gets overwritten in the belief that it is now owned by the list. This commit fixes this by switching to av_fast_realloc() and an array containing the styles directly instead of pointers to individually allocated style attributes. The current style attributes are now no longer individually allocated, instead they are part of the context. Furthermore, av_fast_realloc() allows to easily distinguish between valid and allocated elements, thereby allowing to reuse the array (which up until now has always been freed after processing an AVSubtitleRect). Signed-off-by: Andreas Rheinhardt --- The check "s->count + 1 > SIZE_MAX / sizeof(*s->style_attributes)" below is both good and bad: It is good because the compiler can see for arches where size_t is 64bit and unsigned is 32bit that this is always true, so that it can be optimized away; it is bad, because compilers emit warnings for this. The warning from Clang could be shut up by first checking whether SIZE_MAX / sizeof(*s->style_attributes) exceeds UINT_MAX; but GCC still warns in this case. Unfortunately one can't use sizeof in preprocessor checks. Notice that av_fast_realloc() ensures that s->count * sizeof(*s->style_attributes) is <= UINT_MAX, so that s->count + 1 can't overflow. libavcodec/movtextenc.c | 124 1 file changed, 50 insertions(+), 74 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index dcdbf16e08..73d998d080 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -73,12 +73,13 @@ typedef struct { ASSSplitContext *ass_ctx; ASSStyle *ass_dialog_style; +StyleBox *style_attributes; +unsigned count; +unsigned style_attributes_bytes_allocated; +StyleBox style_attributes_temp; AVBPrint buffer; -StyleBox **style_attributes; -StyleBox *style_attributes_temp; HighlightBox hlit; HilightcolorBox hclr; -int count; uint8_t box_flags; StyleBox d; uint16_t text_pos; @@ -96,22 +97,12 @@ typedef struct { static void mov_text_cleanup(MovTextContext *s) { -int j; -if (s->box_flags & STYL_BOX) { -for (j = 0; j < s->count; j++) { -av_freep(&s->style_attributes[j]); -} -av_freep(&s->style_attributes); -s->count = 0; -} -if (s->style_attributes_temp) { -*s->style_attributes_temp = s->d; -} +s->count = 0; +s->style_attributes_temp = s->d; } static void encode_styl(MovTextContext *s, uint32_t tsmb_type) { -int j; uint32_t tsmb_size; uint16_t style_entries; if ((s->box_flags & STYL_BOX) && s->count) { @@ -124,20 +115,20 @@ static void encode_styl(MovTextContext *s, uint32_t tsmb_type) av_bprint_append_any(&s->buffer, &tsmb_size, 4); av_bprint_append_any(&s->buffer, &tsmb_type, 4); av_bprint_append_any(&s->buffer, &style_entries, 2); -for (j = 0; j < s->count; j++) { +for (unsigned j = 0; j < s->count; j++) { uint16_t style_start, style_end, style_fontID; uint32_t style_color; -style_start = AV_RB16(&s->style_attributes[j]->style_start); -style_end= AV_RB16(&s->style_attributes[j]->style_end); -style_color = AV_RB32(&s->style_attributes[j]->style_color); -style_fontID = AV_RB16(&s->style_attributes[j]->style_fontID); +style_start = AV_RB16(&s->style_attributes[j].style_start); +style_end= AV_RB16(&s->style_attributes[j].style_end); +style_color = AV_RB32(&s->style_attributes[j].style_color); +style_fontID = AV_RB16(&s->style_attributes[j].style_fontID); av_bprint_append_any(&s->buffer, &style_start, 2); av_bprint_append_any(&s->buffer, &style_end, 2); av_bprint_append_any(&s->buffer, &style_fontID, 2); -av_bprint_append_any(&s->buffer, &s->style_attributes[j]->style_flag, 1); -av_bprint_append_any(&s->buffer, &s->style_attributes[j]->style_fontsize, 1); +av_bprint_append_any(&s->buffer, &s->style_at
[FFmpeg-devel] [PATCH v3 6/8] avcodec/movtextenc: Simplify writing to AVBPrint
The mov_text encoder uses an AVBPrint to assemble the subtitles; yet mov_text subtitles are not pure text; they also have a binary portion that was mostly handled as follows: uint32_t size = /* calculation */; size = AV_RB32(&size); av_bprint_append_data(bprint, (const char*)&size, 4); Here AV_RB32() is a no-op on big-endian systems and a LE-BE swap on little-endian systems, making the output endian-independent. Yet this is ugly and unclean: On LE systems, the variable size from the snippet above won't contain the correct value any more. Furthermore, using this pattern leads to lots of small writes to the AVBPrint. This commit therefore changes this to using a temporary buffer instead: uint8_t buf[4]; AV_WB32(buf, /* size calculation */); av_bprint_append_data(bprint, buf, 4); This method also allows to use bigger buffers holding more than one element, saving calls to av_bprint_append_data() and reducing codesize. Signed-off-by: Andreas Rheinhardt --- No real change, just the typical rebase stuff. libavcodec/movtextenc.c | 153 +--- 1 file changed, 66 insertions(+), 87 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 42fdf98042..908b2bfde5 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -29,6 +29,7 @@ #include "libavutil/common.h" #include "ass_split.h" #include "ass.h" +#include "bytestream.h" #define STYLE_FLAG_BOLD (1<<0) #define STYLE_FLAG_ITALIC (1<<1) @@ -103,33 +104,27 @@ static void mov_text_cleanup(MovTextContext *s) static void encode_styl(MovTextContext *s, uint32_t tsmb_type) { -uint32_t tsmb_size; -uint16_t style_entries; if ((s->box_flags & STYL_BOX) && s->count) { -tsmb_size = s->count * STYLE_RECORD_SIZE + SIZE_ADD; -tsmb_size = AV_RB32(&tsmb_size); -tsmb_type = AV_RB32(&tsmb_type); -style_entries = AV_RB16(&s->count); +uint8_t buf[12], *p = buf; + +bytestream_put_be32(&p, s->count * STYLE_RECORD_SIZE + SIZE_ADD); +bytestream_put_be32(&p, tsmb_type); +bytestream_put_be16(&p, s->count); /*The above three attributes are hard coded for now but will come from ASS style in the future*/ -av_bprint_append_any(&s->buffer, &tsmb_size, 4); -av_bprint_append_any(&s->buffer, &tsmb_type, 4); -av_bprint_append_any(&s->buffer, &style_entries, 2); +av_bprint_append_any(&s->buffer, buf, 10); for (unsigned j = 0; j < s->count; j++) { -uint16_t style_start, style_end, style_fontID; -uint32_t style_color; - -style_start = AV_RB16(&s->style_attributes[j].style_start); -style_end= AV_RB16(&s->style_attributes[j].style_end); -style_color = AV_RB32(&s->style_attributes[j].style_color); -style_fontID = AV_RB16(&s->style_attributes[j].style_fontID); - -av_bprint_append_any(&s->buffer, &style_start, 2); -av_bprint_append_any(&s->buffer, &style_end, 2); -av_bprint_append_any(&s->buffer, &style_fontID, 2); -av_bprint_append_any(&s->buffer, &s->style_attributes[j].style_flag, 1); -av_bprint_append_any(&s->buffer, &s->style_attributes[j].style_fontsize, 1); -av_bprint_append_any(&s->buffer, &style_color, 4); +const StyleBox *style = &s->style_attributes[j]; + +p = buf; +bytestream_put_be16(&p, style->style_start); +bytestream_put_be16(&p, style->style_end); +bytestream_put_be16(&p, style->style_fontID); +bytestream_put_byte(&p, style->style_flag); +bytestream_put_byte(&p, style->style_fontsize); +bytestream_put_be32(&p, style->style_color); + +av_bprint_append_any(&s->buffer, buf, 12); } } mov_text_cleanup(s); @@ -137,32 +132,28 @@ static void encode_styl(MovTextContext *s, uint32_t tsmb_type) static void encode_hlit(MovTextContext *s, uint32_t tsmb_type) { -uint32_t tsmb_size; -uint16_t start, end; if (s->box_flags & HLIT_BOX) { -tsmb_size = 12; -tsmb_size = AV_RB32(&tsmb_size); -tsmb_type = AV_RB32(&tsmb_type); -start = AV_RB16(&s->hlit.start); -end = AV_RB16(&s->hlit.end); -av_bprint_append_any(&s->buffer, &tsmb_size, 4); -av_bprint_append_any(&s->buffer, &tsmb_type, 4); -av_bprint_append_any(&s->buffer, &start, 2); -av_bprint_append_any(&s->buffer, &end, 2); +uint8_t buf[12], *p = buf; + +bytestream_put_be32(&p, 12); +bytestream_put_be32(&p, tsmb_type); +bytestream_put_be16(&p, s->hlit.start); +bytestream_put_be16(&p, s->hlit.end); + +av_bprint_append_any(&s->buffer, buf, 12); } } static void encode_hclr(MovTextContext *s, uint32_t tsmb_type) { -uint32_t tsmb_size, color; if (s->box_flags & HCLR_BO
[FFmpeg-devel] [PATCH v3 8/8] avcodec/movtextenc: Cleanup generically on init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextenc.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 2082dc9b25..1bef21e0b9 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -30,6 +30,7 @@ #include "ass_split.h" #include "ass.h" #include "bytestream.h" +#include "internal.h" #define STYLE_FLAG_BOLD (1<<0) #define STYLE_FLAG_ITALIC (1<<1) @@ -331,19 +332,13 @@ static av_cold int mov_text_encode_init(AVCodecContext *avctx) av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED); s->ass_ctx = ff_ass_split(avctx->subtitle_header); -if (!s->ass_ctx) { -ret = AVERROR_INVALIDDATA; -goto fail; -} +if (!s->ass_ctx) +return AVERROR_INVALIDDATA; ret = encode_sample_description(avctx); if (ret < 0) -goto fail; +return ret; return 0; - -fail: -mov_text_encode_close(avctx); -return ret; } // Start a new style box if needed @@ -736,4 +731,5 @@ AVCodec ff_movtext_encoder = { .init = mov_text_encode_init, .encode_sub = mov_text_encode_frame, .close = mov_text_encode_close, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 2.25.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 v2] lavf/url: fix rel path’s query string contains :/
On Sat, 17 Oct 2020, caihaonin...@gmail.com wrote: From: "ruiquan.crq" Signed-off-by: ruiquan.crq --- libavformat/tests/url.c | 1 + libavformat/url.c | 2 +- tests/ref/fate/url | 4 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c index 2440ae08bc..c294795fa2 100644 --- a/libavformat/tests/url.c +++ b/libavformat/tests/url.c @@ -90,6 +90,7 @@ int main(void) test_decompose("http://[::1]/dev/null";); test_decompose("http://[::1]:8080/dev/null";); test_decompose("//ffmpeg/dev/null"); +test_decompose("test?url=http://server/path";); printf("Testing ff_make_absolute_url:\n"); test(NULL, "baz"); diff --git a/libavformat/url.c b/libavformat/url.c index 3c858f0257..da5950723e 100644 --- a/libavformat/url.c +++ b/libavformat/url.c @@ -97,7 +97,7 @@ int ff_url_decompose(URLComponents *uc, const char *url, const char *end) /* scheme */ uc->scheme = cur; -p = find_delim(":/", cur, end); /* lavf "schemes" can contain options */ +p = find_delim(":/?", cur, end); /* lavf "schemes" can contain options, or "schemes" can't contains characters['?']*/ And why not also add # here as well? With the same logic, there can be URL-s like dummy.mp4#t=0:02:00,121.5 and they will fail currently. Also a more clear wording for the comment: /* lavf "schemes" can contain options but not some RFC 3986 delimiters */ Regards, Marton if (*p == ':') cur = p + 1; diff --git a/tests/ref/fate/url b/tests/ref/fate/url index 7e6395c47b..a9db0251f1 100644 --- a/tests/ref/fate/url +++ b/tests/ref/fate/url @@ -43,6 +43,10 @@ http://[::1]:8080/dev/null => host: ffmpeg path: /dev/null +test?url=http://server/path => + path: test + query: ?url=http://server/path + Testing ff_make_absolute_url: (null) baz => baz /foo/bar baz => /foo/baz -- 2.24.1 (Apple Git-126) ___ 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 v1] libavformat/hls: During operation, the user exits and interrupts, causing pls->segment to be released, resulting in a null pointer crash
> 在 2020年10月17日,13:38,徐慧书 写道: > > Andreas Rheinhardt 于2020年10月16日周五 下午9:32写道: > >> javashu2...@gmail.com: >>> From: bevis >>> >>> Signed-off-by: bevis >>> --- >>> libavformat/hls.c | 5 +++-- >>> 1 file changed, 3 insertions(+), 2 deletions(-) >>> >>> diff --git a/libavformat/hls.c b/libavformat/hls.c >>> index 72e28ab94f..0a522a4595 100644 >>> --- a/libavformat/hls.c >>> +++ b/libavformat/hls.c >>> @@ -1979,17 +1979,18 @@ static int hls_read_header(AVFormatContext *s) >>> pls->ctx->interrupt_callback = s->interrupt_callback; >>> url = av_strdup(pls->segments[0]->url); >>> ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0); >>> -av_free(url); >>> if (ret < 0) { >>> /* Free the ctx - it isn't initialized properly at this >> point, >>> * so avformat_close_input shouldn't be called. If >>> * avformat_open_input fails below, it frees and zeros the >>> * context, so it doesn't need any special treatment like >> this. */ >>> -av_log(s, AV_LOG_ERROR, "Error when loading first segment >> '%s'\n", pls->segments[0]->url); >>> +av_log(s, AV_LOG_ERROR, "Error when loading first segment >> '%s'\n", url); >>> avformat_free_context(pls->ctx); >>> pls->ctx = NULL; >>> +av_free(url); >>> goto fail; >>> } >>> +av_free(url); >>> pls->ctx->pb = &pls->pb; >>> pls->ctx->io_open = nested_io_open; >>> pls->ctx->flags |= s->flags & ~AVFMT_FLAG_CUSTOM_IO; >>> >> The change itself seems fine to me (I wonder why this hasn't been >> noticed when writing/reviewing b5e39880fb), but your commit message is >> way too long: The first line should be a short description followed by a >> more detailed description lateron (in the next lines). >> >> How exactly did you find this? >> >> - Andreas >> > > It was found in the crash logs of online users, and it was also simulated > locally. In China, we have a very large number of users, and the hls > protocol is widely used, with hundreds of millions of views every day, and > every small problem becomes more obvious. maybe more than 1.5 billions right now. :D > >> ___ >> 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". Thanks Steven ___ 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 1/6] ffmpeg: deduplicate init_output_stream usage logic
On Fri, Oct 16, 2020 at 11:03 PM Michael Niedermayer wrote: > > On Fri, Oct 16, 2020 at 04:16:44PM +0300, Jan Ekström wrote: > > Adds a wrapper function, which handles any errors depending on how > > fatal a failure would be. > > --- > > fftools/ffmpeg.c | 51 > > 1 file changed, 25 insertions(+), 26 deletions(-) > > LGTM > > thx > Thanks, applied as 86228ebdb2f1c9c066473710c7e14eb8331265bf . Jan ___ 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/5] avformat/icodec: Change order of operations to avoid NULL dereference
On Sat, Oct 17, 2020 at 07:52:02AM +1100, Peter Ross wrote: > On Fri, Oct 16, 2020 at 07:35:29PM +0200, Michael Niedermayer wrote: > > Fixes: SEGV on unknown address 0x > > Fixes: > > 26379/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-5709011753893888 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/icodec.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/icodec.c b/libavformat/icodec.c > > index b47fa98f80..c061f3ec42 100644 > > --- a/libavformat/icodec.c > > +++ b/libavformat/icodec.c > > @@ -156,12 +156,14 @@ static int read_packet(AVFormatContext *s, AVPacket > > *pkt) > > IcoDemuxContext *ico = s->priv_data; > > IcoImage *image; > > AVIOContext *pb = s->pb; > > -AVStream *st = s->streams[0]; > > +AVStream *st; > > int ret; > > > > if (ico->current_image >= ico->nb_images) > > return AVERROR_EOF; > > > > +st = s->streams[0]; > > + > > image = &ico->images[ico->current_image]; > > > > if ((ret = avio_seek(pb, image->offset, SEEK_SET)) < 0) > > -- > > 2.17.1 > > looks good will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. 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 2/2] avcodec/cook: Check subpacket index against max
On Sun, Sep 27, 2020 at 10:20:53PM +0200, Michael Niedermayer wrote: > Fixes: off by 1 error > Fixes: index 5 out of bounds for type 'COOKSubpacket [5]' > Fixes: > 25772/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_COOK_fuzzer-5762459498184704.fuzz > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/cook.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire 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 3/3] avformat/flvdec: Check for EOF in amf_parse_object()
On Fri, Oct 09, 2020 at 06:47:15PM +0200, Michael Niedermayer wrote: > On Fri, Oct 09, 2020 at 10:37:20PM +0800, Steven Liu wrote: > > > > > > > 在 2020年10月9日,03:19,Michael Niedermayer 写道: > > > > > > Fixes: Timeout (too long -> 1ms) > > > Fixes: > > > 26108/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5653887668977664 > > > > > > Found-by: continuous fuzzing process > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > > Signed-off-by: Michael Niedermayer > > > --- > > > libavformat/flvdec.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > > > index d480d0bc67..e6786e8b38 100644 > > > --- a/libavformat/flvdec.c > > > +++ b/libavformat/flvdec.c > > > @@ -493,8 +493,11 @@ static int amf_parse_object(AVFormatContext *s, > > > AVStream *astream, > > > double num_val; > > > amf_date date; > > > > > > + > > empty line? > > removed will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you drop bombs on a foreign country and kill a hundred thousand innocent people, expect your government to call the consequence "unprovoked inhuman terrorist attacks" and use it to justify dropping more bombs and killing more people. The technology changed, the idea is old. 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 3/3] avcodec/mv30: Fix multiple integer overflows
On Sun, Oct 04, 2020 at 09:41:43PM +0200, Michael Niedermayer wrote: > Fixes: signed integer overflow: -895002 * 2400 cannot be represented in type > 'int' > Fixes: > 26052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5431812577558528 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/mv30.c | 24 > 1 file changed, 12 insertions(+), 12 deletions(-) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The bravest are surely those who have the clearest vision of what is before them, glory and danger alike, and yet notwithstanding go out to meet it. -- Thucydides 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 2/3] avcodec/smacker: Check remaining bits in SMK_BLK_FULL
On Mon, Oct 05, 2020 at 03:24:08AM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Fixes: out of array access > > Fixes: > > 26047/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5083031667474432 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/smacker.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c > > index 813eb862c0..6b1faec09e 100644 > > --- a/libavcodec/smacker.c > > +++ b/libavcodec/smacker.c > > @@ -448,6 +448,8 @@ static int decode_frame(AVCodecContext *avctx, void > > *data, int *got_frame, > > case SMK_BLK_FULL: > > mode = 0; > > if(avctx->codec_tag == MKTAG('S', 'M', 'K', '4')) { // In case > > of Smacker v4 we have three modes > > +if (get_bits_left(&gb) < 1) > > +return AVERROR_INVALIDDATA; > > if(get_bits1(&gb)) mode = 1; > > else if(get_bits1(&gb)) mode = 2; > > } > > > LGTM. will apply > (This is a file in which the type and the full tree consists of only one > entry (so that smk_get_code() never checks for overreads), isn't it? I > have to admit to have overlooked this edge case.) possibly so, id have to recheck thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable 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/3] avcodec/hevc_mvs: Cleanup ff_hevc_set_neighbour_available()
On Fri, Oct 16, 2020 at 01:30:27PM +0200, Michael Niedermayer wrote: > Signed-off-by: Michael Niedermayer > --- > libavcodec/hevc_mvs.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) will apply patchset [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope 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 v2] lavf/url: fix rel path’s query string contains :/
Marton Balint 于2020年10月17日周六 下午4:35写道: > And why not also add # here as well? With the same logic, there can be > URL-s like dummy.mp4#t=0:02:00,121.5 and they will fail currently. > > Also a more clear wording for the comment: > /* lavf "schemes" can contain options but not some RFC 3986 delimiters */ > You are right. ___ 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] fix relative URLs contains "://" or "#"
From: "ruiquan.crq" Signed-off-by: ruiquan.crq --- libavformat/tests/url.c | 2 ++ libavformat/url.c | 2 +- tests/ref/fate/url | 8 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c index 2440ae08bc..2eb597bb5e 100644 --- a/libavformat/tests/url.c +++ b/libavformat/tests/url.c @@ -90,6 +90,8 @@ int main(void) test_decompose("http://[::1]/dev/null";); test_decompose("http://[::1]:8080/dev/null";); test_decompose("//ffmpeg/dev/null"); +test_decompose("test?url=http://server/path";); +test_decompose("dummy.mp4#t=0:02:00,121.5"); printf("Testing ff_make_absolute_url:\n"); test(NULL, "baz"); diff --git a/libavformat/url.c b/libavformat/url.c index 3c858f0257..6db4b4e1ae 100644 --- a/libavformat/url.c +++ b/libavformat/url.c @@ -97,7 +97,7 @@ int ff_url_decompose(URLComponents *uc, const char *url, const char *end) /* scheme */ uc->scheme = cur; -p = find_delim(":/", cur, end); /* lavf "schemes" can contain options */ +p = find_delim(":/?#", cur, end); /* lavf "schemes" can contain options but not some RFC 3986 delimiters */ if (*p == ':') cur = p + 1; diff --git a/tests/ref/fate/url b/tests/ref/fate/url index 7e6395c47b..08e80def7d 100644 --- a/tests/ref/fate/url +++ b/tests/ref/fate/url @@ -43,6 +43,14 @@ http://[::1]:8080/dev/null => host: ffmpeg path: /dev/null +test?url=http://server/path => + path: test + query: ?url=http://server/path + +dummy.mp4#t=0:02:00,121.5 => + path: dummy.mp4 + fragment: #t=0:02:00,121.5 + Testing ff_make_absolute_url: (null) baz => baz /foo/bar baz => /foo/baz -- 2.24.1 (Apple Git-126) ___ 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] lavf/url: fix rel path’s query string contains :/
From: "ruiquan.crq" Signed-off-by: ruiquan.crq --- libavformat/tests/url.c | 2 ++ libavformat/url.c | 2 +- tests/ref/fate/url | 8 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c index 2440ae08bc..2eb597bb5e 100644 --- a/libavformat/tests/url.c +++ b/libavformat/tests/url.c @@ -90,6 +90,8 @@ int main(void) test_decompose("http://[::1]/dev/null";); test_decompose("http://[::1]:8080/dev/null";); test_decompose("//ffmpeg/dev/null"); +test_decompose("test?url=http://server/path";); +test_decompose("dummy.mp4#t=0:02:00,121.5"); printf("Testing ff_make_absolute_url:\n"); test(NULL, "baz"); diff --git a/libavformat/url.c b/libavformat/url.c index 3c858f0257..6db4b4e1ae 100644 --- a/libavformat/url.c +++ b/libavformat/url.c @@ -97,7 +97,7 @@ int ff_url_decompose(URLComponents *uc, const char *url, const char *end) /* scheme */ uc->scheme = cur; -p = find_delim(":/", cur, end); /* lavf "schemes" can contain options */ +p = find_delim(":/?#", cur, end); /* lavf "schemes" can contain options but not some RFC 3986 delimiters */ if (*p == ':') cur = p + 1; diff --git a/tests/ref/fate/url b/tests/ref/fate/url index 7e6395c47b..08e80def7d 100644 --- a/tests/ref/fate/url +++ b/tests/ref/fate/url @@ -43,6 +43,14 @@ http://[::1]:8080/dev/null => host: ffmpeg path: /dev/null +test?url=http://server/path => + path: test + query: ?url=http://server/path + +dummy.mp4#t=0:02:00,121.5 => + path: dummy.mp4 + fragment: #t=0:02:00,121.5 + Testing ff_make_absolute_url: (null) baz => baz /foo/bar baz => /foo/baz -- 2.24.1 (Apple Git-126) ___ 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 3/3] avformat/mov: remove an always true condition
> On Sep 18, 2020, at 10:33 PM, Zhao Zhili wrote: > > From: Zhao Zhili > > --- > libavformat/mov.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 9fc0db24d5..f99605c2cd 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1475,7 +1475,7 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration > */ > // set the AVFormatContext duration because the duration of individual > tracks > // may be inaccurate > -if (c->time_scale > 0 && !c->trex_data) > +if (!c->trex_data) > c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, > c->time_scale); > avio_rb32(pb); /* preferred scale */ Ping for review. The always true condition is not obvious in the patch. time_scale is checked a few lines before explicitly. 1471 if (c->time_scale <= 0) { 1472 av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d, defaulting to 1\n", c->time_scale); 1473 c->time_scale = 1; 1474 } 1475 av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale); 1476 1477 c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */ 1478 // set the AVFormatContext duration because the duration of individual tracks 1479 // may be inaccurate 1480 if (c->time_scale > 0 && !c->trex_data) 1481 c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale); > > -- > 2.25.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] avformat/mov: make better use of av_fast_realloc and fix spurious ENOMEM
Ping for review. > On Sep 24, 2020, at 1:28 AM, Zhao Zhili wrote: > > If sc->ctts_allocated_size is larger than the new buffer size, > av_fast_realloc() will return NULL. Since sc->ctts_data is freed, > ctts_allocated_size should be reset to zero. It's better to avoid > free sc->ctts_data at the first place to make better use of > av_fast_realloc(). > --- > libavformat/mov.c | 10 +++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index dcd263b02a..fcb5a583bd 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -3014,6 +3014,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > { > AVStream *st; > MOVStreamContext *sc; > +MOVStts *ctts_data; > unsigned int i, entries, ctts_count = 0; > > if (c->fc->nb_streams < 1) > @@ -3031,10 +3032,13 @@ static int mov_read_ctts(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > return 0; > if (entries >= UINT_MAX / sizeof(*sc->ctts_data)) > return AVERROR_INVALIDDATA; > -av_freep(&sc->ctts_data); > -sc->ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, entries > * sizeof(*sc->ctts_data)); > -if (!sc->ctts_data) > +ctts_data = av_fast_realloc(sc->ctts_data, &sc->ctts_allocated_size, > entries * sizeof(*sc->ctts_data)); > +if (!ctts_data) { > +av_freep(&sc->ctts_data); > +sc->ctts_allocated_size = 0; > return AVERROR(ENOMEM); > +} > +sc->ctts_data = ctts_data; > > for (i = 0; i < entries && !pb->eof_reached; i++) { > int count= avio_rb32(pb); > -- > 2.25.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 7/8] avcodec/movtextenc: Remove redundant function parameters
> On Oct 17, 2020, at 3:37 PM, Andreas Rheinhardt > wrote: > > It makes no sense to call the functions to write styl, hlit or hclr boxes > with a different box name than "styl", "hlit" or "hclr". Therefore this > commit inlines these values in the functions, removes the function > parameter containing the box's name and removes the (non obsolete) box > names from the list of boxes. The extra parameter is useless for now, but it may add some flexibility in the future, for example, two box types with similar handle logic. I don't know whether such thing can happen. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/movtextenc.c | 23 +++ > 1 file changed, 11 insertions(+), 12 deletions(-) > > diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c > index 908b2bfde5..2082dc9b25 100644 > --- a/libavcodec/movtextenc.c > +++ b/libavcodec/movtextenc.c > @@ -92,8 +92,7 @@ typedef struct { > } MovTextContext; > > typedef struct { > -uint32_t type; > -void (*encode)(MovTextContext *s, uint32_t tsmb_type); > +void (*encode)(MovTextContext *s); > } Box; > > static void mov_text_cleanup(MovTextContext *s) > @@ -102,13 +101,13 @@ static void mov_text_cleanup(MovTextContext *s) > s->style_attributes_temp = s->d; > } > > -static void encode_styl(MovTextContext *s, uint32_t tsmb_type) > +static void encode_styl(MovTextContext *s) > { > if ((s->box_flags & STYL_BOX) && s->count) { > uint8_t buf[12], *p = buf; > > bytestream_put_be32(&p, s->count * STYLE_RECORD_SIZE + SIZE_ADD); > -bytestream_put_be32(&p, tsmb_type); > +bytestream_put_be32(&p, MKBETAG('s','t','y','l')); > bytestream_put_be16(&p, s->count); > /*The above three attributes are hard coded for now > but will come from ASS style in the future*/ > @@ -130,13 +129,13 @@ static void encode_styl(MovTextContext *s, uint32_t > tsmb_type) > mov_text_cleanup(s); > } > > -static void encode_hlit(MovTextContext *s, uint32_t tsmb_type) > +static void encode_hlit(MovTextContext *s) > { > if (s->box_flags & HLIT_BOX) { > uint8_t buf[12], *p = buf; > > bytestream_put_be32(&p, 12); > -bytestream_put_be32(&p, tsmb_type); > +bytestream_put_be32(&p, MKBETAG('h','l','i','t')); > bytestream_put_be16(&p, s->hlit.start); > bytestream_put_be16(&p, s->hlit.end); > > @@ -144,13 +143,13 @@ static void encode_hlit(MovTextContext *s, uint32_t > tsmb_type) > } > } > > -static void encode_hclr(MovTextContext *s, uint32_t tsmb_type) > +static void encode_hclr(MovTextContext *s) > { > if (s->box_flags & HCLR_BOX) { > uint8_t buf[12], *p = buf; > > bytestream_put_be32(&p, 12); > -bytestream_put_be32(&p, tsmb_type); > +bytestream_put_be32(&p, MKBETAG('h','c','l','r')); > bytestream_put_be32(&p, s->hclr.color); > > av_bprint_append_any(&s->buffer, buf, 12); > @@ -158,9 +157,9 @@ static void encode_hclr(MovTextContext *s, uint32_t > tsmb_type) > } > > static const Box box_types[] = { > -{ MKBETAG('s','t','y','l'), encode_styl }, > -{ MKBETAG('h','l','i','t'), encode_hlit }, > -{ MKBETAG('h','c','l','r'), encode_hclr }, > +{ encode_styl }, > +{ encode_hlit }, > +{ encode_hclr }, > }; > > const static size_t box_count = FF_ARRAY_ELEMS(box_types); > @@ -682,7 +681,7 @@ static int mov_text_encode_frame(AVCodecContext *avctx, > unsigned char *buf, > #endif > > for (j = 0; j < box_count; j++) { > -box_types[j].encode(s, box_types[j].type); > +box_types[j].encode(s); > } > } > > -- > 2.25.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".
Re: [FFmpeg-devel] [PATCH v3 7/8] avcodec/movtextenc: Remove redundant function parameters
Zhao Zhili: > > >> On Oct 17, 2020, at 3:37 PM, Andreas Rheinhardt >> wrote: >> >> It makes no sense to call the functions to write styl, hlit or hclr boxes >> with a different box name than "styl", "hlit" or "hclr". Therefore this >> commit inlines these values in the functions, removes the function >> parameter containing the box's name and removes the (non obsolete) box >> names from the list of boxes. > > The extra parameter is useless for now, but it may add some flexibility in the > future, for example, two box types with similar handle logic. I don't know > whether such thing can happen. > Of course the parameter could be readded in the future if there is a usecase for it (after all, there are no ABI/API constraints as this is all internal to this translation unit). But right now this parameter has no benefit whatsoever. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavcodec/movtextenc.c | 23 +++ >> 1 file changed, 11 insertions(+), 12 deletions(-) >> >> diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c >> index 908b2bfde5..2082dc9b25 100644 >> --- a/libavcodec/movtextenc.c >> +++ b/libavcodec/movtextenc.c >> @@ -92,8 +92,7 @@ typedef struct { >> } MovTextContext; >> >> typedef struct { >> -uint32_t type; >> -void (*encode)(MovTextContext *s, uint32_t tsmb_type); >> +void (*encode)(MovTextContext *s); >> } Box; >> >> static void mov_text_cleanup(MovTextContext *s) >> @@ -102,13 +101,13 @@ static void mov_text_cleanup(MovTextContext *s) >> s->style_attributes_temp = s->d; >> } >> >> -static void encode_styl(MovTextContext *s, uint32_t tsmb_type) >> +static void encode_styl(MovTextContext *s) >> { >> if ((s->box_flags & STYL_BOX) && s->count) { >> uint8_t buf[12], *p = buf; >> >> bytestream_put_be32(&p, s->count * STYLE_RECORD_SIZE + SIZE_ADD); >> -bytestream_put_be32(&p, tsmb_type); >> +bytestream_put_be32(&p, MKBETAG('s','t','y','l')); >> bytestream_put_be16(&p, s->count); >> /*The above three attributes are hard coded for now >> but will come from ASS style in the future*/ >> @@ -130,13 +129,13 @@ static void encode_styl(MovTextContext *s, uint32_t >> tsmb_type) >> mov_text_cleanup(s); >> } >> >> -static void encode_hlit(MovTextContext *s, uint32_t tsmb_type) >> +static void encode_hlit(MovTextContext *s) >> { >> if (s->box_flags & HLIT_BOX) { >> uint8_t buf[12], *p = buf; >> >> bytestream_put_be32(&p, 12); >> -bytestream_put_be32(&p, tsmb_type); >> +bytestream_put_be32(&p, MKBETAG('h','l','i','t')); >> bytestream_put_be16(&p, s->hlit.start); >> bytestream_put_be16(&p, s->hlit.end); >> >> @@ -144,13 +143,13 @@ static void encode_hlit(MovTextContext *s, uint32_t >> tsmb_type) >> } >> } >> >> -static void encode_hclr(MovTextContext *s, uint32_t tsmb_type) >> +static void encode_hclr(MovTextContext *s) >> { >> if (s->box_flags & HCLR_BOX) { >> uint8_t buf[12], *p = buf; >> >> bytestream_put_be32(&p, 12); >> -bytestream_put_be32(&p, tsmb_type); >> +bytestream_put_be32(&p, MKBETAG('h','c','l','r')); >> bytestream_put_be32(&p, s->hclr.color); >> >> av_bprint_append_any(&s->buffer, buf, 12); >> @@ -158,9 +157,9 @@ static void encode_hclr(MovTextContext *s, uint32_t >> tsmb_type) >> } >> >> static const Box box_types[] = { >> -{ MKBETAG('s','t','y','l'), encode_styl }, >> -{ MKBETAG('h','l','i','t'), encode_hlit }, >> -{ MKBETAG('h','c','l','r'), encode_hclr }, >> +{ encode_styl }, >> +{ encode_hlit }, >> +{ encode_hclr }, >> }; >> >> const static size_t box_count = FF_ARRAY_ELEMS(box_types); >> @@ -682,7 +681,7 @@ static int mov_text_encode_frame(AVCodecContext *avctx, >> unsigned char *buf, >> #endif >> >> for (j = 0; j < box_count; j++) { >> -box_types[j].encode(s, box_types[j].type); >> +box_types[j].encode(s); >> } >> } >> >> -- >> 2.25.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 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] Unbreak av_malloc_max(0) API/ABI
Joakim Tjernlund: > On Fri, 2020-10-16 at 01:38 +0200, Andreas Rheinhardt wrote: >> CAUTION: This email originated from outside of the organization. Do not >> click links or open attachments unless you recognize the sender and know the >> content is safe. >> >> >> Joakim Tjernlund: >>> From >>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1095962&data=02%7C01%7Cjoakim.tjernlund%40infinera.com%7Cb1993f8740d849953d7908d871638074%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637384019459705602&sdata=Lcc%2BcVTlLU1y6EqrMXwfXJ0enHYlIRTBJyGkQgQEviA%3D&reserved=0 >>> >>> This seems to be caused by the custom handling of "av_max_alloc(0)" in >>> Chromium's ffmpeg fork to mean unlimited (added in [1]). >>> >>> Upstream ffmpeg doesn't treat 0 as a special value; versions before 4.3 >>> seemingly worked >>> because 32 was subtracted from max_alloc_size (set to 0 by Chromium) >>> resulting in an >>> integer underflow, making the effective limit be SIZE_MAX - 31. >>> >>> Now that the above underflow doesn't happen, the tab just crashes. The >>> upstream change >>> for no longer subtracting 32 from max_alloc_size was included in ffmpeg >>> 4.3. [2] >>> >>> [1] >>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fthird_party%2Fffmpeg%2F%2B%2F73563&data=02%7C01%7Cjoakim.tjernlund%40infinera.com%7Cb1993f8740d849953d7908d871638074%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637384019459705602&sdata=4%2BwE%2FMIcFSZlTdgzbVdbEBdYlO6Cdx%2Fh%2BLfjtrxCGec%3D&reserved=0 >>> [2] >>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFFmpeg%2FFFmpeg%2Fcommit%2F731c77589841&data=02%7C01%7Cjoakim.tjernlund%40infinera.com%7Cb1993f8740d849953d7908d871638074%7C285643de5f5b4b03a1530ae2dc8aaf77%7C1%7C0%7C637384019459705602&sdata=fuSKAPgqOiDsqwjl1m6P5IPF4a1K%2ByUK1c9e518aV6c%3D&reserved=0 >>> --- >>> >>> Restore av_malloc_max(0) to MAX_INT fixing MS Teams, Discord older chromium >>> etc. >>> >>> Signed-off-by: Joakim Tjernlund >>> --- >>> >>> v2: Cover the full API range 0-31 >>> >>> v3: Closer compat with < 4.3 ffmpeg >>> >>> libavutil/mem.c | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/libavutil/mem.c b/libavutil/mem.c >>> index cfb6d8a..bd1fb85 100644 >>> --- a/libavutil/mem.c >>> +++ b/libavutil/mem.c >>> @@ -71,6 +71,8 @@ void free(void *ptr); >>> static size_t max_alloc_size= INT_MAX; >>> >>> void av_max_alloc(size_t max){ >>> +if (max < 32) >>> +max = SIZE_MAX - max; /* be compatible to older(< 4.3) versions */ >>> max_alloc_size = max; >>> } >>> >>> >> For full compatibility it should be SIZE_MAX - 32 + max. >> > OK, v4 sent. > >> But why don't you go the way of fixing the broken apps? > > Because they are binary apps, in my case from Microsoft. > Their MS Teams is based on a Chromium/Electron framework that(I hope) will > be updated at some point. > And have you already reported this issue to them? - 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 3/9] avcodecc/asvdec: Avoid reversing input data twice
Andreas Rheinhardt: > Up until now the ASV2 decoder used an ordinary big-endian bitreader to > read data actually destined for a little-endian bitreader; this is done > by reversing the whole input packet bitwise, using the big-endian > bigreader and reversing (and shifting) the result again. This commit > stops this and instead uses a little-endian bitreader directly. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/asvdec.c | 77 ++--- > 1 file changed, 44 insertions(+), 33 deletions(-) > > diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c > index 6198188fc5..78e53b6402 100644 > --- a/libavcodec/asvdec.c > +++ b/libavcodec/asvdec.c > @@ -31,7 +31,6 @@ > #include "blockdsp.h" > #include "idctdsp.h" > #include "internal.h" > -#include "mathops.h" > #include "mpeg12data.h" > > #define CCP_VLC_BITS 5 > @@ -56,27 +55,24 @@ static av_cold void init_vlcs(ASV1Context *a) > INIT_VLC_STATIC(&ccp_vlc, CCP_VLC_BITS, 17, > &ff_asv_ccp_tab[0][1], 2, 1, > &ff_asv_ccp_tab[0][0], 2, 1, 32); > -INIT_VLC_STATIC(&dc_ccp_vlc, DC_CCP_VLC_BITS, 8, > -&ff_asv_dc_ccp_tab[0][1], 2, 1, > -&ff_asv_dc_ccp_tab[0][0], 2, 1, 16); > -INIT_VLC_STATIC(&ac_ccp_vlc, AC_CCP_VLC_BITS, 16, > -&ff_asv_ac_ccp_tab[0][1], 2, 1, > -&ff_asv_ac_ccp_tab[0][0], 2, 1, 64); > +INIT_CUSTOM_VLC_STATIC(&dc_ccp_vlc, DC_CCP_VLC_BITS, 8, > + &ff_asv_dc_ccp_tab[0][1], 2, 1, > + &ff_asv_dc_ccp_tab[0][0], 2, 1, > + INIT_VLC_OUTPUT_LE, 16); > +INIT_CUSTOM_VLC_STATIC(&ac_ccp_vlc, AC_CCP_VLC_BITS, 16, > + &ff_asv_ac_ccp_tab[0][1], 2, 1, > + &ff_asv_ac_ccp_tab[0][0], 2, 1, > + INIT_VLC_OUTPUT_LE, 64); > INIT_VLC_STATIC(&level_vlc, ASV1_LEVEL_VLC_BITS, 7, > &ff_asv_level_tab[0][1], 2, 1, > &ff_asv_level_tab[0][0], 2, 1, 16); > -INIT_VLC_STATIC(&asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63, > -&ff_asv2_level_tab[0][1], 2, 1, > -&ff_asv2_level_tab[0][0], 2, 1, 1024); > +INIT_CUSTOM_VLC_STATIC(&asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63, > + &ff_asv2_level_tab[0][1], 2, 1, > + &ff_asv2_level_tab[0][0], 2, 1, > + INIT_VLC_OUTPUT_LE, 1024); > } > } > > -// FIXME write a reversed bitstream reader to avoid the double reverse > -static inline int asv2_get_bits(GetBitContext *gb, int n) > -{ > -return ff_reverse[get_bits(gb, n) << (8 - n)]; > -} > - > static inline int asv1_get_level(GetBitContext *gb) > { > int code = get_vlc2(gb, level_vlc.table, ASV1_LEVEL_VLC_BITS, 1); > @@ -87,12 +83,31 @@ static inline int asv1_get_level(GetBitContext *gb) > return code - 3; > } > > +// get_vlc2() is big-endian in this file > +static inline int asv2_get_vlc2(GetBitContext *gb, VLC_TYPE (*table)[2], int > bits) > +{ > +unsigned int index; > +int code, n; > + > +OPEN_READER(re, gb); > +UPDATE_CACHE_LE(re, gb); > + > +index = SHOW_UBITS_LE(re, gb, bits); > +code = table[index][0]; > +n = table[index][1]; > +LAST_SKIP_BITS(re, gb, n); > + > +CLOSE_READER(re, gb); > + > +return code; > +} > + > static inline int asv2_get_level(GetBitContext *gb) > { > -int code = get_vlc2(gb, asv2_level_vlc.table, ASV2_LEVEL_VLC_BITS, 1); > +int code = asv2_get_vlc2(gb, asv2_level_vlc.table, ASV2_LEVEL_VLC_BITS); > > if (code == 31) > -return (int8_t) asv2_get_bits(gb, 8); > +return (int8_t) get_bits_le(gb, 8); > else > return code - 31; > } > @@ -132,11 +147,11 @@ static inline int asv2_decode_block(ASV1Context *a, > int16_t block[64]) > { > int i, count, ccp; > > -count = asv2_get_bits(&a->gb, 4); > +count = get_bits_le(&a->gb, 4); > > -block[0] = 8 * asv2_get_bits(&a->gb, 8); > +block[0] = 8 * get_bits_le(&a->gb, 8); > > -ccp = get_vlc2(&a->gb, dc_ccp_vlc.table, DC_CCP_VLC_BITS, 1); > +ccp = asv2_get_vlc2(&a->gb, dc_ccp_vlc.table, DC_CCP_VLC_BITS); > if (ccp) { > if (ccp & 4) > block[a->scantable.permutated[1]] = (asv2_get_level(&a->gb) * > a->intra_matrix[1]) >> 4; > @@ -147,7 +162,7 @@ static inline int asv2_decode_block(ASV1Context *a, > int16_t block[64]) > } > > for (i = 1; i < count + 1; i++) { > -const int ccp = get_vlc2(&a->gb, ac_ccp_vlc.table, AC_CCP_VLC_BITS, > 1); > +const int ccp = asv2_get_vlc2(&a->gb, ac_ccp_vlc.table, > AC_CCP_VLC_BITS); > > if (ccp) { > if (ccp & 8) > @@ -221,21 +236,18 @@ static int decode_frame
[FFmpeg-devel] [PATCH 02/11] avcodec/movtextdec: Fix leaks of strings upon reallocation failure
Up until now, the 3GPP Timed Text decoder used av_dynarray_add() for a list of font entries, a structure which contains an allocated string. The font entries are owned by the pointers in the dynamic array and are therefore unsuitable for av_dynarray_add() which simply frees the array, but not the font entries and of course not the strings. The latter all leak if reallocating the dynamic array fails. This commit fixes this. It stops reallocating the array altogether: After all, the final number of elements (pending errors) is already known in advance. Furthermore, the font entries are now the entries of the new array, i.e. the font entries are no longer allocated separately. This also removes one level of indirection. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 61 - 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 068bdb7802..ad60c77519 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -102,15 +102,14 @@ typedef struct { StyleBox *s_temp; HighlightBox h; HilightcolorBox c; -FontRecord **ftab; -FontRecord *ftab_temp; +FontRecord *ftab; TextWrapBox w; MovTextDefault d; uint8_t box_flags; uint16_t style_entries, ftab_entries; uint64_t tracksize; int size_var; -int count_s, count_f; +int count_s; int readorder; int frame_width; int frame_height; @@ -137,16 +136,8 @@ static void mov_text_cleanup(MovTextContext *m) static void mov_text_cleanup_ftab(MovTextContext *m) { -int i; -if (m->ftab_temp) -av_freep(&m->ftab_temp->font); -av_freep(&m->ftab_temp); -if (m->ftab) { -for(i = 0; i < m->count_f; i++) { -av_freep(&m->ftab[i]->font); -av_freep(&m->ftab[i]); -} -} +for (unsigned i = 0; i < m->ftab_entries; i++) +av_freep(&m->ftab[i].font); av_freep(&m->ftab); m->ftab_entries = 0; } @@ -156,9 +147,9 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) uint8_t *tx3g_ptr = avctx->extradata; int i, box_size, font_length; int8_t v_align, h_align; +unsigned ftab_entries; StyleBox s_default; -m->count_f = 0; m->ftab_entries = 0; box_size = BOX_SIZE_INITIAL; /* Size till ftab_entries */ if (avctx->extradata_size < box_size) @@ -223,7 +214,16 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) // ftab tx3g_ptr += 4; -m->ftab_entries = AV_RB16(tx3g_ptr); +// In case of broken header, init default font +m->d.font = ASS_DEFAULT_FONT; + +ftab_entries = AV_RB16(tx3g_ptr); +if (!ftab_entries) +return 0; +m->ftab = av_calloc(ftab_entries, sizeof(*m->ftab)); +if (!m->ftab) +return AVERROR(ENOMEM); +m->ftab_entries = ftab_entries; tx3g_ptr += 2; for (i = 0; i < m->ftab_entries; i++) { @@ -233,12 +233,7 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) mov_text_cleanup_ftab(m); return -1; } -m->ftab_temp = av_mallocz(sizeof(*m->ftab_temp)); -if (!m->ftab_temp) { -mov_text_cleanup_ftab(m); -return AVERROR(ENOMEM); -} -m->ftab_temp->fontID = AV_RB16(tx3g_ptr); +m->ftab[i].fontID = AV_RB16(tx3g_ptr); tx3g_ptr += 2; font_length = *tx3g_ptr++; @@ -247,26 +242,18 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) mov_text_cleanup_ftab(m); return -1; } -m->ftab_temp->font = av_malloc(font_length + 1); -if (!m->ftab_temp->font) { +m->ftab[i].font = av_malloc(font_length + 1); +if (!m->ftab[i].font) { mov_text_cleanup_ftab(m); return AVERROR(ENOMEM); } -memcpy(m->ftab_temp->font, tx3g_ptr, font_length); -m->ftab_temp->font[font_length] = '\0'; -av_dynarray_add(&m->ftab, &m->count_f, m->ftab_temp); -if (!m->ftab) { -mov_text_cleanup_ftab(m); -return AVERROR(ENOMEM); -} -m->ftab_temp = NULL; +memcpy(m->ftab[i].font, tx3g_ptr, font_length); +m->ftab[i].font[font_length] = '\0'; tx3g_ptr = tx3g_ptr + font_length; } -// In case of broken header, init default font -m->d.font = ASS_DEFAULT_FONT; for (i = 0; i < m->ftab_entries; i++) { -if (m->d.fontID == m->ftab[i]->fontID) -m->d.font = m->ftab[i]->font; +if (m->d.fontID == m->ftab[i].fontID) +m->d.font = m->ftab[i].font; } return 0; } @@ -405,8 +392,8 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, av_bprintf(buf, "{\\fs%d}", m->s[entry]->fontsize); if (m->s[entry]->style_fontID != m->d.fontID) for (i = 0; i < m
[FFmpeg-devel] [PATCH 04/11] avcodec/movtextdec: Simplify finding default font
There is no need to walk through the list of fonts twice. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index e46c932c20..974118c4c1 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -145,7 +145,7 @@ static void mov_text_cleanup_ftab(MovTextContext *m) static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) { uint8_t *tx3g_ptr = avctx->extradata; -int i, font_length, remaining = avctx->extradata_size - BOX_SIZE_INITIAL; +int i, j = -1, font_length, remaining = avctx->extradata_size - BOX_SIZE_INITIAL; int8_t v_align, h_align; unsigned ftab_entries; StyleBox s_default; @@ -230,6 +230,8 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) for (i = 0; i < m->ftab_entries; i++) { m->ftab[i].fontID = AV_RB16(tx3g_ptr); +if (m->ftab[i].fontID == m->d.fontID) +j = i; tx3g_ptr += 2; font_length = *tx3g_ptr++; @@ -247,10 +249,8 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) m->ftab[i].font[font_length] = '\0'; tx3g_ptr = tx3g_ptr + font_length; } -for (i = 0; i < m->ftab_entries; i++) { -if (m->d.fontID == m->ftab[i].fontID) -m->d.font = m->ftab[i].font; -} +if (j >= 0) +m->d.font = m->ftab[j].font; return 0; } -- 2.25.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 03/11] avcodec/movtextdec: Simplify checking for invalid extradata
Every font entry occupies at least three bytes, so checking early whether there is that much data available is a low-effort way to exclude invalid extradata. Doing so leads to an overall simplification. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index ad60c77519..e46c932c20 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -145,14 +145,13 @@ static void mov_text_cleanup_ftab(MovTextContext *m) static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) { uint8_t *tx3g_ptr = avctx->extradata; -int i, box_size, font_length; +int i, font_length, remaining = avctx->extradata_size - BOX_SIZE_INITIAL; int8_t v_align, h_align; unsigned ftab_entries; StyleBox s_default; m->ftab_entries = 0; -box_size = BOX_SIZE_INITIAL; /* Size till ftab_entries */ -if (avctx->extradata_size < box_size) +if (remaining < 0) return -1; // Display Flags @@ -220,6 +219,9 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) ftab_entries = AV_RB16(tx3g_ptr); if (!ftab_entries) return 0; +remaining -= 3 * ftab_entries; +if (remaining < 0) +return AVERROR_INVALIDDATA; m->ftab = av_calloc(ftab_entries, sizeof(*m->ftab)); if (!m->ftab) return AVERROR(ENOMEM); @@ -227,18 +229,12 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) tx3g_ptr += 2; for (i = 0; i < m->ftab_entries; i++) { - -box_size += 3; -if (avctx->extradata_size < box_size) { -mov_text_cleanup_ftab(m); -return -1; -} m->ftab[i].fontID = AV_RB16(tx3g_ptr); tx3g_ptr += 2; font_length = *tx3g_ptr++; -box_size = box_size + font_length; -if (avctx->extradata_size < box_size) { +remaining -= font_length; +if (remaining < 0) { mov_text_cleanup_ftab(m); return -1; } -- 2.25.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 01/11] avcodec/movtextdec: Reset counter of fonts when freeing them
If allocating fonts fails when reading the header, all fonts are freed, yet the counter of fonts is not reset and no error is returned; when subtitles are decoded lateron, the inexistent list of fonts is searched for the matching font for this particular entry which of course leads to a segfault. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 4a21dbf36d..068bdb7802 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -148,6 +148,7 @@ static void mov_text_cleanup_ftab(MovTextContext *m) } } av_freep(&m->ftab); +m->ftab_entries = 0; } static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) @@ -230,7 +231,6 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) box_size += 3; if (avctx->extradata_size < box_size) { mov_text_cleanup_ftab(m); -m->ftab_entries = 0; return -1; } m->ftab_temp = av_mallocz(sizeof(*m->ftab_temp)); @@ -245,7 +245,6 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) box_size = box_size + font_length; if (avctx->extradata_size < box_size) { mov_text_cleanup_ftab(m); -m->ftab_entries = 0; return -1; } m->ftab_temp->font = av_malloc(font_length + 1); -- 2.25.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 05/11] avcodec/movtextdec: Fix leaks on (re)allocation failure
Up until now, the 3GPP Timed Text decoder used av_dynarray_add() for a list of style entries. Said entries are inidiviually allocated and owned by the pointers in the dynamic array and are therefore unsuitable for av_dynarray_add() which simply frees the array, but not the entries on error. In this case the intended new entry also leaks because it has been forgotten to free it. This commit fixes this. It is now allocated in one go and not reallocated multiple times (and it won't be overallocated any more). After all, the final number of elements (pending errors) is already known in advance. Furthermore, the style entries are now the entries of the new array, i.e. they are no longer allocated separately. This also removes one level of indirection. Signed-off-by: Andreas Rheinhardt --- If there are several styl boxes in the same packet, the earlier code would add them to the list (and increment count_s), but lateron use style_entries (which only contains the number of entries in the last styl box) as count. So it used the number of the last successfully parsed styl box, but it used the entries from the earliest styl boxes. Weird. Anyway, given that one styl box can contain an entry for each character I only made sure that there are no memleaks when multiple styl boxes are present. libavcodec/movtextdec.c | 84 ++--- 1 file changed, 36 insertions(+), 48 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 974118c4c1..e9df979e92 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -98,8 +98,7 @@ typedef struct { typedef struct { AVClass *class; -StyleBox **s; -StyleBox *s_temp; +StyleBox *s; HighlightBox h; HilightcolorBox c; FontRecord *ftab; @@ -109,7 +108,6 @@ typedef struct { uint16_t style_entries, ftab_entries; uint64_t tracksize; int size_var; -int count_s; int readorder; int frame_width; int frame_height; @@ -123,13 +121,8 @@ typedef struct { static void mov_text_cleanup(MovTextContext *m) { -int i; if (m->box_flags & STYL_BOX) { -for(i = 0; i < m->count_s; i++) { -av_freep(&m->s[i]); -} av_freep(&m->s); -m->count_s = 0; m->style_entries = 0; } } @@ -283,50 +276,45 @@ static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) { int i; int style_entries = AV_RB16(tsmb); +StyleBox *tmp; tsmb += 2; // A single style record is of length 12 bytes. if (m->tracksize + m->size_var + 2 + style_entries * 12 > avpkt->size) return -1; +tmp = av_realloc_array(m->s, style_entries, sizeof(*m->s)); +if (!tmp) +return AVERROR(ENOMEM); +m->s = tmp; m->style_entries = style_entries; m->box_flags |= STYL_BOX; for(i = 0; i < m->style_entries; i++) { -m->s_temp = av_malloc(sizeof(*m->s_temp)); -if (!m->s_temp) { -mov_text_cleanup(m); -return AVERROR(ENOMEM); -} -m->s_temp->style_start = AV_RB16(tsmb); +StyleBox *style = &m->s[i]; +style->style_start = AV_RB16(tsmb); tsmb += 2; -m->s_temp->style_end = AV_RB16(tsmb); +style->style_end = AV_RB16(tsmb); -if ( m->s_temp->style_end < m->s_temp->style_start -|| (m->count_s && m->s_temp->style_start < m->s[m->count_s - 1]->style_end)) { -av_freep(&m->s_temp); +if ( style->style_end < style->style_start +|| (i && style->style_start < m->s[i - 1].style_end)) { mov_text_cleanup(m); return AVERROR(ENOMEM); } tsmb += 2; -m->s_temp->style_fontID = AV_RB16(tsmb); +style->style_fontID = AV_RB16(tsmb); tsmb += 2; -m->s_temp->style_flag = AV_RB8(tsmb); -m->s_temp->bold = !!(m->s_temp->style_flag & STYLE_FLAG_BOLD); -m->s_temp->italic = !!(m->s_temp->style_flag & STYLE_FLAG_ITALIC); -m->s_temp->underline = !!(m->s_temp->style_flag & STYLE_FLAG_UNDERLINE); +style->style_flag = AV_RB8(tsmb); +style->bold = !!(style->style_flag & STYLE_FLAG_BOLD); +style->italic= !!(style->style_flag & STYLE_FLAG_ITALIC); +style->underline = !!(style->style_flag & STYLE_FLAG_UNDERLINE); tsmb++; -m->s_temp->fontsize = AV_RB8(tsmb); +style->fontsize = AV_RB8(tsmb); tsmb++; -m->s_temp->color = AV_RB24(tsmb); +style->color = AV_RB24(tsmb); tsmb += 3; -m->s_temp->alpha = AV_RB8(tsmb); +style->alpha = AV_RB8(tsmb); tsmb++; -av_dynarray_add(&m->s, &m->count_s, m->s_temp); -if(!m->s) { -mov_text_cleanup(m); -return AVERROR(ENOMEM); -} } return 0; } @@ -376,29 +364,30 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end,
[FFmpeg-devel] [PATCH 11/11] avcodec/movtextdec: Reindentation
Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 95dfb2a0af..ad790bf44c 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -412,16 +412,16 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, av_log(avctx, AV_LOG_ERROR, "invalid UTF-8 byte in subtitle\n"); len = 1; } -switch (*text) { -case '\r': -break; -case '\n': -av_bprintf(buf, "\\N"); -break; -default: -av_bprint_append_data(buf, text, len); -break; -} +switch (*text) { +case '\r': +break; +case '\n': +av_bprintf(buf, "\\N"); +break; +default: +av_bprint_append_data(buf, text, len); +break; +} text += len; text_pos++; } -- 2.25.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 06/11] avcodec/movtextdec: Skip empty styles
They would either lead to unnecessary ASS tags being emitted (namely tags that are reset immediately thereafter) or would lead to problems when parsing: e.g. if a zero-length style immediately follows another style, the current code will end the preceding style and set the zero-length style as the next potentially active style, but it is only tested for activation when the next character is parsed at which point the current offset is already greater than both the starting as well as the end offset of the empty style. It will therefore neither be opened nor closed and all subsequent styles will be ignored. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 8 1 file changed, 8 insertions(+) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index e9df979e92..d167eddea5 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -302,6 +302,14 @@ static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) } tsmb += 2; +if (style->style_start == style->style_end) { +/* Skip this style as it applies to no character */ +tsmb += 8; +m->style_entries--; +i--; +continue; +} + style->style_fontID = AV_RB16(tsmb); tsmb += 2; style->style_flag = AV_RB8(tsmb); -- 2.25.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 08/11] avcodec/movtextdec: Remove unnecessary variable
style_active doesn't do anything any more: It is already assured that style_active is one when one reaches the end of a style. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index d46d64b6f2..1bfca8b79d 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -356,7 +356,6 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, MovTextContext *m = avctx->priv_data; int i = 0; int text_pos = 0; -int style_active = 0; int entry = 0; int color = m->d.color; @@ -374,16 +373,12 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, if ((m->box_flags & STYL_BOX) && entry < m->style_entries) { const StyleBox *style = &m->s[entry]; if (text_pos == style->style_end) { -if (style_active) { -av_bprintf(buf, "{\\r}"); -style_active = 0; -color = m->d.color; -} +av_bprintf(buf, "{\\r}"); +color = m->d.color; entry++; style++; } if (entry < m->style_entries && text_pos == style->style_start) { -style_active = 1; if (style->bold ^ m->d.bold) av_bprintf(buf, "{\\b%d}", style->bold); if (style->italic ^ m->d.italic) -- 2.25.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 09/11] avcodec/movtextdec: Avoid loop when writing UTF-8 character to AVBPrint
Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 1bfca8b79d..e5ce58a184 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -430,7 +430,6 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, av_log(avctx, AV_LOG_ERROR, "invalid UTF-8 byte in subtitle\n"); len = 1; } -for (i = 0; i < len; i++) { switch (*text) { case '\r': break; @@ -438,11 +437,10 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, av_bprintf(buf, "\\N"); break; default: -av_bprint_chars(buf, *text, 1); +av_bprint_append_data(buf, text, len); break; } -text++; -} +text += len; text_pos++; } -- 2.25.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 10/11] avcodec/movtextdec: Use bytestream API
Improves readability. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 74 - 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index e5ce58a184..95dfb2a0af 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -27,6 +27,7 @@ #include "libavutil/bprint.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" +#include "bytestream.h" #define STYLE_FLAG_BOLD (1<<0) #define STYLE_FLAG_ITALIC (1<<1) @@ -137,7 +138,7 @@ static void mov_text_cleanup_ftab(MovTextContext *m) static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) { -uint8_t *tx3g_ptr = avctx->extradata; +const uint8_t *tx3g_ptr = avctx->extradata; int i, j = -1, font_length, remaining = avctx->extradata_size - BOX_SIZE_INITIAL; int8_t v_align, h_align; unsigned ftab_entries; @@ -150,8 +151,8 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) // Display Flags tx3g_ptr += 4; // Alignment -h_align = *tx3g_ptr++; -v_align = *tx3g_ptr++; +h_align = bytestream_get_byte(&tx3g_ptr); +v_align = bytestream_get_byte(&tx3g_ptr); if (h_align == 0) { if (v_align == 0) m->d.alignment = TOP_LEFT; @@ -177,29 +178,24 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) m->d.alignment = BOTTOM_RIGHT; } // Background Color -m->d.back_color = AV_RB24(tx3g_ptr); -tx3g_ptr += 3; -m->d.back_alpha = AV_RB8(tx3g_ptr); -tx3g_ptr += 1; +m->d.back_color = bytestream_get_be24(&tx3g_ptr); +m->d.back_alpha = bytestream_get_byte(&tx3g_ptr); // BoxRecord tx3g_ptr += 8; // StyleRecord tx3g_ptr += 4; // fontID -m->d.fontID = AV_RB16(tx3g_ptr); -tx3g_ptr += 2; +m->d.fontID = bytestream_get_be16(&tx3g_ptr); // face-style-flags -s_default.style_flag = *tx3g_ptr++; +s_default.style_flag = bytestream_get_byte(&tx3g_ptr); m->d.bold = !!(s_default.style_flag & STYLE_FLAG_BOLD); m->d.italic = !!(s_default.style_flag & STYLE_FLAG_ITALIC); m->d.underline = !!(s_default.style_flag & STYLE_FLAG_UNDERLINE); // fontsize -m->d.fontsize = *tx3g_ptr++; +m->d.fontsize = bytestream_get_byte(&tx3g_ptr); // Primary color -m->d.color = AV_RB24(tx3g_ptr); -tx3g_ptr += 3; -m->d.alpha = AV_RB8(tx3g_ptr); -tx3g_ptr += 1; +m->d.color = bytestream_get_be24(&tx3g_ptr); +m->d.alpha = bytestream_get_byte(&tx3g_ptr); // FontRecord // FontRecord Size tx3g_ptr += 4; @@ -209,7 +205,7 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) // In case of broken header, init default font m->d.font = ASS_DEFAULT_FONT; -ftab_entries = AV_RB16(tx3g_ptr); +ftab_entries = bytestream_get_be16(&tx3g_ptr); if (!ftab_entries) return 0; remaining -= 3 * ftab_entries; @@ -219,14 +215,12 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) if (!m->ftab) return AVERROR(ENOMEM); m->ftab_entries = ftab_entries; -tx3g_ptr += 2; for (i = 0; i < m->ftab_entries; i++) { -m->ftab[i].fontID = AV_RB16(tx3g_ptr); +m->ftab[i].fontID = bytestream_get_be16(&tx3g_ptr); if (m->ftab[i].fontID == m->d.fontID) j = i; -tx3g_ptr += 2; -font_length = *tx3g_ptr++; +font_length = bytestream_get_byte(&tx3g_ptr); remaining -= font_length; if (remaining < 0) { @@ -238,9 +232,8 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) mov_text_cleanup_ftab(m); return AVERROR(ENOMEM); } -memcpy(m->ftab[i].font, tx3g_ptr, font_length); +bytestream_get_buffer(&tx3g_ptr, m->ftab[i].font, font_length); m->ftab[i].font[font_length] = '\0'; -tx3g_ptr = tx3g_ptr + font_length; } if (j >= 0) m->d.font = m->ftab[j].font; @@ -250,34 +243,31 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m) static int decode_twrp(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) { m->box_flags |= TWRP_BOX; -m->w.wrap_flag = *tsmb++; +m->w.wrap_flag = bytestream_get_byte(&tsmb); return 0; } static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) { m->box_flags |= HLIT_BOX; -m->h.hlit_start = AV_RB16(tsmb); -tsmb += 2; -m->h.hlit_end = AV_RB16(tsmb); -tsmb += 2; +m->h.hlit_start = bytestream_get_be16(&tsmb); +m->h.hlit_end = bytestream_get_be16(&tsmb); return 0; } static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) { m->box_flags |= HCLR_BOX; -memcpy(m->c.hlit_color, tsmb, 4); -tsmb += 4; +bytestream_get_buffer(&tsmb, m->c.hlit_color, 4); return 0; } static int decode_styl(cons
[FFmpeg-devel] [PATCH 07/11] avcodec/movtextdec: Fix immediately adjacent styles
The checks for whether a style should be opened/closed at the current character position are as follows: A variable entry contained the index of the currently active or potentially next active style. If the current character position coincided with the start of style[entry], the style was activated; this was followed by a check whether the current character position coincided with the end of style[entry]; if so, the style was deactivated and entry incremented. Afterwards the char was processed. The order of the checks leads to problems in case the endChar of style A coincides with the startChar of the next style (say B): Style B was never opened. When we are at said common position, the currently active style is A and so the start pos check does not succeed; but the end pos check does and it closes the currently active style A and increments entry. At the next iteration of the loop, the current character position is bigger than the start position of style B (which is style[entry]) and therefore the style is not activated. The solution is of course to first check for whether a style needs to be closed (and increment entry if it does) before checking whether the next style needs to be opened. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index d167eddea5..d46d64b6f2 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -373,7 +373,16 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, if ((m->box_flags & STYL_BOX) && entry < m->style_entries) { const StyleBox *style = &m->s[entry]; -if (text_pos == style->style_start) { +if (text_pos == style->style_end) { +if (style_active) { +av_bprintf(buf, "{\\r}"); +style_active = 0; +color = m->d.color; +} +entry++; +style++; +} +if (entry < m->style_entries && text_pos == style->style_start) { style_active = 1; if (style->bold ^ m->d.bold) av_bprintf(buf, "{\\b%d}", style->bold); @@ -395,14 +404,6 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, if (m->d.alpha != style->alpha) av_bprintf(buf, "{\\1a&H%02X&}", 255 - style->alpha); } -if (text_pos == style->style_end) { -if (style_active) { -av_bprintf(buf, "{\\r}"); -style_active = 0; -color = m->d.color; -} -entry++; -} } if (m->box_flags & HLIT_BOX) { if (text_pos == m->h.hlit_start) { -- 2.25.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] avcodec/av1dec: fix loading PrevGmParams for frames with primary_ref_frame none
Signed-off-by: James Almer --- libavcodec/av1dec.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 54aeba1812..04aaf5d148 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -109,13 +109,18 @@ static void read_global_param(AV1DecContext *s, int type, int ref, int idx) { uint8_t primary_frame, prev_frame; uint32_t abs_bits, prec_bits, round, prec_diff, sub, mx; -int32_t r; +int32_t r, prev_gm_param; primary_frame = s->raw_frame_header->primary_ref_frame; prev_frame = s->raw_frame_header->ref_frame_idx[primary_frame]; abs_bits = AV1_GM_ABS_ALPHA_BITS; prec_bits = AV1_GM_ALPHA_PREC_BITS; +if (s->raw_frame_header->primary_ref_frame == AV1_PRIMARY_REF_NONE) +prev_gm_param = s->cur_frame.gm_params[ref][idx]; +else +prev_gm_param = s->ref[prev_frame].gm_params[ref][idx]; + if (idx < 2) { if (type == AV1_WARP_MODEL_TRANSLATION) { abs_bits = AV1_GM_ABS_TRANS_ONLY_BITS - @@ -131,7 +136,7 @@ static void read_global_param(AV1DecContext *s, int type, int ref, int idx) prec_diff = AV1_WARPEDMODEL_PREC_BITS - prec_bits; sub = (idx % 3) == 2 ? (1 << prec_bits) : 0; mx = 1 << abs_bits; -r = (s->ref[prev_frame].gm_params[ref][idx] >> prec_diff) - sub; +r = (prev_gm_param >> prec_diff) - sub; s->cur_frame.gm_params[ref][idx] = (decode_signed_subexp_with_ref(s->raw_frame_header->gm_params[ref][idx], -- 2.28.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] [PATCH] avformat/format: ensure av_probe_input_buffer2() gives correct format
av_probe_input_buffer2() iterates until *fmt is found. If *fmt is not zeroed out beforehand, no probes will be taken because it is detected that format is already found at the beginning. In these cases method returns success with *fmt potentially containing the previous junk. Signed-off-by: zsugabubus --- libavformat/format.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/format.c b/libavformat/format.c index c47490c..7a5e846 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -229,6 +229,8 @@ int av_probe_input_buffer2(AVIOContext *pb, ff_const59 AVInputFormat **fmt, int score = 0; int ret2; +*fmt = NULL; + if (!max_probe_size) max_probe_size = PROBE_BUF_MAX; else if (max_probe_size < PROBE_BUF_MIN) { -- 2.28.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] [PATCH] avfilter: add frequency and phase shift filters
Signed-off-by: Paul B Mahol --- doc/filters.texi| 30 libavfilter/Makefile| 2 + libavfilter/af_afreqshift.c | 274 libavfilter/allfilters.c| 2 + 4 files changed, 308 insertions(+) create mode 100644 libavfilter/af_afreqshift.c diff --git a/doc/filters.texi b/doc/filters.texi index 50ef692077..428bf4ce92 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1314,6 +1314,21 @@ Force the output to either unsigned 8-bit or signed 16-bit stereo aformat=sample_fmts=u8|s16:channel_layouts=stereo @end example +@section afreqshift +Apply frequency shift to input audio samples. + +The filter accepts the following options: + +@table @option +@item shift +Specify frequency shift. Allowed range is -INT_MAX to INT_MAX. +Default value is 0.0. +@end table + +@subsection Commands + +This filter supports the above option as @ref{commands}. + @section agate A gate is mainly used to reduce lower parts of a signal. This kind of signal @@ -2056,6 +2071,21 @@ It accepts the following values: @end table @end table +@section aphaseshift +Apply phase shift to input audio samples. + +The filter accepts the following options: + +@table @option +@item shift +Specify phase shift. Allowed range is -M_PI to M_PI. +Default value is 0.0. +@end table + +@subsection Commands + +This filter supports the above option as @ref{commands}. + @section apulsator Audio pulsator is something between an autopanner and a tremolo. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 2691612179..480e191987 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -50,6 +50,7 @@ OBJS-$(CONFIG_AFFTDN_FILTER) += af_afftdn.o OBJS-$(CONFIG_AFFTFILT_FILTER) += af_afftfilt.o OBJS-$(CONFIG_AFIR_FILTER) += af_afir.o OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o +OBJS-$(CONFIG_AFREQSHIFT_FILTER) += af_afreqshift.o OBJS-$(CONFIG_AGATE_FILTER) += af_agate.o OBJS-$(CONFIG_AIIR_FILTER) += af_aiir.o OBJS-$(CONFIG_AINTEGRAL_FILTER) += af_aderivative.o @@ -69,6 +70,7 @@ OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o OBJS-$(CONFIG_APAD_FILTER) += af_apad.o OBJS-$(CONFIG_APERMS_FILTER) += f_perms.o OBJS-$(CONFIG_APHASER_FILTER)+= af_aphaser.o generate_wave_table.o +OBJS-$(CONFIG_APHASESHIFT_FILTER)+= af_afreqshift.o OBJS-$(CONFIG_APULSATOR_FILTER) += af_apulsator.o OBJS-$(CONFIG_AREALTIME_FILTER) += f_realtime.o OBJS-$(CONFIG_ARESAMPLE_FILTER) += af_aresample.o diff --git a/libavfilter/af_afreqshift.c b/libavfilter/af_afreqshift.c new file mode 100644 index 00..6173be5a61 --- /dev/null +++ b/libavfilter/af_afreqshift.c @@ -0,0 +1,274 @@ +/* + * 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 "libavutil/channel_layout.h" +#include "libavutil/ffmath.h" +#include "libavutil/opt.h" +#include "avfilter.h" +#include "audio.h" +#include "formats.h" + +typedef struct AFreqShift { +const AVClass *class; + +double shift; + +double c[12]; + +int64_t in_samples; + +AVFrame *i, *o; + +void (*filter_channel)(AVFilterContext *ctx, + int nb_samples, + int sample_rate, + const double *src, double *dst, + double *i, double *o); +} AFreqShift; + +static int query_formats(AVFilterContext *ctx) +{ +AVFilterFormats *formats = NULL; +AVFilterChannelLayouts *layouts = NULL; +static const enum AVSampleFormat sample_fmts[] = { +AV_SAMPLE_FMT_DBLP, +AV_SAMPLE_FMT_NONE +}; +int ret; + +formats = ff_make_format_list(sample_fmts); +if (!formats) +return AVERROR(ENOMEM); +ret = ff_set_common_formats(ctx, formats); +if (ret < 0) +return ret; + +layouts = ff_all_channel_counts(); +if (!layouts) +return AVERROR(ENOMEM); + +ret = ff_set_common_channel_layouts(ctx, layouts); +if (ret < 0) +return ret; + +formats = ff_all_samplerates(); +return ff_set_common_samplerates(ctx, formats); +} + +sta
[FFmpeg-devel] [PATCH 6/6] avformat/wavdec: Refuse to read chunks bigger than the filesize in w64_read_header()
Fixes: OOM Fixes: 26414/clusterfuzz-testcase-minimized-ffmpeg_dem_FWSE_fuzzer-5070632544632832 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/wavdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index d6ab0dde35..31ec14e3d7 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -902,6 +902,7 @@ static int w64_read_header(AVFormatContext *s) } else if (!memcmp(guid, ff_w64_guid_summarylist, 16)) { int64_t start, end, cur; uint32_t count, chunk_size, i; +int64_t filesize = avio_size(s->pb); start = avio_tell(pb); end = start + FFALIGN(size, INT64_C(8)) - 24; @@ -916,7 +917,7 @@ static int w64_read_header(AVFormatContext *s) chunk_key[4] = 0; avio_read(pb, chunk_key, 4); chunk_size = avio_rl32(pb); -if (chunk_size == UINT32_MAX) +if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize)) return AVERROR_INVALIDDATA; value = av_mallocz(chunk_size + 1); -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/6] avformat/ifv: Check that total frames do not overflow
Fixes: Infinite loop Fixes: 26392/clusterfuzz-testcase-minimized-ffmpeg_dem_GIF_fuzzer-5713658237419520 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/ifv.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavformat/ifv.c b/libavformat/ifv.c index f95e9b0e52..4e904fa828 100644 --- a/libavformat/ifv.c +++ b/libavformat/ifv.c @@ -210,6 +210,7 @@ static int ifv_read_packet(AVFormatContext *s, AVPacket *pkt) } if (!ev) { +uint64_t vframes, aframes; if (ifv->is_audio_present && !ea) { /*read new video and audio indexes*/ @@ -217,8 +218,12 @@ static int ifv_read_packet(AVFormatContext *s, AVPacket *pkt) ifv->next_audio_index = ifv->total_aframes; avio_skip(s->pb, 0x1c); -ifv->total_vframes += avio_rl32(s->pb); -ifv->total_aframes += avio_rl32(s->pb); +vframes = ifv->total_vframes + (uint64_t)avio_rl32(s->pb); +aframes = ifv->total_aframes + (uint64_t)avio_rl32(s->pb); +if (vframes > INT_MAX || aframes > INT_MAX) +return AVERROR_INVALIDDATA; +ifv->total_vframes = vframes; +ifv->total_aframes = aframes; avio_skip(s->pb, 0xc); if (avio_feof(s->pb)) @@ -240,7 +245,10 @@ static int ifv_read_packet(AVFormatContext *s, AVPacket *pkt) ifv->next_video_index = ifv->total_vframes; avio_skip(s->pb, 0x1c); -ifv->total_vframes += avio_rl32(s->pb); +vframes = ifv->total_vframes + (uint64_t)avio_rl32(s->pb); +if (vframes > INT_MAX) +return AVERROR_INVALIDDATA; +ifv->total_vframes = vframes; avio_skip(s->pb, 0x10); if (avio_feof(s->pb)) -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/6] avformat/genh: Check block_align for how it will be used in SDX2_DPCM
Fixes: signed integer overflow: 19922944 * 1024 cannot be represented in type 'int' Fixes: 26402/clusterfuzz-testcase-minimized-ffmpeg_dem_VMD_fuzzer-5745470053548032 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/genh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/genh.c b/libavformat/genh.c index 61adf49964..ed9910503d 100644 --- a/libavformat/genh.c +++ b/libavformat/genh.c @@ -87,7 +87,9 @@ static int genh_read_header(AVFormatContext *s) case 5: st->codecpar->codec_id = st->codecpar->block_align > 0 ? AV_CODEC_ID_PCM_S8_PLANAR : AV_CODEC_ID_PCM_S8; break; -case 6: st->codecpar->codec_id = AV_CODEC_ID_SDX2_DPCM;break; +case 6: if (st->codecpar->block_align > INT_MAX/1024) + return AVERROR_INVALIDDATA; + st->codecpar->codec_id = AV_CODEC_ID_SDX2_DPCM;break; case 7: ret = ff_alloc_extradata(st->codecpar, 2); 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/6] avformat/bethsoftvid: Check image dimensions before use
Fixes: signed integer overflow: 55255 * 53207 cannot be represented in type 'int' Fixes: 26387/clusterfuzz-testcase-minimized-ffmpeg_dem_AVS2_fuzzer-568426071552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/bethsoftvid.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c index 47a9a69330..709603daf5 100644 --- a/libavformat/bethsoftvid.c +++ b/libavformat/bethsoftvid.c @@ -28,6 +28,7 @@ */ #include "libavutil/channel_layout.h" +#include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" #include "avformat.h" #include "internal.h" @@ -72,6 +73,7 @@ static int vid_read_header(AVFormatContext *s) { BVID_DemuxContext *vid = s->priv_data; AVIOContext *pb = s->pb; +int ret; /* load main header. Contents: *bytes: 'V' 'I' 'D' @@ -84,6 +86,10 @@ static int vid_read_header(AVFormatContext *s) vid->bethsoft_global_delay = avio_rl16(pb); avio_rl16(pb); +ret = av_image_check_size(vid->width, vid->height, 0, s); +if (ret < 0) +return ret; + // wait until the first packet to create each stream vid->video_index = -1; vid->audio_index = -1; -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/6] avformat/asfdec_f: Check for negative ext_len
Fixes: Infinite loop Fixes: 26376/clusterfuzz-testcase-minimized-ffmpeg_dem_PCM_U32LE_fuzzer-6050518830678016 Fixes: 26377/clusterfuzz-testcase-minimized-ffmpeg_dem_TY_fuzzer-4838195726123008 Fixes: 26384/clusterfuzz-testcase-minimized-ffmpeg_dem_G729_fuzzer-5173450337157120 Fixes: 26396/clusterfuzz-testcase-minimized-ffmpeg_dem_PCM_S24BE_fuzzer-5071092206796800 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/asfdec_f.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index 103155e9e7..4fba6c08b0 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -607,6 +607,8 @@ static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size) ff_get_guid(pb, &g); size = avio_rl16(pb); ext_len = avio_rl32(pb); +if (ext_len < 0) +return AVERROR_INVALIDDATA; avio_skip(pb, ext_len); if (stream_num < 128 && i < FF_ARRAY_ELEMS(asf->streams[stream_num].payload)) { ASFPayload *p = &asf->streams[stream_num].payload[i]; -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/6] avformat/au: Check for EOF in au_read_annotation()
Fixes: Timeout (too looong -> 1 ms) Fixes: 26366/clusterfuzz-testcase-minimized-ffmpeg_dem_SDX_fuzzer-5655584843759616 Fixes: 26391/clusterfuzz-testcase-minimized-ffmpeg_dem_ALP_fuzzer-5484026133217280 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/au.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/au.c b/libavformat/au.c index c09f4da4c9..b4eb4f8477 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -84,6 +84,8 @@ static int au_read_annotation(AVFormatContext *s, int size) av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED); while (size-- > 0) { +if (avio_feof(pb)) +return AVERROR_EOF; c = avio_r8(pb); switch(state) { case PARSE_KEY: -- 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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer
___ From: ffmpeg-devel on behalf of Michael Niedermayer Sent: Thursday, October 15, 2020 11:35 PM To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hls: add support for SAMPLE-AES decryption in HLS demuxer On Thu, Oct 15, 2020 at 10:15:13PM +0530, Nachiket Tarate wrote: > Apple HTTP Live Streaming Sample Encryption: > > https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption > > Signed-off-by: Nachiket Tarate > --- > libavformat/Makefile | 2 +- > libavformat/hls.c| 93 ++- > libavformat/hls_sample_aes.c | 497 +++ > libavformat/hls_sample_aes.h | 64 + > libavformat/mpegts.c | 15 ++ > 5 files changed, 657 insertions(+), 14 deletions(-) > create mode 100644 libavformat/hls_sample_aes.c > create mode 100644 libavformat/hls_sample_aes.h This seems to break fate (segfault) I guess patchwork will notice it too but as i already tested and noticed ... --- ./tests/ref/fate/segment-mp4-to-ts 2020-10-10 18:08:06.500253003 +0200 +++ tests/data/fate/segment-mp4-to-ts 2020-10-15 20:03:24.586303460 +0200 @@ -128,5 +128,3 @@ 0, 428400, 435600, 3600, 156, 0xd2c3406c, F=0x0, S=1, 1, 0x00e000e0 0, 432000, 439200, 3600, 330, 0x150d9b60, F=0x0, S=1, 1, 0x00e000e0 0, 435600, 446400, 3600, 324, 0x558194ee, F=0x0, S=1, 1, 0x00e000e0 -0, 439200, 442800, 3600, 191, 0x108e54d1, F=0x0, S=1, 1, 0x00e000e0 -0, 442800, 45, 3600, 233, 0xac5b6486, F=0x0 Test segment-mp4-to-ts failed. Look at tests/data/fate/segment-mp4-to-ts.err for details. tests/Makefile:255: recipe for target 'fate-segment-mp4-to-ts' failed make: *** [fate-segment-mp4-to-ts] Error 139 I ran FATE with samples again but I didn't get segfault. Can you please help me to reproduce it ? -- Best Regards, Nachiket Tarate ___ 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 0/5] Fix adpcm_swf support in WAV.
On 16/10/20 4:22 pm, Zane van Iperen wrote: > > adpcm_swf support in WAV is completely broken. block_align isn't set > correctly, so > the demuxer gives incorrect packets to the decoder. The encoder doesn't > provide a > value for block_align, so it's set to 1. > > All of this has no bearing on (de)muxing to FLV. > > See https://trac.ffmpeg.org/ticket/5829. > Ping. I'd really like another set of eyes on this, especially because I'm tweaking the behaviour of the WAV muxer. Zane ___ 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] avfilter: add frequency and phase shift filters
On 18/10/20 6:45 am, Paul B Mahol wrote: > > Signed-off-by: Paul B Mahol > --- > doc/filters.texi| 30 > libavfilter/Makefile| 2 + > libavfilter/af_afreqshift.c | 274 > libavfilter/allfilters.c| 2 + > 4 files changed, 308 insertions(+) > create mode 100644 libavfilter/af_afreqshift.c lgtm ___ 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/on2avcdata: Deduplicate symbol tables
Saves about 10KB. Signed-off-by: Andreas Rheinhardt --- libavcodec/on2avcdata.c | 921 ++-- 1 file changed, 36 insertions(+), 885 deletions(-) diff --git a/libavcodec/on2avcdata.c b/libavcodec/on2avcdata.c index ec983572e6..0aa49cee78 100644 --- a/libavcodec/on2avcdata.c +++ b/libavcodec/on2avcdata.c @@ -158,8 +158,8 @@ const uint8_t ff_on2avc_scale_diff_bits[ON2AVC_SCALE_DIFFS] = { 21, }; -#define ON2AVC_CB1_CODES 41 -static const uint32_t on2avc_cb1_codes[ON2AVC_CB1_CODES] = { +#define ON2AVC_CB1_2_CODES 41 +static const uint32_t on2avc_cb1_codes[ON2AVC_CB1_2_CODES] = { 0x, 0x0022, 0x001C, 0x001B, 0x0024, 0x0030, 0x0029, 0x0027, 0x0021, 0x002B, 0x002E, 0x0020, 0x0026, 0x0033, 0x0031, 0x002C, 0x002A, 0x001E, @@ -169,7 +169,7 @@ static const uint32_t on2avc_cb1_codes[ON2AVC_CB1_CODES] = { 0x0023, 0x012F, 0x01F6, 0x01FE, 0x0095, }; -static const uint8_t on2avc_cb1_bits[ON2AVC_CB1_CODES] = { +static const uint8_t on2avc_cb1_bits[ON2AVC_CB1_2_CODES] = { 1, 6, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, @@ -179,7 +179,7 @@ static const uint8_t on2avc_cb1_bits[ON2AVC_CB1_CODES] = { 6, 9, 9, 9, 8, }; -static const uint16_t on2avc_cb1_syms[ON2AVC_CB1_CODES] = { +static const uint16_t on2avc_cb1_2_syms[ON2AVC_CB1_2_CODES] = { 0x, 0x0011, 0x001F, 0x00F1, 0x00FF, 0x0101, 0x010F, 0x0110, 0x01F0, 0x0F01, 0x0F0F, 0x0F10, 0x0FF0, 0x1001, 0x100F, 0x1010, 0x10F0, 0x1100, @@ -189,8 +189,7 @@ static const uint16_t on2avc_cb1_syms[ON2AVC_CB1_CODES] = { 0xFF00, 0xFF11, 0xFF1F, 0xFFF1, 0x, }; -#define ON2AVC_CB2_CODES 41 -static const uint32_t on2avc_cb2_codes[ON2AVC_CB2_CODES] = { +static const uint32_t on2avc_cb2_codes[ON2AVC_CB1_2_CODES] = { 0x0006, 0x0003, 0x001F, 0x001E, 0x, 0x0014, 0x0009, 0x000E, 0x000D, 0x000C, 0x0015, 0x0008, 0x0010, 0x000F, 0x0004, 0x0012, 0x0007, 0x0016, @@ -200,7 +199,7 @@ static const uint32_t on2avc_cb2_codes[ON2AVC_CB2_CODES] = { 0x0002, 0x0007, 0x005D, 0x005C, 0x0004, }; -static const uint8_t on2avc_cb2_bits[ON2AVC_CB2_CODES] = { +static const uint8_t on2avc_cb2_bits[ON2AVC_CB1_2_CODES] = { 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, @@ -210,18 +209,8 @@ static const uint8_t on2avc_cb2_bits[ON2AVC_CB2_CODES] = { 5, 7, 7, 7, 7, }; -static const uint16_t on2avc_cb2_syms[ON2AVC_CB2_CODES] = { -0x, 0x0011, 0x001F, 0x00F1, 0x00FF, 0x0101, -0x010F, 0x0110, 0x01F0, 0x0F01, 0x0F0F, 0x0F10, -0x0FF0, 0x1001, 0x100F, 0x1010, 0x10F0, 0x1100, -0x, 0x111F, 0x11F1, 0x11FF, 0x1F00, 0x1F11, -0x1F1F, 0x1FF1, 0x1FFF, 0xF001, 0xF00F, 0xF010, -0xF0F0, 0xF100, 0xF111, 0xF11F, 0xF1F1, 0xF1FF, -0xFF00, 0xFF11, 0xFF1F, 0xFFF1, 0x, -}; - -#define ON2AVC_CB3_CODES 313 -static const uint32_t on2avc_cb3_codes[ON2AVC_CB3_CODES] = { +#define ON2AVC_CB3_4_CODES 313 +static const uint32_t on2avc_cb3_codes[ON2AVC_CB3_4_CODES] = { 0x0, 0x00044, 0x00042, 0x00034, 0x0002E, 0x000CD, 0x002DF, 0x0024A, 0x000CC, 0x0022E, 0x002D6, 0x00031, 0x0003B, 0x00048, 0x00052, 0x00056, 0x001B8, 0x00160, @@ -277,7 +266,7 @@ static const uint32_t on2avc_cb3_codes[ON2AVC_CB3_CODES] = { 0x00115, }; -static const uint8_t on2avc_cb3_bits[ON2AVC_CB3_CODES] = { +static const uint8_t on2avc_cb3_bits[ON2AVC_CB3_4_CODES] = { 1, 7, 7, 6, 6, 8, 10, 10, 8, 10, 10, 6, 6, 7, 7, 7, 9, 9, @@ -333,7 +322,7 @@ static const uint8_t on2avc_cb3_bits[ON2AVC_CB3_CODES] = { 9, }; -static const uint16_t on2avc_cb3_syms[ON2AVC_CB3_CODES] = { +static const uint16_t on2avc_cb3_4_syms[ON2AVC_CB3_4_CODES] = { 0x, 0x0002, 0x000E, 0x0011, 0x001F, 0x0020, 0x0022, 0x002E, 0x00E0, 0x00E2, 0x00EE, 0x00F1, 0x00FF, 0x0101, 0x010F, 0x0110, 0x0112, 0x011E, @@ -389,8 +378,7 @@ static const uint16_t on2avc_cb3_syms[ON2AVC_CB3_CODES] = { 0x, }; -#define ON2AVC_CB4_CODES 313 -static const uint32_t on2avc_cb4_codes[ON2AVC_CB4_CODES] = { +static const uint32_t on2avc_cb4_codes[ON2AVC_CB3_4_CODES] = { 0x000A, 0x013B, 0x0127, 0x0004, 0x0015, 0x012C, 0x065F, 0x08CD, 0x016A, 0x08E7, 0x06BA, 0x001B, 0x001D, 0x0018, 0x000A, 0x0002, 0x00C0, 0x012B, @@ -446,7 +434,7 @@ static const uint32_t on2avc_cb4_codes[ON2AVC_CB4_CODES] = { 0x0026, }; -static const uint8_t on2avc_cb4_bits[ON2AVC_CB4_CODES] = { +static const uint8_t on2avc_cb4_bits[ON2AVC_CB3_4_CODES] = { 4, 9, 9, 6, 6, 9, 11, 12, 9, 12, 11, 6, 5, 6, 6, 6, 8, 9, @@ -502,64 +490,8 @@ static const uint8_t on2avc_cb4_bits[ON2AVC_CB4_CODES] = { 6, }; -static const uint16_t on2avc_cb4_syms[ON2AVC_CB4_CODES] = { -0x, 0x0002, 0x000E, 0x0011, 0x001F, 0x0020, -0x0022, 0x002E, 0x00E0, 0x00E2, 0x00EE, 0x00F1, -0x00FF, 0x0101, 0x010F, 0x0110, 0x0112, 0x011E, -0x0121, 0x012F, 0x01E1, 0x01EF, 0x01F0, 0x01F2, -0x01FE,
[FFmpeg-devel] [PATCH 2/3] avcodec/on2avc: Unify initializing quad and pair VLCs
Up until now, quad VLCs are initialized with codes of type uint32_t, pair VLCs with codes of type uint16_t. There were two separate loops in the decoder's init function for each type of VLC. This commit unifies this: The type of the codes are now passed in as void * and the actual size of the codes is obtained from a table. This approach also allows to use the smallest type for each VLC code table: some quad tables actually fitted in uint16_t. This allows to remove about 7KB from the binary. Signed-off-by: Andreas Rheinhardt --- libavcodec/on2avc.c | 21 - libavcodec/on2avcdata.c | 65 ++--- libavcodec/on2avcdata.h | 13 - 3 files changed, 40 insertions(+), 59 deletions(-) diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c index 00e5bf5397..e54c23cb1c 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -961,21 +961,12 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx) ff_on2avc_scale_diff_codes, 4, 4, 0)) { goto vlc_fail; } -for (i = 1; i < 9; i++) { -int idx = i - 1; -if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_quad_cb_elems[idx], - ff_on2avc_quad_cb_bits[idx], 1, 1, - ff_on2avc_quad_cb_codes[idx], 4, 4, - ff_on2avc_quad_cb_syms[idx], 2, 2, 0)) { -goto vlc_fail; -} -} -for (i = 9; i < 16; i++) { -int idx = i - 9; -if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_pair_cb_elems[idx], - ff_on2avc_pair_cb_bits[idx], 1, 1, - ff_on2avc_pair_cb_codes[idx], 2, 2, - ff_on2avc_pair_cb_syms[idx], 2, 2, 0)) { +for (i = 1; i < 16; i++) { +int idx = i - 1, codes_size = ff_on2avc_cb_codes_sizes[idx]; +if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_cb_elems[idx], + ff_on2avc_cb_bits[idx], 1, 1, + ff_on2avc_cb_codes[idx], codes_size, codes_size, + ff_on2avc_cb_syms[idx], 2, 2, 0)) { goto vlc_fail; } } diff --git a/libavcodec/on2avcdata.c b/libavcodec/on2avcdata.c index 0aa49cee78..482cf5e5e9 100644 --- a/libavcodec/on2avcdata.c +++ b/libavcodec/on2avcdata.c @@ -159,7 +159,7 @@ const uint8_t ff_on2avc_scale_diff_bits[ON2AVC_SCALE_DIFFS] = { }; #define ON2AVC_CB1_2_CODES 41 -static const uint32_t on2avc_cb1_codes[ON2AVC_CB1_2_CODES] = { +static const uint16_t on2avc_cb1_codes[ON2AVC_CB1_2_CODES] = { 0x, 0x0022, 0x001C, 0x001B, 0x0024, 0x0030, 0x0029, 0x0027, 0x0021, 0x002B, 0x002E, 0x0020, 0x0026, 0x0033, 0x0031, 0x002C, 0x002A, 0x001E, @@ -189,14 +189,14 @@ static const uint16_t on2avc_cb1_2_syms[ON2AVC_CB1_2_CODES] = { 0xFF00, 0xFF11, 0xFF1F, 0xFFF1, 0x, }; -static const uint32_t on2avc_cb2_codes[ON2AVC_CB1_2_CODES] = { -0x0006, 0x0003, 0x001F, 0x001E, 0x, 0x0014, -0x0009, 0x000E, 0x000D, 0x000C, 0x0015, 0x0008, -0x0010, 0x000F, 0x0004, 0x0012, 0x0007, 0x0016, -0x0005, 0x002F, 0x0017, 0x0006, 0x001D, 0x002C, -0x005E, 0x0014, 0x0016, 0x0006, 0x0011, 0x000A, -0x0013, 0x001C, 0x002D, 0x0015, 0x005F, 0x002E, -0x0002, 0x0007, 0x005D, 0x005C, 0x0004, +static const uint8_t on2avc_cb2_codes[ON2AVC_CB1_2_CODES] = { +0x06, 0x03, 0x1F, 0x1E, 0x00, 0x14, +0x09, 0x0E, 0x0D, 0x0C, 0x15, 0x08, +0x10, 0x0F, 0x04, 0x12, 0x07, 0x16, +0x05, 0x2F, 0x17, 0x06, 0x1D, 0x2C, +0x5E, 0x14, 0x16, 0x06, 0x11, 0x0A, +0x13, 0x1C, 0x2D, 0x15, 0x5F, 0x2E, +0x02, 0x07, 0x5D, 0x5C, 0x04, }; static const uint8_t on2avc_cb2_bits[ON2AVC_CB1_2_CODES] = { @@ -378,7 +378,7 @@ static const uint16_t on2avc_cb3_4_syms[ON2AVC_CB3_4_CODES] = { 0x, }; -static const uint32_t on2avc_cb4_codes[ON2AVC_CB3_4_CODES] = { +static const uint16_t on2avc_cb4_codes[ON2AVC_CB3_4_CODES] = { 0x000A, 0x013B, 0x0127, 0x0004, 0x0015, 0x012C, 0x065F, 0x08CD, 0x016A, 0x08E7, 0x06BA, 0x001B, 0x001D, 0x0018, 0x000A, 0x0002, 0x00C0, 0x012B, @@ -3162,7 +3162,7 @@ static const uint16_t on2avc_cb7_8_syms[ON2AVC_CB7_8_CODES] = { 0xFFEE, 0xFFF1, 0xFFF3, 0xFFFD, 0x, }; -static const uint32_t on2avc_cb8_codes[ON2AVC_CB7_8_CODES] = { +static const uint16_t on2avc_cb8_codes[ON2AVC_CB7_8_CODES] = { 0x028C, 0x05E6, 0xFAD9, 0x7DEF, 0x06CE, 0x004C, 0x0178, 0x0A1D, 0x00AE, 0x046E, 0x03D5, 0x3F58, 0x0EAA, 0x0233, 0x1A6A, 0x271F, 0x05CE, 0x0179, @@ -5996,42 +5996,35 @@ static const uint16_t on2avc_cb15_syms[ON2AVC_CB15_CODES] = { 0xFFFD, 0xFFFE, 0x, }; -const uint32_t * const ff_on2avc_quad_cb_codes[] = { -on2avc_cb1_codes, on2avc_cb2_codes, on2avc_cb3_codes, on2avc_cb4_codes, -on2avc_cb5_codes, on2avc_cb6_codes, on2avc_cb7_codes, on2avc_cb8_codes -}; - -const uint8_t * const ff_on2avc_quad_cb_bits[] = { -on2avc_
[FFmpeg-devel] [PATCH 3/3] avcodec/on2avc: Use least max_depth for get_vlc2()
The longest codes of any VLC codebooks are 18 bits long and the VLC tables itself use 9 bits; therefore it is sufficient to read twice from the table, yet this has been done thrice. Signed-off-by: Andreas Rheinhardt --- libavcodec/on2avc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c index e54c23cb1c..625e733ca3 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -195,7 +195,7 @@ static int on2avc_decode_quads(On2AVCContext *c, GetBitContext *gb, float *dst, int i, j, val, val1; for (i = 0; i < dst_size; i += 4) { -val = get_vlc2(gb, c->cb_vlc[type].table, 9, 3); +val = get_vlc2(gb, c->cb_vlc[type].table, 9, 2); for (j = 0; j < 4; j++) { val1 = sign_extend((val >> (12 - j * 4)) & 0xF, 4); @@ -228,7 +228,7 @@ static int on2avc_decode_pairs(On2AVCContext *c, GetBitContext *gb, float *dst, int i, val, val1, val2, sign; for (i = 0; i < dst_size; i += 2) { -val = get_vlc2(gb, c->cb_vlc[type].table, 9, 3); +val = get_vlc2(gb, c->cb_vlc[type].table, 9, 2); val1 = sign_extend(val >> 8, 8); val2 = sign_extend(val & 0xFF, 8); -- 2.25.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".