FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
exrenc.c File Reference
#include <float.h>
#include <zlib.h>
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/float2half.h"
#include "avcodec.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "encode.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 av_cold int encode_init (AVCodecContext *avctx)
 
static av_cold 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 char y_chlist [4] = { 'Y' }
 
static const uint8_t gbra_order [4] = { 3, 1, 0, 2 }
 
static const uint8_t gbr_order [4] = { 1, 0, 2, 0 }
 
static const uint8_t y_order [4] = { 0 }
 
static const AVOption options []
 
static const AVClass exr_class
 
const FFCodec 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 520 of file exrenc.c.

◆ VE

Definition at line 521 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 39 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 47 of file exrenc.c.

Function Documentation

◆ encode_init()

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 92 of file exrenc.c.

◆ encode_close()

static av_cold int encode_close ( AVCodecContext avctx)
static

Definition at line 140 of file exrenc.c.

◆ reorder_pixels()

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

Definition at line 157 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 181 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 220 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 278 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 349 of file exrenc.c.

Variable Documentation

◆ abgr_chlist

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

Definition at line 54 of file exrenc.c.

Referenced by encode_init().

◆ bgr_chlist

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

Definition at line 55 of file exrenc.c.

Referenced by encode_init().

◆ y_chlist

const char y_chlist[4] = { 'Y' }
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().

◆ y_order

const uint8_t y_order[4] = { 0 }
static

Definition at line 59 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, .unit = "compr" },
{ "none", "none", 0, AV_OPT_TYPE_CONST, {.i64=EXR_RAW}, 0, 0, VE, .unit = "compr" },
{ "rle" , "RLE", 0, AV_OPT_TYPE_CONST, {.i64=EXR_RLE}, 0, 0, VE, .unit = "compr" },
{ "zip1", "ZIP1", 0, AV_OPT_TYPE_CONST, {.i64=EXR_ZIP1}, 0, 0, VE, .unit = "compr" },
{ "zip16", "ZIP16", 0, AV_OPT_TYPE_CONST, {.i64=EXR_ZIP16}, 0, 0, VE, .unit = "compr" },
{ "format", "set pixel type", OFFSET(pixel_type), AV_OPT_TYPE_INT, {.i64=EXR_FLOAT}, EXR_HALF, EXR_UNKNOWN-1, VE, .unit = "pixel" },
{ "half" , NULL, 0, AV_OPT_TYPE_CONST, {.i64=EXR_HALF}, 0, 0, VE, .unit = "pixel" },
{ "float", NULL, 0, AV_OPT_TYPE_CONST, {.i64=EXR_FLOAT}, 0, 0, VE, .unit = "pixel" },
{ "gamma", "set gamma", OFFSET(gamma), AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.001, FLT_MAX, VE },
{ NULL},
}

Definition at line 522 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 535 of file exrenc.c.

◆ ff_exr_encoder

const FFCodec ff_exr_encoder
Initial value:
= {
.p.name = "exr",
CODEC_LONG_NAME("OpenEXR image"),
.priv_data_size = sizeof(EXRContext),
.p.priv_class = &exr_class,
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_EXR,
.init = encode_init,
.close = encode_close,
.p.pix_fmts = (const enum AVPixelFormat[]) {
}

Definition at line 542 of file exrenc.c.

EXR_NBCOMPR
@ EXR_NBCOMPR
Definition: exrenc.c:44
EXR_ZIP16
@ EXR_ZIP16
Definition: exrenc.c:43
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
EXR_FLOAT
@ EXR_FLOAT
Definition: exrenc.c:50
exr_class
static const AVClass exr_class
Definition: exrenc.c:535
EXR_RAW
@ EXR_RAW
Definition: exrenc.c:40
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:320
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:535
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
OFFSET
#define OFFSET(x)
Definition: exrenc.c:520
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
AV_CODEC_ID_EXR
@ AV_CODEC_ID_EXR
Definition: codec_id.h:234
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:237
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
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:532
encode_init
static av_cold int encode_init(AVCodecContext *avctx)
Definition: exrenc.c:92
encode_close
static av_cold int encode_close(AVCodecContext *avctx)
Definition: exrenc.c:140
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
EXR_UNKNOWN
@ EXR_UNKNOWN
Definition: exrenc.c:51
EXR_HALF
@ EXR_HALF
Definition: exrenc.c:49
options
static const AVOption options[]
Definition: exrenc.c:522
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:533
EXR_RLE
@ EXR_RLE
Definition: exrenc.c:41
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
VE
#define VE
Definition: exrenc.c:521
encode_frame
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: exrenc.c:349
EXR_ZIP1
@ EXR_ZIP1
Definition: exrenc.c:42
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
EXRContext
Definition: exr.c:147