diff --git a/inc/mpp_frame.h b/inc/mpp_frame.h index 4c4ebdf7..14f4ce78 100644 --- a/inc/mpp_frame.h +++ b/inc/mpp_frame.h @@ -137,7 +137,7 @@ extern "C" { * MppFrame interface */ MPP_RET mpp_frame_init(MppFrame *frame); -MPP_RET mpp_frame_deinit(MppFrame frame); +MPP_RET mpp_frame_deinit(MppFrame *frame); MppFrame mpp_frame_get_next(MppFrame frame); /* diff --git a/inc/mpp_packet.h b/inc/mpp_packet.h index 0bde962c..fd5577a7 100644 --- a/inc/mpp_packet.h +++ b/inc/mpp_packet.h @@ -33,7 +33,7 @@ extern "C" { */ MPP_RET mpp_packet_new(MppPacket *packet); MPP_RET mpp_packet_init(MppPacket *packet, void *data, size_t size); -MPP_RET mpp_packet_deinit(MppPacket packet); +MPP_RET mpp_packet_deinit(MppPacket *packet); void mpp_packet_set_data(MppPacket packet, void *data); diff --git a/mpp/mpp.cpp b/mpp/mpp.cpp index 0b556c24..f3d0e8e1 100644 --- a/mpp/mpp.cpp +++ b/mpp/mpp.cpp @@ -137,11 +137,10 @@ MPP_RET Mpp::put_packet(MppPacket packet) MPP_RET Mpp::get_frame(MppFrame *frame) { - MPP_RET ret = MPP_NOK; if (frames->list_size()) { - ret = (MPP_RET)frames->del_at_tail(frame, sizeof(frame)); + frames->del_at_tail(frame, sizeof(frame)); } - return ret; + return MPP_OK; } MPP_RET Mpp::put_frame(MppFrame frame) @@ -152,10 +151,9 @@ MPP_RET Mpp::put_frame(MppFrame frame) MPP_RET Mpp::get_packet(MppPacket *packet) { - MPP_RET ret = MPP_NOK; if (packets->list_size()) { - ret = (MPP_RET)packets->del_at_tail(packet, sizeof(packet)); + packets->del_at_tail(packet, sizeof(packet)); } - return ret; + return MPP_OK; } diff --git a/mpp/mpp_frame.cpp b/mpp/mpp_frame.cpp index 3809ec53..ae3fb94b 100644 --- a/mpp/mpp_frame.cpp +++ b/mpp/mpp_frame.cpp @@ -52,15 +52,15 @@ MPP_RET mpp_frame_init(MppFrame *frame) return MPP_OK; } -MPP_RET mpp_frame_deinit(MppFrame frame) +MPP_RET mpp_frame_deinit(MppFrame *frame) { - if (NULL == frame) { + if (NULL == frame || NULL == *frame) { mpp_err("mpp_frame_deinit invalid NULL pointer input\n"); return MPP_ERR_NULL_PTR; } - mpp_free(frame); - + mpp_free(*frame); + *frame = NULL; return MPP_OK; } diff --git a/mpp/mpp_packet.cpp b/mpp/mpp_packet.cpp index 8a89c78f..432746ef 100644 --- a/mpp/mpp_packet.cpp +++ b/mpp/mpp_packet.cpp @@ -51,14 +51,15 @@ MPP_RET mpp_packet_init(MppPacket *packet, void *data, size_t size) return MPP_OK; } -MPP_RET mpp_packet_deinit(MppPacket packet) +MPP_RET mpp_packet_deinit(MppPacket *packet) { - if (NULL == packet) { + if (NULL == packet || NULL == packet) { mpp_err("mpp_packet_deinit found NULL input\n"); return MPP_ERR_NULL_PTR; } - mpp_free((MppPacketImpl *)packet); + mpp_free(*packet); + *packet = NULL; return MPP_OK; } diff --git a/test/mpi_test.c b/test/mpi_test.c index d07fd09c..cf604886 100644 --- a/test/mpi_test.c +++ b/test/mpi_test.c @@ -96,13 +96,12 @@ int main() // TODO: diaplay function called here - mpp_frame_deinit(dec_out); + mpp_frame_deinit(&dec_out); dec_out = next; } while (dec_out); } - mpp_packet_deinit(dec_in); - dec_in = NULL; + mpp_packet_deinit(&dec_in); } // interface with input and output separated @@ -116,8 +115,7 @@ int main() goto MPP_TEST_FAILED; } - mpp_packet_deinit(dec_in); - dec_in = NULL; + mpp_packet_deinit(&dec_in); } for (i = 0; i < MPI_DEC_LOOP_COUNT; i++) { @@ -133,7 +131,7 @@ int main() // TODO: diaplay function called here - mpp_frame_deinit(dec_out); + mpp_frame_deinit(&dec_out); dec_out = next; } while (dec_out); } @@ -183,13 +181,10 @@ int main() goto MPP_TEST_FAILED; } - if (enc_out) { - mpp_packet_deinit(enc_out); - enc_out = NULL; - } + if (enc_out) + mpp_packet_deinit(&enc_out); - mpp_frame_deinit(enc_in); - enc_in = NULL; + mpp_frame_deinit(&enc_in); } // interface with input and output separated @@ -203,8 +198,7 @@ int main() goto MPP_TEST_FAILED; } - mpp_frame_deinit(enc_in); - enc_in = NULL; + mpp_frame_deinit(&enc_in); } for (i = 0; i < MPI_ENC_LOOP_COUNT; i++) { @@ -214,10 +208,7 @@ int main() } if (enc_out) { - if (enc_out) { - mpp_packet_deinit(enc_out); - enc_out = NULL; - } + mpp_packet_deinit(&enc_out); } } @@ -228,15 +219,11 @@ int main() goto MPP_TEST_FAILED; } - if (dec_in) { - mpp_packet_deinit(dec_in); - dec_in = NULL; - } + if (dec_in) + mpp_packet_deinit(&dec_in); - if (enc_in) { - mpp_frame_deinit(enc_in); - enc_in = NULL; - } + if (enc_in) + mpp_frame_deinit(&enc_in); mpp_deinit(ctx); free(buf); @@ -246,15 +233,11 @@ int main() return 0; MPP_TEST_FAILED: - if (dec_in) { - mpp_packet_deinit(dec_in); - dec_in = NULL; - } + if (dec_in) + mpp_packet_deinit(&dec_in); - if (enc_in) { - mpp_frame_deinit(enc_in); - enc_in = NULL; - } + if (enc_in) + mpp_frame_deinit(&enc_in); if (ctx) mpp_deinit(ctx); diff --git a/test/mpp_packet_test.c b/test/mpp_packet_test.c index 60ed0a82..0ac6002b 100644 --- a/test/mpp_packet_test.c +++ b/test/mpp_packet_test.c @@ -48,7 +48,7 @@ int main() mpp_err("mpp_packet_test mpp_packet_set_eos failed\n"); goto MPP_PACKET_failed; } - mpp_packet_deinit(packet); + mpp_packet_deinit(&packet); free(data); mpp_log("mpp_packet_test success\n"); @@ -56,7 +56,7 @@ int main() MPP_PACKET_failed: if (packet) - mpp_packet_deinit(packet); + mpp_packet_deinit(&packet); if (data) free(data);