Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
zhaoxiu.zeng authored on 2015/02/13 01:05:36... | ... |
@@ -56,4 +56,15 @@ typedef struct Wmv2Context { |
56 | 56 |
|
57 | 57 |
void ff_wmv2_common_init(Wmv2Context *w); |
58 | 58 |
|
59 |
+static av_always_inline int wmv2_get_cbp_table_index(MpegEncContext *s, int cbp_index) |
|
60 |
+{ |
|
61 |
+ static const uint8_t map[3][3] = { |
|
62 |
+ { 0, 2, 1 }, |
|
63 |
+ { 1, 0, 2 }, |
|
64 |
+ { 2, 1, 0 }, |
|
65 |
+ }; |
|
66 |
+ |
|
67 |
+ return map[(s->qscale > 10) + (s->qscale > 20)][cbp_index]; |
|
68 |
+} |
|
69 |
+ |
|
59 | 70 |
#endif /* AVCODEC_WMV2_H */ |
... | ... |
@@ -173,16 +173,7 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s) |
173 | 173 |
|
174 | 174 |
parse_mb_skip(w); |
175 | 175 |
cbp_index = decode012(&s->gb); |
176 |
- if (s->qscale <= 10) { |
|
177 |
- int map[3] = { 0, 2, 1 }; |
|
178 |
- w->cbp_table_index = map[cbp_index]; |
|
179 |
- } else if (s->qscale <= 20) { |
|
180 |
- int map[3] = { 1, 0, 2 }; |
|
181 |
- w->cbp_table_index = map[cbp_index]; |
|
182 |
- } else { |
|
183 |
- int map[3] = {2,1,0}; |
|
184 |
- w->cbp_table_index = map[cbp_index]; |
|
185 |
- } |
|
176 |
+ w->cbp_table_index = wmv2_get_cbp_table_index(s, cbp_index); |
|
186 | 177 |
|
187 | 178 |
if (w->mspel_bit) |
188 | 179 |
s->mspel = get_bits1(&s->gb); |
... | ... |
@@ -111,16 +111,7 @@ int ff_wmv2_encode_picture_header(MpegEncContext *s, int picture_number) |
111 | 111 |
put_bits(&s->pb, 2, SKIP_TYPE_NONE); |
112 | 112 |
|
113 | 113 |
ff_msmpeg4_code012(&s->pb, cbp_index = 0); |
114 |
- if (s->qscale <= 10) { |
|
115 |
- int map[3] = { 0, 2, 1 }; |
|
116 |
- w->cbp_table_index = map[cbp_index]; |
|
117 |
- } else if (s->qscale <= 20) { |
|
118 |
- int map[3] = { 1, 0, 2 }; |
|
119 |
- w->cbp_table_index = map[cbp_index]; |
|
120 |
- } else { |
|
121 |
- int map[3] = { 2, 1, 0 }; |
|
122 |
- w->cbp_table_index = map[cbp_index]; |
|
123 |
- } |
|
114 |
+ w->cbp_table_index = wmv2_get_cbp_table_index(s, cbp_index); |
|
124 | 115 |
|
125 | 116 |
if (w->mspel_bit) |
126 | 117 |
put_bits(&s->pb, 1, s->mspel); |