33 if (hw_devices[i]->type == type) {
36 found = hw_devices[i];
46 if (!strcmp(hw_devices[i]->name, name))
64 return hw_devices[nb_hw_devices++];
82 const char *errmsg, *p, *q;
85 k = strcspn(arg,
":=@");
95 errmsg =
"unknown device type";
100 k = strcspn(p + 1,
":@");
108 errmsg =
"named device already exists";
119 int index, index_limit = 1000;
120 index_pos = strlen(type_name);
126 for (index = 0; index < index_limit; index++) {
127 snprintf(name, index_pos + 4,
"%s%d", type_name, index);
131 if (index >= index_limit) {
132 errmsg =
"too many devices";
144 }
else if (*p ==
':') {
156 errmsg =
"failed to parse options";
162 device ? device : p, options, 0);
166 }
else if (*p ==
'@') {
171 errmsg =
"invalid source device name";
180 errmsg =
"parse error";
207 "Invalid device specification \"%s\": %s\n", arg, errmsg);
212 "Device creation failed: %d.\n", err);
243 const char *type_name;
249 if (strstr(codec_name, type_name))
300 "for decoder (device type %s for codec %s).\n",
322 "for encoder (device type %s for codec %s).\n",
343 if (input->
format == output_format) {
352 output->
format = output_format;
357 "output frame: %d.\n", err);
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
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 enum AVHWDeviceType hw_device_match_type_by_hwaccel(enum HWAccelID hwaccel_id)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
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.
const OptionDef options[]
#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 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)
char * av_asprintf(const char *fmt,...)
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
enum AVHWDeviceType device_type
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.
main external API structure.
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.
static HWDevice ** hw_devices
static enum AVHWDeviceType hw_device_match_type_in_name(const char *codec_name)
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.
static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
A reference to a data buffer.
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 av_hwdevice_iterate_types(enum AVHWDeviceType prev)
Iterate over supported device types.
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.