FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
exrenc.c File Reference
#include <float.h>
#include <zlib.h>
#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bytestream.h"
#include "encode.h"
#include "internal.h"
#include "float2half.h"

Go to the source code of this file.

Data Structures

struct  EXRScanlineData
 
struct  EXRContext
 

Macros

#define OFFSET(x)   offsetof(EXRContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  ExrCompr {
  EXR_RAW, EXR_RLE, EXR_ZIP1, EXR_ZIP16,
  EXR_PIZ, EXR_PXR24, EXR_B44, EXR_B44A,
  EXR_DWAA, EXR_DWAB, EXR_UNKN, EXR_RAW,
  EXR_RLE, EXR_ZIP1, EXR_ZIP16, EXR_NBCOMPR
}
 
enum  ExrPixelType {
  EXR_UINT, EXR_HALF, EXR_FLOAT, EXR_UNKNOWN,
  EXR_UINT, EXR_HALF, EXR_FLOAT, EXR_UNKNOWN
}
 

Functions

static int encode_init (AVCodecContext *avctx)
 
static int encode_close (AVCodecContext *avctx)
 
static void reorder_pixels (uint8_t *dst, const uint8_t *src, ptrdiff_t size)
 
static void predictor (uint8_t *src, ptrdiff_t size)
 
static int64_t rle_compress (uint8_t *out, int64_t out_size, const uint8_t *in, int64_t in_size)
 
static int encode_scanline_rle (EXRContext *s, const AVFrame *frame)
 
static int encode_scanline_zip (EXRContext *s, const AVFrame *frame)
 
static int encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 

Variables

static const char abgr_chlist [4] = { 'A', 'B', 'G', 'R' }
 
static const char bgr_chlist [4] = { 'B', 'G', 'R', 'A' }
 
static const uint8_t gbra_order [4] = { 3, 1, 0, 2 }
 
static const uint8_t gbr_order [4] = { 1, 0, 2, 0 }
 
static const AVOption options []
 
static const AVClass exr_class
 
const AVCodec ff_exr_encoder
 

Detailed Description

OpenEXR encoder

Definition in file exrenc.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(EXRContext, x)

Definition at line 515 of file exrenc.c.

◆ VE

Definition at line 516 of file exrenc.c.

Enumeration Type Documentation

◆ ExrCompr

enum ExrCompr
Enumerator
EXR_RAW 
EXR_RLE 
EXR_ZIP1 
EXR_ZIP16 
EXR_PIZ 
EXR_PXR24 
EXR_B44 
EXR_B44A 
EXR_DWAA 
EXR_DWAB 
EXR_UNKN 
EXR_RAW 
EXR_RLE 
EXR_ZIP1 
EXR_ZIP16 
EXR_NBCOMPR 

Definition at line 40 of file exrenc.c.

◆ ExrPixelType

Enumerator
EXR_UINT 
EXR_HALF 
EXR_FLOAT 
EXR_UNKNOWN 
EXR_UINT 
EXR_HALF 
EXR_FLOAT 
EXR_UNKNOWN 

Definition at line 48 of file exrenc.c.

Function Documentation

◆ encode_init()

static int encode_init ( AVCodecContext avctx)
static

Definition at line 92 of file exrenc.c.

◆ encode_close()

static int encode_close ( AVCodecContext avctx)
static

Definition at line 135 of file exrenc.c.

◆ reorder_pixels()

static void reorder_pixels ( uint8_t *  dst,
const uint8_t *  src,
ptrdiff_t  size 
)
static

Definition at line 152 of file exrenc.c.

Referenced by encode_scanline_rle(), and encode_scanline_zip().

◆ predictor()

static void predictor ( uint8_t *  src,
ptrdiff_t  size 
)
static

◆ rle_compress()

static int64_t rle_compress ( uint8_t *  out,
int64_t  out_size,
const uint8_t *  in,
int64_t  in_size 
)
static

Definition at line 176 of file exrenc.c.

Referenced by encode_scanline_rle().

◆ encode_scanline_rle()

static int encode_scanline_rle ( EXRContext s,
const AVFrame frame 
)
static

Definition at line 215 of file exrenc.c.

Referenced by encode_frame().

◆ encode_scanline_zip()

static int encode_scanline_zip ( EXRContext s,
const AVFrame frame 
)
static

Definition at line 273 of file exrenc.c.

Referenced by encode_frame().

