Go to the documentation of this file.
21 #include <VideoToolbox/VideoToolbox.h>
55 ret = VTPixelTransferSessionCreate(kCFAllocatorDefault, &
s->transfer);
61 #define STRING_OPTION(var_name, func_name, default_value) \
63 if (s->var_name##_string) { \
64 int var = av_##func_name##_from_name(s->var_name##_string); \
66 av_log(avctx, AV_LOG_ERROR, "Invalid %s.\n", #var_name); \
67 return AVERROR(EINVAL); \
71 s->var_name = default_value; \
83 "Doesn't support converting to colour primaries %s\n",
84 s->colour_primaries_string);
87 VTSessionSetProperty(
s->transfer, kVTPixelTransferPropertyKey_DestinationColorPrimaries,
value);
94 "Doesn't support converting to trc %s\n",
95 s->colour_transfer_string);
98 VTSessionSetProperty(
s->transfer, kVTPixelTransferPropertyKey_DestinationTransferFunction,
value);
105 "Doesn't support converting to colorspace %s\n",
106 s->colour_matrix_string);
109 VTSessionSetProperty(
s->transfer, kVTPixelTransferPropertyKey_DestinationYCbCrMatrix,
value);
120 VTPixelTransferSessionInvalidate(
s->transfer);
121 CFRelease(
s->transfer);
132 CVPixelBufferRef
src;
133 CVPixelBufferRef
dst;
145 av_reduce(&
out->sample_aspect_ratio.num, &
out->sample_aspect_ratio.den,
150 out->color_primaries =
s->colour_primaries;
152 out->color_trc =
s->colour_transfer;
154 out->colorspace =
s->colour_matrix;
156 src = (CVPixelBufferRef)in->
data[3];
157 dst = (CVPixelBufferRef)
out->data[3];
158 ret = VTPixelTransferSessionTransferImage(
s->transfer,
src,
dst);
192 outlink->
w =
s->output_width;
193 outlink->
h =
s->output_height;
195 if (
inlink->sample_aspect_ratio.num) {
209 hw_frame_ctx_out->
width = outlink->
w;
210 hw_frame_ctx_out->
height = outlink->
h;
220 "Failed to init videotoolbox frame context, %s\n",
228 #define OFFSET(x) offsetof(ScaleVtContext, x)
229 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
231 {
"w",
"Output video width",
233 {
"h",
"Output video height",
235 {
"color_matrix",
"Output colour matrix coefficient set",
237 {
"color_primaries",
"Output colour primaries",
239 {
"color_transfer",
"Output colour transfer characteristics",
271 .priv_class = &scale_vt_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteristic trc)
Convert an AVColorTransferCharacteristic to a VideoToolbox/CoreVideo color transfer function string.
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
AVColorTransferCharacteristic
Color Transfer Characteristic.
CFStringRef av_map_videotoolbox_color_matrix_from_av(enum AVColorSpace space)
Convert an AVColorSpace to a VideoToolbox/CoreVideo color matrix string.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
uint8_t * data
The data buffer.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
const AVFilter ff_vf_scale_vt
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
int ff_scale_eval_dimensions(void *log_ctx, const char *w_expr, const char *h_expr, AVFilterLink *inlink, AVFilterLink *outlink, int *ret_w, int *ret_h)
Parse and evaluate string expressions for width and height.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
const char * name
Filter name.
int width
The allocated dimensions of the frames in this pool.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Link properties exposed to filter code, but not external callers.
static int scale_vt_filter_frame(AVFilterLink *link, AVFrame *in)
void * priv
private data for use by the filter
static av_cold int scale_vt_init(AVFilterContext *avctx)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static int scale_vt_config_output(AVFilterLink *outlink)
A filter pad used for either input or output.
CFStringRef av_map_videotoolbox_color_primaries_from_av(enum AVColorPrimaries pri)
Convert an AVColorPrimaries to a VideoToolbox/CoreVideo color primaries string.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
#define FILTER_OUTPUTS(array)
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 link
Describe the class of an AVClass context structure.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Rational number (pair of numerator and denominator).
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
AVFilterLink ** inputs
array of pointers to input links
char * colour_primaries_string
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
int(* init)(AVBSFContext *ctx)
enum AVColorPrimaries colour_primaries
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
VTPixelTransferSessionRef transfer
AVFilterContext * src
source filter
#define AVERROR_EXTERNAL
Generic error in an external library.
static av_cold void scale_vt_uninit(AVFilterContext *avctx)
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
char * colour_transfer_string
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
static void uninit(AVBSFContext *ctx)
int w
agreed upon image width
AVColorSpace
YUV colorspace 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 default value
const char * name
Pad name.
static const AVOption scale_vt_options[]
static const AVFilterPad scale_vt_outputs[]
enum AVColorTransferCharacteristic colour_transfer
This struct describes a set or pool of "hardware" frames (i.e.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
AVFILTER_DEFINE_CLASS(scale_vt)
int h
agreed upon image height
static const AVFilterPad scale_vt_inputs[]
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define STRING_OPTION(var_name, func_name, default_value)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
enum AVColorSpace colour_matrix
char * colour_matrix_string
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.