Go to the documentation of this file.
21 #include <VideoToolbox/VideoToolbox.h>
45 ret = VTPixelRotationSessionCreate(kCFAllocatorDefault, &
s->session);
59 VTPixelRotationSessionInvalidate(
s->session);
60 CFRelease(
s->session);
88 src = (CVPixelBufferRef)in->
data[3];
89 dst = (CVPixelBufferRef)
out->data[3];
90 ret = VTPixelRotationSessionRotateImage(
s->session,
src,
dst);
124 hw_frame_ctx_out->
width = outlink->
w;
125 hw_frame_ctx_out->
height = outlink->
h;
135 "Failed to init videotoolbox frame context, %s\n",
151 CFStringRef rotation = kVTRotation_0;
152 CFBooleanRef vflip = kCFBooleanFalse;
153 CFBooleanRef hflip = kCFBooleanFalse;
162 "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
171 rotation = kVTRotation_CCW90;
172 vflip = kCFBooleanTrue;
176 rotation = kVTRotation_CCW90;
180 rotation = kVTRotation_CW90;
184 rotation = kVTRotation_CW90;
185 vflip = kCFBooleanTrue;
189 rotation = kVTRotation_180;
192 hflip = kCFBooleanTrue;
195 vflip = kCFBooleanTrue;
202 err = VTSessionSetProperty(
s->session, kVTPixelRotationPropertyKey_Rotation,
208 err = VTSessionSetProperty(
s->session, kVTPixelRotationPropertyKey_FlipVerticalOrientation,
214 err = VTSessionSetProperty(
s->session, kVTPixelRotationPropertyKey_FlipHorizontalOrientation,
229 #define OFFSET(x) offsetof(TransposeVtContext, x)
230 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
232 {
"dir",
"set transpose direction",
234 {
"cclock_flip",
"rotate counter-clockwise with vertical flip",
236 {
"clock",
"rotate clockwise",
238 {
"cclock",
"rotate counter-clockwise",
240 {
"clock_flip",
"rotate clockwise with vertical flip",
242 {
"reversal",
"rotate by half-turn",
244 {
"hflip",
"flip horizontally",
246 {
"vflip",
"flip vertically",
249 {
"passthrough",
"do not apply transposition if the input matches the specified geometry",
251 {
"none",
"always apply transposition",
253 {
"portrait",
"preserve portrait geometry",
255 {
"landscape",
"preserve landscape geometry",
280 .
name =
"transpose_vt",
288 .priv_class = &transpose_vt_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
VTPixelRotationSessionRef session
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
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.
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.
static int transpose_vt_config_output(AVFilterLink *outlink)
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
static av_cold int transpose_vt_init(AVFilterContext *avctx)
#define AV_LOG_VERBOSE
Detailed information.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
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.
void * priv
private data for use by the filter
static int transpose_vt_recreate_hw_ctx(AVFilterLink *outlink)
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#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.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
AVFilterLink ** inputs
array of pointers to input links
static av_cold void transpose_vt_uninit(AVFilterContext *avctx)
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...
@ TRANSPOSE_PT_TYPE_PORTRAIT
int(* init)(AVBSFContext *ctx)
#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.
AVFILTER_DEFINE_CLASS(transpose_vt)
static int transpose_vt_filter_frame(AVFilterLink *link, AVFrame *in)
AVFilterContext * src
source filter
#define AVERROR_EXTERNAL
Generic error in an external library.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
const AVFilter ff_vf_transpose_vt
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
static void uninit(AVBSFContext *ctx)
int w
agreed upon image width
const char * name
Pad name.
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.
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ TRANSPOSE_PT_TYPE_LANDSCAPE
static const AVFilterPad transpose_vt_inputs[]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
static const AVOption transpose_vt_options[]
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.
static const AVFilterPad transpose_vt_outputs[]