| 2563 | } |
| 2564 | |
| 2565 | static int decode_slice(struct AVCodecContext *avctx, void *arg) |
| 2566 | { |
| 2567 | H264SliceContext *sl = arg; |
| 2568 | const H264Context *h = sl->h264; |
| 2569 | int lf_x_start = sl->mb_x; |
| 2570 | int orig_deblock = sl->deblocking_filter; |
| 2571 | int ret; |
| 2572 | |
| 2573 | sl->linesize = h->cur_pic_ptr->f->linesize[0]; |
| 2574 | sl->uvlinesize = h->cur_pic_ptr->f->linesize[1]; |
| 2575 | |
| 2576 | ret = alloc_scratch_buffers(sl, sl->linesize); |
| 2577 | if (ret < 0) |
| 2578 | return ret; |
| 2579 | |
| 2580 | sl->mb_skip_run = -1; |
| 2581 | |
| 2582 | av_assert0(h->block_offset[15] == (4 * ((scan8[15] - scan8[0]) & 7) << h->pixel_shift) + 4 * sl->linesize * ((scan8[15] - scan8[0]) >> 3)); |
| 2583 | |
| 2584 | if (h->postpone_filter) |
| 2585 | sl->deblocking_filter = 0; |
| 2586 | |
| 2587 | sl->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME || |
| 2588 | (CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY)); |
| 2589 | |
| 2590 | if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && sl->er->error_status_table) { |
| 2591 | const int start_i = av_clip(sl->resync_mb_x + sl->resync_mb_y * h->mb_width, 0, h->mb_num - 1); |
| 2592 | if (start_i) { |
| 2593 | int prev_status = sl->er->error_status_table[sl->er->mb_index2xy[start_i - 1]]; |
| 2594 | prev_status &= ~ VP_START; |
| 2595 | if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) |
| 2596 | sl->er->error_occurred = 1; |
| 2597 | } |
| 2598 | } |
| 2599 | |
| 2600 | if (h->ps.pps->cabac) { |
| 2601 | /* realign */ |
| 2602 | align_get_bits(&sl->gb); |
| 2603 | |
| 2604 | /* init cabac */ |
| 2605 | ret = ff_init_cabac_decoder(&sl->cabac, |
| 2606 | sl->gb.buffer + get_bits_count(&sl->gb) / 8, |
| 2607 | (get_bits_left(&sl->gb) + 7) / 8); |
| 2608 | if (ret < 0) |
| 2609 | return ret; |
| 2610 | |
| 2611 | ff_h264_init_cabac_states(h, sl); |
| 2612 | |
| 2613 | for (;;) { |
| 2614 | int ret, eos; |
| 2615 | if (sl->mb_x + sl->mb_y * h->mb_width >= sl->next_slice_idx) { |
| 2616 | av_log(h->avctx, AV_LOG_ERROR, "Slice overlaps with next at %d\n", |
| 2617 | sl->next_slice_idx); |
| 2618 | er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x, |
| 2619 | sl->mb_y, ER_MB_ERROR); |
| 2620 | return AVERROR_INVALIDDATA; |
| 2621 | } |
| 2622 |
no test coverage detected