Dirac: Removed goto + some code make up
(cherry picked from commit 8db434f8a6d210f7fd2f28ba325927d7a5dd04b9) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
4bb2b5afc9
commit
aae7a5e36d
@ -350,7 +350,7 @@ static int alloc_sequence_buffers(DiracContext *s)
|
||||
s->edge_emu_buffer_base = av_malloc((w+64)*MAX_BLOCKSIZE);
|
||||
|
||||
s->mctmp = av_malloc((w+64+MAX_BLOCKSIZE) * (h*MAX_BLOCKSIZE) * sizeof(*s->mctmp));
|
||||
s->mcscratch= av_malloc((w+64)*MAX_BLOCKSIZE);
|
||||
s->mcscratch = av_malloc((w+64)*MAX_BLOCKSIZE);
|
||||
|
||||
if (!s->sbsplit || !s->blmotion)
|
||||
return AVERROR(ENOMEM);
|
||||
@ -446,7 +446,7 @@ static inline void coeff_unpack_arith(DiracArith *c, int qfactor, int qoffset,
|
||||
|
||||
coeff = dirac_get_arith_uint(c, pred_ctx, CTX_COEFF_DATA);
|
||||
if (coeff) {
|
||||
coeff = (coeff*qfactor + qoffset + 2)>>2;
|
||||
coeff = (coeff * qfactor + qoffset + 2) >> 2;
|
||||
sign = dirac_get_arith_bit(c, SIGN_CTX(sign_pred));
|
||||
coeff = (coeff ^ -sign) + sign;
|
||||
}
|
||||
@ -459,7 +459,7 @@ static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffse
|
||||
|
||||
coeff = svq3_get_ue_golomb(gb);
|
||||
if (coeff) {
|
||||
coeff = (coeff*qfactor + qoffset + 2)>>2;
|
||||
coeff = (coeff * qfactor + qoffset + 2) >> 2;
|
||||
sign = get_bits1(gb);
|
||||
coeff = (coeff ^ -sign) + sign;
|
||||
}
|
||||
@ -506,7 +506,7 @@ static inline void codeblock(DiracContext *s, SubBand *b,
|
||||
else
|
||||
qoffset = qoffset_inter_tab[b->quant];
|
||||
|
||||
buf = b->ibuf + top*b->stride;
|
||||
buf = b->ibuf + top * b->stride;
|
||||
for (y = top; y < bottom; y++) {
|
||||
for (x = left; x < right; x++) {
|
||||
/* [DIRAC_STD] 13.4.4 Subband coefficients. coeff_unpack() */
|
||||
@ -547,8 +547,7 @@ static inline void intra_dc_prediction(SubBand *b)
|
||||
* Dirac Specification ->
|
||||
* 13.4.2 Non-skipped subbands. subband_coeffs()
|
||||
*/
|
||||
static av_always_inline
|
||||
void decode_subband_internal(DiracContext *s, SubBand *b, int is_arith)
|
||||
static av_always_inline void decode_subband_internal(DiracContext *s, SubBand *b, int is_arith)
|
||||
{
|
||||
int cb_x, cb_y, left, right, top, bottom;
|
||||
DiracArith c;
|
||||
@ -642,14 +641,14 @@ static void lowdelay_subband(DiracContext *s, GetBitContext *gb, int quant,
|
||||
{
|
||||
int left = b1->width * slice_x / s->lowdelay.num_x;
|
||||
int right = b1->width *(slice_x+1) / s->lowdelay.num_x;
|
||||
int top = b1->height* slice_y / s->lowdelay.num_y;
|
||||
int bottom = b1->height*(slice_y+1) / s->lowdelay.num_y;
|
||||
int top = b1->height * slice_y / s->lowdelay.num_y;
|
||||
int bottom = b1->height *(slice_y+1) / s->lowdelay.num_y;
|
||||
|
||||
int qfactor = qscale_tab[FFMIN(quant, MAX_QUANT)];
|
||||
int qoffset = qoffset_intra_tab[FFMIN(quant, MAX_QUANT)];
|
||||
|
||||
IDWTELEM *buf1 = b1->ibuf + top*b1->stride;
|
||||
IDWTELEM *buf2 = b2 ? b2->ibuf + top*b2->stride : NULL;
|
||||
IDWTELEM *buf1 = b1->ibuf + top * b1->stride;
|
||||
IDWTELEM *buf2 = b2 ? b2->ibuf + top * b2->stride : NULL;
|
||||
int x, y;
|
||||
/* we have to constantly check for overread since the spec explictly
|
||||
requires this, with the meaning that all remaining coeffs are set to 0 */
|
||||
@ -694,7 +693,7 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
|
||||
int level, quant, chroma_bits, chroma_end;
|
||||
|
||||
int quant_base = get_bits(gb, 7); /*[DIRAC_STD] qindex */
|
||||
int length_bits = av_log2(8*slice->bytes)+1;
|
||||
int length_bits = av_log2(8 * slice->bytes)+1;
|
||||
int luma_bits = get_bits_long(gb, length_bits);
|
||||
int luma_end = get_bits_count(gb) + FFMIN(luma_bits, get_bits_left(gb));
|
||||
|
||||
@ -742,8 +741,8 @@ static void decode_lowdelay(DiracContext *s)
|
||||
buf = s->gb.buffer + get_bits_count(&s->gb)/8;
|
||||
bufsize = get_bits_left(&s->gb);
|
||||
|
||||
for (slice_y = 0; slice_y < s->lowdelay.num_y; slice_y++)
|
||||
for (slice_x = 0; slice_x < s->lowdelay.num_x; slice_x++) {
|
||||
for (slice_y = 0; bufsize > 0 && slice_y < s->lowdelay.num_y; slice_y++)
|
||||
for (slice_x = 0; bufsize > 0 && slice_x < s->lowdelay.num_x; slice_x++) {
|
||||
bytes = (slice_num+1) * s->lowdelay.bytes.num / s->lowdelay.bytes.den
|
||||
- slice_num * s->lowdelay.bytes.num / s->lowdelay.bytes.den;
|
||||
|
||||
@ -755,10 +754,7 @@ static void decode_lowdelay(DiracContext *s)
|
||||
|
||||
buf += bytes;
|
||||
bufsize -= bytes*8;
|
||||
if (bufsize <= 0)
|
||||
goto end;
|
||||
}
|
||||
end:
|
||||
|
||||
avctx->execute(avctx, decode_lowdelay_slice, slices, NULL, slice_num,
|
||||
sizeof(struct lowdelay_slice)); /* [DIRAC_STD] 13.5.2 Slices */
|
||||
@ -1112,8 +1108,8 @@ static void global_mv(DiracContext *s, DiracBlock *block, int x, int y, int ref)
|
||||
int *c = s->globalmc[ref].perspective;
|
||||
|
||||
int m = (1<<ep) - (c[0]*x + c[1]*y);
|
||||
int mx = m*((A[0][0]*x + A[0][1]*y) + (1<<ez)*b[0]);
|
||||
int my = m*((A[1][0]*x + A[1][1]*y) + (1<<ez)*b[1]);
|
||||
int mx = m * ((A[0][0] * x + A[0][1]*y) + (1<<ez) * b[0]);
|
||||
int my = m * ((A[1][0] * x + A[1][1]*y) + (1<<ez) * b[1]);
|
||||
|
||||
block->u.mv[ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep);
|
||||
block->u.mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep);
|
||||
@ -1150,8 +1146,8 @@ static void decode_block_params(DiracContext *s, DiracArith arith[8], DiracBlock
|
||||
global_mv(s, block, x, y, i);
|
||||
} else {
|
||||
pred_mv(block, stride, x, y, i);
|
||||
block->u.mv[i][0] += dirac_get_arith_int(arith+4+2*i, CTX_MV_F1, CTX_MV_DATA);
|
||||
block->u.mv[i][1] += dirac_get_arith_int(arith+5+2*i, CTX_MV_F1, CTX_MV_DATA);
|
||||
block->u.mv[i][0] += dirac_get_arith_int(arith + 4 + 2 * i, CTX_MV_F1, CTX_MV_DATA);
|
||||
block->u.mv[i][1] += dirac_get_arith_int(arith + 5 + 2 * i, CTX_MV_F1, CTX_MV_DATA);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1190,8 +1186,8 @@ static void dirac_unpack_block_motion_data(DiracContext *s)
|
||||
/* [DIRAC_STD] 11.2.4 and 12.2.1 Number of blocks and superblocks */
|
||||
s->sbwidth = DIVRNDUP(s->source.width, 4*s->plane[0].xbsep);
|
||||
s->sbheight = DIVRNDUP(s->source.height, 4*s->plane[0].ybsep);
|
||||
s->blwidth = 4*s->sbwidth;
|
||||
s->blheight = 4*s->sbheight;
|
||||
s->blwidth = 4 * s->sbwidth;
|
||||
s->blheight = 4 * s->sbheight;
|
||||
|
||||
/* [DIRAC_STD] 12.3.1 Superblock splitting modes. superblock_split_modes()
|
||||
decode superblock split modes */
|
||||
@ -1207,21 +1203,21 @@ static void dirac_unpack_block_motion_data(DiracContext *s)
|
||||
/* setup arith decoding */
|
||||
ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb));
|
||||
for (i = 0; i < s->num_refs; i++) {
|
||||
ff_dirac_init_arith_decoder(arith+4+2*i, gb, svq3_get_ue_golomb(gb));
|
||||
ff_dirac_init_arith_decoder(arith+5+2*i, gb, svq3_get_ue_golomb(gb));
|
||||
ff_dirac_init_arith_decoder(arith + 4 + 2 * i, gb, svq3_get_ue_golomb(gb));
|
||||
ff_dirac_init_arith_decoder(arith + 5 + 2 * i, gb, svq3_get_ue_golomb(gb));
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
ff_dirac_init_arith_decoder(arith+1+i, gb, svq3_get_ue_golomb(gb));
|
||||
|
||||
for (y = 0; y < s->sbheight; y++)
|
||||
for (x = 0; x < s->sbwidth; x++) {
|
||||
int blkcnt = 1 << s->sbsplit[y*s->sbwidth + x];
|
||||
int step = 4 >> s->sbsplit[y*s->sbwidth + x];
|
||||
int blkcnt = 1 << s->sbsplit[y * s->sbwidth + x];
|
||||
int step = 4 >> s->sbsplit[y * s->sbwidth + x];
|
||||
|
||||
for (q = 0; q < blkcnt; q++)
|
||||
for (p = 0; p < blkcnt; p++) {
|
||||
int bx = 4*x + p*step;
|
||||
int by = 4*y + q*step;
|
||||
int bx = 4 * x + p*step;
|
||||
int by = 4 * y + q*step;
|
||||
DiracBlock *block = &s->blmotion[by*s->blwidth + bx];
|
||||
decode_block_params(s, arith, block, s->blwidth, bx, by);
|
||||
propagate_block_data(block, s->blwidth, step);
|
||||
@ -1334,8 +1330,8 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
|
||||
motion_y >>= s->mv_precision;
|
||||
/* normalize subpel coordinates to epel */
|
||||
/* TODO: template this function? */
|
||||
mx <<= 3-s->mv_precision;
|
||||
my <<= 3-s->mv_precision;
|
||||
mx <<= 3 - s->mv_precision;
|
||||
my <<= 3 - s->mv_precision;
|
||||
|
||||
x += motion_x;
|
||||
y += motion_y;
|
||||
@ -1581,7 +1577,8 @@ static int dirac_decode_frame_internal(DiracContext *s)
|
||||
|
||||
dsty = -p->yoffset;
|
||||
for (y = 0; y < s->blheight; y++) {
|
||||
int h = 0, start = FFMAX(dsty, 0);
|
||||
int h = 0,
|
||||
start = FFMAX(dsty, 0);
|
||||
uint16_t *mctmp = s->mctmp + y*rowheight;
|
||||
DiracBlock *blocks = s->blmotion + y*s->blwidth;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user