Go to the documentation of this file.
56 static const char bgr_chlist[4] = {
'B',
'G',
'R',
'A' };
120 switch (
s->compression) {
124 s->scanline_height = 1;
125 s->nb_scanlines = avctx->
height;
128 s->scanline_height = 16;
129 s->nb_scanlines = (avctx->
height +
s->scanline_height - 1) /
s->scanline_height;
135 s->scanline =
av_calloc(
s->nb_scanlines,
sizeof(*
s->scanline));
146 for (
int y = 0; y <
s->nb_scanlines &&
s->scanline; y++) {
161 const ptrdiff_t half_size = (
size + 1) / 2;
163 uint8_t *
t2 = dst + half_size;
165 for (ptrdiff_t
i = 0;
i < half_size;
i++) {
175 for (ptrdiff_t
i = 1;
i <
size;
i++) {
176 int d =
src[
i] - p + 384;
184 const uint8_t *in, int64_t in_size)
186 int64_t
i = 0, o = 0,
run = 1,
copy = 0;
188 while (
i < in_size) {
189 while (
i +
run < in_size && in[
i] == in[
i +
run] &&
run < 128)
199 if (
i +
run < in_size)
208 for (
int x = 0; x <
copy; x++)
209 out[o + x] = in[
i + x];
224 const int64_t element_size =
s->pixel_type ==
EXR_HALF ? 2LL : 4LL;
226 for (
int y = 0; y <
frame->height; y++) {
228 int64_t tmp_size = element_size *
s->planes *
frame->width;
229 int64_t max_compressed_size = tmp_size * 3 / 2;
243 switch (
s->pixel_type) {
245 for (
int p = 0; p <
s->planes; p++) {
246 int ch =
s->ch_order[p];
253 for (
int p = 0; p <
s->planes; p++) {
254 int ch =
s->ch_order[p];
256 uint32_t *
src = (uint32_t *)(
frame->data[ch] + y *
frame->linesize[ch]);
258 for (
int x = 0; x <
frame->width; x++)
268 scanline->
tmp, tmp_size);
282 const int64_t element_size =
s->pixel_type ==
EXR_HALF ? 2LL : 4LL;
284 for (
int y = 0; y <
s->nb_scanlines; y++) {
286 const int scanline_height =
FFMIN(
s->scanline_height,
frame->height - y *
s->scanline_height);
287 int64_t tmp_size = element_size *
s->planes *
frame->width * scanline_height;
288 int64_t max_compressed_size = tmp_size * 3 / 2;
289 unsigned long actual_size, source_size;
303 switch (
s->pixel_type) {
305 for (
int l = 0; l < scanline_height; l++) {
306 const int scanline_size =
frame->width * 4 *
s->planes;
308 for (
int p = 0; p <
s->planes; p++) {
309 int ch =
s->ch_order[p];
312 frame->data[ch] + (y *
s->scanline_height + l) *
frame->linesize[ch],
318 for (
int l = 0; l < scanline_height; l++) {
319 const int scanline_size =
frame->width * 2 *
s->planes;
321 for (
int p = 0; p <
s->planes; p++) {
322 int ch =
s->ch_order[p];
324 uint32_t *
src = (uint32_t *)(
frame->data[ch] + (y *
s->scanline_height + l) *
frame->linesize[ch]);
326 for (
int x = 0; x <
frame->width; x++)
335 source_size = tmp_size;
336 actual_size = max_compressed_size;
338 scanline->
tmp, source_size);
361 avctx->
height, 64) * 3LL / 2;
368 bytestream2_put_le32(pb, 20000630);
369 bytestream2_put_byte(pb, 2);
370 bytestream2_put_le24(pb, 0);
372 bytestream2_put_le32(pb,
s->planes * 18 + 1);
374 for (
int p = 0; p <
s->planes; p++) {
375 bytestream2_put_byte(pb,
s->ch_names[p]);
376 bytestream2_put_byte(pb, 0);
377 bytestream2_put_le32(pb,
s->pixel_type);
378 bytestream2_put_le32(pb, 0);
379 bytestream2_put_le32(pb, 1);
380 bytestream2_put_le32(pb, 1);
382 bytestream2_put_byte(pb, 0);
385 bytestream2_put_le32(pb, 1);
386 bytestream2_put_byte(pb,
s->compression);
389 bytestream2_put_le32(pb, 16);
390 bytestream2_put_le32(pb, 0);
391 bytestream2_put_le32(pb, 0);
392 bytestream2_put_le32(pb, avctx->
width - 1);
393 bytestream2_put_le32(pb, avctx->
height - 1);
396 bytestream2_put_le32(pb, 16);
397 bytestream2_put_le32(pb, 0);
398 bytestream2_put_le32(pb, 0);
399 bytestream2_put_le32(pb, avctx->
width - 1);
400 bytestream2_put_le32(pb, avctx->
height - 1);
403 bytestream2_put_le32(pb, 1);
404 bytestream2_put_byte(pb, 0);
407 bytestream2_put_le32(pb, 8);
408 bytestream2_put_le64(pb, 0);
411 bytestream2_put_le32(pb, 4);
416 bytestream2_put_le32(pb, 4);
422 bytestream2_put_le32(pb, 8);
428 bytestream2_put_le32(pb, 4);
432 bytestream2_put_le32(pb, 4);
434 bytestream2_put_byte(pb, 0);
436 switch (
s->compression) {
451 switch (
s->compression) {
457 for (
int y = 0; y < avctx->
height; y++) {
458 bytestream2_put_le64(pb,
offset);
462 for (
int y = 0; y < avctx->
height; y++) {
463 bytestream2_put_le32(pb, y);
464 bytestream2_put_le32(pb,
s->planes * avctx->
width * 4);
465 for (
int p = 0; p <
s->planes; p++) {
466 int ch =
s->ch_order[p];
472 for (
int y = 0; y < avctx->
height; y++) {
473 bytestream2_put_le64(pb,
offset);
477 for (
int y = 0; y < avctx->
height; y++) {
478 bytestream2_put_le32(pb, y);
479 bytestream2_put_le32(pb,
s->planes * avctx->
width * 2);
480 for (
int p = 0; p <
s->planes; p++) {
481 int ch =
s->ch_order[p];
482 uint32_t *
src = (uint32_t *)(
frame->data[ch] + y *
frame->linesize[ch]);
484 for (
int x = 0; x <
frame->width; x++)
485 bytestream2_put_le16(pb,
float2half(
src[x],
s->basetable,
s->shifttable));
495 for (
int y = 0; y <
s->nb_scanlines; y++) {
498 bytestream2_put_le64(pb,
offset);
502 for (
int y = 0; y <
s->nb_scanlines; y++) {
505 bytestream2_put_le32(pb, y *
s->scanline_height);
522 #define OFFSET(x) offsetof(EXRContext, x)
523 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
AVPixelFormat
Pixel format.
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
This structure describes decoded (raw) audio or video data.
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
static const uint8_t gbra_order[4]
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
static const AVClass exr_class
AVCodec p
The public AVCodec.
uint8_t * uncompressed_data
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
static const char abgr_chlist[4]
#define FF_CODEC_ENCODE_CB(func)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
static const uint8_t gbr_order[4]
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
EXRScanlineData * scanline
#define AV_PIX_FMT_GRAYF32
static const char bgr_chlist[4]
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define LIBAVUTIL_VERSION_INT
static int64_t rle_compress(uint8_t *out, int64_t out_size, const uint8_t *in, int64_t in_size)
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
static uint16_t float2half(uint32_t f, uint16_t *basetable, uint8_t *shifttable)
static int encode_scanline_zip(EXRContext *s, const AVFrame *frame)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static void copy(const float *p1, float *p2, const int length)
#define AV_PIX_FMT_GBRPF32
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters.
const FFCodec ff_exr_encoder
static av_cold int encode_init(AVCodecContext *avctx)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static void predictor(uint8_t *src, ptrdiff_t size)
static const uint8_t y_order[4]
uint8_t * compressed_data
static av_cold int encode_close(AVCodecContext *avctx)
unsigned int compressed_size
unsigned int uncompressed_size
#define i(width, name, range_min, range_max)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void * av_calloc(size_t nmemb, size_t size)
static void float2half_tables(uint16_t *basetable, uint8_t *shifttable)
static const AVOption options[]
static int encode_scanline_rle(EXRContext *s, const AVFrame *frame)
#define FFSWAP(type, a, b)
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
static void reorder_pixels(uint8_t *dst, const uint8_t *src, ptrdiff_t size)
main external API structure.
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
#define AV_PIX_FMT_GBRAPF32
static const char y_chlist[4]
This structure stores compressed data.
int width
picture width / height.
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.