◆ encode_frame()

static int encode_frame ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame frame,
int got_packet 
)
static

Definition at line 344 of file exrenc.c.

Variable Documentation

◆ abgr_chlist

const char abgr_chlist[4] = { 'A', 'B', 'G', 'R' }
static

Definition at line 55 of file exrenc.c.

Referenced by encode_init().

◆ bgr_chlist

const char bgr_chlist[4] = { 'B', 'G', 'R', 'A' }
static

Definition at line 56 of file exrenc.c.

Referenced by encode_init().

◆ gbra_order

const uint8_t gbra_order[4] = { 3, 1, 0, 2 }
static

Definition at line 57 of file exrenc.c.

Referenced by encode_init().

◆ gbr_order

const uint8_t gbr_order[4] = { 1, 0, 2, 0 }
static

Definition at line 58 of file exrenc.c.

Referenced by encode_init().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "compression", "set compression type", OFFSET(compression), AV_OPT_TYPE_INT, {.i64=0}, 0, EXR_NBCOMPR-1, VE, "compr" },
{ "none", "none", 0, AV_OPT_TYPE_CONST, {.i64=EXR_RAW}, 0, 0, VE, "compr" },
{ "rle" , "RLE", 0, AV_OPT_TYPE_CONST, {.i64=EXR_RLE}, 0, 0, VE, "compr" },
{ "zip1", "ZIP1", 0, AV_OPT_TYPE_CONST, {.i64=EXR_ZIP1}, 0, 0, VE, "compr" },
{ "zip16", "ZIP16", 0, AV_OPT_TYPE_CONST, {.i64=EXR_ZIP16}, 0, 0, VE, "compr" },
{ "format", "set pixel type", OFFSET(pixel_type), AV_OPT_TYPE_INT, {.i64=EXR_FLOAT}, EXR_HALF, EXR_UNKNOWN-1, VE, "pixel" },
{ "half" , NULL, 0, AV_OPT_TYPE_CONST, {.i64=EXR_HALF}, 0, 0, VE, "pixel" },
{ "float", NULL, 0, AV_OPT_TYPE_CONST, {.i64=EXR_FLOAT}, 0, 0, VE, "pixel" },
{ "gamma", "set gamma", OFFSET(gamma), AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.001, FLT_MAX, VE },
{ NULL},
}

Definition at line 517 of file exrenc.c.

◆ exr_class

const AVClass exr_class
static
Initial value:
= {
.class_name = "exr",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 530 of file exrenc.c.

◆ ff_exr_encoder

const AVCodec ff_exr_encoder
Initial value:
= {
.name = "exr",
.long_name = NULL_IF_CONFIG_SMALL("OpenEXR image"),
.priv_data_size = sizeof(EXRContext),
.priv_class = &exr_class,
.encode2 = encode_frame,
.close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]) {
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}

Definition at line 537 of file exrenc.c.

EXR_NBCOMPR
@ EXR_NBCOMPR
Definition: exrenc.c:45
EXR_ZIP16
@ EXR_ZIP16
Definition: exrenc.c:44
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:42
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
EXR_FLOAT
@ EXR_FLOAT
Definition: exrenc.c:51
exr_class
static const AVClass exr_class
Definition: exrenc.c:530
init
static int init
Definition: av_tx.c:47
EXR_RAW
@ EXR_RAW
Definition: exrenc.c:41
type
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 type
Definition: writing_filters.txt:86
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
OFFSET
#define OFFSET(x)
Definition: exrenc.c:515
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:113
AV_CODEC_ID_EXR
@ AV_CODEC_ID_EXR
Definition: codec_id.h:230
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:433
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
EXR_UNKNOWN
@ EXR_UNKNOWN
Definition: exrenc.c:52
EXR_HALF
@ EXR_HALF
Definition: exrenc.c:50
options
static const AVOption options[]
Definition: exrenc.c:517
encode_init
static int encode_init(AVCodecContext *avctx)
Definition: exrenc.c:92
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:434
EXR_RLE
@ EXR_RLE
Definition: exrenc.c:42
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
VE
#define VE
Definition: exrenc.c:516
encode_frame
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: exrenc.c:344
EXR_ZIP1
@ EXR_ZIP1
Definition: exrenc.c:43
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
encode_close
static int encode_close(AVCodecContext *avctx)
Definition: exrenc.c:135
EXRContext
Definition: exr.c:145