26#include <SvtJpegxsDec.h>
49static int set_pix_fmt(
void *logctx,
const svt_jpeg_xs_image_config_t *config)
53 switch (config->format) {
54 case COLOUR_FORMAT_PLANAR_YUV420:
55 if (config->bit_depth == 8)
57 else if (config->bit_depth == 10)
59 else if (config->bit_depth == 12)
64 case COLOUR_FORMAT_PLANAR_YUV422:
65 if (config->bit_depth == 8)
67 else if (config->bit_depth == 10)
69 else if (config->bit_depth == 12)
74 case COLOUR_FORMAT_PLANAR_YUV444_OR_RGB:
75 if (config->bit_depth == 8)
77 else if (config->bit_depth == 10)
79 else if (config->bit_depth == 12)
96 SvtJxsErrorType_t err = SvtJxsErrorNone;
100 err = svt_jpeg_xs_decoder_get_single_frame_size_with_proxy(
103 av_log(avctx,
AV_LOG_ERROR,
"svt_jpeg_xs_decoder_get_single_frame_size_with_proxy failed, err=%d\n", err);
122 svt_jpeg_xs_decoder_close(&svt_dec->
decoder);
123 err = svt_jpeg_xs_decoder_init(SVT_JPEGXS_API_VER_MAJOR, SVT_JPEGXS_API_VER_MINOR,
144 svt_dec->
input.bitstream.buffer = avpkt->
data;
145 svt_dec->
input.bitstream.allocation_size = avpkt->
size;
146 svt_dec->
input.bitstream.used_size = avpkt->
size;
147 svt_dec->
input.user_prv_ctx_ptr = avpkt;
153 unsigned pixel_shift = svt_dec->
config.bit_depth <= 8 ? 0 : 1;
160 err = svt_jpeg_xs_decoder_send_frame(&svt_dec->
decoder, &svt_dec->
input, 1 );
166 err = svt_jpeg_xs_decoder_get_frame(&svt_dec->
decoder, &svt_dec->
output, 1 );
172 if (svt_dec->
output.user_prv_ctx_ptr != avpkt) {
186 svt_jpeg_xs_decoder_close(&svt_dec->
decoder);
197 log_level ==
AV_LOG_DEBUG ? VERBOSE_SYSTEM_INFO : VERBOSE_WARNINGS;
200 svt_dec->
decoder.proxy_mode = proxy_mode_half;
201 else if (avctx->
lowres == 2)
202 svt_dec->
decoder.proxy_mode = proxy_mode_quarter;
204 svt_dec->
decoder.proxy_mode = proxy_mode_full;
208 svt_dec->
decoder.use_cpu_flags = CPU_FLAGS_ALL;
214 .p.name =
"libsvtjpegxs",
215 CODEC_LONG_NAME(
"SVT JPEG XS(Scalable Video Technology for JPEG XS) decoder"),
227 .p.wrapper_name =
"libsvtjpegxs",
const FFCodec ff_libsvtjpegxs_decoder
static av_cold void close(AVCodecParserContext *s)
simple assert() macros that are a bit more flexible than ISO C assert().
Libavcodec external API header.
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
int(* init)(AVBSFContext *ctx)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
static const uint8_t frame_size[4]
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AVDISCARD_ALL
discard all
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_log_get_level(void)
Get the current log level.
static av_cold int svt_jpegxs_dec_free(AVCodecContext *avctx)
static int svt_jpegxs_dec_decode(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
static int set_pix_fmt(void *logctx, const svt_jpeg_xs_image_config_t *config)
static av_cold int svt_jpegxs_dec_init(AVCodecContext *avctx)
Memory handling functions.
@ AV_PIX_FMT_YUV420P14LE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV444P14LE
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUV422P14LE
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
enum AVDiscard skip_frame
Skip decoding for selected frames.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
This structure stores compressed data.
svt_jpeg_xs_frame_t output
svt_jpeg_xs_frame_t input
svt_jpeg_xs_decoder_api_t decoder
uint32_t decoder_initialized
svt_jpeg_xs_image_config_t config