#ifndef DAV1D_COMMON_DUMP_H
#define DAV1D_COMMON_DUMP_H
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include "common/bitdepth.h"
static inline void append_plane_to_file(const pixel *buf, ptrdiff_t stride,
int w, int h, const char *const file)
{
FILE *const f = fopen(file, "ab");
while (h--) {
fwrite(buf, w * sizeof(pixel), 1, f);
buf += PXSTRIDE(stride);
}
fclose(f);
}
static inline void hex_fdump(FILE *out, const pixel *buf, ptrdiff_t stride,
int w, int h, const char *what)
{
fprintf(out, "%s\n", what);
while (h--) {
int x;
for (x = 0; x < w; x++)
fprintf(out, " " PIX_HEX_FMT, buf[x]);
buf += PXSTRIDE(stride);
fprintf(out, "\n");
}
}
static inline void hex_dump(const pixel *buf, ptrdiff_t stride,
int w, int h, const char *what)
{
hex_fdump(stdout, buf, stride, w, h, what);
}
static inline void coef_dump(const coef *buf, const int w, const int h,
const int len, const char *what)
{
int y;
printf("%s\n", what);
for (y = 0; y < h; y++) {
int x;
for (x = 0; x < w; x++)
printf(" %*d", len, buf[x]);
buf += w;
printf("\n");
}
}
static inline void ac_dump(const int16_t *buf, int w, int h, const char *what)
{
printf("%s\n", what);
while (h--) {
for (int x = 0; x < w; x++)
printf(" %03d", buf[x]);
buf += w;
printf("\n");
}
}
#endif