Only used by the decoder now that the encoder solves out-of-slice predictions by setting the out-of-slice values appropriately.
Unified · Split
| @@ -37,48 +37,4 @@ void ff_mpeg4_init_direct_mv(MpegEncContext *s); · 36 unmodified lines | ||
| 37 | 37 | */ |
| 38 | 38 | int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my); |
| 39 | 39 | |
| 40 | −/** | |
| 41 | − * Predict the dc. | |
| 42 | − * @param n block index (0-3 are luma, 4-5 are chroma) | |
| 43 | − * @param dir_ptr pointer to an integer where the prediction direction will be stored | |
| 44 | − */ | |
| 45 | −static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr) | |
| 46 | −{ | |
| 47 | − int a, b, c, wrap, pred; | |
| 48 | − const int16_t *const dc_val = s->dc_val + s->block_index[n]; | |
| 49 | − | |
| 50 | − /* find prediction */ | |
| 51 | − | |
| 52 | − wrap = s->block_wrap[n]; | |
| 53 | − | |
| 54 | − /* B C | |
| 55 | − * A X | |
| 56 | − */ | |
| 57 | − a = dc_val[-1]; | |
| 58 | − b = dc_val[-1 - wrap]; | |
| 59 | − c = dc_val[-wrap]; | |
| 60 | − | |
| 61 | − /* outside slice handling (we can't do that by memset as we need the | |
| 62 | − * dc for error resilience) */ | |
| 63 | − if (s->first_slice_line && n != 3) { | |
| 64 | − if (n != 2) | |
| 65 | − b = c = 1024; | |
| 66 | − if (n != 1 && s->mb_x == s->resync_mb_x) | |
| 67 | − b = a = 1024; | |
| 68 | − } | |
| 69 | − if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1) { | |
| 70 | − if (n == 0 || n == 4 || n == 5) | |
| 71 | − b = 1024; | |
| 72 | − } | |
| 73 | − | |
| 74 | − if (abs(a - b) < abs(b - c)) { | |
| 75 | − pred = c; | |
| 76 | − *dir_ptr = 1; /* top */ | |
| 77 | − } else { | |
| 78 | − pred = a; | |
| 79 | − *dir_ptr = 0; /* left */ | |
| 80 | − } | |
| 81 | − return pred; | |
| 82 | −} | |
| 83 | − | |
| 84 | 40 | #endif /* AVCODEC_MPEG4VIDEO_H */ |
| @@ -888,6 +888,49 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n) · 887 unmodified lines | ||
| 888 | 888 | return sum; |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | +/** | |
| 892 | + * Predict the dc. | |
| 893 | + * @param n block index (0-3 are luma, 4-5 are chroma) | |
| 894 | + * @param dir_ptr pointer to an integer where the prediction direction will be stored | |
| 895 | + */ | |
| 896 | +static inline int mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr) | |
| 897 | +{ | |
| 898 | + const int16_t *const dc_val = s->dc_val + s->block_index[n]; | |
| 899 | + const int wrap = s->block_wrap[n]; | |
| 900 | + int pred; | |
| 901 | + | |
| 902 | + /* find prediction */ | |
| 903 | + | |
| 904 | + /* B C | |
| 905 | + * A X | |
| 906 | + */ | |
| 907 | + int a = dc_val[-1]; | |
| 908 | + int b = dc_val[-1 - wrap]; | |
| 909 | + int c = dc_val[-wrap]; | |
| 910 | + | |
| 911 | + /* outside slice handling (we can't do that by memset as we need the | |
| 912 | + * dc for error resilience) */ | |
| 913 | + if (s->first_slice_line && n != 3) { | |
| 914 | + if (n != 2) | |
| 915 | + b = c = 1024; | |
| 916 | + if (n != 1 && s->mb_x == s->resync_mb_x) | |
| 917 | + b = a = 1024; | |
| 918 | + } | |
| 919 | + if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1) { | |
| 920 | + if (n == 0 || n == 4 || n == 5) | |
| 921 | + b = 1024; | |
| 922 | + } | |
| 923 | + | |
| 924 | + if (abs(a - b) < abs(b - c)) { | |
| 925 | + pred = c; | |
| 926 | + *dir_ptr = 1; /* top */ | |
| 927 | + } else { | |
| 928 | + pred = a; | |
| 929 | + *dir_ptr = 0; /* left */ | |
| 930 | + } | |
| 931 | + return pred; | |
| 932 | +} | |
| 933 | + | |
| 891 | 934 | static inline int mpeg4_get_level_dc(MpegEncContext *s, int n, int pred, int level) |
| 892 | 935 | { |
| 893 | 936 | int scale = n < 4 ? s->y_dc_scale : s->c_dc_scale; |
| @@ -971,7 +1014,7 @@ static inline int mpeg4_decode_dc(MpegEncContext *s, int n, int *dir_ptr) · 77 unmodified lines | ||
| 971 | 1014 | } |
| 972 | 1015 | } |
| 973 | 1016 | |
| 974 | − pred = ff_mpeg4_pred_dc(s, n, dir_ptr); | |
| 1017 | + pred = mpeg4_pred_dc(s, n, dir_ptr); | |
| 975 | 1018 | return mpeg4_get_level_dc(s, n, pred, level); |
| 976 | 1019 | } |
| 977 | 1020 | |
| @@ -1362,7 +1405,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 384 unmodified lines | ||
| 1362 | 1405 | i = 0; |
| 1363 | 1406 | } else { |
| 1364 | 1407 | i = -1; |
| 1365 | − pred = ff_mpeg4_pred_dc(s, n, &dc_pred_dir); | |
| 1408 | + pred = mpeg4_pred_dc(s, n, &dc_pred_dir); | |
| 1366 | 1409 | } |
| 1367 | 1410 | if (!coded) |
| 1368 | 1411 | goto not_coded; |