[FFmpeg-cvslog] lavc/pngdec: perform APNG blending in-place
ffmpeg | branch: master | Anton Khirnov | Thu Apr 1 15:45:45 2021 +0200| [485f3c7e30a0039d59f1daea0febea13ccb6c222] | committer: Anton Khirnov lavc/pngdec: perform APNG blending in-place Saves an allocation+free and two frame copies per each frame. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=485f3c7e30a0039d59f1daea0febea13ccb6c222 --- libavcodec/pngdec.c | 51 --- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 63c22063d9..095e4e86c2 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1068,8 +1068,12 @@ static void handle_p_frame_png(PNGDecContext *s, AVFrame *p) static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p) { +uint8_t *dst= p->data[0]; +ptrdiff_t dst_stride = p->linesize[0]; +const uint8_t *src= s->last_picture.f->data[0]; +ptrdiff_t src_stride = s->last_picture.f->linesize[0]; + size_t x, y; -uint8_t *buffer; if (s->blend_op == APNG_BLEND_OP_OVER && avctx->pix_fmt != AV_PIX_FMT_RGBA && @@ -1089,26 +1093,32 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, if (ret < 0) return ret; +src= s->last_picture.f->data[0]; +src_stride = s->last_picture.f->linesize[0]; + for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) { -memset(s->last_picture.f->data[0] + s->image_linesize * y + +memset(s->last_picture.f->data[0] + src_stride * y + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); } } -buffer = av_memdup(s->last_picture.f->data[0], s->image_linesize * s->height); -if (!buffer) -return AVERROR(ENOMEM); +// copy unchanged rectangles from the last frame +for (y = 0; y < s->y_offset; y++) +memcpy(dst + y * dst_stride, src + y * src_stride, p->width * s->bpp); +for (y = s->y_offset; y < s->y_offset + s->cur_h; y++) { +memcpy(dst + y * dst_stride, src + y * src_stride, s->x_offset * s->bpp); +memcpy(dst + y * dst_stride + (s->x_offset + s->cur_w) * s->bpp, + src + y * src_stride + (s->x_offset + s->cur_w) * s->bpp, + (p->width - s->cur_w - s->x_offset) * s->bpp); +} +for (y = s->y_offset + s->cur_h; y < p->height; y++) +memcpy(dst + y * dst_stride, src + y * src_stride, p->width * s->bpp); -// Perform blending -if (s->blend_op == APNG_BLEND_OP_SOURCE) { -for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { -size_t row_start = s->image_linesize * y + s->bpp * s->x_offset; -memcpy(buffer + row_start, p->data[0] + row_start, s->bpp * s->cur_w); -} -} else { // APNG_BLEND_OP_OVER +if (s->blend_op == APNG_BLEND_OP_OVER) { +// Perform blending for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { -uint8_t *foreground = p->data[0] + s->image_linesize * y + s->bpp * s->x_offset; -uint8_t *background = buffer + s->image_linesize * y + s->bpp * s->x_offset; +uint8_t *foreground = dst + dst_stride * y + s->bpp * s->x_offset; +const uint8_t *background = src + src_stride * y + s->bpp * s->x_offset; for (x = s->x_offset; x < s->x_offset + s->cur_w; ++x, foreground += s->bpp, background += s->bpp) { size_t b; uint8_t foreground_alpha, background_alpha, output_alpha; @@ -1135,18 +1145,17 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, break; } -if (foreground_alpha == 0) +if (foreground_alpha == 255) continue; -if (foreground_alpha == 255) { -memcpy(background, foreground, s->bpp); +if (foreground_alpha == 0) { +memcpy(foreground, background, s->bpp); continue; } if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { // TODO: Alpha blending with PAL8 will likely need the entire image converted over to RGBA first avpriv_request_sample(avctx, "Alpha blending palette samples"); -background[0] = foreground[0]; continue; } @@ -1164,15 +1173,11 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, } } output[b] = output_alpha; -memcpy(background, output, s->bpp); +memcpy(foreground, output, s->bpp); } } } -// Copy blended buffer into the frame and free -memcpy(p->data[0], buffer, s->image_linesize * s->height); -av_free(buffer);
[FFmpeg-cvslog] lavc/pngdec: remove unnecessary context variables
ffmpeg | branch: master | Anton Khirnov | Fri Apr 2 10:45:27 2021 +0200| [e20699dd1521fe388302cc363196182e9595bcbc] | committer: Anton Khirnov lavc/pngdec: remove unnecessary context variables Do not store the image buffer pointer/linesize in the context, just access them directly from the frame. Stop assuming that linesize is the same for the current and last frame. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e20699dd1521fe388302cc363196182e9595bcbc --- libavcodec/pngdec.c | 36 +--- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 095e4e86c2..ff705ef48a 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -77,8 +77,6 @@ typedef struct PNGDecContext { int has_trns; uint8_t transparent_color_be[6]; -uint8_t *image_buf; -int image_linesize; uint32_t palette[256]; uint8_t *crow_buf; uint8_t *last_row; @@ -330,27 +328,27 @@ static int percent_missing(PNGDecContext *s) } /* process exactly one decompressed row */ -static void png_handle_row(PNGDecContext *s) +static void png_handle_row(PNGDecContext *s, uint8_t *dst, ptrdiff_t dst_stride) { uint8_t *ptr, *last_row; int got_line; if (!s->interlace_type) { -ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp; +ptr = dst + dst_stride * (s->y + s->y_offset) + s->x_offset * s->bpp; if (s->y == 0) last_row = s->last_row; else -last_row = ptr - s->image_linesize; +last_row = ptr - dst_stride; ff_png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1, last_row, s->row_size, s->bpp); /* loco lags by 1 row so that it doesn't interfere with top prediction */ if (s->filter_type == PNG_FILTER_TYPE_LOCO && s->y > 0) { if (s->bit_depth == 16) { -deloco_rgb16((uint16_t *)(ptr - s->image_linesize), s->row_size / 2, +deloco_rgb16((uint16_t *)(ptr - dst_stride), s->row_size / 2, s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); } else { -deloco_rgb8(ptr - s->image_linesize, s->row_size, +deloco_rgb8(ptr - dst_stride, s->row_size, s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); } } @@ -370,7 +368,7 @@ static void png_handle_row(PNGDecContext *s) } else { got_line = 0; for (;;) { -ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp; +ptr = dst + dst_stride * (s->y + s->y_offset) + s->x_offset * s->bpp; if ((ff_png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) { /* if we already read one row, it is time to stop to * wait for the next one */ @@ -411,7 +409,8 @@ the_end:; } } -static int png_decode_idat(PNGDecContext *s, int length) +static int png_decode_idat(PNGDecContext *s, int length, + uint8_t *dst, ptrdiff_t dst_stride) { int ret; s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb)); @@ -427,7 +426,7 @@ static int png_decode_idat(PNGDecContext *s, int length) } if (s->zstream.avail_out == 0) { if (!(s->pic_state & PNG_ALLIMAGE)) { -png_handle_row(s); +png_handle_row(s, dst, dst_stride); } s->zstream.avail_out = s->crow_size; s->zstream.next_out = s->crow_buf; @@ -732,8 +731,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, } ff_dlog(avctx, "row_size=%d crow_size =%d\n", s->row_size, s->crow_size); -s->image_buf = p->data[0]; -s->image_linesize = p->linesize[0]; + /* copy the palette if needed */ if (avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t)); @@ -764,7 +762,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE) s->bpp -= byte_depth; -ret = png_decode_idat(s, length); +ret = png_decode_idat(s, length, p->data[0], p->linesize[0]); if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE) s->bpp += byte_depth; @@ -913,7 +911,7 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p) pd[8*i + 1]= (pd[i]>>6) & 1; pd[8*i + 0]= pd[i]>>7; } -pd += s->image_linesize; +pd += p->linesize[0]; } } else if (s->bits_per_pixel == 2) { int i, j; @@ -941,7 +939,7 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p) pd[4*i + 0]= ( pd[i]>>6 )*0x55; } } -
[FFmpeg-cvslog] lavc/pngdec: restructure exporting frame meta/side data
ffmpeg | branch: master | Anton Khirnov | Sat Mar 20 19:57:25 2021 +0100| [dfc90fa2ed768828d1ca8b3ecc421c05b9150383] | committer: Anton Khirnov lavc/pngdec: restructure exporting frame meta/side data This data cannot be stored in PNGDecContext.picture, because the corresponding chunks may be read after the call to ff_thread_finish_setup(), at which point modifying shared context data is a race. Store intermediate state in the context and then write it directly to the output frame. Fixes exporting frame metadata after 5663301560 Fixes #8972 Found-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dfc90fa2ed768828d1ca8b3ecc421c05b9150383 --- libavcodec/pngdec.c | 162 ++-- 1 file changed, 119 insertions(+), 43 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index ff705ef48a..f3295688c6 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -57,6 +57,18 @@ typedef struct PNGDecContext { ThreadFrame last_picture; ThreadFrame picture; +AVDictionary *frame_metadata; + +uint8_t iccp_name[82]; +uint8_t *iccp_data; +size_t iccp_data_len; + +int stereo_mode; + +int have_chrm; +uint32_t white_point[2]; +uint32_t display_primaries[3][2]; + enum PNGHeaderState hdr_state; enum PNGImageState pic_state; int width, height; @@ -508,8 +520,7 @@ static uint8_t *iso88591_to_utf8(const uint8_t *in, size_t size_in) return out; } -static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, - AVDictionary **dict) +static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed) { int ret, method; const uint8_t *data= s->gb.buffer; @@ -551,7 +562,7 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, return AVERROR(ENOMEM); } -av_dict_set(dict, kw_utf8, txt_utf8, +av_dict_set(&s->frame_metadata, kw_utf8, txt_utf8, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); return 0; } @@ -849,21 +860,21 @@ static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s, static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f) { int ret, cnt = 0; -uint8_t *data, profile_name[82]; AVBPrint bp; -AVFrameSideData *sd; -while ((profile_name[cnt++] = bytestream2_get_byte(&s->gb)) && cnt < 81); +while ((s->iccp_name[cnt++] = bytestream2_get_byte(&s->gb)) && cnt < 81); if (cnt > 80) { av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid name!\n"); -return AVERROR_INVALIDDATA; +ret = AVERROR_INVALIDDATA; +goto fail; } length = FFMAX(length - cnt, 0); if (bytestream2_get_byte(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid compression!\n"); -return AVERROR_INVALIDDATA; +ret = AVERROR_INVALIDDATA; +goto fail; } length = FFMAX(length - 1, 0); @@ -871,24 +882,19 @@ static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f) if ((ret = decode_zbuf(&bp, s->gb.buffer, s->gb.buffer + length)) < 0) return ret; -ret = av_bprint_finalize(&bp, (char **)&data); +av_freep(&s->iccp_data); +ret = av_bprint_finalize(&bp, (char **)&s->iccp_data); if (ret < 0) return ret; - -sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, bp.len); -if (!sd) { -av_free(data); -return AVERROR(ENOMEM); -} - -av_dict_set(&sd->metadata, "name", profile_name, 0); -memcpy(sd->data, data, bp.len); -av_free(data); +s->iccp_data_len = bp.len; /* ICC compressed data and CRC */ bytestream2_skip(&s->gb, length + 4); return 0; +fail: +s->iccp_name[0] = 0; +return ret; } static void handle_small_bpp(PNGDecContext *s, AVFrame *p) @@ -1183,7 +1189,6 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p, const AVPacket *avpkt) { const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE); -AVDictionary **metadatap = NULL; uint32_t tag, length; int decode_next_dat = 0; int i, ret; @@ -1251,7 +1256,6 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, } } -metadatap = &p->metadata; switch (tag) { case MKTAG('I', 'H', 'D', 'R'): if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0) @@ -1293,26 +1297,20 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, goto skip_tag; break; case MKTAG('t', 'E', 'X', 't'): -if (decode_text_chunk(s, length, 0, metadatap) < 0) +if (decode_text_chunk(s, length, 0) < 0) av_log(avctx, AV_LOG_WARNING, "Broken tEXt chunk\n"); bytestream2_skip(&s->
[FFmpeg-cvslog] lavc/pngdec: improve chunk length check
ffmpeg | branch: master | Anton Khirnov | Fri Apr 2 16:00:23 2021 +0200| [c73f288d9d002359b27153b4c7736e98015691e1] | committer: Anton Khirnov lavc/pngdec: improve chunk length check The length does not cover the chunk type or CRC. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c73f288d9d002359b27153b4c7736e98015691e1 --- libavcodec/pngdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index f3295688c6..0ff81d740c 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1217,7 +1217,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, } length = bytestream2_get_be32(&s->gb); -if (length > 0x7fff || length > bytestream2_get_bytes_left(&s->gb)) { +if (length > 0x7fff || length + 8 > bytestream2_get_bytes_left(&s->gb)) { av_log(avctx, AV_LOG_ERROR, "chunk too big\n"); ret = AVERROR_INVALIDDATA; goto fail; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] tests/fate: add tests for PNG side/meta data
ffmpeg | branch: master | Anton Khirnov | Sun Mar 21 11:10:34 2021 +0100| [6454d714fa73902b6dfbb9e0bbb56c68a28a3896] | committer: Anton Khirnov tests/fate: add tests for PNG side/meta data > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6454d714fa73902b6dfbb9e0bbb56c68a28a3896 --- tests/fate/image.mak | 8 +++ tests/ref/fate/png-frame-metadata | 4 tests/ref/fate/png-side-data | 46 +++ 3 files changed, 58 insertions(+) diff --git a/tests/fate/image.mak b/tests/fate/image.mak index eca8d5ab2c..226e190262 100644 --- a/tests/fate/image.mak +++ b/tests/fate/image.mak @@ -358,6 +358,14 @@ $(foreach CLSP,$(PNG_COLORSPACES),$(eval $(call FATE_IMGSUITE_PNG,$(CLSP FATE_PNG += fate-png-int-rgb24 fate-png-int-rgb24: CMD = framecrc -i $(TARGET_SAMPLES)/png1/lena-int_rgb24.png -sws_flags +accurate_rnd+bitexact +FATE_PNG += fate-png-frame-metadata +fate-png-frame-metadata: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries frame_tags \ +-i $(TARGET_SAMPLES)/filter/pixelart0.png + +FATE_PNG += fate-png-side-data +fate-png-side-data: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_frames \ +-i $(TARGET_SAMPLES)/png1/lena-int_rgb24.png + FATE_PNG-$(call DEMDEC, IMAGE2, PNG) += $(FATE_PNG) FATE_IMAGE += $(FATE_PNG-yes) fate-png: $(FATE_PNG-yes) diff --git a/tests/ref/fate/png-frame-metadata b/tests/ref/fate/png-frame-metadata new file mode 100644 index 00..7c6d1916eb --- /dev/null +++ b/tests/ref/fate/png-frame-metadata @@ -0,0 +1,4 @@ +[FRAME] +TAG:gamma=45455/10 +TAG:Software=GLDPNG ver 3.4 +[/FRAME] diff --git a/tests/ref/fate/png-side-data b/tests/ref/fate/png-side-data new file mode 100644 index 00..c3d1030f96 --- /dev/null +++ b/tests/ref/fate/png-side-data @@ -0,0 +1,46 @@ +[FRAME] +media_type=video +stream_index=0 +key_frame=1 +pkt_pts=0 +pkt_pts_time=0.00 +pkt_dts=0 +pkt_dts_time=0.00 +best_effort_timestamp=0 +best_effort_timestamp_time=0.00 +pkt_duration=1 +pkt_duration_time=0.04 +pkt_pos=0 +pkt_size=40194 +width=128 +height=128 +pix_fmt=rgb24 +sample_aspect_ratio=1:1 +pict_type=I +coded_picture_number=0 +display_picture_number=0 +interlaced_frame=1 +top_field_first=0 +repeat_pict=0 +color_range=pc +color_space=unknown +color_primaries=unknown +color_transfer=unknown +chroma_location=unspecified +[SIDE_DATA] +side_data_type=ICC profile +name=Photoshop ICC profile +size=3144 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=63999/10 +red_y=33001/10 +green_x=3/10 +green_y=6/10 +blue_x=15000/10 +blue_y=5999/10 +white_point_x=31269/10 +white_point_y=32899/10 +[/SIDE_DATA] +[/FRAME] ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/pngdec: use a separate bytestream reader for each chunk
ffmpeg | branch: master | Anton Khirnov | Fri Apr 2 16:33:44 2021 +0200| [c813f6deaf0737fa26f5e43841df35d2d0a69317] | committer: Anton Khirnov lavc/pngdec: use a separate bytestream reader for each chunk This makes sure that reading a truncated chunk will never overflow into the following chunk. It also allows to remove many repeated lines skipping over the trailing crc checksum. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c813f6deaf0737fa26f5e43841df35d2d0a69317 --- libavcodec/pngdec.c | 166 +++- 1 file changed, 72 insertions(+), 94 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 0ff81d740c..562c5ffea4 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -421,13 +421,12 @@ the_end:; } } -static int png_decode_idat(PNGDecContext *s, int length, +static int png_decode_idat(PNGDecContext *s, GetByteContext *gb, uint8_t *dst, ptrdiff_t dst_stride) { int ret; -s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb)); -s->zstream.next_in = s->gb.buffer; -bytestream2_skip(&s->gb, length); +s->zstream.avail_in = bytestream2_get_bytes_left(gb); +s->zstream.next_in = gb->buffer; /* decode one line if possible */ while (s->zstream.avail_in > 0) { @@ -520,11 +519,11 @@ static uint8_t *iso88591_to_utf8(const uint8_t *in, size_t size_in) return out; } -static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed) +static int decode_text_chunk(PNGDecContext *s, GetByteContext *gb, int compressed) { int ret, method; -const uint8_t *data= s->gb.buffer; -const uint8_t *data_end= data + length; +const uint8_t *data= gb->buffer; +const uint8_t *data_end= gb->buffer_end; const uint8_t *keyword = data; const uint8_t *keyword_end = memchr(keyword, 0, data_end - keyword); uint8_t *kw_utf8 = NULL, *text, *txt_utf8 = NULL; @@ -568,9 +567,9 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed) } static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s, - uint32_t length) + GetByteContext *gb) { -if (length != 13) +if (bytestream2_get_bytes_left(gb) != 13) return AVERROR_INVALIDDATA; if (s->pic_state & PNG_IDAT) { @@ -583,28 +582,27 @@ static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s, return AVERROR_INVALIDDATA; } -s->width = s->cur_w = bytestream2_get_be32(&s->gb); -s->height = s->cur_h = bytestream2_get_be32(&s->gb); +s->width = s->cur_w = bytestream2_get_be32(gb); +s->height = s->cur_h = bytestream2_get_be32(gb); if (av_image_check_size(s->width, s->height, 0, avctx)) { s->cur_w = s->cur_h = s->width = s->height = 0; av_log(avctx, AV_LOG_ERROR, "Invalid image size\n"); return AVERROR_INVALIDDATA; } -s->bit_depth= bytestream2_get_byte(&s->gb); +s->bit_depth= bytestream2_get_byte(gb); if (s->bit_depth != 1 && s->bit_depth != 2 && s->bit_depth != 4 && s->bit_depth != 8 && s->bit_depth != 16) { av_log(avctx, AV_LOG_ERROR, "Invalid bit depth\n"); goto error; } -s->color_type = bytestream2_get_byte(&s->gb); -s->compression_type = bytestream2_get_byte(&s->gb); +s->color_type = bytestream2_get_byte(gb); +s->compression_type = bytestream2_get_byte(gb); if (s->compression_type) { av_log(avctx, AV_LOG_ERROR, "Invalid compression method %d\n", s->compression_type); goto error; } -s->filter_type = bytestream2_get_byte(&s->gb); -s->interlace_type = bytestream2_get_byte(&s->gb); -bytestream2_skip(&s->gb, 4); /* crc */ +s->filter_type = bytestream2_get_byte(gb); +s->interlace_type = bytestream2_get_byte(gb); s->hdr_state |= PNG_IHDR; if (avctx->debug & FF_DEBUG_PICT_INFO) av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d " @@ -619,24 +617,24 @@ error: return AVERROR_INVALIDDATA; } -static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s) +static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s, + GetByteContext *gb) { if (s->pic_state & PNG_IDAT) { av_log(avctx, AV_LOG_ERROR, "pHYs after IDAT\n"); return AVERROR_INVALIDDATA; } -avctx->sample_aspect_ratio.num = bytestream2_get_be32(&s->gb); -avctx->sample_aspect_ratio.den = bytestream2_get_be32(&s->gb); +avctx->sample_aspect_ratio.num = bytestream2_get_be32(gb); +avctx->sample_aspect_ratio.den = bytestream2_get_be32(gb); if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.den < 0) avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; -bytestream2_skip(&s->gb, 1); /*
[FFmpeg-cvslog] avcodec/vc1dec: Fix memleak upon allocation error
ffmpeg | branch: master | Andreas Rheinhardt | Thu Apr 8 01:49:53 2021 +0200| [98060a198ef0bd213d0d0b029f8955fcd3be93d2] | committer: Andreas Rheinhardt avcodec/vc1dec: Fix memleak upon allocation error ff_vc1_decode_init_alloc_tables() had one error path that forgot to free already allocated buffers; these would then be overwritten on the next allocation attempt (or they would just not be freed in case this happened during init, as the decoders for which it is used do not have the FF_CODEC_CAP_INIT_CLEANUP set). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98060a198ef0bd213d0d0b029f8955fcd3be93d2 --- libavcodec/vc1dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index b702b76060..ea93e11588 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -384,7 +384,7 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v) if (s->avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || s->avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { for (i = 0; i < 4; i++) if (!(v->sr_rows[i >> 1][i & 1] = av_malloc(v->output_width))) -return AVERROR(ENOMEM); +goto error; } ret = ff_intrax8_common_init(s->avctx, &v->x8, &s->idsp, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf: postpone removal of FF_API_COMPUTE_PKT_FIELDS2
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 11:48:48 2021 +0200| [235386842daefcb73fbf4bb3db9186d47d0a58bb] | committer: Anton Khirnov lavf: postpone removal of FF_API_COMPUTE_PKT_FIELDS2 The infrastructure to fully handle generating timestamps e.g. for raw video streamcopy is still not present. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=235386842daefcb73fbf4bb3db9186d47d0a58bb --- libavformat/mux.c | 8 libavformat/version.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index e98b86a81e..d8746f3c13 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -541,7 +541,7 @@ fail: #define AV_PKT_FLAG_UNCODED_FRAME 0x2000 -#if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX +#if FF_API_COMPUTE_PKT_FIELDS2 FF_DISABLE_DEPRECATION_WARNINGS //FIXME merge with compute_pkt_fields static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *pkt) @@ -621,7 +621,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * case AVMEDIA_TYPE_AUDIO: frame_size = (pkt->flags & AV_PKT_FLAG_UNCODED_FRAME) ? (*(AVFrame **)pkt->data)->nb_samples : - av_get_audio_frame_duration(st->codec, pkt->size); + av_get_audio_frame_duration2(st->codecpar, pkt->size); /* HACK/FIXME, we skip the initial 0 size packets as they are most * likely equal to the encoder delay, but it would be better if we @@ -779,7 +779,7 @@ static int check_packet(AVFormatContext *s, AVPacket *pkt) static int prepare_input_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt) { -#if !FF_API_COMPUTE_PKT_FIELDS2 || !FF_API_LAVF_AVCTX +#if !FF_API_COMPUTE_PKT_FIELDS2 /* sanitize the timestamps */ if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { @@ -1140,7 +1140,7 @@ static int write_packet_common(AVFormatContext *s, AVStream *st, AVPacket *pkt, guess_pkt_duration(s, st, pkt); -#if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX +#if FF_API_COMPUTE_PKT_FIELDS2 if ((ret = compute_muxer_pkt_fields(s, st, pkt)) < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) return ret; #endif diff --git a/libavformat/version.h b/libavformat/version.h index b6023f9d2e..66068d4d56 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -55,9 +55,6 @@ * at once through the bump. This improves the git bisect-ability of the change. * */ -#ifndef FF_API_COMPUTE_PKT_FIELDS2 -#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif #ifndef FF_API_OLD_OPEN_CALLBACKS #define FF_API_OLD_OPEN_CALLBACKS (LIBAVFORMAT_VERSION_MAJOR < 59) #endif @@ -115,6 +112,9 @@ #ifndef FF_API_LAVF_PRIV_OPT #define FF_API_LAVF_PRIV_OPT(LIBAVFORMAT_VERSION_MAJOR < 60) #endif +#ifndef FF_API_COMPUTE_PKT_FIELDS2 +#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 60) +#endif #ifndef FF_API_R_FRAME_RATE ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/matroskaenc: fix avio_printf argument types after bump
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 10:41:59 2021 +0200| [450ab6ab43a71ab82c29bd76bc4b0280f96864de] | committer: Anton Khirnov lavf/matroskaenc: fix avio_printf argument types after bump Field precision supplied with the '*' specification must be an int. Also, make sure converting those fields to int does not overflow. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=450ab6ab43a71ab82c29bd76bc4b0280f96864de --- libavformat/matroskaenc.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index bbf231f2a4..609a588f78 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2143,7 +2143,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac mkv_track *track = &mkv->tracks[pkt->stream_index]; ebml_master blockgroup; buffer_size_t id_size, settings_size; -int size; +int size, id_size_int, settings_size_int; const char *id, *settings; int64_t ts = track->write_dts ? pkt->dts : pkt->pts; const int flags = 0; @@ -2156,6 +2156,10 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac &settings_size); settings = settings ? settings : ""; +if (id_size > INT_MAX - 2 || settings_size > INT_MAX - id_size - 2 || +pkt->size > INT_MAX - settings_size - id_size - 2) +return AVERROR(EINVAL); + size = id_size + 1 + settings_size + 1 + pkt->size; /* The following string is identical to the one in mkv_write_block so that @@ -2175,7 +2179,10 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac put_ebml_num(pb, track->track_num, track->track_num_size); avio_wb16(pb, ts - mkv->cluster_pts); avio_w8(pb, flags); -avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, pkt->size, pkt->data); + +id_size_int = id_size; +settings_size_int = settings_size; +avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size_int, id, settings_size_int, settings, pkt->size, pkt->data); put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, pkt->duration); end_ebml_master(pb, blockgroup); @@ -2352,6 +2359,8 @@ static int mkv_write_packet_internal(AVFormatContext *s, const AVPacket *pkt) } else { if (par->codec_id == AV_CODEC_ID_WEBVTT) { duration = mkv_write_vtt_blocks(s, pb, pkt); +if (duration < 0) +return duration; } else { ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(pkt->size, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc: postpone FF_API_AVCTX_TIMEBASE
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 13:01:58 2021 +0200| [96ee9d52e534f9ba6f29036a73cbae4e4bfe17a1] | committer: Anton Khirnov lavc: postpone FF_API_AVCTX_TIMEBASE There are still several decoders setting it and the situation is non-trivial to resolve. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96ee9d52e534f9ba6f29036a73cbae4e4bfe17a1 --- libavcodec/version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index 1444c19552..83ebba22d9 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -51,9 +51,6 @@ * at once through the bump. This improves the git bisect-ability of the change. */ -#ifndef FF_API_AVCTX_TIMEBASE -#define FF_API_AVCTX_TIMEBASE(LIBAVCODEC_VERSION_MAJOR < 59) -#endif #ifndef FF_API_CODED_FRAME #define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59) #endif @@ -168,5 +165,8 @@ #ifndef FF_API_INIT_PACKET #define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60) #endif +#ifndef FF_API_AVCTX_TIMEBASE +#define FF_API_AVCTX_TIMEBASE(LIBAVCODEC_VERSION_MAJOR < 60) +#endif #endif /* AVCODEC_VERSION_H */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/webvttenc: fix avio_printf argument types after bump
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 10:41:59 2021 +0200| [a03175bb67dd6ed32fe5020e462914bd1cb28964] | committer: Anton Khirnov lavf/webvttenc: fix avio_printf argument types after bump Field precision supplied with the '*' specification must be an int. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a03175bb67dd6ed32fe5020e462914bd1cb28964 --- libavformat/webvttenc.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c index 552bc38b65..809fead69f 100644 --- a/libavformat/webvttenc.c +++ b/libavformat/webvttenc.c @@ -65,6 +65,7 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt) { AVIOContext *pb = ctx->pb; buffer_size_t id_size, settings_size; +int id_size_int, settings_size_int; uint8_t *id, *settings; avio_printf(pb, "\n"); @@ -72,8 +73,12 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt) id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size); -if (id && id_size > 0) -avio_printf(pb, "%.*s\n", id_size, id); +if (id_size > INT_MAX) +return AVERROR(EINVAL); + +id_size_int = id_size; +if (id && id_size_int > 0) +avio_printf(pb, "%.*s\n", id_size_int, id); webvtt_write_time(pb, pkt->pts); avio_printf(pb, " --> "); @@ -82,8 +87,12 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt) settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size); -if (settings && settings_size > 0) -avio_printf(pb, " %.*s", settings_size, settings); +if (settings_size_int > INT_MAX) +return AVERROR(EINVAL); + +settings_size_int = settings_size; +if (settings && settings_size_int > 0) +avio_printf(pb, " %.*s", settings_size_int, settings); avio_printf(pb, "\n"); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/movenc: use framerate correctly in mov_write_tmcd_tag
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 20:07:15 2021 +0200| [f53f9fe51add5a140ae40e98a8873c1e2a3a5799] | committer: Anton Khirnov lavf/movenc: use framerate correctly in mov_write_tmcd_tag Current code uses its inverse. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f53f9fe51add5a140ae40e98a8873c1e2a3a5799 --- libavformat/movenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index c00e38e72f..0b620a802d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2353,8 +2353,8 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) return AVERROR(EINVAL); #endif } else { -frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.num, track->st->avg_frame_rate.den); -nb_frames = ROUNDED_DIV(track->st->avg_frame_rate.den, track->st->avg_frame_rate.num); +frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.den, track->st->avg_frame_rate.num); +nb_frames = ROUNDED_DIV(track->st->avg_frame_rate.num, track->st->avg_frame_rate.den); } if (nb_frames > 255) { @@ -6234,7 +6234,7 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde return AVERROR(ENOMEM); track->par->codec_type = AVMEDIA_TYPE_DATA; track->par->codec_tag = track->tag; -track->st->avg_frame_rate = av_inv_q(rate); +track->st->avg_frame_rate = rate; /* the tmcd track just contains one packet with the frame number */ pkt->data = data; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools/ffmpeg: when framerate is set, prefer its inverse as output timebase
ffmpeg | branch: master | Anton Khirnov | Mon Apr 5 10:44:36 2021 +0200| [72184cc4cba21abc42f3efff94bc0e36f8b270a9] | committer: Anton Khirnov fftools/ffmpeg: when framerate is set, prefer its inverse as output timebase Codec timebase is not well-defined for streamcopy, so it should only be used as the last resort. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72184cc4cba21abc42f3efff94bc0e36f8b270a9 --- fftools/ffmpeg.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 46bb014de8..8e6206647f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3151,8 +3151,12 @@ static int init_output_stream_streamcopy(OutputStream *ost) return ret; // copy timebase while removing common factors -if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) -ost->st->time_base = av_add_q(av_stream_get_codec_timebase(ost->st), (AVRational){0, 1}); +if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) { +if (ost->frame_rate.num) +ost->st->time_base = av_inv_q(ost->frame_rate); +else +ost->st->time_base = av_add_q(av_stream_get_codec_timebase(ost->st), (AVRational){0, 1}); +} // copy estimated duration as a hint to the muxer if (ost->st->duration <= 0 && ist->st->duration > 0) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf: do not derive timebase from avg_frame_rate
ffmpeg | branch: master | Anton Khirnov | Mon Apr 5 10:47:10 2021 +0200| [0ac10d05f944c0fd8c6107e92d1f9ab790108f67] | committer: Anton Khirnov lavf: do not derive timebase from avg_frame_rate avg_frame_rate is the _average_ framerate, its presence does not guarantee that the stream is CFR, so it should not be used for setting the timebase. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ac10d05f944c0fd8c6107e92d1f9ab790108f67 --- libavformat/utils.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index b671fa75b3..d9971d7fd3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -5892,9 +5892,6 @@ FF_ENABLE_DEPRECATION_WARNINGS enc_ctx->time_base = dec_ctx->time_base; } -if (ost->avg_frame_rate.num) -enc_ctx->time_base = av_inv_q(ost->avg_frame_rate); - av_reduce(&enc_ctx->time_base.num, &enc_ctx->time_base.den, enc_ctx->time_base.num, enc_ctx->time_base.den, INT_MAX); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools/ffmpeg: copy average framerate for streamcopy, when known
ffmpeg | branch: master | Anton Khirnov | Mon Apr 5 10:48:43 2021 +0200| [fa800d684fc0c08cc7f6698fdd8aa69eb76b011c] | committer: Anton Khirnov fftools/ffmpeg: copy average framerate for streamcopy, when known > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa800d684fc0c08cc7f6698fdd8aa69eb76b011c --- fftools/ffmpeg.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8e6206647f..3ad11452da 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3144,7 +3144,11 @@ static int init_output_stream_streamcopy(OutputStream *ost) if (!ost->frame_rate.num) ost->frame_rate = ist->framerate; -ost->st->avg_frame_rate = ost->frame_rate; + +if (ost->frame_rate.num) +ost->st->avg_frame_rate = ost->frame_rate; +else +ost->st->avg_frame_rate = ist->st->avg_frame_rate; ret = avformat_transfer_internal_stream_timing_info(of->ctx->oformat, ost->st, ist->st, copy_tb); if (ret < 0) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/pngdec: perform APNG blending in-place
ffmpeg | branch: master | Anton Khirnov | Thu Apr 1 15:45:45 2021 +0200| [5a50bd88db670f8c030a814e4cdb2a880dc1d4f4] | committer: Anton Khirnov lavc/pngdec: perform APNG blending in-place Saves an allocation+free and two frame copies per each frame. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5a50bd88db670f8c030a814e4cdb2a880dc1d4f4 --- libavcodec/pngdec.c | 51 --- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 63c22063d9..095e4e86c2 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1068,8 +1068,12 @@ static void handle_p_frame_png(PNGDecContext *s, AVFrame *p) static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p) { +uint8_t *dst= p->data[0]; +ptrdiff_t dst_stride = p->linesize[0]; +const uint8_t *src= s->last_picture.f->data[0]; +ptrdiff_t src_stride = s->last_picture.f->linesize[0]; + size_t x, y; -uint8_t *buffer; if (s->blend_op == APNG_BLEND_OP_OVER && avctx->pix_fmt != AV_PIX_FMT_RGBA && @@ -1089,26 +1093,32 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, if (ret < 0) return ret; +src= s->last_picture.f->data[0]; +src_stride = s->last_picture.f->linesize[0]; + for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) { -memset(s->last_picture.f->data[0] + s->image_linesize * y + +memset(s->last_picture.f->data[0] + src_stride * y + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); } } -buffer = av_memdup(s->last_picture.f->data[0], s->image_linesize * s->height); -if (!buffer) -return AVERROR(ENOMEM); +// copy unchanged rectangles from the last frame +for (y = 0; y < s->y_offset; y++) +memcpy(dst + y * dst_stride, src + y * src_stride, p->width * s->bpp); +for (y = s->y_offset; y < s->y_offset + s->cur_h; y++) { +memcpy(dst + y * dst_stride, src + y * src_stride, s->x_offset * s->bpp); +memcpy(dst + y * dst_stride + (s->x_offset + s->cur_w) * s->bpp, + src + y * src_stride + (s->x_offset + s->cur_w) * s->bpp, + (p->width - s->cur_w - s->x_offset) * s->bpp); +} +for (y = s->y_offset + s->cur_h; y < p->height; y++) +memcpy(dst + y * dst_stride, src + y * src_stride, p->width * s->bpp); -// Perform blending -if (s->blend_op == APNG_BLEND_OP_SOURCE) { -for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { -size_t row_start = s->image_linesize * y + s->bpp * s->x_offset; -memcpy(buffer + row_start, p->data[0] + row_start, s->bpp * s->cur_w); -} -} else { // APNG_BLEND_OP_OVER +if (s->blend_op == APNG_BLEND_OP_OVER) { +// Perform blending for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { -uint8_t *foreground = p->data[0] + s->image_linesize * y + s->bpp * s->x_offset; -uint8_t *background = buffer + s->image_linesize * y + s->bpp * s->x_offset; +uint8_t *foreground = dst + dst_stride * y + s->bpp * s->x_offset; +const uint8_t *background = src + src_stride * y + s->bpp * s->x_offset; for (x = s->x_offset; x < s->x_offset + s->cur_w; ++x, foreground += s->bpp, background += s->bpp) { size_t b; uint8_t foreground_alpha, background_alpha, output_alpha; @@ -1135,18 +1145,17 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, break; } -if (foreground_alpha == 0) +if (foreground_alpha == 255) continue; -if (foreground_alpha == 255) { -memcpy(background, foreground, s->bpp); +if (foreground_alpha == 0) { +memcpy(foreground, background, s->bpp); continue; } if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { // TODO: Alpha blending with PAL8 will likely need the entire image converted over to RGBA first avpriv_request_sample(avctx, "Alpha blending palette samples"); -background[0] = foreground[0]; continue; } @@ -1164,15 +1173,11 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, } } output[b] = output_alpha; -memcpy(background, output, s->bpp); +memcpy(foreground, output, s->bpp); } } } -// Copy blended buffer into the frame and free -memcpy(p->data[0], buffer, s->image_linesize * s->height); -av_free(buffer);
[FFmpeg-cvslog] lavc/pngdec: remove unnecessary context variables
ffmpeg | branch: master | Anton Khirnov | Fri Apr 2 10:45:27 2021 +0200| [89ea5057bf47880145419341258eadb3635448cf] | committer: Anton Khirnov lavc/pngdec: remove unnecessary context variables Do not store the image buffer pointer/linesize in the context, just access them directly from the frame. Stop assuming that linesize is the same for the current and last frame. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=89ea5057bf47880145419341258eadb3635448cf --- libavcodec/pngdec.c | 36 +--- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 095e4e86c2..ff705ef48a 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -77,8 +77,6 @@ typedef struct PNGDecContext { int has_trns; uint8_t transparent_color_be[6]; -uint8_t *image_buf; -int image_linesize; uint32_t palette[256]; uint8_t *crow_buf; uint8_t *last_row; @@ -330,27 +328,27 @@ static int percent_missing(PNGDecContext *s) } /* process exactly one decompressed row */ -static void png_handle_row(PNGDecContext *s) +static void png_handle_row(PNGDecContext *s, uint8_t *dst, ptrdiff_t dst_stride) { uint8_t *ptr, *last_row; int got_line; if (!s->interlace_type) { -ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp; +ptr = dst + dst_stride * (s->y + s->y_offset) + s->x_offset * s->bpp; if (s->y == 0) last_row = s->last_row; else -last_row = ptr - s->image_linesize; +last_row = ptr - dst_stride; ff_png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1, last_row, s->row_size, s->bpp); /* loco lags by 1 row so that it doesn't interfere with top prediction */ if (s->filter_type == PNG_FILTER_TYPE_LOCO && s->y > 0) { if (s->bit_depth == 16) { -deloco_rgb16((uint16_t *)(ptr - s->image_linesize), s->row_size / 2, +deloco_rgb16((uint16_t *)(ptr - dst_stride), s->row_size / 2, s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); } else { -deloco_rgb8(ptr - s->image_linesize, s->row_size, +deloco_rgb8(ptr - dst_stride, s->row_size, s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); } } @@ -370,7 +368,7 @@ static void png_handle_row(PNGDecContext *s) } else { got_line = 0; for (;;) { -ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp; +ptr = dst + dst_stride * (s->y + s->y_offset) + s->x_offset * s->bpp; if ((ff_png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) { /* if we already read one row, it is time to stop to * wait for the next one */ @@ -411,7 +409,8 @@ the_end:; } } -static int png_decode_idat(PNGDecContext *s, int length) +static int png_decode_idat(PNGDecContext *s, int length, + uint8_t *dst, ptrdiff_t dst_stride) { int ret; s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb)); @@ -427,7 +426,7 @@ static int png_decode_idat(PNGDecContext *s, int length) } if (s->zstream.avail_out == 0) { if (!(s->pic_state & PNG_ALLIMAGE)) { -png_handle_row(s); +png_handle_row(s, dst, dst_stride); } s->zstream.avail_out = s->crow_size; s->zstream.next_out = s->crow_buf; @@ -732,8 +731,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, } ff_dlog(avctx, "row_size=%d crow_size =%d\n", s->row_size, s->crow_size); -s->image_buf = p->data[0]; -s->image_linesize = p->linesize[0]; + /* copy the palette if needed */ if (avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t)); @@ -764,7 +762,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE) s->bpp -= byte_depth; -ret = png_decode_idat(s, length); +ret = png_decode_idat(s, length, p->data[0], p->linesize[0]); if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE) s->bpp += byte_depth; @@ -913,7 +911,7 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p) pd[8*i + 1]= (pd[i]>>6) & 1; pd[8*i + 0]= pd[i]>>7; } -pd += s->image_linesize; +pd += p->linesize[0]; } } else if (s->bits_per_pixel == 2) { int i, j; @@ -941,7 +939,7 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p) pd[4*i + 0]= ( pd[i]>>6 )*0x55; } } -
[FFmpeg-cvslog] lavc/pngdec: restructure exporting frame meta/side data
ffmpeg | branch: master | Anton Khirnov | Sat Mar 20 19:57:25 2021 +0100| [8d74baccff59192d395735036cd40a131a140391] | committer: Anton Khirnov lavc/pngdec: restructure exporting frame meta/side data This data cannot be stored in PNGDecContext.picture, because the corresponding chunks may be read after the call to ff_thread_finish_setup(), at which point modifying shared context data is a race. Store intermediate state in the context and then write it directly to the output frame. Fixes exporting frame metadata after 5663301560 Fixes #8972 Found-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d74baccff59192d395735036cd40a131a140391 --- libavcodec/pngdec.c | 162 ++-- 1 file changed, 119 insertions(+), 43 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index ff705ef48a..f3295688c6 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -57,6 +57,18 @@ typedef struct PNGDecContext { ThreadFrame last_picture; ThreadFrame picture; +AVDictionary *frame_metadata; + +uint8_t iccp_name[82]; +uint8_t *iccp_data; +size_t iccp_data_len; + +int stereo_mode; + +int have_chrm; +uint32_t white_point[2]; +uint32_t display_primaries[3][2]; + enum PNGHeaderState hdr_state; enum PNGImageState pic_state; int width, height; @@ -508,8 +520,7 @@ static uint8_t *iso88591_to_utf8(const uint8_t *in, size_t size_in) return out; } -static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, - AVDictionary **dict) +static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed) { int ret, method; const uint8_t *data= s->gb.buffer; @@ -551,7 +562,7 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, return AVERROR(ENOMEM); } -av_dict_set(dict, kw_utf8, txt_utf8, +av_dict_set(&s->frame_metadata, kw_utf8, txt_utf8, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); return 0; } @@ -849,21 +860,21 @@ static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s, static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f) { int ret, cnt = 0; -uint8_t *data, profile_name[82]; AVBPrint bp; -AVFrameSideData *sd; -while ((profile_name[cnt++] = bytestream2_get_byte(&s->gb)) && cnt < 81); +while ((s->iccp_name[cnt++] = bytestream2_get_byte(&s->gb)) && cnt < 81); if (cnt > 80) { av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid name!\n"); -return AVERROR_INVALIDDATA; +ret = AVERROR_INVALIDDATA; +goto fail; } length = FFMAX(length - cnt, 0); if (bytestream2_get_byte(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid compression!\n"); -return AVERROR_INVALIDDATA; +ret = AVERROR_INVALIDDATA; +goto fail; } length = FFMAX(length - 1, 0); @@ -871,24 +882,19 @@ static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f) if ((ret = decode_zbuf(&bp, s->gb.buffer, s->gb.buffer + length)) < 0) return ret; -ret = av_bprint_finalize(&bp, (char **)&data); +av_freep(&s->iccp_data); +ret = av_bprint_finalize(&bp, (char **)&s->iccp_data); if (ret < 0) return ret; - -sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, bp.len); -if (!sd) { -av_free(data); -return AVERROR(ENOMEM); -} - -av_dict_set(&sd->metadata, "name", profile_name, 0); -memcpy(sd->data, data, bp.len); -av_free(data); +s->iccp_data_len = bp.len; /* ICC compressed data and CRC */ bytestream2_skip(&s->gb, length + 4); return 0; +fail: +s->iccp_name[0] = 0; +return ret; } static void handle_small_bpp(PNGDecContext *s, AVFrame *p) @@ -1183,7 +1189,6 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p, const AVPacket *avpkt) { const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE); -AVDictionary **metadatap = NULL; uint32_t tag, length; int decode_next_dat = 0; int i, ret; @@ -1251,7 +1256,6 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, } } -metadatap = &p->metadata; switch (tag) { case MKTAG('I', 'H', 'D', 'R'): if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0) @@ -1293,26 +1297,20 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, goto skip_tag; break; case MKTAG('t', 'E', 'X', 't'): -if (decode_text_chunk(s, length, 0, metadatap) < 0) +if (decode_text_chunk(s, length, 0) < 0) av_log(avctx, AV_LOG_WARNING, "Broken tEXt chunk\n"); bytestream2_skip(&s->
[FFmpeg-cvslog] tests/fate: add tests for PNG side/meta data
ffmpeg | branch: master | Anton Khirnov | Sun Mar 21 11:10:34 2021 +0100| [8e4390de48b22cf6dd2307f0c29a3fef7016ef4c] | committer: Anton Khirnov tests/fate: add tests for PNG side/meta data > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8e4390de48b22cf6dd2307f0c29a3fef7016ef4c --- tests/fate/image.mak | 8 +++ tests/ref/fate/png-frame-metadata | 4 tests/ref/fate/png-side-data | 46 +++ 3 files changed, 58 insertions(+) diff --git a/tests/fate/image.mak b/tests/fate/image.mak index eca8d5ab2c..226e190262 100644 --- a/tests/fate/image.mak +++ b/tests/fate/image.mak @@ -358,6 +358,14 @@ $(foreach CLSP,$(PNG_COLORSPACES),$(eval $(call FATE_IMGSUITE_PNG,$(CLSP FATE_PNG += fate-png-int-rgb24 fate-png-int-rgb24: CMD = framecrc -i $(TARGET_SAMPLES)/png1/lena-int_rgb24.png -sws_flags +accurate_rnd+bitexact +FATE_PNG += fate-png-frame-metadata +fate-png-frame-metadata: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries frame_tags \ +-i $(TARGET_SAMPLES)/filter/pixelart0.png + +FATE_PNG += fate-png-side-data +fate-png-side-data: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_frames \ +-i $(TARGET_SAMPLES)/png1/lena-int_rgb24.png + FATE_PNG-$(call DEMDEC, IMAGE2, PNG) += $(FATE_PNG) FATE_IMAGE += $(FATE_PNG-yes) fate-png: $(FATE_PNG-yes) diff --git a/tests/ref/fate/png-frame-metadata b/tests/ref/fate/png-frame-metadata new file mode 100644 index 00..7c6d1916eb --- /dev/null +++ b/tests/ref/fate/png-frame-metadata @@ -0,0 +1,4 @@ +[FRAME] +TAG:gamma=45455/10 +TAG:Software=GLDPNG ver 3.4 +[/FRAME] diff --git a/tests/ref/fate/png-side-data b/tests/ref/fate/png-side-data new file mode 100644 index 00..c3d1030f96 --- /dev/null +++ b/tests/ref/fate/png-side-data @@ -0,0 +1,46 @@ +[FRAME] +media_type=video +stream_index=0 +key_frame=1 +pkt_pts=0 +pkt_pts_time=0.00 +pkt_dts=0 +pkt_dts_time=0.00 +best_effort_timestamp=0 +best_effort_timestamp_time=0.00 +pkt_duration=1 +pkt_duration_time=0.04 +pkt_pos=0 +pkt_size=40194 +width=128 +height=128 +pix_fmt=rgb24 +sample_aspect_ratio=1:1 +pict_type=I +coded_picture_number=0 +display_picture_number=0 +interlaced_frame=1 +top_field_first=0 +repeat_pict=0 +color_range=pc +color_space=unknown +color_primaries=unknown +color_transfer=unknown +chroma_location=unspecified +[SIDE_DATA] +side_data_type=ICC profile +name=Photoshop ICC profile +size=3144 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=63999/10 +red_y=33001/10 +green_x=3/10 +green_y=6/10 +blue_x=15000/10 +blue_y=5999/10 +white_point_x=31269/10 +white_point_y=32899/10 +[/SIDE_DATA] +[/FRAME] ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/pngdec: improve chunk length check
ffmpeg | branch: master | Anton Khirnov | Fri Apr 2 16:00:23 2021 +0200| [ae08eec6a1f2129cd231a0ab664f0f17b854d138] | committer: Anton Khirnov lavc/pngdec: improve chunk length check The length does not cover the chunk type or CRC. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae08eec6a1f2129cd231a0ab664f0f17b854d138 --- libavcodec/pngdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index f3295688c6..0ff81d740c 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1217,7 +1217,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, } length = bytestream2_get_be32(&s->gb); -if (length > 0x7fff || length > bytestream2_get_bytes_left(&s->gb)) { +if (length > 0x7fff || length + 8 > bytestream2_get_bytes_left(&s->gb)) { av_log(avctx, AV_LOG_ERROR, "chunk too big\n"); ret = AVERROR_INVALIDDATA; goto fail; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/pngdec: use a separate bytestream reader for each chunk
ffmpeg | branch: master | Anton Khirnov | Fri Apr 2 16:33:44 2021 +0200| [19e81034064586eb9873f7972aaa7915bc56c98e] | committer: Anton Khirnov lavc/pngdec: use a separate bytestream reader for each chunk This makes sure that reading a truncated chunk will never overflow into the following chunk. It also allows to remove many repeated lines skipping over the trailing crc checksum. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=19e81034064586eb9873f7972aaa7915bc56c98e --- libavcodec/pngdec.c | 166 +++- 1 file changed, 72 insertions(+), 94 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 0ff81d740c..562c5ffea4 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -421,13 +421,12 @@ the_end:; } } -static int png_decode_idat(PNGDecContext *s, int length, +static int png_decode_idat(PNGDecContext *s, GetByteContext *gb, uint8_t *dst, ptrdiff_t dst_stride) { int ret; -s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb)); -s->zstream.next_in = s->gb.buffer; -bytestream2_skip(&s->gb, length); +s->zstream.avail_in = bytestream2_get_bytes_left(gb); +s->zstream.next_in = gb->buffer; /* decode one line if possible */ while (s->zstream.avail_in > 0) { @@ -520,11 +519,11 @@ static uint8_t *iso88591_to_utf8(const uint8_t *in, size_t size_in) return out; } -static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed) +static int decode_text_chunk(PNGDecContext *s, GetByteContext *gb, int compressed) { int ret, method; -const uint8_t *data= s->gb.buffer; -const uint8_t *data_end= data + length; +const uint8_t *data= gb->buffer; +const uint8_t *data_end= gb->buffer_end; const uint8_t *keyword = data; const uint8_t *keyword_end = memchr(keyword, 0, data_end - keyword); uint8_t *kw_utf8 = NULL, *text, *txt_utf8 = NULL; @@ -568,9 +567,9 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed) } static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s, - uint32_t length) + GetByteContext *gb) { -if (length != 13) +if (bytestream2_get_bytes_left(gb) != 13) return AVERROR_INVALIDDATA; if (s->pic_state & PNG_IDAT) { @@ -583,28 +582,27 @@ static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s, return AVERROR_INVALIDDATA; } -s->width = s->cur_w = bytestream2_get_be32(&s->gb); -s->height = s->cur_h = bytestream2_get_be32(&s->gb); +s->width = s->cur_w = bytestream2_get_be32(gb); +s->height = s->cur_h = bytestream2_get_be32(gb); if (av_image_check_size(s->width, s->height, 0, avctx)) { s->cur_w = s->cur_h = s->width = s->height = 0; av_log(avctx, AV_LOG_ERROR, "Invalid image size\n"); return AVERROR_INVALIDDATA; } -s->bit_depth= bytestream2_get_byte(&s->gb); +s->bit_depth= bytestream2_get_byte(gb); if (s->bit_depth != 1 && s->bit_depth != 2 && s->bit_depth != 4 && s->bit_depth != 8 && s->bit_depth != 16) { av_log(avctx, AV_LOG_ERROR, "Invalid bit depth\n"); goto error; } -s->color_type = bytestream2_get_byte(&s->gb); -s->compression_type = bytestream2_get_byte(&s->gb); +s->color_type = bytestream2_get_byte(gb); +s->compression_type = bytestream2_get_byte(gb); if (s->compression_type) { av_log(avctx, AV_LOG_ERROR, "Invalid compression method %d\n", s->compression_type); goto error; } -s->filter_type = bytestream2_get_byte(&s->gb); -s->interlace_type = bytestream2_get_byte(&s->gb); -bytestream2_skip(&s->gb, 4); /* crc */ +s->filter_type = bytestream2_get_byte(gb); +s->interlace_type = bytestream2_get_byte(gb); s->hdr_state |= PNG_IHDR; if (avctx->debug & FF_DEBUG_PICT_INFO) av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d " @@ -619,24 +617,24 @@ error: return AVERROR_INVALIDDATA; } -static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s) +static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s, + GetByteContext *gb) { if (s->pic_state & PNG_IDAT) { av_log(avctx, AV_LOG_ERROR, "pHYs after IDAT\n"); return AVERROR_INVALIDDATA; } -avctx->sample_aspect_ratio.num = bytestream2_get_be32(&s->gb); -avctx->sample_aspect_ratio.den = bytestream2_get_be32(&s->gb); +avctx->sample_aspect_ratio.num = bytestream2_get_be32(gb); +avctx->sample_aspect_ratio.den = bytestream2_get_be32(gb); if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.den < 0) avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; -bytestream2_skip(&s->gb, 1); /*
[FFmpeg-cvslog] lavc: postpone FF_API_AVCTX_TIMEBASE
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 13:01:58 2021 +0200| [6ad79047a7de58d0c9d3372096908d9323dd2400] | committer: Anton Khirnov lavc: postpone FF_API_AVCTX_TIMEBASE There are still several decoders setting it and the situation is non-trivial to resolve. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6ad79047a7de58d0c9d3372096908d9323dd2400 --- libavcodec/version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index 1444c19552..83ebba22d9 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -51,9 +51,6 @@ * at once through the bump. This improves the git bisect-ability of the change. */ -#ifndef FF_API_AVCTX_TIMEBASE -#define FF_API_AVCTX_TIMEBASE(LIBAVCODEC_VERSION_MAJOR < 59) -#endif #ifndef FF_API_CODED_FRAME #define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59) #endif @@ -168,5 +165,8 @@ #ifndef FF_API_INIT_PACKET #define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60) #endif +#ifndef FF_API_AVCTX_TIMEBASE +#define FF_API_AVCTX_TIMEBASE(LIBAVCODEC_VERSION_MAJOR < 60) +#endif #endif /* AVCODEC_VERSION_H */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/webvttenc: fix avio_printf argument types after bump
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 10:41:59 2021 +0200| [9168a1c0e67b5c31727b12329b6f52d2bb5e0a14] | committer: Anton Khirnov lavf/webvttenc: fix avio_printf argument types after bump Field precision supplied with the '*' specification must be an int. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9168a1c0e67b5c31727b12329b6f52d2bb5e0a14 --- libavformat/webvttenc.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c index 552bc38b65..809fead69f 100644 --- a/libavformat/webvttenc.c +++ b/libavformat/webvttenc.c @@ -65,6 +65,7 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt) { AVIOContext *pb = ctx->pb; buffer_size_t id_size, settings_size; +int id_size_int, settings_size_int; uint8_t *id, *settings; avio_printf(pb, "\n"); @@ -72,8 +73,12 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt) id = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size); -if (id && id_size > 0) -avio_printf(pb, "%.*s\n", id_size, id); +if (id_size > INT_MAX) +return AVERROR(EINVAL); + +id_size_int = id_size; +if (id && id_size_int > 0) +avio_printf(pb, "%.*s\n", id_size_int, id); webvtt_write_time(pb, pkt->pts); avio_printf(pb, " --> "); @@ -82,8 +87,12 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt) settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size); -if (settings && settings_size > 0) -avio_printf(pb, " %.*s", settings_size, settings); +if (settings_size_int > INT_MAX) +return AVERROR(EINVAL); + +settings_size_int = settings_size; +if (settings && settings_size_int > 0) +avio_printf(pb, " %.*s", settings_size_int, settings); avio_printf(pb, "\n"); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/movenc: use framerate correctly in mov_write_tmcd_tag
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 20:07:15 2021 +0200| [7ec8229982de55f0c68008862e944583c18e4e47] | committer: Anton Khirnov lavf/movenc: use framerate correctly in mov_write_tmcd_tag Current code uses its inverse. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7ec8229982de55f0c68008862e944583c18e4e47 --- libavformat/movenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index c00e38e72f..0b620a802d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2353,8 +2353,8 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) return AVERROR(EINVAL); #endif } else { -frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.num, track->st->avg_frame_rate.den); -nb_frames = ROUNDED_DIV(track->st->avg_frame_rate.den, track->st->avg_frame_rate.num); +frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.den, track->st->avg_frame_rate.num); +nb_frames = ROUNDED_DIV(track->st->avg_frame_rate.num, track->st->avg_frame_rate.den); } if (nb_frames > 255) { @@ -6234,7 +6234,7 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde return AVERROR(ENOMEM); track->par->codec_type = AVMEDIA_TYPE_DATA; track->par->codec_tag = track->tag; -track->st->avg_frame_rate = av_inv_q(rate); +track->st->avg_frame_rate = rate; /* the tmcd track just contains one packet with the frame number */ pkt->data = data; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools/ffmpeg: when framerate is set, prefer its inverse as output timebase
ffmpeg | branch: master | Anton Khirnov | Mon Apr 5 10:44:36 2021 +0200| [0214da22cae08615f58f9769a4e8fb47d21aa687] | committer: Anton Khirnov fftools/ffmpeg: when framerate is set, prefer its inverse as output timebase Codec timebase is not well-defined for streamcopy, so it should only be used as the last resort. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0214da22cae08615f58f9769a4e8fb47d21aa687 --- fftools/ffmpeg.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 46bb014de8..8e6206647f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3151,8 +3151,12 @@ static int init_output_stream_streamcopy(OutputStream *ost) return ret; // copy timebase while removing common factors -if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) -ost->st->time_base = av_add_q(av_stream_get_codec_timebase(ost->st), (AVRational){0, 1}); +if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) { +if (ost->frame_rate.num) +ost->st->time_base = av_inv_q(ost->frame_rate); +else +ost->st->time_base = av_add_q(av_stream_get_codec_timebase(ost->st), (AVRational){0, 1}); +} // copy estimated duration as a hint to the muxer if (ost->st->duration <= 0 && ist->st->duration > 0) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/matroskaenc: fix avio_printf argument types after bump
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 10:41:59 2021 +0200| [2822bfbbfbc7a0013849758cc557226d48956424] | committer: Anton Khirnov lavf/matroskaenc: fix avio_printf argument types after bump Field precision supplied with the '*' specification must be an int. Also, make sure converting those fields to int does not overflow. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2822bfbbfbc7a0013849758cc557226d48956424 --- libavformat/matroskaenc.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index bbf231f2a4..609a588f78 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2143,7 +2143,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac mkv_track *track = &mkv->tracks[pkt->stream_index]; ebml_master blockgroup; buffer_size_t id_size, settings_size; -int size; +int size, id_size_int, settings_size_int; const char *id, *settings; int64_t ts = track->write_dts ? pkt->dts : pkt->pts; const int flags = 0; @@ -2156,6 +2156,10 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac &settings_size); settings = settings ? settings : ""; +if (id_size > INT_MAX - 2 || settings_size > INT_MAX - id_size - 2 || +pkt->size > INT_MAX - settings_size - id_size - 2) +return AVERROR(EINVAL); + size = id_size + 1 + settings_size + 1 + pkt->size; /* The following string is identical to the one in mkv_write_block so that @@ -2175,7 +2179,10 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, const AVPac put_ebml_num(pb, track->track_num, track->track_num_size); avio_wb16(pb, ts - mkv->cluster_pts); avio_w8(pb, flags); -avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, pkt->size, pkt->data); + +id_size_int = id_size; +settings_size_int = settings_size; +avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size_int, id, settings_size_int, settings, pkt->size, pkt->data); put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, pkt->duration); end_ebml_master(pb, blockgroup); @@ -2352,6 +2359,8 @@ static int mkv_write_packet_internal(AVFormatContext *s, const AVPacket *pkt) } else { if (par->codec_id == AV_CODEC_ID_WEBVTT) { duration = mkv_write_vtt_blocks(s, pb, pkt); +if (duration < 0) +return duration; } else { ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(pkt->size, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf: do not derive timebase from avg_frame_rate
ffmpeg | branch: master | Anton Khirnov | Mon Apr 5 10:47:10 2021 +0200| [04feb1c0382104c36d2297a277ffd1450d016d35] | committer: Anton Khirnov lavf: do not derive timebase from avg_frame_rate avg_frame_rate is the _average_ framerate, its presence does not guarantee that the stream is CFR, so it should not be used for setting the timebase. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=04feb1c0382104c36d2297a277ffd1450d016d35 --- libavformat/utils.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index b671fa75b3..d9971d7fd3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -5892,9 +5892,6 @@ FF_ENABLE_DEPRECATION_WARNINGS enc_ctx->time_base = dec_ctx->time_base; } -if (ost->avg_frame_rate.num) -enc_ctx->time_base = av_inv_q(ost->avg_frame_rate); - av_reduce(&enc_ctx->time_base.num, &enc_ctx->time_base.den, enc_ctx->time_base.num, enc_ctx->time_base.den, INT_MAX); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf: postpone removal of FF_API_COMPUTE_PKT_FIELDS2
ffmpeg | branch: master | Anton Khirnov | Sun Apr 4 11:48:48 2021 +0200| [270ddc2baf8a4533255e770e8e23b2a7cc399026] | committer: Anton Khirnov lavf: postpone removal of FF_API_COMPUTE_PKT_FIELDS2 The infrastructure to fully handle generating timestamps e.g. for raw video streamcopy is still not present. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=270ddc2baf8a4533255e770e8e23b2a7cc399026 --- libavformat/mux.c | 8 libavformat/version.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index e98b86a81e..d8746f3c13 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -541,7 +541,7 @@ fail: #define AV_PKT_FLAG_UNCODED_FRAME 0x2000 -#if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX +#if FF_API_COMPUTE_PKT_FIELDS2 FF_DISABLE_DEPRECATION_WARNINGS //FIXME merge with compute_pkt_fields static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *pkt) @@ -621,7 +621,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * case AVMEDIA_TYPE_AUDIO: frame_size = (pkt->flags & AV_PKT_FLAG_UNCODED_FRAME) ? (*(AVFrame **)pkt->data)->nb_samples : - av_get_audio_frame_duration(st->codec, pkt->size); + av_get_audio_frame_duration2(st->codecpar, pkt->size); /* HACK/FIXME, we skip the initial 0 size packets as they are most * likely equal to the encoder delay, but it would be better if we @@ -779,7 +779,7 @@ static int check_packet(AVFormatContext *s, AVPacket *pkt) static int prepare_input_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt) { -#if !FF_API_COMPUTE_PKT_FIELDS2 || !FF_API_LAVF_AVCTX +#if !FF_API_COMPUTE_PKT_FIELDS2 /* sanitize the timestamps */ if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { @@ -1140,7 +1140,7 @@ static int write_packet_common(AVFormatContext *s, AVStream *st, AVPacket *pkt, guess_pkt_duration(s, st, pkt); -#if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX +#if FF_API_COMPUTE_PKT_FIELDS2 if ((ret = compute_muxer_pkt_fields(s, st, pkt)) < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) return ret; #endif diff --git a/libavformat/version.h b/libavformat/version.h index b6023f9d2e..66068d4d56 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -55,9 +55,6 @@ * at once through the bump. This improves the git bisect-ability of the change. * */ -#ifndef FF_API_COMPUTE_PKT_FIELDS2 -#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif #ifndef FF_API_OLD_OPEN_CALLBACKS #define FF_API_OLD_OPEN_CALLBACKS (LIBAVFORMAT_VERSION_MAJOR < 59) #endif @@ -115,6 +112,9 @@ #ifndef FF_API_LAVF_PRIV_OPT #define FF_API_LAVF_PRIV_OPT(LIBAVFORMAT_VERSION_MAJOR < 60) #endif +#ifndef FF_API_COMPUTE_PKT_FIELDS2 +#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 60) +#endif #ifndef FF_API_R_FRAME_RATE ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools/ffmpeg: copy average framerate for streamcopy, when known
ffmpeg | branch: master | Anton Khirnov | Mon Apr 5 10:48:43 2021 +0200| [f6ea2ee005740247a446d28174943b3606721967] | committer: Anton Khirnov fftools/ffmpeg: copy average framerate for streamcopy, when known > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f6ea2ee005740247a446d28174943b3606721967 --- fftools/ffmpeg.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8e6206647f..3ad11452da 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3144,7 +3144,11 @@ static int init_output_stream_streamcopy(OutputStream *ost) if (!ost->frame_rate.num) ost->frame_rate = ist->framerate; -ost->st->avg_frame_rate = ost->frame_rate; + +if (ost->frame_rate.num) +ost->st->avg_frame_rate = ost->frame_rate; +else +ost->st->avg_frame_rate = ist->st->avg_frame_rate; ret = avformat_transfer_internal_stream_timing_info(of->ctx->oformat, ost->st, ist->st, copy_tb); if (ret < 0) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/rmdec: Fix memleaks upon read_header failure
ffmpeg | branch: master | Andreas Rheinhardt | Mon Jul 20 23:26:15 2020 +0200| [9a471c5437d34cd1e63520b47f50a0fa605a5688] | committer: Andreas Rheinhardt avformat/rmdec: Fix memleaks upon read_header failure For both the RealMedia as well as the IVR demuxer (which share the same context) each AVStream's priv_data contains an AVPacket that might contain data (even when reading the header) and therefore needs to be unreferenced. Up until now, this has not always been done: The RealMedia demuxer didn't do it when allocating a new stream's priv_data failed although there might be other streams with packets to unreference. (The reason for this was that until recently rm_read_close() couldn't handle an AVStream without priv_data, so one had to choose between a potential crash and a memleak.) The IVR demuxer meanwhile never ever called read_close so that the data already contained in packets leaks upon error. This patch fixes both demuxers by adding the appropriate cleanup code. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9a471c5437d34cd1e63520b47f50a0fa605a5688 --- libavformat/rmdec.c | 38 ++ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index b6f42183e8..1dec70e95b 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -614,8 +614,10 @@ static int rm_read_header(AVFormatContext *s) get_str8(pb, mime, sizeof(mime)); /* mimetype */ st->codecpar->codec_type = AVMEDIA_TYPE_DATA; st->priv_data = ff_rm_alloc_rmstream(); -if (!st->priv_data) -return AVERROR(ENOMEM); +if (!st->priv_data) { +ret = AVERROR(ENOMEM); +goto fail; +} size = avio_rb32(pb); codec_pos = avio_tell(pb); @@ -1249,20 +1251,19 @@ static int ivr_read_header(AVFormatContext *s) } for (n = 0; n < nb_streams; n++) { -st = avformat_new_stream(s, NULL); -if (!st) -return AVERROR(ENOMEM); -st->priv_data = ff_rm_alloc_rmstream(); -if (!st->priv_data) -return AVERROR(ENOMEM); +if (!(st = avformat_new_stream(s, NULL)) || +!(st->priv_data = ff_rm_alloc_rmstream())) { +ret = AVERROR(ENOMEM); +goto fail; +} if (avio_r8(pb) != 1) -return AVERROR_INVALIDDATA; +goto invalid_data; count = avio_rb32(pb); for (i = 0; i < count; i++) { if (avio_feof(pb)) -return AVERROR_INVALIDDATA; +goto invalid_data; type = avio_r8(pb); tlen = avio_rb32(pb); @@ -1274,25 +1275,25 @@ static int ivr_read_header(AVFormatContext *s) } else if (type == 4 && !strncmp(key, "OpaqueData", tlen)) { ret = ffio_ensure_seekback(pb, 4); if (ret < 0) -return ret; +goto fail; if (avio_rb32(pb) == MKBETAG('M', 'L', 'T', 'I')) { ret = rm_read_multi(s, pb, st, NULL); } else { if (avio_feof(pb)) -return AVERROR_INVALIDDATA; +goto invalid_data; avio_seek(pb, -4, SEEK_CUR); ret = ff_rm_read_mdpr_codecdata(s, pb, st, st->priv_data, len, NULL); } if (ret < 0) -return ret; +goto fail; } else if (type == 4) { int j; av_log(s, AV_LOG_DEBUG, "%s = '0x", key); for (j = 0; j < len; j++) { if (avio_feof(pb)) -return AVERROR_INVALIDDATA; +goto invalid_data; av_log(s, AV_LOG_DEBUG, "%X", avio_r8(pb)); } av_log(s, AV_LOG_DEBUG, "'\n"); @@ -1309,14 +1310,19 @@ static int ivr_read_header(AVFormatContext *s) } if (avio_r8(pb) != 6) -return AVERROR_INVALIDDATA; +goto invalid_data; avio_skip(pb, 12); avio_skip(pb, avio_rb64(pb) + pos - avio_tell(s->pb)); if (avio_r8(pb) != 8) -return AVERROR_INVALIDDATA; +goto invalid_data; avio_skip(pb, 8); return 0; +invalid_data: +ret = AVERROR_INVALIDDATA; +fail: +rm_read_close(s); +return ret; } static int ivr_read_packet(AVFormatContext *s, AVPacket *pkt) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/rmdec: Don't rely on unspecified order of evaluation
ffmpeg | branch: master | Andreas Rheinhardt | Wed Apr 7 13:37:09 2021 +0200| [4666ce0aef395fc7dfa2a718e8d238e58e635d2a] | committer: Andreas Rheinhardt avformat/rmdec: Don't rely on unspecified order of evaluation Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4666ce0aef395fc7dfa2a718e8d238e58e635d2a --- libavformat/rmdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 1dec70e95b..fc3bff4859 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -1312,7 +1312,7 @@ static int ivr_read_header(AVFormatContext *s) if (avio_r8(pb) != 6) goto invalid_data; avio_skip(pb, 12); -avio_skip(pb, avio_rb64(pb) + pos - avio_tell(s->pb)); +avio_seek(pb, avio_rb64(pb) + pos, SEEK_SET); if (avio_r8(pb) != 8) goto invalid_data; avio_skip(pb, 8); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/encode: Fix check for allowed LJPEG pixel formats
ffmpeg | branch: master | Andreas Rheinhardt | Tue Apr 6 00:32:39 2021 +0200| [6e8e9b7633d8b755e7a464a10ba5047f31cbd84d] | committer: Andreas Rheinhardt avcodec/encode: Fix check for allowed LJPEG pixel formats The pix_fmts of the LJPEG encoder already contain all supported pixel formats (including the ones only supported when strictness is unofficial or less); yet the check in ff_encode_preinit() ignored this list in case strictness is unofficial or less. But the encoder presumed that it is always applied and blacklists some of the entries in pix_fmts when strictness is > unofficial. The result is that if one uses an entry not on that list and sets strictness to unofficial, said entry passes both checks and this can lead to segfaults lateron (e.g. when using gray). Fix this by removing the exception for LJPEG in ff_encode_preinit(). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e8e9b7633d8b755e7a464a10ba5047f31cbd84d --- libavcodec/encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index a93bb3ccf7..89df5235da 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -565,7 +565,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if (avctx->pix_fmt == avctx->codec->pix_fmts[i]) break; if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE -&& !((avctx->codec_id == AV_CODEC_ID_MJPEG || avctx->codec_id == AV_CODEC_ID_LJPEG) +&& !(avctx->codec_id == AV_CODEC_ID_MJPEG && avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)) { char buf[128]; snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant
ffmpeg | branch: master | Andreas Rheinhardt | Tue Apr 6 15:45:42 2021 +0200| [d393c45051ddaf6146e7e29ec2ea97035a727529] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant The (deprecated) field AVCodecContext.mpeg_quant has no range restriction; MpegEncContext.mpeg_quant is restricted to 0..1. If the former is set, the latter is overwritten with it without checking the range. This can trigger an av_assert2() with the MPEG-4 encoder when writing said field. Fix this by just setting MpegEncContext.mpeg_quant to 1 if AVCodecContext.mpeg_quant is set. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d393c45051ddaf6146e7e29ec2ea97035a727529 --- libavcodec/mpegvideo_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 79c4071bad..651b1b5325 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -627,7 +627,7 @@ FF_ENABLE_DEPRECATION_WARNINGS #if FF_API_PRIVATE_OPT FF_DISABLE_DEPRECATION_WARNINGS if (avctx->mpeg_quant) -s->mpeg_quant = avctx->mpeg_quant; +s->mpeg_quant = 1; FF_ENABLE_DEPRECATION_WARNINGS #endif ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/pthread_frame: Factor initializing single thread out
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Sun Mar 21 05:00:09 2021 +0100| [04012468459fb896e3a24202d7cc69b1cdda1db4] | committer: Andreas Rheinhardt avcodec/pthread_frame: Factor initializing single thread out Signed-off-by: Andreas Rheinhardt (cherry picked from commit 24ee1514021e2a2419b1ae9a779e6a18a4add064) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=04012468459fb896e3a24202d7cc69b1cdda1db4 --- libavcodec/pthread_frame.c | 127 - 1 file changed, 68 insertions(+), 59 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 7bcb9a7bcc..311d6ed771 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -763,52 +763,12 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) avctx->codec = NULL; } -int ff_frame_thread_init(AVCodecContext *avctx) +static av_cold int init_thread(PerThreadContext *p, + FrameThreadContext *fctx, AVCodecContext *avctx, + AVCodecContext *src, const AVCodec *codec, int first) { -int thread_count = avctx->thread_count; -const AVCodec *codec = avctx->codec; -AVCodecContext *src = avctx; -FrameThreadContext *fctx; -int i, err = 0; - -if (!thread_count) { -int nb_cpus = av_cpu_count(); -// use number of cores + 1 as thread count if there is more than one -if (nb_cpus > 1) -thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS); -else -thread_count = avctx->thread_count = 1; -} - -if (thread_count <= 1) { -avctx->active_thread_type = 0; -return 0; -} - -avctx->internal->thread_ctx = fctx = av_mallocz(sizeof(FrameThreadContext)); -if (!fctx) -return AVERROR(ENOMEM); - -fctx->threads = av_mallocz_array(thread_count, sizeof(PerThreadContext)); -if (!fctx->threads) { -av_freep(&avctx->internal->thread_ctx); -return AVERROR(ENOMEM); -} - -pthread_mutex_init(&fctx->buffer_mutex, NULL); -pthread_mutex_init(&fctx->hwaccel_mutex, NULL); -pthread_mutex_init(&fctx->async_mutex, NULL); -pthread_cond_init(&fctx->async_cond, NULL); - -fctx->async_lock = 1; -fctx->delaying = 1; - -if (codec->type == AVMEDIA_TYPE_VIDEO) -avctx->delay = src->thread_count - 1; - -for (i = 0; i < thread_count; i++) { AVCodecContext *copy = av_malloc(sizeof(AVCodecContext)); -PerThreadContext *p = &fctx->threads[i]; +int err; pthread_mutex_init(&p->mutex, NULL); pthread_mutex_init(&p->progress_mutex, NULL); @@ -819,22 +779,19 @@ int ff_frame_thread_init(AVCodecContext *avctx) p->frame = av_frame_alloc(); if (!p->frame) { av_freep(©); -err = AVERROR(ENOMEM); -goto error; +return AVERROR(ENOMEM); } p->avpkt = av_packet_alloc(); if (!p->avpkt) { av_freep(©); -err = AVERROR(ENOMEM); -goto error; +return AVERROR(ENOMEM); } p->parent = fctx; p->avctx = copy; if (!copy) { -err = AVERROR(ENOMEM); -goto error; +return AVERROR(ENOMEM); } *copy = *src; @@ -842,8 +799,7 @@ int ff_frame_thread_init(AVCodecContext *avctx) copy->internal = av_malloc(sizeof(AVCodecInternal)); if (!copy->internal) { copy->priv_data = NULL; -err = AVERROR(ENOMEM); -goto error; +return AVERROR(ENOMEM); } *copy->internal = *src->internal; copy->internal->thread_ctx = p; @@ -854,27 +810,27 @@ int ff_frame_thread_init(AVCodecContext *avctx) if (codec->priv_data_size) { copy->priv_data = av_mallocz(codec->priv_data_size); if (!copy->priv_data) { -err = AVERROR(ENOMEM); -goto error; +return AVERROR(ENOMEM); } if (codec->priv_class) { *(const AVClass **)copy->priv_data = codec->priv_class; err = av_opt_copy(copy->priv_data, src->priv_data); if (err < 0) -goto error; +return err; } } -if (i) +if (!first) copy->internal->is_copy = 1; if (codec->init) err = codec->init(copy); +if (err < 0) { +return err; +} -if (err) goto error; - -if (!i) +if (first) update_context_from_thread(avctx, copy, 1); atomic_init(&p->debug_threads, (copy->debug & FF_DEBUG_THREADS) != 0); @@ -882,6 +838,59 @@ int ff_frame_thread_init(AVCodecContext *avctx) err = AVERROR(pthread_create(&p->thread, NULL, frame_worker_thread, p)); p->thread_in
[FFmpeg-cvslog] avcodec/pthread_frame: Fix cleanup during init
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Thu Feb 11 13:45:31 2021 +0100| [aa8f8748caa15d99a77537cbd5bbec014a6630b8] | committer: Andreas Rheinhardt avcodec/pthread_frame: Fix cleanup during init In case an error happened when setting up the child threads, ff_frame_thread_init() would up until now call ff_frame_thread_free() to clean up all threads set up so far, including the current, not properly initialized one. But a half-allocated context needs special handling which ff_frame_thread_frame_free() doesn't provide. Notably, if allocating the AVCodecInternal, the codec's private data or setting the options fails, the codec's close function will be called (if there is one); it will also be called if the codec's init function fails, regardless of whether the FF_CODEC_CAP_INIT_CLEANUP is set. This is not supported by all codecs; in ticket #9099 it led to a crash. Signed-off-by: Andreas Rheinhardt (cherry picked from commit e9b66175793e5c2af19beefe8e143f6e4901b5df) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa8f8748caa15d99a77537cbd5bbec014a6630b8 --- libavcodec/pthread_frame.c | 137 ++--- 1 file changed, 67 insertions(+), 70 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 311d6ed771..db2f0cb3d2 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -64,6 +64,12 @@ enum { STATE_SETUP_FINISHED, }; +enum { +UNINITIALIZED, ///< Thread has not been created, AVCodec->close mustn't be called +NEEDS_CLOSE,///< AVCodec->close needs to be called +INITIALIZED,///< Thread has been properly set up +}; + /** * Context used by codec threads and stored in their AVCodecInternal thread_ctx. */ @@ -698,27 +704,40 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) for (i = 0; i < thread_count; i++) { PerThreadContext *p = &fctx->threads[i]; +AVCodecContext *ctx = p->avctx; -pthread_mutex_lock(&p->mutex); -p->die = 1; -pthread_cond_signal(&p->input_cond); -pthread_mutex_unlock(&p->mutex); - -if (p->thread_init) -pthread_join(p->thread, NULL); -p->thread_init=0; +if (ctx->internal) { +if (p->thread_init == INITIALIZED) { +pthread_mutex_lock(&p->mutex); +p->die = 1; +pthread_cond_signal(&p->input_cond); +pthread_mutex_unlock(&p->mutex); -if (codec->close && p->avctx) -codec->close(p->avctx); +pthread_join(p->thread, NULL); +} +if (codec->close && p->thread_init != UNINITIALIZED) +codec->close(ctx); #if FF_API_THREAD_SAFE_CALLBACKS -release_delayed_buffers(p); +release_delayed_buffers(p); +for (int j = 0; j < p->released_buffers_allocated; j++) +av_frame_free(&p->released_buffers[j]); +av_freep(&p->released_buffers); #endif -av_frame_free(&p->frame); -} +if (ctx->priv_data) { +if (codec->priv_class) +av_opt_free(ctx->priv_data); +av_freep(&ctx->priv_data); +} -for (i = 0; i < thread_count; i++) { -PerThreadContext *p = &fctx->threads[i]; +av_freep(&ctx->slice_offset); + +av_buffer_unref(&ctx->internal->pool); +av_freep(&ctx->internal); +av_buffer_unref(&ctx->hw_frames_ctx); +} + +av_frame_free(&p->frame); pthread_mutex_destroy(&p->mutex); pthread_mutex_destroy(&p->progress_mutex); @@ -727,26 +746,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) pthread_cond_destroy(&p->output_cond); av_packet_free(&p->avpkt); -#if FF_API_THREAD_SAFE_CALLBACKS -for (int j = 0; j < p->released_buffers_allocated; j++) -av_frame_free(&p->released_buffers[j]); -av_freep(&p->released_buffers); -#endif - -if (p->avctx) { -if (codec->priv_class) -av_opt_free(p->avctx->priv_data); -av_freep(&p->avctx->priv_data); - -av_freep(&p->avctx->slice_offset); -} - -if (p->avctx) { -av_buffer_unref(&p->avctx->internal->pool); -av_freep(&p->avctx->internal); -av_buffer_unref(&p->avctx->hw_frames_ctx); -} - av_freep(&p->avctx); } @@ -763,47 +762,37 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) avctx->codec = NULL; } -static av_cold int init_thread(PerThreadContext *p, +static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, FrameThreadContext *fctx, AVCodecContext *avctx, AVCodecContext *src, const AVCodec *codec, int first) { -AVCodecContext *copy = av_malloc(s
[FFmpeg-cvslog] avcodec/pthread_frame: Reindentation
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Sun Mar 21 05:39:49 2021 +0100| [1761cc0cb0d3936565d8f406528db580e3b7eb2d] | committer: Andreas Rheinhardt avcodec/pthread_frame: Reindentation Signed-off-by: Andreas Rheinhardt (cherry picked from commit 659996094074b0c34904c2fd391c4a12bbf58211) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1761cc0cb0d3936565d8f406528db580e3b7eb2d --- libavcodec/pthread_frame.c | 38 +++--- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index fe4c42a401..9176027f15 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -834,23 +834,22 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, copy->internal = av_memdup(src->internal, sizeof(*src->internal)); if (!copy->internal) return AVERROR(ENOMEM); -copy->internal->thread_ctx = p; +copy->internal->thread_ctx = p; -copy->delay = avctx->delay; +copy->delay = avctx->delay; -if (codec->priv_data_size) { -copy->priv_data = av_mallocz(codec->priv_data_size); -if (!copy->priv_data) { -return AVERROR(ENOMEM); -} +if (codec->priv_data_size) { +copy->priv_data = av_mallocz(codec->priv_data_size); +if (!copy->priv_data) +return AVERROR(ENOMEM); -if (codec->priv_class) { -*(const AVClass **)copy->priv_data = codec->priv_class; -err = av_opt_copy(copy->priv_data, src->priv_data); -if (err < 0) -return err; -} +if (codec->priv_class) { +*(const AVClass **)copy->priv_data = codec->priv_class; +err = av_opt_copy(copy->priv_data, src->priv_data); +if (err < 0) +return err; } +} err = init_pthread(p, per_thread_offsets); if (err < 0) @@ -862,23 +861,24 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, copy->internal->last_pkt_props = p->avpkt; if (!first) -copy->internal->is_copy = 1; +copy->internal->is_copy = 1; -if (codec->init) -err = codec->init(copy); +if (codec->init) { +err = codec->init(copy); if (err < 0) { if (codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP) p->thread_init = NEEDS_CLOSE; return err; } +} p->thread_init = NEEDS_CLOSE; if (first) -update_context_from_thread(avctx, copy, 1); +update_context_from_thread(avctx, copy, 1); -atomic_init(&p->debug_threads, (copy->debug & FF_DEBUG_THREADS) != 0); +atomic_init(&p->debug_threads, (copy->debug & FF_DEBUG_THREADS) != 0); -err = AVERROR(pthread_create(&p->thread, NULL, frame_worker_thread, p)); +err = AVERROR(pthread_create(&p->thread, NULL, frame_worker_thread, p)); if (err < 0) return err; p->thread_init = INITIALIZED; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/wmavoice: Check operations that can fail
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Sat Apr 3 17:45:17 2021 +0200| [ed7efbe3ab94088fcad2785cf1d71195b4c506c6] | committer: Andreas Rheinhardt avcodec/wmavoice: Check operations that can fail There might be segfaults on failure. Signed-off-by: Andreas Rheinhardt (cherry picked from commit e93875b756b575438d7b825332739719d4fbc600) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed7efbe3ab94088fcad2785cf1d71195b4c506c6 --- libavcodec/wmavoice.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index fbdb865360..f1e1504a88 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -367,7 +367,7 @@ static av_cold void wmavoice_flush(AVCodecContext *ctx) static av_cold int wmavoice_decode_init(AVCodecContext *ctx) { static AVOnce init_static_once = AV_ONCE_INIT; -int n, flags, pitch_range, lsp16_flag; +int n, flags, pitch_range, lsp16_flag, ret; WMAVoiceContext *s = ctx->priv_data; ff_thread_once(&init_static_once, wmavoice_init_static_data); @@ -395,10 +395,11 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) s->spillover_bitsize = 3 + av_ceil_log2(ctx->block_align); s->do_apf=flags & 0x1; if (s->do_apf) { -ff_rdft_init(&s->rdft, 7, DFT_R2C); -ff_rdft_init(&s->irdft, 7, IDFT_C2R); -ff_dct_init(&s->dct, 6, DCT_I); -ff_dct_init(&s->dst, 6, DST_I); +if ((ret = ff_rdft_init(&s->rdft, 7, DFT_R2C)) < 0 || +(ret = ff_rdft_init(&s->irdft, 7, IDFT_C2R)) < 0 || +(ret = ff_dct_init (&s->dct, 6,DCT_I)) < 0 || +(ret = ff_dct_init (&s->dst, 6,DST_I)) < 0) +return ret; ff_sine_window_init(s->cos, 256); memcpy(&s->sin[255], s->cos, 256 * sizeof(s->cos[0])); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/pthread_frame: Check initializing mutexes/condition variables
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Tue Mar 23 06:34:11 2021 +0100| [562ff3ee0ec65e51fb212c2bf05b6ce9f569d5ba] | committer: Andreas Rheinhardt avcodec/pthread_frame: Check initializing mutexes/condition variables Up until now, initializing the mutexes/condition variables wasn't checked by ff_frame_thread_init(). This commit changes this. Given that it is not documented to be save to destroy a zeroed but otherwise uninitialized mutex/condition variable, one has to choose between two approaches: Either one duplicates the code to free them in ff_frame_thread_init() in case of errors or one records which have been successfully initialized. This commit takes the latter approach: For each of the two structures with mutexes/condition variables an array containing the offsets of the members to initialize is added. Said array is used both for initializing and freeing and the only thing that needs to be recorded is how many of these have been successfully initialized. Signed-off-by: Andreas Rheinhardt (cherry picked from commit c85fcc96b79a502b1d2cd022c6f0c638e4527732) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=562ff3ee0ec65e51fb212c2bf05b6ce9f569d5ba --- libavcodec/pthread_frame.c | 98 ++ 1 file changed, 73 insertions(+), 25 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index db2f0cb3d2..fe4c42a401 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -78,6 +78,7 @@ typedef struct PerThreadContext { pthread_t thread; intthread_init; +unsigned pthread_init_cnt;///< Number of successfully initialized mutexes/conditions pthread_cond_t input_cond; ///< Used to wait for a new packet from the main thread. pthread_cond_t progress_cond; ///< Used by child threads to wait for progress to change. pthread_cond_t output_cond; ///< Used by the main thread to wait for frames to finish. @@ -126,6 +127,7 @@ typedef struct FrameThreadContext { PerThreadContext *threads; ///< The contexts for each thread. PerThreadContext *prev_thread; ///< The last thread submit_packet() was called on. +unsignedpthread_init_cnt; ///< Number of successfully initialized mutexes/conditions pthread_mutex_t buffer_mutex; ///< Mutex used to protect get/release_buffer(). /** * This lock is used for ensuring threads run in serial when hwaccel @@ -680,6 +682,59 @@ static void park_frame_worker_threads(FrameThreadContext *fctx, int thread_count async_lock(fctx); } +#define SENTINEL 0 // This forbids putting a mutex/condition variable at the front. +#define OFFSET_ARRAY(...) __VA_ARGS__, SENTINEL +#define DEFINE_OFFSET_ARRAY(type, name, mutexes, conds) \ +static const unsigned name ## _offsets[] = { offsetof(type, pthread_init_cnt),\ + OFFSET_ARRAY mutexes,\ + OFFSET_ARRAY conds } + +#define OFF(member) offsetof(FrameThreadContext, member) +DEFINE_OFFSET_ARRAY(FrameThreadContext, thread_ctx, +(OFF(buffer_mutex), OFF(hwaccel_mutex), OFF(async_mutex)), +(OFF(async_cond))); +#undef OFF + +#define OFF(member) offsetof(PerThreadContext, member) +DEFINE_OFFSET_ARRAY(PerThreadContext, per_thread, +(OFF(progress_mutex), OFF(mutex)), +(OFF(input_cond), OFF(progress_cond), OFF(output_cond))); +#undef OFF + +static av_cold void free_pthread(void *obj, const unsigned offsets[]) +{ +unsigned cnt = *(unsigned*)((char*)obj + offsets[0]); +const unsigned *cur_offset = offsets; + +for (; *(++cur_offset) != SENTINEL && cnt; cnt--) +pthread_mutex_destroy((pthread_mutex_t*)((char*)obj + *cur_offset)); +for (; *(++cur_offset) != SENTINEL && cnt; cnt--) +pthread_cond_destroy ((pthread_cond_t *)((char*)obj + *cur_offset)); +} + +static av_cold int init_pthread(void *obj, const unsigned offsets[]) +{ +const unsigned *cur_offset = offsets; +unsigned cnt = 0; +int err; + +#define PTHREAD_INIT_LOOP(type) \ +for (; *(++cur_offset) != SENTINEL; cnt++) { \ +pthread_ ## type ## _t *dst = (void*)((char*)obj + *cur_offset); \ +err = pthread_ ## type ## _init(dst, NULL); \ +if (err) {\ +err = AVERROR(err); \ +goto fail;\ +} \ +} +PTHREAD_INIT_LOOP(mutex) +PTHREAD_INIT_LOOP(cond) + +fail: +*(unsigned*)((char*)obj + offsets[0]) = cnt; +return err; +} + void ff_frame_thread_free
[FFmpeg-cvslog] avcodec/tiff: Avoid forward declarations
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Tue Mar 30 07:53:50 2021 +0200| [5621d10b7a55f555a563dbc928d2a61891f4cd6b] | committer: Andreas Rheinhardt avcodec/tiff: Avoid forward declarations In this case it also fixes a potential for compilation failures: Not all compilers can handle the case in which a function with a forward declaration declared with an attribute to always inline it is called before the function body appears. E.g. GCC 4.2.1 on OS X 10.6 doesn't like it. Reviewed-by: Pavel Koshevoy Signed-off-by: Andreas Rheinhardt (cherry picked from commit e5d6af7b35d97f5c1252ecf8bd61f3295909fb6c) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5621d10b7a55f555a563dbc928d2a61891f4cd6b --- libavcodec/tiff.c | 394 +++--- 1 file changed, 195 insertions(+), 199 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 0878098b90..f8c68f1e7d 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -275,9 +275,101 @@ static int add_metadata(int count, int type, }; } +/** + * Map stored raw sensor values into linear reference values (see: DNG Specification - Chapter 5) + */ +static uint16_t av_always_inline dng_process_color16(uint16_t value, + const uint16_t *lut, + uint16_t black_level, + float scale_factor) +{ +float value_norm; + +// Lookup table lookup +if (lut) +value = lut[value]; + +// Black level subtraction +value = av_clip_uint16_c((unsigned)value - black_level); + +// Color scaling +value_norm = (float)value * scale_factor; + +value = av_clip_uint16_c(value_norm * 65535); + +return value; +} + +static uint16_t av_always_inline dng_process_color8(uint16_t value, +const uint16_t *lut, +uint16_t black_level, +float scale_factor) +{ +return dng_process_color16(value, lut, black_level, scale_factor) >> 8; +} + static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height, - int is_single_comp, int is_u16); + int is_single_comp, int is_u16) +{ +int line, col; +float scale_factor; + +scale_factor = 1.0f / (s->white_level - s->black_level); + +if (is_single_comp) { +if (!is_u16) +return; /* <= 8bpp unsupported */ + +/* Image is double the width and half the height we need, each row comprises 2 rows of the output + (split vertically in the middle). */ +for (line = 0; line < height / 2; line++) { +uint16_t *dst_u16 = (uint16_t *)dst; +uint16_t *src_u16 = (uint16_t *)src; + +/* Blit first half of input row row to initial row of output */ +for (col = 0; col < width; col++) +*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor); + +/* Advance the destination pointer by a row (source pointer remains in the same place) */ +dst += dst_stride * sizeof(uint16_t); +dst_u16 = (uint16_t *)dst; + +/* Blit second half of input row row to next row of output */ +for (col = 0; col < width; col++) +*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor); + +dst += dst_stride * sizeof(uint16_t); +src += src_stride * sizeof(uint16_t); +} +} else { +/* Input and output image are the same size and the MJpeg decoder has done per-component + deinterleaving, so blitting here is straightforward. */ +if (is_u16) { +for (line = 0; line < height; line++) { +uint16_t *dst_u16 = (uint16_t *)dst; +uint16_t *src_u16 = (uint16_t *)src; + +for (col = 0; col < width; col++) +*dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor); + +dst += dst_stride * sizeof(uint16_t); +src += src_stride * sizeof(uint16_t); +} +} else { +for (line = 0; line < height; line++) { +uint8_t *dst_u8 = dst; +const uint8_t *src_u8 = src; + +for (col = 0; col < width; col++) +*dst_u8++ = dng_process_color8(*src_u8++, s->dng_lut, s->black_level, scale_factor); + +dst += dst_stride; +src += src_stride; +} +} +} +} static void av_always_inline horizontal_fill(TiffContext *s,
[FFmpeg-cvslog] Revert "avcodec: add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ff_mpv_common_init()"
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Thu Dec 24 14:36:22 2020 +0100| [0155d5cd744bae026e5e4215f362ff5249f07cb7] | committer: Andreas Rheinhardt Revert "avcodec: add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ff_mpv_common_init()" This mostly reverts commit 4b2863ff01b1fe93d9a518523c9098d17a9d8c6f. Said commit removed the freeing code from ff_mpv_common_init(), ff_mpv_common_frame_size_change() and ff_mpeg_framesize_alloc() and instead added the FF_CODEC_CAP_INIT_CLEANUP to several codecs that use ff_mpv_common_init(). This introduced several bugs: a) Several decoders using ff_mpv_common_init() in their init function were forgotten: This affected FLV, Intel H.263, RealVideo 3.0 and V4.0 as well as VC-1/WMV3. b) ff_mpv_common_init() is not only called from the init function of codecs, it is also called from AVCodec.decode functions. If an error happens after an allocation has succeeded, it can lead to memleaks; furthermore, it is now possible for the MpegEncContext to be marked as initialized even when ff_mpv_common_init() returns an error and this can lead to segfaults because decoders that call ff_mpv_common_init() when decoding a frame can mistakenly think that the MpegEncContext has been properly initialized. This can e.g. happen with H.261 or MPEG-4. c) Removing code for freeing from ff_mpeg_framesize_alloc() (which can't be called from any init function) can lead to segfaults because the check for whether it needs to allocate consists of checking whether the first of the buffers allocated there has been allocated. This part has already been fixed in 76cea1d2ce3f23e8131c8664086a1daf873ed694. d) ff_mpv_common_frame_size_change() can also not be reached from any AVCodec.init function; yet the changes can e.g. lead to segfaults with decoders using ff_h263_decode_frame() upon allocation failure, because the MpegEncContext will upon return be flagged as both initialized and not in need of reinitialization (granted, the fact that ff_h263_decode_frame() clears context_reinit before the context has been reinited is a bug in itself). With the earlier version, the context would be cleaned upon failure and it would be attempted to initialize the context again in the next call to ff_h263_decode_frame(). While a) could be fixed by adding the missing FF_CODEC_CAP_INIT_CLEANUP, keeping the current approach would entail adding cleanup code to several other places because of b). Therefore ff_mpv_common_init() is again made to clean up after itself; the changes to the wmv2 decoder and the SVQ1 encoder have not been reverted: The former fixed a memleak, the latter allowed to remove cleanup code. Fixes: double free Fixes: ff_free_picture_tables.mp4 Fixes: ff_mpeg_update_thread_context.mp4 Fixes: decode_colskip.mp4 Fixes: memset.mp4 Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt (cherry picked from commit d4b9e117ceb6356cbcdc9ca81ec9c6c4b90efdae) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0155d5cd744bae026e5e4215f362ff5249f07cb7 --- libavcodec/h261dec.c | 2 +- libavcodec/h263dec.c | 4 ++-- libavcodec/mpeg12dec.c | 9 + libavcodec/mpeg4videodec.c | 3 +-- libavcodec/mpegvideo.c | 33 + libavcodec/msmpeg4dec.c| 8 libavcodec/rv10.c | 2 -- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 5c25aa9cb3..eb544e6046 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -678,6 +678,6 @@ AVCodec ff_h261_decoder = { .close = h261_decode_end, .decode = h261_decode_frame, .capabilities = AV_CODEC_CAP_DR1, -.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .max_lowres = 3, }; diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index dafa54d8d4..e8b4d83e6e 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -771,7 +771,7 @@ AVCodec ff_h263_decoder = { .decode = ff_h263_decode_frame, .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY, -.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP, +.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .flush = ff_mpeg_flush, .max_lowres = 3, .pix_fmts = ff_h263_hwaccel_pixfmt_list_420, @@ -789,7 +789,7 @@ AVCodec ff_h263p_decoder = { .decode = ff_h263_decode_frame, .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY, -.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP, +.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .flush = ff_mpeg_flush, .max_lowres = 3, .pix_fmts = ff_h2
[FFmpeg-cvslog] avcodec/mjpegdec: Fix leak in case ICC array allocations fail partially
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Sat Apr 3 15:39:35 2021 +0200| [6aad0b1bb54d6a5d0367ec3b127476f5516ed618] | committer: Andreas Rheinhardt avcodec/mjpegdec: Fix leak in case ICC array allocations fail partially If only one of the two arrays used for the ICC profile could be successfully allocated, it might be overwritten and leak when the next ICC entry is encountered. Fix this by using a common struct, so that one has only one array to allocate. Signed-off-by: Andreas Rheinhardt (cherry picked from commit a5b2f06b0c69221e375edd918a335c68b33d5667) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6aad0b1bb54d6a5d0367ec3b127476f5516ed618 --- libavcodec/mjpegdec.c | 28 +--- libavcodec/mjpegdec.h | 8 ++-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index e4e0c26df9..2df6caa440 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2087,28 +2087,26 @@ static int mjpeg_decode_app(MJpegDecodeContext *s) /* Allocate if this is the first APP2 we've seen. */ if (s->iccnum == 0) { -s->iccdata = av_mallocz(nummarkers * sizeof(*(s->iccdata))); -s->iccdatalens = av_mallocz(nummarkers * sizeof(*(s->iccdatalens))); -if (!s->iccdata || !s->iccdatalens) { +if (!FF_ALLOCZ_TYPED_ARRAY(s->iccentries, nummarkers)) { av_log(s->avctx, AV_LOG_ERROR, "Could not allocate ICC data arrays\n"); return AVERROR(ENOMEM); } s->iccnum = nummarkers; } -if (s->iccdata[seqno - 1]) { +if (s->iccentries[seqno - 1].data) { av_log(s->avctx, AV_LOG_WARNING, "Duplicate ICC sequence number\n"); goto out; } -s->iccdatalens[seqno - 1] = len; -s->iccdata[seqno - 1] = av_malloc(len); -if (!s->iccdata[seqno - 1]) { +s->iccentries[seqno - 1].length = len; +s->iccentries[seqno - 1].data = av_malloc(len); +if (!s->iccentries[seqno - 1].data) { av_log(s->avctx, AV_LOG_ERROR, "Could not allocate ICC data buffer\n"); return AVERROR(ENOMEM); } -memcpy(s->iccdata[seqno - 1], align_get_bits(&s->gb), len); +memcpy(s->iccentries[seqno - 1].data, align_get_bits(&s->gb), len); skip_bits(&s->gb, len << 3); len = 0; s->iccread++; @@ -2317,11 +2315,11 @@ static void reset_icc_profile(MJpegDecodeContext *s) { int i; -if (s->iccdata) +if (s->iccentries) { for (i = 0; i < s->iccnum; i++) -av_freep(&s->iccdata[i]); -av_freep(&s->iccdata); -av_freep(&s->iccdatalens); +av_freep(&s->iccentries[i].data); +av_freep(&s->iccentries); +} s->iccread = 0; s->iccnum = 0; @@ -2837,7 +2835,7 @@ the_end: /* Sum size of all parts. */ for (i = 0; i < s->iccnum; i++) -total_size += s->iccdatalens[i]; +total_size += s->iccentries[i].length; sd = av_frame_new_side_data(frame, AV_FRAME_DATA_ICC_PROFILE, total_size); if (!sd) { @@ -2847,8 +2845,8 @@ the_end: /* Reassemble the parts, which are now in-order. */ for (i = 0; i < s->iccnum; i++) { -memcpy(sd->data + offset, s->iccdata[i], s->iccdatalens[i]); -offset += s->iccdatalens[i]; +memcpy(sd->data + offset, s->iccentries[i].data, s->iccentries[i].length); +offset += s->iccentries[i].length; } } diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h index 732aeab994..0d69d9101b 100644 --- a/libavcodec/mjpegdec.h +++ b/libavcodec/mjpegdec.h @@ -44,6 +44,11 @@ #define MAX_COMPONENTS 4 +typedef struct ICCEntry { +uint8_t *data; +intlength; +} ICCEntry; + typedef struct MJpegDecodeContext { AVClass *class; AVCodecContext *avctx; @@ -138,8 +143,7 @@ typedef struct MJpegDecodeContext { const AVPixFmtDescriptor *pix_desc; -uint8_t **iccdata; -int *iccdatalens; +ICCEntry *iccentries; int iccnum; int iccread; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo: Fix memleak upon allocation error
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Fri Dec 25 14:17:10 2020 +0100| [63277aa98e6731ed933c7ca3314239d80c67a945] | committer: Andreas Rheinhardt avcodec/mpegvideo: Fix memleak upon allocation error When slice-threading is used, ff_mpv_common_init() duplicates the first MpegEncContext and allocates some buffers for each MpegEncContext (the first as well as the copies). But the count of allocated MpegEncContexts is not updated until after everything has been allocated and if an error happens after the first one has been allocated, only the first one is freed; the others leak. This commit fixes this: The count is now set before the copies are allocated. Furthermore, the copies are now created and initialized before the first MpegEncContext, so that the buffers exclusively owned by each MpegEncContext are still NULL in the src MpegEncContext so that no double-free happens upon allocation failure. Given that this effectively touches every line of the init code, it has also been factored out in a function of its own in order to remove code duplication with the same code in ff_mpv_common_frame_size_change() (which was never called when using more than one slice (and if it were, there would be potential double-frees)). Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt (cherry picked from commit ff0706cde8b1a1f483e26c0ccac117c23b23d604) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63277aa98e6731ed933c7ca3314239d80c67a945 --- libavcodec/mpegvideo.c | 89 -- 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index e03f174024..7327204e99 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -366,13 +366,6 @@ static int init_duplicate_context(MpegEncContext *s) if (s->mb_height & 1) yc_size += 2*s->b8_stride + 2*s->mb_stride; -s->sc.edge_emu_buffer = -s->me.scratchpad = -s->me.temp = -s->sc.rd_scratchpad = -s->sc.b_scratchpad= -s->sc.obmc_scratchpad = NULL; - if (s->encoding) { if (!FF_ALLOCZ_TYPED_ARRAY(s->me.map, ME_MAP_SIZE) || !FF_ALLOCZ_TYPED_ARRAY(s->me.score_map, ME_MAP_SIZE)) @@ -413,6 +406,35 @@ static int init_duplicate_context(MpegEncContext *s) return 0; } +/** + * Initialize an MpegEncContext's thread contexts. Presumes that + * slice_context_count is already set and that all the fields + * that are freed/reset in free_duplicate_context() are NULL. + */ +static int init_duplicate_contexts(MpegEncContext *s) +{ +int nb_slices = s->slice_context_count, ret; + +/* We initialize the copies before the original so that + * fields allocated in init_duplicate_context are NULL after + * copying. This prevents double-frees upon allocation error. */ +for (int i = 1; i < nb_slices; i++) { +s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext)); +if (!s->thread_context[i]) +return AVERROR(ENOMEM); +if ((ret = init_duplicate_context(s->thread_context[i])) < 0) +return ret; +s->thread_context[i]->start_mb_y = +(s->mb_height * (i) + nb_slices / 2) / nb_slices; +s->thread_context[i]->end_mb_y = +(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; +} +s->start_mb_y = 0; +s->end_mb_y = nb_slices > 1 ? (s->mb_height + nb_slices / 2) / nb_slices + : s->mb_height; +return init_duplicate_context(s); +} + static void free_duplicate_context(MpegEncContext *s) { if (!s) @@ -949,29 +971,12 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) s->context_initialized = 1; memset(s->thread_context, 0, sizeof(s->thread_context)); s->thread_context[0] = s; +s->slice_context_count = nb_slices; // if (s->width && s->height) { -if (nb_slices > 1) { -for (i = 0; i < nb_slices; i++) { -if (i) { -s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext)); -if (!s->thread_context[i]) -goto fail_nomem; -} -if ((ret = init_duplicate_context(s->thread_context[i])) < 0) -goto fail; -s->thread_context[i]->start_mb_y = -(s->mb_height * (i) + nb_slices / 2) / nb_slices; -s->thread_context[i]->end_mb_y = -(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; -} -} else { -if ((ret = init_duplicate_context(s)) < 0) -goto fail; -s->start_mb_y = 0; -s->end_mb_y = s->mb_height; -} -s->slice_context_count = nb_slices; +ret = init_duplicate_contexts(s); +if (ret < 0) +goto fail; // } return 0; @@ -1088,31 +1093,9 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s) s->thread_context[0] = s; if (s->width && s
[FFmpeg-cvslog] avcodec/mpegvideo: Factor common freeing code out
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Fri Dec 25 14:57:38 2020 +0100| [6d7dfabfb071f10cfdc5183dc9d48eb7992c0209] | committer: Andreas Rheinhardt avcodec/mpegvideo: Factor common freeing code out Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt (cherry picked from commit 9bab7de175d7c942a6ebddae6ba0cacdf360827e) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6d7dfabfb071f10cfdc5183dc9d48eb7992c0209 --- libavcodec/mpegvideo.c | 36 +++- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 7327204e99..7eddbdcc37 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -457,6 +457,15 @@ static void free_duplicate_context(MpegEncContext *s) s->block = NULL; } +static void free_duplicate_contexts(MpegEncContext *s) +{ +for (int i = 1; i < s->slice_context_count; i++) { +free_duplicate_context(s->thread_context[i]); +av_freep(&s->thread_context[i]); +} +free_duplicate_context(s); +} + static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src) { #define COPY(a) bak->a = src->a @@ -988,7 +997,8 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) } /** - * Frees and resets MpegEncContext fields depending on the resolution. + * Frees and resets MpegEncContext fields depending on the resolution + * as well as the slice thread contexts. * Is used during resolution changes to avoid a full reinitialization of the * codec. */ @@ -996,6 +1006,8 @@ static void free_context_frame(MpegEncContext *s) { int i, j, k; +free_duplicate_contexts(s); + av_freep(&s->mb_type); av_freep(&s->p_mv_table_base); av_freep(&s->b_forw_mv_table_base); @@ -1048,16 +1060,6 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s) if (!s->context_initialized) return AVERROR(EINVAL); -if (s->slice_context_count > 1) { -for (i = 0; i < s->slice_context_count; i++) { -free_duplicate_context(s->thread_context[i]); -} -for (i = 1; i < s->slice_context_count; i++) { -av_freep(&s->thread_context[i]); -} -} else -free_duplicate_context(s); - free_context_frame(s); if (s->picture) @@ -1112,15 +1114,9 @@ void ff_mpv_common_end(MpegEncContext *s) if (!s) return; -if (s->slice_context_count > 1) { -for (i = 0; i < s->slice_context_count; i++) { -free_duplicate_context(s->thread_context[i]); -} -for (i = 1; i < s->slice_context_count; i++) { -av_freep(&s->thread_context[i]); -} +free_context_frame(s); +if (s->slice_context_count > 1) s->slice_context_count = 1; -} else free_duplicate_context(s); av_freep(&s->parse_context.buffer); s->parse_context.buffer_size = 0; @@ -1152,8 +1148,6 @@ void ff_mpv_common_end(MpegEncContext *s) ff_mpeg_unref_picture(s->avctx, &s->new_picture); av_frame_free(&s->new_picture.f); -free_context_frame(s); - s->context_initialized = 0; s->last_picture_ptr = s->next_picture_ptr = ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/rv10: Don't presume context to be initialized
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Sun Apr 4 21:30:33 2021 +0200| [4562719c7d598e3efa884af23b1dd127287011b8] | committer: Andreas Rheinhardt avcodec/rv10: Don't presume context to be initialized In case of resolution changes rv20_decode_picture_header() closes and reopens its MpegEncContext; it checks the latter for errors, yet when an error happens, it might happen that no new attempt at reinitialization is performed when decoding the next frame; this leads to crashes lateron. This commit fixes this by making sure that initialization will always be attempted if the context is currently not initialized. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt (cherry picked from commit 8ffd3ef9d94f33b411348c594a49d994b55c9550) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4562719c7d598e3efa884af23b1dd127287011b8 --- libavcodec/rv10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 89b838ad15..bd70689cab 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -226,7 +226,7 @@ static int rv20_decode_picture_header(RVDecContext *rv) new_w = rv->orig_width; new_h = rv->orig_height; } -if (new_w != s->width || new_h != s->height) { +if (new_w != s->width || new_h != s->height || !s->context_initialized) { AVRational old_aspect = s->avctx->sample_aspect_ratio; av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/rv34, mpegvideo: Fix segfault upon frame size change error
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Mon Apr 5 02:05:58 2021 +0200| [b0997b8526e5f801052dbfcef89fa9d77fd046f4] | committer: Andreas Rheinhardt avcodec/rv34, mpegvideo: Fix segfault upon frame size change error The RealVideo 3.0 and 4.0 decoders call ff_mpv_common_init() only during their init function and not during decode_frame(); when the size of the frame changes, they call ff_mpv_common_frame_size_change(). Yet upon error, said function calls ff_mpv_common_end() which frees the whole MpegEncContext and not only those parts that ff_mpv_common_frame_size_change() reinits. As a result, the context will never be usable again; worse, because decode_frame() contains no check for whether the context is initialized or not, it is presumed that it is initialized, leading to segfaults. Basically the same happens if rv34_decoder_realloc() fails. This commit fixes this by only resetting the parts that ff_mpv_common_frame_size_change() changes upon error and by actually checking whether the context is in need of reinitialization in ff_rv34_decode_frame(). Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt (cherry picked from commit 9abda1365c5e2d827eb673b6d98245163c868bf1) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b0997b8526e5f801052dbfcef89fa9d77fd046f4 --- libavcodec/mpegvideo.c | 6 -- libavcodec/rv34.c | 13 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 7eddbdcc37..5de0719f83 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -555,7 +555,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, } if (s->height != s1->height || s->width != s1->width || s->context_reinit) { -s->context_reinit = 0; s->height = s1->height; s->width = s1->width; if ((ret = ff_mpv_common_frame_size_change(s)) < 0) @@ -1099,10 +1098,12 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s) if (err < 0) goto fail; } +s->context_reinit = 0; return 0; fail: -ff_mpv_common_end(s); +free_context_frame(s); +s->context_reinit = 1; return err; } @@ -1149,6 +1150,7 @@ void ff_mpv_common_end(MpegEncContext *s) av_frame_free(&s->new_picture.f); s->context_initialized = 0; +s->context_reinit = 0; s->last_picture_ptr = s->next_picture_ptr = s->current_picture_ptr = NULL; diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 7e5bfe0e22..99e580a09a 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1383,6 +1383,7 @@ static int rv34_decoder_alloc(RV34DecContext *r) if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs && r->intra_types_hist && r->mb_type)) { +r->s.context_reinit = 1; rv34_decoder_free(r); return AVERROR(ENOMEM); } @@ -1530,7 +1531,7 @@ int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecConte if (dst == src || !s1->context_initialized) return 0; -if (s->height != s1->height || s->width != s1->width) { +if (s->height != s1->height || s->width != s1->width || s->context_reinit) { s->height = s1->height; s->width = s1->width; if ((err = ff_mpv_common_frame_size_change(s)) < 0) @@ -1667,11 +1668,12 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, if (s->mb_num_left > 0 && s->current_picture_ptr) { av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n", s->mb_num_left); -ff_er_frame_end(&s->er); +if (!s->context_reinit) +ff_er_frame_end(&s->er); ff_mpv_frame_end(s); } -if (s->width != si.width || s->height != si.height) { +if (s->width != si.width || s->height != si.height || s->context_reinit) { int err; av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n", @@ -1689,7 +1691,6 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, err = ff_set_dimensions(s->avctx, s->width, s->height); if (err < 0) return err; - if ((err = ff_mpv_common_frame_size_change(s)) < 0) return err; if ((err = rv34_decoder_realloc(r)) < 0) @@ -1744,6 +1745,10 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, } s->mb_x = s->mb_y = 0; ff_thread_finish_setup(s->avctx); +} else if (s->context_reinit) { +av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames to " + "reinitialize (start MB is %d).\n", si.start); +return AVERROR_INVALIDDATA; } else if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) { av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames in frame " ___
[FFmpeg-cvslog] avcodec/vc1dec: Fix memleak upon allocation error
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Thu Apr 8 01:49:53 2021 +0200| [c72fca598c90c8550fe51e967ea54dae7f8cbc78] | committer: Andreas Rheinhardt avcodec/vc1dec: Fix memleak upon allocation error ff_vc1_decode_init_alloc_tables() had one error path that forgot to free already allocated buffers; these would then be overwritten on the next allocation attempt (or they would just not be freed in case this happened during init, as the decoders for which it is used do not have the FF_CODEC_CAP_INIT_CLEANUP set). Signed-off-by: Andreas Rheinhardt (cherry picked from commit 98060a198ef0bd213d0d0b029f8955fcd3be93d2) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c72fca598c90c8550fe51e967ea54dae7f8cbc78 --- libavcodec/vc1dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index b702b76060..ea93e11588 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -384,7 +384,7 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v) if (s->avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || s->avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { for (i = 0; i < 4; i++) if (!(v->sr_rows[i >> 1][i & 1] = av_malloc(v->output_width))) -return AVERROR(ENOMEM); +goto error; } ret = ff_intrax8_common_init(s->avctx, &v->x8, &s->idsp, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/rmdec: Fix memleaks upon read_header failure
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Mon Jul 20 23:26:15 2020 +0200| [be5970fcaabde6bc3b74e4f4c7b97360a5b6fb5f] | committer: Andreas Rheinhardt avformat/rmdec: Fix memleaks upon read_header failure For both the RealMedia as well as the IVR demuxer (which share the same context) each AVStream's priv_data contains an AVPacket that might contain data (even when reading the header) and therefore needs to be unreferenced. Up until now, this has not always been done: The RealMedia demuxer didn't do it when allocating a new stream's priv_data failed although there might be other streams with packets to unreference. (The reason for this was that until recently rm_read_close() couldn't handle an AVStream without priv_data, so one had to choose between a potential crash and a memleak.) The IVR demuxer meanwhile never ever called read_close so that the data already contained in packets leaks upon error. This patch fixes both demuxers by adding the appropriate cleanup code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 9a471c5437d34cd1e63520b47f50a0fa605a5688) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=be5970fcaabde6bc3b74e4f4c7b97360a5b6fb5f --- libavformat/rmdec.c | 38 ++ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index b6f42183e8..1dec70e95b 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -614,8 +614,10 @@ static int rm_read_header(AVFormatContext *s) get_str8(pb, mime, sizeof(mime)); /* mimetype */ st->codecpar->codec_type = AVMEDIA_TYPE_DATA; st->priv_data = ff_rm_alloc_rmstream(); -if (!st->priv_data) -return AVERROR(ENOMEM); +if (!st->priv_data) { +ret = AVERROR(ENOMEM); +goto fail; +} size = avio_rb32(pb); codec_pos = avio_tell(pb); @@ -1249,20 +1251,19 @@ static int ivr_read_header(AVFormatContext *s) } for (n = 0; n < nb_streams; n++) { -st = avformat_new_stream(s, NULL); -if (!st) -return AVERROR(ENOMEM); -st->priv_data = ff_rm_alloc_rmstream(); -if (!st->priv_data) -return AVERROR(ENOMEM); +if (!(st = avformat_new_stream(s, NULL)) || +!(st->priv_data = ff_rm_alloc_rmstream())) { +ret = AVERROR(ENOMEM); +goto fail; +} if (avio_r8(pb) != 1) -return AVERROR_INVALIDDATA; +goto invalid_data; count = avio_rb32(pb); for (i = 0; i < count; i++) { if (avio_feof(pb)) -return AVERROR_INVALIDDATA; +goto invalid_data; type = avio_r8(pb); tlen = avio_rb32(pb); @@ -1274,25 +1275,25 @@ static int ivr_read_header(AVFormatContext *s) } else if (type == 4 && !strncmp(key, "OpaqueData", tlen)) { ret = ffio_ensure_seekback(pb, 4); if (ret < 0) -return ret; +goto fail; if (avio_rb32(pb) == MKBETAG('M', 'L', 'T', 'I')) { ret = rm_read_multi(s, pb, st, NULL); } else { if (avio_feof(pb)) -return AVERROR_INVALIDDATA; +goto invalid_data; avio_seek(pb, -4, SEEK_CUR); ret = ff_rm_read_mdpr_codecdata(s, pb, st, st->priv_data, len, NULL); } if (ret < 0) -return ret; +goto fail; } else if (type == 4) { int j; av_log(s, AV_LOG_DEBUG, "%s = '0x", key); for (j = 0; j < len; j++) { if (avio_feof(pb)) -return AVERROR_INVALIDDATA; +goto invalid_data; av_log(s, AV_LOG_DEBUG, "%X", avio_r8(pb)); } av_log(s, AV_LOG_DEBUG, "'\n"); @@ -1309,14 +1310,19 @@ static int ivr_read_header(AVFormatContext *s) } if (avio_r8(pb) != 6) -return AVERROR_INVALIDDATA; +goto invalid_data; avio_skip(pb, 12); avio_skip(pb, avio_rb64(pb) + pos - avio_tell(s->pb)); if (avio_r8(pb) != 8) -return AVERROR_INVALIDDATA; +goto invalid_data; avio_skip(pb, 8); return 0; +invalid_data: +ret = AVERROR_INVALIDDATA; +fail: +rm_read_close(s); +return ret; } static int ivr_read_packet(AVFormatContext *s, AVPacket *pkt) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/rmdec: Don't rely on unspecified order of evaluation
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Wed Apr 7 13:37:09 2021 +0200| [44d218e99aba4cbcbbed06bc5065380636623a36] | committer: Andreas Rheinhardt avformat/rmdec: Don't rely on unspecified order of evaluation Signed-off-by: Andreas Rheinhardt (cherry picked from commit 4666ce0aef395fc7dfa2a718e8d238e58e635d2a) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=44d218e99aba4cbcbbed06bc5065380636623a36 --- libavformat/rmdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 1dec70e95b..fc3bff4859 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -1312,7 +1312,7 @@ static int ivr_read_header(AVFormatContext *s) if (avio_r8(pb) != 6) goto invalid_data; avio_skip(pb, 12); -avio_skip(pb, avio_rb64(pb) + pos - avio_tell(s->pb)); +avio_seek(pb, avio_rb64(pb) + pos, SEEK_SET); if (avio_r8(pb) != 8) goto invalid_data; avio_skip(pb, 8); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/encode: Fix check for allowed LJPEG pixel formats
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Tue Apr 6 00:32:39 2021 +0200| [fb7cd459778d6ae8975bf26766109ad82859c0e8] | committer: Andreas Rheinhardt avcodec/encode: Fix check for allowed LJPEG pixel formats The pix_fmts of the LJPEG encoder already contain all supported pixel formats (including the ones only supported when strictness is unofficial or less); yet the check in ff_encode_preinit() ignored this list in case strictness is unofficial or less. But the encoder presumed that it is always applied and blacklists some of the entries in pix_fmts when strictness is > unofficial. The result is that if one uses an entry not on that list and sets strictness to unofficial, said entry passes both checks and this can lead to segfaults lateron (e.g. when using gray). Fix this by removing the exception for LJPEG in ff_encode_preinit(). Signed-off-by: Andreas Rheinhardt (cherry picked from commit 6e8e9b7633d8b755e7a464a10ba5047f31cbd84d) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fb7cd459778d6ae8975bf26766109ad82859c0e8 --- libavcodec/encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index a93bb3ccf7..89df5235da 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -565,7 +565,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if (avctx->pix_fmt == avctx->codec->pix_fmts[i]) break; if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE -&& !((avctx->codec_id == AV_CODEC_ID_MJPEG || avctx->codec_id == AV_CODEC_ID_LJPEG) +&& !(avctx->codec_id == AV_CODEC_ID_MJPEG && avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)) { char buf[128]; snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant
ffmpeg | branch: release/4.4 | Andreas Rheinhardt | Tue Apr 6 15:45:42 2021 +0200| [5c457c673fbd8d2d0ef1ed10dbd269ee3570e628] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant The (deprecated) field AVCodecContext.mpeg_quant has no range restriction; MpegEncContext.mpeg_quant is restricted to 0..1. If the former is set, the latter is overwritten with it without checking the range. This can trigger an av_assert2() with the MPEG-4 encoder when writing said field. Fix this by just setting MpegEncContext.mpeg_quant to 1 if AVCodecContext.mpeg_quant is set. Signed-off-by: Andreas Rheinhardt (cherry picked from commit d393c45051ddaf6146e7e29ec2ea97035a727529) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c457c673fbd8d2d0ef1ed10dbd269ee3570e628 --- libavcodec/mpegvideo_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 29572dd61e..eb13d57d2b 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -627,7 +627,7 @@ FF_ENABLE_DEPRECATION_WARNINGS #if FF_API_PRIVATE_OPT FF_DISABLE_DEPRECATION_WARNINGS if (avctx->mpeg_quant) -s->mpeg_quant = avctx->mpeg_quant; +s->mpeg_quant = 1; FF_ENABLE_DEPRECATION_WARNINGS #endif ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/webvttenc: Fix use of uninitialized variable
ffmpeg | branch: master | Andreas Rheinhardt | Thu Apr 8 14:06:24 2021 +0200| [44c8b6750231137d5ba650d6cc149c9c23ae4c68] | committer: Andreas Rheinhardt avformat/webvttenc: Fix use of uninitialized variable Happened in 9168a1c0e67b5c31727b12329b6f52d2bb5e0a14. Reviewed-by: Anton Khirnov Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=44c8b6750231137d5ba650d6cc149c9c23ae4c68 --- libavformat/webvttenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c index 809fead69f..2bc86041a7 100644 --- a/libavformat/webvttenc.c +++ b/libavformat/webvttenc.c @@ -87,7 +87,7 @@ static int webvtt_write_packet(AVFormatContext *ctx, AVPacket *pkt) settings = av_packet_get_side_data(pkt, AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size); -if (settings_size_int > INT_MAX) +if (settings_size > INT_MAX) return AVERROR(EINVAL); settings_size_int = settings_size; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/pngdec: perform APNG blending in-place
ffmpeg | branch: release/4.4 | Anton Khirnov | Thu Apr 1 15:45:45 2021 +0200| [53ecdbfbe5e3c896b06ad1fe472df14eb0e336db] | committer: Anton Khirnov lavc/pngdec: perform APNG blending in-place Saves an allocation+free and two frame copies per each frame. (cherry picked from commit 5a50bd88db670f8c030a814e4cdb2a880dc1d4f4) Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53ecdbfbe5e3c896b06ad1fe472df14eb0e336db --- libavcodec/pngdec.c | 51 --- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 63c22063d9..095e4e86c2 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1068,8 +1068,12 @@ static void handle_p_frame_png(PNGDecContext *s, AVFrame *p) static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p) { +uint8_t *dst= p->data[0]; +ptrdiff_t dst_stride = p->linesize[0]; +const uint8_t *src= s->last_picture.f->data[0]; +ptrdiff_t src_stride = s->last_picture.f->linesize[0]; + size_t x, y; -uint8_t *buffer; if (s->blend_op == APNG_BLEND_OP_OVER && avctx->pix_fmt != AV_PIX_FMT_RGBA && @@ -1089,26 +1093,32 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, if (ret < 0) return ret; +src= s->last_picture.f->data[0]; +src_stride = s->last_picture.f->linesize[0]; + for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) { -memset(s->last_picture.f->data[0] + s->image_linesize * y + +memset(s->last_picture.f->data[0] + src_stride * y + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); } } -buffer = av_memdup(s->last_picture.f->data[0], s->image_linesize * s->height); -if (!buffer) -return AVERROR(ENOMEM); +// copy unchanged rectangles from the last frame +for (y = 0; y < s->y_offset; y++) +memcpy(dst + y * dst_stride, src + y * src_stride, p->width * s->bpp); +for (y = s->y_offset; y < s->y_offset + s->cur_h; y++) { +memcpy(dst + y * dst_stride, src + y * src_stride, s->x_offset * s->bpp); +memcpy(dst + y * dst_stride + (s->x_offset + s->cur_w) * s->bpp, + src + y * src_stride + (s->x_offset + s->cur_w) * s->bpp, + (p->width - s->cur_w - s->x_offset) * s->bpp); +} +for (y = s->y_offset + s->cur_h; y < p->height; y++) +memcpy(dst + y * dst_stride, src + y * src_stride, p->width * s->bpp); -// Perform blending -if (s->blend_op == APNG_BLEND_OP_SOURCE) { -for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { -size_t row_start = s->image_linesize * y + s->bpp * s->x_offset; -memcpy(buffer + row_start, p->data[0] + row_start, s->bpp * s->cur_w); -} -} else { // APNG_BLEND_OP_OVER +if (s->blend_op == APNG_BLEND_OP_OVER) { +// Perform blending for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) { -uint8_t *foreground = p->data[0] + s->image_linesize * y + s->bpp * s->x_offset; -uint8_t *background = buffer + s->image_linesize * y + s->bpp * s->x_offset; +uint8_t *foreground = dst + dst_stride * y + s->bpp * s->x_offset; +const uint8_t *background = src + src_stride * y + s->bpp * s->x_offset; for (x = s->x_offset; x < s->x_offset + s->cur_w; ++x, foreground += s->bpp, background += s->bpp) { size_t b; uint8_t foreground_alpha, background_alpha, output_alpha; @@ -1135,18 +1145,17 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, break; } -if (foreground_alpha == 0) +if (foreground_alpha == 255) continue; -if (foreground_alpha == 255) { -memcpy(background, foreground, s->bpp); +if (foreground_alpha == 0) { +memcpy(foreground, background, s->bpp); continue; } if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { // TODO: Alpha blending with PAL8 will likely need the entire image converted over to RGBA first avpriv_request_sample(avctx, "Alpha blending palette samples"); -background[0] = foreground[0]; continue; } @@ -1164,15 +1173,11 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, } } output[b] = output_alpha; -memcpy(background, output, s->bpp); +memcpy(foreground, output, s->bpp); } } } -// Copy blended buffer into
[FFmpeg-cvslog] lavc/pngdec: remove unnecessary context variables
ffmpeg | branch: release/4.4 | Anton Khirnov | Fri Apr 2 10:45:27 2021 +0200| [5f21bbed8a63efcd052c9a51fd235faa01ba793e] | committer: Anton Khirnov lavc/pngdec: remove unnecessary context variables Do not store the image buffer pointer/linesize in the context, just access them directly from the frame. Stop assuming that linesize is the same for the current and last frame. (cherry picked from commit 89ea5057bf47880145419341258eadb3635448cf) Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5f21bbed8a63efcd052c9a51fd235faa01ba793e --- libavcodec/pngdec.c | 36 +--- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 095e4e86c2..ff705ef48a 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -77,8 +77,6 @@ typedef struct PNGDecContext { int has_trns; uint8_t transparent_color_be[6]; -uint8_t *image_buf; -int image_linesize; uint32_t palette[256]; uint8_t *crow_buf; uint8_t *last_row; @@ -330,27 +328,27 @@ static int percent_missing(PNGDecContext *s) } /* process exactly one decompressed row */ -static void png_handle_row(PNGDecContext *s) +static void png_handle_row(PNGDecContext *s, uint8_t *dst, ptrdiff_t dst_stride) { uint8_t *ptr, *last_row; int got_line; if (!s->interlace_type) { -ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp; +ptr = dst + dst_stride * (s->y + s->y_offset) + s->x_offset * s->bpp; if (s->y == 0) last_row = s->last_row; else -last_row = ptr - s->image_linesize; +last_row = ptr - dst_stride; ff_png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1, last_row, s->row_size, s->bpp); /* loco lags by 1 row so that it doesn't interfere with top prediction */ if (s->filter_type == PNG_FILTER_TYPE_LOCO && s->y > 0) { if (s->bit_depth == 16) { -deloco_rgb16((uint16_t *)(ptr - s->image_linesize), s->row_size / 2, +deloco_rgb16((uint16_t *)(ptr - dst_stride), s->row_size / 2, s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); } else { -deloco_rgb8(ptr - s->image_linesize, s->row_size, +deloco_rgb8(ptr - dst_stride, s->row_size, s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); } } @@ -370,7 +368,7 @@ static void png_handle_row(PNGDecContext *s) } else { got_line = 0; for (;;) { -ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp; +ptr = dst + dst_stride * (s->y + s->y_offset) + s->x_offset * s->bpp; if ((ff_png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) { /* if we already read one row, it is time to stop to * wait for the next one */ @@ -411,7 +409,8 @@ the_end:; } } -static int png_decode_idat(PNGDecContext *s, int length) +static int png_decode_idat(PNGDecContext *s, int length, + uint8_t *dst, ptrdiff_t dst_stride) { int ret; s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb)); @@ -427,7 +426,7 @@ static int png_decode_idat(PNGDecContext *s, int length) } if (s->zstream.avail_out == 0) { if (!(s->pic_state & PNG_ALLIMAGE)) { -png_handle_row(s); +png_handle_row(s, dst, dst_stride); } s->zstream.avail_out = s->crow_size; s->zstream.next_out = s->crow_buf; @@ -732,8 +731,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, } ff_dlog(avctx, "row_size=%d crow_size =%d\n", s->row_size, s->crow_size); -s->image_buf = p->data[0]; -s->image_linesize = p->linesize[0]; + /* copy the palette if needed */ if (avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(p->data[1], s->palette, 256 * sizeof(uint32_t)); @@ -764,7 +762,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE) s->bpp -= byte_depth; -ret = png_decode_idat(s, length); +ret = png_decode_idat(s, length, p->data[0], p->linesize[0]); if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE) s->bpp += byte_depth; @@ -913,7 +911,7 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p) pd[8*i + 1]= (pd[i]>>6) & 1; pd[8*i + 0]= pd[i]>>7; } -pd += s->image_linesize; +pd += p->linesize[0]; } } else if (s->bits_per_pixel == 2) { int i, j; @@ -941,7 +939,7 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame
[FFmpeg-cvslog] lavc/pngdec: restructure exporting frame meta/side data
ffmpeg | branch: release/4.4 | Anton Khirnov | Sat Mar 20 19:57:25 2021 +0100| [8ee432dc2365f11908c6535be7e076d9d298a9ad] | committer: Anton Khirnov lavc/pngdec: restructure exporting frame meta/side data This data cannot be stored in PNGDecContext.picture, because the corresponding chunks may be read after the call to ff_thread_finish_setup(), at which point modifying shared context data is a race. Store intermediate state in the context and then write it directly to the output frame. Fixes exporting frame metadata after 5663301560 Fixes #8972 Found-by: Andreas Rheinhardt (cherry picked from commit 8d74baccff59192d395735036cd40a131a140391) Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8ee432dc2365f11908c6535be7e076d9d298a9ad --- libavcodec/pngdec.c | 162 ++-- 1 file changed, 119 insertions(+), 43 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index ff705ef48a..f3295688c6 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -57,6 +57,18 @@ typedef struct PNGDecContext { ThreadFrame last_picture; ThreadFrame picture; +AVDictionary *frame_metadata; + +uint8_t iccp_name[82]; +uint8_t *iccp_data; +size_t iccp_data_len; + +int stereo_mode; + +int have_chrm; +uint32_t white_point[2]; +uint32_t display_primaries[3][2]; + enum PNGHeaderState hdr_state; enum PNGImageState pic_state; int width, height; @@ -508,8 +520,7 @@ static uint8_t *iso88591_to_utf8(const uint8_t *in, size_t size_in) return out; } -static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, - AVDictionary **dict) +static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed) { int ret, method; const uint8_t *data= s->gb.buffer; @@ -551,7 +562,7 @@ static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed, return AVERROR(ENOMEM); } -av_dict_set(dict, kw_utf8, txt_utf8, +av_dict_set(&s->frame_metadata, kw_utf8, txt_utf8, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); return 0; } @@ -849,21 +860,21 @@ static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s, static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f) { int ret, cnt = 0; -uint8_t *data, profile_name[82]; AVBPrint bp; -AVFrameSideData *sd; -while ((profile_name[cnt++] = bytestream2_get_byte(&s->gb)) && cnt < 81); +while ((s->iccp_name[cnt++] = bytestream2_get_byte(&s->gb)) && cnt < 81); if (cnt > 80) { av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid name!\n"); -return AVERROR_INVALIDDATA; +ret = AVERROR_INVALIDDATA; +goto fail; } length = FFMAX(length - cnt, 0); if (bytestream2_get_byte(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid compression!\n"); -return AVERROR_INVALIDDATA; +ret = AVERROR_INVALIDDATA; +goto fail; } length = FFMAX(length - 1, 0); @@ -871,24 +882,19 @@ static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f) if ((ret = decode_zbuf(&bp, s->gb.buffer, s->gb.buffer + length)) < 0) return ret; -ret = av_bprint_finalize(&bp, (char **)&data); +av_freep(&s->iccp_data); +ret = av_bprint_finalize(&bp, (char **)&s->iccp_data); if (ret < 0) return ret; - -sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, bp.len); -if (!sd) { -av_free(data); -return AVERROR(ENOMEM); -} - -av_dict_set(&sd->metadata, "name", profile_name, 0); -memcpy(sd->data, data, bp.len); -av_free(data); +s->iccp_data_len = bp.len; /* ICC compressed data and CRC */ bytestream2_skip(&s->gb, length + 4); return 0; +fail: +s->iccp_name[0] = 0; +return ret; } static void handle_small_bpp(PNGDecContext *s, AVFrame *p) @@ -1183,7 +1189,6 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p, const AVPacket *avpkt) { const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE); -AVDictionary **metadatap = NULL; uint32_t tag, length; int decode_next_dat = 0; int i, ret; @@ -1251,7 +1256,6 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, } } -metadatap = &p->metadata; switch (tag) { case MKTAG('I', 'H', 'D', 'R'): if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0) @@ -1293,26 +1297,20 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, goto skip_tag; break; case MKTAG('t', 'E', 'X', 't'): -if (decode_text_chunk(s, length, 0, metadatap) < 0) +if (decode_text_chunk(s, length, 0) < 0)
[FFmpeg-cvslog] lavc/pngdec: improve chunk length check
ffmpeg | branch: release/4.4 | Anton Khirnov | Fri Apr 2 16:00:23 2021 +0200| [c64180fac8442d4b0f1ed9cb07265361c193400e] | committer: Anton Khirnov lavc/pngdec: improve chunk length check The length does not cover the chunk type or CRC. (cherry picked from commit ae08eec6a1f2129cd231a0ab664f0f17b854d138) Signed-off-by: Anton Khirnov > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c64180fac8442d4b0f1ed9cb07265361c193400e --- libavcodec/pngdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index f3295688c6..0ff81d740c 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1217,7 +1217,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, } length = bytestream2_get_be32(&s->gb); -if (length > 0x7fff || length > bytestream2_get_bytes_left(&s->gb)) { +if (length > 0x7fff || length + 8 > bytestream2_get_bytes_left(&s->gb)) { av_log(avctx, AV_LOG_ERROR, "chunk too big\n"); ret = AVERROR_INVALIDDATA; goto fail; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/url: fix ff_make_absolute_url with Windows file paths
ffmpeg | branch: release/4.4 | Marton Balint | Fri Apr 2 17:07:54 2021 +0200| [d622923b36f6a31b043da73b05946bea5612bb72] | committer: Marton Balint avformat/url: fix ff_make_absolute_url with Windows file paths Ugly, but a lot less broken than it was. Fixes ticket #9166. Signed-off-by: Marton Balint (cherry picked from commit 5dc5f289cefe67457bd16f1950c56911e926385f) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d622923b36f6a31b043da73b05946bea5612bb72 --- libavformat/url.c | 24 +++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libavformat/url.c b/libavformat/url.c index 77d610d95f..222d7d8a10 100644 --- a/libavformat/url.c +++ b/libavformat/url.c @@ -149,6 +149,18 @@ int ff_url_decompose(URLComponents *uc, const char *url, const char *end) return 0; } +static int is_fq_dos_path(const char *path) +{ +if ((path[0] >= 'a' && path[0] <= 'z' || path[0] >= 'A' && path[0] <= 'Z') && + path[1] == ':' && +(path[2] == '/' || path[2] == '\\')) +return 1; +if ((path[0] == '/' || path[0] == '\\') && +(path[1] == '/' || path[1] == '\\')) +return 1; +return 0; +} + static int append_path(char *root, char *out_end, char **rout, const char *in, const char *in_end) { @@ -185,6 +197,7 @@ int ff_make_absolute_url(char *buf, int size, const char *base, char *out, *out_end, *path; const char *keep, *base_path_end; int use_base_path, simplify_path = 0, ret; +const char *base_separators = "/"; /* This is tricky. For HTTP, http://server/site/page + ../media/file @@ -211,6 +224,15 @@ int ff_make_absolute_url(char *buf, int size, const char *base, if (!base) base = ""; +if (HAVE_DOS_PATHS) { +if ((ret = ff_url_decompose(&ub, base, NULL)) < 0) +goto error; +if (is_fq_dos_path(base) || av_strstart(base, "file:", NULL) || ub.path == ub.url) { +base_separators = "/\\"; +if (is_fq_dos_path(rel)) +base = ""; +} +} if ((ret = ff_url_decompose(&ub, base, NULL)) < 0 || (ret = ff_url_decompose(&uc, rel, NULL)) < 0) goto error; @@ -249,7 +271,7 @@ int ff_make_absolute_url(char *buf, int size, const char *base, if (use_base_path) { base_path_end = ub.url_component_end_path; if (URL_COMPONENT_HAVE(uc, path)) -while (base_path_end > ub.path && base_path_end[-1] != '/') +while (base_path_end > ub.path && !strchr(base_separators, base_path_end[-1])) base_path_end--; } if (keep > ub.path) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/url: add ff_make_absolulte_url2 to be able to test windows path cases
ffmpeg | branch: release/4.4 | Marton Balint | Tue Apr 6 01:10:30 2021 +0200| [25e794a1ea13ad0ed9f5c4792ab3727fe7a3ace1] | committer: Marton Balint avformat/url: add ff_make_absolulte_url2 to be able to test windows path cases Signed-off-by: Marton Balint (cherry picked from commit fb4da90fecdefa2508618ca835cd0250be940e04) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=25e794a1ea13ad0ed9f5c4792ab3727fe7a3ace1 --- libavformat/tests/url.c | 33 ++--- libavformat/url.c | 12 +--- libavformat/url.h | 10 ++ tests/ref/fate/url | 20 4 files changed, 69 insertions(+), 6 deletions(-) diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c index 2eb597bb5e..8644a3e826 100644 --- a/libavformat/tests/url.c +++ b/libavformat/tests/url.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" #include "libavformat/url.h" #include "libavformat/avformat.h" @@ -48,19 +49,30 @@ static void test_decompose(const char *url) static void test(const char *base, const char *rel) { -char buf[200], buf2[200]; +char buf[200], buf2[200], buf_dos[200], buf_native[200]; int ret; -ret = ff_make_absolute_url(buf, sizeof(buf), base, rel); +ret = ff_make_absolute_url2(buf, sizeof(buf), base, rel, 0); if (ret < 0) { printf("%50s %-20s => error %s\n", base, rel, av_err2str(ret)); return; } printf("%50s %-20s => %s\n", base, rel, buf); +ret = ff_make_absolute_url2(buf_dos, sizeof(buf_dos), base, rel, 1); +if (ret < 0) +snprintf(buf_dos, sizeof(buf_dos), "error %s", av_err2str(ret)); +ret = ff_make_absolute_url(buf_native, sizeof(buf_native), base, rel); +if (ret < 0) +snprintf(buf_native, sizeof(buf_native), "error %s", av_err2str(ret)); +if (strcmp(buf, buf_dos)) +printf("%50s %-20sDOS %s\n", base, rel, buf_dos); +if (HAVE_DOS_PATHS && strcmp(buf_dos, buf_native) || +!HAVE_DOS_PATHS && strcmp(buf, buf_native)) +printf("Native mismatch\n"); if (base) { /* Test in-buffer replacement */ snprintf(buf2, sizeof(buf2), "%s", base); -ff_make_absolute_url(buf2, sizeof(buf2), buf2, rel); +ff_make_absolute_url2(buf2, sizeof(buf2), buf2, rel, 0); if (strcmp(buf, buf2)) { printf("In-place handling of %s + %s failed\n", base, rel); exit(1); @@ -121,6 +133,21 @@ int main(void) test("http://server/foo/bar";, "..doubledotfile"); test("http://server/foo/bar";, "double..dotfile"); test("http://server/foo/bar";, "doubledotfile.."); +test("file1", "file2"); +test("dir/file1", "file2"); +test("dir/file1", "../file2"); +test("dir\\file1", "file2"); +test("srv\\shr\\file", "..\\..\\dummy"); +test("srv\\shr\\file", "dummy"); +test("srv\\shr\\file", "srv2\\shr2\\file2"); +test("srv\\shr\\file", "d:/file"); +test("C:\\dir\\a", "..\\file"); +test("C:\\dir\\a", "srv\\shr\\file"); +test("C:\\dir\\a", "d:\\file"); +test("http://a/b";, "srv\\shr\\file"); +test("http://a/b";, "//srv/shr/file"); +test("http://a/b";, "d:\\file"); +test("http://a/b";, "C:/file"); /* From https://tools.ietf.org/html/rfc3986#section-5.4 */ test("http://a/b/c/d;p?q";, "g:h"); // g:h diff --git a/libavformat/url.c b/libavformat/url.c index 222d7d8a10..f53fdf59d8 100644 --- a/libavformat/url.c +++ b/libavformat/url.c @@ -190,8 +190,8 @@ static int append_path(char *root, char *out_end, char **rout, return 0; } -int ff_make_absolute_url(char *buf, int size, const char *base, - const char *rel) +int ff_make_absolute_url2(char *buf, int size, const char *base, + const char *rel, int handle_dos_paths) { URLComponents ub, uc; char *out, *out_end, *path; @@ -224,7 +224,7 @@ int ff_make_absolute_url(char *buf, int size, const char *base, if (!base) base = ""; -if (HAVE_DOS_PATHS) { +if (handle_dos_paths) { if ((ret = ff_url_decompose(&ub, base, NULL)) < 0) goto error; if (is_fq_dos_path(base) || av_strstart(base, "file:", NULL) || ub.path == ub.url) { @@ -316,6 +316,12 @@ error: return ret; } +int ff_make_absolute_url(char *buf, int size, const char *base, + const char *rel) +{ +return ff_make_absolute_url2(buf, size, base, rel, HAVE_DOS_PATHS); +} + AVIODirEntry *ff_alloc_dir_entry(void) { AVIODirEntry *entry = av_mallocz(sizeof(AVIODirEntry)); diff --git a/libavformat/url.h b/libavformat/url.h index f13e851a14..3bb1cf89f7 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -308,6 +308,16 @@ int ff_url_join(char *str, int size, const char *proto, * @param size the size of buf * @param base the base url, may be equal to buf.
[FFmpeg-cvslog] avformat/url: add ff_make_absolulte_url2 to be able to test windows path cases
ffmpeg | branch: release/4.3 | Marton Balint | Tue Apr 6 01:10:30 2021 +0200| [31d249a418409a0e295e74701040e8ef866847d1] | committer: Marton Balint avformat/url: add ff_make_absolulte_url2 to be able to test windows path cases Signed-off-by: Marton Balint (cherry picked from commit fb4da90fecdefa2508618ca835cd0250be940e04) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=31d249a418409a0e295e74701040e8ef866847d1 --- libavformat/tests/url.c | 33 ++--- libavformat/url.c | 12 +--- libavformat/url.h | 10 ++ tests/ref/fate/url | 20 4 files changed, 69 insertions(+), 6 deletions(-) diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c index 2eb597bb5e..8644a3e826 100644 --- a/libavformat/tests/url.c +++ b/libavformat/tests/url.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" #include "libavformat/url.h" #include "libavformat/avformat.h" @@ -48,19 +49,30 @@ static void test_decompose(const char *url) static void test(const char *base, const char *rel) { -char buf[200], buf2[200]; +char buf[200], buf2[200], buf_dos[200], buf_native[200]; int ret; -ret = ff_make_absolute_url(buf, sizeof(buf), base, rel); +ret = ff_make_absolute_url2(buf, sizeof(buf), base, rel, 0); if (ret < 0) { printf("%50s %-20s => error %s\n", base, rel, av_err2str(ret)); return; } printf("%50s %-20s => %s\n", base, rel, buf); +ret = ff_make_absolute_url2(buf_dos, sizeof(buf_dos), base, rel, 1); +if (ret < 0) +snprintf(buf_dos, sizeof(buf_dos), "error %s", av_err2str(ret)); +ret = ff_make_absolute_url(buf_native, sizeof(buf_native), base, rel); +if (ret < 0) +snprintf(buf_native, sizeof(buf_native), "error %s", av_err2str(ret)); +if (strcmp(buf, buf_dos)) +printf("%50s %-20sDOS %s\n", base, rel, buf_dos); +if (HAVE_DOS_PATHS && strcmp(buf_dos, buf_native) || +!HAVE_DOS_PATHS && strcmp(buf, buf_native)) +printf("Native mismatch\n"); if (base) { /* Test in-buffer replacement */ snprintf(buf2, sizeof(buf2), "%s", base); -ff_make_absolute_url(buf2, sizeof(buf2), buf2, rel); +ff_make_absolute_url2(buf2, sizeof(buf2), buf2, rel, 0); if (strcmp(buf, buf2)) { printf("In-place handling of %s + %s failed\n", base, rel); exit(1); @@ -121,6 +133,21 @@ int main(void) test("http://server/foo/bar";, "..doubledotfile"); test("http://server/foo/bar";, "double..dotfile"); test("http://server/foo/bar";, "doubledotfile.."); +test("file1", "file2"); +test("dir/file1", "file2"); +test("dir/file1", "../file2"); +test("dir\\file1", "file2"); +test("srv\\shr\\file", "..\\..\\dummy"); +test("srv\\shr\\file", "dummy"); +test("srv\\shr\\file", "srv2\\shr2\\file2"); +test("srv\\shr\\file", "d:/file"); +test("C:\\dir\\a", "..\\file"); +test("C:\\dir\\a", "srv\\shr\\file"); +test("C:\\dir\\a", "d:\\file"); +test("http://a/b";, "srv\\shr\\file"); +test("http://a/b";, "//srv/shr/file"); +test("http://a/b";, "d:\\file"); +test("http://a/b";, "C:/file"); /* From https://tools.ietf.org/html/rfc3986#section-5.4 */ test("http://a/b/c/d;p?q";, "g:h"); // g:h diff --git a/libavformat/url.c b/libavformat/url.c index 222d7d8a10..f53fdf59d8 100644 --- a/libavformat/url.c +++ b/libavformat/url.c @@ -190,8 +190,8 @@ static int append_path(char *root, char *out_end, char **rout, return 0; } -int ff_make_absolute_url(char *buf, int size, const char *base, - const char *rel) +int ff_make_absolute_url2(char *buf, int size, const char *base, + const char *rel, int handle_dos_paths) { URLComponents ub, uc; char *out, *out_end, *path; @@ -224,7 +224,7 @@ int ff_make_absolute_url(char *buf, int size, const char *base, if (!base) base = ""; -if (HAVE_DOS_PATHS) { +if (handle_dos_paths) { if ((ret = ff_url_decompose(&ub, base, NULL)) < 0) goto error; if (is_fq_dos_path(base) || av_strstart(base, "file:", NULL) || ub.path == ub.url) { @@ -316,6 +316,12 @@ error: return ret; } +int ff_make_absolute_url(char *buf, int size, const char *base, + const char *rel) +{ +return ff_make_absolute_url2(buf, size, base, rel, HAVE_DOS_PATHS); +} + AVIODirEntry *ff_alloc_dir_entry(void) { AVIODirEntry *entry = av_mallocz(sizeof(AVIODirEntry)); diff --git a/libavformat/url.h b/libavformat/url.h index 728a861bd5..e059024c46 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -311,6 +311,16 @@ int ff_url_join(char *str, int size, const char *proto, * @param size the size of buf * @param base the base url, may be equal to buf.
[FFmpeg-cvslog] avformat/url: fix ff_make_absolute_url with Windows file paths
ffmpeg | branch: release/4.3 | Marton Balint | Fri Apr 2 17:07:54 2021 +0200| [51de6103e9c762f4ca528ffa030f978db6f5b72a] | committer: Marton Balint avformat/url: fix ff_make_absolute_url with Windows file paths Ugly, but a lot less broken than it was. Fixes ticket #9166. Signed-off-by: Marton Balint (cherry picked from commit 5dc5f289cefe67457bd16f1950c56911e926385f) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=51de6103e9c762f4ca528ffa030f978db6f5b72a --- libavformat/url.c | 24 +++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libavformat/url.c b/libavformat/url.c index 77d610d95f..222d7d8a10 100644 --- a/libavformat/url.c +++ b/libavformat/url.c @@ -149,6 +149,18 @@ int ff_url_decompose(URLComponents *uc, const char *url, const char *end) return 0; } +static int is_fq_dos_path(const char *path) +{ +if ((path[0] >= 'a' && path[0] <= 'z' || path[0] >= 'A' && path[0] <= 'Z') && + path[1] == ':' && +(path[2] == '/' || path[2] == '\\')) +return 1; +if ((path[0] == '/' || path[0] == '\\') && +(path[1] == '/' || path[1] == '\\')) +return 1; +return 0; +} + static int append_path(char *root, char *out_end, char **rout, const char *in, const char *in_end) { @@ -185,6 +197,7 @@ int ff_make_absolute_url(char *buf, int size, const char *base, char *out, *out_end, *path; const char *keep, *base_path_end; int use_base_path, simplify_path = 0, ret; +const char *base_separators = "/"; /* This is tricky. For HTTP, http://server/site/page + ../media/file @@ -211,6 +224,15 @@ int ff_make_absolute_url(char *buf, int size, const char *base, if (!base) base = ""; +if (HAVE_DOS_PATHS) { +if ((ret = ff_url_decompose(&ub, base, NULL)) < 0) +goto error; +if (is_fq_dos_path(base) || av_strstart(base, "file:", NULL) || ub.path == ub.url) { +base_separators = "/\\"; +if (is_fq_dos_path(rel)) +base = ""; +} +} if ((ret = ff_url_decompose(&ub, base, NULL)) < 0 || (ret = ff_url_decompose(&uc, rel, NULL)) < 0) goto error; @@ -249,7 +271,7 @@ int ff_make_absolute_url(char *buf, int size, const char *base, if (use_base_path) { base_path_end = ub.url_component_end_path; if (URL_COMPONENT_HAVE(uc, path)) -while (base_path_end > ub.path && base_path_end[-1] != '/') +while (base_path_end > ub.path && !strchr(base_separators, base_path_end[-1])) base_path_end--; } if (keep > ub.path) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/msp2dec: Check available space in RLE decoder
ffmpeg | branch: master | Michael Niedermayer | Tue Apr 6 23:14:08 2021 +0200| [caaf4633117f77a545975dac18e85b8fcdbc9ce7] | committer: Michael Niedermayer avcodec/msp2dec: Check available space in RLE decoder Fixes: out of array read Fixes: 32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=caaf4633117f77a545975dac18e85b8fcdbc9ce7 --- libavcodec/msp2dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c index cc548d218a..16c5ac6f02 100644 --- a/libavcodec/msp2dec.c +++ b/libavcodec/msp2dec.c @@ -71,6 +71,7 @@ static int msp2_decode_frame(AVCodecContext *avctx, while (bytestream2_get_bytes_left(&gb) && x < width) { int size = bytestream2_get_byte(&gb); if (size) { +size = FFMIN(size, bytestream2_get_bytes_left(&gb)); memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, FFMIN(size, width - x)); bytestream2_skip(&gb, size); } else { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/pngdec: always create a copy for APNG_DISPOSE_OP_BACKGROUND
ffmpeg | branch: master | Anton Khirnov | Thu Apr 8 10:46:54 2021 +0200| [b593abda6c642cb0c3959752dd235c2faf66837f] | committer: Michael Niedermayer lavc/pngdec: always create a copy for APNG_DISPOSE_OP_BACKGROUND Calling av_frame_make_writable() from decoders is tricky, especially when frame threading is used. It is much simpler and safer to just make a private copy of the frame. This is not expected to have a major performance impact, since APNG_DISPOSE_OP_BACKGROUND is not used often and av_frame_make_writable() would typically make a copy anyway. Found-by: James Almer Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b593abda6c642cb0c3959752dd235c2faf66837f --- libavcodec/pngdec.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 562c5ffea4..3e509e8ae0 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -89,6 +89,8 @@ typedef struct PNGDecContext { int has_trns; uint8_t transparent_color_be[6]; +uint8_t *background_buf; +unsigned background_buf_allocated; uint32_t palette[256]; uint8_t *crow_buf; uint8_t *last_row; @@ -1079,19 +1081,20 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, ff_thread_await_progress(&s->last_picture, INT_MAX, 0); // need to reset a rectangle to background: -// create a new writable copy if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) { -int ret = av_frame_make_writable(s->last_picture.f); -if (ret < 0) -return ret; +av_fast_malloc(&s->background_buf, &s->background_buf_allocated, + src_stride * p->height); +if (!s->background_buf) +return AVERROR(ENOMEM); -src= s->last_picture.f->data[0]; -src_stride = s->last_picture.f->linesize[0]; +memcpy(s->background_buf, src, src_stride * p->height); for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) { -memset(s->last_picture.f->data[0] + src_stride * y + +memset(s->background_buf + src_stride * y + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); } + +src = s->background_buf; } // copy unchanged rectangles from the last frame @@ -1716,6 +1719,7 @@ static av_cold int png_dec_end(AVCodecContext *avctx) s->last_row_size = 0; av_freep(&s->tmp_row); s->tmp_row_size = 0; +av_freep(&s->background_buf); av_freep(&s->iccp_data); av_dict_free(&s->frame_metadata); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/pngdec: always create a copy for APNG_DISPOSE_OP_BACKGROUND
ffmpeg | branch: release/4.4 | Anton Khirnov | Thu Apr 8 10:46:54 2021 +0200| [2a7f1bc282ddebee296bc0ca48a85bf01b626b3b] | committer: Michael Niedermayer lavc/pngdec: always create a copy for APNG_DISPOSE_OP_BACKGROUND Calling av_frame_make_writable() from decoders is tricky, especially when frame threading is used. It is much simpler and safer to just make a private copy of the frame. This is not expected to have a major performance impact, since APNG_DISPOSE_OP_BACKGROUND is not used often and av_frame_make_writable() would typically make a copy anyway. Found-by: James Almer Signed-off-by: Michael Niedermayer (cherry picked from commit b593abda6c642cb0c3959752dd235c2faf66837f) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2a7f1bc282ddebee296bc0ca48a85bf01b626b3b --- libavcodec/pngdec.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 0ff81d740c..f3b212d508 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -89,6 +89,8 @@ typedef struct PNGDecContext { int has_trns; uint8_t transparent_color_be[6]; +uint8_t *background_buf; +unsigned background_buf_allocated; uint32_t palette[256]; uint8_t *crow_buf; uint8_t *last_row; @@ -1091,19 +1093,20 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, ff_thread_await_progress(&s->last_picture, INT_MAX, 0); // need to reset a rectangle to background: -// create a new writable copy if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) { -int ret = av_frame_make_writable(s->last_picture.f); -if (ret < 0) -return ret; +av_fast_malloc(&s->background_buf, &s->background_buf_allocated, + src_stride * p->height); +if (!s->background_buf) +return AVERROR(ENOMEM); -src= s->last_picture.f->data[0]; -src_stride = s->last_picture.f->linesize[0]; +memcpy(s->background_buf, src, src_stride * p->height); for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) { -memset(s->last_picture.f->data[0] + src_stride * y + +memset(s->background_buf + src_stride * y + s->bpp * s->last_x_offset, 0, s->bpp * s->last_w); } + +src = s->background_buf; } // copy unchanged rectangles from the last frame @@ -1738,6 +1741,7 @@ static av_cold int png_dec_end(AVCodecContext *avctx) s->last_row_size = 0; av_freep(&s->tmp_row); s->tmp_row_size = 0; +av_freep(&s->background_buf); av_freep(&s->iccp_data); av_dict_free(&s->frame_metadata); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/mov: check offset for overflow in mov_probe()
ffmpeg | branch: release/4.4 | Michael Niedermayer | Sun Apr 4 21:01:46 2021 +0200| [d22550dd61003ffefc1a7738b2c14916083116a9] | committer: Michael Niedermayer avformat/mov: check offset for overflow in mov_probe() Fixes: Invalid read of size 4 Fixes: ASAN_Deadlysignal.zip Found-by: Hardik Shah Signed-off-by: Michael Niedermayer (cherry picked from commit 0f6a3405e8987ad761a2d9139fdc95bbb6a61118) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d22550dd61003ffefc1a7738b2c14916083116a9 --- libavformat/mov.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 50234f3b5f..38a70589be 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7122,7 +7122,7 @@ static int mov_probe(const AVProbeData *p) int64_t size; int minsize = 8; /* ignore invalid offset */ -if ((offset + 8) > (unsigned int)p->buf_size) +if ((offset + 8ULL) > (unsigned int)p->buf_size) break; size = AV_RB32(p->buf + offset); if (size == 1 && offset + 16 <= (unsigned int)p->buf_size) { @@ -7169,6 +7169,8 @@ static int mov_probe(const AVProbeData *p) score = FFMAX(score, AVPROBE_SCORE_EXTENSION); break; } +if (size > INT64_MAX - offset) +break; offset += size; } if (score > AVPROBE_SCORE_MAX - 50 && moov_offset != -1) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/msp2dec: Check available space in RLE decoder
ffmpeg | branch: release/4.4 | Michael Niedermayer | Tue Apr 6 23:14:08 2021 +0200| [aeba1a4c20cf37f1cbbd6338783e18cfb463b0c7] | committer: Michael Niedermayer avcodec/msp2dec: Check available space in RLE decoder Fixes: out of array read Fixes: 32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit caaf4633117f77a545975dac18e85b8fcdbc9ce7) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aeba1a4c20cf37f1cbbd6338783e18cfb463b0c7 --- libavcodec/msp2dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c index cc548d218a..16c5ac6f02 100644 --- a/libavcodec/msp2dec.c +++ b/libavcodec/msp2dec.c @@ -71,6 +71,7 @@ static int msp2_decode_frame(AVCodecContext *avctx, while (bytestream2_get_bytes_left(&gb) && x < width) { int size = bytestream2_get_byte(&gb); if (size) { +size = FFMIN(size, bytestream2_get_bytes_left(&gb)); memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, FFMIN(size, width - x)); bytestream2_skip(&gb, size); } else { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] RELEASE_NOTES: Based on the version from 4.3
ffmpeg | branch: release/4.4 | Michael Niedermayer | Fri Nov 2 01:36:21 2018 +0100| [dc91b913b6260e85e1304c74ff7bb3c22a8c9fb1] | committer: Michael Niedermayer RELEASE_NOTES: Based on the version from 4.3 Name suggested by Lynne, Gyan, Reto, Zane, Jan, Derek Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc91b913b6260e85e1304c74ff7bb3c22a8c9fb1 --- RELEASE_NOTES | 15 +++ 1 file changed, 15 insertions(+) diff --git a/RELEASE_NOTES b/RELEASE_NOTES new file mode 100644 index 00..67339dca85 --- /dev/null +++ b/RELEASE_NOTES @@ -0,0 +1,15 @@ + + ┌┐ + │ RELEASE NOTES for FFmpeg 4.4 "Rao" │ + └┘ + + The FFmpeg Project proudly presents FFmpeg 4.4 "Rao", about 10 + months after the release of FFmpeg 4.3. + + A complete Changelog is available at the root of the project, and the + complete Git history on https://git.ffmpeg.org/gitweb/ffmpeg.git + + We hope you will like this release as much as we enjoyed working on it, and + as usual, if you have any questions about it, or any FFmpeg related topic, + feel free to join us on the #ffmpeg IRC channel (on irc.freenode.net) or ask + on the mailing-lists. ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] Tag n4.4 : FFmpeg 4.4 release
[ffmpeg] [branch: refs/tags/n4.4] Tag:09c358362008e2d04cec8239526c6827543da4cf > http://git.videolan.org/gitweb.cgi/ffmpeg.git?a=tag;h=09c358362008e2d04cec8239526c6827543da4cf Tagger: Michael Niedermayer Date: Thu Apr 8 23:39:42 2021 +0200 FFmpeg 4.4 release ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] [ffmpeg-web] branch master updated. 8afd3bf web/download: Add FFmpeg 4.4
The branch, master has been updated via 8afd3bf998264f47f500caefa2d9f46c98da4fdb (commit) from c04853a37681d915ffb8590fb5095fceffa2347d (commit) - Log - commit 8afd3bf998264f47f500caefa2d9f46c98da4fdb Author: Michael Niedermayer AuthorDate: Thu Apr 8 23:50:58 2021 +0200 Commit: Michael Niedermayer CommitDate: Thu Apr 8 23:50:58 2021 +0200 web/download: Add FFmpeg 4.4 Signed-off-by: Michael Niedermayer diff --git a/src/download b/src/download index a6483a6..0761874 100644 --- a/src/download +++ b/src/download @@ -304,6 +304,42 @@ gpg: Good signature from "FFmpeg release signing keyChangelog + https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/release/4.3:/RELEASE_NOTES";>Release Notes + + + FFmpeg 4.3.2 "4:3" --- Summary of changes: src/download | 36 1 file changed, 36 insertions(+) hooks/post-receive -- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] [ffmpeg-web] branch master updated. 1e5f91f web/security: add CVEs for 4.4
The branch, master has been updated via 1e5f91f1f484a956b4945972dfc2d730a4a65200 (commit) from 8afd3bf998264f47f500caefa2d9f46c98da4fdb (commit) - Log - commit 1e5f91f1f484a956b4945972dfc2d730a4a65200 Author: Michael Niedermayer AuthorDate: Thu Apr 8 23:55:54 2021 +0200 Commit: Michael Niedermayer CommitDate: Thu Apr 8 23:55:54 2021 +0200 web/security: add CVEs for 4.4 diff --git a/src/security b/src/security index 86487c1..b5033c0 100644 --- a/src/security +++ b/src/security @@ -1,5 +1,19 @@ Please report vulnerabilities to mailto:ffmpeg-secur...@ffmpeg.org";>ffmpeg-secur...@ffmpeg.org +FFmpeg 4.4 + +4.4 + +Fixes following vulnerabilities: + + +CVE-2020-14212, 0b3bd001ac1745d9d008a2d195817df57d7d1d14 +CVE-2020-13904, 9dfb19baeb86a8bb02c53a441682c6e9a6e104cc +CVE-2020-13904, b5e39880fb7269b1b3577cee288e06aa3dc1dfa2 +CVE-2020-35965, b0a8b40294ea212c1938348ff112ef1b9bf16bb3 +CVE-2020-35965, 3e5959b3457f7f1856d997261e6ac672bba49e8b + + FFmpeg 4.3 4.3.1 --- Summary of changes: src/security | 14 ++ 1 file changed, 14 insertions(+) hooks/post-receive -- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] [ffmpeg-web] branch master updated. d512aab web/download: fix copy and paste error in release notes link
The branch, master has been updated via d512aabee0298785e9adb533fb8d6f869c21d540 (commit) from 1e5f91f1f484a956b4945972dfc2d730a4a65200 (commit) - Log - commit d512aabee0298785e9adb533fb8d6f869c21d540 Author: Michael Niedermayer AuthorDate: Thu Apr 8 23:58:38 2021 +0200 Commit: Michael Niedermayer CommitDate: Thu Apr 8 23:58:38 2021 +0200 web/download: fix copy and paste error in release notes link diff --git a/src/download b/src/download index 0761874..85f3163 100644 --- a/src/download +++ b/src/download @@ -336,7 +336,7 @@ libpostproc55. 9.100 https://git.ffmpeg.org/gitweb/ffmpeg.git/shortlog/n4.4";>Changelog - https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/release/4.3:/RELEASE_NOTES";>Release Notes + https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/release/4.4:/RELEASE_NOTES";>Release Notes --- Summary of changes: src/download | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] Tag n4.5-dev : Main development, master branch after release/4.4 branched off
[ffmpeg] [branch: refs/tags/n4.5-dev] Tag:3187c3628c0c05e2e02968c2ac1449e15f0fad3e > http://git.videolan.org/gitweb.cgi/ffmpeg.git?a=tag;h=3187c3628c0c05e2e02968c2ac1449e15f0fad3e Tagger: James Almer Date: Thu Apr 8 19:36:38 2021 -0300 Main development, master branch after release/4.4 branched off ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] [ffmpeg-web] branch master updated. fec8808 web/index: add news entry for 4.4
The branch, master has been updated via fec8808a1a75365afaec17b0601d3b843708d77c (commit) from d512aabee0298785e9adb533fb8d6f869c21d540 (commit) - Log - commit fec8808a1a75365afaec17b0601d3b843708d77c Author: James Almer AuthorDate: Thu Apr 8 22:17:04 2021 -0300 Commit: James Almer CommitDate: Thu Apr 8 22:17:04 2021 -0300 web/index: add news entry for 4.4 diff --git a/src/index b/src/index index b0ca46c..e456ed2 100644 --- a/src/index +++ b/src/index @@ -35,6 +35,99 @@ News + April 8th, 2021, FFmpeg 4.4 "Rao" + +FFmpeg 4.4 "Rao", a new +major release, is now available! Some of the highlights: + + +AudioToolbox output device +MacCaption demuxer +PGX decoder +chromanr video filter +VDPAU accelerated HEVC 10/12bit decoding +ADPCM IMA Ubisoft APM encoder +Rayman 2 APM muxer +AV1 encoding support SVT-AV1 +Cineform HD encoder +ADPCM Argonaut Games encoder +Argonaut Games ASF muxer +AV1 Low overhead bitstream format demuxer +RPZA video encoder +ADPCM IMA MOFLEX decoder +MobiClip FastAudio decoder +MobiClip video decoder +MOFLEX demuxer +MODS demuxer +PhotoCD decoder +MCA demuxer +AV1 decoder (Hardware acceleration used only) +SVS demuxer +Argonaut Games BRP demuxer +DAT demuxer +aax demuxer +IPU decoder, parser and demuxer +Intel QSV-accelerated AV1 decoding +Argonaut Games Video decoder +libwavpack encoder removed +ACE demuxer +AVS3 demuxer +AVS3 video decoder via libuavs3d +Cintel RAW decoder +VDPAU accelerated VP9 10/12bit decoding +afreqshift and aphaseshift filters +High Voltage Software ADPCM encoder +LEGO Racers ALP (.tun & .pcm) muxer +AV1 VAAPI decoder +adenorm filter +ADPCM IMA AMV encoder +AMV muxer +NVDEC AV1 hwaccel +DXVA2/D3D11VA hardware accelerated AV1 decoding +speechnorm filter +SpeedHQ encoder +asupercut filter +asubcut filter +Microsoft Paint (MSP) version 2 decoder +Microsoft Paint (MSP) demuxer +AV1 monochrome encoding support via libaom >= 2.0.1 +asuperpass and asuperstop filter +shufflepixels filter +tmidequalizer filter +estdif filter +epx filter +Dolby E parser +shear filter +kirsch filter +colortemperature filter +colorcontrast filter +PFM encoder +colorcorrect filter +binka demuxer +XBM parser +xbm_pipe demuxer +colorize filter +CRI parser +aexciter audio filter +exposure video filter +monochrome video filter +setts bitstream filter +vif video filter +OpenEXR image encoder +Simbiosis IMX decoder +Simbiosis IMX demuxer +Digital Pictures SGA demuxer and decoders +TTML subtitle encoder and muxer +identity video filter +msad video filter +gophers protocol +RIST protocol via librist + + +We strongly recommend users, distributors, and system integrators to +upgrade unless they use current git master. + + June 15th, 2020, FFmpeg 4.3 "4:3" FFmpeg 4.3 "4:3", a new --- Summary of changes: src/index | 93 +++ 1 file changed, 93 insertions(+) hooks/post-receive -- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] Changelog: replace by 4.4
ffmpeg | branch: release/4.4 | Michael Niedermayer | Fri Apr 9 06:23:34 2021 +0200| [f68ab9de4e6ef9830deef778046bea760eff74f9] | committer: Michael Niedermayer Changelog: replace by 4.4 Found-by: Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f68ab9de4e6ef9830deef778046bea760eff74f9 --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index a96e350e09..214b3dbb4d 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. -version : +version 4.4: - AudioToolbox output device - MacCaption demuxer - PGX decoder ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".