cavs: K&R formatting cosmetics

This commit is contained in:
Luca Barbato 2013-10-13 03:08:51 +02:00
parent 71549a857b
commit 14ddbb477f

View File

@ -376,10 +376,11 @@ void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv)
*
****************************************************************************/
static inline void mc_dir_part(AVSContext *h, AVFrame *pic,
int chroma_height,int delta,int list,uint8_t *dest_y,
uint8_t *dest_cb,uint8_t *dest_cr,int src_x_offset,
int src_y_offset,qpel_mc_func *qpix_op,
static inline void mc_dir_part(AVSContext *h, AVFrame *pic, int chroma_height,
int delta, int list, uint8_t *dest_y,
uint8_t *dest_cb, uint8_t *dest_cr,
int src_x_offset, int src_y_offset,
qpel_mc_func *qpix_op,
h264_chroma_mc_func chroma_op, cavs_vector *mv)
{
const int mx = mv->x + src_x_offset*8;
@ -390,49 +391,66 @@ static inline void mc_dir_part(AVSContext *h, AVFrame *pic,
uint8_t *src_cr = pic->data[2] + (mx >> 3) + (my >> 3) * h->c_stride;
int extra_width = 0;
int extra_height = extra_width;
int emu=0;
const int full_mx = mx >> 2;
const int full_my = my >> 2;
const int pic_width = 16 * h->mb_width;
const int pic_height = 16 * h->mb_height;
int emu = 0;
if (!pic->data[0])
return;
if(mx&7) extra_width -= 3;
if(my&7) extra_height -= 3;
if (mx & 7)
extra_width -= 3;
if (my & 7)
extra_height -= 3;
if( full_mx < 0-extra_width
|| full_my < 0-extra_height
|| full_mx + 16/*FIXME*/ > pic_width + extra_width
|| full_my + 16/*FIXME*/ > pic_height + extra_height){
h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_y - 2 - 2*h->l_stride, h->l_stride,
16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height);
if (full_mx < 0 - extra_width ||
full_my < 0 - extra_height ||
full_mx + 16 /* FIXME */ > pic_width + extra_width ||
full_my + 16 /* FIXME */ > pic_height + extra_height) {
h->vdsp.emulated_edge_mc(h->edge_emu_buffer,
src_y - 2 - 2 * h->l_stride, h->l_stride,
16 + 5, 16 + 5 /* FIXME */,
full_mx - 2, full_my - 2,
pic_width, pic_height);
src_y = h->edge_emu_buffer + 2 + 2 * h->l_stride;
emu = 1;
}
qpix_op[luma_xy](dest_y, src_y, h->l_stride); //FIXME try variable height perhaps?
// FIXME try variable height perhaps?
qpix_op[luma_xy](dest_y, src_y, h->l_stride);
if (emu) {
h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cb, h->c_stride,
9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cb,
h->c_stride,
9, 9 /* FIXME */,
mx >> 3, my >> 3,
pic_width >> 1, pic_height >> 1);
src_cb = h->edge_emu_buffer;
}
chroma_op(dest_cb, src_cb, h->c_stride, chroma_height, mx & 7, my & 7);
if (emu) {
h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cr, h->c_stride,
9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cr,
h->c_stride,
9, 9 /* FIXME */,
mx >> 3, my >> 3,
pic_width >> 1, pic_height >> 1);
src_cr = h->edge_emu_buffer;
}
chroma_op(dest_cr, src_cr, h->c_stride, chroma_height, mx & 7, my & 7);
}
static inline void mc_part_std(AVSContext *h, int chroma_height, int delta,
uint8_t *dest_y,uint8_t *dest_cb,uint8_t *dest_cr,
int x_offset, int y_offset,qpel_mc_func *qpix_put,
h264_chroma_mc_func chroma_put,qpel_mc_func *qpix_avg,
h264_chroma_mc_func chroma_avg, cavs_vector *mv)
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int x_offset, int y_offset,
qpel_mc_func *qpix_put,
h264_chroma_mc_func chroma_put,
qpel_mc_func *qpix_avg,
h264_chroma_mc_func chroma_avg,
cavs_vector *mv)
{
qpel_mc_func *qpix_op = qpix_put;
h264_chroma_mc_func chroma_op = chroma_put;
@ -461,7 +479,8 @@ static inline void mc_part_std(AVSContext *h,int chroma_height,int delta,
}
}
void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type) {
void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type)
{
if (ff_cavs_partition_flags[mb_type] == 0) { // 16x16
mc_part_std(h, 8, 0, h->cy, h->cu, h->cv, 0, 0,
h->cdsp.put_cavs_qpel_pixels_tab[0],
@ -503,15 +522,21 @@ void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type) {
*
****************************************************************************/
static inline void scale_mv(AVSContext *h, int *d_x, int *d_y, cavs_vector *src, int distp) {
static inline void scale_mv(AVSContext *h, int *d_x, int *d_y,
cavs_vector *src, int distp)
{
int den = h->scale_den[src->ref];
*d_x = (src->x * distp * den + 256 + (src->x >> 31)) >> 9;
*d_y = (src->y * distp * den + 256 + (src->y >> 31)) >> 9;
}
static inline void mv_pred_median(AVSContext *h, cavs_vector *mvP,
cavs_vector *mvA, cavs_vector *mvB, cavs_vector *mvC) {
static inline void mv_pred_median(AVSContext *h,
cavs_vector *mvP,
cavs_vector *mvA,
cavs_vector *mvB,
cavs_vector *mvC)
{
int ax, ay, bx, by, cx, cy;
int len_ab, len_bc, len_ca, len_mid;
@ -537,7 +562,8 @@ static inline void mv_pred_median(AVSContext *h, cavs_vector *mvP,
}
void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC,
enum cavs_mv_pred mode, enum cavs_block size, int ref) {
enum cavs_mv_pred mode, enum cavs_block size, int ref)
{
cavs_vector *mvP = &h->mv[nP];
cavs_vector *mvA = &h->mv[nP-1];
cavs_vector *mvB = &h->mv[nP-4];
@ -548,17 +574,18 @@ void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC,
mvP->dist = h->dist[mvP->ref];
if (mvC->ref == NOT_AVAIL)
mvC = &h->mv[nP-5]; // set to top-left (mvD)
if((mode == MV_PRED_PSKIP) &&
((mvA->ref == NOT_AVAIL) || (mvB->ref == NOT_AVAIL) ||
((mvA->x | mvA->y | mvA->ref) == 0) ||
((mvB->x | mvB->y | mvB->ref) == 0) )) {
if (mode == MV_PRED_PSKIP &&
(mvA->ref == NOT_AVAIL ||
mvB->ref == NOT_AVAIL ||
(mvA->x | mvA->y | mvA->ref) == 0 ||
(mvB->x | mvB->y | mvB->ref) == 0)) {
mvP2 = &un_mv;
/* if there is only one suitable candidate, take it */
} else if((mvA->ref >= 0) && (mvB->ref < 0) && (mvC->ref < 0)) {
} else if (mvA->ref >= 0 && mvB->ref < 0 && mvC->ref < 0) {
mvP2 = mvA;
} else if((mvA->ref < 0) && (mvB->ref >= 0) && (mvC->ref < 0)) {
} else if (mvA->ref < 0 && mvB->ref >= 0 && mvC->ref < 0) {
mvP2 = mvB;
} else if((mvA->ref < 0) && (mvB->ref < 0) && (mvC->ref >= 0)) {
} else if (mvA->ref < 0 && mvB->ref < 0 && mvC->ref >= 0) {
mvP2 = mvC;
} else if (mode == MV_PRED_LEFT && mvA->ref == ref) {
mvP2 = mvA;
@ -589,7 +616,8 @@ void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC,
/**
* initialise predictors for motion vectors and intra prediction
*/
void ff_cavs_init_mb(AVSContext *h) {
void ff_cavs_init_mb(AVSContext *h)
{
int i;
/* copy predictors from top line (MB B and C) into cache */
@ -629,7 +657,8 @@ void ff_cavs_init_mb(AVSContext *h) {
* macroblock address
* @return 0 if end of frame is reached, 1 otherwise
*/
int ff_cavs_next_mb(AVSContext *h) {
int ff_cavs_next_mb(AVSContext *h)
{
int i;
h->flags |= A_AVAIL;
@ -647,7 +676,7 @@ int ff_cavs_next_mb(AVSContext *h) {
/* next MB address */
h->mbidx++;
h->mbx++;
if(h->mbx == h->mb_width) { //new mb line
if (h->mbx == h->mb_width) { // New mb line
h->flags = B_AVAIL | C_AVAIL;
/* clear left pred_modes */
h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
@ -660,7 +689,7 @@ int ff_cavs_next_mb(AVSContext *h) {
h->cy = h->cur.f->data[0] + h->mby * 16 * h->l_stride;
h->cu = h->cur.f->data[1] + h->mby * 8 * h->c_stride;
h->cv = h->cur.f->data[2] + h->mby * 8 * h->c_stride;
if(h->mby == h->mb_height) { //frame end
if (h->mby == h->mb_height) { // Frame end
return 0;
}
}
@ -673,7 +702,8 @@ int ff_cavs_next_mb(AVSContext *h) {
*
****************************************************************************/
void ff_cavs_init_pic(AVSContext *h) {
void ff_cavs_init_pic(AVSContext *h)
{
int i;
/* clear some predictors */
@ -706,7 +736,8 @@ void ff_cavs_init_pic(AVSContext *h) {
* this data has to be stored for one complete row of macroblocks
* and this storage space is allocated here
*/
void ff_cavs_init_top_lines(AVSContext *h) {
void ff_cavs_init_top_lines(AVSContext *h)
{
/* alloc top line of predictors */
h->top_qp = av_mallocz(h->mb_width);
h->top_mv[0] = av_mallocz((h->mb_width * 2 + 1) * sizeof(cavs_vector));
@ -717,12 +748,14 @@ void ff_cavs_init_top_lines(AVSContext *h) {
h->top_border_v = av_mallocz(h->mb_width * 10);
/* alloc space for co-located MVs and types */
h->col_mv = av_mallocz( h->mb_width*h->mb_height*4*sizeof(cavs_vector));
h->col_mv = av_mallocz(h->mb_width * h->mb_height * 4 *
sizeof(cavs_vector));
h->col_type_base = av_mallocz(h->mb_width * h->mb_height);
h->block = av_mallocz(64 * sizeof(int16_t));
}
av_cold int ff_cavs_init(AVCodecContext *avctx) {
av_cold int ff_cavs_init(AVCodecContext *avctx)
{
AVSContext *h = avctx->priv_data;
ff_dsputil_init(&h->dsp, avctx);
@ -766,7 +799,8 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) {
return 0;
}
av_cold int ff_cavs_end(AVCodecContext *avctx) {
av_cold int ff_cavs_end(AVCodecContext *avctx)
{
AVSContext *h = avctx->priv_data;
av_frame_free(&h->cur.f);