FFmpeg
ffmpeg_hw.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <string.h>
20 
21 #include "libavutil/avstring.h"
22 #include "libavutil/pixdesc.h"
23 #include "libavfilter/buffersink.h"
24 
25 #include "ffmpeg.h"
26 
27 static int nb_hw_devices;
29 
31 {
32  HWDevice *found = NULL;
33  int i;
34  for (i = 0; i < nb_hw_devices; i++) {
35  if (hw_devices[i]->type == type) {
36  if (found)
37  return NULL;
38  found = hw_devices[i];
39  }
40  }
41  return found;
42 }
43 
45 {
46  int i;
47  for (i = 0; i < nb_hw_devices; i++) {
48  if (!strcmp(hw_devices[i]->name, name))
49  return hw_devices[i];
50  }
51  return NULL;
52 }
53 
54 static HWDevice *hw_device_add(void)
55 {
56  int err;
58  sizeof(*hw_devices));
59  if (err) {
60  nb_hw_devices = 0;
61  return NULL;
62  }
65  return NULL;
66  return hw_devices[nb_hw_devices++];
67 }
68 
70 {
71  // Make an automatic name of the form "type%d". We arbitrarily
72  // limit at 1000 anonymous devices of the same type - there is
73  // probably something else very wrong if you get to this limit.
74  const char *type_name = av_hwdevice_get_type_name(type);
75  char *name;
76  size_t index_pos;
77  int index, index_limit = 1000;
78  index_pos = strlen(type_name);
79  name = av_malloc(index_pos + 4);
80  if (!name)
81  return NULL;
82  for (index = 0; index < index_limit; index++) {
83  snprintf(name, index_pos + 4, "%s%d", type_name, index);
85  break;
86  }
87  if (index >= index_limit) {
88  av_freep(&name);
89  return NULL;
90  }
91  return name;
92 }
93 
94 int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
95 {
96  // "type=name"
97  // "type=name,key=value,key2=value2"
98  // "type=name:device,key=value,key2=value2"
99  // "type:device,key=value,key2=value2"
100  // -> av_hwdevice_ctx_create()
101  // "type=name@name"
102  // "type@name"
103  // -> av_hwdevice_ctx_create_derived()
104 
106  const char *type_name = NULL, *name = NULL, *device = NULL;
107  enum AVHWDeviceType type;
108  HWDevice *dev, *src;
109  AVBufferRef *device_ref = NULL;
110  int err;
111  const char *errmsg, *p, *q;
112  size_t k;
113 
114  k = strcspn(arg, ":=@");
115  p = arg + k;
116 
117  type_name = av_strndup(arg, k);
118  if (!type_name) {
119  err = AVERROR(ENOMEM);
120  goto fail;
121  }
122  type = av_hwdevice_find_type_by_name(type_name);
123  if (type == AV_HWDEVICE_TYPE_NONE) {
124  errmsg = "unknown device type";
125  goto invalid;
126  }
127 
128  if (*p == '=') {
129  k = strcspn(p + 1, ":@,");
130 
131  name = av_strndup(p + 1, k);
132  if (!name) {
133  err = AVERROR(ENOMEM);
134  goto fail;
135  }
137  errmsg = "named device already exists";
138  goto invalid;
139  }
140 
141  p += 1 + k;
142  } else {
144  if (!name) {
145  err = AVERROR(ENOMEM);
146  goto fail;
147  }
148  }
149 
150  if (!*p) {
151  // New device with no parameters.
152  err = av_hwdevice_ctx_create(&device_ref, type,
153  NULL, NULL, 0);
154  if (err < 0)
155  goto fail;
156 
157  } else if (*p == ':') {
158  // New device with some parameters.
159  ++p;
160  q = strchr(p, ',');
161  if (q) {
162  if (q - p > 0) {
163  device = av_strndup(p, q - p);
164  if (!device) {
165  err = AVERROR(ENOMEM);
166  goto fail;
167  }
168  }
169  err = av_dict_parse_string(&options, q + 1, "=", ",", 0);
170  if (err < 0) {
171  errmsg = "failed to parse options";
172  goto invalid;
173  }
174  }
175 
176  err = av_hwdevice_ctx_create(&device_ref, type,
177  q ? device : p[0] ? p : NULL,
178  options, 0);
179  if (err < 0)
180  goto fail;
181 
182  } else if (*p == '@') {
183  // Derive from existing device.
184 
185  src = hw_device_get_by_name(p + 1);
186  if (!src) {
187  errmsg = "invalid source device name";
188  goto invalid;
189  }
190 
191  err = av_hwdevice_ctx_create_derived(&device_ref, type,
192  src->device_ref, 0);
193  if (err < 0)
194  goto fail;
195  } else if (*p == ',') {
196  err = av_dict_parse_string(&options, p + 1, "=", ",", 0);
197 
198  if (err < 0) {
199  errmsg = "failed to parse options";
200  goto invalid;
201  }
202 
203  err = av_hwdevice_ctx_create(&device_ref, type,
204  NULL, options, 0);
205  if (err < 0)
206  goto fail;
207  } else {
208  errmsg = "parse error";
209  goto invalid;
210  }
211 
212  dev = hw_device_add();
213  if (!dev) {
214  err = AVERROR(ENOMEM);
215  goto fail;
216  }
217 
218  dev->name = name;
219  dev->type = type;
220  dev->device_ref = device_ref;
221 
222  if (dev_out)
223  *dev_out = dev;
224 
225  name = NULL;
226  err = 0;
227 done:
228  av_freep(&type_name);
229  av_freep(&name);
230  av_freep(&device);
232  return err;
233 invalid:
235  "Invalid device specification \"%s\": %s\n", arg, errmsg);
236  err = AVERROR(EINVAL);
237  goto done;
238 fail:
240  "Device creation failed: %d.\n", err);
241  av_buffer_unref(&device_ref);
242  goto done;
243 }
244 
246  const char *device,
247  HWDevice **dev_out)
248 {
249  AVBufferRef *device_ref = NULL;
250  HWDevice *dev;
251  char *name;
252  int err;
253 
255  if (!name) {
256  err = AVERROR(ENOMEM);
257  goto fail;
258  }
259 
260  err = av_hwdevice_ctx_create(&device_ref, type, device, NULL, 0);
261  if (err < 0) {
263  "Device creation failed: %d.\n", err);
264  goto fail;
265  }
266 
267  dev = hw_device_add();
268  if (!dev) {
269  err = AVERROR(ENOMEM);
270  goto fail;
271  }
272 
273  dev->name = name;
274  dev->type = type;
275  dev->device_ref = device_ref;
276 
277  if (dev_out)
278  *dev_out = dev;
279 
280  return 0;
281 
282 fail:
283  av_freep(&name);
284  av_buffer_unref(&device_ref);
285  return err;
286 }
287 
289 {
290  int i;
291  for (i = 0; i < nb_hw_devices; i++) {
293  av_buffer_unref(&hw_devices[i]->device_ref);
294  av_freep(&hw_devices[i]);
295  }
297  nb_hw_devices = 0;
298 }
299 
301 {
302  const AVCodecHWConfig *config;
303  HWDevice *dev;
304  int i;
305  for (i = 0;; i++) {
306  config = avcodec_get_hw_config(codec, i);
307  if (!config)
308  return NULL;
310  continue;
311  dev = hw_device_get_by_type(config->device_type);
312  if (dev)
313  return dev;
314  }
315 }
316 
318 {
319  const AVCodecHWConfig *config;
320  enum AVHWDeviceType type;
321  HWDevice *dev = NULL;
322  int err, auto_device = 0;
323 
324  if (ist->hwaccel_device) {
325  dev = hw_device_get_by_name(ist->hwaccel_device);
326  if (!dev) {
327  if (ist->hwaccel_id == HWACCEL_AUTO) {
328  auto_device = 1;
329  } else if (ist->hwaccel_id == HWACCEL_GENERIC) {
330  type = ist->hwaccel_device_type;
331  err = hw_device_init_from_type(type, ist->hwaccel_device,
332  &dev);
333  } else {
334  // This will be dealt with by API-specific initialisation
335  // (using hwaccel_device), so nothing further needed here.
336  return 0;
337  }
338  } else {
339  if (ist->hwaccel_id == HWACCEL_AUTO) {
340  ist->hwaccel_device_type = dev->type;
341  } else if (ist->hwaccel_device_type != dev->type) {
342  av_log(ist->dec_ctx, AV_LOG_ERROR, "Invalid hwaccel device "
343  "specified for decoder: device %s of type %s is not "
344  "usable with hwaccel %s.\n", dev->name,
346  av_hwdevice_get_type_name(ist->hwaccel_device_type));
347  return AVERROR(EINVAL);
348  }
349  }
350  } else {
351  if (ist->hwaccel_id == HWACCEL_AUTO) {
352  auto_device = 1;
353  } else if (ist->hwaccel_id == HWACCEL_GENERIC) {
354  type = ist->hwaccel_device_type;
356 
357  // When "-qsv_device device" is used, an internal QSV device named
358  // as "__qsv_device" is created. Another QSV device is created too
359  // if "-init_hw_device qsv=name:device" is used. There are 2 QSV devices
360  // if both "-qsv_device device" and "-init_hw_device qsv=name:device"
361  // are used, hw_device_get_by_type(AV_HWDEVICE_TYPE_QSV) returns NULL.
362  // To keep back-compatibility with the removed ad-hoc libmfx setup code,
363  // call hw_device_get_by_name("__qsv_device") to select the internal QSV
364  // device.
365  if (!dev && type == AV_HWDEVICE_TYPE_QSV)
366  dev = hw_device_get_by_name("__qsv_device");
367 
368  if (!dev)
369  err = hw_device_init_from_type(type, NULL, &dev);
370  } else {
371  dev = hw_device_match_by_codec(ist->dec);
372  if (!dev) {
373  // No device for this codec, but not using generic hwaccel
374  // and therefore may well not need one - ignore.
375  return 0;
376  }
377  }
378  }
379 
380  if (auto_device) {
381  int i;
382  if (!avcodec_get_hw_config(ist->dec, 0)) {
383  // Decoder does not support any hardware devices.
384  return 0;
385  }
386  for (i = 0; !dev; i++) {
388  if (!config)
389  break;
390  type = config->device_type;
392  if (dev) {
393  av_log(ist->dec_ctx, AV_LOG_INFO, "Using auto "
394  "hwaccel type %s with existing device %s.\n",
396  }
397  }
398  for (i = 0; !dev; i++) {
400  if (!config)
401  break;
402  type = config->device_type;
403  // Try to make a new device of this type.
404  err = hw_device_init_from_type(type, ist->hwaccel_device,
405  &dev);
406  if (err < 0) {
407  // Can't make a device of this type.
408  continue;
409  }
410  if (ist->hwaccel_device) {
411  av_log(ist->dec_ctx, AV_LOG_INFO, "Using auto "
412  "hwaccel type %s with new device created "
413  "from %s.\n", av_hwdevice_get_type_name(type),
414  ist->hwaccel_device);
415  } else {
416  av_log(ist->dec_ctx, AV_LOG_INFO, "Using auto "
417  "hwaccel type %s with new default device.\n",
419  }
420  }
421  if (dev) {
422  ist->hwaccel_device_type = type;
423  } else {
424  av_log(ist->dec_ctx, AV_LOG_INFO, "Auto hwaccel "
425  "disabled: no device found.\n");
426  ist->hwaccel_id = HWACCEL_NONE;
427  return 0;
428  }
429  }
430 
431  if (!dev) {
432  av_log(ist->dec_ctx, AV_LOG_ERROR, "No device available "
433  "for decoder: device type %s needed for codec %s.\n",
434  av_hwdevice_get_type_name(type), ist->dec->name);
435  return err;
436  }
437 
438  ist->dec_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref);
439  if (!ist->dec_ctx->hw_device_ctx)
440  return AVERROR(ENOMEM);
441 
442  return 0;
443 }
444 
446 {
447  const AVCodecHWConfig *config;
448  HWDevice *dev = NULL;
449  AVBufferRef *frames_ref = NULL;
450  int i;
451 
452  if (ost->filter) {
454  if (frames_ref &&
455  ((AVHWFramesContext*)frames_ref->data)->format ==
456  ost->enc_ctx->pix_fmt) {
457  // Matching format, will try to use hw_frames_ctx.
458  } else {
459  frames_ref = NULL;
460  }
461  }
462 
463  for (i = 0;; i++) {
465  if (!config)
466  break;
467 
468  if (frames_ref &&
470  (config->pix_fmt == AV_PIX_FMT_NONE ||
471  config->pix_fmt == ost->enc_ctx->pix_fmt)) {
472  av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using input "
473  "frames context (format %s) with %s encoder.\n",
475  ost->enc->name);
476  ost->enc_ctx->hw_frames_ctx = av_buffer_ref(frames_ref);
477  if (!ost->enc_ctx->hw_frames_ctx)
478  return AVERROR(ENOMEM);
479  return 0;
480  }
481 
482  if (!dev &&
484  dev = hw_device_get_by_type(config->device_type);
485  }
486 
487  if (dev) {
488  av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using device %s "
489  "(type %s) with %s encoder.\n", dev->name,
490  av_hwdevice_get_type_name(dev->type), ost->enc->name);
492  if (!ost->enc_ctx->hw_device_ctx)
493  return AVERROR(ENOMEM);
494  } else {
495  // No device required, or no device available.
496  }
497  return 0;
498 }
499 
501 {
502  InputStream *ist = avctx->opaque;
503  AVFrame *output = NULL;
504  enum AVPixelFormat output_format = ist->hwaccel_output_format;
505  int err;
506 
507  if (input->format == output_format) {
508  // Nothing to do.
509  return 0;
510  }
511 
513  if (!output)
514  return AVERROR(ENOMEM);
515 
516  output->format = output_format;
517 
519  if (err < 0) {
520  av_log(avctx, AV_LOG_ERROR, "Failed to transfer data to "
521  "output frame: %d.\n", err);
522  goto fail;
523  }
524 
526  if (err < 0) {
528  goto fail;
529  }
530 
534 
535  return 0;
536 
537 fail:
539  return err;
540 }
541 
543 {
544  InputStream *ist = avctx->opaque;
545 
546  ist->hwaccel_retrieve_data = &hwaccel_retrieve_data;
547 
548  return 0;
549 }
550 
552 {
553  HWDevice *dev;
554  int i;
555 
556  // Pick the last hardware device if the user doesn't pick the device for
557  // filters explicitly with the filter_hw_device option.
558  if (filter_hw_device)
559  dev = filter_hw_device;
560  else if (nb_hw_devices > 0) {
561  dev = hw_devices[nb_hw_devices - 1];
562 
563  if (nb_hw_devices > 1)
564  av_log(NULL, AV_LOG_WARNING, "There are %d hardware devices. device "
565  "%s of type %s is picked for filters by default. Set hardware "
566  "device explicitly with the filter_hw_device option if device "
567  "%s is not usable for filters.\n",
568  nb_hw_devices, dev->name,
569  av_hwdevice_get_type_name(dev->type), dev->name);
570  } else
571  dev = NULL;
572 
573  if (dev) {
574  for (i = 0; i < fg->graph->nb_filters; i++) {
575  fg->graph->filters[i]->hw_device_ctx =
577  if (!fg->graph->filters[i]->hw_device_ctx)
578  return AVERROR(ENOMEM);
579  }
580  }
581 
582  return 0;
583 }
ost
OutputStream * ost
Definition: ffmpeg_filter.c:160
AVCodec
AVCodec.
Definition: codec.h:202
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
AVERROR
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
OutputStream::enc
AVCodecContext * enc
Definition: muxing.c:56
OutputStream::enc_ctx
AVCodecContext * enc_ctx
Definition: ffmpeg.h:473
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
output
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
Definition: filter_design.txt:225
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
pixdesc.h
index
fg index
Definition: ffmpeg_filter.c:167
AV_HWDEVICE_TYPE_NONE
@ AV_HWDEVICE_TYPE_NONE
Definition: hwcontext.h:28
ist
ifilter ist
Definition: ffmpeg_filter.c:177
av_hwdevice_find_type_by_name
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
Definition: hwcontext.c:82
ffmpeg.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AVFilterContext::hw_device_ctx
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
Definition: avfilter.h:458
AVDictionary
Definition: dict.c:30
HWDevice
Definition: ffmpeg.h:67
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
hw_device_default_name
static char * hw_device_default_name(enum AVHWDeviceType type)
Definition: ffmpeg_hw.c:69
av_buffersink_get_hw_frames_ctx
AVBufferRef * av_buffersink_get_hw_frames_ctx(const AVFilterContext *ctx)
tf_sess_config.config
config
Definition: tf_sess_config.py:33
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
InputStream
Definition: ffmpeg.h:302
fail
#define fail()
Definition: checkasm.h:127
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
hw_device_free_all
void hw_device_free_all(void)
Definition: ffmpeg_hw.c:288
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:97
hw_device_init_from_type
static int hw_device_init_from_type(enum AVHWDeviceType type, const char *device, HWDevice **dev_out)
Definition: ffmpeg_hw.c:245
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
nb_hw_devices
static int nb_hw_devices
Definition: ffmpeg_hw.c:27
AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
The codec supports this format via the hw_frames_ctx interface.
Definition: codec.h:441
HWACCEL_GENERIC
@ HWACCEL_GENERIC
Definition: ffmpeg.h:64
AVHWDeviceType
AVHWDeviceType
Definition: hwcontext.h:27
av_hwdevice_get_type_name
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
Definition: hwcontext.c:92
hw_device_get_by_name
HWDevice * hw_device_get_by_name(const char *name)
Definition: ffmpeg_hw.c:44
arg
const char * arg
Definition: jacosubdec.c:67
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AVFilterGraph::filters
AVFilterContext ** filters
Definition: avfilter.h:863
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
Definition: codec.h:428
hw_devices
static HWDevice ** hw_devices
Definition: ffmpeg_hw.c:28
src
#define src
Definition: vp8dsp.c:255
hw_device_add
static HWDevice * hw_device_add(void)
Definition: ffmpeg_hw.c:54
hwaccel_retrieve_data
static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
Definition: ffmpeg_hw.c:500
hwaccel_decode_init
int hwaccel_decode_init(AVCodecContext *avctx)
Definition: ffmpeg_hw.c:542
FilterGraph
Definition: ffmpeg.h:286
hw_device_match_by_codec
static HWDevice * hw_device_match_by_codec(const AVCodec *codec)
Definition: ffmpeg_hw.c:300
options
const OptionDef options[]
OutputStream::filter
OutputFilter * filter
Definition: ffmpeg.h:516
FilterGraph::graph
AVFilterGraph * graph
Definition: ffmpeg.h:290
HWDevice::device_ref
AVBufferRef * device_ref
Definition: ffmpeg.h:70
OutputFilter::filter
AVFilterContext * filter
Definition: ffmpeg.h:263
av_reallocp_array
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
Definition: mem.c:232
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:203
input
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
Definition: filter_design.txt:172
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
buffersink.h
HWACCEL_AUTO
@ HWACCEL_AUTO
Definition: ffmpeg.h:63
av_hwdevice_ctx_create_derived
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.
Definition: hwcontext.c:714
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
hw_device_setup_for_decode
int hw_device_setup_for_decode(InputStream *ist)
Definition: ffmpeg_hw.c:317
av_frame_move_ref
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:462
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:435
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:263
AVCodecContext::hw_device_ctx
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
Definition: avcodec.h:1908
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:593
AVCodecContext::hw_frames_ctx
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition: avcodec.h:1858
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
av_hwdevice_ctx_create
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.
Definition: hwcontext.c:610
AVCodecContext::opaque
void * opaque
Private data of the user, can be used to carry app specific stuff.
Definition: avcodec.h:425
av_hwframe_transfer_data
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
Definition: hwcontext.c:443
AV_HWDEVICE_TYPE_QSV
@ AV_HWDEVICE_TYPE_QSV
Definition: hwcontext.h:33
filter_hw_device
HWDevice * filter_hw_device
Definition: ffmpeg_opt.c:139
AVCodecContext
main external API structure.
Definition: avcodec.h:383
HWDevice::name
const char * name
Definition: ffmpeg.h:68
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
av_dict_parse_string
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.
Definition: dict.c:180
hw_device_setup_for_encode
int hw_device_setup_for_encode(OutputStream *ost)
Definition: ffmpeg_hw.c:445
hw_device_init_from_string
int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
Definition: ffmpeg_hw.c:94
HWACCEL_NONE
@ HWACCEL_NONE
Definition: ffmpeg.h:62
avcodec_get_hw_config
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
Definition: utils.c:855
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
HWDevice::type
enum AVHWDeviceType type
Definition: ffmpeg.h:69
OutputStream
Definition: muxing.c:54
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVCodecHWConfig
Definition: codec.h:460
hw_device_setup_for_filter
int hw_device_setup_for_filter(FilterGraph *fg)
Definition: ffmpeg_hw.c:551
AVFilterGraph::nb_filters
unsigned nb_filters
Definition: avfilter.h:864
avstring.h
av_strndup
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
Definition: mem.c:291
snprintf
#define snprintf
Definition: snprintf.h:34
av_get_pix_fmt_name
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.
Definition: pixdesc.c:2580
hw_device_get_by_type
static HWDevice * hw_device_get_by_type(enum AVHWDeviceType type)
Definition: ffmpeg_hw.c:30