History

lavc: Add codec metadata to indicate hardware support

Mark Thompson committed 9 years ago

Commit 720cf4e1 parent 47687a25 files · +108 −1Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. libavcodec/avcodec.h +74 −0
  3. libavcodec/hwaccel.h +18 −0
  4. libavcodec/utils.c +12 −0
  5. libavcodec/version.h +1 −1
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2017-03-23 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2017-xx-xx - xxxxxxx - lavc 58.6.0 - avcodec.h
17+ Add AVCodecHWConfig and avcodec_get_hw_config().
18+
1619 2017-xx-xx - xxxxxxx - lavu 56.7.0 - stereo3d.h
1720 Add view field to AVStereo3D structure and AVStereo3DView enum.
1821
libavcodec/avcodec.h+74−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include "libavutil/cpu.h"
3636 #include "libavutil/dict.h"
3737 #include "libavutil/frame.h"
38+#include "libavutil/hwcontext.h"
3839 #include "libavutil/log.h"
3940 #include "libavutil/pixfmt.h"
4041 #include "libavutil/rational.h"
@@ -2748,6 +2749,61 @@ typedef struct AVProfile { · 2707 unmodified lines
27482749 const char *name; ///< short name for the profile
27492750 } AVProfile;
27502751
2752+enum {
2753+ /**
2754+ * The codec supports this format via the hw_device_ctx interface.
2755+ *
2756+ * When selecting this format, AVCodecContext.hw_device_ctx should
2757+ * have been set to a device of the specified type before calling
2758+ * avcodec_open2().
2759+ */
2760+ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,
2761+ /**
2762+ * The codec supports this format via the hw_frames_ctx interface.
2763+ *
2764+ * When selecting this format for a decoder,
2765+ * AVCodecContext.hw_frames_ctx should be set to a suitable frames
2766+ * context inside the get_format() callback. The frames context
2767+ * must have been created on a device of the specified type.
2768+ */
2769+ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,
2770+ /**
2771+ * The codec supports this format by some internal method.
2772+ *
2773+ * This format can be selected without any additional configuration -
2774+ * no device or frames context is required.
2775+ */
2776+ AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04,
2777+ /**
2778+ * The codec supports this format by some ad-hoc method.
2779+ *
2780+ * Additional settings and/or function calls are required. See the
2781+ * codec-specific documentation for details. (Methods requiring
2782+ * this sort of configuration are deprecated and others should be
2783+ * used in preference.)
2784+ */
2785+ AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08,
2786+};
2787+
2788+typedef struct AVCodecHWConfig {
2789+ /**
2790+ * A hardware pixel format which the codec can use.
2791+ */
2792+ enum AVPixelFormat pix_fmt;
2793+ /**
2794+ * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible
2795+ * setup methods which can be used with this configuration.
2796+ */
2797+ int methods;
2798+ /**
2799+ * The device type associated with the configuration.
2800+ *
2801+ * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and
2802+ * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.
2803+ */
2804+ enum AVHWDeviceType device_type;
2805+} AVCodecHWConfig;
2806+
27512807 typedef struct AVCodecDefault AVCodecDefault;
27522808
27532809 struct AVSubtitle;
@@ -2884,8 +2940,26 @@ typedef struct AVCodec { · 130 unmodified lines
28842940 * packets before decoding.
28852941 */
28862942 const char *bsfs;
2943+
2944+ /**
2945+ * Array of pointers to hardware configurations supported by the codec,
2946+ * or NULL if no hardware supported. The array is terminated by a NULL
2947+ * pointer.
2948+ *
2949+ * The user can only access this field via avcodec_get_hw_config().
2950+ */
2951+ const struct AVCodecHWConfigInternal **hw_configs;
28872952 } AVCodec;
28882953
2954+/**
2955+ * Retrieve supported hardware configurations for a codec.
2956+ *
2957+ * Values of index from zero to some maximum return the indexed configuration
2958+ * descriptor; all other values return NULL. If the codec does not support
2959+ * any hardware configurations then it will always return NULL.
2960+ */
2961+const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);
2962+
28892963 /**
28902964 * @defgroup lavc_hwaccel AVHWAccel
28912965 * @{
libavcodec/hwaccel.h+18−0
@@ -19,6 +19,24 @@ · 18 unmodified lines
1919 #ifndef AVCODEC_HWACCEL_H
2020 #define AVCODEC_HWACCEL_H
2121
22+#include "avcodec.h"
23+
24+
2225 #define HWACCEL_CAP_ASYNC_SAFE (1 << 0)
2326
27+
28+typedef struct AVCodecHWConfigInternal {
29+ /**
30+ * This is the structure which will be returned to the user by
31+ * avcodec_get_hw_config().
32+ */
33+ AVCodecHWConfig public;
34+ /**
35+ * If this configuration uses a hwaccel, a pointer to it.
36+ * If not, NULL.
37+ */
38+ const AVHWAccel *hwaccel;
39+} AVCodecHWConfigInternal;
40+
41+
2442 #endif /* AVCODEC_HWACCEL_H */
libavcodec/utils.c+12−0
@@ -41,6 +41,7 @@ · 40 unmodified lines
4141 #include "libavutil/dict.h"
4242 #include "avcodec.h"
4343 #include "decode.h"
44+#include "hwaccel.h"
4445 #include "libavutil/opt.h"
4546 #include "me_cmp.h"
4647 #include "mpegvideo.h"
@@ -1335,6 +1336,17 @@ int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b) · 1288 unmodified lines
13351336 return i;
13361337 }
13371338
1339+const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index)
1340+{
1341+ int i;
1342+ if (!codec->hw_configs || index < 0)
1343+ return NULL;
1344+ for (i = 0; i <= index; i++)
1345+ if (!codec->hw_configs[i])
1346+ return NULL;
1347+ return &codec->hw_configs[index]->public;
1348+}
1349+
13381350 static AVHWAccel *first_hwaccel = NULL;
13391351
13401352 void av_register_hwaccel(AVHWAccel *hwaccel)
libavcodec/version.h+1−1
@@ -28,7 +28,7 @@ · 27 unmodified lines
2828 #include "libavutil/version.h"
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 58
31−#define LIBAVCODEC_VERSION_MINOR 5
31+#define LIBAVCODEC_VERSION_MINOR 6
3232 #define LIBAVCODEC_VERSION_MICRO 0
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t