summaryrefslogtreecommitdiff
path: root/libavcodec/svq1enc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-10 22:54:17 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-14 16:14:24 +0200
commite84348a8abd465f3a8b0e254321a3e29561fafc2 (patch)
tree7bd46a22484b66d9d829f10894d3a6a48dea09ef /libavcodec/svq1enc.c
parent42bde73b20b9fe8924df8640db80f245993bb247 (diff)
avcodec/svq1enc: Add SVQ1EncDSPContext, make codec context private
Currently, SVQ1EncContext is defined in a header that is also included by the arch-specific code that initializes the one and only dsp function that this encoder uses directly. But the arch-specific functions to set this dsp function do not need anything from SVQ1EncContext. This commit therefore adds a small SVQ1EncDSPContext whose only member is said function pointer and renames svq1enc.h to svq1encdsp.h to avoid exposing unnecessary internals to these init functions (and the whole mpegvideo with it). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/svq1enc.c')
-rw-r--r--libavcodec/svq1enc.c60
1 files changed, 55 insertions, 5 deletions
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 79e9e578ac..67a6de5cc0 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -37,11 +37,61 @@
#include "internal.h"
#include "mpegutils.h"
#include "packet_internal.h"
+#include "put_bits.h"
#include "svq1.h"
-#include "svq1enc.h"
+#include "svq1encdsp.h"
#include "svq1enc_cb.h"
+
#include "libavutil/avassert.h"
+#include "libavutil/frame.h"
+#include "libavutil/mem_internal.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;
+ MECmpContext mecc;
+ HpelDSPContext hdsp;
+ AVFrame *current_picture;
+ AVFrame *last_picture;
+ PutBitContext pb;
+
+ /* Some compression statistics */
+ enum AVPictureType pict_type;
+ int quality;
+
+ /* 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;
+
+ DECLARE_ALIGNED(16, int16_t, encoded_block_levels)[6][7][256];
+
+ 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;
+
+ int motion_est;
+ SVQ1EncDSPContext svq1encdsp;
+} SVQ1EncContext;
static void svq1_write_header(SVQ1EncContext *s, int frame_type)
{
@@ -154,7 +204,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->ssd_int8_vs_int16(vector, block[stage], size);
+ sqr = s->svq1encdsp.ssd_int8_vs_int16(vector, block[stage], size);
diff = block_sum[stage] - sum;
score = sqr - (diff * (int64_t)diff >> (level + 3)); // FIXME: 64 bits slooow
if (score < best_vector_score) {
@@ -558,7 +608,7 @@ 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;
+ s->svq1encdsp.ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
if (!s->m.me.temp || !s->m.me.scratchpad || !s->m.me.map ||
!s->m.me.score_map || !s->mb_type || !s->dummy) {
@@ -566,9 +616,9 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
}
#if ARCH_PPC
- ff_svq1enc_init_ppc(s);
+ ff_svq1enc_init_ppc(&s->svq1encdsp);
#elif ARCH_X86
- ff_svq1enc_init_x86(s);
+ ff_svq1enc_init_x86(&s->svq1encdsp);
#endif
ff_h263_encode_init(&s->m); // mv_penalty