2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
15 int y4m_write_file_header(char *buf
, size_t len
, int width
, int height
,
16 const struct AvxRational
*framerate
,
17 aom_img_fmt_t fmt
, unsigned int bit_depth
) {
21 color
= fmt
== AOM_IMG_FMT_444A
23 : fmt
== AOM_IMG_FMT_I444
25 : fmt
== AOM_IMG_FMT_I422
? "C422\n" : "C420jpeg\n";
28 color
= fmt
== AOM_IMG_FMT_I44416
29 ? "C444p9 XYSCSS=444P9\n"
30 : fmt
== AOM_IMG_FMT_I42216
? "C422p9 XYSCSS=422P9\n"
31 : "C420p9 XYSCSS=420P9\n";
34 color
= fmt
== AOM_IMG_FMT_I44416
35 ? "C444p10 XYSCSS=444P10\n"
36 : fmt
== AOM_IMG_FMT_I42216
? "C422p10 XYSCSS=422P10\n"
37 : "C420p10 XYSCSS=420P10\n";
40 color
= fmt
== AOM_IMG_FMT_I44416
41 ? "C444p12 XYSCSS=444P12\n"
42 : fmt
== AOM_IMG_FMT_I42216
? "C422p12 XYSCSS=422P12\n"
43 : "C420p12 XYSCSS=420P12\n";
46 color
= fmt
== AOM_IMG_FMT_I44416
47 ? "C444p14 XYSCSS=444P14\n"
48 : fmt
== AOM_IMG_FMT_I42216
? "C422p14 XYSCSS=422P14\n"
49 : "C420p14 XYSCSS=420P14\n";
52 color
= fmt
== AOM_IMG_FMT_I44416
53 ? "C444p16 XYSCSS=444P16\n"
54 : fmt
== AOM_IMG_FMT_I42216
? "C422p16 XYSCSS=422P16\n"
55 : "C420p16 XYSCSS=420P16\n";
57 default: color
= NULL
; assert(0);
59 return snprintf(buf
, len
, "YUV4MPEG2 W%u H%u F%u:%u I%c %s", width
, height
,
60 framerate
->numerator
, framerate
->denominator
, 'p', color
);
63 int y4m_write_frame_header(char *buf
, size_t len
) {
64 return snprintf(buf
, len
, "FRAME\n");