|
|
|
@ -132,99 +132,6 @@ void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the top & left blocks are available if needed and |
|
|
|
|
* change the dc mode so it only uses the available blocks. |
|
|
|
|
*/ |
|
|
|
|
int ff_h264_check_intra4x4_pred_mode(const H264Context *h, H264SliceContext *sl) |
|
|
|
|
{ |
|
|
|
|
static const int8_t top[12] = { |
|
|
|
|
-1, 0, LEFT_DC_PRED, -1, -1, -1, -1, -1, 0 |
|
|
|
|
}; |
|
|
|
|
static const int8_t left[12] = { |
|
|
|
|
0, -1, TOP_DC_PRED, 0, -1, -1, -1, 0, -1, DC_128_PRED |
|
|
|
|
}; |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
if (!(sl->top_samples_available & 0x8000)) { |
|
|
|
|
for (i = 0; i < 4; i++) { |
|
|
|
|
int status = top[sl->intra4x4_pred_mode_cache[scan8[0] + i]]; |
|
|
|
|
if (status < 0) { |
|
|
|
|
av_log(h->avctx, AV_LOG_ERROR, |
|
|
|
|
"top block unavailable for requested intra4x4 mode %d at %d %d\n", |
|
|
|
|
status, sl->mb_x, sl->mb_y); |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
} else if (status) { |
|
|
|
|
sl->intra4x4_pred_mode_cache[scan8[0] + i] = status; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((sl->left_samples_available & 0x8888) != 0x8888) { |
|
|
|
|
static const int mask[4] = { 0x8000, 0x2000, 0x80, 0x20 }; |
|
|
|
|
for (i = 0; i < 4; i++) |
|
|
|
|
if (!(sl->left_samples_available & mask[i])) { |
|
|
|
|
int status = left[sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i]]; |
|
|
|
|
if (status < 0) { |
|
|
|
|
av_log(h->avctx, AV_LOG_ERROR, |
|
|
|
|
"left block unavailable for requested intra4x4 mode %d at %d %d\n", |
|
|
|
|
status, sl->mb_x, sl->mb_y); |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
} else if (status) { |
|
|
|
|
sl->intra4x4_pred_mode_cache[scan8[0] + 8 * i] = status; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} // FIXME cleanup like ff_h264_check_intra_pred_mode
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the top & left blocks are available if needed and |
|
|
|
|
* change the dc mode so it only uses the available blocks. |
|
|
|
|
*/ |
|
|
|
|
int ff_h264_check_intra_pred_mode(const H264Context *h, H264SliceContext *sl, |
|
|
|
|
int mode, int is_chroma) |
|
|
|
|
{ |
|
|
|
|
static const int8_t top[4] = { LEFT_DC_PRED8x8, 1, -1, -1 }; |
|
|
|
|
static const int8_t left[5] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 }; |
|
|
|
|
|
|
|
|
|
if (mode > 3U) { |
|
|
|
|
av_log(h->avctx, AV_LOG_ERROR, |
|
|
|
|
"out of range intra chroma pred mode at %d %d\n", |
|
|
|
|
sl->mb_x, sl->mb_y); |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(sl->top_samples_available & 0x8000)) { |
|
|
|
|
mode = top[mode]; |
|
|
|
|
if (mode < 0) { |
|
|
|
|
av_log(h->avctx, AV_LOG_ERROR, |
|
|
|
|
"top block unavailable for requested intra mode at %d %d\n", |
|
|
|
|
sl->mb_x, sl->mb_y); |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((sl->left_samples_available & 0x8080) != 0x8080) { |
|
|
|
|
mode = left[mode]; |
|
|
|
|
if (mode < 0) { |
|
|
|
|
av_log(h->avctx, AV_LOG_ERROR, |
|
|
|
|
"left block unavailable for requested intra mode at %d %d\n", |
|
|
|
|
sl->mb_x, sl->mb_y); |
|
|
|
|
return AVERROR_INVALIDDATA; |
|
|
|
|
} |
|
|
|
|
if (is_chroma && (sl->left_samples_available & 0x8080)) { |
|
|
|
|
// mad cow disease mode, aka MBAFF + constrained_intra_pred
|
|
|
|
|
mode = ALZHEIMER_DC_L0T_PRED8x8 + |
|
|
|
|
(!(sl->left_samples_available & 0x8000)) + |
|
|
|
|
2 * (mode == DC_128_PRED8x8); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return mode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const uint8_t *ff_h264_decode_nal(H264Context *h, H264SliceContext *sl, |
|
|
|
|
const uint8_t *src, |
|
|
|
|
int *dst_length, int *consumed, int length) |
|
|
|
|