mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 01:02:39 +08:00
[mpp]: change mpi_get_frame return value meaning:
return MPP_NOK means flow error return MPP_OK does not mean there is available frame, need to check the MppFrame pointer [mpp_dec_test]: reduce buffer size on reading to avoid one packet multiple frame input. git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@930 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -128,28 +128,35 @@ RK_S32 VpuApi::decode(VpuCodecContext *ctx, VideoPacket_t *pkt, DecoderOut_t *aD
|
|||||||
|
|
||||||
RK_S32 VpuApi::decode_sendstream(VideoPacket_t *pkt)
|
RK_S32 VpuApi::decode_sendstream(VideoPacket_t *pkt)
|
||||||
{
|
{
|
||||||
//mpp_log_f("in\n");
|
RK_S32 ret;
|
||||||
MppPacket mpkt = NULL;
|
MppPacket mpkt = NULL;
|
||||||
|
|
||||||
mpp_packet_init(&mpkt, pkt->data, pkt->size);
|
mpp_packet_init(&mpkt, pkt->data, pkt->size);
|
||||||
mpp_packet_set_pts(mpkt, pkt->pts);
|
mpp_packet_set_pts(mpkt, pkt->pts);
|
||||||
if (pkt->nFlags & OMX_BUFFERFLAG_EOS) {
|
if (pkt->nFlags & OMX_BUFFERFLAG_EOS) {
|
||||||
mpp_err("decode_sendstream set eos");
|
mpp_log("decode_sendstream set eos");
|
||||||
mpp_packet_set_eos(mpkt);
|
mpp_packet_set_eos(mpkt);
|
||||||
}
|
}
|
||||||
if (mpi->decode_put_packet(mpp_ctx, mpkt) == MPP_OK) {
|
|
||||||
|
ret = mpi->decode_put_packet(mpp_ctx, mpkt);
|
||||||
|
|
||||||
|
if (ret == MPP_OK) {
|
||||||
pkt->size = 0;
|
pkt->size = 0;
|
||||||
|
} else {
|
||||||
|
mpp_err("decode_put_packet ret %d\n", ret);
|
||||||
}
|
}
|
||||||
mpp_packet_deinit(&mpkt);
|
mpp_packet_deinit(&mpkt);
|
||||||
// mpp_log_f("ok\n");
|
return ret;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
||||||
{
|
{
|
||||||
// mpp_log_f("in\n");
|
RK_S32 ret = 0;
|
||||||
VPU_FRAME *vframe = (VPU_FRAME *)aDecOut->data;
|
VPU_FRAME *vframe = (VPU_FRAME *)aDecOut->data;
|
||||||
memset(vframe, 0, sizeof(VPU_FRAME));
|
|
||||||
MppFrame mframe = NULL;
|
MppFrame mframe = NULL;
|
||||||
|
|
||||||
|
memset(vframe, 0, sizeof(VPU_FRAME));
|
||||||
|
|
||||||
if (NULL == mpi) {
|
if (NULL == mpi) {
|
||||||
aDecOut->size = 0;
|
aDecOut->size = 0;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -158,7 +165,11 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
|||||||
aDecOut->size = 0;
|
aDecOut->size = 0;
|
||||||
return VPU_API_EOS_STREAM_REACHED;
|
return VPU_API_EOS_STREAM_REACHED;
|
||||||
}
|
}
|
||||||
if (MPP_OK == mpi->decode_get_frame(mpp_ctx, &mframe)) {
|
|
||||||
|
ret = mpi->decode_get_frame(mpp_ctx, &mframe);
|
||||||
|
if (ret || NULL == mframe) {
|
||||||
|
aDecOut->size = 0;
|
||||||
|
} else {
|
||||||
MppBuffer buf = NULL;
|
MppBuffer buf = NULL;
|
||||||
RK_U64 pts = 0;
|
RK_U64 pts = 0;
|
||||||
RK_U32 fd = 0;
|
RK_U32 fd = 0;
|
||||||
@@ -268,12 +279,9 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
|||||||
*/
|
*/
|
||||||
mpp_frame_set_buffer(mframe, NULL);
|
mpp_frame_set_buffer(mframe, NULL);
|
||||||
mpp_frame_deinit(&mframe);
|
mpp_frame_deinit(&mframe);
|
||||||
} else {
|
|
||||||
aDecOut->size = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mpp_log_f("ok\n");
|
return ret;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RK_S32 VpuApi::encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, EncoderOut_t *aEncOut)
|
RK_S32 VpuApi::encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, EncoderOut_t *aEncOut)
|
||||||
|
@@ -226,10 +226,9 @@ MPP_RET Mpp::get_frame(MppFrame *frame)
|
|||||||
prev = next;
|
prev = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*frame = first;
|
|
||||||
return MPP_OK;
|
|
||||||
}
|
}
|
||||||
return MPP_NOK;
|
*frame = first;
|
||||||
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET Mpp::put_frame(MppFrame frame)
|
MPP_RET Mpp::put_frame(MppFrame frame)
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#define MPI_DEC_LOOP_COUNT 4
|
#define MPI_DEC_LOOP_COUNT 4
|
||||||
#define MPI_STREAM_SIZE (SZ_512K)
|
#define MPI_DEC_STREAM_SIZE (SZ_64K)
|
||||||
#define MAX_FILE_NAME_LENGTH 256
|
#define MAX_FILE_NAME_LENGTH 256
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -81,8 +81,9 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
|
|||||||
|
|
||||||
// resources
|
// resources
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
size_t packet_size = MPI_STREAM_SIZE;
|
size_t packet_size = MPI_DEC_STREAM_SIZE;
|
||||||
size_t read_size = 0;
|
size_t read_size = 0;
|
||||||
|
RK_U32 frame_count = 0;
|
||||||
|
|
||||||
mpp_log("mpi_dec_test start\n");
|
mpp_log("mpi_dec_test start\n");
|
||||||
|
|
||||||
@@ -141,7 +142,6 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
|
|||||||
|
|
||||||
while (!found_eos) {
|
while (!found_eos) {
|
||||||
read_size = fread(buf, 1, packet_size, fp_input);
|
read_size = fread(buf, 1, packet_size, fp_input);
|
||||||
mpp_log("read packet length %u\n", read_size);
|
|
||||||
if (read_size != packet_size || feof(fp_input)) {
|
if (read_size != packet_size || feof(fp_input)) {
|
||||||
mpp_log("found last packet\n");
|
mpp_log("found last packet\n");
|
||||||
found_eos = 1;
|
found_eos = 1;
|
||||||
@@ -157,6 +157,7 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
|
|||||||
|
|
||||||
ret = mpi->decode_put_packet(ctx, packet);
|
ret = mpi->decode_put_packet(ctx, packet);
|
||||||
if (MPP_OK != ret) {
|
if (MPP_OK != ret) {
|
||||||
|
mpp_err("decode_put_packet failed ret %d\n", ret);
|
||||||
goto MPP_TEST_OUT;
|
goto MPP_TEST_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +165,7 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
|
|||||||
|
|
||||||
ret = mpi->decode_get_frame(ctx, &frame);
|
ret = mpi->decode_get_frame(ctx, &frame);
|
||||||
if (MPP_OK != ret) {
|
if (MPP_OK != ret) {
|
||||||
|
mpp_err("decode_get_frame failed ret %d\n", ret);
|
||||||
goto MPP_TEST_OUT;
|
goto MPP_TEST_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,6 +174,7 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
|
|||||||
mpp_log("decode_get_frame get info changed found\n");
|
mpp_log("decode_get_frame get info changed found\n");
|
||||||
mpi->control(ctx, MPP_CODEC_SET_INFO_CHANGE_READY, NULL);
|
mpi->control(ctx, MPP_CODEC_SET_INFO_CHANGE_READY, NULL);
|
||||||
} else {
|
} else {
|
||||||
|
mpp_log("decode_get_frame get frame %d\n", frame_count++);
|
||||||
if (fp_output)
|
if (fp_output)
|
||||||
dump_mpp_frame_to_file(frame, fp_output);
|
dump_mpp_frame_to_file(frame, fp_output);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user