| 524 | } |
| 525 | |
| 526 | static AMF_RESULT amf_buffer_from_packet(AVCodecContext *avctx, const AVPacket* pkt, AMFBuffer** buffer) |
| 527 | { |
| 528 | AMFDecoderContext *ctx = avctx->priv_data; |
| 529 | AVHWDeviceContext *hw_device_ctx = (AVHWDeviceContext*)ctx->device_ctx_ref->data; |
| 530 | AVAMFDeviceContext *amf_device_ctx = (AVAMFDeviceContext *)hw_device_ctx->hwctx; |
| 531 | AMFContext *ctxt = amf_device_ctx->context; |
| 532 | void *mem; |
| 533 | AMF_RESULT err; |
| 534 | AMFBuffer *buf = NULL; |
| 535 | |
| 536 | AMF_RETURN_IF_FALSE(ctxt, pkt != NULL, AMF_INVALID_ARG, "amf_buffer_from_packet() - packet not passed in"); |
| 537 | AMF_RETURN_IF_FALSE(ctxt, buffer != NULL, AMF_INVALID_ARG, "amf_buffer_from_packet() - buffer pointer not passed in"); |
| 538 | |
| 539 | err = ctxt->pVtbl->AllocBuffer(ctxt, AMF_MEMORY_HOST, pkt->size + AV_INPUT_BUFFER_PADDING_SIZE, buffer); |
| 540 | AMF_RETURN_IF_FALSE(ctxt, err == AMF_OK, err, "amf_buffer_from_packet() - failed"); |
| 541 | buf = *buffer; |
| 542 | err = buf->pVtbl->SetSize(buf, pkt->size); |
| 543 | AMF_RETURN_IF_FALSE(ctxt, err == AMF_OK, err, "amf_buffer_from_packet() - SetSize failed"); |
| 544 | // get the memory location and check the buffer was indeed allocated |
| 545 | mem = buf->pVtbl->GetNative(buf); |
| 546 | AMF_RETURN_IF_FALSE(ctxt, mem != NULL, AMF_INVALID_POINTER, "amf_buffer_from_packet() - GetNative failed"); |
| 547 | |
| 548 | // copy the packet memory and clear data padding |
| 549 | memcpy(mem, pkt->data, pkt->size); |
| 550 | memset((amf_int8*)(mem)+pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
| 551 | |
| 552 | return amf_update_buffer_properties(avctx, buf, pkt); |
| 553 | } |
| 554 | |
| 555 | static int amf_decode_frame(AVCodecContext *avctx, struct AVFrame *frame) |
| 556 | { |
no test coverage detected