| 136 | } |
| 137 | |
| 138 | static int vaapi_encode_wait(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic) |
| 139 | { |
| 140 | #if VA_CHECK_VERSION(1, 9, 0) |
| 141 | FFHWBaseEncodeContext *base_ctx = avctx->priv_data; |
| 142 | #endif |
| 143 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 144 | VAAPIEncodePicture *pic = base_pic->priv; |
| 145 | VAStatus vas; |
| 146 | |
| 147 | av_assert0(base_pic->encode_issued); |
| 148 | |
| 149 | if (base_pic->encode_complete) { |
| 150 | // Already waited for this picture. |
| 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | av_log(avctx, AV_LOG_DEBUG, "Sync to pic %"PRId64"/%"PRId64" " |
| 155 | "(input surface %#x).\n", base_pic->display_order, |
| 156 | base_pic->encode_order, pic->input_surface); |
| 157 | |
| 158 | #if VA_CHECK_VERSION(1, 9, 0) |
| 159 | if (base_ctx->async_encode) { |
| 160 | vas = vaSyncBuffer(ctx->hwctx->display, |
| 161 | pic->output_buffer, |
| 162 | VA_TIMEOUT_INFINITE); |
| 163 | if (vas != VA_STATUS_SUCCESS) { |
| 164 | av_log(avctx, AV_LOG_ERROR, "Failed to sync to output buffer completion: " |
| 165 | "%d (%s).\n", vas, vaErrorStr(vas)); |
| 166 | return AVERROR(EIO); |
| 167 | } |
| 168 | } else |
| 169 | #endif |
| 170 | { // If vaSyncBuffer is not implemented, try old version API. |
| 171 | vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface); |
| 172 | if (vas != VA_STATUS_SUCCESS) { |
| 173 | av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: " |
| 174 | "%d (%s).\n", vas, vaErrorStr(vas)); |
| 175 | return AVERROR(EIO); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // Input is definitely finished with now. |
| 180 | av_frame_free(&base_pic->input_image); |
| 181 | |
| 182 | base_pic->encode_complete = 1; |
| 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | static int vaapi_encode_make_row_slice(AVCodecContext *avctx, |
| 187 | VAAPIEncodePicture *pic) |
no test coverage detected