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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162017-xx-xx - xxxxxxx - lavc 58.6.0 - avcodec.h
17 Add AVCodecHWConfig and avcodec_get_hw_config().
18
162017-xx-xx - xxxxxxx - lavu 56.7.0 - stereo3d.h192017-xx-xx - xxxxxxx - lavu 56.7.0 - stereo3d.h
17 Add view field to AVStereo3D structure and AVStereo3DView enum.20 Add view field to AVStereo3D structure and AVStereo3DView enum.
18 21
libavcodec/avcodec.h+74−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
35#include "libavutil/cpu.h"35#include "libavutil/cpu.h"
36#include "libavutil/dict.h"36#include "libavutil/dict.h"
37#include "libavutil/frame.h"37#include "libavutil/frame.h"
38#include "libavutil/hwcontext.h"
38#include "libavutil/log.h"39#include "libavutil/log.h"
39#include "libavutil/pixfmt.h"40#include "libavutil/pixfmt.h"
40#include "libavutil/rational.h"41#include "libavutil/rational.h"
@@ -2748,6 +2749,61 @@ typedef struct AVProfile { · 2707 unmodified lines
2748 const char *name; ///< short name for the profile2749 const char *name; ///< short name for the profile
2749} AVProfile;2750} AVProfile;
2750 2751
2752enum {
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
2788typedef 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
2751typedef struct AVCodecDefault AVCodecDefault;2807typedef struct AVCodecDefault AVCodecDefault;
2752 2808
2753struct AVSubtitle;2809struct AVSubtitle;
@@ -2884,8 +2940,26 @@ typedef struct AVCodec { · 130 unmodified lines
2884 * packets before decoding.2940 * packets before decoding.
2885 */2941 */
2886 const char *bsfs;2942 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;
2887} AVCodec;2952} AVCodec;
2888 2953
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 */
2961const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);
2962
2889/**2963/**
2890 * @defgroup lavc_hwaccel AVHWAccel2964 * @defgroup lavc_hwaccel AVHWAccel
2891 * @{2965 * @{
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
@@ -41,6 +41,7 @@ · 40 unmodified lines
41#include "libavutil/dict.h"41#include "libavutil/dict.h"
42#include "avcodec.h"42#include "avcodec.h"
43#include "decode.h"43#include "decode.h"
44#include "hwaccel.h"
44#include "libavutil/opt.h"45#include "libavutil/opt.h"
45#include "me_cmp.h"46#include "me_cmp.h"
46#include "mpegvideo.h"47#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
1335 return i;1336 return i;
1336}1337}
1337 1338
1339const 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
1338static AVHWAccel *first_hwaccel = NULL;1350static AVHWAccel *first_hwaccel = NULL;
1339 1351
1340void av_register_hwaccel(AVHWAccel *hwaccel)1352void av_register_hwaccel(AVHWAccel *hwaccel)
libavcodec/version.h+1−1
@@ -28,7 +28,7 @@ · 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 531#define LIBAVCODEC_VERSION_MINOR 6
32#define LIBAVCODEC_VERSION_MICRO 032#define LIBAVCODEC_VERSION_MICRO 0
33 33
34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \34#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