Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -297,98 +297,98 @@ static int decode_speedhq_field(const SHQContext *s, const uint8_t *buf, int buf · 296 unmodified lines | ||
| 297 | 297 | return AVERROR_INVALIDDATA; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | − slice_begin = slice_offsets[slice_number]; | |
| 301 | − slice_end = slice_offsets[slice_number + 1]; | |
| 300 | + slice_begin = slice_offsets[slice_number]; | |
| 301 | + slice_end = slice_offsets[slice_number + 1]; | |
| 302 | 302 | |
| 303 | − if ((ret = init_get_bits8(&gb, buf + slice_begin + 3, slice_end - slice_begin - 3)) < 0) | |
| 304 | − return ret; | |
| 303 | + if ((ret = init_get_bits8(&gb, buf + slice_begin + 3, slice_end - slice_begin - 3)) < 0) | |
| 304 | + return ret; | |
| 305 | 305 | |
| 306 | − for (y = slice_number * 16 * line_stride; y < frame->height; y += line_stride * 64) { | |
| 307 | − uint8_t *dest_y, *dest_cb, *dest_cr, *dest_a; | |
| 308 | − int last_dc[4] = { 1024, 1024, 1024, 1024 }; | |
| 309 | − uint8_t last_alpha[16]; | |
| 306 | + for (y = slice_number * 16 * line_stride; y < frame->height; y += line_stride * 64) { | |
| 307 | + uint8_t *dest_y, *dest_cb, *dest_cr, *dest_a; | |
| 308 | + int last_dc[4] = { 1024, 1024, 1024, 1024 }; | |
| 309 | + uint8_t last_alpha[16]; | |
| 310 | 310 | |
| 311 | − memset(last_alpha, 255, sizeof(last_alpha)); | |
| 311 | + memset(last_alpha, 255, sizeof(last_alpha)); | |
| 312 | 312 | |
| 313 | − dest_y = frame->data[0] + frame->linesize[0] * (y + field_number); | |
| 314 | − if (s->subsampling == SHQ_SUBSAMPLING_420) { | |
| 315 | − dest_cb = frame->data[1] + frame->linesize[1] * (y/2 + field_number); | |
| 316 | − dest_cr = frame->data[2] + frame->linesize[2] * (y/2 + field_number); | |
| 317 | − } else { | |
| 318 | − dest_cb = frame->data[1] + frame->linesize[1] * (y + field_number); | |
| 319 | − dest_cr = frame->data[2] + frame->linesize[2] * (y + field_number); | |
| 320 | − } | |
| 321 | − if (s->alpha_type != SHQ_NO_ALPHA) { | |
| 322 | − dest_a = frame->data[3] + frame->linesize[3] * (y + field_number); | |
| 323 | − } | |
| 313 | + dest_y = frame->data[0] + frame->linesize[0] * (y + field_number); | |
| 314 | + if (s->subsampling == SHQ_SUBSAMPLING_420) { | |
| 315 | + dest_cb = frame->data[1] + frame->linesize[1] * (y/2 + field_number); | |
| 316 | + dest_cr = frame->data[2] + frame->linesize[2] * (y/2 + field_number); | |
| 317 | + } else { | |
| 318 | + dest_cb = frame->data[1] + frame->linesize[1] * (y + field_number); | |
| 319 | + dest_cr = frame->data[2] + frame->linesize[2] * (y + field_number); | |
| 320 | + } | |
| 321 | + if (s->alpha_type != SHQ_NO_ALPHA) { | |
| 322 | + dest_a = frame->data[3] + frame->linesize[3] * (y + field_number); | |
| 323 | + } | |
| 324 | 324 | |
| 325 | − for (x = 0; x < frame->width - 8 * (s->subsampling != SHQ_SUBSAMPLING_444); x += 16) { | |
| 326 | − /* Decode the four luma blocks. */ | |
| 327 | − if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y, linesize_y)) < 0) | |
| 328 | − return ret; | |
| 329 | − if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y + 8, linesize_y)) < 0) | |
| 330 | − return ret; | |
| 331 | − if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y + 8 * linesize_y, linesize_y)) < 0) | |
| 332 | − return ret; | |
| 333 | − if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y + 8 * linesize_y + 8, linesize_y)) < 0) | |
| 334 | − return ret; | |
| 325 | + for (x = 0; x < frame->width - 8 * (s->subsampling != SHQ_SUBSAMPLING_444); x += 16) { | |
| 326 | + /* Decode the four luma blocks. */ | |
| 327 | + if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y, linesize_y)) < 0) | |
| 328 | + return ret; | |
| 329 | + if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y + 8, linesize_y)) < 0) | |
| 330 | + return ret; | |
| 331 | + if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y + 8 * linesize_y, linesize_y)) < 0) | |
| 332 | + return ret; | |
| 333 | + if ((ret = decode_dct_block(s, &gb, last_dc, 0, dest_y + 8 * linesize_y + 8, linesize_y)) < 0) | |
| 334 | + return ret; | |
| 335 | + | |
| 336 | + /* | |
| 337 | + * Decode the first chroma block. For 4:2:0, this is the only one; | |
| 338 | + * for 4:2:2, it's the top block; for 4:4:4, it's the top-left block. | |
| 339 | + */ | |
| 340 | + if ((ret = decode_dct_block(s, &gb, last_dc, 1, dest_cb, linesize_cb)) < 0) | |
| 341 | + return ret; | |
| 342 | + if ((ret = decode_dct_block(s, &gb, last_dc, 2, dest_cr, linesize_cr)) < 0) | |
| 343 | + return ret; | |
| 335 | 344 | |
| 336 | − /* | |
| 337 | − * Decode the first chroma block. For 4:2:0, this is the only one; | |
| 338 | − * for 4:2:2, it's the top block; for 4:4:4, it's the top-left block. | |
| 339 | − */ | |
| 340 | − if ((ret = decode_dct_block(s, &gb, last_dc, 1, dest_cb, linesize_cb)) < 0) | |
| 345 | + if (s->subsampling != SHQ_SUBSAMPLING_420) { | |
| 346 | + /* For 4:2:2, this is the bottom block; for 4:4:4, it's the bottom-left block. */ | |
| 347 | + if ((ret = decode_dct_block(s, &gb, last_dc, 1, dest_cb + 8 * linesize_cb, linesize_cb)) < 0) | |
| 341 | 348 | return ret; |
| 342 | − if ((ret = decode_dct_block(s, &gb, last_dc, 2, dest_cr, linesize_cr)) < 0) | |
| 349 | + if ((ret = decode_dct_block(s, &gb, last_dc, 2, dest_cr + 8 * linesize_cr, linesize_cr)) < 0) | |
| 343 | 350 | return ret; |
| 344 | 351 | |
| 345 | − if (s->subsampling != SHQ_SUBSAMPLING_420) { | |
| 346 | − /* For 4:2:2, this is the bottom block; for 4:4:4, it's the bottom-left block. */ | |
| 347 | − if ((ret = decode_dct_block(s, &gb, last_dc, 1, dest_cb + 8 * linesize_cb, linesize_cb)) < 0) | |
| 348 | − return ret; | |
| 349 | − if ((ret = decode_dct_block(s, &gb, last_dc, 2, dest_cr + 8 * linesize_cr, linesize_cr)) < 0) | |
| 350 | − return ret; | |
| 351 | − | |
| 352 | − if (s->subsampling == SHQ_SUBSAMPLING_444) { | |
| 353 | − /* Top-right and bottom-right blocks. */ | |
| 354 | − if ((ret = decode_dct_block(s, &gb, last_dc, 1, dest_cb + 8, linesize_cb)) < 0) | |
| 355 | − return ret; | |
| 356 | − if ((ret = decode_dct_block(s, &gb, last_dc, 2, dest_cr + 8, linesize_cr)) < 0) | |
| 357 | − return ret; | |
| 358 | − if ((ret = decode_dct_block(s, &gb, last_dc, 1, dest_cb + 8 * linesize_cb + 8, linesize_cb)) < 0) | |
| 359 | − return ret; | |
| 360 | − if ((ret = decode_dct_block(s, &gb, last_dc, 2, dest_cr + 8 * linesize_cr + 8, linesize_cr)) < 0) | |
| 361 | − return ret; | |
| 362 | − | |
| 363 | − dest_cb += 8; | |
| 364 | − dest_cr += 8; | |
| 365 | − } | |
| 366 | − } | |
| 367 | − dest_y += 16; | |
| 368 | − dest_cb += 8; | |
| 369 | − dest_cr += 8; | |
| 370 | − | |
| 371 | − if (s->alpha_type == SHQ_RLE_ALPHA) { | |
| 372 | − /* Alpha coded using 16x8 RLE blocks. */ | |
| 373 | − if ((ret = decode_alpha_block(s, &gb, last_alpha, dest_a, linesize_a)) < 0) | |
| 374 | − return ret; | |
| 375 | − if ((ret = decode_alpha_block(s, &gb, last_alpha, dest_a + 8 * linesize_a, linesize_a)) < 0) | |
| 376 | − return ret; | |
| 377 | − dest_a += 16; | |
| 378 | − } else if (s->alpha_type == SHQ_DCT_ALPHA) { | |
| 379 | − /* Alpha encoded exactly like luma. */ | |
| 380 | − if ((ret = decode_dct_block(s, &gb, last_dc, 3, dest_a, linesize_a)) < 0) | |
| 352 | + if (s->subsampling == SHQ_SUBSAMPLING_444) { | |
| 353 | + /* Top-right and bottom-right blocks. */ | |
| 354 | + if ((ret = decode_dct_block(s, &gb, last_dc, 1, dest_cb + 8, linesize_cb)) < 0) | |
| 381 | 355 | return ret; |
| 382 | − if ((ret = decode_dct_block(s, &gb, last_dc, 3, dest_a + 8, linesize_a)) < 0) | |
| 356 | + if ((ret = decode_dct_block(s, &gb, last_dc, 2, dest_cr + 8, linesize_cr)) < 0) | |
| 383 | 357 | return ret; |
| 384 | − if ((ret = decode_dct_block(s, &gb, last_dc, 3, dest_a + 8 * linesize_a, linesize_a)) < 0) | |
| 358 | + if ((ret = decode_dct_block(s, &gb, last_dc, 1, dest_cb + 8 * linesize_cb + 8, linesize_cb)) < 0) | |
| 385 | 359 | return ret; |
| 386 | − if ((ret = decode_dct_block(s, &gb, last_dc, 3, dest_a + 8 * linesize_a + 8, linesize_a)) < 0) | |
| 360 | + if ((ret = decode_dct_block(s, &gb, last_dc, 2, dest_cr + 8 * linesize_cr + 8, linesize_cr)) < 0) | |
| 387 | 361 | return ret; |
| 388 | − dest_a += 16; | |
| 362 | + | |
| 363 | + dest_cb += 8; | |
| 364 | + dest_cr += 8; | |
| 389 | 365 | } |
| 390 | 366 | } |
| 367 | + dest_y += 16; | |
| 368 | + dest_cb += 8; | |
| 369 | + dest_cr += 8; | |
| 370 | + | |
| 371 | + if (s->alpha_type == SHQ_RLE_ALPHA) { | |
| 372 | + /* Alpha coded using 16x8 RLE blocks. */ | |
| 373 | + if ((ret = decode_alpha_block(s, &gb, last_alpha, dest_a, linesize_a)) < 0) | |
| 374 | + return ret; | |
| 375 | + if ((ret = decode_alpha_block(s, &gb, last_alpha, dest_a + 8 * linesize_a, linesize_a)) < 0) | |
| 376 | + return ret; | |
| 377 | + dest_a += 16; | |
| 378 | + } else if (s->alpha_type == SHQ_DCT_ALPHA) { | |
| 379 | + /* Alpha encoded exactly like luma. */ | |
| 380 | + if ((ret = decode_dct_block(s, &gb, last_dc, 3, dest_a, linesize_a)) < 0) | |
| 381 | + return ret; | |
| 382 | + if ((ret = decode_dct_block(s, &gb, last_dc, 3, dest_a + 8, linesize_a)) < 0) | |
| 383 | + return ret; | |
| 384 | + if ((ret = decode_dct_block(s, &gb, last_dc, 3, dest_a + 8 * linesize_a, linesize_a)) < 0) | |
| 385 | + return ret; | |
| 386 | + if ((ret = decode_dct_block(s, &gb, last_dc, 3, dest_a + 8 * linesize_a + 8, linesize_a)) < 0) | |
| 387 | + return ret; | |
| 388 | + dest_a += 16; | |
| 389 | + } | |
| 391 | 390 | } |
| 391 | + } | |
| 392 | 392 | |
| 393 | 393 | if (s->subsampling != SHQ_SUBSAMPLING_444 && (frame->width & 15) && slice_number == 3) |
| 394 | 394 | return decode_speedhq_border(s, &gb, frame, field_number, line_stride); |