Go to the documentation of this file.
22 #include <OpenColorIO/OpenColorIO.h>
25 namespace OCIO = OCIO_NAMESPACE;
30 OCIO::ConstCPUProcessorRcPtr
cpu;
48 return OCIO::BIT_DEPTH_UINT8;
52 return OCIO::BIT_DEPTH_UINT16;
56 return OCIO::BIT_DEPTH_UINT10;
60 return OCIO::BIT_DEPTH_UINT12;
67 return OCIO::BIT_DEPTH_F16;
71 return OCIO::BIT_DEPTH_F32;
74 return OCIO::BIT_DEPTH_UNKNOWN;
81 OCIO::ConstContextRcPtr
context =
config->getCurrentContext();
87 OCIO::ContextRcPtr
ctx =
context->createEditableCopy();
100 const char *input_color_space,
101 const char *output_color_space,
107 s->config = OCIO::Config::CreateFromEnv();
109 s->config = OCIO::Config::CreateFromFile(config_path);
111 if (!
s->config || !input_color_space || !output_color_space) {
121 OCIO::ColorSpaceTransformRcPtr cst = OCIO::ColorSpaceTransform::Create();
122 cst->setSrc(input_color_space);
123 cst->setDst(output_color_space);
125 s->processor =
s->config->getProcessor(
context, cst, OCIO::TRANSFORM_DIR_FORWARD);
128 }
catch (OCIO::Exception &e) {
129 av_log(
ctx,
AV_LOG_ERROR,
"OCIO Filter: Error in create_output_colorspace_processor: %s\n", e.what());
138 const char *config_path,
139 const char *input_color_space,
148 s->config = OCIO::Config::CreateFromEnv();
150 s->config = OCIO::Config::CreateFromFile(config_path);
152 if (!
s->config || !input_color_space || !display || !view) {
163 OCIO::DisplayViewTransformRcPtr dv = OCIO::DisplayViewTransform::Create();
164 dv->setSrc(input_color_space);
165 dv->setDisplay(display);
167 OCIO::TransformDirection direction = OCIO::TRANSFORM_DIR_FORWARD;
169 direction = OCIO::TRANSFORM_DIR_INVERSE;
171 s->processor =
s->config->getProcessor(
context, dv, direction);
174 }
catch (OCIO::Exception &e) {
184 const char *file_transform,
188 if (!file_transform) {
195 OCIO::FileTransformRcPtr ft = OCIO::FileTransform::Create();
196 ft->setSrc(file_transform);
197 OCIO::TransformDirection direction = OCIO::TRANSFORM_DIR_FORWARD;
199 direction = OCIO::TRANSFORM_DIR_INVERSE;
200 s->config = OCIO::Config::Create();
201 s->processor =
s->config->getProcessor(ft, direction);
204 }
catch (OCIO::Exception &e) {
219 if (!
s || !
s->processor)
222 s->cpu =
s->processor->getOptimizedCPUProcessor(
224 OCIO::OPTIMIZATION_DEFAULT);
227 }
catch (OCIO::Exception &e) {
240 if (ocio_bitdepth == OCIO::BIT_DEPTH_UNKNOWN) {
241 throw std::runtime_error(
"Unsupported pixel format for OCIO processing");
244 int stridex =
frame->linesize[0];
248 throw std::runtime_error(
"Invalid pixel format descriptor");
255 uint8_t *red =
frame->data[2] + y_start *
frame->linesize[2];
256 uint8_t *green =
frame->data[0] + y_start *
frame->linesize[0];
257 uint8_t *blue =
frame->data[1] + y_start *
frame->linesize[1];
258 uint8_t *
alpha = (
desc->nb_components == 4)
259 ? (
frame->data[3] + y_start *
frame->linesize[3])
262 return new OCIO::PlanarImageDesc(
263 (
void *)red, (
void *)green, (
void *)blue, (
void *)
alpha,
frame->width,
264 height, ocio_bitdepth,
desc->comp[0].step, stridex);
270 return new OCIO::PackedImageDesc(
272 desc->comp[0].depth / 8,
desc->comp[0].step,
frame->linesize[0]);
285 s->cpu->apply(*imgDesc);
297 }
catch (
const OCIO::Exception &ex) {
300 }
catch (
const std::exception &ex) {
AVPixelFormat
Pixel format.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
OCIO::ConstCPUProcessorRcPtr cpu
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
This structure describes decoded (raw) audio or video data.
int ocio_apply(AVFilterContext *ctx, OCIOHandle handle, AVFrame *input_frame, AVFrame *output_frame, int y_start, int height)
#define AV_PIX_FMT_GBRP10
OCIOHandle ocio_create_output_colorspace_processor(AVFilterContext *ctx, const char *config_path, const char *input_color_space, const char *output_color_space, AVDictionary *params)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP12
OCIO::ConstConfigRcPtr config
static AVFormatContext * ctx
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
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 default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your context
#define AV_PIX_FMT_RGBA64
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
#define AV_PIX_FMT_GBRPF16
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define AV_PIX_FMT_GBRPF32
OCIOHandle ocio_create_file_transform_processor(AVFilterContext *ctx, const char *file_transform, int inverse)
static OCIO::ImageDesc * AVFrame2ImageDescSlice(AVFrame *frame, int y_start, int height)
OCIO::ConstProcessorRcPtr processor
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
OCIOHandle ocio_create_display_view_processor(AVFilterContext *ctx, const char *config_path, const char *input_color_space, const char *display, const char *view, int inverse, AVDictionary *params)
#define AV_PIX_FMT_GBRP12
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
#define AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF16
static char * output_format
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
static OCIO::ConstContextRcPtr add_context_params(OCIO::ConstConfigRcPtr config, AVDictionary *params)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void ocio_destroy_processor(AVFilterContext *ctx, OCIOHandle handle)
static const int16_t alpha[]
static OCIO::BitDepth get_ocio_depth(int format)
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
int ocio_finalize_processor(AVFilterContext *ctx, OCIOHandle handle, int input_format, int output_format)