Merge "Moving y4m encoding functions into separate files."

This commit is contained in:
Dmitry Kovalev 2014-01-17 23:59:21 -08:00 коммит произвёл Gerrit Code Review
Родитель 5088631410 5ab63583db
Коммит 9c8b74f121
4 изменённых файлов: 64 добавлений и 23 удалений

Просмотреть файл

@ -26,6 +26,7 @@ vpxdec.SRCS += args.c args.h
vpxdec.SRCS += ivfdec.c ivfdec.h
vpxdec.SRCS += tools_common.c tools_common.h
vpxdec.SRCS += webmdec.c webmdec.h
vpxdec.SRCS += y4menc.c y4menc.h
vpxdec.SRCS += nestegg/halloc/halloc.h
vpxdec.SRCS += nestegg/halloc/src/align.h
vpxdec.SRCS += nestegg/halloc/src/halloc.c

Просмотреть файл

@ -33,6 +33,7 @@
#include "./tools_common.h"
#include "./webmdec.h"
#include "./y4menc.h"
static const char *exec_name;
@ -691,31 +692,19 @@ int main_loop(int argc, const char **argv_) {
}
if (use_y4m && !noblit) {
char buffer[128];
if (!single_file) {
fprintf(stderr, "YUV4MPEG2 not supported with output patterns,"
" try --i420 or --yv12.\n");
return EXIT_FAILURE;
}
if (vpx_input_ctx.file_type == FILE_TYPE_WEBM)
if (vpx_input_ctx.file_type == FILE_TYPE_WEBM) {
if (webm_guess_framerate(input.webm_ctx, input.vpx_input_ctx)) {
fprintf(stderr, "Failed to guess framerate -- error parsing "
"webm file?\n");
return EXIT_FAILURE;
}
/*Note: We can't output an aspect ratio here because IVF doesn't
store one, and neither does VP8.
That will have to wait until these tools support WebM natively.*/
snprintf(buffer, sizeof(buffer), "YUV4MPEG2 W%u H%u F%u:%u I%c ",
vpx_input_ctx.width, vpx_input_ctx.height,
vpx_input_ctx.framerate.numerator,
vpx_input_ctx.framerate.denominator,
'p');
fwrite(buffer, 1, strlen(buffer), out);
}
}
/* Try to determine the codec from the fourcc. */
@ -863,14 +852,8 @@ int main_loop(int argc, const char **argv_) {
if (!noblit) {
if (frame_out == 1 && img && use_y4m) {
/* Write out the color format to terminate the header line */
const char *color =
img->fmt == VPX_IMG_FMT_444A ? "C444alpha\n" :
img->fmt == VPX_IMG_FMT_I444 ? "C444\n" :
img->fmt == VPX_IMG_FMT_I422 ? "C422\n" :
"C420jpeg\n";
fwrite(color, 1, strlen(color), out);
y4m_write_file_header(out, vpx_input_ctx.width, vpx_input_ctx.height,
&vpx_input_ctx.framerate, img->fmt);
}
if (img && do_scale) {
@ -916,7 +899,7 @@ int main_loop(int argc, const char **argv_) {
out = out_open(out_fn, do_md5);
} else {
if (use_y4m)
fwrite("FRAME\n", 1, 6, out);
y4m_write_frame_header(out);
}
if (do_md5)

30
y4menc.c Normal file
Просмотреть файл

@ -0,0 +1,30 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "./y4menc.h"
void y4m_write_file_header(FILE *file, int width, int height,
const struct VpxRational *framerate,
vpx_img_fmt_t fmt) {
const char *color = fmt == VPX_IMG_FMT_444A ? "C444alpha\n" :
fmt == VPX_IMG_FMT_I444 ? "C444\n" :
fmt == VPX_IMG_FMT_I422 ? "C422\n" :
"C420jpeg\n";
// Note: We can't output an aspect ratio here because IVF doesn't
// store one, and neither does VP8.
// That will have to wait until these tools support WebM natively.*/
fprintf(file, "YUV4MPEG2 W%u H%u F%u:%u I%c %s", width, height,
framerate->numerator, framerate->denominator, 'p', color);
}
void y4m_write_frame_header(FILE *file) {
fprintf(file, "FRAME\n");
}

27
y4menc.h Normal file
Просмотреть файл

@ -0,0 +1,27 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef Y4MENC_H_
#define Y4MENC_H_
#include <stdio.h>
#include "./tools_common.h"
#include "vpx/vpx_decoder.h"
void y4m_write_file_header(FILE *file, int width, int height,
const struct VpxRational *framerate,
vpx_img_fmt_t fmt);
void y4m_write_frame_header(FILE *file);
#endif // Y4MENC_H_