Go to the documentation of this file.
26 #include <SvtJpegxsEnc.h>
58 svt_jpeg_xs_frame_t enc_input;
59 svt_jpeg_xs_bitstream_buffer_t *
const out_buf = &enc_input.bitstream;
60 svt_jpeg_xs_image_buffer_t *
const in_buf = &enc_input.image;
61 svt_jpeg_xs_frame_t enc_output;
63 SvtJxsErrorType_t err = SvtJxsErrorNone;
70 out_buf->allocation_size =
pkt->
size;
71 out_buf->used_size = 0;
73 unsigned pixel_shift = svt_enc->
encoder.input_bit_depth <= 8 ? 0 : 1;
81 enc_input.user_prv_ctx_ptr =
pkt;
83 err = svt_jpeg_xs_encoder_send_picture(&svt_enc->
encoder, &enc_input, 1 );
84 if (err != SvtJxsErrorNone) {
89 err = svt_jpeg_xs_encoder_get_packet(&svt_enc->
encoder, &enc_output, 1 );
90 if (err != SvtJxsErrorNone) {
95 if (enc_output.user_prv_ctx_ptr !=
pkt) {
100 pkt->
size = enc_output.bitstream.used_size;
110 svt_jpeg_xs_encoder_close(&svt_enc->
encoder);
119 encoder->input_bit_depth = 8;
120 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV420;
123 encoder->input_bit_depth = 8;
124 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV422;
127 encoder->input_bit_depth = 8;
128 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB;
131 encoder->input_bit_depth = 10;
132 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV420;
135 encoder->input_bit_depth = 10;
136 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV422;
139 encoder->input_bit_depth = 10;
140 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB;
143 encoder->input_bit_depth = 12;
144 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV420;
147 encoder->input_bit_depth = 12;
148 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV422;
151 encoder->input_bit_depth = 12;
152 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB;
155 encoder->input_bit_depth = 14;
156 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV420;
159 encoder->input_bit_depth = 14;
160 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV422;
163 encoder->input_bit_depth = 14;
164 encoder->colour_format = COLOUR_FORMAT_PLANAR_YUV444_OR_RGB;
175 SvtJxsErrorType_t err;
177 err = svt_jpeg_xs_encoder_load_default_parameters(SVT_JPEGXS_API_VER_MAJOR, SVT_JPEGXS_API_VER_MINOR, &(svt_enc->
encoder));
178 if (err != SvtJxsErrorNone) {
193 log_level ==
AV_LOG_DEBUG ? VERBOSE_SYSTEM_INFO : VERBOSE_WARNINGS;
216 if (svt_enc->
quant >= 0)
227 err = svt_jpeg_xs_encoder_init(SVT_JPEGXS_API_VER_MAJOR, SVT_JPEGXS_API_VER_MINOR, &svt_enc->
encoder);
228 if (err != SvtJxsErrorNone) {
234 svt_enc->
encoder.bpp_numerator / svt_enc->
encoder.bpp_denominator + 7) / 8);
260 #define OFFSET(x) offsetof(SvtJpegXsEncodeContext, x)
261 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
268 {
"coding-signs",
"Enable Signs handling strategy",
OFFSET(coding_signs_handling),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 2,
VE, .unit =
"coding-signs" },
272 {
"coding-sigf",
"Enable Significance coding",
OFFSET(coding_significance),
AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1,
VE },
273 {
"coding-vpred",
"Enable Vertical Prediction coding",
OFFSET(coding_vpred),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 2,
VE, .unit =
"coding-vpred" },
288 .
p.
name =
"libsvtjpegxs",
289 CODEC_LONG_NAME(
"SVT JPEG XS(Scalable Video Technology for JPEG XS) encoder"),
301 .p.wrapper_name =
"libsvtjpegxs",
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVClass svtjpegxs_enc_class
AVPixelFormat
Pixel format.
static const FFCodecDefault svt_jpegxs_defaults[]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static const FFCodecDefault defaults[]
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AV_PIX_FMT_YUV422P14LE
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
This structure describes decoded (raw) audio or video data.
static av_cold int svt_jpegxs_enc_free(AVCodecContext *avctx)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
static int svt_jpegxs_enc_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
static av_cold void close(AVCodecParserContext *s)
AVCodec p
The public AVCodec.
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
#define FF_CODEC_ENCODE_CB(func)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_YUV444P14LE
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
static const uint8_t quant[64]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
svt_jpeg_xs_encoder_api_t encoder
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int av_log_get_level(void)
Get the current log level.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
#define CODEC_PIXFMTS_ARRAY(array)
Rational number (pair of numerator and denominator).
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
int64_t bit_rate
the average bitrate
const char * av_default_item_name(void *ptr)
Return the context name.
static const AVOption svtjpegxs_enc_options[]
@ AV_PIX_FMT_YUV420P14LE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
static av_cold int svt_jpegxs_enc_init(AVCodecContext *avctx)
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
#define AVERROR_EXTERNAL
Generic error in an external library.
static enum AVPixelFormat pix_fmts[]
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
main external API structure.
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static void set_pix_fmt(AVCodecContext *avctx, svt_jpeg_xs_encoder_api_t *encoder)
int coding_signs_handling
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int slices
Number of slices.
This structure stores compressed data.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
int width
picture width / height.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
const FFCodec ff_libsvtjpegxs_encoder