| 251 | } |
| 252 | |
| 253 | int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags) |
| 254 | { |
| 255 | int ret; |
| 256 | |
| 257 | if (avctx->hw_frames_ctx) { |
| 258 | ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0); |
| 259 | if (ret == AVERROR(ENOMEM)) { |
| 260 | AVHWFramesContext *frames_ctx = |
| 261 | (AVHWFramesContext*)avctx->hw_frames_ctx->data; |
| 262 | if (frames_ctx->initial_pool_size > 0 && |
| 263 | !avctx->internal->warned_on_failed_allocation_from_fixed_pool) { |
| 264 | av_log(avctx, AV_LOG_WARNING, "Failed to allocate a %s/%s " |
| 265 | "frame from a fixed pool of hardware frames.\n", |
| 266 | av_get_pix_fmt_name(frames_ctx->format), |
| 267 | av_get_pix_fmt_name(frames_ctx->sw_format)); |
| 268 | av_log(avctx, AV_LOG_WARNING, "Consider setting " |
| 269 | "extra_hw_frames to a larger value " |
| 270 | "(currently set to %d, giving a pool size of %d).\n", |
| 271 | avctx->extra_hw_frames, frames_ctx->initial_pool_size); |
| 272 | avctx->internal->warned_on_failed_allocation_from_fixed_pool = 1; |
| 273 | } |
| 274 | } |
| 275 | frame->width = avctx->coded_width; |
| 276 | frame->height = avctx->coded_height; |
| 277 | return ret; |
| 278 | } |
| 279 | |
| 280 | if ((ret = update_frame_pool(avctx, frame)) < 0) |
| 281 | return ret; |
| 282 | |
| 283 | switch (avctx->codec_type) { |
| 284 | case AVMEDIA_TYPE_VIDEO: |
| 285 | return video_get_buffer(avctx, frame); |
| 286 | case AVMEDIA_TYPE_AUDIO: |
| 287 | return audio_get_buffer(avctx, frame); |
| 288 | default: |
| 289 | return -1; |
| 290 | } |
| 291 | } |
no test coverage detected