35 if (hw_devices[i]->type == type) {
38 found = hw_devices[
i];
48 if (!strcmp(hw_devices[i]->name, name))
66 return hw_devices[nb_hw_devices++];
77 int index, index_limit = 1000;
78 index_pos = strlen(type_name);
82 for (index = 0; index < index_limit; index++) {
83 snprintf(name, index_pos + 4,
"%s%d", type_name, index);
87 if (index >= index_limit) {
109 const char *errmsg, *p, *q;
112 k = strcspn(arg,
":=@");
122 errmsg =
"unknown device type";
127 k = strcspn(p + 1,
":@");
135 errmsg =
"named device already exists";
155 }
else if (*p ==
':') {
169 errmsg =
"failed to parse options";
175 q ? device : p[0] ? p :
NULL,
180 }
else if (*p ==
'@') {
185 errmsg =
"invalid source device name";
194 errmsg =
"parse error";
221 "Invalid device specification \"%s\": %s\n", arg, errmsg);
226 "Device creation failed: %d.\n", err);
249 "Device creation failed: %d.\n", err);
308 int err, auto_device = 0;
329 "specified for decoder: device %s of type %s is not " 330 "usable with hwaccel %s.\n", dev->
name,
360 for (i = 0; !dev; i++) {
368 "hwaccel type %s with existing device %s.\n",
372 for (i = 0; !dev; i++) {
386 "hwaccel type %s with new device created " 391 "hwaccel type %s with new default device.\n",
399 "disabled: no device found.\n");
407 "for decoder: device type %s needed for codec %s.\n",
447 "frames context (format %s) with %s encoder.\n",
463 "(type %s) with %s encoder.\n", dev->
name,
481 if (input->
format == output_format) {
490 output->
format = output_format;
495 "output frame: %d.\n", err);
AVFilterContext ** filters
static char * hw_device_default_name(enum AVHWDeviceType type)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
This structure describes decoded (raw) audio or video data.
HWDevice * filter_hw_device
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
int hw_device_setup_for_filter(FilterGraph *fg)
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int hw_device_init_from_type(enum AVHWDeviceType type, const char *device, HWDevice **dev_out)
memory buffer sink API for audio and video
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
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
enum AVPixelFormat pix_fmt
For decoders, a hardware pixel format which that decoder may be able to decode to if suitable hardwar...
int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags)
Open a device of the specified type and create an AVHWDeviceContext for it.
#define AV_LOG_VERBOSE
Detailed information.
AVBufferRef * av_buffersink_get_hw_frames_ctx(const AVFilterContext *ctx)
The codec supports this format via the hw_device_ctx interface.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static HWDevice * hw_device_add(void)
void hw_device_free_all(void)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int methods
Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible setup methods which can be used...
int hwaccel_decode_init(AVCodecContext *avctx)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
const char * name
Name of the codec implementation.
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames...
int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr, enum AVHWDeviceType type, AVBufferRef *src_ref, int flags)
Create a new device of the specified type from an existing device.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
#define AV_LOG_INFO
Standard information.
main external API structure.
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
uint8_t * data
The data buffer.
HWDevice * hw_device_get_by_name(const char *name)
int hw_device_setup_for_decode(InputStream *ist)
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
This struct describes a set or pool of "hardware" frames (i.e.
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
static HWDevice ** hw_devices
static HWDevice * hw_device_get_by_type(enum AVHWDeviceType type)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
The codec supports this format via the hw_frames_ctx interface.
static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
A reference to a data buffer.
static HWDevice * hw_device_match_by_codec(const AVCodec *codec)
const OptionDef options[]
int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
enum AVHWDeviceType device_type
The device type associated with the configuration.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
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 hw_device_setup_for_encode(OutputStream *ost)
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
AVPixelFormat
Pixel format.
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
void * opaque
Private data of the user, can be used to carry app specific stuff.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.