[FFmpeg-cvslog] avcodec/ffv1: Fix remap and float with golomb rice
ffmpeg | branch: master | Michael Niedermayer | Sun Mar 9 23:35:44 2025 +0100| [a8a83e06f917a4d4c8c090184515d6ba6bed30b1] | committer: Michael Niedermayer avcodec/ffv1: Fix remap and float with golomb rice Sponsored-by: Sovereign Tech Fund Reviewed-by: Lynne Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a8a83e06f917a4d4c8c090184515d6ba6bed30b1 --- libavcodec/ffv1dec.c | 37 +++ libavcodec/ffv1dec_template.c | 27 -- libavcodec/ffv1enc.c | 42 + libavcodec/ffv1enc_template.c | 86 +-- 4 files changed, 113 insertions(+), 79 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 5e9a765e38..37b14c0410 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -243,6 +243,37 @@ static void slice_set_damaged(FFV1Context *f, FFV1SliceContext *sc) f->frame_damaged = 1; } +static int decode_remap(FFV1Context *f, FFV1SliceContext *sc) +{ +int transparency = f->transparency; + +for (int p= 0; p<3 + transparency; p++) { +int j = 0; +int lu = 0; +uint8_t state[2][32]; +memset(state, 128, sizeof(state)); + +for (int i= 0; i<65536; i++) { +int run = get_symbol_inline(&sc->c, state[lu], 0); +if (run > 65536U - i) +return AVERROR_INVALIDDATA; +if (lu) { +lu ^= !run; +while (run--) { +sc->fltmap[p][j++] = i ^ ((i&0x8000) ? 0 : 0x7FFF); +i++; +} +} else { +i += run; +if (i != 65536) +sc->fltmap[p][j++] = i ^ ((i&0x8000) ? 0 : 0x7FFF); +lu ^= !run; +} +} +} +return 0; +} + static int decode_slice(AVCodecContext *c, void *arg) { FFV1Context *f= c->priv_data; @@ -285,6 +316,12 @@ static int decode_slice(AVCodecContext *c, void *arg) x = sc->slice_x; y = sc->slice_y; +if (sc->remap) { +ret = decode_remap(f, sc); +if (ret < 0) +return ret; +} + if (ac == AC_GOLOMB_RICE) { if (f->combined_version >= 0x30002) get_rac(&sc->c, (uint8_t[]) { 129 }); diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c index 01e61e1ae8..cdebdf3a62 100644 --- a/libavcodec/ffv1dec_template.c +++ b/libavcodec/ffv1dec_template.c @@ -155,33 +155,6 @@ static int RENAME(decode_rgb_frame)(FFV1Context *f, FFV1SliceContext *sc, memset(RENAME(sc->sample_buffer), 0, 8 * (w + 6) * sizeof(*RENAME(sc->sample_buffer))); -if (sc->remap) { -for (int p= 0; p<3 + transparency; p++) { -int j = 0; -int lu = 0; -uint8_t state[2][32]; -memset(state, 128, sizeof(state)); - -for (int i= 0; i<65536; i++) { -int run = get_symbol_inline(&sc->c, state[lu], 0); -if (run > 65536U - i) -return AVERROR_INVALIDDATA; -if (lu) { -lu ^= !run; -while (run--) { -sc->fltmap[p][j++] = i ^ ((i&0x8000) ? 0 : 0x7FFF); -i++; -} -} else { -i += run; -if (i != 65536) -sc->fltmap[p][j++] = i ^ ((i&0x8000) ? 0 : 0x7FFF); -lu ^= !run; -} -} -} -} - for (y = 0; y < h; y++) { for (p = 0; p < 3 + transparency; p++) { int ret; diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index cc366621ca..79288e945d 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1101,6 +1101,36 @@ static void choose_rct_params(const FFV1Context *f, FFV1SliceContext *sc, sc->slice_rct_ry_coef = rct_y_coeff[best][0]; } +static void encode_remap(FFV1Context *f, FFV1SliceContext *sc) +{ +int transparency = f->transparency; + +for (int p= 0; p<3 + transparency; p++) { +int j = 0; +int lu = 0; +uint8_t state[2][32]; +int run = 0; +memset(state, 128, sizeof(state)); +for (int i= 0; i<65536; i++) { +int ri = i ^ ((i&0x8000) ? 0 : 0x7FFF); +int u = sc->fltmap[p][ri]; +sc->fltmap[p][ri] = j; +j+= u; + +if (lu == u) { +run ++; +} else { +put_symbol_inline(&sc->c, state[lu], run, 0, NULL, NULL); +if (run == 0) +lu = u; +run = 0; +} +} +if (run) +put_symbol(&sc->c, state[lu], run, 0); +} +} + static int encode_slice(AVCodecContext *c, void *arg) { FFV1SliceContext *sc = arg; @@ -1133,6 +1163,18 @@ retry: if (f->version > 2)
[FFmpeg-cvslog] avcodec/ffv1enc: Fix slice coding mode 1 with rgb frames
ffmpeg | branch: master | Michael Niedermayer | Sun Mar 9 23:33:48 2025 +0100| [99f0f6e4012ef89c4e9079da6aba8824769ebe0f] | committer: Michael Niedermayer avcodec/ffv1enc: Fix slice coding mode 1 with rgb frames Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=99f0f6e4012ef89c4e9079da6aba8824769ebe0f --- libavcodec/ffv1enc.c | 6 +++--- libavcodec/ffv1enc_template.c | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 6acc4d7ece..cc366621ca 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -419,7 +419,7 @@ av_cold int ff_ffv1_write_extradata(AVCodecContext *avctx) if (f->version == 3) { f->micro_version = 4; } else if (f->version == 4) -f->micro_version = 4; +f->micro_version = 5; f->combined_version += f->micro_version; put_symbol(&c, state, f->micro_version, 0); } @@ -1158,9 +1158,9 @@ retry: ret = encode_plane(f, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 2, ac); ret |= encode_plane(f, sc, p->data[0] + 1 + ps*x + y*p->linesize[0], width, height, p->linesize[0], 1, 2, ac); } else if (f->use32bit) { -ret = encode_rgb_frame32(f, sc, planes, width, height, p->linesize); +ret = encode_rgb_frame32(f, sc, planes, width, height, p->linesize, ac); } else { -ret = encode_rgb_frame(f, sc, planes, width, height, p->linesize); +ret = encode_rgb_frame(f, sc, planes, width, height, p->linesize, ac); } if (ac != AC_GOLOMB_RICE) { diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c index af3354497a..1430a27ee7 100644 --- a/libavcodec/ffv1enc_template.c +++ b/libavcodec/ffv1enc_template.c @@ -129,12 +129,11 @@ RENAME(encode_line)(FFV1Context *f, FFV1SliceContext *sc, static int RENAME(encode_rgb_frame)(FFV1Context *f, FFV1SliceContext *sc, const uint8_t *src[4], -int w, int h, const int stride[4]) +int w, int h, const int stride[4], int ac) { int x, y, p, i; const int ring_size = f->context_model ? 3 : 2; TYPE *sample[4][3]; -const int ac = f->ac; const int pass1 = !!(f->avctx->flags & AV_CODEC_FLAG_PASS1); int lbd= f->bits_per_raw_sample <= 8; int packed = !src[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] hwcontext_vulkan: add support for mapping multiplane images into CUDA
ffmpeg | branch: master | Lynne | Fri Mar 7 00:01:47 2025 +| [bdc07f372ac14ad9cb6d4f7f356d4c7a47c251fe] | committer: Lynne hwcontext_vulkan: add support for mapping multiplane images into CUDA This patch refactors the CUDA import code to allow for Vulkan images with multiple planes to be mapped. Currently, a driver bug exists which causes NV12 images to be mapped incorrectly when the memory being mapped contains both planes, the issue has been reported to NVIDIA. yuv420p does work correctly, however. This is still an improvement, as the code used to crash when trying to map the memory, unless disable_multiplane=1 was given as an option. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bdc07f372ac14ad9cb6d4f7f356d4c7a47c251fe --- libavutil/hwcontext_vulkan.c | 262 ++- 1 file changed, 160 insertions(+), 102 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 10521ce685..fcff34b5e2 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -3409,6 +3409,130 @@ fail: #endif #if CONFIG_CUDA +static int export_mem_to_cuda(AVHWDeviceContext *ctx, + AVHWDeviceContext *cuda_cu, CudaFunctions *cu, + AVVkFrameInternal *dst_int, int idx, + VkDeviceMemory mem, size_t size) +{ +VkResult ret; +VulkanDevicePriv *p = ctx->hwctx; +AVVulkanDeviceContext *hwctx = &p->p; +FFVulkanFunctions *vk = &p->vkctx.vkfn; + +#ifdef _WIN32 +CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc = { +.type = IsWindows8OrGreater() +? CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32 +: CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT, +.size = size, +}; +VkMemoryGetWin32HandleInfoKHR export_info = { +.sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR, +.memory = mem, +.handleType = IsWindows8OrGreater() +? VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT +: VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, +}; + +ret = vk->GetMemoryWin32HandleKHR(hwctx->act_dev, &export_info, + &ext_desc.handle.win32.handle); +if (ret != VK_SUCCESS) { +av_log(ctx, AV_LOG_ERROR, "Unable to export the image as a Win32 Handle: %s!\n", + ff_vk_ret2str(ret)); +return AVERROR_EXTERNAL; +} +dst_int->ext_mem_handle[idx] = ext_desc.handle.win32.handle; +#else +CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc = { +.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD, +.size = size, +}; +VkMemoryGetFdInfoKHR export_info = { +.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR, +.memory = mem, +.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR, +}; + +ret = vk->GetMemoryFdKHR(hwctx->act_dev, &export_info, + &ext_desc.handle.fd); +if (ret != VK_SUCCESS) { +av_log(ctx, AV_LOG_ERROR, "Unable to export the image as a FD: %s!\n", + ff_vk_ret2str(ret)); +return AVERROR_EXTERNAL; +} +#endif + +ret = CHECK_CU(cu->cuImportExternalMemory(&dst_int->ext_mem[idx], &ext_desc)); +if (ret < 0) { +#ifndef _WIN32 +close(ext_desc.handle.fd); +#endif +return AVERROR_EXTERNAL; +} + +return 0; +} + +static int export_sem_to_cuda(AVHWDeviceContext *ctx, + AVHWDeviceContext *cuda_cu, CudaFunctions *cu, + AVVkFrameInternal *dst_int, int idx, + VkSemaphore sem) +{ +VkResult ret; +VulkanDevicePriv *p = ctx->hwctx; +AVVulkanDeviceContext *hwctx = &p->p; +FFVulkanFunctions *vk = &p->vkctx.vkfn; + +#ifdef _WIN32 +VkSemaphoreGetWin32HandleInfoKHR sem_export = { +.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR, +.semaphore = sem, +.handleType = IsWindows8OrGreater() + ? VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT + : VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, +}; +CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC ext_sem_desc = { +.type = 10 /* TODO: CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32 */, +}; +#else +VkSemaphoreGetFdInfoKHR sem_export = { +.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR, +.semaphore = sem, +.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, +}; +CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC ext_sem_desc = { +.type = 9 /* TODO: CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD */, +}; +#endif + +#ifdef _WIN32 +ret = vk->GetSemaphoreWin32HandleKHR(hwctx->act_dev, &sem_export, + &ext_sem_desc.handle.win32.handle); +#else +ret = vk->GetSemaphoreFdKHR(hwc
[FFmpeg-cvslog] avcodec/put_bits: Add and use put_bits63()
ffmpeg | branch: master | Andreas Rheinhardt | Sat Mar 8 17:35:32 2025 +0100| [ede2b391cc516f4f93621f6a214b3410b231f582] | committer: Andreas Rheinhardt avcodec/put_bits: Add and use put_bits63() When using a 64bit PutBitContext (i.e. on x64), put_bits_no_assert() can naturally write up to 63 bits. So one can avoid treating the cases <32bits, 32 bits and <63 bits differently. As it turns out, no user actually wants to write 64 bit at once (maybe except testprograms). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ede2b391cc516f4f93621f6a214b3410b231f582 --- libavcodec/dovi_rpuenc.c | 8 libavcodec/put_bits.h | 29 ++--- libavcodec/put_golomb.h | 2 +- libavcodec/vc2enc.c | 2 +- libavformat/iamf_parse.c | 2 +- libavformat/iamf_writer.c | 2 +- 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c index eb79a3af5d..334b2c98a0 100644 --- a/libavcodec/dovi_rpuenc.c +++ b/libavcodec/dovi_rpuenc.c @@ -334,12 +334,12 @@ static inline void put_ue_coef(PutBitContext *pb, const AVDOVIRpuDataHeader *hdr switch (hdr->coef_data_type) { case RPU_COEFF_FIXED: set_ue_golomb(pb, coef >> hdr->coef_log2_denom); -put_bits64(pb, hdr->coef_log2_denom, +put_bits63(pb, hdr->coef_log2_denom, coef & ((1LL << hdr->coef_log2_denom) - 1)); break; case RPU_COEFF_FLOAT: fpart.f32 = coef / (float) (1LL << hdr->coef_log2_denom); -put_bits64(pb, hdr->coef_log2_denom, fpart.u32); +put_bits63(pb, hdr->coef_log2_denom, fpart.u32); break; } } @@ -352,12 +352,12 @@ static inline void put_se_coef(PutBitContext *pb, const AVDOVIRpuDataHeader *hdr switch (hdr->coef_data_type) { case RPU_COEFF_FIXED: set_se_golomb(pb, coef >> hdr->coef_log2_denom); -put_bits64(pb, hdr->coef_log2_denom, +put_bits63(pb, hdr->coef_log2_denom, coef & ((1LL << hdr->coef_log2_denom) - 1)); break; case RPU_COEFF_FLOAT: fpart.f32 = coef / (float) (1LL << hdr->coef_log2_denom); -put_bits64(pb, hdr->coef_log2_denom, fpart.u32); +put_bits63(pb, hdr->coef_log2_denom, fpart.u32); break; } } diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index 0caaa6b338..56c3f4cc6d 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -39,14 +39,14 @@ typedef uint64_t BitBuf; #define AV_WBBUF AV_WB64 #define AV_WLBUF AV_WL64 +#define BUF_BITS 64 #else typedef uint32_t BitBuf; #define AV_WBBUF AV_WB32 #define AV_WLBUF AV_WL32 +#define BUF_BITS 32 #endif -static const int BUF_BITS = 8 * sizeof(BitBuf); - typedef struct PutBitContext { BitBuf bit_buf; int bit_left; @@ -329,12 +329,15 @@ static void av_unused put_bits32(PutBitContext *s, uint32_t value) } /** - * Write up to 64 bits into a bitstream. + * Write up to 63 bits into a bitstream. */ -static inline void put_bits64(PutBitContext *s, int n, uint64_t value) +static inline void put_bits63(PutBitContext *s, int n, uint64_t value) { -av_assert2((n == 64) || (n < 64 && value < (UINT64_C(1) << n))); +av_assert2(n < 64U && value < (UINT64_C(1) << n)); +#if BUF_BITS >= 64 +put_bits_no_assert(s, n, value); +#else if (n < 32) put_bits(s, n, value); else if (n == 32) @@ -349,6 +352,19 @@ static inline void put_bits64(PutBitContext *s, int n, uint64_t value) put_bits(s, n - 32, hi); put_bits32(s, lo); #endif +} +#endif +} + +/** + * Write up to 64 bits into a bitstream. + */ +static inline void put_bits64(PutBitContext *s, int n, uint64_t value) +{ +av_assert2((n == 64) || (n < 64 && value < (UINT64_C(1) << n))); + +if (n < 64) { +put_bits63(s, n, value); } else { uint32_t lo = value & 0x; uint32_t hi = value >> 32; @@ -359,7 +375,6 @@ static inline void put_bits64(PutBitContext *s, int n, uint64_t value) put_bits32(s, hi); put_bits32(s, lo); #endif - } } @@ -367,7 +382,7 @@ static inline void put_sbits63(PutBitContext *pb, int n, int64_t value) { av_assert2(n >= 0 && n < 64); -put_bits64(pb, n, (uint64_t)(value) & (~(UINT64_MAX << n))); +put_bits63(pb, n, (uint64_t)(value) & (~(UINT64_MAX << n))); } /** diff --git a/libavcodec/put_golomb.h b/libavcodec/put_golomb.h index 43c1233fdb..91e7852a17 100644 --- a/libavcodec/put_golomb.h +++ b/libavcodec/put_golomb.h @@ -62,7 +62,7 @@ static inline void set_ue_golomb_long(PutBitContext *pb, uint32_t i) put_bits(pb, ff_ue_golomb_len[i], i + 1); else { int e = av_log2(i + 1); -put_bits64(pb, 2 * e + 1, i + 1); +put_bits63(pb, 2 * e + 1, i + 1); } } diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index 4611c3977b..4728a48938 100644 --- a/libavcodec/vc2enc.c +++ b/lib
[FFmpeg-cvslog] libavfilter: guard against ff_draw_init/ff_draw_init2 failures
ffmpeg | branch: master | Nil Fons Miret | Fri Feb 21 01:18:21 2025 +| [9899da8175f059aa8bf21e45ad1b5e7cfd33b786] | committer: Michael Niedermayer libavfilter: guard against ff_draw_init/ff_draw_init2 failures The return value of ff_draw_init and ff_draw_init2 are not checked in most usages. However, if they return an error, they don't get to the point where they set the attributes of the FFDrawContext. These functions are typically used in conjunction with ff_draw_color, which checks draw->desc->flags, causing a null pointer dereference. Signed-off-by: Nil Fons Miret Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9899da8175f059aa8bf21e45ad1b5e7cfd33b786 --- libavfilter/qrencode.c | 27 ++- libavfilter/src_avsynctest.c | 7 ++- libavfilter/vf_datascope.c | 31 +-- libavfilter/vf_drawtext.c| 6 +- libavfilter/vf_pad.c | 6 +- libavfilter/vf_shear.c | 7 ++- libavfilter/vf_stack.c | 6 +- libavfilter/vf_subtitles.c | 16 +++- libavfilter/vf_tile.c| 7 ++- libavfilter/vf_tinterlace.c | 6 +- libavfilter/vf_tpad.c| 7 ++- libavfilter/vsrc_testsrc.c | 9 +++-- 12 files changed, 109 insertions(+), 26 deletions(-) diff --git a/libavfilter/qrencode.c b/libavfilter/qrencode.c index f96cc8dc93..8c09b605ad 100644 --- a/libavfilter/qrencode.c +++ b/libavfilter/qrencode.c @@ -636,11 +636,20 @@ static int qrencodesrc_config_props(AVFilterLink *outlink) return AVERROR(EINVAL); } -ff_draw_init(&qr->draw, AV_PIX_FMT_ARGB, FF_DRAW_PROCESS_ALPHA); +ret = ff_draw_init(&qr->draw, AV_PIX_FMT_ARGB, FF_DRAW_PROCESS_ALPHA); +if (ret < 0) { +// This call using constants should not fail. Checking its error code for completeness. +av_log(ctx, AV_LOG_ERROR, "Failed to initialize FFDrawContext\n"); +return ret; +} ff_draw_color(&qr->draw, &qr->draw_foreground_color, (const uint8_t *)&qr->foreground_color); ff_draw_color(&qr->draw, &qr->draw_background_color, (const uint8_t *)&qr->background_color); -ff_draw_init2(&qr->draw0, outlink->format, outlink->colorspace, outlink->color_range, FF_DRAW_PROCESS_ALPHA); +ret = ff_draw_init2(&qr->draw0, outlink->format, outlink->colorspace, outlink->color_range, FF_DRAW_PROCESS_ALPHA); +if (ret < 0) { +av_log(ctx, AV_LOG_ERROR, "Failed to initialize FFDrawContext\n"); +return ret; +} ff_draw_color(&qr->draw0, &qr->draw0_background_color, (const uint8_t *)&qr->background_color); outlink->w = qr->rendered_padded_qrcode_width; @@ -734,8 +743,12 @@ static int qrencode_config_input(AVFilterLink *inlink) qr->is_source = 0; -ff_draw_init2(&qr->draw, inlink->format, inlink->colorspace, inlink->color_range, - FF_DRAW_PROCESS_ALPHA); +ret = ff_draw_init2(&qr->draw, inlink->format, inlink->colorspace, inlink->color_range, +FF_DRAW_PROCESS_ALPHA); +if (ret < 0) { +av_log(ctx, AV_LOG_ERROR, "Failed to initialize FFDrawContext\n"); +return ret; +} V(W) = V(main_w) = inlink->w; V(H) = V(main_h) = inlink->h; @@ -764,8 +777,12 @@ static int qrencode_config_input(AVFilterLink *inlink) PARSE_EXPR(rendered_qrcode_width); PARSE_EXPR(rendered_padded_qrcode_width); -ff_draw_init2(&qr->draw, inlink->format, inlink->colorspace, inlink->color_range, +ret = ff_draw_init2(&qr->draw, inlink->format, inlink->colorspace, inlink->color_range, FF_DRAW_PROCESS_ALPHA); +if (ret < 0) { +av_log(ctx, AV_LOG_ERROR, "Failed to initialize FFDrawContext\n"); +return ret; +} ff_draw_color(&qr->draw, &qr->draw_foreground_color, (const uint8_t *)&qr->foreground_color); ff_draw_color(&qr->draw, &qr->draw_background_color, (const uint8_t *)&qr->background_color); diff --git a/libavfilter/src_avsynctest.c b/libavfilter/src_avsynctest.c index 6f42137f49..68dffba43a 100644 --- a/libavfilter/src_avsynctest.c +++ b/libavfilter/src_avsynctest.c @@ -147,6 +147,7 @@ static av_cold int config_props(AVFilterLink *outlink) FilterLink *l = ff_filter_link(outlink); AVFilterContext *ctx = outlink->src; AVSyncTestContext *s = ctx->priv; +int ret; outlink->w = s->w; outlink->h = s->h; @@ -160,7 +161,11 @@ static av_cold int config_props(AVFilterLink *outlink) s->dir = 1; s->prev_intpart = INT64_MIN; -ff_draw_init2(&s->draw, outlink->format, outlink->colorspace, outlink->color_range, 0); +ret = ff_draw_init2(&s->draw, outlink->format, outlink->colorspace, outlink->color_range, 0); +if (ret < 0) { +av_log(ctx, AV_LOG_ERROR, "Failed to initialize FFDrawContext\n"); +return ret; +} ff_draw_color(&s->draw, &s->fg, s->rgba[0]); ff_draw_color(&s->draw, &s->bg, s->rgba[1])
[FFmpeg-cvslog] avcodec/ffv1enc_template: Be a bit more verbose on error
ffmpeg | branch: master | Michael Niedermayer | Sun Mar 9 23:38:29 2025 +0100| [0b097ed9f141f57e2b91f0704c721a9eff0204c0] | committer: Michael Niedermayer avcodec/ffv1enc_template: Be a bit more verbose on error Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b097ed9f141f57e2b91f0704c721a9eff0204c0 --- libavcodec/ffv1enc_template.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c index 502c805ff6..878ab6c720 100644 --- a/libavcodec/ffv1enc_template.c +++ b/libavcodec/ffv1enc_template.c @@ -37,12 +37,12 @@ RENAME(encode_line)(FFV1Context *f, FFV1SliceContext *sc, if (ac != AC_GOLOMB_RICE) { if (c->bytestream_end - c->bytestream < w * 35) { -av_log(logctx, AV_LOG_ERROR, "encoded frame too large\n"); +av_log(logctx, AV_LOG_ERROR, "encoded Range Coder frame too large\n"); return AVERROR_INVALIDDATA; } } else { if (put_bytes_left(&sc->pb, 0) < w * 4) { -av_log(logctx, AV_LOG_ERROR, "encoded frame too large\n"); +av_log(logctx, AV_LOG_ERROR, "encoded Golomb Rice frame too large\n"); return AVERROR_INVALIDDATA; } } ___ 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] configure: update copyright year
ffmpeg | branch: release/4.3 | Lynne | Wed Jan 1 18:03:33 2025 +0900| [db25eb352aeb898ede31b2bae1fa276372cac17e] | committer: Michael Niedermayer configure: update copyright year On 01/01/2025 19:05, Peter Ross wrote: > FFmpeg turns 25 this year. (cherry picked from commit d3aa99a4f436e89773246339d9d363587a1d21df) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db25eb352aeb898ede31b2bae1fa276372cac17e --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 6c843ad682..61a9b20f0e 100755 --- a/configure +++ b/configure @@ -7518,7 +7518,7 @@ cat > $TMPH
[FFmpeg-cvslog] Update for 4.3.9
ffmpeg | branch: release/4.3 | Michael Niedermayer | Tue Mar 11 19:12:05 2025 +0100| [fe01189b0afd31d4888caf1043d52d49827ce7e1] | committer: Michael Niedermayer Update for 4.3.9 Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fe01189b0afd31d4888caf1043d52d49827ce7e1 --- Changelog| 105 +++ RELEASE | 2 +- doc/Doxyfile | 2 +- 3 files changed, 107 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index f777b9d779..763e394fd4 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,111 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version 4.3.9: + configure: update copyright year + avformat/hls: Partially revert "reduce default max reload to 3" + avformat/hls: Fix twitter + libavformat/hls: Be more restrictive on mpegts extensions + avformat/hls: .ts is always ok even if its a mov/mp4 + avformat/hls: Print input format in error message + avformat/hls: Be more picky on extensions + avformat: add ff_match_url_ext() + avfilter/bwdif: account for chroma sub-sampling in min size calculation + avformat/iff: Check that we have a stream in read_dst_frame() + avformat/mlvdec: fix size checks + avformat/mxfdec: Check edit unit for overflow in mxf_set_current_edit_unit() + avcodec/h263dec: Check against previous dimensions instead of coded + avformat/mxfdec: Check avio_read() success in mxf_decrypt_triplet() + avcodec/huffyuvdec: Initialize whole output for decode_gray_bitstream() + avformat/ipmovie: Check signature_buffer read + avformat/wtvdec: Initialize buf + avcodec/cbs_vp9: Initialize VP9RawSuperframeIndex + avformat/vqf: Propagate errors from add_metadata() + avformat/vqf: Check avio_read() in add_metadata() + avformat/dashdec: Check whitelist + avutil/avstring: dont mess with NULL pointers in av_match_list() + avcodec/mpegvideo_enc: Check FLV1 resolution limits + avcodec/ffv1enc: Fix handling of 32bit unsigned symbols + avcodec/vc1dec: Clear block_index in vc1_decode_reset() + avcodec/aacsbr_template: Clear n_q on error + swscale/output: Fix undefined overflow in yuv2rgba64_full_X_c_template() + avfilter/af_pan: Fix sscanf() use + avfilter/vf_addroi: Add missing NULL termination to addroi_var_names[]() + avformat/rmdec: check that buf if completely filled + avcodec/hapdec: Clear tex buffer + avformat/mxfdec: Check that key was read sucessfull + avformat/rpl: Fix check for negative values + avformat/mlvdec: Check avio_read() + avcodec/utils: Fix block align overflow for ADPCM_IMA_WAV + avformat/matroskadec: Check pre_ns for overflow + avcodec/webp: Check ref_x/y + avcodec/ilbcdec: Initialize tempbuff2 + avformat/dxa: check bpc + swscale/slice: clear allocated memory in alloc_lines() + avformat/icodec: fix integer overflow with nb_pal + doc/developer: Document relationship between git accounts and MAINTAINERS + avformat/vividas: Check avio_read() for failure + avformat/ilbc: Check avio_read() for failure + avformat/nistspheredec: Clear buffer + INSTALL: explain the circular dependency issue and solution + avformat/mpegts: Initialize predefined_SLConfigDescriptor_seen + avformat/mxfdec: Fix overflow in midpoint computation + swscale/output: used unsigned for bit accumulation + avcodec/rangecoder: only perform renorm check/loop for callers that need it + avcodec/ffv1dec: Fix end computation with ec=2 + avcodec/ffv1enc: Prevent generation of files with broken slices + avformat/matroskadec: Check desc_bytes so bits fit in 64bit + avcodec/ffv1enc: Correct error message about unsupported version + avcodec/ffv1enc: Slice combination is unsupported + avcodec/ffv1enc: 2Pass mode is not possible with golomb coding + avcodec/ffv1enc: Fix >8bit context size + avcodec/xan: Add basic input size check + avcodec/svq3: Check for minimum size input + avcodec/eacmv: Check input size for intra frames + avcodec/jfdctint_template: use unsigned z* in row_fdct() + avformat/mxfdec: Check timecode for overflow + avformat/mxfdec: More offset_temp checks + swscale/output: Fix undefined integer overflow in yuv2rgba64_2_c_template() + swscale/swscale: Use unsigned operation to avoid undefined behavior + avcodec/vc2enc: basic sanity check on slice_max_bytes + avformat/mvdec: Check if name was fully read + avcodec/wmavoice: Do not use uninitialized pitch[0] + avcodec/notchlc: Check bytes left before reading + avcodec/vc1_block: propagate error codes + avformat/apetag: Check APETAGEX + avcodec/avcodec: Warn about data returned from get_buffer*() + avcodec/aic: Clear slice_data + avcodec/vc1dec: Clear mb_type_base and ttblk_base + avcodec/shorten: clear padding + avformat/mpeg: Check an avio_read() for failure + avcodec/mvha: Clear remaining space after inflate() + avformat/segafilm: Set keyframe + avcodec/dxva2: initialize hr in ff_dxva2_common_end_frame() + avcodec/dxva2: initialize validate + avcodec/dxva2: Initialize Config
[FFmpeg-cvslog] avformat/hls: Partially revert "reduce default max reload to 3"
ffmpeg | branch: release/4.3 | softworkz | Thu Feb 27 16:36:56 2025 +| [69a69741165d506ff61be0d29758c738a01dbb12] | committer: Michael Niedermayer avformat/hls: Partially revert "reduce default max reload to 3" (setting to 100 as a reasonable compromise) The change has caused regressions for many users and consumers. Playlist reloads only happen when a playlist doesn't indicate that it has ended (via #EXT-X-ENDLIST), which means that the addition of future segments is still expected. It is well possible that an HLS server is temporarily unable to serve further segments but resumes after some time, either indicating a discontinuity or even by fully catching up. With a segment length of 3s, a max_reload value of 1000 corresponds to a duration of 50 minutes which appears to be a reasonable default. Signed-off-by: Michael Niedermayer (cherry picked from commit ace9f03a6c0a58b84a02701df1b6e5d5ac1d1b8e) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=69a69741165d506ff61be0d29758c738a01dbb12 --- libavformat/hls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 90a7a191d8..acfb382faa 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2433,7 +2433,7 @@ static const AVOption hls_options[] = { {"extension_picky", "Be picky with all extensions matching", OFFSET(extension_picky), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS}, {"max_reload", "Maximum number of times a insufficient list is attempted to be reloaded", -OFFSET(max_reload), AV_OPT_TYPE_INT, {.i64 = 3}, 0, INT_MAX, FLAGS}, +OFFSET(max_reload), AV_OPT_TYPE_INT, {.i64 = 100}, 0, INT_MAX, FLAGS}, {"m3u8_hold_counters", "The maximum number of times to load m3u8 when it refreshes without new segments", OFFSET(m3u8_hold_counters), AV_OPT_TYPE_INT, {.i64 = 1000}, 0, INT_MAX, FLAGS}, {"http_persistent", "Use persistent HTTP connections", ___ 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] swscale: aarch64: Simplify the assignment of lumToYV12
ffmpeg | branch: master | Martin Storsjö | Tue Mar 4 10:29:36 2025 +0200| [73f4668ef8167d90a1804c04a1537d21aedd29e4] | committer: Martin Storsjö swscale: aarch64: Simplify the assignment of lumToYV12 We normally don't need else statements here; the common pattern is to assign lower level SIMD implementations first, then conditionally reassign higher level ones afterwards, if supported. Signed-off-by: Martin Storsjö > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=73f4668ef8167d90a1804c04a1537d21aedd29e4 --- libswscale/aarch64/swscale.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index 18746b1b19..6e5a721c1f 100644 --- a/libswscale/aarch64/swscale.c +++ b/libswscale/aarch64/swscale.c @@ -300,13 +300,12 @@ av_cold void ff_sws_init_swscale_aarch64(SwsInternal *c) c->chrToYV12 = ff_bgr24ToUV_neon; break; case AV_PIX_FMT_BGRA: +c->lumToYV12 = ff_bgra32ToY_neon; #if HAVE_DOTPROD if (have_dotprod(cpu_flags)) { c->lumToYV12 = ff_bgra32ToY_neon_dotprod; } -else #endif -c->lumToYV12 = ff_bgra32ToY_neon; if (c->chrSrcHSubSample) c->chrToYV12 = ff_bgra32ToUV_half_neon; else @@ -320,13 +319,12 @@ av_cold void ff_sws_init_swscale_aarch64(SwsInternal *c) c->chrToYV12 = ff_rgb24ToUV_neon; break; case AV_PIX_FMT_RGBA: +c->lumToYV12 = ff_rgba32ToY_neon; #if HAVE_DOTPROD if (have_dotprod(cpu_flags)) { c->lumToYV12 = ff_rgba32ToY_neon_dotprod; } -else #endif -c->lumToYV12 = ff_rgba32ToY_neon; if (c->chrSrcHSubSample) c->chrToYV12 = ff_rgba32ToUV_half_neon; 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] all: Use put_bytes_output() instead of put_bits_ptr - pb->buf
ffmpeg | branch: master | Andreas Rheinhardt | Fri May 24 22:24:02 2024 +0200| [b98beb37044e9cecc6da7a6e01f36e120b98c4d9] | committer: Andreas Rheinhardt all: Use put_bytes_output() instead of put_bits_ptr - pb->buf Avoids accessing internals of PutBitContext. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b98beb37044e9cecc6da7a6e01f36e120b98c4d9 --- libavcodec/ljpegenc.c | 2 +- libavcodec/proresenc_anatoliy.c | 2 +- libavcodec/wmaenc.c | 2 +- libavformat/mpegenc.c | 4 ++-- libavformat/swfenc.c| 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 8162b5b611..ab37ab0d5c 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -252,7 +252,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, ff_mjpeg_encode_picture_trailer(&pb, header_bits); flush_put_bits(&pb); -pkt->size = put_bits_ptr(&pb) - pb.buf; +pkt->size = put_bytes_output(&pb); *got_packet = 1; return 0; diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index 0a1488dd69..fc69b94780 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -382,7 +382,7 @@ static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsig encode_acs(&pb, blocks, blocks_per_slice, qmat, scan); flush_put_bits(&pb); -return put_bits_ptr(&pb) - pb.buf; +return put_bytes_output(&pb); } static av_always_inline unsigned encode_slice_data(AVCodecContext *avctx, diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index dba90f993c..09435c1585 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -425,7 +425,7 @@ static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt, put_bits(&s->pb, 8, 'N'); flush_put_bits(&s->pb); -av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == avctx->block_align); +av_assert0(put_bytes_output(&s->pb) == avctx->block_align); if (frame->pts != AV_NOPTS_VALUE) avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding); diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 30a034a418..c41aa1095c 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -125,7 +125,7 @@ static int put_pack_header(AVFormatContext *ctx, uint8_t *buf, put_bits(&pb, 3, 0); /* stuffing length */ } flush_put_bits(&pb); -return put_bits_ptr(&pb) - pb.buf; +return put_bytes_output(&pb); } static int put_system_header(AVFormatContext *ctx, uint8_t *buf, @@ -270,7 +270,7 @@ static int put_system_header(AVFormatContext *ctx, uint8_t *buf, } flush_put_bits(&pb); -size = put_bits_ptr(&pb) - pb.buf; +size = put_bytes_output(&pb); /* patch packet size */ AV_WB16(buf + 4, size - 6); diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index d106e16d19..fc883b8023 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -124,7 +124,7 @@ static void put_swf_rect(AVIOContext *pb, put_bits(&p, nbits, ymax & mask); flush_put_bits(&p); -avio_write(pb, buf, put_bits_ptr(&p) - p.buf); +avio_write(pb, buf, put_bytes_output(&p)); } static void put_swf_line_edge(PutBitContext *pb, int dx, int dy) @@ -189,7 +189,7 @@ static void put_swf_matrix(AVIOContext *pb, put_bits(&p, nbits, ty); flush_put_bits(&p); -avio_write(pb, buf, put_bits_ptr(&p) - p.buf); +avio_write(pb, buf, put_bytes_output(&p)); } static int swf_write_header(AVFormatContext *s) @@ -323,7 +323,7 @@ static int swf_write_header(AVFormatContext *s) put_bits(&p, 5, 0); flush_put_bits(&p); -avio_write(pb, buf1, put_bits_ptr(&p) - p.buf); +avio_write(pb, buf1, put_bytes_output(&p)); put_swf_end_tag(s); } ___ 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] New commits on branch release/3.4
URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e6304a83a2012a8a49cc6ec059ff2703323a581b Author: Michael Niedermayer Date: Tue Mar 11 20:10:05 2025 +0100 Update for 3.4.14 Signed-off-by: Michael Niedermayer URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f8faa3ff142ccd210ed6bc6a17a1f0b67f4ec46 Author: Lynne Date: Wed Jan 1 18:03:33 2025 +0900 configure: update copyright year On 01/01/2025 19:05, Peter Ross wrote: > FFmpeg turns 25 this year. (cherry picked from commit d3aa99a4f436e89773246339d9d363587a1d21df) Signed-off-by: Michael Niedermayer URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e6ef90db6cf9e00dcbef21216641cd335bd2ecd6 Author: Cosmin Stejerean Date: Wed Dec 6 18:39:32 2023 +0800 avfilter/bwdif: account for chroma sub-sampling in min size calculation The current logic for detecting frames that are too small for the algorithm does not account for chroma sub-sampling, and so a sample where the luma plane is large enough, but the chroma planes are not will not be rejected. In that event, a heap overflow will occur. This change adjusts the logic to consider the chroma planes and makes the change to all three bwdif implementations. Fixes #10688 Signed-off-by: Cosmin Stejerean Reviewed-by: Thomas Mundt Signed-off-by: Philip Langdale (cherry picked from commit 737ede405b11a37fdd61d19cf25df296a0cb0b75) Signed-off-by: Michael Niedermayer URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dae907d55171f052e3e4a018e9868d09c9638d37 Author: Michael Niedermayer Date: Sun Feb 9 01:28:17 2025 +0100 avformat/iff: Check that we have a stream in read_dst_frame() Fixes: null pointer dereference Fixes: 385644864/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4551049565765632 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Peter Ross Signed-off-by: Michael Niedermayer (cherry picked from commit 8668957ef604bd2b99175310638bc5031ae0d991) Signed-off-by: Michael Niedermayer URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7dc39ecb8ff5ab53cccf2c9253ce06e8d2761a15 Author: Michael Niedermayer Date: Fri Feb 7 02:33:21 2025 +0100 avformat/mlvdec: fix size checks Fixes: heap-buffer-overflow Fixes: 391962476/clusterfuzz-testcase-minimized-ffmpeg_dem_MLV_fuzzer-5746746587676672 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit 251d43aef0df9262f2688c1c848af993bbb67d08) Signed-off-by: Michael Niedermayer URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c072bd7e1e4c656ec1953b455d717ae97a1f13e Author: Michael Niedermayer Date: Thu Jan 30 02:28:32 2025 +0100 avcodec/h263dec: Check against previous dimensions instead of coded Fixes: out of array access Fixes: crash-a41ef3db699013f669b076f02f36942925f5a98c Found-by: Kacper Michajlow Reviewed-by: Kacper Michajlow Signed-off-by: Michael Niedermayer (cherry picked from commit 0fe33c99a26a06a6875c4abfb96362a65145264b) Signed-off-by: Michael Niedermayer URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=17c4b50908a9bb3210ff2d55937bbbe603a7cd2b Author: Michael Niedermayer Date: Mon Sep 23 20:05:37 2024 +0200 avformat/mxfdec: Check avio_read() success in mxf_decrypt_triplet() Fixes: Use of uninitialized memory Fixes: 71444/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5448597561212928 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit 6ecc96f4d08d74b0590ab03f39f93f386910c4c0) Signed-off-by: Michael Niedermayer URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67249b7cbfc29094da60ce4c378974feb9856ca7 Author: Michael Niedermayer Date: Sat Nov 30 01:48:22 2024 +0100 avcodec/huffyuvdec: Initialize whole output for decode_gray_bitstream() Fixes: use of uninitialized memory Fixes: 375286238/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HYMT_fuzzer-6352546854141952 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit ef71552cf970876085d99834abdb8e429aea9730) Signed-off-by: Michael Niedermayer URL: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c32f218fbea96724ad7296b89eeb2e924f84a88 Author: Michael Niedermayer Date: Thu Dec 26 03:07:51 2024 +0100 avformat/ipmovie: Check signature_buffer read Fixes: use of uninitilaized data Fixes: 385167047/cl
[FFmpeg-cvslog] swscale/input: add support for YAF16 and YAF32
ffmpeg | branch: master | James Almer | Wed Mar 5 12:55:26 2025 -0300| [468577d1a52908519bb5af91cbe1430b5ae44d1e] | committer: James Almer swscale/input: add support for YAF16 and YAF32 Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=468577d1a52908519bb5af91cbe1430b5ae44d1e --- libswscale/input.c | 89 libswscale/utils.c | 4 +++ libswscale/version.h | 2 +- 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/libswscale/input.c b/libswscale/input.c index d6b319f25f..9633df5d19 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -1283,6 +1283,28 @@ static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, } } +static av_always_inline void read_yaf32_gray_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, + const uint8_t *unused2, int width, int is_be, uint32_t *unused) +{ +int i; +const float *src = (const float *)_src; +uint16_t *dst= (uint16_t *)_dst; + +for (i = 0; i < width; ++i) +dst[i] = lrintf(av_clipf(65535.0f * rdpx(src + i*2), 0.0f, 65535.0f)); +} + +static av_always_inline void read_yaf32_alpha_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, +const uint8_t *unused2, int width, int is_be, uint32_t *unused) +{ +int i; +const float *src = (const float *)_src; +uint16_t *dst= (uint16_t *)_dst; + +for (i = 0; i < width; ++i) +dst[i] = lrintf(av_clipf(65535.0f * rdpx(src + i*2 + 1), 0.0f, 65535.0f)); +} + #undef rdpx #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \ @@ -1363,6 +1385,18 @@ static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused, void *opq) \ { \ grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \ +} \ +static void read_yaf32##endian_name##_gray_c(uint8_t *dst, const uint8_t *src, \ + const uint8_t *unused1, const uint8_t *unused2, \ + int width, uint32_t *unused, void *opq) \ +{ \ +read_yaf32_gray_c(dst, src, unused1, unused2, width, endian, unused); \ +} \ +static void read_yaf32##endian_name##_alpha_c(uint8_t *dst, const uint8_t *src, \ + const uint8_t *unused1, const uint8_t *unused2, \ + int width, uint32_t *unused, void *opq) \ +{ \ +read_yaf32_alpha_c(dst, src, unused1, unused2, width, endian, unused); \ } rgbf32_funcs_endian(le, 0) @@ -1421,6 +1455,24 @@ static av_always_inline void grayf16ToY16_c(uint8_t *dst, const uint8_t *src, co } } +static av_always_inline void read_yaf16_gray_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, + const uint8_t *unused2, int width, int is_be, uint32_t *unused, Half2FloatTables *h2f_tbl) +{ +uint16_t *dst = (uint16_t *)_dst; + +for (int i = 0; i < width; i++) +dst[i] = lrintf(av_clipf(65535.0f * rdpx2(src + 4*i), 0.0f, 65535.0f)); +} + +static av_always_inline void read_yaf16_alpha_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, + const uint8_t *unused2, int width, int is_be, uint32_t *unused, Half2FloatTables *h2f_tbl) +{ +uint16_t *dst = (uint16_t *)_dst; + +for (int i = 0; i < width; i++) +dst[i] = lrintf(av_clipf(65535.0f * rdpx2(src + 4*i + 2), 0.0f, 65535.0f)); +} + static av_always_inline void rgbaf16ToUV_half_endian(uint16_t *dstU, uint16_t *dstV, int is_be, const uint16_t *src, int width, int32_t *rgb2yuv, Half2FloatTables *h2f_tbl) @@ -1557,6 +1609,19 @@ static void grayf16##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, { \ grayf16ToY16_c(dst, src, unused1, unused2, width, endian, unused, o
[FFmpeg-cvslog] avcodec/vc2enc: Use LUT to assemble interleaved golomb code
ffmpeg | branch: master | Andreas Rheinhardt | Wed Mar 12 03:26:09 2025 +0100| [b0af32265430d170458a8365bd1ad293644147c8] | committer: Andreas Rheinhardt avcodec/vc2enc: Use LUT to assemble interleaved golomb code Up until now, the encoder processed only one bit at a time. With this patch, it is eight bits. Reviewed-by: Lynne Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b0af32265430d170458a8365bd1ad293644147c8 --- libavcodec/vc2enc.c | 45 + 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index 4728a48938..1fe973f4cd 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -22,6 +22,7 @@ #include "libavutil/mem.h" #include "libavutil/pixdesc.h" #include "libavutil/opt.h" +#include "libavutil/thread.h" #include "libavutil/version.h" #include "codec_internal.h" #include "dirac.h" @@ -186,22 +187,39 @@ typedef struct VC2EncContext { enum DiracParseCodes last_parse_code; } VC2EncContext; +/// x_k x_{k-1} ... x_0 -> 0 x_k 0 x_{k - 1} ... 0 x_0 +static uint16_t interleaved_ue_golomb_tab[256]; +/// 1 x_{k-1} ... x_0 -> 0 0 0 x_{k - 1} ... 0 x_0 +static uint16_t top_interleaved_ue_golomb_tab[256]; +/// 1 x_{k-1} ... x_0 -> 2 * k +static uint8_t golomb_len_tab[256]; + +static av_cold void vc2_init_static_data(void) +{ +interleaved_ue_golomb_tab[1] = 1; +for (unsigned i = 2; i < 256; ++i) { +golomb_len_tab[i] = golomb_len_tab[i >> 1] + 2; +interleaved_ue_golomb_tab[i] = (interleaved_ue_golomb_tab[i >> 1] << 2) | (i & 1); +top_interleaved_ue_golomb_tab[i] = interleaved_ue_golomb_tab[i] ^ (1 << golomb_len_tab[i]); +} +} + static av_always_inline void put_vc2_ue_uint(PutBitContext *pb, uint32_t val) { -int i; -int bits = av_log2(++val); -unsigned topbit = 1 << bits; -uint64_t pbits = 0; - -for (i = 0; i < bits; i++) { -topbit >>= 1; -av_assert2(pbits <= UINT64_MAX>>3); -pbits <<= 2; -if (val & topbit) -pbits |= 0x1; +uint64_t pbits = 1; +int bits = 1; + +++val; + +while (val >> 8) { +pbits |= (uint64_t)interleaved_ue_golomb_tab[val & 0xff] << bits; +val >>= 8; +bits += 16; } +pbits |= (uint64_t)top_interleaved_ue_golomb_tab[val] << bits; +bits += golomb_len_tab[val]; -put_bits63(pb, 2 * bits + 1, (pbits << 1) | 1); +put_bits63(pb, bits, pbits); } static av_always_inline int count_vc2_ue_uint(uint32_t val) @@ -1003,6 +1021,7 @@ static av_cold int vc2_encode_end(AVCodecContext *avctx) static av_cold int vc2_encode_init(AVCodecContext *avctx) { +static AVOnce init_static_once = AV_ONCE_INIT; Plane *p; SubBand *b; int i, level, o, shift; @@ -1165,6 +1184,8 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx) } } +ff_thread_once(&init_static_once, vc2_init_static_data); + return 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/vc2enc: Simplify writing dirac golomb codes
ffmpeg | branch: master | Andreas Rheinhardt | Sat Mar 8 15:45:24 2025 +0100| [512e597932dfe05cf5665192efbe2c93c2e36af2] | committer: Andreas Rheinhardt avcodec/vc2enc: Simplify writing dirac golomb codes The earlier code used a loop to determine the number of bits used and called ff_log2() on a power of two (and it would be easy to keep track of the exponent of said power-of-two); neither GCC nor Clang optimized the loop away or avoided the ff_log2(). This patch replaces the loop and the log2 with a single av_log2(). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=512e597932dfe05cf5665192efbe2c93c2e36af2 --- libavcodec/vc2enc.c | 30 +++--- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index aa1ec40f3d..4611c3977b 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -189,23 +189,10 @@ typedef struct VC2EncContext { static av_always_inline void put_vc2_ue_uint(PutBitContext *pb, uint32_t val) { int i; -int bits = 0; -unsigned topbit = 1, maxval = 1; +int bits = av_log2(++val); +unsigned topbit = 1 << bits; uint64_t pbits = 0; -if (!val++) { -put_bits(pb, 1, 1); -return; -} - -while (val > maxval) { -topbit <<= 1; -maxval <<= 1; -maxval |= 1; -} - -bits = ff_log2(topbit); - for (i = 0; i < bits; i++) { topbit >>= 1; av_assert2(pbits <= UINT64_MAX>>3); @@ -219,18 +206,7 @@ static av_always_inline void put_vc2_ue_uint(PutBitContext *pb, uint32_t val) static av_always_inline int count_vc2_ue_uint(uint32_t val) { -int topbit = 1, maxval = 1; - -if (!val++) -return 1; - -while (val > maxval) { -topbit <<= 1; -maxval <<= 1; -maxval |= 1; -} - -return ff_log2(topbit)*2 + 1; +return 2 * av_log2(val + 1) + 1; } /* VC-2 10.4 - parse_info() */ ___ 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".