This makes the function closer to encode_dcs() in proresenc_kostya.
Unified · Split
| @@ -257,7 +257,6 @@ static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val) · 256 unmodified lines | |||
| 257 | 257 | ||
| 258 | #define GET_SIGN(x) ((x) >> 31) | 258 | #define GET_SIGN(x) ((x) >> 31) |
| 259 | #define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val)) | 259 | #define TO_GOLOMB(val) (((val) * 2) ^ GET_SIGN(val)) |
| 260 | #define DIFF_SIGN(val, sign) (GET_SIGN(val) ^ (sign)) | ||
| 261 | #define IS_NEGATIVE(val) ((GET_SIGN(val) ^ -1) + 1) | 260 | #define IS_NEGATIVE(val) ((GET_SIGN(val) ^ -1) + 1) |
| 262 | #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign)) | 261 | #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign)) |
| 263 | 262 | ||
| @@ -272,7 +271,7 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks, · 8 unmodified lines | |||
| 272 | int blocks_per_slice, int *qmat) | 271 | int blocks_per_slice, int *qmat) |
| 273 | { | 272 | { |
| 274 | int prev_dc, codebook; | 273 | int prev_dc, codebook; |
| 275 | int i, sign; | 274 | int i, sign, new_sign; |
| 276 | int new_dc, delta, diff_sign, code; | 275 | int new_dc, delta, diff_sign, code; |
| 277 | 276 | ||
| 278 | prev_dc = (blocks[0] - 0x4000) / qmat[0]; | 277 | prev_dc = (blocks[0] - 0x4000) / qmat[0]; |
| @@ -284,13 +283,14 @@ static void encode_dcs(PutBitContext *pb, int16_t *blocks, · 5 unmodified lines | |||
| 284 | for (i = 1; i < blocks_per_slice; i++, blocks += 64) { | 283 | for (i = 1; i < blocks_per_slice; i++, blocks += 64) { |
| 285 | new_dc = (blocks[0] - 0x4000) / qmat[0]; | 284 | new_dc = (blocks[0] - 0x4000) / qmat[0]; |
| 286 | delta = new_dc - prev_dc; | 285 | delta = new_dc - prev_dc; |
| 287 | diff_sign = DIFF_SIGN(delta, sign); | 286 | new_sign = GET_SIGN(delta); |
| 287 | diff_sign = new_sign ^ sign; | ||
| 288 | code = TO_GOLOMB2(get_level(delta), diff_sign); | 288 | code = TO_GOLOMB2(get_level(delta), diff_sign); |
| 289 | 289 | ||
| 290 | encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code); | 290 | encode_vlc_codeword(pb, ff_prores_dc_codebook[codebook], code); |
| 291 | 291 | ||
| 292 | codebook = FFMIN(code, 6); | 292 | codebook = FFMIN(code, 6); |
| 293 | sign = delta >> 31; | 293 | sign = new_sign; |
| 294 | prev_dc = new_dc; | 294 | prev_dc = new_dc; |
| 295 | } | 295 | } |
| 296 | } | 296 | } |