Go to the documentation of this file.
21 #include <VideoToolbox/VideoToolbox.h>
54 ret = VTPixelTransferSessionCreate(kCFAllocatorDefault, &
s->transfer);
60 #define STRING_OPTION(var_name, func_name, default_value) \
62 if (s->var_name##_string) { \
63 int var = av_##func_name##_from_name(s->var_name##_string); \
65 av_log(avctx, AV_LOG_ERROR, "Invalid %s.\n", #var_name); \
66 return AVERROR(EINVAL); \
70 s->var_name = default_value; \
82 "Doesn't support converting to colour primaries %s\n",
83 s->colour_primaries_string);
86 VTSessionSetProperty(
s->transfer, kVTPixelTransferPropertyKey_DestinationColorPrimaries,
value);
93 "Doesn't support converting to trc %s\n",
94 s->colour_transfer_string);
97 VTSessionSetProperty(
s->transfer, kVTPixelTransferPropertyKey_DestinationTransferFunction,
value);
104 "Doesn't support converting to colorspace %s\n",
105 s->colour_matrix_string);
108 VTSessionSetProperty(
s->transfer, kVTPixelTransferPropertyKey_DestinationYCbCrMatrix,
value);
119 VTPixelTransferSessionInvalidate(
s->transfer);
120 CFRelease(
s->transfer);
131 CVPixelBufferRef
src;
132 CVPixelBufferRef dst;
144 av_reduce(&
out->sample_aspect_ratio.num, &
out->sample_aspect_ratio.den,
149 out->color_primaries =
s->colour_primaries;
151 out->color_trc =
s->colour_transfer;
153 out->colorspace =
s->colour_matrix;
155 src = (CVPixelBufferRef)in->
data[3];
156 dst = (CVPixelBufferRef)
out->data[3];
157 ret = VTPixelTransferSessionTransferImage(
s->transfer,
src, dst);
189 outlink->
w =
s->output_width;
190 outlink->
h =
s->output_height;
192 if (
inlink->sample_aspect_ratio.num) {
206 hw_frame_ctx_out->
width = outlink->
w;
207 hw_frame_ctx_out->
height = outlink->
h;
216 "Failed to init videotoolbox frame context, %s\n",
224 #define OFFSET(x) offsetof(ScaleVtContext, x)
225 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
227 {
"w",
"Output video width",
229 {
"h",
"Output video height",
231 {
"color_matrix",
"Output colour matrix coefficient set",
233 {
"color_primaries",
"Output colour primaries",
235 {
"color_transfer",
"Output colour transfer characteristics",
267 .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.
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
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.
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.
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_INPUTS(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 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.
#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)
char * colour_transfer_string
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
static void uninit(AVBSFContext *ctx)
int w
agreed upon image width
AVColorSpace
YUV colorspace type.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
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.
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)
#define FILTER_OUTPUTS(array)
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.