History

vaapi_encode: Pass framerate parameters to driver

Only do this when building for a recent VAAPI version - initial driver implementations were confused about the interpretation of the framerate field, but hopefully this will be consistent everywhere once 0.40.0 is released. (cherry picked from commit ff35aa8ca4069bf1543adeec4c28e51e4a012eee)

Mark Thompson committed 9 years ago

Commit be6546a1 parent 2201c022 files · +22 −0Browse files

Unified · Split

2 files
  1. libavcodec/vaapi_encode.c +18 −0
  2. libavcodec/vaapi_encode.h +4 −0
libavcodec/vaapi_encode.c+18−0
@@ -1116,6 +1116,7 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) · 1115 unmodified lines
1116 int rc_window_size;1116 int rc_window_size;
1117 int hrd_buffer_size;1117 int hrd_buffer_size;
1118 int hrd_initial_buffer_fullness;1118 int hrd_initial_buffer_fullness;
1119 int fr_num, fr_den;
1119 1120
1120 if (avctx->bit_rate > INT32_MAX) {1121 if (avctx->bit_rate > INT32_MAX) {
1121 av_log(avctx, AV_LOG_ERROR, "Target bitrate of 2^31 bps or "1122 av_log(avctx, AV_LOG_ERROR, "Target bitrate of 2^31 bps or "
@@ -1172,6 +1173,23 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) · 50 unmodified lines
1172 ctx->global_params_size[ctx->nb_global_params++] =1173 ctx->global_params_size[ctx->nb_global_params++] =
1173 sizeof(ctx->hrd_params);1174 sizeof(ctx->hrd_params);
1174 1175
1176 if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
1177 av_reduce(&fr_num, &fr_den,
1178 avctx->framerate.num, avctx->framerate.den, 65535);
1179 else
1180 av_reduce(&fr_num, &fr_den,
1181 avctx->time_base.den, avctx->time_base.num, 65535);
1182
1183 ctx->fr_params.misc.type = VAEncMiscParameterTypeFrameRate;
1184 ctx->fr_params.fr.framerate = (unsigned int)fr_den << 16 | fr_num;
1185
1186#if VA_CHECK_VERSION(0, 40, 0)
1187 ctx->global_params[ctx->nb_global_params] =
1188 &ctx->fr_params.misc;
1189 ctx->global_params_size[ctx->nb_global_params++] =
1190 sizeof(ctx->fr_params);
1191#endif
1192
1175 return 0;1193 return 0;
1176}1194}
1177 1195
libavcodec/vaapi_encode.h+4−0
@@ -155,6 +155,10 @@ typedef struct VAAPIEncodeContext { · 154 unmodified lines
155 VAEncMiscParameterBuffer misc;155 VAEncMiscParameterBuffer misc;
156 VAEncMiscParameterHRD hrd;156 VAEncMiscParameterHRD hrd;
157 } hrd_params;157 } hrd_params;
158 struct {
159 VAEncMiscParameterBuffer misc;
160 VAEncMiscParameterFrameRate fr;
161 } fr_params;
158 162
159 // Per-sequence parameter structure (VAEncSequenceParameterBuffer*).163 // Per-sequence parameter structure (VAEncSequenceParameterBuffer*).
160 void *codec_sequence_params;164 void *codec_sequence_params;

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