summaryrefslogtreecommitdiff
path: root/libavcodec/svq1enc.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2013-12-23 19:48:43 +0100
committerDiego Biurrun <diego@biurrun.de>2014-05-29 06:41:15 -0700
commit65d5d5865845f057cc6530a8d0f34db952d9009c (patch)
tree87f2ff44f58d550ae4076e741a4c6b3564d98bc0 /libavcodec/svq1enc.c
parent2ea2612df508abdd1f97c6a6ef56275a52c5c41e (diff)
dsputil: Move SVQ1 encoding specific bits into svq1enc
Diffstat (limited to 'libavcodec/svq1enc.c')
-rw-r--r--libavcodec/svq1enc.c58
1 files changed, 19 insertions, 39 deletions
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 76c3e6e7ab..bdb6f0fd54 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -34,49 +34,12 @@
#include "internal.h"
#include "mpegutils.h"
#include "svq1.h"
+#include "svq1enc.h"
#include "svq1enc_cb.h"
#undef NDEBUG
#include <assert.h>
-typedef struct SVQ1EncContext {
- /* FIXME: Needed for motion estimation, should not be used for anything
- * else, the idea is to make the motion estimation eventually independent
- * of MpegEncContext, so this will be removed then. */
- MpegEncContext m;
- AVCodecContext *avctx;
- DSPContext dsp;
- HpelDSPContext hdsp;
- AVFrame *current_picture;
- AVFrame *last_picture;
- PutBitContext pb;
- GetBitContext gb;
-
- /* why ooh why this sick breadth first order,
- * everything is slower and more complex */
- PutBitContext reorder_pb[6];
-
- int frame_width;
- int frame_height;
-
- /* Y plane block dimensions */
- int y_block_width;
- int y_block_height;
-
- /* U & V plane (C planes) block dimensions */
- int c_block_width;
- int c_block_height;
-
- uint16_t *mb_type;
- uint32_t *dummy;
- int16_t (*motion_val8[3])[2];
- int16_t (*motion_val16[3])[2];
-
- int64_t rd_total;
-
- uint8_t *scratchbuf;
-} SVQ1EncContext;
-
static void svq1_write_header(SVQ1EncContext *s, int frame_type)
{
int i;
@@ -114,6 +77,16 @@ static void svq1_write_header(SVQ1EncContext *s, int frame_type)
#define QUALITY_THRESHOLD 100
#define THRESHOLD_MULTIPLIER 0.6
+static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2,
+ int size)
+{
+ int score = 0, i;
+
+ for (i = 0; i < size; i++)
+ score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
+ return score;
+}
+
static int encode_block(SVQ1EncContext *s, uint8_t *src, uint8_t *ref,
uint8_t *decoded, int stride, int level,
int threshold, int lambda, int intra)
@@ -175,7 +148,7 @@ static int encode_block(SVQ1EncContext *s, uint8_t *src, uint8_t *ref,
int sqr, diff, score;
vector = codebook + stage * size * 16 + i * size;
- sqr = s->dsp.ssd_int8_vs_int16(vector, block[stage], size);
+ sqr = s->ssd_int8_vs_int16(vector, block[stage], size);
diff = block_sum[stage] - sum;
score = sqr - (diff * (int64_t)diff >> (level + 3)); // FIXME: 64bit slooow
if (score < best_vector_score) {
@@ -574,6 +547,13 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
s->y_block_height * sizeof(int16_t));
s->dummy = av_mallocz((s->y_block_width + 1) *
s->y_block_height * sizeof(int32_t));
+ s->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
+
+ if (ARCH_PPC)
+ ff_svq1enc_init_ppc(s);
+ if (ARCH_X86)
+ ff_svq1enc_init_x86(s);
+
ff_h263_encode_init(&s->m); // mv_penalty
return 0;