mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-03 14:32:16 +02:00
4xm: refactor decode_p_block
Directly return from code 1, 2 and 6 codepaths and simplify the remaining one to have a single overflow check and a single call to mcdc.
This commit is contained in:
parent
94aefb1932
commit
fbd0dacc8d
@ -342,52 +342,26 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
|
|||||||
uint16_t *start = (uint16_t *)f->last_picture->data[0];
|
uint16_t *start = (uint16_t *)f->last_picture->data[0];
|
||||||
uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w);
|
uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w);
|
||||||
int ret;
|
int ret;
|
||||||
|
int scale = 1;
|
||||||
|
unsigned dc = 0;
|
||||||
|
|
||||||
if (code < 0 || code > 6 || log2w < 0)
|
if (code < 0 || code > 6 || log2w < 0)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 1) {
|
||||||
src += f->mv[bytestream2_get_byte(&f->g)];
|
|
||||||
if (start > src || src > end) {
|
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
mcdc(dst, src, log2w, h, stride, 1, 0);
|
|
||||||
} else if (code == 1) {
|
|
||||||
log2h--;
|
log2h--;
|
||||||
if ((ret = decode_p_block(f, dst, src, log2w, log2h, stride)) < 0)
|
if ((ret = decode_p_block(f, dst, src, log2w, log2h, stride)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret = decode_p_block(f, dst + (stride << log2h),
|
return decode_p_block(f, dst + (stride << log2h),
|
||||||
src + (stride << log2h),
|
src + (stride << log2h),
|
||||||
log2w, log2h, stride)) < 0)
|
log2w, log2h, stride);
|
||||||
return ret;
|
|
||||||
} else if (code == 2) {
|
} else if (code == 2) {
|
||||||
log2w--;
|
log2w--;
|
||||||
if ((ret = decode_p_block(f, dst , src, log2w, log2h, stride)) < 0)
|
if ((ret = decode_p_block(f, dst , src, log2w, log2h, stride)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret = decode_p_block(f, dst + (1 << log2w),
|
return decode_p_block(f, dst + (1 << log2w),
|
||||||
src + (1 << log2w),
|
src + (1 << log2w),
|
||||||
log2w, log2h, stride)) < 0)
|
log2w, log2h, stride);
|
||||||
return ret;
|
|
||||||
} else if (code == 3 && f->version < 2) {
|
|
||||||
if (start > src || src > end) {
|
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
mcdc(dst, src, log2w, h, stride, 1, 0);
|
|
||||||
} else if (code == 4) {
|
|
||||||
src += f->mv[bytestream2_get_byte(&f->g)];
|
|
||||||
if (start > src || src > end) {
|
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
mcdc(dst, src, log2w, h, stride, 1, bytestream2_get_le16(&f->g2));
|
|
||||||
} else if (code == 5) {
|
|
||||||
if (start > src || src > end) {
|
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
mcdc(dst, src, log2w, h, stride, 0, bytestream2_get_le16(&f->g2));
|
|
||||||
} else if (code == 6) {
|
} else if (code == 6) {
|
||||||
if (log2w) {
|
if (log2w) {
|
||||||
dst[0] = bytestream2_get_le16(&f->g2);
|
dst[0] = bytestream2_get_le16(&f->g2);
|
||||||
@ -396,7 +370,28 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
|
|||||||
dst[0] = bytestream2_get_le16(&f->g2);
|
dst[0] = bytestream2_get_le16(&f->g2);
|
||||||
dst[stride] = bytestream2_get_le16(&f->g2);
|
dst[stride] = bytestream2_get_le16(&f->g2);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code == 0) {
|
||||||
|
src += f->mv[bytestream2_get_byte(&f->g)];
|
||||||
|
} else if (code == 3 && f->version >= 2) {
|
||||||
|
return 0;
|
||||||
|
} else if (code == 4) {
|
||||||
|
src += f->mv[bytestream2_get_byte(&f->g)];
|
||||||
|
dc = bytestream2_get_le16(&f->g2);
|
||||||
|
} else if (code == 5) {
|
||||||
|
scale = 0;
|
||||||
|
dc = bytestream2_get_le16(&f->g2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start > src || src > end) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcdc(dst, src, log2w, h, stride, scale, dc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user