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
This commit is contained in:
Martin Pulec
2026-02-25 11:36:48 +01:00
parent 2b24d37433
commit 36a02caa19
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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;
}