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
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182017-11-xx - xxxxxxx - lavc 58.4.100 - avcodec.h
19 Add AVCodecHWConfig and avcodec_get_hw_config().
20
182017-11-22 - 3650cb2dfa - lavu 55.3.100 - opencl.h212017-11-22 - 3650cb2dfa - lavu 55.3.100 - opencl.h
19 Remove experimental OpenCL API (av_opencl_*).22 Remove experimental OpenCL API (av_opencl_*).
20 23
libavcodec/avcodec.h+74−0
@@ -36,6 +36,7 @@ · 35 unmodified lines
36#include "libavutil/channel_layout.h"36#include "libavutil/channel_layout.h"
37#include "libavutil/dict.h"37#include "libavutil/dict.h"
38#include "libavutil/frame.h"38#include "libavutil/frame.h"
39#include "libavutil/hwcontext.h"
39#include "libavutil/log.h"40#include "libavutil/log.h"
40#include "libavutil/pixfmt.h"41#include "libavutil/pixfmt.h"
41#include "libavutil/rational.h"42#include "libavutil/rational.h"
@@ -3279,6 +3280,61 @@ typedef struct AVProfile { · 3237 unmodified lines
3279 const char *name; ///< short name for the profile3280 const char *name; ///< short name for the profile
3280} AVProfile;3281} AVProfile;
3281 3282
3283enum {
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
3319typedef 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
3282typedef struct AVCodecDefault AVCodecDefault;3338typedef struct AVCodecDefault AVCodecDefault;
3283 3339
3284struct AVSubtitle;3340struct AVSubtitle;
@@ -3404,6 +3460,15 @@ typedef struct AVCodec { · 119 unmodified lines
3404 * packets before decoding.3460 * packets before decoding.
3405 */3461 */
3406 const char *bsfs;3462 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;
3407} AVCodec;3472} AVCodec;
3408 3473
3409#if FF_API_CODEC_GET_SET3474#if FF_API_CODEC_GET_SET
@@ -3413,6 +3478,15 @@ int av_codec_get_max_lowres(const AVCodec *codec); · 3 unmodified lines
3413 3478
3414struct MpegEncContext;3479struct MpegEncContext;
3415 3480
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 */
3488const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);
3489
3416/**3490/**
3417 * @defgroup lavc_hwaccel AVHWAccel3491 * @defgroup lavc_hwaccel AVHWAccel
3418 * @{3492 * @{
libavcodec/hwaccel.h+18−0
@@ -19,6 +19,24 @@ · 18 unmodified lines
19#ifndef AVCODEC_HWACCEL_H19#ifndef AVCODEC_HWACCEL_H
20#define AVCODEC_HWACCEL_H20#define AVCODEC_HWACCEL_H
21 21
22#include "avcodec.h"
23
24
22#define HWACCEL_CAP_ASYNC_SAFE (1 << 0)25#define HWACCEL_CAP_ASYNC_SAFE (1 << 0)
23 26
27
28typedef 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
24#endif /* AVCODEC_HWACCEL_H */42#endif /* AVCODEC_HWACCEL_H */
libavcodec/utils.c+12−0
@@ -45,6 +45,7 @@ · 44 unmodified lines
45#include "libavutil/thread.h"45#include "libavutil/thread.h"
46#include "avcodec.h"46#include "avcodec.h"
47#include "decode.h"47#include "decode.h"
48#include "hwaccel.h"
48#include "libavutil/opt.h"49#include "libavutil/opt.h"
49#include "me_cmp.h"50#include "me_cmp.h"
50#include "mpegvideo.h"51#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
1886 return i;1887 return i;
1887}1888}
1888 1889
1890const 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
1889static AVHWAccel *first_hwaccel = NULL;1901static AVHWAccel *first_hwaccel = NULL;
1890static AVHWAccel **last_hwaccel = &first_hwaccel;1902static AVHWAccel **last_hwaccel = &first_hwaccel;
1891 1903
libavcodec/version.h+2−2
@@ -28,8 +28,8 @@ · 27 unmodified lines
28#include "libavutil/version.h"28#include "libavutil/version.h"
29 29
30#define LIBAVCODEC_VERSION_MAJOR 5830#define LIBAVCODEC_VERSION_MAJOR 58
31#define LIBAVCODEC_VERSION_MINOR 331#define LIBAVCODEC_VERSION_MINOR 4
32#define LIBAVCODEC_VERSION_MICRO 10532#define LIBAVCODEC_VERSION_MICRO 100
33 33
34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
35 LIBAVCODEC_VERSION_MINOR, \35 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