History

lavc: Add codec metadata to indicate hardware support

Mark Thompson committed 9 years ago

Commit 24cc0a51 parent 2779d335 files · +109 −2Browse 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 +2 −2
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2017-11-xx - xxxxxxx - lavc 58.4.100 - avcodec.h
19+ Add AVCodecHWConfig and avcodec_get_hw_config().
20+
1821 2017-11-22 - 3650cb2dfa - lavu 55.3.100 - opencl.h
1922 Remove experimental OpenCL API (av_opencl_*).
2023
libavcodec/avcodec.h+74−0
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #include "libavutil/channel_layout.h"
3737 #include "libavutil/dict.h"
3838 #include "libavutil/frame.h"
39+#include "libavutil/hwcontext.h"
3940 #include "libavutil/log.h"
4041 #include "libavutil/pixfmt.h"
4142 #include "libavutil/rational.h"
@@ -3279,6 +3280,61 @@ typedef struct AVProfile { · 3237 unmodified lines
32793280 const char *name; ///< short name for the profile
32803281 } AVProfile;
32813282
3283+enum {
3284+ /**
3285+ * The codec supports this format via the hw_device_ctx interface.
3286+ *
3287+ * When selecting this format, AVCodecContext.hw_device_ctx should
3288+ * have been set to a device of the specified type before calling
3289+ * avcodec_open2().
3290+ */
3291+ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,
3292+ /**
3293+ * The codec supports this format via the hw_frames_ctx interface.
3294+ *
3295+ * When selecting this format for a decoder,
3296+ * AVCodecContext.hw_frames_ctx should be set to a suitable frames
3297+ * context inside the get_format() callback. The frames context
3298+ * must have been created on a device of the specified type.
3299+ */
3300+ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,
3301+ /**
3302+ * The codec supports this format by some internal method.
3303+ *
3304+ * This format can be selected without any additional configuration -
3305+ * no device or frames context is required.
3306+ */
3307+ AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04,
3308+ /**
3309+ * The codec supports this format by some ad-hoc method.
3310+ *
3311+ * Additional settings and/or function calls are required. See the
3312+ * codec-specific documentation for details. (Methods requiring
3313+ * this sort of configuration are deprecated and others should be
3314+ * used in preference.)
3315+ */
3316+ AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08,
3317+};
3318+
3319+typedef struct AVCodecHWConfig {
3320+ /**
3321+ * A hardware pixel format which the codec can use.
3322+ */
3323+ enum AVPixelFormat pix_fmt;
3324+ /**
3325+ * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible
3326+ * setup methods which can be used with this configuration.
3327+ */
3328+ int methods;
3329+ /**
3330+ * The device type associated with the configuration.
3331+ *
3332+ * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and
3333+ * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.
3334+ */
3335+ enum AVHWDeviceType device_type;
3336+} AVCodecHWConfig;
3337+
32823338 typedef struct AVCodecDefault AVCodecDefault;
32833339
32843340 struct AVSubtitle;
@@ -3404,6 +3460,15 @@ typedef struct AVCodec { · 119 unmodified lines
34043460 * packets before decoding.
34053461 */
34063462 const char *bsfs;
3463+
3464+ /**
3465+ * Array of pointers to hardware configurations supported by the codec,
3466+ * or NULL if no hardware supported. The array is terminated by a NULL
3467+ * pointer.
3468+ *
3469+ * The user can only access this field via avcodec_get_hw_config().
3470+ */
3471+ const struct AVCodecHWConfigInternal **hw_configs;
34073472 } AVCodec;
34083473
34093474 #if FF_API_CODEC_GET_SET
@@ -3413,6 +3478,15 @@ int av_codec_get_max_lowres(const AVCodec *codec); · 3 unmodified lines
34133478
34143479 struct MpegEncContext;
34153480
3481+/**
3482+ * Retrieve supported hardware configurations for a codec.
3483+ *
3484+ * Values of index from zero to some maximum return the indexed configuration
3485+ * descriptor; all other values return NULL. If the codec does not support
3486+ * any hardware configurations then it will always return NULL.
3487+ */
3488+const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);
3489+
34163490 /**
34173491 * @defgroup lavc_hwaccel AVHWAccel
34183492 * @{
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
@@ -45,6 +45,7 @@ · 44 unmodified lines
4545 #include "libavutil/thread.h"
4646 #include "avcodec.h"
4747 #include "decode.h"
48+#include "hwaccel.h"
4849 #include "libavutil/opt.h"
4950 #include "me_cmp.h"
5051 #include "mpegvideo.h"
@@ -1886,6 +1887,17 @@ int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b) · 1835 unmodified lines
18861887 return i;
18871888 }
18881889
1890+const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index)
1891+{
1892+ int i;
1893+ if (!codec->hw_configs || index < 0)
1894+ return NULL;
1895+ for (i = 0; i <= index; i++)
1896+ if (!codec->hw_configs[i])
1897+ return NULL;
1898+ return &codec->hw_configs[index]->public;
1899+}
1900+
18891901 static AVHWAccel *first_hwaccel = NULL;
18901902 static AVHWAccel **last_hwaccel = &first_hwaccel;
18911903
libavcodec/version.h+2−2
@@ -28,8 +28,8 @@ · 27 unmodified lines
2828 #include "libavutil/version.h"
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 58
31−#define LIBAVCODEC_VERSION_MINOR 3
32−#define LIBAVCODEC_VERSION_MICRO 105
31+#define LIBAVCODEC_VERSION_MINOR 4
32+#define LIBAVCODEC_VERSION_MICRO 100
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3535 LIBAVCODEC_VERSION_MINOR, \

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