From 36a02caa1913722193cfc5cfaa4e7b705c3669d4 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 25 Feb 2026 11:36:48 +0100 Subject: [PATCH] vdec/jpegxs: more tolerant to errors although we do not accept corrupt frames, if we decide to switch to or an error occurs for whatever reason, handle it better: - probe - do not abort - actual decode - return the buffer to the pool --- src/video_decompress.h | 4 ++-- src/video_decompress/jpegxs.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video_decompress.h b/src/video_decompress.h index 344859a5d..582e6b212 100644 --- a/src/video_decompress.h +++ b/src/video_decompress.h @@ -6,7 +6,7 @@ * @brief API for video decompress drivers */ /* - * Copyright (c) 2011-2025 CESNET + * Copyright (c) 2011-2026 CESNET, zájmové sdružení právnických osob * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -88,7 +88,7 @@ typedef int (*decompress_reconfigure_t)(void * state, struct video_desc desc, int rshift, int gshift, int bshift, int pitch, codec_t out_codec); typedef enum { - DECODER_NO_FRAME = 0, //Frame not decoded yet + DECODER_NO_FRAME = 0, ///< Frame not decoded (yet?) DECODER_GOT_FRAME, //Frame decoded and written to destination DECODER_GOT_CODEC, ///< Internal pixel format was determined DECODER_UNSUPP_PIXFMT, ///< Decoder can't decode to selected out_codec diff --git a/src/video_decompress/jpegxs.cpp b/src/video_decompress/jpegxs.cpp index 56dd14904..655b94d6d 100644 --- a/src/video_decompress/jpegxs.cpp +++ b/src/video_decompress/jpegxs.cpp @@ -153,7 +153,7 @@ static decompress_status jpegxs_probe_internal_codec(struct state_decompress_jpe SvtJxsErrorType_t err = svt_jpeg_xs_decoder_get_single_frame_size(buffer, buffer_size, &s->image_config, &size, 0); if (err != SvtJxsErrorNone) { log_msg(LOG_LEVEL_ERROR, MOD_NAME "Failed to get frame size from bitstream, error code: %x\n", err); - abort(); + return DECODER_NO_FRAME; } assert(buffer_size == size); @@ -219,6 +219,7 @@ static decompress_status jpegxs_decompress(void *state, unsigned char *dst, unsi svt_jpeg_xs_frame_t dec_output; err = svt_jpeg_xs_decoder_get_frame(&s->decoder, &dec_output, 1 /*blocking*/); if (err != SvtJxsErrorNone) { + svt_jpeg_xs_frame_pool_release(s->frame_pool, &dec_output); log_msg(LOG_LEVEL_ERROR, MOD_NAME "Failed to get encoded packet, error code: %x\n", err); return DECODER_NO_FRAME; }