History

avcodec/mpeg4video: Move ff_mpeg4_pred_dc() to decoder

Only used by the decoder now that the encoder solves out-of-slice predictions by setting the out-of-slice values appropriately.

Andreas Rheinhardt committed 1 year ago

Commit 689cde71 parent 56fd45d2 files · +45 −46Browse files

Unified · Split

2 files
  1. libavcodec/mpeg4video.h +0 −44
  2. libavcodec/mpeg4videodec.c +45 −2
libavcodec/mpeg4video.h+0−44
@@ -37,48 +37,4 @@ void ff_mpeg4_init_direct_mv(MpegEncContext *s); · 36 unmodified lines
3737 */
3838 int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
3939
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−
8440 #endif /* AVCODEC_MPEG4VIDEO_H */
libavcodec/mpeg4videodec.c+45−2
@@ -888,6 +888,49 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n) · 887 unmodified lines
888888 return sum;
889889 }
890890
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+
891934 static inline int mpeg4_get_level_dc(MpegEncContext *s, int n, int pred, int level)
892935 {
893936 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
9711014 }
9721015 }
9731016
974− pred = ff_mpeg4_pred_dc(s, n, dir_ptr);
1017+ pred = mpeg4_pred_dc(s, n, dir_ptr);
9751018 return mpeg4_get_level_dc(s, n, pred, level);
9761019 }
9771020
@@ -1362,7 +1405,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 384 unmodified lines
13621405 i = 0;
13631406 } else {
13641407 i = -1;
1365− pred = ff_mpeg4_pred_dc(s, n, &dc_pred_dir);
1408+ pred = mpeg4_pred_dc(s, n, &dc_pred_dir);
13661409 }
13671410 if (!coded)
13681411 goto not_coded;

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