| 129 | }; |
| 130 | |
| 131 | static int qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame, |
| 132 | AVBufferPool *pool) |
| 133 | { |
| 134 | int ret = 0; |
| 135 | |
| 136 | ret = ff_decode_frame_props(avctx, frame); |
| 137 | if (ret < 0) |
| 138 | return ret; |
| 139 | |
| 140 | frame->width = avctx->coded_width; |
| 141 | frame->height = avctx->coded_height; |
| 142 | |
| 143 | switch (avctx->pix_fmt) { |
| 144 | case AV_PIX_FMT_NV12: |
| 145 | frame->linesize[0] = FFALIGN(avctx->coded_width, 128); |
| 146 | break; |
| 147 | case AV_PIX_FMT_P010: |
| 148 | case AV_PIX_FMT_P012: |
| 149 | case AV_PIX_FMT_YUYV422: |
| 150 | frame->linesize[0] = 2 * FFALIGN(avctx->coded_width, 128); |
| 151 | break; |
| 152 | case AV_PIX_FMT_Y210: |
| 153 | case AV_PIX_FMT_VUYX: |
| 154 | case AV_PIX_FMT_XV30: |
| 155 | case AV_PIX_FMT_Y212: |
| 156 | frame->linesize[0] = 4 * FFALIGN(avctx->coded_width, 128); |
| 157 | break; |
| 158 | case AV_PIX_FMT_XV36: |
| 159 | frame->linesize[0] = 8 * FFALIGN(avctx->coded_width, 128); |
| 160 | break; |
| 161 | default: |
| 162 | av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n"); |
| 163 | return AVERROR(EINVAL); |
| 164 | } |
| 165 | |
| 166 | frame->buf[0] = av_buffer_pool_get(pool); |
| 167 | if (!frame->buf[0]) |
| 168 | return AVERROR(ENOMEM); |
| 169 | |
| 170 | frame->data[0] = frame->buf[0]->data; |
| 171 | if (avctx->pix_fmt == AV_PIX_FMT_NV12 || |
| 172 | avctx->pix_fmt == AV_PIX_FMT_P010 || |
| 173 | avctx->pix_fmt == AV_PIX_FMT_P012) { |
| 174 | frame->linesize[1] = frame->linesize[0]; |
| 175 | frame->data[1] = frame->data[0] + |
| 176 | frame->linesize[0] * FFALIGN(avctx->coded_height, 64); |
| 177 | } |
| 178 | |
| 179 | ret = ff_attach_decode_data(frame); |
| 180 | if (ret < 0) |
| 181 | return ret; |
| 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession session, |
| 187 | AVBufferRef *hw_frames_ref, AVBufferRef *hw_device_ref) |
no test coverage detected