Re: [FFmpeg-devel] [PATCH] x86/ttadsp: add ff_ttafilter_process_enc_{ssse3, sse4}

2016-08-02 Thread James Almer
On 7/31/2016 10:27 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/Makefile  |  2 +-
>  libavcodec/ttadsp.c  | 41 -
>  libavcodec/ttadsp.h  |  3 +++
>  libavcodec/ttaenc.c  | 38 ++
>  libavcodec/x86/Makefile  |  2 ++
>  libavcodec/x86/ttadsp.asm| 24 
>  libavcodec/x86/ttadsp_init.c | 25 +++--
>  7 files changed, 83 insertions(+), 52 deletions(-)

Split into its own context instead and pushed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] x86/ttadsp: add ff_ttafilter_process_enc_{ssse3, sse4}

2016-07-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/Makefile  |  2 +-
 libavcodec/ttadsp.c  | 41 -
 libavcodec/ttadsp.h  |  3 +++
 libavcodec/ttaenc.c  | 38 ++
 libavcodec/x86/Makefile  |  2 ++
 libavcodec/x86/ttadsp.asm| 24 
 libavcodec/x86/ttadsp_init.c | 25 +++--
 7 files changed, 83 insertions(+), 52 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 33ac2b3..4355c13 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -552,7 +552,7 @@ OBJS-$(CONFIG_TRUESPEECH_DECODER)  += truespeech.o
 OBJS-$(CONFIG_TSCC_DECODER)+= tscc.o msrledec.o
 OBJS-$(CONFIG_TSCC2_DECODER)   += tscc2.o
 OBJS-$(CONFIG_TTA_DECODER) += tta.o ttadata.o ttadsp.o
-OBJS-$(CONFIG_TTA_ENCODER) += ttaenc.o ttadata.o
+OBJS-$(CONFIG_TTA_ENCODER) += ttaenc.o ttadata.o ttadsp.o
 OBJS-$(CONFIG_TWINVQ_DECODER)  += twinvqdec.o twinvq.o
 OBJS-$(CONFIG_TXD_DECODER) += txd.o
 OBJS-$(CONFIG_ULTI_DECODER)+= ulti.o
diff --git a/libavcodec/ttadsp.c b/libavcodec/ttadsp.c
index 30b7ab9..32a87b2 100644
--- a/libavcodec/ttadsp.c
+++ b/libavcodec/ttadsp.c
@@ -18,9 +18,10 @@
 
 #include "ttadsp.h"
 
-static void ttafilter_process_dec_c(int32_t *qm, int32_t *dx, int32_t *dl,
-int32_t *error, int32_t *in, int32_t shift,
-int32_t round) {
+static inline void ttafilter_process(int32_t *qm, int32_t *dx, int32_t *dl,
+ int32_t *error, int32_t *in, int32_t 
shift,
+ int32_t round, int enc)
+{
 if (*error < 0) {
 qm[0] -= dx[0]; qm[1] -= dx[1]; qm[2] -= dx[2]; qm[3] -= dx[3];
 qm[4] -= dx[4]; qm[5] -= dx[5]; qm[6] -= dx[6]; qm[7] -= dx[7];
@@ -40,17 +41,47 @@ static void ttafilter_process_dec_c(int32_t *qm, int32_t 
*dx, int32_t *dl,
 dx[6] = ((dl[6] >> 30) | 2) & ~1;
 dx[7] = ((dl[7] >> 30) | 4) & ~3;
 
-*error = *in;
-*in += (round >> shift);
+if (!enc) {
+*error = *in;
+*in += (round >> shift);
+}
 
 dl[4] = -dl[5]; dl[5] = -dl[6];
 dl[6] = *in - dl[7]; dl[7] = *in;
 dl[5] += dl[6]; dl[4] += dl[5];
+
+if (enc) {
+*in -= (round >> shift);
+*error = *in;
+}
+}
+
+#if CONFIG_TTA_DECODER
+static void ttafilter_process_dec_c(int32_t *qm, int32_t *dx, int32_t *dl,
+int32_t *error, int32_t *in, int32_t shift,
+int32_t round)
+{
+ttafilter_process(qm, dx, dl, error, in, shift, round, 0);
+}
+#endif
+
+#if CONFIG_TTA_ENCODER
+static void ttafilter_process_enc_c(int32_t *qm, int32_t *dx, int32_t *dl,
+int32_t *error, int32_t *in, int32_t shift,
+int32_t round)
+{
+ttafilter_process(qm, dx, dl, error, in, shift, round, 1);
 }
+#endif
 
 av_cold void ff_ttadsp_init(TTADSPContext *c)
 {
+#if CONFIG_TTA_DECODER
 c->ttafilter_process_dec = ttafilter_process_dec_c;
+#endif
+#if CONFIG_TTA_ENCODER
+c->ttafilter_process_enc = ttafilter_process_enc_c;
+#endif
 
 if (ARCH_X86)
 ff_ttadsp_init_x86(c);
diff --git a/libavcodec/ttadsp.h b/libavcodec/ttadsp.h
index 56930f1..df73998 100644
--- a/libavcodec/ttadsp.h
+++ b/libavcodec/ttadsp.h
@@ -26,6 +26,9 @@ typedef struct TTADSPContext {
 void (*ttafilter_process_dec)(int32_t *qm, int32_t *dx, int32_t *dl,
   int32_t *error, int32_t *in, int32_t shift,
   int32_t round);
+void (*ttafilter_process_enc)(int32_t *qm, int32_t *dx, int32_t *dl,
+  int32_t *error, int32_t *in, int32_t shift,
+  int32_t round);
 } TTADSPContext;
 
 void ff_ttadsp_init(TTADSPContext *c);
diff --git a/libavcodec/ttaenc.c b/libavcodec/ttaenc.c
index 2f1c8db..5ccf98b 100644
--- a/libavcodec/ttaenc.c
+++ b/libavcodec/ttaenc.c
@@ -20,6 +20,7 @@
 
 #define BITSTREAM_WRITER_LE
 #include "ttadata.h"
+#include "ttadsp.h"
 #include "avcodec.h"
 #include "put_bits.h"
 #include "internal.h"
@@ -29,6 +30,7 @@ typedef struct TTAEncContext {
 const AVCRC *crc_table;
 int bps;
 TTAChannel *ch_ctx;
+TTADSPContext dsp;
 } TTAEncContext;
 
 static av_cold int tta_encode_init(AVCodecContext *avctx)
@@ -57,38 +59,9 @@ static av_cold int tta_encode_init(AVCodecContext *avctx)
 if (!s->ch_ctx)
 return AVERROR(ENOMEM);
 
-return 0;
-}
-
-static inline void ttafilter_process(TTAFilter *c, int32_t *in)
-{
-register int32_t *dl = c->dl, *qm = c->qm, *dx = c->dx, sum = c->round;
-
-if (c->error < 0) {
-qm[0] -= dx[0]; qm[1] -= dx[1]; qm[2] -= dx[2]; qm[3] -= dx[3];
-qm[4] -= dx[4]; qm[5] -= dx[5]; qm[6] -=