From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 04/18] avcodec/vp8: Inline mb_layout for VP7
Date: Sat, 10 Sep 2022 03:07:15 +0200
Message-ID: <AS8P250MB07449A231210446D1542BD928F429@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB0744923C03A16E5BF7BE11B28F429@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
It is always one for VP7.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/vp8.c | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 50e879ef0b..635e45f87e 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -244,11 +244,11 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
s->mb_layout = is_vp7 || avctx->active_thread_type == FF_THREAD_SLICE &&
avctx->thread_count > 1;
- if (!s->mb_layout) { // Frame threading and one thread
+ if (!s->mb_layout) { // Frame threading and one thread when VP8
s->macroblocks_base = av_mallocz((s->mb_width + s->mb_height * 2 + 1) *
sizeof(*s->macroblocks));
s->intra4x4_pred_mode_top = av_mallocz(s->mb_width * 4);
- } else // Sliced threading
+ } else // Sliced threading or VP7
s->macroblocks_base = av_mallocz((s->mb_width + 2) * (s->mb_height + 2) *
sizeof(*s->macroblocks));
s->top_nnz = av_mallocz(s->mb_width * sizeof(*s->top_nnz));
@@ -256,7 +256,7 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
s->thread_data = av_mallocz(MAX_THREADS * sizeof(VP8ThreadData));
if (!s->macroblocks_base || !s->top_nnz || !s->top_border ||
- !s->thread_data || (!s->intra4x4_pred_mode_top && !s->mb_layout)) {
+ !s->thread_data || (!s->intra4x4_pred_mode_top && (!is_vp7 && !s->mb_layout))) {
free_buffers(s);
return AVERROR(ENOMEM);
}
@@ -1044,7 +1044,7 @@ static const VP8mv *get_bmv_ptr(const VP8Macroblock *mb, int subblock)
static av_always_inline
void vp7_decode_mvs(VP8Context *s, VP8Macroblock *mb,
- int mb_x, int mb_y, int layout)
+ int mb_x, int mb_y)
{
VP8Macroblock *mb_edge[12];
enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR };
@@ -1065,11 +1065,8 @@ void vp7_decode_mvs(VP8Context *s, VP8Macroblock *mb,
if (vp7_calculate_mb_offset(mb_x, mb_y, s->mb_width, pred->xoffset,
pred->yoffset, !s->profile, &edge_x, &edge_y)) {
- VP8Macroblock *edge = mb_edge[i] = (s->mb_layout == 1)
- ? s->macroblocks_base + 1 + edge_x +
- (s->mb_width + 1) * (edge_y + 1)
- : s->macroblocks + edge_x +
- (s->mb_height - edge_y - 1) * 2;
+ VP8Macroblock *edge = mb_edge[i] = s->macroblocks_base + 1 + edge_x +
+ (s->mb_width + 1) * (edge_y + 1);
uint32_t mv = AV_RN32A(get_bmv_ptr(edge, vp7_mv_pred[i].subblock));
if (mv) {
if (AV_RN32A(&near_mv[CNT_NEAREST])) {
@@ -1112,7 +1109,7 @@ void vp7_decode_mvs(VP8Context *s, VP8Macroblock *mb,
if (vpx_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAR]][3])) {
mb->mode = VP8_MVMODE_SPLIT;
- mb->mv = mb->bmv[decode_splitmvs(s, c, mb, layout, IS_VP7) - 1];
+ mb->mv = mb->bmv[decode_splitmvs(s, c, mb, 1, IS_VP7) - 1];
} else {
mb->mv.y += vp7_read_mv_component(c, s->prob->mvc[0]);
mb->mv.x += vp7_read_mv_component(c, s->prob->mvc[1]);
@@ -1310,7 +1307,7 @@ void decode_mb_mode(VP8Context *s, VP8mvbounds *mv_bounds,
} else {
const uint32_t modes = (is_vp7 ? vp7_pred4x4_mode
: vp8_pred4x4_mode)[mb->mode] * 0x01010101u;
- if (s->mb_layout)
+ if (is_vp7 || s->mb_layout)
AV_WN32A(mb->intra4x4_pred_mode_top, modes);
else
AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes);
@@ -1332,7 +1329,7 @@ void decode_mb_mode(VP8Context *s, VP8mvbounds *mv_bounds,
// motion vectors, 16.3
if (is_vp7)
- vp7_decode_mvs(s, mb, mb_x, mb_y, layout);
+ vp7_decode_mvs(s, mb, mb_x, mb_y);
else
vp8_decode_mvs(s, mv_bounds, mb, mb_x, mb_y, layout);
} else {
@@ -2420,7 +2417,7 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void
next_td = td;
else
next_td = &s->thread_data[(jobnr + 1) % num_jobs];
- if (s->mb_layout == 1)
+ if (is_vp7 || s->mb_layout == 1)
mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1);
else {
// Make sure the previous frame has read its segmentation map,
@@ -2460,10 +2457,10 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void
s->vdsp.prefetch(dst[1] + (mb_x & 7) * s->uvlinesize + 64,
dst[2] - dst[1], 2);
- if (!s->mb_layout)
+ if (!is_vp7 && !s->mb_layout)
decode_mb_mode(s, &td->mv_bounds, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy,
prev_frame && prev_frame->seg_map ?
- prev_frame->seg_map->data + mb_xy : NULL, 0, is_vp7);
+ prev_frame->seg_map->data + mb_xy : NULL, 0, IS_VP8);
prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP8_FRAME_PREVIOUS);
@@ -2547,7 +2544,7 @@ static av_always_inline void filter_mb_row(AVCodecContext *avctx, void *tdata,
curframe->data[2] + 8 * mb_y * s->uvlinesize
};
- if (s->mb_layout == 1)
+ if (is_vp7 || s->mb_layout == 1)
mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1);
else
mb = s->macroblocks + (s->mb_height - mb_y - 1) * 2;
@@ -2770,17 +2767,18 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame,
s->uvlinesize = curframe->tf.f->linesize[1];
memset(s->top_nnz, 0, s->mb_width * sizeof(*s->top_nnz));
- /* Zero macroblock structures for top/top-left prediction
- * from outside the frame. */
- if (!s->mb_layout)
+ if (!is_vp7 && !s->mb_layout) {
+ /* Zero macroblock structures for top/top-left prediction
+ * from outside the frame. */
memset(s->macroblocks + s->mb_height * 2 - 1, 0,
(s->mb_width + 1) * sizeof(*s->macroblocks));
- if (!s->mb_layout && s->keyframe)
- memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width * 4);
+ if (s->keyframe)
+ memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width * 4);
+ }
memset(s->ref_count, 0, sizeof(s->ref_count));
- if (s->mb_layout == 1) {
+ if (is_vp7 || s->mb_layout == 1) {
if (is_vp7) {
ret = vp7_decode_mv_mb_modes(avctx, curframe, prev_frame);
} else {
--
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-09-10 1:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-10 0:19 [FFmpeg-devel] [PATCH 01/18] avcodec/vp8: Disable segmentation " Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 02/18] avcodec/vp8: Disable lf_delta " Andreas Rheinhardt
2022-09-11 4:29 ` Peter Ross
2022-09-11 4:38 ` Andreas Rheinhardt
2022-09-11 14:41 ` Ronald S. Bultje
2022-09-11 15:09 ` Ronald S. Bultje
2022-09-11 22:41 ` Peter Ross
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 03/18] avcodec/vp8: Remove unused macros Andreas Rheinhardt
2022-09-10 1:07 ` Andreas Rheinhardt [this message]
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 05/18] avcodec/vp8: Inline inner_filter for VP7 Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 06/18] avcodec/vp8: Inline mbskip_enabled " Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 07/18] avcodec/vp8: Pass mb_y explicitly Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 08/18] avcodec/vp8: Inline num_coeff_partitions for VP7 Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 09/18] avcodec/vp8: Disable slice-thread synchronization code " Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 10/18] avcodec/vp8: Inline num_jobs " Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 11/18] avcodec/vp8: Inline jobnr, threadnr " Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 12/18] avcodec/vp8: Inline update_last " Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 13/18] avcodec/vp8: Don't use avctx->execute2 " Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 14/18] avcodec/vp8: Move fade_present from context to stack Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 15/18] avcodec/vp8: Disable frame-threading code for VP7 Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 16/18] avcodec/vp8dsp: Remove declarations of inexistent functions Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 17/18] avcodec/vp8dsp: Constify src in vp8_mc_func Andreas Rheinhardt
2022-09-10 1:07 ` [FFmpeg-devel] [PATCH 18/18] avcodec/vp8: Add const where appropriate 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=AS8P250MB07449A231210446D1542BD928F429@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