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
109 */109 */
110 DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];110 DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];
111 DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16];111 DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16];
112 uint8_t intra4x4_pred_mode_mb[16];
112 113
113 int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock114 int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock
114 115
@@ -670,19 +671,22 @@ static int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, · 555 unmodified lines
670static inline void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4,671static inline void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4,
671 int stride, int keyframe)672 int stride, int keyframe)
672{673{
673 int x, y, t, l;674 int x, y, t, l, i;
674 const uint8_t *ctx = vp8_pred4x4_prob_inter;
675 675
676 for (y = 0; y < 4; y++) {676 if (keyframe) {
677 for (x = 0; x < 4; x++) {677 const uint8_t *ctx;
678 if (keyframe) {678 for (y = 0; y < 4; y++) {
679 for (x = 0; x < 4; x++) {
679 t = intra4x4[x - stride];680 t = intra4x4[x - stride];
680 l = intra4x4[x - 1];681 l = intra4x4[x - 1];
681 ctx = vp8_pred4x4_prob_intra[t][l];682 ctx = vp8_pred4x4_prob_intra[t][l];
683 intra4x4[x] = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx);
682 }684 }
683 intra4x4[x] = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx);685 intra4x4 += stride;
684 }686 }
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);
686 }690 }
687}691}
688 692
@@ -753,7 +757,7 @@ static void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, · 64 unmodified lines
753 mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16);757 mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16);
754 758
755 if (mb->mode == MODE_I4x4)759 if (mb->mode == MODE_I4x4)
756 decode_intra4x4_modes(c, intra4x4, s->b4_stride, 0);760 decode_intra4x4_modes(c, intra4x4, 4, 0);
757 761
758 s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, s->prob->pred8x8c);762 s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, s->prob->pred8x8c);
759 mb->ref_frame = VP56_FRAME_CURRENT;763 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
922}926}
923 927
924static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,928static 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)
926{930{
927 int x, y, mode, nnz, tr;931 int x, y, mode, nnz, tr;
928 932
@@ -938,6 +942,7 @@ static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, · 9 unmodified lines
938 s->hpc.pred16x16[mode](dst[0], s->linesize);942 s->hpc.pred16x16[mode](dst[0], s->linesize);
939 } else {943 } else {
940 uint8_t *ptr = dst[0];944 uint8_t *ptr = dst[0];
945 int stride = s->keyframe ? s->b4_stride : 4;
941 946
942 // all blocks on the right edge of the macroblock use bottom edge947 // all blocks on the right edge of the macroblock use bottom edge
943 // the top macroblock for their topright edge948 // 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
956 if (x == 3)961 if (x == 3)
957 topright = tr_right;962 topright = tr_right;
958 963
959 s->hpc.pred4x4[bmode[x]](ptr+4*x, topright, s->linesize);964 s->hpc.pred4x4[intra4x4[x]](ptr+4*x, topright, s->linesize);
960 965
961 nnz = s->non_zero_count_cache[y][x];966 nnz = s->non_zero_count_cache[y][x];
962 if (nnz) {967 if (nnz) {
@@ -969,7 +974,7 @@ static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, · 6 unmodified lines
969 }974 }
970 975
971 ptr += 4*s->linesize;976 ptr += 4*s->linesize;
972 bmode += s->b4_stride;977 intra4x4 += stride;
973 }978 }
974 }979 }
975 980
@@ -1457,11 +1462,13 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 481 unmodified lines
1457 memset(s->top_border, 129, sizeof(*s->top_border));1462 memset(s->top_border, 129, sizeof(*s->top_border));
1458 1463
1459 for (mb_x = 0; mb_x < s->mb_width; mb_x++) {1464 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
1460 /* Prefetch the current frame, 4 MBs ahead */1467 /* Prefetch the current frame, 4 MBs ahead */
1461 s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4);1468 s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4);
1462 s->dsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2);1469 s->dsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2);
1463 1470
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);
1465 1472
1466 if (!mb->skip)1473 if (!mb->skip)
1467 decode_mb_coeffs(s, c, mb, s->top_nnz[mb_x], s->left_nnz);1474 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
1471 }1478 }
1472 1479
1473 if (mb->mode <= MODE_I4x4) {1480 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);
1475 memset(mb->bmv, 0, sizeof(mb->bmv));1482 memset(mb->bmv, 0, sizeof(mb->bmv));
1476 } else {1483 } else {
1477 inter_predict(s, dst, mb, mb_x, mb_y);1484 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