[FFmpeg-devel] [PATCH 5/5] lavf: add uncodedframecrc test muxer.
Michael Niedermayer
michaelni at gmx.at
Thu Jan 16 14:52:59 CET 2014
On Wed, Jan 15, 2014 at 11:30:04PM +0100, Nicolas George wrote:
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
> libavformat/Makefile | 1 +
> libavformat/allformats.c | 1 +
> libavformat/avformat.h | 6 +-
> libavformat/uncodedframecrcenc.c | 171 +++++++++++++++++++++++++++++++++++++++
> 4 files changed, 176 insertions(+), 3 deletions(-)
> create mode 100644 libavformat/uncodedframecrcenc.c
>
>
> ALSA and XVideo are great for casual testing, not so much for valgrind.
>
> The output matches the output of framecrc for u8 audio and packed 8-bits
> video.
>
>
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 383f82f..704bd62 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -387,6 +387,7 @@ OBJS-$(CONFIG_TRUEHD_MUXER) += rawenc.o
> OBJS-$(CONFIG_TTA_DEMUXER) += tta.o apetag.o img2.o
> OBJS-$(CONFIG_TTY_DEMUXER) += tty.o sauce.o
> OBJS-$(CONFIG_TXD_DEMUXER) += txd.o
> +OBJS-$(CONFIG_UNCODEDFRAMECRC_MUXER) += uncodedframecrcenc.o framehash.o
> OBJS-$(CONFIG_VC1_DEMUXER) += rawdec.o
> OBJS-$(CONFIG_VC1_MUXER) += rawenc.o
> OBJS-$(CONFIG_VC1T_DEMUXER) += vc1test.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index f1039dd..0ee2246 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -284,6 +284,7 @@ void av_register_all(void)
> REGISTER_DEMUXER (TTA, tta);
> REGISTER_DEMUXER (TXD, txd);
> REGISTER_DEMUXER (TTY, tty);
> + REGISTER_MUXER (UNCODEDFRAMECRC, uncodedframecrc);
> REGISTER_MUXDEMUX(VC1, vc1);
> REGISTER_MUXDEMUX(VC1T, vc1t);
> REGISTER_DEMUXER (VIVO, vivo);
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 3fe6c3e..4c03985 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -460,7 +460,7 @@ typedef struct AVOutputFormat {
> * See av_write_uncoded_frame() for details.
> */
> int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,
> - AVFrame **frame, unsigned flags);
> + AVFrame *frame, unsigned flags);
> } AVOutputFormat;
> /**
> * @}
> @@ -1937,8 +1937,8 @@ int av_write_uncoded_frame(AVFormatContext *s, int stream_index,
> * To test whether it is possible to use it with a given muxer and stream,
> * use av_write_uncoded_frame_query().
> *
> - * The caller gives up ownership of the frame and must not access it
> - * afterwards.
> + * The caller keeps ownership of the frame and is responsible for freeing
> + * it.
> *
> * @return >=0 for success, a negative code on error
> */
> diff --git a/libavformat/uncodedframecrcenc.c b/libavformat/uncodedframecrcenc.c
> new file mode 100644
> index 0000000..99d1740
> --- /dev/null
> +++ b/libavformat/uncodedframecrcenc.c
> @@ -0,0 +1,171 @@
> +/*
> +* Copyright (c) 2013 Nicolas George
> +*
> +* 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 "libavutil/adler32.h"
> +#include "libavutil/avassert.h"
> +#include "libavutil/bprint.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/pixdesc.h"
> +#include "avformat.h"
> +#include "internal.h"
> +
> +#define DEFINE_CRC_LINE(name, type, conv) \
> +static void crc_line_ ## name(unsigned *crc, void *data, unsigned size) \
> +{ \
> + type *p = data; \
> + unsigned a = *crc & 0xFFFF, b = *crc >> 16; \
> + for (; size > 0; size--, p++) { \
> + a = (a + (unsigned)(conv)) % 65521; \
> + b = (b + a) % 65521; \
> + } \
> + *crc = a | (b << 16); \
> +}
please dont call adler32 a crc, (classical) crcs are cyclic, adler32
is not, consider a message with 1 bit set and the checksum appended
you cant just rotate that and still get a valid message, the checksum
is not even in the same kind of set (GF(256) vs GF(65521))
a valid message in respect to CRCs is just a polynom that has the
CRC generator as one of its factors (if you append the crc checksum
after the messsage), and there happens to be a n so that the generator
is a factor of x^n-1, but if x^n-1 contains the generator as a factor
its a valid message with correct CRC and adding 2 valid messages will
still give a valid message (for all linear codes actually) but adding
x^n-1 is just rotation
(i hope i got that proof right, as i didnt really double check this)
patch LGTM otherwise
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140116/bac1c15c/attachment.asc>
More information about the ffmpeg-devel
mailing list