2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
13 #include "./tools_common.h"
14 #include "vpx/vpx_encoder.h"
15 #include "vpx_ports/mem_ops.h"
17 void ivf_write_file_header(FILE *outfile,
18 const struct vpx_codec_enc_cfg *cfg,
23 if (cfg->g_pass != VPX_RC_ONE_PASS && cfg->g_pass != VPX_RC_LAST_PASS)
30 mem_put_le16(header + 4, 0); /* version */
31 mem_put_le16(header + 6, 32); /* headersize */
32 mem_put_le32(header + 8, fourcc); /* four CC */
33 mem_put_le16(header + 12, cfg->g_w); /* width */
34 mem_put_le16(header + 14, cfg->g_h); /* height */
35 mem_put_le32(header + 16, cfg->g_timebase.den); /* rate */
36 mem_put_le32(header + 20, cfg->g_timebase.num); /* scale */
37 mem_put_le32(header + 24, frame_cnt); /* length */
38 mem_put_le32(header + 28, 0); /* unused */
40 (void) fwrite(header, 1, 32, outfile);
43 void ivf_write_frame_header(FILE *outfile, const struct vpx_codec_cx_pkt *pkt) {
47 if (pkt->kind != VPX_CODEC_CX_FRAME_PKT)
50 pts = pkt->data.frame.pts;
51 mem_put_le32(header, (int)pkt->data.frame.sz);
52 mem_put_le32(header + 4, pts & 0xFFFFFFFF);
53 mem_put_le32(header + 8, pts >> 32);
55 (void) fwrite(header, 1, 12, outfile);
58 void ivf_write_frame_size(FILE *outfile, size_t size) {
60 mem_put_le32(header, (int)size);
61 (void) fwrite(header, 1, 4, outfile);