FFmpeg
|
#include <string.h>
#include "libavutil/avutil.h"
#include "libavutil/csp.h"
#include "libavutil/error.h"
#include "libavutil/frame.h"
#include "libavutil/libm.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixfmt.h"
#include "libavutil/version.h"
#include "avcodec.h"
#include "encode.h"
#include "codec_internal.h"
#include <jxl/encode.h>
#include <jxl/thread_parallel_runner.h>
#include "libjxl.h"
Go to the source code of this file.
Data Structures | |
struct | LibJxlEncodeContext |
Macros | |
#define | OFFSET(x) offsetof(LibJxlEncodeContext, x) |
#define | VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
Functions | |
static float | quality_to_distance (float quality) |
Map a quality setting for -qscale roughly from libjpeg quality numbers to libjxl's butteraugli distance for photographic content. More... | |
static int | libjxl_init_jxl_encoder (AVCodecContext *avctx) |
Initalize the encoder on a per-file basis. More... | |
static av_cold int | libjxl_encode_init (AVCodecContext *avctx) |
Global encoder initialization. More... | |
static av_cold int | libjxl_anim_encode_init (AVCodecContext *avctx) |
Initializer for the animation encoder. More... | |
static int | libjxl_populate_primaries (void *avctx, JxlColorEncoding *jxl_color, enum AVColorPrimaries prm) |
Populate a JxlColorEncoding with the given enum AVColorPrimaries. More... | |
static int | libjxl_preprocess_stream (AVCodecContext *avctx, const AVFrame *frame, int animated) |
Sends metadata to libjxl based on the first frame of the stream, such as pixel format, orientation, bit depth, and that sort of thing. More... | |
static int | libjxl_preprocess_frame (AVCodecContext *avctx, const AVFrame *frame, const uint8_t **data) |
Sends frame information to libjxl on a per-frame basis. More... | |
static int | libjxl_process_output (AVCodecContext *avctx, size_t *bytes_written) |
Run libjxl's output processing loop, reallocating the packet as necessary if libjxl needs more space to work with. More... | |
static int | libjxl_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) |
Encode an entire frame. More... | |
static int | libjxl_anim_encode_frame (AVCodecContext *avctx, AVPacket *pkt) |
Encode one frame of the animation. More... | |
static av_cold int | libjxl_encode_close (AVCodecContext *avctx) |
Variables | |
static const AVOption | libjxl_encode_options [] |
static const AVClass | libjxl_encode_class |
static enum AVPixelFormat | libjxl_supported_pixfmts [] |
const FFCodec | ff_libjxl_encoder |
const FFCodec | ff_libjxl_anim_encoder |
JPEG XL encoder using libjxl
Definition in file libjxlenc.c.
#define OFFSET | ( | x | ) | offsetof(LibJxlEncodeContext, x) |
Definition at line 657 of file libjxlenc.c.
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
Definition at line 658 of file libjxlenc.c.
Map a quality setting for -qscale roughly from libjpeg quality numbers to libjxl's butteraugli distance for photographic content.
Setting distance explicitly is preferred, but this will allow qscale to be used as a fallback.
This function is continuous and injective on [0, 100] which makes it monotonic.
quality | 0.0 to 100.0 quality setting, libjpeg quality |
Definition at line 81 of file libjxlenc.c.
Referenced by libjxl_encode_init().
|
static |
Initalize the encoder on a per-file basis.
All of these need to be set once each time the encoder is reset, which is each frame for still images, to make the image2 muxer work. For animation this is run once.
Definition at line 102 of file libjxlenc.c.
Referenced by libjxl_anim_encode_init(), and libjxl_encode_frame().
|
static |
Global encoder initialization.
This only needs to be run once, not every frame.
Definition at line 129 of file libjxlenc.c.
Referenced by libjxl_anim_encode_init().
|
static |
Initializer for the animation encoder.
This calls the other initializers to prevent code duplication and also allocates the prev-frame used in the encoder.
Definition at line 179 of file libjxlenc.c.
|
static |
Populate a JxlColorEncoding with the given enum AVColorPrimaries.
Definition at line 203 of file libjxlenc.c.
Referenced by libjxl_preprocess_stream().
|
static |
Sends metadata to libjxl based on the first frame of the stream, such as pixel format, orientation, bit depth, and that sort of thing.
Definition at line 254 of file libjxlenc.c.
Referenced by libjxl_anim_encode_frame(), and libjxl_encode_frame().
|
static |
Sends frame information to libjxl on a per-frame basis.
If this is a still image, this is evaluated once per output file. If this is an animated JPEG XL encode, it is called once per frame.
This returns a buffer to the data that should be passed to libjxl (via the argument **data). If the linesize is nonnegative, this will be frame->data[0], although if the linesize is negative, it will be the start of the buffer instead. *data is just a pointer to a location in frame->data so it should not be freed directly.
Definition at line 410 of file libjxlenc.c.
Referenced by libjxl_anim_encode_frame(), and libjxl_encode_frame().
|
static |
Run libjxl's output processing loop, reallocating the packet as necessary if libjxl needs more space to work with.
Definition at line 454 of file libjxlenc.c.
Referenced by libjxl_anim_encode_frame(), and libjxl_encode_frame().
|
static |
Encode an entire frame.
This will always reinitialize a new still image and encode a one-frame image (for image2 and image2pipe).
Definition at line 499 of file libjxlenc.c.
|
static |
Encode one frame of the animation.
libjxl requires us to set duration of the frame but we're only promised the PTS, not the duration. As a result we have to buffer a frame and subtract the PTS from the last PTS. The last frame uses the previous frame's calculated duration as a fallback if its duration field is unset.
We also need to tell libjxl if our frame is the last one, which we won't know upon receiving a single frame, so we have to buffer a frame as well and send the "last frame" upon receiving the special EOF frame.
Definition at line 556 of file libjxlenc.c.
|
static |
Definition at line 634 of file libjxlenc.c.
|
static |
Definition at line 660 of file libjxlenc.c.
|
static |
Definition at line 670 of file libjxlenc.c.
|
static |
Definition at line 677 of file libjxlenc.c.
const FFCodec ff_libjxl_encoder |
Definition at line 687 of file libjxlenc.c.
const FFCodec ff_libjxl_anim_encoder |
Definition at line 707 of file libjxlenc.c.