Merge "Removing out_put() function from vpxdec.c."
This commit is contained in:
commit
6f8b3039af
101
vpxdec.c
101
vpxdec.c
@ -248,11 +248,51 @@ void *out_open(const char *out_fn, int do_md5) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void out_put(void *out, const uint8_t *buf, unsigned int len, int do_md5) {
|
static int get_image_plane_width(int plane, const vpx_image_t *img) {
|
||||||
if (do_md5) {
|
return (plane > 0 && img->x_chroma_shift > 0) ?
|
||||||
MD5Update(out, buf, len);
|
(img->d_w + 1) >> img->x_chroma_shift :
|
||||||
} else {
|
img->d_w;
|
||||||
(void) fwrite(buf, 1, len, out);
|
}
|
||||||
|
|
||||||
|
static int get_image_plane_height(int plane, const vpx_image_t *img) {
|
||||||
|
return (plane > 0 && img->y_chroma_shift > 0) ?
|
||||||
|
(img->d_h + 1) >> img->y_chroma_shift :
|
||||||
|
img->d_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void update_image_md5(const vpx_image_t *img, const int planes[3],
|
||||||
|
MD5Context *md5) {
|
||||||
|
int i, y;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; ++i) {
|
||||||
|
const int plane = planes[i];
|
||||||
|
const unsigned char *buf = img->planes[plane];
|
||||||
|
const int stride = img->stride[plane];
|
||||||
|
const int w = get_image_plane_width(plane, img);
|
||||||
|
const int h = get_image_plane_height(plane, img);
|
||||||
|
|
||||||
|
for (y = 0; y < h; ++y) {
|
||||||
|
MD5Update(md5, buf, w);
|
||||||
|
buf += stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_image_file(const vpx_image_t *img, const int planes[3],
|
||||||
|
FILE *file) {
|
||||||
|
int i, y;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; ++i) {
|
||||||
|
const int plane = planes[i];
|
||||||
|
const unsigned char *buf = img->planes[plane];
|
||||||
|
const int stride = img->stride[plane];
|
||||||
|
const int w = get_image_plane_width(plane, img);
|
||||||
|
const int h = get_image_plane_height(plane, img);
|
||||||
|
|
||||||
|
for (y = 0; y < h; ++y) {
|
||||||
|
fwrite(buf, 1, w, file);
|
||||||
|
buf += stride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +453,6 @@ void generate_filename(const char *pattern, char *out, size_t q_len,
|
|||||||
} while (*p);
|
} while (*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main_loop(int argc, const char **argv_) {
|
int main_loop(int argc, const char **argv_) {
|
||||||
vpx_codec_ctx_t decoder;
|
vpx_codec_ctx_t decoder;
|
||||||
char *fn = NULL;
|
char *fn = NULL;
|
||||||
@ -663,8 +702,7 @@ int main_loop(int argc, const char **argv_) {
|
|||||||
vpx_input_ctx.framerate.numerator,
|
vpx_input_ctx.framerate.numerator,
|
||||||
vpx_input_ctx.framerate.denominator,
|
vpx_input_ctx.framerate.denominator,
|
||||||
'p');
|
'p');
|
||||||
out_put(out, (unsigned char *)buffer,
|
fwrite(buffer, 1, strlen(buffer), out);
|
||||||
(unsigned int)strlen(buffer), do_md5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to determine the codec from the fourcc. */
|
/* Try to determine the codec from the fourcc. */
|
||||||
@ -819,7 +857,7 @@ int main_loop(int argc, const char **argv_) {
|
|||||||
img->fmt == VPX_IMG_FMT_I422 ? "C422\n" :
|
img->fmt == VPX_IMG_FMT_I422 ? "C422\n" :
|
||||||
"C420jpeg\n";
|
"C420jpeg\n";
|
||||||
|
|
||||||
out_put(out, (const unsigned char*)color, strlen(color), do_md5);
|
fwrite(color, 1, strlen(color), out);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img && do_scale) {
|
if (img && do_scale) {
|
||||||
@ -864,46 +902,25 @@ int main_loop(int argc, const char **argv_) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (img) {
|
if (img) {
|
||||||
unsigned int y;
|
const int PLANES_YUV[] = {VPX_PLANE_Y, VPX_PLANE_U, VPX_PLANE_V};
|
||||||
|
const int PLANES_YVU[] = {VPX_PLANE_Y, VPX_PLANE_V, VPX_PLANE_U};
|
||||||
|
|
||||||
|
const int *planes = flipuv ? PLANES_YVU : PLANES_YUV;
|
||||||
char out_fn[PATH_MAX];
|
char out_fn[PATH_MAX];
|
||||||
uint8_t *buf;
|
|
||||||
unsigned int c_w =
|
|
||||||
img->x_chroma_shift ? (1 + img->d_w) >> img->x_chroma_shift
|
|
||||||
: img->d_w;
|
|
||||||
unsigned int c_h =
|
|
||||||
img->y_chroma_shift ? (1 + img->d_h) >> img->y_chroma_shift
|
|
||||||
: img->d_h;
|
|
||||||
|
|
||||||
if (!single_file) {
|
if (!single_file) {
|
||||||
size_t len = sizeof(out_fn) - 1;
|
generate_filename(outfile_pattern, out_fn, PATH_MAX,
|
||||||
|
|
||||||
out_fn[len] = '\0';
|
|
||||||
generate_filename(outfile_pattern, out_fn, len - 1,
|
|
||||||
img->d_w, img->d_h, frame_in);
|
img->d_w, img->d_h, frame_in);
|
||||||
out = out_open(out_fn, do_md5);
|
out = out_open(out_fn, do_md5);
|
||||||
} else if (use_y4m)
|
} else {
|
||||||
out_put(out, (unsigned char *)"FRAME\n", 6, do_md5);
|
if (use_y4m)
|
||||||
|
fwrite("FRAME\n", 1, 6, out);
|
||||||
buf = img->planes[VPX_PLANE_Y];
|
|
||||||
|
|
||||||
for (y = 0; y < img->d_h; y++) {
|
|
||||||
out_put(out, buf, img->d_w, do_md5);
|
|
||||||
buf += img->stride[VPX_PLANE_Y];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = img->planes[flipuv ? VPX_PLANE_V : VPX_PLANE_U];
|
if (do_md5)
|
||||||
|
update_image_md5(img, planes, out);
|
||||||
for (y = 0; y < c_h; y++) {
|
else
|
||||||
out_put(out, buf, c_w, do_md5);
|
write_image_file(img, planes, out);
|
||||||
buf += img->stride[VPX_PLANE_U];
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = img->planes[flipuv ? VPX_PLANE_U : VPX_PLANE_V];
|
|
||||||
|
|
||||||
for (y = 0; y < c_h; y++) {
|
|
||||||
out_put(out, buf, c_w, do_md5);
|
|
||||||
buf += img->stride[VPX_PLANE_V];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!single_file)
|
if (!single_file)
|
||||||
out_close(out, out_fn, do_md5);
|
out_close(out, out_fn, do_md5);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user