Changing ivf_write_frame_header() function signature.
Replacing vpx_codec_cx_pkt argument with two separate pts and frame_size. Change-Id: I7b37e379ee71342520cf08f03acfb4b499b2cbe4
This commit is contained in:
parent
afc8f43448
commit
373b0f9ae3
41
ivfenc.c
41
ivfenc.c
@ -10,7 +10,6 @@
|
||||
|
||||
#include "./ivfenc.h"
|
||||
|
||||
#include "./tools_common.h"
|
||||
#include "vpx/vpx_encoder.h"
|
||||
#include "vpx_ports/mem_ops.h"
|
||||
|
||||
@ -24,33 +23,31 @@ void ivf_write_file_header(FILE *outfile,
|
||||
header[1] = 'K';
|
||||
header[2] = 'I';
|
||||
header[3] = 'F';
|
||||
mem_put_le16(header + 4, 0); /* version */
|
||||
mem_put_le16(header + 6, 32); /* headersize */
|
||||
mem_put_le32(header + 8, fourcc); /* four CC */
|
||||
mem_put_le16(header + 12, cfg->g_w); /* width */
|
||||
mem_put_le16(header + 14, cfg->g_h); /* height */
|
||||
mem_put_le32(header + 16, cfg->g_timebase.den); /* rate */
|
||||
mem_put_le32(header + 20, cfg->g_timebase.num); /* scale */
|
||||
mem_put_le32(header + 24, frame_cnt); /* length */
|
||||
mem_put_le32(header + 28, 0); /* unused */
|
||||
mem_put_le16(header + 4, 0); // version
|
||||
mem_put_le16(header + 6, 32); // header size
|
||||
mem_put_le32(header + 8, fourcc); // fourcc
|
||||
mem_put_le16(header + 12, cfg->g_w); // width
|
||||
mem_put_le16(header + 14, cfg->g_h); // height
|
||||
mem_put_le32(header + 16, cfg->g_timebase.den); // rate
|
||||
mem_put_le32(header + 20, cfg->g_timebase.num); // scale
|
||||
mem_put_le32(header + 24, frame_cnt); // length
|
||||
mem_put_le32(header + 28, 0); // unused
|
||||
|
||||
(void) fwrite(header, 1, 32, outfile);
|
||||
fwrite(header, 1, 32, outfile);
|
||||
}
|
||||
|
||||
void ivf_write_frame_header(FILE *outfile, const struct vpx_codec_cx_pkt *pkt) {
|
||||
void ivf_write_frame_header(FILE *outfile, int64_t pts, size_t frame_size) {
|
||||
char header[12];
|
||||
vpx_codec_pts_t pts;
|
||||
|
||||
pts = pkt->data.frame.pts;
|
||||
mem_put_le32(header, (int)pkt->data.frame.sz);
|
||||
mem_put_le32(header + 4, pts & 0xFFFFFFFF);
|
||||
mem_put_le32(header + 8, pts >> 32);
|
||||
|
||||
(void) fwrite(header, 1, 12, outfile);
|
||||
mem_put_le32(header, (int)frame_size);
|
||||
mem_put_le32(header + 4, (int)(pts & 0xFFFFFFFF));
|
||||
mem_put_le32(header + 8, (int)(pts >> 32));
|
||||
fwrite(header, 1, 12, outfile);
|
||||
}
|
||||
|
||||
void ivf_write_frame_size(FILE *outfile, size_t size) {
|
||||
void ivf_write_frame_size(FILE *outfile, size_t frame_size) {
|
||||
char header[4];
|
||||
mem_put_le32(header, (int)size);
|
||||
(void) fwrite(header, 1, 4, outfile);
|
||||
|
||||
mem_put_le32(header, (int)frame_size);
|
||||
fwrite(header, 1, 4, outfile);
|
||||
}
|
||||
|
6
ivfenc.h
6
ivfenc.h
@ -23,8 +23,10 @@ void ivf_write_file_header(FILE *outfile,
|
||||
const struct vpx_codec_enc_cfg *cfg,
|
||||
uint32_t fourcc,
|
||||
int frame_cnt);
|
||||
void ivf_write_frame_header(FILE *outfile, const struct vpx_codec_cx_pkt *pkt);
|
||||
void ivf_write_frame_size(FILE *outfile, size_t size);
|
||||
|
||||
void ivf_write_frame_header(FILE *outfile, int64_t pts, size_t frame_size);
|
||||
|
||||
void ivf_write_frame_size(FILE *outfile, size_t frame_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -193,8 +193,6 @@ int main(int argc, const char **argv) {
|
||||
vpx_codec_err_t res;
|
||||
int pts = 0; /* PTS starts at 0 */
|
||||
int frame_duration = 1; /* 1 timebase tick per frame */
|
||||
vpx_codec_cx_pkt_t packet = {0};
|
||||
packet.kind = VPX_CODEC_CX_FRAME_PKT;
|
||||
|
||||
memset(&svc_ctx, 0, sizeof(svc_ctx));
|
||||
svc_ctx.log_print = 1;
|
||||
@ -234,9 +232,7 @@ int main(int argc, const char **argv) {
|
||||
die_codec(&codec, "Failed to encode frame");
|
||||
}
|
||||
if (vpx_svc_get_frame_size(&svc_ctx) > 0) {
|
||||
packet.data.frame.pts = pts;
|
||||
packet.data.frame.sz = vpx_svc_get_frame_size(&svc_ctx);
|
||||
ivf_write_frame_header(outfile, &packet);
|
||||
ivf_write_frame_header(outfile, pts, vpx_svc_get_frame_size(&svc_ctx));
|
||||
(void)fwrite(vpx_svc_get_buffer(&svc_ctx), 1,
|
||||
vpx_svc_get_frame_size(&svc_ctx), outfile);
|
||||
}
|
||||
|
2
vpxenc.c
2
vpxenc.c
@ -1323,7 +1323,7 @@ static void get_cx_data(struct stream_state *stream,
|
||||
ivf_header_pos = ftello(stream->file);
|
||||
fsize = pkt->data.frame.sz;
|
||||
|
||||
ivf_write_frame_header(stream->file, pkt);
|
||||
ivf_write_frame_header(stream->file, pkt->data.frame.pts, fsize);
|
||||
} else {
|
||||
fsize += pkt->data.frame.sz;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user