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",
163 inlink->
w, inlink->
h, inlink->
w, inlink->
h);
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,
224 outlink->
w = inlink->
h;
225 outlink->
h = inlink->
w;
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 .p.name =
"transpose_vt",
282 .p.priv_class = &transpose_vt_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFFilter ff_vf_transpose_vt
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
An API-specific header for AV_HWDEVICE_TYPE_VIDEOTOOLBOX.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
uint8_t * data
The data buffer.
Describe the class of an AVClass context structure.
AVFilterLink ** inputs
array of pointers to input links
void * priv
private data for use by the filter
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int width
The allocated dimensions of the frames in this pool.
Link properties exposed to filter code, but not external callers.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
VTPixelRotationSessionRef session
static AVFormatContext * ctx
@ TRANSPOSE_PT_TYPE_PORTRAIT
@ TRANSPOSE_PT_TYPE_LANDSCAPE
static av_cold void transpose_vt_uninit(AVFilterContext *avctx)
static int transpose_vt_config_output(AVFilterLink *outlink)
static const AVFilterPad transpose_vt_inputs[]
static av_cold int transpose_vt_init(AVFilterContext *avctx)
static int transpose_vt_filter_frame(AVFilterLink *link, AVFrame *in)
static const AVOption transpose_vt_options[]
static const AVFilterPad transpose_vt_outputs[]
static int transpose_vt_recreate_hw_ctx(AVFilterLink *outlink)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.