/* make a new row by copying the key fields from r */ Row RowGetKey(Row *r) { Row row = {0,0,0}; size_t nb = key_length(r); size_t n = g_row_key_n; char *d = pg_malloc(nb); size_t i = 0; char *out_iter = d; row.ptr = d; row.fields = pg_malloc(n * sizeof(Field)); row.n = n; TermAssert(RowSize(r) > g_row_key_n); for (i = 0; i < n; ++i) { size_t col = g_row_key[i]; char *tok = out_iter; memcpy(out_iter, r->fields[col].data, r->fields[col].n); out_iter += r->fields[col].n; *out_iter++ = '\0'; row.fields[i].data = tok; row.fields[i].n = r->fields[col].n; } return row; }
void Deinterlacer::PropagatePassToDownscaler(Downscaler& aDownscaler) { for (int32_t row = 0 ; row < mImageSize.height ; ++row) { memcpy(aDownscaler.RowBuffer(), RowBuffer(row), RowSize()); aDownscaler.CommitRow(); } }
uint8_t* Deinterlacer::RowBuffer(uint32_t aRow) { uint32_t offset = aRow * RowSize(); MOZ_ASSERT(offset < mImageSize.width * mImageSize.height * sizeof(uint32_t), "Row is outside of image"); return mBuffer.get() + offset; }
void Deinterlacer::PropagatePassToDownscaler(Downscaler& aDownscaler) { MOZ_ASSERT(IsValid(), "Deinterlacer in invalid state"); for (int32_t row = 0 ; row < mImageSize.height ; ++row) { memcpy(aDownscaler.RowBuffer(), RowBuffer(row), RowSize()); aDownscaler.CommitRow(); } }
/* debugging funcs */ void RowDump(Row *row) { size_t i = 0; for (i = 0; i < RowSize(row); ++i) printf("%.*s ", (int) RowFieldLength(row, i), RowFieldValue(row, i)); printf("\n"); }
void RowDumpToString(Row *row, PQExpBuffer buf) { size_t i = 0; for (i = 0; i < RowSize(row); ++i) { Field *f = RowGetField(row, i); appendBinaryPQExpBuffer(buf, f->data, f->n); appendPQExpBuffer(buf, " "); } }
static int row_cmp_row_key(Row *r1, Row *r2) { size_t i = 0; if (RowSize(r2) == 0) return 1; TermAssert(RowSize(r2) == g_row_key_n); for (i = 0; i < g_row_key_n; ++i) { size_t col = g_row_key[i]; int c = field_cmp(RowGetField(r1, col), RowGetField(r2, i)); if (c != 0) return c; } return 0; }
/* * Render a row, taking column, x_pos and padding into account. * * Note - render in this context means send the data to ncurses, the tty * won't be updated until refresh() is called */ static inline void render_row(Screen *s, Row *row, char sep) { size_t i = 0; for (i = s->x_col; i < RowSize(row); ++i) { size_t padlen = maxlen(s, i); char *fv = RowFieldValue(row, i); size_t fn = RowFieldLength(row, i); if (i == s->x_col) { if (s->x_pos < fn) { printw("%s", fv + s->x_pos); printwpad(padlen - fn); } else { printwpad(padlen - s->x_pos); } } else { printw("%s", fv); printwpad(padlen - fn); } if (i != (RowSize(row) - 1)) printw("%c", sep); } clrtoeol(); printw("\n"); }
void Transpose_CosPmlTableGen(int bw, int m, double *cos_pml_table, double *result) { /* recall that cospml_table has had all the zeroes stripped out, and that if m is odd, then it is really a Gml function, which affects indexing a bit. */ double *trans_tableptr, *tableptr; int i, row, rowsize, stride, offset, costable_offset; /* note that the number of non-zero entries is the same as in the non-transposed case */ trans_tableptr = result; /* now traverse the cos_pml_table , loading appropriate values into the rows of transposed array */ if ( m == bw - 1 ) memcpy( result, cos_pml_table, sizeof(double)*TableSize(m,bw)); else { for (row = 0; row < bw; row++) { /* if m odd, no need to do last row - all zeroes */ if (row == (bw-1)) { if ( m % 2 ) return; } /* get the rowsize for the transposed array */ rowsize = Transpose_RowSize(row, m, bw); /* compute the starting point for values in cos_pml_table */ if (row <= m) { if ((row % 2) == 0) tableptr = cos_pml_table + (row/2); else tableptr = cos_pml_table + (m/2) + 1 + (row/2); } else { /* if row > m, then the highest degree coefficient of P(m,row) should be the first coefficient loaded into the transposed array, so figure out where this point is. */ offset = 0; if ( (m%2) == 0 ) { for (i=m; i<=row; i++) offset += RowSize(m, i); } else { for (i=m;i<=row+1;i++) offset += RowSize(m, i); } /* now we are pointing one element too far, so decrement */ offset--; tableptr = cos_pml_table + offset; } /* stride is how far we need to jump between values in cos_pml_table, i.e., to traverse the columns of the cos_pml_table. Need to set initial value. Stride always increases by 2 after that */ if (row <= m) stride = m + 2 - (m % 2) + (row % 2); else stride = row + 2; /* now load up this row of the transposed table */ costable_offset = 0; for (i=0; i < rowsize; i++) { trans_tableptr[i] = tableptr[costable_offset]; costable_offset += stride; stride += 2; } /* closes i loop */ trans_tableptr += rowsize; } /* closes row loop */ } }