History

Avoid tracking i4x4 modes in P-frames in VP8 As in the previous commit, they aren't used for context selection, so it saves memory this way.

Originally committed as revision 24416 to svn://svn.ffmpeg.org/ffmpeg/trunk

Jason Garrett-Glaser committed 16 years ago

Commit d1c58fc1 parent 158e0621 file · +20 −13Browse files

Unified · Split

libavcodec/vp8.c+20−13
@@ -109,6 +109,7 @@ typedef struct { · 108 unmodified lines
109109 */
110110 DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];
111111 DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16];
112+ uint8_t intra4x4_pred_mode_mb[16];
112113
113114 int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock
114115
@@ -670,19 +671,22 @@ static int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, · 555 unmodified lines
670671 static inline void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4,
671672 int stride, int keyframe)
672673 {
673− int x, y, t, l;
674− const uint8_t *ctx = vp8_pred4x4_prob_inter;
674+ int x, y, t, l, i;
675675
676− for (y = 0; y < 4; y++) {
677− for (x = 0; x < 4; x++) {
678− if (keyframe) {
676+ if (keyframe) {
677+ const uint8_t *ctx;
678+ for (y = 0; y < 4; y++) {
679+ for (x = 0; x < 4; x++) {
679680 t = intra4x4[x - stride];
680681 l = intra4x4[x - 1];
681682 ctx = vp8_pred4x4_prob_intra[t][l];
683+ intra4x4[x] = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx);
682684 }
683− intra4x4[x] = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx);
685+ intra4x4 += stride;
684686 }
685− intra4x4 += stride;
687+ } else {
688+ for (i = 0; i < 16; i++)
689+ intra4x4[i] = vp8_rac_get_tree(c, vp8_pred4x4_tree, vp8_pred4x4_prob_inter);
686690 }
687691 }
688692
@@ -753,7 +757,7 @@ static void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, · 64 unmodified lines
753757 mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16);
754758
755759 if (mb->mode == MODE_I4x4)
756− decode_intra4x4_modes(c, intra4x4, s->b4_stride, 0);
760+ decode_intra4x4_modes(c, intra4x4, 4, 0);
757761
758762 s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, s->prob->pred8x8c);
759763 mb->ref_frame = VP56_FRAME_CURRENT;
@@ -922,7 +926,7 @@ static int check_intra_pred_mode(int mode, int mb_x, int mb_y) · 162 unmodified lines
922926 }
923927
924928 static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
925− uint8_t *bmode, int mb_x, int mb_y)
929+ uint8_t *intra4x4, int mb_x, int mb_y)
926930 {
927931 int x, y, mode, nnz, tr;
928932
@@ -938,6 +942,7 @@ static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, · 9 unmodified lines
938942 s->hpc.pred16x16[mode](dst[0], s->linesize);
939943 } else {
940944 uint8_t *ptr = dst[0];
945+ int stride = s->keyframe ? s->b4_stride : 4;
941946
942947 // all blocks on the right edge of the macroblock use bottom edge
943948 // the top macroblock for their topright edge
@@ -956,7 +961,7 @@ static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, · 12 unmodified lines
956961 if (x == 3)
957962 topright = tr_right;
958963
959− s->hpc.pred4x4[bmode[x]](ptr+4*x, topright, s->linesize);
964+ s->hpc.pred4x4[intra4x4[x]](ptr+4*x, topright, s->linesize);
960965
961966 nnz = s->non_zero_count_cache[y][x];
962967 if (nnz) {
@@ -969,7 +974,7 @@ static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, · 6 unmodified lines
969974 }
970975
971976 ptr += 4*s->linesize;
972− bmode += s->b4_stride;
977+ intra4x4 += stride;
973978 }
974979 }
975980
@@ -1457,11 +1462,13 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 481 unmodified lines
14571462 memset(s->top_border, 129, sizeof(*s->top_border));
14581463
14591464 for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
1465+ uint8_t *intra4x4_mb = s->keyframe ? intra4x4 + 4*mb_x : s->intra4x4_pred_mode_mb;
1466+
14601467 /* Prefetch the current frame, 4 MBs ahead */
14611468 s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4);
14621469 s->dsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2);
14631470
1464− decode_mb_mode(s, mb, mb_x, mb_y, intra4x4 + 4*mb_x);
1471+ decode_mb_mode(s, mb, mb_x, mb_y, intra4x4_mb);
14651472
14661473 if (!mb->skip)
14671474 decode_mb_coeffs(s, c, mb, s->top_nnz[mb_x], s->left_nnz);
@@ -1471,7 +1478,7 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 3 unmodified lines
14711478 }
14721479
14731480 if (mb->mode <= MODE_I4x4) {
1474− intra_predict(s, dst, mb, intra4x4 + 4*mb_x, mb_x, mb_y);
1481+ intra_predict(s, dst, mb, intra4x4_mb, mb_x, mb_y);
14751482 memset(mb->bmv, 0, sizeof(mb->bmv));
14761483 } else {
14771484 inter_predict(s, dst, mb, mb_x, mb_y);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t