diff options
author | Ben Avison <bavison@riscosopen.org> | 2014-04-16 01:51:31 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-25 02:35:56 +0200 |
commit | 270cede3f3772117454a14b620803d731036942d (patch) | |
tree | f8cf2f6e0999e71379d555913a3b23de27a09fc4 | |
parent | e148a5820dc5e7077f519d091b5e1ff2a5b23665 (diff) | |
download | ffmpeg-270cede3f3772117454a14b620803d731036942d.tar.gz |
h264: Move search code search functions into separate source files.
This permits re-use with parsers for codecs which use similar start codes.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/Makefile | 2 | ||||
-rw-r--r-- | libavcodec/arm/Makefile | 2 | ||||
-rw-r--r-- | libavcodec/arm/h264dsp_init_arm.c | 4 | ||||
-rw-r--r-- | libavcodec/arm/startcode_armv6.S (renamed from libavcodec/arm/h264dsp_armv6.S) | 4 | ||||
-rw-r--r-- | libavcodec/h264dsp.c | 31 | ||||
-rw-r--r-- | libavcodec/startcode.c | 57 | ||||
-rw-r--r-- | libavcodec/startcode.h | 35 |
7 files changed, 100 insertions, 35 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 332b3e1d6d..c4ddc8e18a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -50,7 +50,7 @@ OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \ OBJS-$(CONFIG_GOLOMB) += golomb.o OBJS-$(CONFIG_H263DSP) += h263dsp.o OBJS-$(CONFIG_H264CHROMA) += h264chroma.o -OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o +OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o startcode.o OBJS-$(CONFIG_H264PRED) += h264pred.o OBJS-$(CONFIG_H264QPEL) += h264qpel.o OBJS-$(CONFIG_HPELDSP) += hpeldsp.o diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile index fd4fa32e78..4c7e7d2dbe 100644 --- a/libavcodec/arm/Makefile +++ b/libavcodec/arm/Makefile @@ -51,7 +51,7 @@ ARMV6-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_armv6.o ARMV6-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_armv6.o \ arm/dsputil_armv6.o \ arm/simple_idct_armv6.o -ARMV6-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_armv6.o +ARMV6-OBJS-$(CONFIG_H264DSP) += arm/startcode_armv6.o ARMV6-OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_armv6.o \ arm/hpeldsp_armv6.o ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o diff --git a/libavcodec/arm/h264dsp_init_arm.c b/libavcodec/arm/h264dsp_init_arm.c index a0418fd5c7..eb6c514727 100644 --- a/libavcodec/arm/h264dsp_init_arm.c +++ b/libavcodec/arm/h264dsp_init_arm.c @@ -24,7 +24,7 @@ #include "libavutil/arm/cpu.h" #include "libavcodec/h264dsp.h" -int ff_h264_find_start_code_candidate_armv6(const uint8_t *buf, int size); +int ff_startcode_find_candidate_armv6(const uint8_t *buf, int size); void ff_h264_v_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); @@ -109,7 +109,7 @@ av_cold void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, int cpu_flags = av_get_cpu_flags(); if (have_armv6(cpu_flags)) - c->h264_find_start_code_candidate = ff_h264_find_start_code_candidate_armv6; + c->h264_find_start_code_candidate = ff_startcode_find_candidate_armv6; if (have_neon(cpu_flags)) h264dsp_init_neon(c, bit_depth, chroma_format_idc); } diff --git a/libavcodec/arm/h264dsp_armv6.S b/libavcodec/arm/startcode_armv6.S index 2758262c84..a46f009375 100644 --- a/libavcodec/arm/h264dsp_armv6.S +++ b/libavcodec/arm/startcode_armv6.S @@ -69,8 +69,8 @@ TMP3 .req lr andseq TMP3, TMP3, PATTERN .endm -/* int ff_h264_find_start_code_candidate_armv6(const uint8_t *buf, int size) */ -function ff_h264_find_start_code_candidate_armv6, export=1 +/* int ff_startcode_find_candidate_armv6(const uint8_t *buf, int size) */ +function ff_startcode_find_candidate_armv6, export=1 push {v1-v6,lr} mov PTR, BUF @ Ensure there are at least (PRELOAD_DISTANCE+2) complete cachelines to go diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c index a2a4abad98..a4da7764ed 100644 --- a/libavcodec/h264dsp.c +++ b/libavcodec/h264dsp.c @@ -33,6 +33,7 @@ #include "avcodec.h" #include "h264dsp.h" #include "h264idct.h" +#include "startcode.h" #include "libavutil/common.h" #define BIT_DEPTH 8 @@ -63,34 +64,6 @@ #include "h264addpx_template.c" #undef BIT_DEPTH -static int h264_find_start_code_candidate_c(const uint8_t *buf, int size) -{ - int i = 0; -#if HAVE_FAST_UNALIGNED - /* we check i < size instead of i + 3 / 7 because it is - * simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE - * bytes at the end. - */ -# if HAVE_FAST_64BIT - while (i < size && - !((~*(const uint64_t *)(buf + i) & - (*(const uint64_t *)(buf + i) - 0x0101010101010101ULL)) & - 0x8080808080808080ULL)) - i += 8; -# else - while (i < size && - !((~*(const uint32_t *)(buf + i) & - (*(const uint32_t *)(buf + i) - 0x01010101U)) & - 0x80808080U)) - i += 4; -# endif -#endif - for (; i < size; i++) - if (!buf[i]) - break; - return i; -} - av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { @@ -178,7 +151,7 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, H264_DSP(8); break; } - c->h264_find_start_code_candidate = h264_find_start_code_candidate_c; + c->h264_find_start_code_candidate = ff_startcode_find_candidate_c; if (ARCH_AARCH64) ff_h264dsp_init_aarch64(c, bit_depth, chroma_format_idc); if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc); diff --git a/libavcodec/startcode.c b/libavcodec/startcode.c new file mode 100644 index 0000000000..5df7695150 --- /dev/null +++ b/libavcodec/startcode.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at> + * + * 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 + */ + +/** + * @file + * Accelerated start code search function for start codes common to + * MPEG-1/2/4 video, VC-1, H.264/5 + * @author Michael Niedermayer <michaelni@gmx.at> + */ + +#include "startcode.h" +#include "config.h" + +int ff_startcode_find_candidate_c(const uint8_t *buf, int size) +{ + int i = 0; +#if HAVE_FAST_UNALIGNED + /* we check i < size instead of i + 3 / 7 because it is + * simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE + * bytes at the end. + */ +# if HAVE_FAST_64BIT + while (i < size && + !((~*(const uint64_t *)(buf + i) & + (*(const uint64_t *)(buf + i) - 0x0101010101010101ULL)) & + 0x8080808080808080ULL)) + i += 8; +# else + while (i < size && + !((~*(const uint32_t *)(buf + i) & + (*(const uint32_t *)(buf + i) - 0x01010101U)) & + 0x80808080U)) + i += 4; +# endif +#endif + for (; i < size; i++) + if (!buf[i]) + break; + return i; +} diff --git a/libavcodec/startcode.h b/libavcodec/startcode.h new file mode 100644 index 0000000000..cc55d5f642 --- /dev/null +++ b/libavcodec/startcode.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at> + * + * 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 + */ + +/** + * @file + * Accelerated start code search function for start codes common to + * MPEG-1/2/4 video, VC-1, H.264/5 + * @author Michael Niedermayer <michaelni@gmx.at> + */ + +#ifndef AVCODEC_STARTCODE_H +#define AVCODEC_STARTCODE_H + +#include <stdint.h> + +int ff_startcode_find_candidate_c(const uint8_t *buf, int size); + +#endif /* AVCODEC_STARTCODE_H */ |