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 "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 521 of file exrenc.c.

◆ VE

Definition at line 522 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 av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 93 of file exrenc.c.

◆ encode_close()

static av_cold int encode_close ( AVCodecContext avctx)
static

Definition at line 141 of file exrenc.c.

◆ reorder_pixels()

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

Definition at line 158 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 182 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 221 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 279 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 350 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().

◆ y_chlist

const char y_chlist[4] = { 'Y' }
static

Definition at line 57 of file exrenc.c.

Referenced by encode_init().

◆ gbra_order

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

Definition at line 58 of file exrenc.c.

Referenced by encode_init().

◆ gbr_order

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

Definition at line 59 of file exrenc.c.

Referenced by encode_init().

◆ y_order

const uint8_t y_order[4] = { 0 }
static

Definition at line 60 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 523 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 536 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 543 of file exrenc.c.

EXR_NBCOMPR
@ EXR_NBCOMPR
Definition: exrenc.c:45
EXR_ZIP16
@ EXR_ZIP16
Definition: exrenc.c:44
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:536
EXR_RAW
@ EXR_RAW
Definition: exrenc.c:41
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:315
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:156
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:491
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
OFFSET
#define OFFSET(x)
Definition: exrenc.c:521
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:107
AV_CODEC_ID_EXR
@ AV_CODEC_ID_EXR
Definition: codec_id.h:232
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:488
encode_init
static av_cold int encode_init(AVCodecContext *avctx)
Definition: exrenc.c:93
encode_close
static av_cold int encode_close(AVCodecContext *avctx)
Definition: exrenc.c:141
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
EXR_UNKNOWN
@ EXR_UNKNOWN
Definition: exrenc.c:52
EXR_HALF
@ EXR_HALF
Definition: exrenc.c:50
options
static const AVOption options[]
Definition: exrenc.c:523
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:489
EXR_RLE
@ EXR_RLE
Definition: exrenc.c:42
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
VE
#define VE
Definition: exrenc.c:522
encode_frame
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: exrenc.c:350
EXR_ZIP1
@ EXR_ZIP1
Definition: exrenc.c:43
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
EXRContext
Definition: exr.c:146