[FFmpeg-devel] [PATCH] libavcodec/tests: Added test for libavcodec/avpacket.c
Michael Niedermayer
michael at niedermayer.cc
Tue Nov 8 15:05:41 EET 2016
On Mon, Nov 07, 2016 at 08:38:59PM -0800, Thomas Turner wrote:
> Signed-off-by: Thomas Turner <thomastdt at googlemail.com>
> ---
> libavcodec/Makefile | 3 +-
> libavcodec/tests/avpacket.c | 134 ++++++++++++++++++++++++++++++++++++++++++++
> tests/fate/libavcodec.mak | 5 ++
> 3 files changed, 141 insertions(+), 1 deletion(-)
> create mode 100644 libavcodec/tests/avpacket.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index f1d5bf1..46e3af7 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1019,7 +1019,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..4826522
> --- /dev/null
> +++ b/libavcodec/tests/avpacket.c
> @@ -0,0 +1,134 @@
> +/*
> + * 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 <string.h>
> +#include "libavcodec/avcodec.h"
> +#include "libavutil/error.h"
> +
> +
> +
> +static int setup_side_data_entry(AVPacket* avpkt)
> +{
> + const uint8_t *data_name = NULL;
> + int ret = 0, bytes;
> + uint8_t *extra_data = NULL;
> +
> +
> + /* get side_data_name string */
> + data_name = av_packet_side_data_name(AV_PKT_DATA_NEW_EXTRADATA);
> +
> + /* Allocate a memory bloc */
> + bytes = strlen(data_name);
> +
> + if(!(extra_data = av_malloc(bytes))){
> + ret = AVERROR(ENOMEM);
> + fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
> + return 1;
error codes in ffmpeg are generally negative AVERROR() / AVERROR_*
while only cosmetic, i think its better to be consistent here
except where other things are needed for interfacing (like main()
return or oter APIs)
> + }
> + /* copy side_data_name to extra_data array */
> + memcpy(extra_data, data_name, bytes);
> +
> + /* create side data for AVPacket */
> + ret = av_packet_add_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
> + extra_data, bytes);
> + if(ret < 0){
> + fprintf(stderr,
> + "Error occurred in av_packet_add_side_data: %s\n",
> + av_err2str(ret));
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> +static int initializations(AVPacket* avpkt)
> +{
> + static uint8_t data[] = "selftest for av_packet_clone(...)";
const static ...
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161108/fc31d1a1/attachment.sig>
More information about the ffmpeg-devel
mailing list