| 779 | } |
| 780 | |
| 781 | int ff_hw_base_encode_init(AVCodecContext *avctx, FFHWBaseEncodeContext *ctx) |
| 782 | { |
| 783 | ctx->log_ctx = (void *)avctx; |
| 784 | |
| 785 | ctx->frame = av_frame_alloc(); |
| 786 | if (!ctx->frame) |
| 787 | return AVERROR(ENOMEM); |
| 788 | |
| 789 | if (!avctx->hw_frames_ctx) { |
| 790 | av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is " |
| 791 | "required to associate the encoding device.\n"); |
| 792 | return AVERROR(EINVAL); |
| 793 | } |
| 794 | |
| 795 | ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx); |
| 796 | if (!ctx->input_frames_ref) |
| 797 | return AVERROR(ENOMEM); |
| 798 | |
| 799 | ctx->input_frames = (AVHWFramesContext *)ctx->input_frames_ref->data; |
| 800 | |
| 801 | ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref); |
| 802 | if (!ctx->device_ref) |
| 803 | return AVERROR(ENOMEM); |
| 804 | |
| 805 | ctx->device = (AVHWDeviceContext *)ctx->device_ref->data; |
| 806 | |
| 807 | ctx->tail_pkt = av_packet_alloc(); |
| 808 | if (!ctx->tail_pkt) |
| 809 | return AVERROR(ENOMEM); |
| 810 | |
| 811 | return 0; |
| 812 | } |
| 813 | |
| 814 | int ff_hw_base_encode_close(FFHWBaseEncodeContext *ctx) |
| 815 | { |
no test coverage detected