| 237 | } |
| 238 | |
| 239 | static int amf_init_frames_context(AVCodecContext *avctx, int sw_format, int new_width, int new_height) |
| 240 | { |
| 241 | int ret; |
| 242 | AVHWDeviceContext *hwdev_ctx; |
| 243 | AVHWFramesContext *hwframes_ctx; |
| 244 | AMFDecoderContext *ctx; |
| 245 | if (!avctx->hw_frames_ctx || !avctx->hw_device_ctx) |
| 246 | return 0; |
| 247 | hwdev_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data; |
| 248 | hwframes_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; |
| 249 | ctx = avctx->priv_data; |
| 250 | |
| 251 | if (hwdev_ctx->type != AV_HWDEVICE_TYPE_AMF) |
| 252 | return 0; |
| 253 | |
| 254 | hwframes_ctx->width = new_width; |
| 255 | hwframes_ctx->height = new_height; |
| 256 | hwframes_ctx->format = AV_PIX_FMT_AMF_SURFACE; |
| 257 | hwframes_ctx->sw_format = sw_format; |
| 258 | hwframes_ctx->initial_pool_size = ctx->surface_pool_size + 8; |
| 259 | |
| 260 | ret = av_hwframe_ctx_init(avctx->hw_frames_ctx); |
| 261 | if (ret < 0) { |
| 262 | av_log(NULL, AV_LOG_ERROR, "Error initializing a AMF frame pool\n"); |
| 263 | av_buffer_unref(&avctx->hw_frames_ctx); |
| 264 | return ret; |
| 265 | } |
| 266 | return 0; |
| 267 | } |
| 268 | |
| 269 | static int amf_decode_init(AVCodecContext *avctx) |
| 270 | { |
no test coverage detected