[3/4] vc-1: Add platform-specific start code search routine to VC1DSPContext.

Message ID 1405950789-11364-3-git-send-email-bavison@riscosopen.org
State New
Headers show

Commit Message

Ben Avison July 21, 2014, 1:53 p.m.
Initialise VC1DSPContext for parser as well as for decoder.
Note, the VC-1 code doesn't actually use the function pointer yet.
---
 configure                        |    4 ++--
 libavcodec/Makefile              |    2 +-
 libavcodec/arm/vc1dsp_init_arm.c |    3 +++
 libavcodec/vc1.c                 |    2 ++
 libavcodec/vc1dec.c              |    1 -
 libavcodec/vc1dsp.c              |    3 +++
 libavcodec/vc1dsp.h              |    8 ++++++++
 7 files changed, 19 insertions(+), 4 deletions(-)

Patch

diff --git a/configure b/configure
index 0b9e215..4e306ea 100755
--- a/configure
+++ b/configure
@@ -1873,7 +1873,7 @@  twinvq_decoder_select="mdct lsp sinewin"
 utvideo_decoder_select="bswapdsp"
 utvideo_encoder_select="bswapdsp huffman huffyuvencdsp"
 vble_decoder_select="huffyuvdsp"
-vc1_decoder_select="blockdsp error_resilience h263_decoder h264chroma h264qpel intrax8 mpeg_er qpeldsp"
+vc1_decoder_select="blockdsp error_resilience h263_decoder h264chroma h264qpel intrax8 mpeg_er qpeldsp startcode"
 vc1image_decoder_select="vc1_decoder"
 vorbis_decoder_select="mdct"
 vorbis_encoder_select="mdct"
@@ -1951,7 +1951,7 @@  wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 h264_parser_select="h264_decoder"
 mpegvideo_parser_select="mpegvideo"
 mpeg4video_parser_select="error_resilience h263dsp mpeg_er mpegvideo qpeldsp"
-vc1_parser_select="mpegvideo"
+vc1_parser_select="mpegvideo startcode"
 
 # external libraries
 libfaac_encoder_deps="libfaac"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f25e96f..3e569a5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -673,7 +673,7 @@  OBJS-$(CONFIG_PNM_PARSER)              += pnm_parser.o pnm.o
 OBJS-$(CONFIG_RV30_PARSER)             += rv34_parser.o
 OBJS-$(CONFIG_RV40_PARSER)             += rv34_parser.o
 OBJS-$(CONFIG_TAK_PARSER)              += tak_parser.o tak.o
-OBJS-$(CONFIG_VC1_PARSER)              += vc1_parser.o vc1.o vc1data.o \
+OBJS-$(CONFIG_VC1_PARSER)              += vc1_parser.o vc1.o vc1data.o vc1dsp.o \
                                           msmpeg4.o msmpeg4data.o mpeg4video.o \
                                           h263.o
 OBJS-$(CONFIG_VORBIS_PARSER)           += vorbis_parser.o xiph.o
diff --git a/libavcodec/arm/vc1dsp_init_arm.c b/libavcodec/arm/vc1dsp_init_arm.c
index 6d4eb79..a6a97c8 100644
--- a/libavcodec/arm/vc1dsp_init_arm.c
+++ b/libavcodec/arm/vc1dsp_init_arm.c
@@ -20,6 +20,7 @@ 
 
 #include "libavutil/attributes.h"
 #include "libavutil/arm/cpu.h"
+#include "libavcodec/arm/startcode.h"
 #include "libavcodec/vc1dsp.h"
 #include "vc1dsp.h"
 
@@ -27,6 +28,8 @@  av_cold void ff_vc1dsp_init_arm(VC1DSPContext *dsp)
 {
     int cpu_flags = av_get_cpu_flags();
 
+    if (have_setend(cpu_flags))
+        dsp->startcode_find_candidate = ff_startcode_find_candidate_armv6;
     if (have_neon(cpu_flags))
         ff_vc1dsp_init_neon(dsp);
 }
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 1978b08..cef0fe6 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -1688,5 +1688,7 @@  av_cold int ff_vc1_init_common(VC1Context *v)
     v->pq      = -1;
     v->mvrange = 0; /* 7.1.1.18, p80 */
 
+    ff_vc1dsp_init(&v->vc1dsp);
+
     return 0;
 }
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index c83bb4f..f7f6a9f 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5629,7 +5629,6 @@  static av_cold int vc1_decode_init(AVCodecContext *avctx)
     ff_blockdsp_init(&s->bdsp, avctx);
     ff_h264chroma_init(&v->h264chroma, 8);
     ff_qpeldsp_init(&s->qdsp);
-    ff_vc1dsp_init(&v->vc1dsp);
 
     if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) {
         int count = 0;
diff --git a/libavcodec/vc1dsp.c b/libavcodec/vc1dsp.c
index 5adcb62..224c5b6 100644
--- a/libavcodec/vc1dsp.c
+++ b/libavcodec/vc1dsp.c
@@ -29,6 +29,7 @@ 
 #include "h264chroma.h"
 #include "qpeldsp.h"
 #include "vc1dsp.h"
+#include "startcode.h"
 
 /* Apply overlap transform to horizontal edge */
 static void vc1_v_overlap_c(uint8_t *src, int stride)
@@ -935,6 +936,8 @@  av_cold void ff_vc1dsp_init(VC1DSPContext *dsp)
     dsp->sprite_v_double_twoscale = sprite_v_double_twoscale_c;
 #endif /* CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER */
 
+    dsp->startcode_find_candidate = ff_startcode_find_candidate_c;
+
     if (ARCH_AARCH64)
         ff_vc1dsp_init_aarch64(dsp);
     if (ARCH_ARM)
diff --git a/libavcodec/vc1dsp.h b/libavcodec/vc1dsp.h
index 7de6a3d..682f682 100644
--- a/libavcodec/vc1dsp.h
+++ b/libavcodec/vc1dsp.h
@@ -71,6 +71,14 @@  typedef struct VC1DSPContext {
     void (*sprite_v_double_twoscale)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
                                                    const uint8_t *src2a, const uint8_t *src2b, int offset2,
                                      int alpha, int width);
+
+    /**
+     * Search buf from the start for up to size bytes. Return the index
+     * of a zero byte, or >= size if not found. Ideally, use lookahead
+     * to filter out any zero bytes that are known to not be followed by
+     * one or more further zero bytes and a one byte.
+     */
+    int (*startcode_find_candidate)(const uint8_t *buf, int size);
 } VC1DSPContext;
 
 void ff_vc1dsp_init(VC1DSPContext* c);