| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * RV30/40 decoder common data | ||
| 3 | * Copyright (c) 2007 Mike Melanson, Konstantin Shishkov | ||
| 4 | * | ||
| 5 | * This file is part of FFmpeg. | ||
| 6 | * | ||
| 7 | * FFmpeg is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with FFmpeg; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @file | ||
| 24 | * RV30/40 decoder common data | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include "libavutil/avassert.h" | ||
| 28 | #include "libavutil/imgutils.h" | ||
| 29 | #include "libavutil/internal.h" | ||
| 30 | #include "libavutil/mem.h" | ||
| 31 | #include "libavutil/mem_internal.h" | ||
| 32 | #include "libavutil/thread.h" | ||
| 33 | |||
| 34 | #include "avcodec.h" | ||
| 35 | #include "decode.h" | ||
| 36 | #include "error_resilience.h" | ||
| 37 | #include "mpegutils.h" | ||
| 38 | #include "mpegvideo.h" | ||
| 39 | #include "mpegvideodec.h" | ||
| 40 | #include "golomb.h" | ||
| 41 | #include "mathops.h" | ||
| 42 | #include "mpeg_er.h" | ||
| 43 | #include "qpeldsp.h" | ||
| 44 | #include "rectangle.h" | ||
| 45 | #include "thread.h" | ||
| 46 | #include "threadprogress.h" | ||
| 47 | |||
| 48 | #include "rv34vlc.h" | ||
| 49 | #include "rv34data.h" | ||
| 50 | #include "rv34.h" | ||
| 51 | |||
| 52 | 457801 | static inline void ZERO8x2(void* dst, int stride) | |
| 53 | { | ||
| 54 | 457801 | fill_rectangle(dst, 1, 2, stride, 0, 4); | |
| 55 | 457801 | fill_rectangle(((uint8_t*)(dst))+4, 1, 2, stride, 0, 4); | |
| 56 | 457801 | } | |
| 57 | |||
| 58 | /** translation of RV30/40 macroblock types to lavc ones */ | ||
| 59 | static const int rv34_mb_type_to_lavc[12] = { | ||
| 60 | MB_TYPE_INTRA, | ||
| 61 | MB_TYPE_INTRA16x16 | MB_TYPE_SEPARATE_DC, | ||
| 62 | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV, | ||
| 63 | MB_TYPE_8x8 | MB_TYPE_FORWARD_MV, | ||
| 64 | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV, | ||
| 65 | MB_TYPE_16x16 | MB_TYPE_BACKWARD_MV, | ||
| 66 | MB_TYPE_SKIP, | ||
| 67 | MB_TYPE_DIRECT2 | MB_TYPE_16x16, | ||
| 68 | MB_TYPE_16x8 | MB_TYPE_FORWARD_MV, | ||
| 69 | MB_TYPE_8x16 | MB_TYPE_FORWARD_MV, | ||
| 70 | MB_TYPE_16x16 | MB_TYPE_BIDIR_MV, | ||
| 71 | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV | MB_TYPE_SEPARATE_DC | ||
| 72 | }; | ||
| 73 | |||
| 74 | |||
| 75 | static RV34VLC intra_vlcs[NUM_INTRA_TABLES], inter_vlcs[NUM_INTER_TABLES]; | ||
| 76 | |||
| 77 | static int rv34_decode_mv(RV34DecContext *r, int block_type); | ||
| 78 | |||
| 79 | /** | ||
| 80 | * @name RV30/40 VLC generating functions | ||
| 81 | * @{ | ||
| 82 | */ | ||
| 83 | |||
| 84 | static VLCElem table_data[117592]; | ||
| 85 | |||
| 86 | /** | ||
| 87 | * Generate VLC from codeword lengths. | ||
| 88 | * @param bits codeword lengths (zeroes are accepted) | ||
| 89 | * @param size length of input data | ||
| 90 | * @param vlc output VLC | ||
| 91 | * @param insyms symbols for input codes (NULL for default ones) | ||
| 92 | * @param num VLC table number (for static initialization) | ||
| 93 | */ | ||
| 94 | 895 | static av_cold void rv34_gen_vlc_ext(const uint8_t *bits, int size, VLC *vlc, | |
| 95 | const uint8_t *syms, int mod_three_bits_offset, int *offset) | ||
| 96 | { | ||
| 97 | 895 | int counts[17] = {0}, codes[17]; | |
| 98 | int maxbits; | ||
| 99 | |||
| 100 | av_assert1(size > 0); | ||
| 101 | |||
| 102 |
2/2✓ Branch 0 taken 290320 times.
✓ Branch 1 taken 895 times.
|
291215 | for (int i = 0; i < size; i++) |
| 103 | 290320 | counts[bits[i]]++; | |
| 104 | |||
| 105 | /* bits[0] is zero for some tables, i.e. syms actually starts at 1. | ||
| 106 | * So we reset it here. The code assigned to this element is 0x00. */ | ||
| 107 | 895 | codes[0] = counts[0] = 0; | |
| 108 |
2/2✓ Branch 0 taken 14320 times.
✓ Branch 1 taken 895 times.
|
15215 | for (int i = 0; i < 16; i++) { |
| 109 | 14320 | codes[i+1] = (codes[i] + counts[i]) << 1; | |
| 110 |
2/2✓ Branch 0 taken 8095 times.
✓ Branch 1 taken 6225 times.
|
14320 | if (counts[i]) |
| 111 | 8095 | maxbits = i; | |
| 112 | } | ||
| 113 | |||
| 114 | uint16_t symbols[MAX_VLC_SIZE]; | ||
| 115 | uint16_t cw[MAX_VLC_SIZE]; | ||
| 116 | 895 | const void *symp = syms; | |
| 117 | int symbol_size; | ||
| 118 | |||
| 119 |
2/2✓ Branch 0 taken 255 times.
✓ Branch 1 taken 640 times.
|
895 | if (mod_three_bits_offset > 0) { |
| 120 | 255 | symp = symbols; | |
| 121 | 255 | symbol_size = 2; | |
| 122 | |||
| 123 |
2/2✓ Branch 0 taken 257040 times.
✓ Branch 1 taken 255 times.
|
257295 | for (int i = 0, mask = (1 << mod_three_bits_offset) - 1; i < size; ++i) { |
| 124 | 257040 | cw[i] = codes[bits[i]]++; | |
| 125 | 257040 | symbols[i] = (modulo_three_table[i >> mod_three_bits_offset] << mod_three_bits_offset) | (i & mask); | |
| 126 | } | ||
| 127 | } else { | ||
| 128 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 400 times.
|
640 | if (!mod_three_bits_offset) |
| 129 | 240 | symp = modulo_three_table; | |
| 130 | |||
| 131 | 640 | symbol_size = !!symp; | |
| 132 |
2/2✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 640 times.
|
33920 | for (int i = 0; i < size; ++i) |
| 133 | 33280 | cw[i] = codes[bits[i]]++; | |
| 134 | } | ||
| 135 | |||
| 136 | 895 | vlc->table = &table_data[*offset]; | |
| 137 | 895 | vlc->table_allocated = FF_ARRAY_ELEMS(table_data) - *offset; | |
| 138 | 895 | ff_vlc_init_sparse(vlc, FFMIN(maxbits, 9), size, | |
| 139 | bits, 1, 1, | ||
| 140 | cw, 2, 2, | ||
| 141 | symp, symbol_size, symbol_size, VLC_INIT_STATIC_OVERLONG); | ||
| 142 | 895 | *offset += vlc->table_size; | |
| 143 | 895 | } | |
| 144 | |||
| 145 | 555 | static av_cold void rv34_gen_vlc(const uint8_t *bits, int size, const VLCElem **vlcp, | |
| 146 | int mod_three_bits_offset, int *offset) | ||
| 147 | { | ||
| 148 | 555 | VLC vlc = { 0 }; | |
| 149 | 555 | rv34_gen_vlc_ext(bits, size, &vlc, NULL, mod_three_bits_offset, offset); | |
| 150 | 555 | *vlcp = vlc.table; | |
| 151 | 555 | } | |
| 152 | |||
| 153 | /** | ||
| 154 | * Initialize all tables. | ||
| 155 | */ | ||
| 156 | 5 | static av_cold void rv34_init_tables(void) | |
| 157 | { | ||
| 158 | 5 | int i, j, k, offset = 0; | |
| 159 | |||
| 160 |
2/2✓ Branch 0 taken 25 times.
✓ Branch 1 taken 5 times.
|
30 | for(i = 0; i < NUM_INTRA_TABLES; i++){ |
| 161 |
2/2✓ Branch 0 taken 50 times.
✓ Branch 1 taken 25 times.
|
75 | for(j = 0; j < 2; j++){ |
| 162 | 50 | rv34_gen_vlc(rv34_table_intra_cbppat [i][j], CBPPAT_VLC_SIZE, | |
| 163 | &intra_vlcs[i].cbppattern[j], 4, &offset); | ||
| 164 | 50 | rv34_gen_vlc(rv34_table_intra_secondpat[i][j], OTHERBLK_VLC_SIZE, | |
| 165 | &intra_vlcs[i].second_pattern[j], 0, &offset); | ||
| 166 | 50 | rv34_gen_vlc(rv34_table_intra_thirdpat [i][j], OTHERBLK_VLC_SIZE, | |
| 167 | &intra_vlcs[i].third_pattern[j], 0, &offset); | ||
| 168 |
2/2✓ Branch 0 taken 200 times.
✓ Branch 1 taken 50 times.
|
250 | for(k = 0; k < 4; k++){ |
| 169 | 200 | rv34_gen_vlc_ext(rv34_table_intra_cbp[i][j+k*2], CBP_VLC_SIZE, | |
| 170 | &intra_vlcs[i].cbp[j][k], rv34_cbp_code, -1, &offset); | ||
| 171 | } | ||
| 172 | } | ||
| 173 |
2/2✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
|
125 | for(j = 0; j < 4; j++){ |
| 174 | 100 | rv34_gen_vlc(rv34_table_intra_firstpat[i][j], FIRSTBLK_VLC_SIZE, | |
| 175 | &intra_vlcs[i].first_pattern[j], 3, &offset); | ||
| 176 | } | ||
| 177 | 25 | rv34_gen_vlc(rv34_intra_coeff[i], COEFF_VLC_SIZE, | |
| 178 | &intra_vlcs[i].coefficient, -1, &offset); | ||
| 179 | } | ||
| 180 | |||
| 181 |
2/2✓ Branch 0 taken 35 times.
✓ Branch 1 taken 5 times.
|
40 | for(i = 0; i < NUM_INTER_TABLES; i++){ |
| 182 | 35 | rv34_gen_vlc(rv34_inter_cbppat[i], CBPPAT_VLC_SIZE, | |
| 183 | &inter_vlcs[i].cbppattern[0], 4, &offset); | ||
| 184 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 35 times.
|
175 | for(j = 0; j < 4; j++){ |
| 185 | 140 | rv34_gen_vlc_ext(rv34_inter_cbp[i][j], CBP_VLC_SIZE, | |
| 186 | &inter_vlcs[i].cbp[0][j], rv34_cbp_code, -1, &offset); | ||
| 187 | } | ||
| 188 |
2/2✓ Branch 0 taken 70 times.
✓ Branch 1 taken 35 times.
|
105 | for(j = 0; j < 2; j++){ |
| 189 | 70 | rv34_gen_vlc(rv34_table_inter_firstpat [i][j], FIRSTBLK_VLC_SIZE, | |
| 190 | &inter_vlcs[i].first_pattern[j], 3, &offset); | ||
| 191 | 70 | rv34_gen_vlc(rv34_table_inter_secondpat[i][j], OTHERBLK_VLC_SIZE, | |
| 192 | &inter_vlcs[i].second_pattern[j], 0, &offset); | ||
| 193 | 70 | rv34_gen_vlc(rv34_table_inter_thirdpat [i][j], OTHERBLK_VLC_SIZE, | |
| 194 | &inter_vlcs[i].third_pattern[j], 0, &offset); | ||
| 195 | } | ||
| 196 | 35 | rv34_gen_vlc(rv34_inter_coeff[i], COEFF_VLC_SIZE, | |
| 197 | &inter_vlcs[i].coefficient, -1, &offset); | ||
| 198 | } | ||
| 199 | 5 | } | |
| 200 | |||
| 201 | /** @} */ // vlc group | ||
| 202 | |||
| 203 | /** | ||
| 204 | * @name RV30/40 4x4 block decoding functions | ||
| 205 | * @{ | ||
| 206 | */ | ||
| 207 | |||
| 208 | /** | ||
| 209 | * Decode coded block pattern. | ||
| 210 | */ | ||
| 211 | 129866 | static int rv34_decode_cbp(GetBitContext *gb, const RV34VLC *vlc, int table) | |
| 212 | { | ||
| 213 | 129866 | int pattern, code, cbp=0; | |
| 214 | int ones; | ||
| 215 | static const int cbp_masks[3] = {0x100000, 0x010000, 0x110000}; | ||
| 216 | static const int shifts[4] = { 0, 2, 8, 10 }; | ||
| 217 | 129866 | const int *curshift = shifts; | |
| 218 | int i, t, mask; | ||
| 219 | |||
| 220 | 129866 | code = get_vlc2(gb, vlc->cbppattern[table], 9, 2); | |
| 221 | 129866 | pattern = code & 0xF; | |
| 222 | 129866 | code >>= 4; | |
| 223 | |||
| 224 | 129866 | ones = rv34_count_ones[pattern]; | |
| 225 | |||
| 226 |
2/2✓ Branch 0 taken 519464 times.
✓ Branch 1 taken 129866 times.
|
649330 | for(mask = 8; mask; mask >>= 1, curshift++){ |
| 227 |
2/2✓ Branch 0 taken 182302 times.
✓ Branch 1 taken 337162 times.
|
519464 | if(pattern & mask) |
| 228 | 182302 | cbp |= get_vlc2(gb, vlc->cbp[table][ones].table, vlc->cbp[table][ones].bits, 1) << curshift[0]; | |
| 229 | } | ||
| 230 | |||
| 231 |
2/2✓ Branch 0 taken 519464 times.
✓ Branch 1 taken 129866 times.
|
649330 | for(i = 0; i < 4; i++){ |
| 232 | 519464 | t = (code >> (6 - 2*i)) & 3; | |
| 233 |
2/2✓ Branch 0 taken 121745 times.
✓ Branch 1 taken 397719 times.
|
519464 | if(t == 1) |
| 234 | 121745 | cbp |= cbp_masks[get_bits1(gb)] << i; | |
| 235 |
2/2✓ Branch 0 taken 59551 times.
✓ Branch 1 taken 459913 times.
|
519464 | if(t == 2) |
| 236 | 59551 | cbp |= cbp_masks[2] << i; | |
| 237 | } | ||
| 238 | 129866 | return cbp; | |
| 239 | } | ||
| 240 | |||
| 241 | /** | ||
| 242 | * Get one coefficient value from the bitstream and store it. | ||
| 243 | */ | ||
| 244 | 2282071 | static inline void decode_coeff(int16_t *dst, int coef, int esc, GetBitContext *gb, | |
| 245 | const VLCElem *vlc, int q) | ||
| 246 | { | ||
| 247 |
2/2✓ Branch 0 taken 1165141 times.
✓ Branch 1 taken 1116930 times.
|
2282071 | if(coef){ |
| 248 |
2/2✓ Branch 0 taken 159314 times.
✓ Branch 1 taken 1005827 times.
|
1165141 | if(coef == esc){ |
| 249 | 159314 | coef = get_vlc2(gb, vlc, 9, 2); | |
| 250 |
2/2✓ Branch 0 taken 139 times.
✓ Branch 1 taken 159175 times.
|
159314 | if(coef > 23){ |
| 251 | 139 | coef -= 23; | |
| 252 | 139 | coef = 22 + ((1 << coef) | get_bits(gb, coef)); | |
| 253 | } | ||
| 254 | 159314 | coef += esc; | |
| 255 | } | ||
| 256 |
2/2✓ Branch 1 taken 575126 times.
✓ Branch 2 taken 590015 times.
|
1165141 | if(get_bits1(gb)) |
| 257 | 575126 | coef = -coef; | |
| 258 | 1165141 | *dst = (coef*q + 8) >> 4; | |
| 259 | } | ||
| 260 | 2282071 | } | |
| 261 | |||
| 262 | /** | ||
| 263 | * Decode 2x2 subblock of coefficients. | ||
| 264 | */ | ||
| 265 | 135062 | static inline void decode_subblock(int16_t *dst, int flags, const int is_block2, | |
| 266 | GetBitContext *gb, const VLCElem *vlc, int q) | ||
| 267 | { | ||
| 268 | 135062 | decode_coeff( dst+0*4+0, (flags >> 6) , 3, gb, vlc, q); | |
| 269 |
2/2✓ Branch 0 taken 83849 times.
✓ Branch 1 taken 51213 times.
|
135062 | if(is_block2){ |
| 270 | 83849 | decode_coeff(dst+1*4+0, (flags >> 4) & 3, 2, gb, vlc, q); | |
| 271 | 83849 | decode_coeff(dst+0*4+1, (flags >> 2) & 3, 2, gb, vlc, q); | |
| 272 | }else{ | ||
| 273 | 51213 | decode_coeff(dst+0*4+1, (flags >> 4) & 3, 2, gb, vlc, q); | |
| 274 | 51213 | decode_coeff(dst+1*4+0, (flags >> 2) & 3, 2, gb, vlc, q); | |
| 275 | } | ||
| 276 | 135062 | decode_coeff( dst+1*4+1, (flags >> 0) & 3, 2, gb, vlc, q); | |
| 277 | 135062 | } | |
| 278 | |||
| 279 | /** | ||
| 280 | * Decode a single coefficient. | ||
| 281 | */ | ||
| 282 | 406803 | static inline void decode_subblock1(int16_t *dst, int flags, GetBitContext *gb, | |
| 283 | const VLCElem *vlc, int q) | ||
| 284 | { | ||
| 285 | 406803 | int coeff = flags >> 6; | |
| 286 | 406803 | decode_coeff(dst, coeff, 3, gb, vlc, q); | |
| 287 | 406803 | } | |
| 288 | |||
| 289 | 333755 | static inline void decode_subblock3(int16_t *dst, int flags, GetBitContext *gb, | |
| 290 | const VLCElem *vlc, | ||
| 291 | int q_dc, int q_ac1, int q_ac2) | ||
| 292 | { | ||
| 293 | 333755 | decode_coeff(dst+0*4+0, (flags >> 6) , 3, gb, vlc, q_dc); | |
| 294 | 333755 | decode_coeff(dst+0*4+1, (flags >> 4) & 3, 2, gb, vlc, q_ac1); | |
| 295 | 333755 | decode_coeff(dst+1*4+0, (flags >> 2) & 3, 2, gb, vlc, q_ac1); | |
| 296 | 333755 | decode_coeff(dst+1*4+1, (flags >> 0) & 3, 2, gb, vlc, q_ac2); | |
| 297 | 333755 | } | |
| 298 | |||
| 299 | /** | ||
| 300 | * Decode coefficients for 4x4 block. | ||
| 301 | * | ||
| 302 | * This is done by filling 2x2 subblocks with decoded coefficients | ||
| 303 | * in this order (the same for subblocks and subblock coefficients): | ||
| 304 | * o--o | ||
| 305 | * / | ||
| 306 | * / | ||
| 307 | * o--o | ||
| 308 | */ | ||
| 309 | |||
| 310 | 740558 | static int rv34_decode_block(int16_t *dst, GetBitContext *gb, const RV34VLC *rvlc, | |
| 311 | int fc, int sc, int q_dc, int q_ac1, int q_ac2) | ||
| 312 | { | ||
| 313 | 740558 | int flags = get_vlc2(gb, rvlc->first_pattern[fc], 9, 2); | |
| 314 | |||
| 315 | 740558 | int pattern = flags & 0x7; | |
| 316 | |||
| 317 | 740558 | flags >>= 3; | |
| 318 | |||
| 319 |
2/2✓ Branch 0 taken 333755 times.
✓ Branch 1 taken 406803 times.
|
740558 | if (flags & 0x3F) { |
| 320 | 333755 | decode_subblock3(dst, flags, gb, rvlc->coefficient, q_dc, q_ac1, q_ac2); | |
| 321 | } else { | ||
| 322 | 406803 | decode_subblock1(dst, flags, gb, rvlc->coefficient, q_dc); | |
| 323 |
2/2✓ Branch 0 taken 365599 times.
✓ Branch 1 taken 41204 times.
|
406803 | if (!pattern) |
| 324 | 365599 | return 0; | |
| 325 | } | ||
| 326 | |||
| 327 |
2/2✓ Branch 0 taken 44969 times.
✓ Branch 1 taken 329990 times.
|
374959 | if(pattern & 4){ |
| 328 | 44969 | flags = get_vlc2(gb, rvlc->second_pattern[sc], 9, 2); | |
| 329 | 44969 | decode_subblock(dst + 4*0+2, flags, 0, gb, rvlc->coefficient, q_ac2); | |
| 330 | } | ||
| 331 |
2/2✓ Branch 0 taken 83849 times.
✓ Branch 1 taken 291110 times.
|
374959 | if(pattern & 2){ // Looks like coefficients 1 and 2 are swapped for this block |
| 332 | 83849 | flags = get_vlc2(gb, rvlc->second_pattern[sc], 9, 2); | |
| 333 | 83849 | decode_subblock(dst + 4*2+0, flags, 1, gb, rvlc->coefficient, q_ac2); | |
| 334 | } | ||
| 335 |
2/2✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 368715 times.
|
374959 | if(pattern & 1){ |
| 336 | 6244 | flags = get_vlc2(gb, rvlc->third_pattern[sc], 9, 2); | |
| 337 | 6244 | decode_subblock(dst + 4*2+2, flags, 0, gb, rvlc->coefficient, q_ac2); | |
| 338 | } | ||
| 339 | 374959 | return 1; | |
| 340 | } | ||
| 341 | |||
| 342 | /** | ||
| 343 | * @name RV30/40 bitstream parsing | ||
| 344 | * @{ | ||
| 345 | */ | ||
| 346 | |||
| 347 | /** | ||
| 348 | * Decode starting slice position. | ||
| 349 | * @todo Maybe replace with ff_h263_decode_mba() ? | ||
| 350 | */ | ||
| 351 | 2786 | int ff_rv34_get_start_offset(GetBitContext *gb, int mb_size) | |
| 352 | { | ||
| 353 | int i; | ||
| 354 |
1/2✓ Branch 0 taken 10432 times.
✗ Branch 1 not taken.
|
10432 | for(i = 0; i < 5; i++) |
| 355 |
2/2✓ Branch 0 taken 2786 times.
✓ Branch 1 taken 7646 times.
|
10432 | if(rv34_mb_max_sizes[i] >= mb_size - 1) |
| 356 | 2786 | break; | |
| 357 | 2786 | return get_bits(gb, rv34_mb_bits_sizes[i]); | |
| 358 | } | ||
| 359 | |||
| 360 | /** | ||
| 361 | * Select VLC set for decoding from current quantizer, modifier and frame type. | ||
| 362 | */ | ||
| 363 | 130964 | static inline RV34VLC* choose_vlc_set(int quant, int mod, int type) | |
| 364 | { | ||
| 365 |
4/4✓ Branch 0 taken 60927 times.
✓ Branch 1 taken 70037 times.
✓ Branch 2 taken 60450 times.
✓ Branch 3 taken 477 times.
|
130964 | if(mod == 2 && quant < 19) quant += 10; |
| 366 |
3/4✓ Branch 0 taken 24464 times.
✓ Branch 1 taken 46050 times.
✓ Branch 2 taken 24464 times.
✗ Branch 3 not taken.
|
70514 | else if(mod && quant < 26) quant += 5; |
| 367 | av_assert2(quant >= 0 && quant < 32); | ||
| 368 | 98400 | return type ? &inter_vlcs[rv34_quant_to_vlc_set[1][quant]] | |
| 369 |
2/2✓ Branch 0 taken 98400 times.
✓ Branch 1 taken 32564 times.
|
130964 | : &intra_vlcs[rv34_quant_to_vlc_set[0][quant]]; |
| 370 | } | ||
| 371 | |||
| 372 | /** | ||
| 373 | * Decode intra macroblock header and return CBP in case of success, -1 otherwise. | ||
| 374 | */ | ||
| 375 | 7640 | static int rv34_decode_intra_mb_header(RV34DecContext *r, int8_t *intra_types) | |
| 376 | { | ||
| 377 | 7640 | MpegEncContext *s = &r->s; | |
| 378 | 7640 | GetBitContext *const gb = &r->gb; | |
| 379 | 7640 | int mb_pos = s->mb_x + s->mb_y * s->mb_stride; | |
| 380 | int t; | ||
| 381 | |||
| 382 | 7640 | r->is16 = get_bits1(gb); | |
| 383 |
2/2✓ Branch 0 taken 5830 times.
✓ Branch 1 taken 1810 times.
|
7640 | if(r->is16){ |
| 384 | 5830 | s->cur_pic.mb_type[mb_pos] = MB_TYPE_INTRA16x16; | |
| 385 | 5830 | r->block_type = RV34_MB_TYPE_INTRA16x16; | |
| 386 | 5830 | t = get_bits(gb, 2); | |
| 387 | 5830 | fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); | |
| 388 | 5830 | r->luma_vlc = 2; | |
| 389 | }else{ | ||
| 390 |
2/2✓ Branch 0 taken 467 times.
✓ Branch 1 taken 1343 times.
|
1810 | if(!r->rv30){ |
| 391 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
|
467 | if(!get_bits1(gb)) |
| 392 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n"); | |
| 393 | } | ||
| 394 | 1810 | s->cur_pic.mb_type[mb_pos] = MB_TYPE_INTRA; | |
| 395 | 1810 | r->block_type = RV34_MB_TYPE_INTRA; | |
| 396 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1810 times.
|
1810 | if(r->decode_intra_types(r, gb, intra_types) < 0) |
| 397 | ✗ | return -1; | |
| 398 | 1810 | r->luma_vlc = 1; | |
| 399 | } | ||
| 400 | |||
| 401 | 7640 | r->chroma_vlc = 0; | |
| 402 | 7640 | r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); | |
| 403 | |||
| 404 | 7640 | return rv34_decode_cbp(gb, r->cur_vlcs, r->is16); | |
| 405 | } | ||
| 406 | |||
| 407 | /** | ||
| 408 | * Decode inter macroblock header and return CBP in case of success, -1 otherwise. | ||
| 409 | */ | ||
| 410 | 286800 | static int rv34_decode_inter_mb_header(RV34DecContext *r, int8_t *intra_types) | |
| 411 | { | ||
| 412 | 286800 | MpegEncContext *s = &r->s; | |
| 413 | 286800 | GetBitContext *const gb = &r->gb; | |
| 414 | 286800 | int mb_pos = s->mb_x + s->mb_y * s->mb_stride; | |
| 415 | int i, t; | ||
| 416 | |||
| 417 | 286800 | r->block_type = r->decode_mb_info(r); | |
| 418 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 286800 times.
|
286800 | if(r->block_type == -1) |
| 419 | ✗ | return -1; | |
| 420 | 286800 | s->cur_pic.mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type]; | |
| 421 | 286800 | r->mb_type[mb_pos] = r->block_type; | |
| 422 |
2/2✓ Branch 0 taken 164574 times.
✓ Branch 1 taken 122226 times.
|
286800 | if(r->block_type == RV34_MB_SKIP){ |
| 423 |
2/2✓ Branch 0 taken 31715 times.
✓ Branch 1 taken 132859 times.
|
164574 | if(s->pict_type == AV_PICTURE_TYPE_P) |
| 424 | 31715 | r->mb_type[mb_pos] = RV34_MB_P_16x16; | |
| 425 |
2/2✓ Branch 0 taken 132859 times.
✓ Branch 1 taken 31715 times.
|
164574 | if(s->pict_type == AV_PICTURE_TYPE_B) |
| 426 | 132859 | r->mb_type[mb_pos] = RV34_MB_B_DIRECT; | |
| 427 | } | ||
| 428 | 286800 | r->is16 = !!IS_INTRA16x16(s->cur_pic.mb_type[mb_pos]); | |
| 429 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 286800 times.
|
286800 | if (rv34_decode_mv(r, r->block_type) < 0) |
| 430 | ✗ | return -1; | |
| 431 |
2/2✓ Branch 0 taken 164574 times.
✓ Branch 1 taken 122226 times.
|
286800 | if(r->block_type == RV34_MB_SKIP){ |
| 432 | 164574 | fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0])); | |
| 433 | 164574 | return 0; | |
| 434 | } | ||
| 435 | 122226 | r->chroma_vlc = 1; | |
| 436 | 122226 | r->luma_vlc = 0; | |
| 437 | |||
| 438 |
2/2✓ Branch 0 taken 24375 times.
✓ Branch 1 taken 97851 times.
|
122226 | if (IS_INTRA(s->cur_pic.mb_type[mb_pos])) { |
| 439 |
2/2✓ Branch 0 taken 11056 times.
✓ Branch 1 taken 13319 times.
|
24375 | if(r->is16){ |
| 440 | 11056 | t = get_bits(gb, 2); | |
| 441 | 11056 | fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0])); | |
| 442 | 11056 | r->luma_vlc = 2; | |
| 443 | }else{ | ||
| 444 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 13319 times.
|
13319 | if(r->decode_intra_types(r, gb, intra_types) < 0) |
| 445 | ✗ | return -1; | |
| 446 | 13319 | r->luma_vlc = 1; | |
| 447 | } | ||
| 448 | 24375 | r->chroma_vlc = 0; | |
| 449 | 24375 | r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); | |
| 450 | }else{ | ||
| 451 |
2/2✓ Branch 0 taken 1565616 times.
✓ Branch 1 taken 97851 times.
|
1663467 | for(i = 0; i < 16; i++) |
| 452 | 1565616 | intra_types[(i & 3) + (i>>2) * r->intra_types_stride] = 0; | |
| 453 | 97851 | r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); | |
| 454 |
2/2✓ Branch 0 taken 549 times.
✓ Branch 1 taken 97302 times.
|
97851 | if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){ |
| 455 | 549 | r->is16 = 1; | |
| 456 | 549 | r->chroma_vlc = 1; | |
| 457 | 549 | r->luma_vlc = 2; | |
| 458 | 549 | r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0); | |
| 459 | } | ||
| 460 | } | ||
| 461 | |||
| 462 | 122226 | return rv34_decode_cbp(gb, r->cur_vlcs, r->is16); | |
| 463 | } | ||
| 464 | |||
| 465 | /** @} */ //bitstream functions | ||
| 466 | |||
| 467 | /** | ||
| 468 | * @name motion vector related code (prediction, reconstruction, motion compensation) | ||
| 469 | * @{ | ||
| 470 | */ | ||
| 471 | |||
| 472 | /** macroblock partition width in 8x8 blocks */ | ||
| 473 | static const uint8_t part_sizes_w[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2 }; | ||
| 474 | |||
| 475 | /** macroblock partition height in 8x8 blocks */ | ||
| 476 | static const uint8_t part_sizes_h[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2 }; | ||
| 477 | |||
| 478 | /** availability index for subblocks */ | ||
| 479 | static const uint8_t avail_indexes[4] = { 6, 7, 10, 11 }; | ||
| 480 | |||
| 481 | /** | ||
| 482 | * motion vector prediction | ||
| 483 | * | ||
| 484 | * Motion prediction performed for the block by using median prediction of | ||
| 485 | * motion vectors from the left, top and right top blocks but in corner cases | ||
| 486 | * some other vectors may be used instead. | ||
| 487 | */ | ||
| 488 | 42942 | static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int dmv_no) | |
| 489 | { | ||
| 490 | 42942 | MpegEncContext *s = &r->s; | |
| 491 | 42942 | int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; | |
| 492 | 42942 | int A[2] = {0}, B[2], C[2]; | |
| 493 | int i, j; | ||
| 494 | int mx, my; | ||
| 495 | 42942 | int* avail = r->avail_cache + avail_indexes[subblock_no]; | |
| 496 | 42942 | int c_off = part_sizes_w[block_type]; | |
| 497 | 42942 | int16_t (*motion_val)[2] = s->cur_pic.motion_val[0]; | |
| 498 | |||
| 499 | 42942 | mv_pos += (subblock_no & 1) + (subblock_no >> 1)*s->b8_stride; | |
| 500 |
2/2✓ Branch 0 taken 4544 times.
✓ Branch 1 taken 38398 times.
|
42942 | if(subblock_no == 3) |
| 501 | 4544 | c_off = -1; | |
| 502 | |||
| 503 |
2/2✓ Branch 0 taken 41455 times.
✓ Branch 1 taken 1487 times.
|
42942 | if(avail[-1]){ |
| 504 | 41455 | A[0] = motion_val[mv_pos-1][0]; | |
| 505 | 41455 | A[1] = motion_val[mv_pos-1][1]; | |
| 506 | } | ||
| 507 |
2/2✓ Branch 0 taken 30578 times.
✓ Branch 1 taken 12364 times.
|
42942 | if(avail[-4]){ |
| 508 | 30578 | B[0] = motion_val[mv_pos-s->b8_stride][0]; | |
| 509 | 30578 | B[1] = motion_val[mv_pos-s->b8_stride][1]; | |
| 510 | }else{ | ||
| 511 | 12364 | B[0] = A[0]; | |
| 512 | 12364 | B[1] = A[1]; | |
| 513 | } | ||
| 514 |
2/2✓ Branch 0 taken 14048 times.
✓ Branch 1 taken 28894 times.
|
42942 | if(!avail[c_off-4]){ |
| 515 |
5/6✓ Branch 0 taken 1883 times.
✓ Branch 1 taken 12165 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 1831 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52 times.
|
14048 | if(avail[-4] && (avail[-1] || r->rv30)){ |
| 516 | 1831 | C[0] = motion_val[mv_pos-s->b8_stride-1][0]; | |
| 517 | 1831 | C[1] = motion_val[mv_pos-s->b8_stride-1][1]; | |
| 518 | }else{ | ||
| 519 | 12217 | C[0] = A[0]; | |
| 520 | 12217 | C[1] = A[1]; | |
| 521 | } | ||
| 522 | }else{ | ||
| 523 | 28894 | C[0] = motion_val[mv_pos-s->b8_stride+c_off][0]; | |
| 524 | 28894 | C[1] = motion_val[mv_pos-s->b8_stride+c_off][1]; | |
| 525 | } | ||
| 526 | 42942 | mx = mid_pred(A[0], B[0], C[0]); | |
| 527 | 42942 | my = mid_pred(A[1], B[1], C[1]); | |
| 528 | 42942 | mx += r->dmv[dmv_no][0]; | |
| 529 | 42942 | my += r->dmv[dmv_no][1]; | |
| 530 |
2/2✓ Branch 0 taken 64988 times.
✓ Branch 1 taken 42942 times.
|
107930 | for(j = 0; j < part_sizes_h[block_type]; j++){ |
| 531 |
2/2✓ Branch 0 taken 101864 times.
✓ Branch 1 taken 64988 times.
|
166852 | for(i = 0; i < part_sizes_w[block_type]; i++){ |
| 532 | 101864 | motion_val[mv_pos + i + j*s->b8_stride][0] = mx; | |
| 533 | 101864 | motion_val[mv_pos + i + j*s->b8_stride][1] = my; | |
| 534 | } | ||
| 535 | } | ||
| 536 | 42942 | } | |
| 537 | |||
| 538 | #define GET_PTS_DIFF(a, b) (((a) - (b) + 8192) & 0x1FFF) | ||
| 539 | |||
| 540 | /** | ||
| 541 | * Calculate motion vector component that should be added for direct blocks. | ||
| 542 | */ | ||
| 543 | 810576 | static int calc_add_mv(RV34DecContext *r, int dir, int val) | |
| 544 | { | ||
| 545 |
2/2✓ Branch 0 taken 405288 times.
✓ Branch 1 taken 405288 times.
|
810576 | int mul = dir ? -r->mv_weight2 : r->mv_weight1; |
| 546 | |||
| 547 | 810576 | return (int)(val * (SUINT)mul + 0x2000) >> 14; | |
| 548 | } | ||
| 549 | |||
| 550 | /** | ||
| 551 | * Predict motion vector for B-frame macroblock. | ||
| 552 | */ | ||
| 553 | 47304 | static inline void rv34_pred_b_vector(int A[2], int B[2], int C[2], | |
| 554 | int A_avail, int B_avail, int C_avail, | ||
| 555 | int *mx, int *my) | ||
| 556 | { | ||
| 557 |
2/2✓ Branch 0 taken 34556 times.
✓ Branch 1 taken 12748 times.
|
47304 | if(A_avail + B_avail + C_avail != 3){ |
| 558 | 34556 | *mx = A[0] + B[0] + C[0]; | |
| 559 | 34556 | *my = A[1] + B[1] + C[1]; | |
| 560 |
2/2✓ Branch 0 taken 11663 times.
✓ Branch 1 taken 22893 times.
|
34556 | if(A_avail + B_avail + C_avail == 2){ |
| 561 | 11663 | *mx /= 2; | |
| 562 | 11663 | *my /= 2; | |
| 563 | } | ||
| 564 | }else{ | ||
| 565 | 12748 | *mx = mid_pred(A[0], B[0], C[0]); | |
| 566 | 12748 | *my = mid_pred(A[1], B[1], C[1]); | |
| 567 | } | ||
| 568 | 47304 | } | |
| 569 | |||
| 570 | /** | ||
| 571 | * motion vector prediction for B-frames | ||
| 572 | */ | ||
| 573 | 47304 | static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) | |
| 574 | { | ||
| 575 | 47304 | MpegEncContext *s = &r->s; | |
| 576 | 47304 | int mb_pos = s->mb_x + s->mb_y * s->mb_stride; | |
| 577 | 47304 | int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; | |
| 578 | 47304 | int A[2] = { 0 }, B[2] = { 0 }, C[2] = { 0 }; | |
| 579 | 47304 | int has_A = 0, has_B = 0, has_C = 0; | |
| 580 | int mx, my; | ||
| 581 | int i, j; | ||
| 582 | 47304 | MPVWorkPicture *cur_pic = &s->cur_pic; | |
| 583 |
2/2✓ Branch 0 taken 24486 times.
✓ Branch 1 taken 22818 times.
|
47304 | const int mask = dir ? MB_TYPE_BACKWARD_MV : MB_TYPE_FORWARD_MV; |
| 584 | 47304 | int type = cur_pic->mb_type[mb_pos]; | |
| 585 | |||
| 586 |
2/2✓ Branch 0 taken 29735 times.
✓ Branch 1 taken 17569 times.
|
47304 | if((r->avail_cache[6-1] & type) & mask){ |
| 587 | 29735 | A[0] = cur_pic->motion_val[dir][mv_pos - 1][0]; | |
| 588 | 29735 | A[1] = cur_pic->motion_val[dir][mv_pos - 1][1]; | |
| 589 | 29735 | has_A = 1; | |
| 590 | } | ||
| 591 |
2/2✓ Branch 0 taken 24178 times.
✓ Branch 1 taken 23126 times.
|
47304 | if((r->avail_cache[6-4] & type) & mask){ |
| 592 | 24178 | B[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][0]; | |
| 593 | 24178 | B[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][1]; | |
| 594 | 24178 | has_B = 1; | |
| 595 | } | ||
| 596 |
4/4✓ Branch 0 taken 40744 times.
✓ Branch 1 taken 6560 times.
✓ Branch 2 taken 22080 times.
✓ Branch 3 taken 18664 times.
|
47304 | if(r->avail_cache[6-4] && (r->avail_cache[6-2] & type) & mask){ |
| 597 | 22080 | C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][0]; | |
| 598 | 22080 | C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][1]; | |
| 599 | 22080 | has_C = 1; | |
| 600 |
4/4✓ Branch 0 taken 918 times.
✓ Branch 1 taken 24306 times.
✓ Branch 2 taken 391 times.
✓ Branch 3 taken 527 times.
|
25224 | }else if((s->mb_x+1) == s->mb_width && (r->avail_cache[6-5] & type) & mask){ |
| 601 | 391 | C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][0]; | |
| 602 | 391 | C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][1]; | |
| 603 | 391 | has_C = 1; | |
| 604 | } | ||
| 605 | |||
| 606 | 47304 | rv34_pred_b_vector(A, B, C, has_A, has_B, has_C, &mx, &my); | |
| 607 | |||
| 608 | 47304 | mx += r->dmv[dir][0]; | |
| 609 | 47304 | my += r->dmv[dir][1]; | |
| 610 | |||
| 611 |
2/2✓ Branch 0 taken 94608 times.
✓ Branch 1 taken 47304 times.
|
141912 | for(j = 0; j < 2; j++){ |
| 612 |
2/2✓ Branch 0 taken 189216 times.
✓ Branch 1 taken 94608 times.
|
283824 | for(i = 0; i < 2; i++){ |
| 613 | 189216 | cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx; | |
| 614 | 189216 | cur_pic->motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my; | |
| 615 | } | ||
| 616 | } | ||
| 617 |
4/4✓ Branch 0 taken 32129 times.
✓ Branch 1 taken 15175 times.
✓ Branch 2 taken 13507 times.
✓ Branch 3 taken 18622 times.
|
47304 | if(block_type == RV34_MB_B_BACKWARD || block_type == RV34_MB_B_FORWARD){ |
| 618 | 28682 | ZERO8x2(cur_pic->motion_val[!dir][mv_pos], s->b8_stride); | |
| 619 | } | ||
| 620 | 47304 | } | |
| 621 | |||
| 622 | /** | ||
| 623 | * motion vector prediction - RV3 version | ||
| 624 | */ | ||
| 625 | 9134 | static void rv34_pred_mv_rv3(RV34DecContext *r, int block_type, int dir) | |
| 626 | { | ||
| 627 | 9134 | MpegEncContext *s = &r->s; | |
| 628 | 9134 | int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; | |
| 629 | 9134 | int A[2] = {0}, B[2], C[2]; | |
| 630 | int i, j, k; | ||
| 631 | int mx, my; | ||
| 632 | 9134 | int* avail = r->avail_cache + avail_indexes[0]; | |
| 633 | |||
| 634 |
2/2✓ Branch 0 taken 8666 times.
✓ Branch 1 taken 468 times.
|
9134 | if(avail[-1]){ |
| 635 | 8666 | A[0] = s->cur_pic.motion_val[0][mv_pos - 1][0]; | |
| 636 | 8666 | A[1] = s->cur_pic.motion_val[0][mv_pos - 1][1]; | |
| 637 | } | ||
| 638 |
2/2✓ Branch 0 taken 8618 times.
✓ Branch 1 taken 516 times.
|
9134 | if(avail[-4]){ |
| 639 | 8618 | B[0] = s->cur_pic.motion_val[0][mv_pos - s->b8_stride][0]; | |
| 640 | 8618 | B[1] = s->cur_pic.motion_val[0][mv_pos - s->b8_stride][1]; | |
| 641 | }else{ | ||
| 642 | 516 | B[0] = A[0]; | |
| 643 | 516 | B[1] = A[1]; | |
| 644 | } | ||
| 645 |
2/2✓ Branch 0 taken 950 times.
✓ Branch 1 taken 8184 times.
|
9134 | if(!avail[-4 + 2]){ |
| 646 |
3/4✓ Branch 0 taken 434 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
|
950 | if(avail[-4] && (avail[-1])){ |
| 647 | 434 | C[0] = s->cur_pic.motion_val[0][mv_pos - s->b8_stride - 1][0]; | |
| 648 | 434 | C[1] = s->cur_pic.motion_val[0][mv_pos - s->b8_stride - 1][1]; | |
| 649 | }else{ | ||
| 650 | 516 | C[0] = A[0]; | |
| 651 | 516 | C[1] = A[1]; | |
| 652 | } | ||
| 653 | }else{ | ||
| 654 | 8184 | C[0] = s->cur_pic.motion_val[0][mv_pos - s->b8_stride + 2][0]; | |
| 655 | 8184 | C[1] = s->cur_pic.motion_val[0][mv_pos - s->b8_stride + 2][1]; | |
| 656 | } | ||
| 657 | 9134 | mx = mid_pred(A[0], B[0], C[0]); | |
| 658 | 9134 | my = mid_pred(A[1], B[1], C[1]); | |
| 659 | 9134 | mx += r->dmv[0][0]; | |
| 660 | 9134 | my += r->dmv[0][1]; | |
| 661 |
2/2✓ Branch 0 taken 18268 times.
✓ Branch 1 taken 9134 times.
|
27402 | for(j = 0; j < 2; j++){ |
| 662 |
2/2✓ Branch 0 taken 36536 times.
✓ Branch 1 taken 18268 times.
|
54804 | for(i = 0; i < 2; i++){ |
| 663 |
2/2✓ Branch 0 taken 73072 times.
✓ Branch 1 taken 36536 times.
|
109608 | for(k = 0; k < 2; k++){ |
| 664 | 73072 | s->cur_pic.motion_val[k][mv_pos + i + j*s->b8_stride][0] = mx; | |
| 665 | 73072 | s->cur_pic.motion_val[k][mv_pos + i + j*s->b8_stride][1] = my; | |
| 666 | } | ||
| 667 | } | ||
| 668 | } | ||
| 669 | 9134 | } | |
| 670 | |||
| 671 | static const int chroma_coeffs[3] = { 0, 3, 5 }; | ||
| 672 | |||
| 673 | /** | ||
| 674 | * generic motion compensation function | ||
| 675 | * | ||
| 676 | * @param r decoder context | ||
| 677 | * @param block_type type of the current block | ||
| 678 | * @param xoff horizontal offset from the start of the current block | ||
| 679 | * @param yoff vertical offset from the start of the current block | ||
| 680 | * @param mv_off offset to the motion vector information | ||
| 681 | * @param width width of the current partition in 8x8 blocks | ||
| 682 | * @param height height of the current partition in 8x8 blocks | ||
| 683 | * @param dir motion compensation direction (i.e. from the last or the next reference frame) | ||
| 684 | * @param thirdpel motion vectors are specified in 1/3 of pixel | ||
| 685 | * @param qpel_mc a set of functions used to perform luma motion compensation | ||
| 686 | * @param chroma_mc a set of functions used to perform chroma motion compensation | ||
| 687 | */ | ||
| 688 | 516215 | static inline void rv34_mc(RV34DecContext *r, const int block_type, | |
| 689 | const int xoff, const int yoff, int mv_off, | ||
| 690 | const int width, const int height, int dir, | ||
| 691 | const int thirdpel, int weighted, | ||
| 692 | qpel_mc_func (*qpel_mc)[16], | ||
| 693 | h264_chroma_mc_func (*chroma_mc)) | ||
| 694 | { | ||
| 695 | 516215 | MpegEncContext *s = &r->s; | |
| 696 | uint8_t *Y, *U, *V; | ||
| 697 | const uint8_t *srcY, *srcU, *srcV; | ||
| 698 | int dxy, mx, my, umx, umy, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; | ||
| 699 | 516215 | int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride + mv_off; | |
| 700 | 516215 | int is16x16 = 1; | |
| 701 | 516215 | int emu = 0; | |
| 702 | 516215 | int16_t *motion_val = s->cur_pic.motion_val[dir][mv_pos]; | |
| 703 | |||
| 704 |
2/2✓ Branch 0 taken 127708 times.
✓ Branch 1 taken 388507 times.
|
516215 | if(thirdpel){ |
| 705 | int chroma_mx, chroma_my; | ||
| 706 | 127708 | mx = (motion_val[0] + (3 << 24)) / 3 - (1 << 24); | |
| 707 | 127708 | my = (motion_val[1] + (3 << 24)) / 3 - (1 << 24); | |
| 708 | 127708 | lx = (motion_val[0] + (3 << 24)) % 3; | |
| 709 | 127708 | ly = (motion_val[1] + (3 << 24)) % 3; | |
| 710 | 127708 | chroma_mx = motion_val[0] / 2; | |
| 711 | 127708 | chroma_my = motion_val[1] / 2; | |
| 712 | 127708 | umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24); | |
| 713 | 127708 | umy = (chroma_my + (3 << 24)) / 3 - (1 << 24); | |
| 714 | 127708 | uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3]; | |
| 715 | 127708 | uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3]; | |
| 716 | }else{ | ||
| 717 | int cx, cy; | ||
| 718 | 388507 | mx = motion_val[0] >> 2; | |
| 719 | 388507 | my = motion_val[1] >> 2; | |
| 720 | 388507 | lx = motion_val[0] & 3; | |
| 721 | 388507 | ly = motion_val[1] & 3; | |
| 722 | 388507 | cx = motion_val[0] / 2; | |
| 723 | 388507 | cy = motion_val[1] / 2; | |
| 724 | 388507 | umx = cx >> 2; | |
| 725 | 388507 | umy = cy >> 2; | |
| 726 | 388507 | uvmx = (cx & 3) << 1; | |
| 727 | 388507 | uvmy = (cy & 3) << 1; | |
| 728 | //due to some flaw RV40 uses the same MC compensation routine for H2V2 and H3V3 | ||
| 729 |
4/4✓ Branch 0 taken 34993 times.
✓ Branch 1 taken 353514 times.
✓ Branch 2 taken 7463 times.
✓ Branch 3 taken 27530 times.
|
388507 | if(uvmx == 6 && uvmy == 6) |
| 730 | 7463 | uvmx = uvmy = 4; | |
| 731 | } | ||
| 732 | |||
| 733 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 516215 times.
|
516215 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) { |
| 734 | /* wait for the referenced mb row to be finished */ | ||
| 735 | ✗ | int mb_row = s->mb_y + ((yoff + my + 5 + 8 * height) >> 4); | |
| 736 | ✗ | const ThreadProgress *p = dir ? &s->next_pic.ptr->progress : &s->last_pic.ptr->progress; | |
| 737 | ✗ | ff_thread_progress_await(p, mb_row); | |
| 738 | } | ||
| 739 | |||
| 740 | 516215 | dxy = ly*4 + lx; | |
| 741 |
2/2✓ Branch 0 taken 222466 times.
✓ Branch 1 taken 293749 times.
|
516215 | srcY = dir ? s->next_pic.data[0] : s->last_pic.data[0]; |
| 742 |
2/2✓ Branch 0 taken 222466 times.
✓ Branch 1 taken 293749 times.
|
516215 | srcU = dir ? s->next_pic.data[1] : s->last_pic.data[1]; |
| 743 |
2/2✓ Branch 0 taken 222466 times.
✓ Branch 1 taken 293749 times.
|
516215 | srcV = dir ? s->next_pic.data[2] : s->last_pic.data[2]; |
| 744 | 516215 | src_x = s->mb_x * 16 + xoff + mx; | |
| 745 | 516215 | src_y = s->mb_y * 16 + yoff + my; | |
| 746 | 516215 | uvsrc_x = s->mb_x * 8 + (xoff >> 1) + umx; | |
| 747 | 516215 | uvsrc_y = s->mb_y * 8 + (yoff >> 1) + umy; | |
| 748 | 516215 | srcY += src_y * s->linesize + src_x; | |
| 749 | 516215 | srcU += uvsrc_y * s->uvlinesize + uvsrc_x; | |
| 750 | 516215 | srcV += uvsrc_y * s->uvlinesize + uvsrc_x; | |
| 751 |
2/4✓ Branch 0 taken 516215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516215 times.
✗ Branch 3 not taken.
|
516215 | if(s->h_edge_pos - (width << 3) < 6 || s->v_edge_pos - (height << 3) < 6 || |
| 752 |
6/6✓ Branch 0 taken 167109 times.
✓ Branch 1 taken 349106 times.
✓ Branch 2 taken 167109 times.
✓ Branch 3 taken 349106 times.
✓ Branch 4 taken 500060 times.
✓ Branch 5 taken 16155 times.
|
516215 | (unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 4 || |
| 753 |
6/6✓ Branch 0 taken 144092 times.
✓ Branch 1 taken 355968 times.
✓ Branch 2 taken 144092 times.
✓ Branch 3 taken 355968 times.
✓ Branch 4 taken 27762 times.
✓ Branch 5 taken 472298 times.
|
500060 | (unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 4) { |
| 754 | 43917 | srcY -= 2 + 2*s->linesize; | |
| 755 | 43917 | s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, srcY, | |
| 756 | s->linesize, s->linesize, | ||
| 757 | 43917 | (width << 3) + 6, (height << 3) + 6, | |
| 758 | src_x - 2, src_y - 2, | ||
| 759 | s->h_edge_pos, s->v_edge_pos); | ||
| 760 | 43917 | srcY = s->sc.edge_emu_buffer + 2 + 2*s->linesize; | |
| 761 | 43917 | emu = 1; | |
| 762 | } | ||
| 763 |
2/2✓ Branch 0 taken 231631 times.
✓ Branch 1 taken 284584 times.
|
516215 | if(!weighted){ |
| 764 | 231631 | Y = s->dest[0] + xoff + yoff *s->linesize; | |
| 765 | 231631 | U = s->dest[1] + (xoff>>1) + (yoff>>1)*s->uvlinesize; | |
| 766 | 231631 | V = s->dest[2] + (xoff>>1) + (yoff>>1)*s->uvlinesize; | |
| 767 | }else{ | ||
| 768 | 284584 | Y = r->tmp_b_block_y [dir] + xoff + yoff *s->linesize; | |
| 769 | 284584 | U = r->tmp_b_block_uv[dir*2] + (xoff>>1) + (yoff>>1)*s->uvlinesize; | |
| 770 | 284584 | V = r->tmp_b_block_uv[dir*2+1] + (xoff>>1) + (yoff>>1)*s->uvlinesize; | |
| 771 | } | ||
| 772 | |||
| 773 |
2/2✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 513495 times.
|
516215 | if(block_type == RV34_MB_P_16x8){ |
| 774 | 2720 | qpel_mc[1][dxy](Y, srcY, s->linesize); | |
| 775 | 2720 | Y += 8; | |
| 776 | 2720 | srcY += 8; | |
| 777 |
2/2✓ Branch 0 taken 4968 times.
✓ Branch 1 taken 508527 times.
|
513495 | }else if(block_type == RV34_MB_P_8x16){ |
| 778 | 4968 | qpel_mc[1][dxy](Y, srcY, s->linesize); | |
| 779 | 4968 | Y += 8 * s->linesize; | |
| 780 | 4968 | srcY += 8 * s->linesize; | |
| 781 | } | ||
| 782 |
6/6✓ Branch 0 taken 406191 times.
✓ Branch 1 taken 110024 times.
✓ Branch 2 taken 403471 times.
✓ Branch 3 taken 2720 times.
✓ Branch 4 taken 398503 times.
✓ Branch 5 taken 4968 times.
|
516215 | is16x16 = (block_type != RV34_MB_P_8x8) && (block_type != RV34_MB_P_16x8) && (block_type != RV34_MB_P_8x16); |
| 783 |
2/2✓ Branch 0 taken 117712 times.
✓ Branch 1 taken 398503 times.
|
516215 | qpel_mc[!is16x16][dxy](Y, srcY, s->linesize); |
| 784 |
2/2✓ Branch 0 taken 43917 times.
✓ Branch 1 taken 472298 times.
|
516215 | if (emu) { |
| 785 | 43917 | uint8_t *uvbuf = s->sc.edge_emu_buffer; | |
| 786 | |||
| 787 | 43917 | s->vdsp.emulated_edge_mc(uvbuf, srcU, | |
| 788 | s->uvlinesize, s->uvlinesize, | ||
| 789 | 43917 | (width << 2) + 1, (height << 2) + 1, | |
| 790 | uvsrc_x, uvsrc_y, | ||
| 791 | 43917 | s->h_edge_pos >> 1, s->v_edge_pos >> 1); | |
| 792 | 43917 | srcU = uvbuf; | |
| 793 | 43917 | uvbuf += 9*s->uvlinesize; | |
| 794 | |||
| 795 | 43917 | s->vdsp.emulated_edge_mc(uvbuf, srcV, | |
| 796 | s->uvlinesize, s->uvlinesize, | ||
| 797 | 43917 | (width << 2) + 1, (height << 2) + 1, | |
| 798 | uvsrc_x, uvsrc_y, | ||
| 799 | 43917 | s->h_edge_pos >> 1, s->v_edge_pos >> 1); | |
| 800 | 43917 | srcV = uvbuf; | |
| 801 | } | ||
| 802 | 516215 | chroma_mc[2-width] (U, srcU, s->uvlinesize, height*4, uvmx, uvmy); | |
| 803 | 516215 | chroma_mc[2-width] (V, srcV, s->uvlinesize, height*4, uvmx, uvmy); | |
| 804 | 516215 | } | |
| 805 | |||
| 806 | 112473 | static void rv34_mc_1mv(RV34DecContext *r, const int block_type, | |
| 807 | const int xoff, const int yoff, int mv_off, | ||
| 808 | const int width, const int height, int dir) | ||
| 809 | { | ||
| 810 | 112473 | rv34_mc(r, block_type, xoff, yoff, mv_off, width, height, dir, r->rv30, 0, | |
| 811 | 112473 | r->rdsp.put_pixels_tab, | |
| 812 | 112473 | r->rdsp.put_chroma_pixels_tab); | |
| 813 | 112473 | } | |
| 814 | |||
| 815 | 117119 | static void rv4_weight(RV34DecContext *r) | |
| 816 | { | ||
| 817 | 117119 | r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][0](r->s.dest[0], | |
| 818 | r->tmp_b_block_y[0], | ||
| 819 | r->tmp_b_block_y[1], | ||
| 820 | r->weight1, | ||
| 821 | r->weight2, | ||
| 822 | r->s.linesize); | ||
| 823 | 117119 | r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][1](r->s.dest[1], | |
| 824 | r->tmp_b_block_uv[0], | ||
| 825 | r->tmp_b_block_uv[2], | ||
| 826 | r->weight1, | ||
| 827 | r->weight2, | ||
| 828 | r->s.uvlinesize); | ||
| 829 | 117119 | r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][1](r->s.dest[2], | |
| 830 | r->tmp_b_block_uv[1], | ||
| 831 | r->tmp_b_block_uv[3], | ||
| 832 | r->weight1, | ||
| 833 | r->weight2, | ||
| 834 | r->s.uvlinesize); | ||
| 835 | 117119 | } | |
| 836 | |||
| 837 | 155947 | static void rv34_mc_2mv(RV34DecContext *r, const int block_type) | |
| 838 | { | ||
| 839 |
5/6✓ Branch 0 taken 118039 times.
✓ Branch 1 taken 37908 times.
✓ Branch 2 taken 108728 times.
✓ Branch 3 taken 9311 times.
✓ Branch 4 taken 108728 times.
✗ Branch 5 not taken.
|
155947 | int weighted = !r->rv30 && block_type != RV34_MB_B_BIDIR && r->weight1 != 8192; |
| 840 | |||
| 841 | 155947 | rv34_mc(r, block_type, 0, 0, 0, 2, 2, 0, r->rv30, weighted, | |
| 842 | 155947 | r->rdsp.put_pixels_tab, | |
| 843 | 155947 | r->rdsp.put_chroma_pixels_tab); | |
| 844 |
2/2✓ Branch 0 taken 47219 times.
✓ Branch 1 taken 108728 times.
|
155947 | if(!weighted){ |
| 845 | 47219 | rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->rv30, 0, | |
| 846 | 47219 | r->rdsp.avg_pixels_tab, | |
| 847 | 47219 | r->rdsp.avg_chroma_pixels_tab); | |
| 848 | }else{ | ||
| 849 | 108728 | rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->rv30, 1, | |
| 850 | 108728 | r->rdsp.put_pixels_tab, | |
| 851 | 108728 | r->rdsp.put_chroma_pixels_tab); | |
| 852 | 108728 | rv4_weight(r); | |
| 853 | } | ||
| 854 | 155947 | } | |
| 855 | |||
| 856 | 11481 | static void rv34_mc_2mv_skip(RV34DecContext *r) | |
| 857 | { | ||
| 858 | int i, j; | ||
| 859 |
3/4✓ Branch 0 taken 8391 times.
✓ Branch 1 taken 3090 times.
✓ Branch 2 taken 8391 times.
✗ Branch 3 not taken.
|
11481 | int weighted = !r->rv30 && r->weight1 != 8192; |
| 860 | |||
| 861 |
2/2✓ Branch 0 taken 22962 times.
✓ Branch 1 taken 11481 times.
|
34443 | for(j = 0; j < 2; j++) |
| 862 |
2/2✓ Branch 0 taken 45924 times.
✓ Branch 1 taken 22962 times.
|
68886 | for(i = 0; i < 2; i++){ |
| 863 | 45924 | rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 0, r->rv30, | |
| 864 | weighted, | ||
| 865 | 45924 | r->rdsp.put_pixels_tab, | |
| 866 | 45924 | r->rdsp.put_chroma_pixels_tab); | |
| 867 |
4/4✓ Branch 0 taken 33564 times.
✓ Branch 1 taken 12360 times.
✓ Branch 2 taken 33564 times.
✓ Branch 3 taken 12360 times.
|
45924 | rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 1, r->rv30, |
| 868 | weighted, | ||
| 869 | weighted ? r->rdsp.put_pixels_tab : r->rdsp.avg_pixels_tab, | ||
| 870 | weighted ? r->rdsp.put_chroma_pixels_tab : r->rdsp.avg_chroma_pixels_tab); | ||
| 871 | } | ||
| 872 |
2/2✓ Branch 0 taken 8391 times.
✓ Branch 1 taken 3090 times.
|
11481 | if(weighted) |
| 873 | 8391 | rv4_weight(r); | |
| 874 | 11481 | } | |
| 875 | |||
| 876 | /** number of motion vectors in each macroblock type */ | ||
| 877 | static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 }; | ||
| 878 | |||
| 879 | /** | ||
| 880 | * Decode motion vector differences | ||
| 881 | * and perform motion vector reconstruction and motion compensation. | ||
| 882 | */ | ||
| 883 | 286800 | static int rv34_decode_mv(RV34DecContext *r, int block_type) | |
| 884 | { | ||
| 885 | 286800 | MpegEncContext *s = &r->s; | |
| 886 | 286800 | GetBitContext *const gb = &r->gb; | |
| 887 | int i, j, k, l; | ||
| 888 | 286800 | int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; | |
| 889 | int next_bt; | ||
| 890 | |||
| 891 | 286800 | memset(r->dmv, 0, sizeof(r->dmv)); | |
| 892 |
2/2✓ Branch 0 taken 99380 times.
✓ Branch 1 taken 286800 times.
|
386180 | for(i = 0; i < num_mvs[block_type]; i++){ |
| 893 | 99380 | r->dmv[i][0] = get_interleaved_se_golomb(gb); | |
| 894 | 99380 | r->dmv[i][1] = get_interleaved_se_golomb(gb); | |
| 895 |
1/2✓ Branch 0 taken 99380 times.
✗ Branch 1 not taken.
|
99380 | if (r->dmv[i][0] == INVALID_VLC || |
| 896 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 99380 times.
|
99380 | r->dmv[i][1] == INVALID_VLC) { |
| 897 | ✗ | r->dmv[i][0] = r->dmv[i][1] = 0; | |
| 898 | ✗ | return AVERROR_INVALIDDATA; | |
| 899 | } | ||
| 900 | } | ||
| 901 |
8/9✓ Branch 0 taken 24375 times.
✓ Branch 1 taken 164574 times.
✓ Branch 2 taken 25258 times.
✓ Branch 3 taken 17078 times.
✓ Branch 4 taken 37816 times.
✓ Branch 5 taken 3844 times.
✓ Branch 6 taken 9311 times.
✓ Branch 7 taken 4544 times.
✗ Branch 8 not taken.
|
286800 | switch(block_type){ |
| 902 | 24375 | case RV34_MB_TYPE_INTRA: | |
| 903 | case RV34_MB_TYPE_INTRA16x16: | ||
| 904 | 24375 | ZERO8x2(s->cur_pic.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); | |
| 905 | 24375 | return 0; | |
| 906 | 164574 | case RV34_MB_SKIP: | |
| 907 |
2/2✓ Branch 0 taken 31715 times.
✓ Branch 1 taken 132859 times.
|
164574 | if(s->pict_type == AV_PICTURE_TYPE_P){ |
| 908 | 31715 | ZERO8x2(s->cur_pic.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); | |
| 909 | 31715 | rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); | |
| 910 | 31715 | break; | |
| 911 | } | ||
| 912 | case RV34_MB_B_DIRECT: | ||
| 913 | //surprisingly, it uses motion scheme from next reference frame | ||
| 914 | /* wait for the current mb row to be finished */ | ||
| 915 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 158117 times.
|
158117 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) |
| 916 | ✗ | ff_thread_progress_await(&s->next_pic.ptr->progress, FFMAX(0, s->mb_y-1)); | |
| 917 | |||
| 918 | 158117 | next_bt = s->next_pic.mb_type[s->mb_x + s->mb_y * s->mb_stride]; | |
| 919 |
4/4✓ Branch 0 taken 144391 times.
✓ Branch 1 taken 13726 times.
✓ Branch 2 taken 93730 times.
✓ Branch 3 taken 50661 times.
|
158117 | if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){ |
| 920 | 107456 | ZERO8x2(s->cur_pic.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); | |
| 921 | 107456 | ZERO8x2(s->cur_pic.motion_val[1][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); | |
| 922 | }else | ||
| 923 |
2/2✓ Branch 0 taken 101322 times.
✓ Branch 1 taken 50661 times.
|
151983 | for(j = 0; j < 2; j++) |
| 924 |
2/2✓ Branch 0 taken 202644 times.
✓ Branch 1 taken 101322 times.
|
303966 | for(i = 0; i < 2; i++) |
| 925 |
2/2✓ Branch 0 taken 405288 times.
✓ Branch 1 taken 202644 times.
|
607932 | for(k = 0; k < 2; k++) |
| 926 |
2/2✓ Branch 0 taken 810576 times.
✓ Branch 1 taken 405288 times.
|
1215864 | for(l = 0; l < 2; l++) |
| 927 | 810576 | s->cur_pic.motion_val[l][mv_pos + i + j*s->b8_stride][k] = calc_add_mv(r, l, s->next_pic.motion_val[0][mv_pos + i + j*s->b8_stride][k]); | |
| 928 |
6/6✓ Branch 0 taken 155964 times.
✓ Branch 1 taken 2153 times.
✓ Branch 2 taken 152793 times.
✓ Branch 3 taken 3171 times.
✓ Branch 4 taken 146636 times.
✓ Branch 5 taken 6157 times.
|
158117 | if(!(IS_16X8(next_bt) || IS_8X16(next_bt) || IS_8X8(next_bt))) //we can use whole macroblock MC |
| 929 | 146636 | rv34_mc_2mv(r, block_type); | |
| 930 | else | ||
| 931 | 11481 | rv34_mc_2mv_skip(r); | |
| 932 | 158117 | ZERO8x2(s->cur_pic.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride); | |
| 933 | 158117 | break; | |
| 934 | 17078 | case RV34_MB_P_16x16: | |
| 935 | case RV34_MB_P_MIX16x16: | ||
| 936 | 17078 | rv34_pred_mv(r, block_type, 0, 0); | |
| 937 | 17078 | rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0); | |
| 938 | 17078 | break; | |
| 939 | 37816 | case RV34_MB_B_FORWARD: | |
| 940 | case RV34_MB_B_BACKWARD: | ||
| 941 | 37816 | r->dmv[1][0] = r->dmv[0][0]; | |
| 942 | 37816 | r->dmv[1][1] = r->dmv[0][1]; | |
| 943 |
2/2✓ Branch 0 taken 9134 times.
✓ Branch 1 taken 28682 times.
|
37816 | if(r->rv30) |
| 944 | 9134 | rv34_pred_mv_rv3(r, block_type, block_type == RV34_MB_B_BACKWARD); | |
| 945 | else | ||
| 946 | 28682 | rv34_pred_mv_b (r, block_type, block_type == RV34_MB_B_BACKWARD); | |
| 947 | 37816 | rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, block_type == RV34_MB_B_BACKWARD); | |
| 948 | 37816 | break; | |
| 949 | 3844 | case RV34_MB_P_16x8: | |
| 950 | case RV34_MB_P_8x16: | ||
| 951 | 3844 | rv34_pred_mv(r, block_type, 0, 0); | |
| 952 |
2/2✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 2484 times.
|
3844 | rv34_pred_mv(r, block_type, 1 + (block_type == RV34_MB_P_16x8), 1); |
| 953 |
2/2✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 2484 times.
|
3844 | if(block_type == RV34_MB_P_16x8){ |
| 954 | 1360 | rv34_mc_1mv(r, block_type, 0, 0, 0, 2, 1, 0); | |
| 955 | 1360 | rv34_mc_1mv(r, block_type, 0, 8, s->b8_stride, 2, 1, 0); | |
| 956 | } | ||
| 957 |
2/2✓ Branch 0 taken 2484 times.
✓ Branch 1 taken 1360 times.
|
3844 | if(block_type == RV34_MB_P_8x16){ |
| 958 | 2484 | rv34_mc_1mv(r, block_type, 0, 0, 0, 1, 2, 0); | |
| 959 | 2484 | rv34_mc_1mv(r, block_type, 8, 0, 1, 1, 2, 0); | |
| 960 | } | ||
| 961 | 3844 | break; | |
| 962 | 9311 | case RV34_MB_B_BIDIR: | |
| 963 | 9311 | rv34_pred_mv_b (r, block_type, 0); | |
| 964 | 9311 | rv34_pred_mv_b (r, block_type, 1); | |
| 965 | 9311 | rv34_mc_2mv (r, block_type); | |
| 966 | 9311 | break; | |
| 967 | 4544 | case RV34_MB_P_8x8: | |
| 968 |
2/2✓ Branch 0 taken 18176 times.
✓ Branch 1 taken 4544 times.
|
22720 | for(i=0;i< 4;i++){ |
| 969 | 18176 | rv34_pred_mv(r, block_type, i, i); | |
| 970 | 18176 | rv34_mc_1mv (r, block_type, (i&1)<<3, (i&2)<<2, (i&1)+(i>>1)*s->b8_stride, 1, 1, 0); | |
| 971 | } | ||
| 972 | 4544 | break; | |
| 973 | } | ||
| 974 | |||
| 975 | 262425 | return 0; | |
| 976 | } | ||
| 977 | /** @} */ // mv group | ||
| 978 | |||
| 979 | /** | ||
| 980 | * @name Macroblock reconstruction functions | ||
| 981 | * @{ | ||
| 982 | */ | ||
| 983 | /** mapping of RV30/40 intra prediction types to standard H.264 types */ | ||
| 984 | static const int ittrans[9] = { | ||
| 985 | DC_PRED, VERT_PRED, HOR_PRED, DIAG_DOWN_RIGHT_PRED, DIAG_DOWN_LEFT_PRED, | ||
| 986 | VERT_RIGHT_PRED, VERT_LEFT_PRED, HOR_UP_PRED, HOR_DOWN_PRED, | ||
| 987 | }; | ||
| 988 | |||
| 989 | /** mapping of RV30/40 intra 16x16 prediction types to standard H.264 types */ | ||
| 990 | static const int ittrans16[4] = { | ||
| 991 | DC_PRED8x8, VERT_PRED8x8, HOR_PRED8x8, PLANE_PRED8x8, | ||
| 992 | }; | ||
| 993 | |||
| 994 | /** | ||
| 995 | * Perform 4x4 intra prediction. | ||
| 996 | */ | ||
| 997 | 363096 | static void rv34_pred_4x4_block(RV34DecContext *r, uint8_t *dst, int stride, int itype, int up, int left, int down, int right) | |
| 998 | { | ||
| 999 | 363096 | uint8_t *prev = dst - stride + 4; | |
| 1000 | uint32_t topleft; | ||
| 1001 | |||
| 1002 |
4/4✓ Branch 0 taken 44632 times.
✓ Branch 1 taken 318464 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 43726 times.
|
363096 | if(!up && !left) |
| 1003 | 906 | itype = DC_128_PRED; | |
| 1004 |
2/2✓ Branch 0 taken 43726 times.
✓ Branch 1 taken 318464 times.
|
362190 | else if(!up){ |
| 1005 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43726 times.
|
43726 | if(itype == VERT_PRED) itype = HOR_PRED; |
| 1006 |
2/2✓ Branch 0 taken 25536 times.
✓ Branch 1 taken 18190 times.
|
43726 | if(itype == DC_PRED) itype = LEFT_DC_PRED; |
| 1007 |
2/2✓ Branch 0 taken 5318 times.
✓ Branch 1 taken 313146 times.
|
318464 | }else if(!left){ |
| 1008 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5318 times.
|
5318 | if(itype == HOR_PRED) itype = VERT_PRED; |
| 1009 |
2/2✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1618 times.
|
5318 | if(itype == DC_PRED) itype = TOP_DC_PRED; |
| 1010 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5318 times.
|
5318 | if(itype == DIAG_DOWN_LEFT_PRED) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN; |
| 1011 | } | ||
| 1012 |
2/2✓ Branch 0 taken 289785 times.
✓ Branch 1 taken 73311 times.
|
363096 | if(!down){ |
| 1013 |
2/2✓ Branch 0 taken 16270 times.
✓ Branch 1 taken 273515 times.
|
289785 | if(itype == DIAG_DOWN_LEFT_PRED) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN; |
| 1014 |
2/2✓ Branch 0 taken 9069 times.
✓ Branch 1 taken 280716 times.
|
289785 | if(itype == HOR_UP_PRED) itype = HOR_UP_PRED_RV40_NODOWN; |
| 1015 |
2/2✓ Branch 0 taken 23196 times.
✓ Branch 1 taken 266589 times.
|
289785 | if(itype == VERT_LEFT_PRED) itype = VERT_LEFT_PRED_RV40_NODOWN; |
| 1016 | } | ||
| 1017 |
4/4✓ Branch 0 taken 120385 times.
✓ Branch 1 taken 242711 times.
✓ Branch 2 taken 76137 times.
✓ Branch 3 taken 44248 times.
|
363096 | if(!right && up){ |
| 1018 | 76137 | topleft = dst[-stride + 3] * 0x01010101u; | |
| 1019 | 76137 | prev = (uint8_t*)&topleft; | |
| 1020 | } | ||
| 1021 | 363096 | r->h.pred4x4[itype](dst, prev, stride); | |
| 1022 | 363096 | } | |
| 1023 | |||
| 1024 | 33772 | static inline int adjust_pred16(int itype, int up, int left) | |
| 1025 | { | ||
| 1026 |
4/4✓ Branch 0 taken 5834 times.
✓ Branch 1 taken 27938 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 5780 times.
|
33772 | if(!up && !left) |
| 1027 | 54 | itype = DC_128_PRED8x8; | |
| 1028 |
2/2✓ Branch 0 taken 5780 times.
✓ Branch 1 taken 27938 times.
|
33718 | else if(!up){ |
| 1029 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5780 times.
|
5780 | if(itype == PLANE_PRED8x8)itype = HOR_PRED8x8; |
| 1030 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5780 times.
|
5780 | if(itype == VERT_PRED8x8) itype = HOR_PRED8x8; |
| 1031 |
2/2✓ Branch 0 taken 3780 times.
✓ Branch 1 taken 2000 times.
|
5780 | if(itype == DC_PRED8x8) itype = LEFT_DC_PRED8x8; |
| 1032 |
2/2✓ Branch 0 taken 840 times.
✓ Branch 1 taken 27098 times.
|
27938 | }else if(!left){ |
| 1033 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
|
840 | if(itype == PLANE_PRED8x8)itype = VERT_PRED8x8; |
| 1034 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
|
840 | if(itype == HOR_PRED8x8) itype = VERT_PRED8x8; |
| 1035 |
2/2✓ Branch 0 taken 684 times.
✓ Branch 1 taken 156 times.
|
840 | if(itype == DC_PRED8x8) itype = TOP_DC_PRED8x8; |
| 1036 | } | ||
| 1037 | 33772 | return itype; | |
| 1038 | } | ||
| 1039 | |||
| 1040 | 708799 | static inline void rv34_process_block(RV34DecContext *r, | |
| 1041 | uint8_t *pdst, int stride, | ||
| 1042 | int fc, int sc, int q_dc, int q_ac) | ||
| 1043 | { | ||
| 1044 | 708799 | int16_t *const ptr = r->block; | |
| 1045 | 708799 | int has_ac = rv34_decode_block(ptr, &r->gb, r->cur_vlcs, | |
| 1046 | fc, sc, q_dc, q_ac, q_ac); | ||
| 1047 |
2/2✓ Branch 0 taken 352408 times.
✓ Branch 1 taken 356391 times.
|
708799 | if(has_ac){ |
| 1048 | 352408 | r->rdsp.rv34_idct_add(pdst, stride, ptr); | |
| 1049 | }else{ | ||
| 1050 | 356391 | r->rdsp.rv34_idct_dc_add(pdst, stride, ptr[0]); | |
| 1051 | 356391 | ptr[0] = 0; | |
| 1052 | } | ||
| 1053 | 708799 | } | |
| 1054 | |||
| 1055 | 16886 | static void rv34_output_i16x16(RV34DecContext *r, int8_t *intra_types, int cbp) | |
| 1056 | { | ||
| 1057 | 16886 | LOCAL_ALIGNED_16(int16_t, block16, [16]); | |
| 1058 | 16886 | MpegEncContext *s = &r->s; | |
| 1059 | 16886 | GetBitContext *const gb = &r->gb; | |
| 1060 | 16886 | int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ], | |
| 1061 | 16886 | q_ac = rv34_qscale_tab[s->qscale]; | |
| 1062 | 16886 | uint8_t *dst = s->dest[0]; | |
| 1063 | 16886 | int16_t *const ptr = r->block; | |
| 1064 | int i, j, itype, has_ac; | ||
| 1065 | |||
| 1066 | 16886 | memset(block16, 0, 16 * sizeof(*block16)); | |
| 1067 | |||
| 1068 | 16886 | has_ac = rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac); | |
| 1069 |
2/2✓ Branch 0 taken 7959 times.
✓ Branch 1 taken 8927 times.
|
16886 | if(has_ac) |
| 1070 | 7959 | r->rdsp.rv34_inv_transform(block16); | |
| 1071 | else | ||
| 1072 | 8927 | r->rdsp.rv34_inv_transform_dc(block16); | |
| 1073 | |||
| 1074 | 16886 | itype = ittrans16[intra_types[0]]; | |
| 1075 | 16886 | itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]); | |
| 1076 | 16886 | r->h.pred16x16[itype](dst, s->linesize); | |
| 1077 | |||
| 1078 |
2/2✓ Branch 0 taken 67544 times.
✓ Branch 1 taken 16886 times.
|
84430 | for(j = 0; j < 4; j++){ |
| 1079 |
2/2✓ Branch 0 taken 270176 times.
✓ Branch 1 taken 67544 times.
|
337720 | for(i = 0; i < 4; i++, cbp >>= 1){ |
| 1080 | 270176 | int dc = block16[i + j*4]; | |
| 1081 | |||
| 1082 |
2/2✓ Branch 0 taken 14318 times.
✓ Branch 1 taken 255858 times.
|
270176 | if(cbp & 1){ |
| 1083 | 14318 | has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac); | |
| 1084 | }else | ||
| 1085 | 255858 | has_ac = 0; | |
| 1086 | |||
| 1087 |
2/2✓ Branch 0 taken 14318 times.
✓ Branch 1 taken 255858 times.
|
270176 | if(has_ac){ |
| 1088 | 14318 | ptr[0] = dc; | |
| 1089 | 14318 | r->rdsp.rv34_idct_add(dst+4*i, s->linesize, ptr); | |
| 1090 | }else | ||
| 1091 | 255858 | r->rdsp.rv34_idct_dc_add(dst+4*i, s->linesize, dc); | |
| 1092 | } | ||
| 1093 | |||
| 1094 | 67544 | dst += 4*s->linesize; | |
| 1095 | } | ||
| 1096 | |||
| 1097 | 16886 | itype = ittrans16[intra_types[0]]; | |
| 1098 |
2/2✓ Branch 0 taken 1214 times.
✓ Branch 1 taken 15672 times.
|
16886 | if(itype == PLANE_PRED8x8) itype = DC_PRED8x8; |
| 1099 | 16886 | itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]); | |
| 1100 | |||
| 1101 | 16886 | q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]]; | |
| 1102 | 16886 | q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]; | |
| 1103 | |||
| 1104 |
2/2✓ Branch 0 taken 33772 times.
✓ Branch 1 taken 16886 times.
|
50658 | for(j = 1; j < 3; j++){ |
| 1105 | 33772 | dst = s->dest[j]; | |
| 1106 | 33772 | r->h.pred8x8[itype](dst, s->uvlinesize); | |
| 1107 |
2/2✓ Branch 0 taken 135088 times.
✓ Branch 1 taken 33772 times.
|
168860 | for(i = 0; i < 4; i++, cbp >>= 1){ |
| 1108 | uint8_t *pdst; | ||
| 1109 |
2/2✓ Branch 0 taken 110307 times.
✓ Branch 1 taken 24781 times.
|
135088 | if(!(cbp & 1)) continue; |
| 1110 | 24781 | pdst = dst + (i&1)*4 + (i&2)*2*s->uvlinesize; | |
| 1111 | |||
| 1112 | 24781 | rv34_process_block(r, pdst, s->uvlinesize, | |
| 1113 | r->chroma_vlc, 1, q_dc, q_ac); | ||
| 1114 | } | ||
| 1115 | } | ||
| 1116 | 16886 | } | |
| 1117 | |||
| 1118 | 15129 | static void rv34_output_intra(RV34DecContext *r, int8_t *intra_types, int cbp) | |
| 1119 | { | ||
| 1120 | 15129 | MpegEncContext *s = &r->s; | |
| 1121 | 15129 | uint8_t *dst = s->dest[0]; | |
| 1122 | 15129 | int avail[6*8] = {0}; | |
| 1123 | int i, j, k; | ||
| 1124 | int idx, q_ac, q_dc; | ||
| 1125 | |||
| 1126 | // Set neighbour information. | ||
| 1127 |
2/2✓ Branch 0 taken 8929 times.
✓ Branch 1 taken 6200 times.
|
15129 | if(r->avail_cache[1]) |
| 1128 | 8929 | avail[0] = 1; | |
| 1129 |
2/2✓ Branch 0 taken 9550 times.
✓ Branch 1 taken 5579 times.
|
15129 | if(r->avail_cache[2]) |
| 1130 | 9550 | avail[1] = avail[2] = 1; | |
| 1131 |
2/2✓ Branch 0 taken 9550 times.
✓ Branch 1 taken 5579 times.
|
15129 | if(r->avail_cache[3]) |
| 1132 | 9550 | avail[3] = avail[4] = 1; | |
| 1133 |
2/2✓ Branch 0 taken 9514 times.
✓ Branch 1 taken 5615 times.
|
15129 | if(r->avail_cache[4]) |
| 1134 | 9514 | avail[5] = 1; | |
| 1135 |
2/2✓ Branch 0 taken 14351 times.
✓ Branch 1 taken 778 times.
|
15129 | if(r->avail_cache[5]) |
| 1136 | 14351 | avail[8] = avail[16] = 1; | |
| 1137 |
2/2✓ Branch 0 taken 14351 times.
✓ Branch 1 taken 778 times.
|
15129 | if(r->avail_cache[9]) |
| 1138 | 14351 | avail[24] = avail[32] = 1; | |
| 1139 | |||
| 1140 | 15129 | q_ac = rv34_qscale_tab[s->qscale]; | |
| 1141 |
2/2✓ Branch 0 taken 60516 times.
✓ Branch 1 taken 15129 times.
|
75645 | for(j = 0; j < 4; j++){ |
| 1142 | 60516 | idx = 9 + j*8; | |
| 1143 |
2/2✓ Branch 0 taken 242064 times.
✓ Branch 1 taken 60516 times.
|
302580 | for(i = 0; i < 4; i++, cbp >>= 1, dst += 4, idx++){ |
| 1144 | 242064 | rv34_pred_4x4_block(r, dst, s->linesize, ittrans[intra_types[i]], avail[idx-8], avail[idx-1], avail[idx+7], avail[idx-7]); | |
| 1145 | 242064 | avail[idx] = 1; | |
| 1146 |
2/2✓ Branch 0 taken 93479 times.
✓ Branch 1 taken 148585 times.
|
242064 | if(!(cbp & 1)) continue; |
| 1147 | |||
| 1148 | 148585 | rv34_process_block(r, dst, s->linesize, | |
| 1149 | r->luma_vlc, 0, q_ac, q_ac); | ||
| 1150 | } | ||
| 1151 | 60516 | dst += s->linesize * 4 - 4*4; | |
| 1152 | 60516 | intra_types += r->intra_types_stride; | |
| 1153 | } | ||
| 1154 | |||
| 1155 | 15129 | intra_types -= r->intra_types_stride * 4; | |
| 1156 | |||
| 1157 | 15129 | q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]]; | |
| 1158 | 15129 | q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]; | |
| 1159 | |||
| 1160 |
2/2✓ Branch 0 taken 30258 times.
✓ Branch 1 taken 15129 times.
|
45387 | for(k = 0; k < 2; k++){ |
| 1161 | 30258 | dst = s->dest[1+k]; | |
| 1162 | 30258 | fill_rectangle(r->avail_cache + 6, 2, 2, 4, 0, 4); | |
| 1163 | |||
| 1164 |
2/2✓ Branch 0 taken 60516 times.
✓ Branch 1 taken 30258 times.
|
90774 | for(j = 0; j < 2; j++){ |
| 1165 | 60516 | int* acache = r->avail_cache + 6 + j*4; | |
| 1166 |
2/2✓ Branch 0 taken 121032 times.
✓ Branch 1 taken 60516 times.
|
181548 | for(i = 0; i < 2; i++, cbp >>= 1, acache++){ |
| 1167 | 121032 | int itype = ittrans[intra_types[i*2+j*2*r->intra_types_stride]]; | |
| 1168 |
4/4✓ Branch 0 taken 60516 times.
✓ Branch 1 taken 60516 times.
✓ Branch 2 taken 30258 times.
✓ Branch 3 taken 30258 times.
|
121032 | rv34_pred_4x4_block(r, dst+4*i, s->uvlinesize, itype, acache[-4], acache[-1], !i && !j, acache[-3]); |
| 1169 | 121032 | acache[0] = 1; | |
| 1170 | |||
| 1171 |
2/2✓ Branch 0 taken 49869 times.
✓ Branch 1 taken 71163 times.
|
121032 | if(!(cbp&1)) continue; |
| 1172 | |||
| 1173 | 71163 | rv34_process_block(r, dst + 4*i, s->uvlinesize, | |
| 1174 | r->chroma_vlc, 1, q_dc, q_ac); | ||
| 1175 | } | ||
| 1176 | |||
| 1177 | 60516 | dst += 4*s->uvlinesize; | |
| 1178 | } | ||
| 1179 | } | ||
| 1180 | 15129 | } | |
| 1181 | |||
| 1182 | 2263432 | static int is_mv_diff_gt_3(int16_t (*motion_val)[2], int step) | |
| 1183 | { | ||
| 1184 | int d; | ||
| 1185 | 2263432 | d = motion_val[0][0] - motion_val[-step][0]; | |
| 1186 |
4/4✓ Branch 0 taken 2170456 times.
✓ Branch 1 taken 92976 times.
✓ Branch 2 taken 96418 times.
✓ Branch 3 taken 2074038 times.
|
2263432 | if(d < -3 || d > 3) |
| 1187 | 189394 | return 1; | |
| 1188 | 2074038 | d = motion_val[0][1] - motion_val[-step][1]; | |
| 1189 |
4/4✓ Branch 0 taken 2059609 times.
✓ Branch 1 taken 14429 times.
✓ Branch 2 taken 17585 times.
✓ Branch 3 taken 2042024 times.
|
2074038 | if(d < -3 || d > 3) |
| 1190 | 32014 | return 1; | |
| 1191 | 2042024 | return 0; | |
| 1192 | } | ||
| 1193 | |||
| 1194 | 286800 | static int rv34_set_deblock_coef(RV34DecContext *r) | |
| 1195 | { | ||
| 1196 | 286800 | MpegEncContext *s = &r->s; | |
| 1197 | 286800 | int hmvmask = 0, vmvmask = 0, i, j; | |
| 1198 | 286800 | int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; | |
| 1199 | 286800 | int16_t (*motion_val)[2] = &s->cur_pic.motion_val[0][midx]; | |
| 1200 |
2/2✓ Branch 0 taken 573600 times.
✓ Branch 1 taken 286800 times.
|
860400 | for(j = 0; j < 16; j += 8){ |
| 1201 |
2/2✓ Branch 0 taken 1147200 times.
✓ Branch 1 taken 573600 times.
|
1720800 | for(i = 0; i < 2; i++){ |
| 1202 |
2/2✓ Branch 1 taken 107029 times.
✓ Branch 2 taken 1040171 times.
|
1147200 | if(is_mv_diff_gt_3(motion_val + i, 1)) |
| 1203 | 107029 | vmvmask |= 0x11 << (j + i*2); | |
| 1204 |
6/6✓ Branch 0 taken 573600 times.
✓ Branch 1 taken 573600 times.
✓ Branch 2 taken 542632 times.
✓ Branch 3 taken 30968 times.
✓ Branch 5 taken 114379 times.
✓ Branch 6 taken 1001853 times.
|
1147200 | if((j || s->mb_y) && is_mv_diff_gt_3(motion_val + i, s->b8_stride)) |
| 1205 | 114379 | hmvmask |= 0x03 << (j + i*2); | |
| 1206 | } | ||
| 1207 | 573600 | motion_val += s->b8_stride; | |
| 1208 | } | ||
| 1209 |
2/2✓ Branch 0 taken 42635 times.
✓ Branch 1 taken 244165 times.
|
286800 | if(s->first_slice_line) |
| 1210 | 42635 | hmvmask &= ~0x000F; | |
| 1211 |
2/2✓ Branch 0 taken 9180 times.
✓ Branch 1 taken 277620 times.
|
286800 | if(!s->mb_x) |
| 1212 | 9180 | vmvmask &= ~0x1111; | |
| 1213 |
2/2✓ Branch 0 taken 68640 times.
✓ Branch 1 taken 218160 times.
|
286800 | if(r->rv30){ //RV30 marks both subblocks on the edge for filtering |
| 1214 | 68640 | vmvmask |= (vmvmask & 0x4444) >> 1; | |
| 1215 | 68640 | hmvmask |= (hmvmask & 0x0F00) >> 4; | |
| 1216 |
2/2✓ Branch 0 taken 65520 times.
✓ Branch 1 taken 3120 times.
|
68640 | if(s->mb_x) |
| 1217 | 65520 | r->deblock_coefs[s->mb_x - 1 + s->mb_y*s->mb_stride] |= (vmvmask & 0x1111) << 3; | |
| 1218 |
2/2✓ Branch 0 taken 61878 times.
✓ Branch 1 taken 6762 times.
|
68640 | if(!s->first_slice_line) |
| 1219 | 61878 | r->deblock_coefs[s->mb_x + (s->mb_y - 1)*s->mb_stride] |= (hmvmask & 0xF) << 12; | |
| 1220 | } | ||
| 1221 | 286800 | return hmvmask | vmvmask; | |
| 1222 | } | ||
| 1223 | |||
| 1224 | 286800 | static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types) | |
| 1225 | { | ||
| 1226 | 286800 | MpegEncContext *s = &r->s; | |
| 1227 | 286800 | GetBitContext *const gb = &r->gb; | |
| 1228 | 286800 | uint8_t *dst = s->dest[0]; | |
| 1229 | 286800 | int16_t *const ptr = r->block; | |
| 1230 | 286800 | int mb_pos = s->mb_x + s->mb_y * s->mb_stride; | |
| 1231 | int cbp, cbp2; | ||
| 1232 | int q_dc, q_ac, has_ac; | ||
| 1233 | int i, j; | ||
| 1234 | int dist; | ||
| 1235 | |||
| 1236 | // Calculate which neighbours are available. Maybe it's worth optimizing too. | ||
| 1237 | 286800 | memset(r->avail_cache, 0, sizeof(r->avail_cache)); | |
| 1238 | 286800 | fill_rectangle(r->avail_cache + 6, 2, 2, 4, 1, 4); | |
| 1239 | 286800 | dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width; | |
| 1240 |
4/4✓ Branch 0 taken 277620 times.
✓ Branch 1 taken 9180 times.
✓ Branch 2 taken 277115 times.
✓ Branch 3 taken 505 times.
|
286800 | if(s->mb_x && dist) |
| 1241 | 277115 | r->avail_cache[5] = | |
| 1242 | 277115 | r->avail_cache[9] = s->cur_pic.mb_type[mb_pos - 1]; | |
| 1243 |
2/2✓ Branch 0 taken 244165 times.
✓ Branch 1 taken 42635 times.
|
286800 | if(dist >= s->mb_width) |
| 1244 | 244165 | r->avail_cache[2] = | |
| 1245 | 244165 | r->avail_cache[3] = s->cur_pic.mb_type[mb_pos - s->mb_stride]; | |
| 1246 |
4/4✓ Branch 0 taken 277620 times.
✓ Branch 1 taken 9180 times.
✓ Branch 2 taken 236751 times.
✓ Branch 3 taken 40869 times.
|
286800 | if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1) |
| 1247 | 236751 | r->avail_cache[4] = s->cur_pic.mb_type[mb_pos - s->mb_stride + 1]; | |
| 1248 |
4/4✓ Branch 0 taken 277620 times.
✓ Branch 1 taken 9180 times.
✓ Branch 2 taken 235822 times.
✓ Branch 3 taken 41798 times.
|
286800 | if(s->mb_x && dist > s->mb_width) |
| 1249 | 235822 | r->avail_cache[1] = s->cur_pic.mb_type[mb_pos - s->mb_stride - 1]; | |
| 1250 | |||
| 1251 | 286800 | s->qscale = r->si.quant; | |
| 1252 | 286800 | cbp = cbp2 = rv34_decode_inter_mb_header(r, intra_types); | |
| 1253 | 286800 | r->cbp_luma [mb_pos] = cbp; | |
| 1254 | 286800 | r->cbp_chroma[mb_pos] = cbp >> 16; | |
| 1255 | 286800 | r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r) | r->cbp_luma[mb_pos]; | |
| 1256 | 286800 | s->cur_pic.qscale_table[mb_pos] = s->qscale; | |
| 1257 | |||
| 1258 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 286800 times.
|
286800 | if(cbp == -1) |
| 1259 | ✗ | return -1; | |
| 1260 | |||
| 1261 |
2/2✓ Branch 0 taken 24375 times.
✓ Branch 1 taken 262425 times.
|
286800 | if (IS_INTRA(s->cur_pic.mb_type[mb_pos])) { |
| 1262 |
2/2✓ Branch 0 taken 11056 times.
✓ Branch 1 taken 13319 times.
|
24375 | if(r->is16) rv34_output_i16x16(r, intra_types, cbp); |
| 1263 | 13319 | else rv34_output_intra(r, intra_types, cbp); | |
| 1264 | 24375 | return 0; | |
| 1265 | } | ||
| 1266 | |||
| 1267 |
2/2✓ Branch 0 taken 549 times.
✓ Branch 1 taken 261876 times.
|
262425 | if(r->is16){ |
| 1268 | // Only for RV34_MB_P_MIX16x16 | ||
| 1269 | 549 | LOCAL_ALIGNED_16(int16_t, block16, [16]); | |
| 1270 | 549 | memset(block16, 0, 16 * sizeof(*block16)); | |
| 1271 | 549 | q_dc = rv34_qscale_tab[ r->luma_dc_quant_p[s->qscale] ]; | |
| 1272 | 549 | q_ac = rv34_qscale_tab[s->qscale]; | |
| 1273 |
2/2✓ Branch 1 taken 268 times.
✓ Branch 2 taken 281 times.
|
549 | if (rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac)) |
| 1274 | 268 | r->rdsp.rv34_inv_transform(block16); | |
| 1275 | else | ||
| 1276 | 281 | r->rdsp.rv34_inv_transform_dc(block16); | |
| 1277 | |||
| 1278 | 549 | q_ac = rv34_qscale_tab[s->qscale]; | |
| 1279 | |||
| 1280 |
2/2✓ Branch 0 taken 2196 times.
✓ Branch 1 taken 549 times.
|
2745 | for(j = 0; j < 4; j++){ |
| 1281 |
2/2✓ Branch 0 taken 8784 times.
✓ Branch 1 taken 2196 times.
|
10980 | for(i = 0; i < 4; i++, cbp >>= 1){ |
| 1282 | 8784 | int dc = block16[i + j*4]; | |
| 1283 | |||
| 1284 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8778 times.
|
8784 | if(cbp & 1){ |
| 1285 | 6 | has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac); | |
| 1286 | }else | ||
| 1287 | 8778 | has_ac = 0; | |
| 1288 | |||
| 1289 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8778 times.
|
8784 | if(has_ac){ |
| 1290 | 6 | ptr[0] = dc; | |
| 1291 | 6 | r->rdsp.rv34_idct_add(dst+4*i, s->linesize, ptr); | |
| 1292 | }else | ||
| 1293 | 8778 | r->rdsp.rv34_idct_dc_add(dst+4*i, s->linesize, dc); | |
| 1294 | } | ||
| 1295 | |||
| 1296 | 2196 | dst += 4*s->linesize; | |
| 1297 | } | ||
| 1298 | |||
| 1299 | 549 | r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); | |
| 1300 | }else{ | ||
| 1301 | 261876 | q_ac = rv34_qscale_tab[s->qscale]; | |
| 1302 | |||
| 1303 |
2/2✓ Branch 0 taken 1047504 times.
✓ Branch 1 taken 261876 times.
|
1309380 | for(j = 0; j < 4; j++){ |
| 1304 |
2/2✓ Branch 0 taken 4190016 times.
✓ Branch 1 taken 1047504 times.
|
5237520 | for(i = 0; i < 4; i++, cbp >>= 1){ |
| 1305 |
2/2✓ Branch 0 taken 3870649 times.
✓ Branch 1 taken 319367 times.
|
4190016 | if(!(cbp & 1)) continue; |
| 1306 | |||
| 1307 | 319367 | rv34_process_block(r, dst + 4*i, s->linesize, | |
| 1308 | r->luma_vlc, 0, q_ac, q_ac); | ||
| 1309 | } | ||
| 1310 | 1047504 | dst += 4*s->linesize; | |
| 1311 | } | ||
| 1312 | } | ||
| 1313 | |||
| 1314 | 262425 | q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]]; | |
| 1315 | 262425 | q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]; | |
| 1316 | |||
| 1317 |
2/2✓ Branch 0 taken 524850 times.
✓ Branch 1 taken 262425 times.
|
787275 | for(j = 1; j < 3; j++){ |
| 1318 | 524850 | dst = s->dest[j]; | |
| 1319 |
2/2✓ Branch 0 taken 2099400 times.
✓ Branch 1 taken 524850 times.
|
2624250 | for(i = 0; i < 4; i++, cbp >>= 1){ |
| 1320 | uint8_t *pdst; | ||
| 1321 |
2/2✓ Branch 0 taken 1954497 times.
✓ Branch 1 taken 144903 times.
|
2099400 | if(!(cbp & 1)) continue; |
| 1322 | 144903 | pdst = dst + (i&1)*4 + (i&2)*2*s->uvlinesize; | |
| 1323 | |||
| 1324 | 144903 | rv34_process_block(r, pdst, s->uvlinesize, | |
| 1325 | r->chroma_vlc, 1, q_dc, q_ac); | ||
| 1326 | } | ||
| 1327 | } | ||
| 1328 | |||
| 1329 | 262425 | return 0; | |
| 1330 | } | ||
| 1331 | |||
| 1332 | 7640 | static int rv34_decode_intra_macroblock(RV34DecContext *r, int8_t *intra_types) | |
| 1333 | { | ||
| 1334 | 7640 | MpegEncContext *s = &r->s; | |
| 1335 | int cbp, dist; | ||
| 1336 | 7640 | int mb_pos = s->mb_x + s->mb_y * s->mb_stride; | |
| 1337 | |||
| 1338 | // Calculate which neighbours are available. Maybe it's worth optimizing too. | ||
| 1339 | 7640 | memset(r->avail_cache, 0, sizeof(r->avail_cache)); | |
| 1340 | 7640 | fill_rectangle(r->avail_cache + 6, 2, 2, 4, 1, 4); | |
| 1341 | 7640 | dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width; | |
| 1342 |
4/4✓ Branch 0 taken 7352 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 7325 times.
✓ Branch 3 taken 27 times.
|
7640 | if(s->mb_x && dist) |
| 1343 | 7325 | r->avail_cache[5] = | |
| 1344 | 7325 | r->avail_cache[9] = s->cur_pic.mb_type[mb_pos - 1]; | |
| 1345 |
2/2✓ Branch 0 taken 6133 times.
✓ Branch 1 taken 1507 times.
|
7640 | if(dist >= s->mb_width) |
| 1346 | 6133 | r->avail_cache[2] = | |
| 1347 | 6133 | r->avail_cache[3] = s->cur_pic.mb_type[mb_pos - s->mb_stride]; | |
| 1348 |
4/4✓ Branch 0 taken 7352 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 5928 times.
✓ Branch 3 taken 1424 times.
|
7640 | if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1) |
| 1349 | 5928 | r->avail_cache[4] = s->cur_pic.mb_type[mb_pos - s->mb_stride + 1]; | |
| 1350 |
4/4✓ Branch 0 taken 7352 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 5878 times.
✓ Branch 3 taken 1474 times.
|
7640 | if(s->mb_x && dist > s->mb_width) |
| 1351 | 5878 | r->avail_cache[1] = s->cur_pic.mb_type[mb_pos - s->mb_stride - 1]; | |
| 1352 | |||
| 1353 | 7640 | s->qscale = r->si.quant; | |
| 1354 | 7640 | cbp = rv34_decode_intra_mb_header(r, intra_types); | |
| 1355 | 7640 | r->cbp_luma [mb_pos] = cbp; | |
| 1356 | 7640 | r->cbp_chroma[mb_pos] = cbp >> 16; | |
| 1357 | 7640 | r->deblock_coefs[mb_pos] = 0xFFFF; | |
| 1358 | 7640 | s->cur_pic.qscale_table[mb_pos] = s->qscale; | |
| 1359 | |||
| 1360 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7640 times.
|
7640 | if(cbp == -1) |
| 1361 | ✗ | return -1; | |
| 1362 | |||
| 1363 |
2/2✓ Branch 0 taken 5830 times.
✓ Branch 1 taken 1810 times.
|
7640 | if(r->is16){ |
| 1364 | 5830 | rv34_output_i16x16(r, intra_types, cbp); | |
| 1365 | 5830 | return 0; | |
| 1366 | } | ||
| 1367 | |||
| 1368 | 1810 | rv34_output_intra(r, intra_types, cbp); | |
| 1369 | 1810 | return 0; | |
| 1370 | } | ||
| 1371 | |||
| 1372 | 295833 | static int check_slice_end(RV34DecContext *r, MpegEncContext *s) | |
| 1373 | { | ||
| 1374 | int bits; | ||
| 1375 |
2/2✓ Branch 0 taken 529 times.
✓ Branch 1 taken 295304 times.
|
295833 | if(s->mb_y >= s->mb_height) |
| 1376 | 529 | return 1; | |
| 1377 |
2/2✓ Branch 0 taken 864 times.
✓ Branch 1 taken 294440 times.
|
295304 | if (!r->mb_num_left) |
| 1378 | 864 | return 1; | |
| 1379 |
2/2✓ Branch 0 taken 129696 times.
✓ Branch 1 taken 164744 times.
|
294440 | if (r->mb_skip_run > 1) |
| 1380 | 129696 | return 0; | |
| 1381 | 164744 | bits = get_bits_left(&r->gb); | |
| 1382 |
4/6✓ Branch 0 taken 164744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✓ Branch 3 taken 164575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 169 times.
|
164744 | if (bits <= 0 || (bits < 8 && !show_bits(&r->gb, bits))) |
| 1383 | ✗ | return 1; | |
| 1384 | 164744 | return 0; | |
| 1385 | } | ||
| 1386 | |||
| 1387 | |||
| 1388 | 9 | static void rv34_decoder_free(RV34DecContext *r) | |
| 1389 | { | ||
| 1390 | 9 | av_freep(&r->intra_types_hist); | |
| 1391 | 9 | r->intra_types = NULL; | |
| 1392 | 9 | av_freep(&r->tmp_b_block_base); | |
| 1393 | 9 | av_freep(&r->mb_type); | |
| 1394 | 9 | av_freep(&r->cbp_luma); | |
| 1395 | 9 | av_freep(&r->cbp_chroma); | |
| 1396 | 9 | av_freep(&r->deblock_coefs); | |
| 1397 | 9 | } | |
| 1398 | |||
| 1399 | |||
| 1400 | 9 | static int rv34_decoder_alloc(RV34DecContext *r) | |
| 1401 | { | ||
| 1402 | 9 | r->intra_types_stride = r->s.mb_width * 4 + 4; | |
| 1403 | |||
| 1404 | 9 | r->cbp_chroma = av_mallocz(r->s.mb_stride * r->s.mb_height * | |
| 1405 | sizeof(*r->cbp_chroma)); | ||
| 1406 | 9 | r->cbp_luma = av_mallocz(r->s.mb_stride * r->s.mb_height * | |
| 1407 | sizeof(*r->cbp_luma)); | ||
| 1408 | 9 | r->deblock_coefs = av_mallocz(r->s.mb_stride * r->s.mb_height * | |
| 1409 | sizeof(*r->deblock_coefs)); | ||
| 1410 | 9 | r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * | |
| 1411 | sizeof(*r->intra_types_hist)); | ||
| 1412 | 9 | r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * | |
| 1413 | sizeof(*r->mb_type)); | ||
| 1414 | |||
| 1415 |
3/6✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
|
9 | if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs && |
| 1416 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | r->intra_types_hist && r->mb_type)) { |
| 1417 | ✗ | r->s.context_reinit = 1; | |
| 1418 | ✗ | rv34_decoder_free(r); | |
| 1419 | ✗ | return AVERROR(ENOMEM); | |
| 1420 | } | ||
| 1421 | |||
| 1422 | 9 | r->intra_types = r->intra_types_hist + r->intra_types_stride * 4; | |
| 1423 | |||
| 1424 | 9 | return 0; | |
| 1425 | } | ||
| 1426 | |||
| 1427 | |||
| 1428 | ✗ | static int rv34_decoder_realloc(RV34DecContext *r) | |
| 1429 | { | ||
| 1430 | ✗ | rv34_decoder_free(r); | |
| 1431 | ✗ | return rv34_decoder_alloc(r); | |
| 1432 | } | ||
| 1433 | |||
| 1434 | |||
| 1435 | 1393 | static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size) | |
| 1436 | { | ||
| 1437 | 1393 | MpegEncContext *s = &r->s; | |
| 1438 | 1393 | GetBitContext *const gb = &r->gb; | |
| 1439 | int mb_pos, slice_type; | ||
| 1440 | int res; | ||
| 1441 | |||
| 1442 | 1393 | init_get_bits(gb, buf, buf_size*8); | |
| 1443 | 1393 | res = r->parse_slice_header(r, gb, &r->si); | |
| 1444 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1393 times.
|
1393 | if(res < 0){ |
| 1445 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n"); | |
| 1446 | ✗ | return -1; | |
| 1447 | } | ||
| 1448 | |||
| 1449 |
2/2✓ Branch 0 taken 1334 times.
✓ Branch 1 taken 59 times.
|
1393 | slice_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I; |
| 1450 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1393 times.
|
1393 | if (slice_type != s->pict_type) { |
| 1451 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n"); | |
| 1452 | ✗ | return AVERROR_INVALIDDATA; | |
| 1453 | } | ||
| 1454 |
2/4✓ Branch 0 taken 1393 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1393 times.
|
1393 | if (s->width != r->si.width || s->height != r->si.height) { |
| 1455 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "Size mismatch\n"); | |
| 1456 | ✗ | return AVERROR_INVALIDDATA; | |
| 1457 | } | ||
| 1458 | |||
| 1459 | 1393 | r->si.end = end; | |
| 1460 | 1393 | s->qscale = r->si.quant; | |
| 1461 | 1393 | r->mb_num_left = r->si.end - r->si.start; | |
| 1462 | 1393 | r->mb_skip_run = 0; | |
| 1463 | |||
| 1464 | 1393 | mb_pos = s->mb_x + s->mb_y * s->mb_width; | |
| 1465 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1393 times.
|
1393 | if(r->si.start != mb_pos){ |
| 1466 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "Slice indicates MB offset %d, got %d\n", r->si.start, mb_pos); | |
| 1467 | ✗ | s->mb_x = r->si.start % s->mb_width; | |
| 1468 | ✗ | s->mb_y = r->si.start / s->mb_width; | |
| 1469 | } | ||
| 1470 | 1393 | memset(r->intra_types_hist, -1, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); | |
| 1471 | 1393 | s->first_slice_line = 1; | |
| 1472 | 1393 | s->resync_mb_x = s->mb_x; | |
| 1473 | 1393 | s->resync_mb_y = s->mb_y; | |
| 1474 | |||
| 1475 | 1393 | ff_init_block_index(s); | |
| 1476 |
2/2✓ Branch 1 taken 294440 times.
✓ Branch 2 taken 1393 times.
|
295833 | while(!check_slice_end(r, s)) { |
| 1477 | 294440 | s->dest[0] += 16; | |
| 1478 | 294440 | s->dest[1] += 8; | |
| 1479 | 294440 | s->dest[2] += 8; | |
| 1480 | |||
| 1481 |
2/2✓ Branch 0 taken 286800 times.
✓ Branch 1 taken 7640 times.
|
294440 | if(r->si.type) |
| 1482 | 286800 | res = rv34_decode_inter_macroblock(r, r->intra_types + s->mb_x * 4 + 4); | |
| 1483 | else | ||
| 1484 | 7640 | res = rv34_decode_intra_macroblock(r, r->intra_types + s->mb_x * 4 + 4); | |
| 1485 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 294440 times.
|
294440 | if(res < 0){ |
| 1486 | ✗ | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_ERROR); | |
| 1487 | ✗ | return -1; | |
| 1488 | } | ||
| 1489 |
2/2✓ Branch 0 taken 9468 times.
✓ Branch 1 taken 284972 times.
|
294440 | if (++s->mb_x == s->mb_width) { |
| 1490 | 9468 | s->mb_x = 0; | |
| 1491 | 9468 | s->mb_y++; | |
| 1492 | 9468 | ff_init_block_index(s); | |
| 1493 | |||
| 1494 | 9468 | memmove(r->intra_types_hist, r->intra_types, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist)); | |
| 1495 | 9468 | memset(r->intra_types, -1, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist)); | |
| 1496 | |||
| 1497 |
3/4✓ Branch 0 taken 9468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8939 times.
✓ Branch 3 taken 529 times.
|
9468 | if(r->loop_filter && s->mb_y >= 2) |
| 1498 | 8939 | r->loop_filter(r, s->mb_y - 2); | |
| 1499 | |||
| 1500 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9468 times.
|
9468 | if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) |
| 1501 | ✗ | ff_thread_progress_report(&s->cur_pic.ptr->progress, | |
| 1502 | ✗ | s->mb_y - 2); | |
| 1503 | |||
| 1504 | } | ||
| 1505 |
2/2✓ Branch 0 taken 9089 times.
✓ Branch 1 taken 285351 times.
|
294440 | if(s->mb_x == s->resync_mb_x) |
| 1506 | 9089 | s->first_slice_line=0; | |
| 1507 | 294440 | r->mb_num_left--; | |
| 1508 | } | ||
| 1509 | 1393 | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); | |
| 1510 | |||
| 1511 | 1393 | return s->mb_y == s->mb_height; | |
| 1512 | } | ||
| 1513 | |||
| 1514 | /** @} */ // reconstruction group end | ||
| 1515 | |||
| 1516 | /** | ||
| 1517 | * Initialize decoder. | ||
| 1518 | */ | ||
| 1519 | 9 | av_cold int ff_rv34_decode_init(AVCodecContext *avctx) | |
| 1520 | { | ||
| 1521 | static AVOnce init_static_once = AV_ONCE_INIT; | ||
| 1522 | 9 | RV34DecContext *r = avctx->priv_data; | |
| 1523 | 9 | MpegEncContext *s = &r->s; | |
| 1524 | int ret; | ||
| 1525 | |||
| 1526 | 9 | ret = ff_mpv_decode_init(s, avctx); | |
| 1527 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (ret < 0) |
| 1528 | ✗ | return ret; | |
| 1529 | 9 | s->out_format = FMT_H263; | |
| 1530 | |||
| 1531 | 9 | avctx->pix_fmt = AV_PIX_FMT_YUV420P; | |
| 1532 | 9 | avctx->has_b_frames = 1; | |
| 1533 | 9 | s->low_delay = 0; | |
| 1534 | |||
| 1535 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
|
9 | if ((ret = ff_mpv_common_init(s)) < 0) |
| 1536 | ✗ | return ret; | |
| 1537 | |||
| 1538 | 9 | ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1); | |
| 1539 | |||
| 1540 | 9 | ret = rv34_decoder_alloc(r); | |
| 1541 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (ret < 0) |
| 1542 | ✗ | return ret; | |
| 1543 | |||
| 1544 | 9 | ff_thread_once(&init_static_once, rv34_init_tables); | |
| 1545 | |||
| 1546 | 9 | return 0; | |
| 1547 | } | ||
| 1548 | |||
| 1549 | ✗ | int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) | |
| 1550 | { | ||
| 1551 | ✗ | RV34DecContext *r = dst->priv_data, *r1 = src->priv_data; | |
| 1552 | ✗ | MpegEncContext *const s1 = &r1->s; | |
| 1553 | int ret; | ||
| 1554 | |||
| 1555 | ✗ | if (dst == src || !s1->context_initialized) | |
| 1556 | ✗ | return 0; | |
| 1557 | |||
| 1558 | ✗ | ret = ff_mpeg_update_thread_context(dst, src); | |
| 1559 | ✗ | if (ret < 0) | |
| 1560 | ✗ | return ret; | |
| 1561 | |||
| 1562 | // Did ff_mpeg_update_thread_context reinit? | ||
| 1563 | ✗ | if (ret > 0) { | |
| 1564 | ✗ | ret = rv34_decoder_realloc(r); | |
| 1565 | ✗ | if (ret < 0) | |
| 1566 | ✗ | return ret; | |
| 1567 | } | ||
| 1568 | |||
| 1569 | ✗ | r->cur_pts = r1->cur_pts; | |
| 1570 | ✗ | r->last_pts = r1->last_pts; | |
| 1571 | ✗ | r->next_pts = r1->next_pts; | |
| 1572 | |||
| 1573 | ✗ | memset(&r->si, 0, sizeof(r->si)); | |
| 1574 | |||
| 1575 | ✗ | return 0; | |
| 1576 | } | ||
| 1577 | |||
| 1578 | 4180 | static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n, int slice_count, int buf_size) | |
| 1579 | { | ||
| 1580 |
2/2✓ Branch 0 taken 3291 times.
✓ Branch 1 taken 889 times.
|
4180 | if (n < slice_count) { |
| 1581 |
1/2✓ Branch 0 taken 3291 times.
✗ Branch 1 not taken.
|
3291 | return AV_RL32(buf + n*8 - 4) == 1 ? AV_RL32(buf + n*8) : AV_RB32(buf + n*8); |
| 1582 | } else | ||
| 1583 | 889 | return buf_size; | |
| 1584 | } | ||
| 1585 | |||
| 1586 | 529 | static int finish_frame(AVCodecContext *avctx, AVFrame *pict) | |
| 1587 | { | ||
| 1588 | 529 | RV34DecContext *r = avctx->priv_data; | |
| 1589 | 529 | MpegEncContext *s = &r->s; | |
| 1590 | 529 | int got_picture = 0, ret; | |
| 1591 | |||
| 1592 | 529 | ff_er_frame_end(&s->er, NULL); | |
| 1593 | 529 | ff_mpv_frame_end(s); | |
| 1594 | 529 | r->mb_num_left = 0; | |
| 1595 | |||
| 1596 |
2/2✓ Branch 0 taken 389 times.
✓ Branch 1 taken 140 times.
|
529 | if (s->pict_type == AV_PICTURE_TYPE_B) { |
| 1597 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 389 times.
|
389 | if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0) |
| 1598 | ✗ | return ret; | |
| 1599 | 389 | ff_print_debug_info(s, s->cur_pic.ptr, pict); | |
| 1600 | 389 | ff_mpv_export_qp_table(s, pict, s->cur_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG1); | |
| 1601 | 389 | got_picture = 1; | |
| 1602 |
2/2✓ Branch 0 taken 131 times.
✓ Branch 1 taken 9 times.
|
140 | } else if (s->last_pic.ptr) { |
| 1603 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 131 times.
|
131 | if ((ret = av_frame_ref(pict, s->last_pic.ptr->f)) < 0) |
| 1604 | ✗ | return ret; | |
| 1605 | 131 | ff_print_debug_info(s, s->last_pic.ptr, pict); | |
| 1606 | 131 | ff_mpv_export_qp_table(s, pict, s->last_pic.ptr, FF_MPV_QSCALE_TYPE_MPEG1); | |
| 1607 | 131 | got_picture = 1; | |
| 1608 | } | ||
| 1609 | |||
| 1610 | 529 | return got_picture; | |
| 1611 | } | ||
| 1612 | |||
| 1613 | ✗ | static AVRational update_sar(int old_w, int old_h, AVRational sar, int new_w, int new_h) | |
| 1614 | { | ||
| 1615 | // attempt to keep aspect during typical resolution switches | ||
| 1616 | ✗ | if (!sar.num) | |
| 1617 | ✗ | sar = (AVRational){1, 1}; | |
| 1618 | |||
| 1619 | ✗ | sar = av_mul_q(sar, av_mul_q((AVRational){new_h, new_w}, (AVRational){old_w, old_h})); | |
| 1620 | ✗ | return sar; | |
| 1621 | } | ||
| 1622 | |||
| 1623 | 533 | int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, | |
| 1624 | int *got_picture_ptr, AVPacket *avpkt) | ||
| 1625 | { | ||
| 1626 | 533 | const uint8_t *buf = avpkt->data; | |
| 1627 | 533 | int buf_size = avpkt->size; | |
| 1628 | 533 | RV34DecContext *r = avctx->priv_data; | |
| 1629 | 533 | MpegEncContext *s = &r->s; | |
| 1630 | SliceInfo si; | ||
| 1631 | int i, ret; | ||
| 1632 | int slice_count; | ||
| 1633 | 533 | const uint8_t *slices_hdr = NULL; | |
| 1634 | 533 | int last = 0; | |
| 1635 | 533 | int faulty_b = 0; | |
| 1636 | int offset; | ||
| 1637 | |||
| 1638 | /* no supplementary picture */ | ||
| 1639 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 529 times.
|
533 | if (buf_size == 0) { |
| 1640 | /* special case for last picture */ | ||
| 1641 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | if (s->next_pic.ptr) { |
| 1642 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if ((ret = av_frame_ref(pict, s->next_pic.ptr->f)) < 0) |
| 1643 | ✗ | return ret; | |
| 1644 | 2 | ff_mpv_unref_picture(&s->next_pic); | |
| 1645 | |||
| 1646 | 2 | *got_picture_ptr = 1; | |
| 1647 | } | ||
| 1648 | 4 | return 0; | |
| 1649 | } | ||
| 1650 | |||
| 1651 | 529 | slice_count = (*buf++) + 1; | |
| 1652 | 529 | slices_hdr = buf + 4; | |
| 1653 | 529 | buf += 8 * slice_count; | |
| 1654 | 529 | buf_size -= 1 + 8 * slice_count; | |
| 1655 | |||
| 1656 | 529 | offset = get_slice_offset(avctx, slices_hdr, 0, slice_count, buf_size); | |
| 1657 | //parse first slice header to check whether this frame can be decoded | ||
| 1658 |
2/4✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 529 times.
|
529 | if(offset < 0 || offset > buf_size){ |
| 1659 | ✗ | av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); | |
| 1660 | ✗ | return AVERROR_INVALIDDATA; | |
| 1661 | } | ||
| 1662 | 529 | init_get_bits(&r->gb, buf+offset, (buf_size-offset)*8); | |
| 1663 |
2/4✓ Branch 1 taken 529 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 529 times.
|
529 | if (r->parse_slice_header(r, &r->gb, &si) < 0 || si.start) { |
| 1664 | ✗ | av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n"); | |
| 1665 | ✗ | return AVERROR_INVALIDDATA; | |
| 1666 | } | ||
| 1667 |
3/4✓ Branch 0 taken 13 times.
✓ Branch 1 taken 516 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
|
529 | if (!s->last_pic.ptr && si.type == AV_PICTURE_TYPE_B) { |
| 1668 | ✗ | av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without " | |
| 1669 | "reference data.\n"); | ||
| 1670 | ✗ | faulty_b = 1; | |
| 1671 | } | ||
| 1672 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
529 | if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B) |
| 1673 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
529 | || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I) |
| 1674 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
|
529 | || avctx->skip_frame >= AVDISCARD_ALL) |
| 1675 | ✗ | return avpkt->size; | |
| 1676 | |||
| 1677 | /* first slice */ | ||
| 1678 |
1/2✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
|
529 | if (si.start == 0) { |
| 1679 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
529 | if (r->mb_num_left > 0 && s->cur_pic.ptr) { |
| 1680 | ✗ | av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n", | |
| 1681 | r->mb_num_left); | ||
| 1682 | ✗ | if (!s->context_reinit) | |
| 1683 | ✗ | ff_er_frame_end(&s->er, NULL); | |
| 1684 | ✗ | ff_mpv_frame_end(s); | |
| 1685 | } | ||
| 1686 | |||
| 1687 |
3/6✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 529 times.
|
529 | if (s->width != si.width || s->height != si.height || s->context_reinit) { |
| 1688 | int err; | ||
| 1689 | |||
| 1690 | ✗ | av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n", | |
| 1691 | si.width, si.height); | ||
| 1692 | |||
| 1693 | ✗ | if (av_image_check_size(si.width, si.height, 0, s->avctx)) | |
| 1694 | ✗ | return AVERROR_INVALIDDATA; | |
| 1695 | |||
| 1696 | ✗ | s->avctx->sample_aspect_ratio = update_sar( | |
| 1697 | ✗ | s->width, s->height, s->avctx->sample_aspect_ratio, | |
| 1698 | si.width, si.height); | ||
| 1699 | ✗ | s->width = si.width; | |
| 1700 | ✗ | s->height = si.height; | |
| 1701 | |||
| 1702 | ✗ | err = ff_set_dimensions(s->avctx, s->width, s->height); | |
| 1703 | ✗ | if (err < 0) | |
| 1704 | ✗ | return err; | |
| 1705 | ✗ | if ((err = ff_mpv_common_frame_size_change(s)) < 0) | |
| 1706 | ✗ | return err; | |
| 1707 | ✗ | if ((err = rv34_decoder_realloc(r)) < 0) | |
| 1708 | ✗ | return err; | |
| 1709 | } | ||
| 1710 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
|
529 | if (faulty_b) |
| 1711 | ✗ | return AVERROR_INVALIDDATA; | |
| 1712 |
2/2✓ Branch 0 taken 511 times.
✓ Branch 1 taken 18 times.
|
529 | s->pict_type = si.type ? si.type : AV_PICTURE_TYPE_I; |
| 1713 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
|
529 | if (ff_mpv_frame_start(s, s->avctx) < 0) |
| 1714 | ✗ | return -1; | |
| 1715 | 529 | ff_mpeg_er_frame_start(s); | |
| 1716 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 520 times.
|
529 | if (!r->tmp_b_block_base) { |
| 1717 | int i; | ||
| 1718 | |||
| 1719 | 9 | r->tmp_b_block_base = av_malloc(s->linesize * 48); | |
| 1720 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (!r->tmp_b_block_base) |
| 1721 | ✗ | return AVERROR(ENOMEM); | |
| 1722 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | for (i = 0; i < 2; i++) |
| 1723 | 18 | r->tmp_b_block_y[i] = r->tmp_b_block_base | |
| 1724 | 18 | + i * 16 * s->linesize; | |
| 1725 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 9 times.
|
45 | for (i = 0; i < 4; i++) |
| 1726 | 36 | r->tmp_b_block_uv[i] = r->tmp_b_block_base + 32 * s->linesize | |
| 1727 | 36 | + (i >> 1) * 8 * s->uvlinesize | |
| 1728 | 36 | + (i & 1) * 16; | |
| 1729 | } | ||
| 1730 | 529 | r->cur_pts = si.pts; | |
| 1731 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 389 times.
|
529 | if (s->pict_type != AV_PICTURE_TYPE_B) { |
| 1732 | 140 | r->last_pts = r->next_pts; | |
| 1733 | 140 | r->next_pts = r->cur_pts; | |
| 1734 | } else { | ||
| 1735 | 389 | int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts); | |
| 1736 | 389 | int dist0 = GET_PTS_DIFF(r->cur_pts, r->last_pts); | |
| 1737 | 389 | int dist1 = GET_PTS_DIFF(r->next_pts, r->cur_pts); | |
| 1738 | |||
| 1739 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 389 times.
|
389 | if(!refdist){ |
| 1740 | ✗ | r->mv_weight1 = r->mv_weight2 = r->weight1 = r->weight2 = 8192; | |
| 1741 | ✗ | r->scaled_weight = 0; | |
| 1742 | }else{ | ||
| 1743 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 389 times.
|
389 | if (FFMAX(dist0, dist1) > refdist) |
| 1744 | ✗ | av_log(avctx, AV_LOG_TRACE, "distance overflow\n"); | |
| 1745 | |||
| 1746 | 389 | r->mv_weight1 = (dist0 << 14) / refdist; | |
| 1747 | 389 | r->mv_weight2 = (dist1 << 14) / refdist; | |
| 1748 |
2/2✓ Branch 0 taken 351 times.
✓ Branch 1 taken 38 times.
|
389 | if((r->mv_weight1|r->mv_weight2) & 511){ |
| 1749 | 351 | r->weight1 = r->mv_weight1; | |
| 1750 | 351 | r->weight2 = r->mv_weight2; | |
| 1751 | 351 | r->scaled_weight = 0; | |
| 1752 | }else{ | ||
| 1753 | 38 | r->weight1 = r->mv_weight1 >> 9; | |
| 1754 | 38 | r->weight2 = r->mv_weight2 >> 9; | |
| 1755 | 38 | r->scaled_weight = 1; | |
| 1756 | } | ||
| 1757 | } | ||
| 1758 | } | ||
| 1759 | 529 | s->mb_x = s->mb_y = 0; | |
| 1760 | 529 | ff_thread_finish_setup(s->avctx); | |
| 1761 | ✗ | } else if (s->context_reinit) { | |
| 1762 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames to " | |
| 1763 | "reinitialize (start MB is %d).\n", si.start); | ||
| 1764 | ✗ | return AVERROR_INVALIDDATA; | |
| 1765 | ✗ | } else if (HAVE_THREADS && | |
| 1766 | ✗ | (s->avctx->active_thread_type & FF_THREAD_FRAME)) { | |
| 1767 | ✗ | av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames in frame " | |
| 1768 | "multithreading mode (start MB is %d).\n", si.start); | ||
| 1769 | ✗ | return AVERROR_INVALIDDATA; | |
| 1770 | } | ||
| 1771 | |||
| 1772 |
1/2✓ Branch 0 taken 1393 times.
✗ Branch 1 not taken.
|
1393 | for(i = 0; i < slice_count; i++){ |
| 1773 | 1393 | int offset = get_slice_offset(avctx, slices_hdr, i , slice_count, buf_size); | |
| 1774 | 1393 | int offset1 = get_slice_offset(avctx, slices_hdr, i+1, slice_count, buf_size); | |
| 1775 | int size; | ||
| 1776 | |||
| 1777 |
3/6✓ Branch 0 taken 1393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1393 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1393 times.
|
1393 | if(offset < 0 || offset > offset1 || offset1 > buf_size){ |
| 1778 | ✗ | av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); | |
| 1779 | ✗ | break; | |
| 1780 | } | ||
| 1781 | 1393 | size = offset1 - offset; | |
| 1782 | |||
| 1783 | 1393 | r->si.end = s->mb_width * s->mb_height; | |
| 1784 | 1393 | r->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; | |
| 1785 | |||
| 1786 |
2/2✓ Branch 0 taken 865 times.
✓ Branch 1 taken 528 times.
|
1393 | if(i+1 < slice_count){ |
| 1787 | 865 | int offset2 = get_slice_offset(avctx, slices_hdr, i+2, slice_count, buf_size); | |
| 1788 |
2/4✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 865 times.
|
865 | if (offset2 < offset1 || offset2 > buf_size) { |
| 1789 | ✗ | av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); | |
| 1790 | ✗ | break; | |
| 1791 | } | ||
| 1792 | 865 | init_get_bits(&r->gb, buf+offset1, (buf_size-offset1)*8); | |
| 1793 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 864 times.
|
865 | if (r->parse_slice_header(r, &r->gb, &si) < 0) { |
| 1794 | 1 | size = offset2 - offset; | |
| 1795 | }else | ||
| 1796 | 864 | r->si.end = si.start; | |
| 1797 | } | ||
| 1798 |
2/4✓ Branch 0 taken 1393 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1393 times.
|
1393 | av_assert0 (size >= 0 && size <= buf_size - offset); |
| 1799 | 1393 | last = rv34_decode_slice(r, r->si.end, buf + offset, size); | |
| 1800 |
2/2✓ Branch 0 taken 529 times.
✓ Branch 1 taken 864 times.
|
1393 | if(last) |
| 1801 | 529 | break; | |
| 1802 | } | ||
| 1803 | |||
| 1804 |
1/2✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
|
529 | if (s->cur_pic.ptr) { |
| 1805 |
1/2✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
|
529 | if (last) { |
| 1806 |
1/2✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
|
529 | if(r->loop_filter) |
| 1807 | 529 | r->loop_filter(r, s->mb_height - 1); | |
| 1808 | |||
| 1809 | 529 | ret = finish_frame(avctx, pict); | |
| 1810 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
|
529 | if (ret < 0) |
| 1811 | ✗ | return ret; | |
| 1812 | 529 | *got_picture_ptr = ret; | |
| 1813 | ✗ | } else if (HAVE_THREADS && | |
| 1814 | ✗ | (s->avctx->active_thread_type & FF_THREAD_FRAME)) { | |
| 1815 | ✗ | av_log(avctx, AV_LOG_INFO, "marking unfinished frame as finished\n"); | |
| 1816 | /* always mark the current frame as finished, frame-mt supports | ||
| 1817 | * only complete frames */ | ||
| 1818 | ✗ | ff_er_frame_end(&s->er, NULL); | |
| 1819 | ✗ | ff_mpv_frame_end(s); | |
| 1820 | ✗ | r->mb_num_left = 0; | |
| 1821 | ✗ | return AVERROR_INVALIDDATA; | |
| 1822 | } | ||
| 1823 | } | ||
| 1824 | |||
| 1825 | 529 | return avpkt->size; | |
| 1826 | } | ||
| 1827 | |||
| 1828 | 9 | av_cold int ff_rv34_decode_end(AVCodecContext *avctx) | |
| 1829 | { | ||
| 1830 | 9 | RV34DecContext *r = avctx->priv_data; | |
| 1831 | |||
| 1832 | 9 | rv34_decoder_free(r); | |
| 1833 | |||
| 1834 | 9 | return ff_mpv_decode_close(avctx); | |
| 1835 | } | ||
| 1836 |