| 487 | } |
| 488 | |
| 489 | static int oh_decode_wrap_sw_buffer(AVCodecContext *avctx, AVFrame *frame, |
| 490 | OHBufferQueueItem *output, |
| 491 | const OH_AVCodecBufferAttr *attr) |
| 492 | { |
| 493 | OHCodecDecContext *s = avctx->priv_data; |
| 494 | |
| 495 | frame->format = avctx->pix_fmt; |
| 496 | frame->width = s->width; |
| 497 | frame->height = s->height; |
| 498 | int ret = ff_get_buffer(avctx, frame, 0); |
| 499 | if (ret < 0) |
| 500 | return ret; |
| 501 | |
| 502 | frame->pts = av_rescale_q(attr->pts, AV_TIME_BASE_Q, avctx->pkt_timebase); |
| 503 | frame->pkt_dts = AV_NOPTS_VALUE; |
| 504 | |
| 505 | uint8_t *p = OH_AVBuffer_GetAddr(output->buffer); |
| 506 | if (!p) { |
| 507 | av_log(avctx, AV_LOG_ERROR, "Failed to get output buffer addr\n"); |
| 508 | return AVERROR_EXTERNAL; |
| 509 | } |
| 510 | |
| 511 | uint8_t *src[4] = {0}; |
| 512 | int src_linesizes[4] = {0}; |
| 513 | |
| 514 | ret = av_image_fill_linesizes(src_linesizes, frame->format, s->stride); |
| 515 | if (ret < 0) |
| 516 | return ret; |
| 517 | ret = av_image_fill_pointers(src, frame->format, s->slice_height, p, |
| 518 | src_linesizes); |
| 519 | if (ret < 0) |
| 520 | return ret; |
| 521 | av_image_copy2(frame->data, frame->linesize, src, src_linesizes, |
| 522 | frame->format, frame->width, frame->height); |
| 523 | |
| 524 | OH_AVErrCode err = OH_VideoDecoder_FreeOutputBuffer(s->dec, output->index); |
| 525 | if (err != AV_ERR_OK) { |
| 526 | ret = ff_oh_err_to_ff_err(err); |
| 527 | av_log(avctx, AV_LOG_ERROR, "FreeOutputBuffer failed, %d, %s\n", err, |
| 528 | av_err2str(ret)); |
| 529 | return ret; |
| 530 | } |
| 531 | |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | static int oh_decode_output_frame(AVCodecContext *avctx, AVFrame *frame, |
| 536 | OHBufferQueueItem *output) |
no test coverage detected