From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/svq1enc: Add SVQ1EncDSPContext, make codec context private Date: Tue, 11 Oct 2022 15:18:46 +0200 Message-ID: <AS8P250MB0744A468B1388D970F1587438F239@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB07447D47B896E0C97810EADC8F239@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> 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> --- libavcodec/ppc/svq1enc_altivec.c | 4 +- libavcodec/svq1enc.c | 60 ++++++++++++++++++++-- libavcodec/svq1enc.h | 86 -------------------------------- libavcodec/svq1encdsp.h | 34 +++++++++++++ libavcodec/x86/svq1enc_init.c | 4 +- 5 files changed, 93 insertions(+), 95 deletions(-) delete mode 100644 libavcodec/svq1enc.h create mode 100644 libavcodec/svq1encdsp.h diff --git a/libavcodec/ppc/svq1enc_altivec.c b/libavcodec/ppc/svq1enc_altivec.c index aa66b40996..5721bede34 100644 --- a/libavcodec/ppc/svq1enc_altivec.c +++ b/libavcodec/ppc/svq1enc_altivec.c @@ -27,7 +27,7 @@ #include "libavutil/ppc/cpu.h" #include "libavutil/ppc/util_altivec.h" -#include "libavcodec/svq1enc.h" +#include "libavcodec/svq1encdsp.h" #if HAVE_ALTIVEC static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2, @@ -71,7 +71,7 @@ static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2, } #endif /* HAVE_ALTIVEC */ -av_cold void ff_svq1enc_init_ppc(SVQ1EncContext *c) +av_cold void ff_svq1enc_init_ppc(SVQ1EncDSPContext *c) { #if HAVE_ALTIVEC if (!PPC_ALTIVEC(av_get_cpu_flags())) 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 diff --git a/libavcodec/svq1enc.h b/libavcodec/svq1enc.h deleted file mode 100644 index bb6af082d5..0000000000 --- a/libavcodec/svq1enc.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SVQ1 encoder - * - * 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 - */ - -#ifndef AVCODEC_SVQ1ENC_H -#define AVCODEC_SVQ1ENC_H - -#include <stdint.h> - -#include "libavutil/frame.h" -#include "libavutil/mem_internal.h" - -#include "avcodec.h" -#include "hpeldsp.h" -#include "me_cmp.h" -#include "mpegvideo.h" -#include "put_bits.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; - - int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2, - intptr_t size); -} SVQ1EncContext; - -void ff_svq1enc_init_ppc(SVQ1EncContext *c); -void ff_svq1enc_init_x86(SVQ1EncContext *c); - -#endif /* AVCODEC_SVQ1ENC_H */ diff --git a/libavcodec/svq1encdsp.h b/libavcodec/svq1encdsp.h new file mode 100644 index 0000000000..91b36735d7 --- /dev/null +++ b/libavcodec/svq1encdsp.h @@ -0,0 +1,34 @@ +/* + * SVQ1 encoder DSP + * + * 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 + */ + +#ifndef AVCODEC_SVQ1ENCDSP_H +#define AVCODEC_SVQ1ENCDSP_H + +#include <stdint.h> + +typedef struct SVQ1EncDSPContext { + int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2, + intptr_t size); +} SVQ1EncDSPContext; + +void ff_svq1enc_init_ppc(SVQ1EncDSPContext *c); +void ff_svq1enc_init_x86(SVQ1EncDSPContext *c); + +#endif /* AVCODEC_SVQ1ENCDSP_H */ diff --git a/libavcodec/x86/svq1enc_init.c b/libavcodec/x86/svq1enc_init.c index 787a5245f3..daf573beba 100644 --- a/libavcodec/x86/svq1enc_init.c +++ b/libavcodec/x86/svq1enc_init.c @@ -22,12 +22,12 @@ #include "libavutil/attributes.h" #include "libavutil/cpu.h" #include "libavutil/x86/cpu.h" -#include "libavcodec/svq1enc.h" +#include "libavcodec/svq1encdsp.h" int ff_ssd_int8_vs_int16_sse2(const int8_t *pix1, const int16_t *pix2, intptr_t size); -av_cold void ff_svq1enc_init_x86(SVQ1EncContext *c) +av_cold void ff_svq1enc_init_x86(SVQ1EncDSPContext *c) { int cpu_flags = av_get_cpu_flags(); -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-10-11 13:18 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-11 13:13 [FFmpeg-devel] [PATCH 1/4] avcodec/svq1enc: Inline constants Andreas Rheinhardt 2022-10-11 13:18 ` Andreas Rheinhardt [this message] 2022-10-11 13:18 ` [FFmpeg-devel] [PATCH 3/4] avcodec/svq1: Set hidden visibility Andreas Rheinhardt 2022-10-11 13:18 ` [FFmpeg-devel] [PATCH 4/4] avcodec/svq1enc: Move PutBitContext from context to stack Andreas Rheinhardt 2022-10-13 17:25 ` [FFmpeg-devel] [PATCH 1/4] avcodec/svq1enc: Inline constants Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AS8P250MB0744A468B1388D970F1587438F239@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git