Skip to content

Commit

Permalink
add prefix to VAAPI specific options
Browse files Browse the repository at this point in the history
- low power is VAAPI specific\
- compression level is codec/encoder dependent
  - clarify above and VAAPI meaning

Implements #38
  • Loading branch information
bmegli committed Jan 17, 2023
1 parent 329369e commit 6fdc9e0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ There are just 4 functions and 3 user-visible data types:
```C
struct hve_config hardware_config = {WIDTH, HEIGHT, INPUT_WIDTH, INPUT_HEIGHT, FRAMERATE,
DEVICE, ENCODER, PIXEL_FORMAT, PROFILE, BFRAMES,
BITRATE, QP, GOP_SIZE, COMPRESSION_LEVEL, LOW_POWER};
BITRATE, QP, GOP_SIZE, COMPRESSION_LEVEL, VAAPI_LOW_POWER};

struct hve *hardware_encoder=hve_init(&hardware_config);
struct hve_frame frame = { 0 };
Expand Down
4 changes: 2 additions & 2 deletions examples/hve_encode_raw_h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const int BITRATE=0; //average bitrate in VBR mode (bit_rate != 0 and qp == 0)
const int QP=0; //quantization parameter in CQP mode (qp != 0 and bit_rate == 0)
const int GOP_SIZE=0; //group of pictures size, 0 for default (determines keyframe period)
const int COMPRESSION_LEVEL=0; //speed-quality tradeoff, 0 for default, 1 for the highest quality, 7 for the fastest
const int LOW_POWER=0; //alternative limited low-power encoding path if non-zero
const int VAAPI_LOW_POWER=0; //alternative VAAPI limited low-power encoding path if non-zero

int encoding_loop(struct hve *hardware_encoder, FILE *output_file);
int process_user_input(int argc, char* argv[]);
Expand All @@ -45,7 +45,7 @@ int main(int argc, char* argv[])
//prepare library data
struct hve_config hardware_config = {WIDTH, HEIGHT, INPUT_WIDTH, INPUT_HEIGHT, FRAMERATE,
DEVICE, ENCODER, PIXEL_FORMAT, PROFILE, BFRAMES,
BITRATE, QP, GOP_SIZE, COMPRESSION_LEVEL, LOW_POWER};
BITRATE, QP, GOP_SIZE, COMPRESSION_LEVEL, VAAPI_LOW_POWER};
struct hve *hardware_encoder;

//prepare file for raw H.264 output
Expand Down
4 changes: 2 additions & 2 deletions examples/hve_encode_raw_hevc10.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const int BITRATE=0; //average bitrate in VBR mode (bit_rate != 0 and qp == 0)
const int QP=0; //quantization parameter in CQP mode (qp != 0 and bit_rate == 0)
const int GOP_SIZE=0; //group of pictures size, 0 for default (determines keyframe period)
const int COMPRESSION_LEVEL=0; //speed-quality tradeoff, 0 for default, 1 for the highest quality, 7 for the fastest
const int LOW_POWER=0; //alternative limited low-power encoding path if non-zero
const int VAAPI_LOW_POWER=0; //alternative VAAPI limited low-power encoding path if non-zero

int encoding_loop(struct hve *hardware_encoder, FILE *output_file);
int process_user_input(int argc, char* argv[]);
Expand All @@ -45,7 +45,7 @@ int main(int argc, char* argv[])
//prepare library data
struct hve_config hardware_config = {WIDTH, HEIGHT, INPUT_WIDTH, INPUT_HEIGHT, FRAMERATE,
DEVICE, ENCODER, PIXEL_FORMAT, PROFILE, BFRAMES,
BITRATE, QP, GOP_SIZE, COMPRESSION_LEVEL, LOW_POWER};
BITRATE, QP, GOP_SIZE, COMPRESSION_LEVEL, VAAPI_LOW_POWER};
struct hve *hardware_encoder;

//prepare file for raw HEVC output
Expand Down
2 changes: 1 addition & 1 deletion hve.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct hve *hve_init(const struct hve_config *config)
if(config->qp && av_dict_set_int(&opts, "qp", config->qp, 0) < 0)
return hve_close_and_return_null(h, "failed to initialize option dictionary (qp)");

if(config->low_power && av_dict_set_int(&opts, "low_power", config->low_power != 0, 0) < 0)
if(config->vaapi_low_power && av_dict_set_int(&opts, "low_power", config->vaapi_low_power != 0, 0) < 0)
return hve_close_and_return_null(h, "failed to initialize option dictionary (low_power)");

if((err = avcodec_open2(h->avctx, codec, &opts)) < 0)
Expand Down
9 changes: 5 additions & 4 deletions hve.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,13 @@ struct hve;
* Setting gop_size equal to framerate results in one keyframe per second.
* Use 0 value for default, -1 for intra only.
*
* The compression_level (VAAPI specific) is speed-quality trade-off. Use 0 for driver default.
* The compression_level is codec/encoder specific
* For VAAPI it is speed-quality trade-off. Use 0 for driver default.
* For highest quality use 1, for fastest encoding use 7.
* The default is not highest quality so if you need it, set it explicitly to 1.
* The exact interpretation is hardware dependent.
*
* The low_power (VAAPI specific) enables alternative encoding path available on some Intel platforms.
* The vaapi_low_power (VAAPI specific) enables alternative encoding path available on some Intel platforms.
*
* You may check support with vainfo (entrypoints ending with LP):
* @code
Expand Down Expand Up @@ -172,8 +173,8 @@ struct hve_config
int bit_rate; //!< average bitrate in VBR mode (bit_rate != 0 and qp == 0)
int qp; //!< quantization parameter in CQP mode (qp != 0 and bit_rate == 0)
int gop_size; //!< group of pictures size, 0 for default, -1 for intra only
int compression_level; //!< speed-quality tradeoff, 0 for default, 1 for the highest quality, 7 for the fastest (VAAPI specific)
int low_power; //!< alternative limited low-power encoding if non-zero (VAAPI specific)
int compression_level; //!< encoder/codec dependent, 0 for default, for VAAPI 1-7 speed-quality tradeoff, 1 highest quality, 7 fastest
int vaapi_low_power; //!< VAAPI specific alternative limited low-power encoding if non-zero
};

/**
Expand Down

0 comments on commit 6fdc9e0

Please sign in to comment.