Added test for libavcodec/avpacket.c Function(s) tested: av_packet_clone() Signed-off-by: Thomas Turner <thomas...@gmail.com> --- libavcodec/Makefile | 3 +- libavcodec/tests/avpacket.c | 115 ++++++++++++++++++++++++++++++++++++++++++++ tests/fate/libavcodec.mak | 5 ++ 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 libavcodec/tests/avpacket.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a1560ba..d64b8df 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1016,7 +1016,8 @@ SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_vt_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vda_vt_internal.h -TESTPROGS = imgconvert \ +TESTPROGS = avpacket \ + imgconvert \ jpeg2000dwt \ mathops \ options \ diff --git a/libavcodec/tests/avpacket.c b/libavcodec/tests/avpacket.c new file mode 100644 index 0000000..d02f2e2 --- /dev/null +++ b/libavcodec/tests/avpacket.c @@ -0,0 +1,115 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdio.h> +#include <stdlib.h> +#include <inttypes.h> +#include "libavcodec/avcodec.h" + + + +static void LOG_AVPACKET(AVPacket* avpkt, const char* message) +{ + char buf_info[256]; + char data_info[256]; + + if(avpkt->buf) + sprintf(buf_info, "{buffer: %p, data: %p, size: %d}", + avpkt->buf->buffer, avpkt->buf->data, avpkt->buf->size); + else + sprintf(buf_info, "{}"); + + if(avpkt->data) + snprintf(data_info, avpkt->size + 3, "{%s}", avpkt->data); + else + sprintf(data_info, "{}"); + + av_log(NULL, AV_LOG_INFO, + "%s:\n\n" + "buf\t\t: %p " + "%s\n" + "pts\t\t: %" PRId64 "\n" + "dts\t\t: %" PRId64 "\n" + "data\t\t: %p " + "%s\n" + "size\t\t: %d\n" + "stream_index\t: %d\n" + "flags\t\t: %d\n" + "side_data\t: %p\n" + "side_data_elems\t: %d\n" + "duration\t: %" PRId64 "\n" + "pos\t\t: %" PRId64 "\n\n", + message, + avpkt->buf, + buf_info, + avpkt->pts, + avpkt->dts, + avpkt->data, + data_info, + avpkt->size, + avpkt->stream_index, + avpkt->flags, + avpkt->side_data, + avpkt->side_data_elems, + avpkt->duration, + avpkt->pos + ); +} + +static void TEST_AV_PACKET_CLONE(void) +{ + + AVPacket avpkt, *avpkt_ptr, *avpkt_clone; + + unsigned char buffer[] = "\x73\x65\x6c\x66\x74\x65\x73\x74\x20\x66\x6f\x72" + "\x20\x61\x76\x5f\x70\x61\x63\x6b\x65\x74\x5f\x63\x6c\x6f\x6e\x65\x28" + "\x2e\x2e\x2e\x29"; + + /* initialize avpkt */ + av_init_packet(&avpkt); + + /* try to make av_packet_clone fail */ + avpkt_clone = av_packet_clone(&avpkt); + + if(!avpkt_clone){ + av_log(NULL, AV_LOG_ERROR, "Error cloning packet.\n\n"); + } + + /* make av_packet_clone succeed */ + + /* fill data buffer */ + avpkt.data = buffer; + avpkt.size = sizeof(buffer); + + /* clone avpkt */ + avpkt_clone = av_packet_clone(&avpkt); + + if(avpkt_clone){ + avpkt_ptr= &avpkt; + LOG_AVPACKET(avpkt_ptr, "Original Packet info"); + LOG_AVPACKET(avpkt_clone, "Cloned Packet info"); + } + +} + +int main(void) +{ + TEST_AV_PACKET_CLONE(); + + return 0; +} diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak index cf25285..3bc74c1 100644 --- a/tests/fate/libavcodec.mak +++ b/tests/fate/libavcodec.mak @@ -1,3 +1,8 @@ +FATE_LIBAVCODEC-yes += fate-avpacket +fate-avpacket: libavcodec/tests/avpacket$(EXESUF) +fate-avpacket: CMD = run libavcodec/tests/avpacket +fate-avpacket: REF = /dev/null + FATE_LIBAVCODEC-$(CONFIG_CABAC) += fate-cabac fate-cabac: libavcodec/tests/cabac$(EXESUF) fate-cabac: CMD = run libavcodec/tests/cabac -- 1.9.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel