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++];
75 int index, index_limit = 1000;
76 index_pos = strlen(type_name);
80 for (index = 0; index < index_limit; index++) {
81 snprintf(name, index_pos + 4,
"%s%d", type_name, index);
85 if (index >= index_limit) {
107 const char *errmsg, *p, *q;
110 k = strcspn(arg,
":=@");
120 errmsg =
"unknown device type";
125 k = strcspn(p + 1,
":@");
133 errmsg =
"named device already exists";
153 }
else if (*p ==
':') {
165 errmsg =
"failed to parse options";
171 device ? device : p, options, 0);
175 }
else if (*p ==
'@') {
180 errmsg =
"invalid source device name";
189 errmsg =
"parse error";
216 "Invalid device specification \"%s\": %s\n", arg, errmsg);
221 "Device creation failed: %d.\n", err);
244 "Device creation failed: %d.\n", err);
303 int err, auto_device = 0;
324 "specified for decoder: device %s of type %s is not "
325 "usable with hwaccel %s.\n", dev->
name,
355 for (i = 0; !dev; i++) {
363 "hwaccel type %s with existing device %s.\n",
367 for (i = 0; !dev; i++) {
381 "hwaccel type %s with new device created "
386 "hwaccel type %s with new default device.\n",
394 "disabled: no device found.\n");
402 "for decoder: device type %s needed for codec %s.\n",
437 if (input->
format == output_format) {
446 output->
format = output_format;
451 "output frame: %d.\n", err);
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.
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 int hw_device_init_from_type(enum AVHWDeviceType type, const char *device, HWDevice **dev_out)
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.
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)
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
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.
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 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.
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.
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.