Write Kvazaar's version and encoding options in an user data unregistered SEI.

This commit is contained in:
Yusuke Nakamura 2014-02-07 10:48:38 +09:00
parent 430e475954
commit 3e96df2a81
4 changed files with 52 additions and 3 deletions

View file

@ -82,7 +82,7 @@ int main(int argc, char *argv[])
if (!cfg || !config_init(cfg) || !config_read(cfg,argc,argv)) {
fprintf(stderr,
"/***********************************************/\n"
" * Kvazaar HEVC Encoder v. " VERSION_STRING "*\n"
" * Kvazaar HEVC Encoder v. " VERSION_STRING " *\n"
" * Tampere University of Technology 2014 *\n"
"/***********************************************/\n\n");

View file

@ -425,6 +425,15 @@ void encode_one_frame(encoder_control* encoder)
encoder->stream->buffer_pos, 0, NAL_PPS_NUT, 0, 1);
bitstream_clear_buffer(encoder->stream);
if (encoder->frame == 0) {
encode_prefix_sei_version(encoder);
bitstream_align(encoder->stream);
bitstream_flush(encoder->stream);
nal_write(encoder->output, encoder->stream->buffer,
encoder->stream->buffer_pos, 0, PREFIX_SEI_NUT, 0, 0);
bitstream_clear_buffer(encoder->stream);
}
// First slice is IDR
cabac_start(&cabac);
scalinglist_process();
@ -586,6 +595,45 @@ void encode_access_unit_delimiter(encoder_control* encoder)
WRITE_U(encoder->stream, pic_type, 3, "pic_type");
}
void encode_prefix_sei_version(encoder_control* encoder)
{
int i, length;
char buf[1000] = { 0 };
char *s = buf;
config *cfg = encoder->cfg;
// uuid_iso_iec_11578
static const uint8_t uuid[16] = {
0x32, 0xfe, 0x46, 0x6c, 0x98, 0x41, 0x42, 0x69,
0xae, 0x35, 0x6a, 0x91, 0x54, 0x9e, 0xf3, 0xf1
};
memcpy(buf, uuid, 16);
// user_data_payload_byte
s += sprintf(s + 16, "Kvazaar HEVC Encoder v. " VERSION_STRING " - "
"Copyleft 2012-2014 - http://ultravideo.cs.tut.fi/ - options:");
s += sprintf(s, " %dx%d", cfg->width, cfg->height);
s += sprintf(s, " deblock=%d:%d:%d", cfg->deblock_enable,
cfg->deblock_beta, cfg->deblock_tc);
s += sprintf(s, " sao=%d", cfg->sao_enable);
s += sprintf(s, " intra_period=%d", cfg->intra_period);
s += sprintf(s, " qp=%d", cfg->qp);
length = strlen(buf) + 1;
// payloadType = 5 -> user_data_unregistered
WRITE_U(encoder->stream, 5, 8, "last_payload_type_byte");
// payloadSize
for (i = 0; i <= length - 255; i += 255)
WRITE_U(encoder->stream, 255, 8, "ff_byte");
WRITE_U(encoder->stream, length - i, 8, "last_payload_size_byte");
for (i = 0; i < length; i++)
WRITE_U(encoder->stream, ((uint8_t *)buf)[i], 8, "sei_payload");
}
void encode_pic_parameter_set(encoder_control* encoder)
{
#ifdef _DEBUG

View file

@ -111,6 +111,7 @@ void encode_vid_parameter_set(encoder_control *encoder);
void encode_slice_data(encoder_control *encoder);
void encode_slice_header(encoder_control *encoder);
void encode_access_unit_delimiter(encoder_control* encoder);
void encode_prefix_sei_version(encoder_control* encoder);
void encode_coding_tree(encoder_control *encoder, uint16_t x_ctb,
uint16_t y_ctb, uint8_t depth);
void encode_last_significant_xy(encoder_control *encoder, uint8_t lastpos_x,

View file

@ -22,7 +22,7 @@
/*
* \file
* \brief Header that is included in every other header.
´*
*
* This file contains global constants that can be referred to from any header
* or source file. It also contains some helper macros and includes stdint.h
* so that any file can refer to integer types with exact widths.
@ -109,7 +109,7 @@ typedef int16_t coefficient;
//#define SIGN3(x) ((x) > 0) ? +1 : ((x) == 0 ? 0 : -1)
#define SIGN3(x) (((x) > 0) - ((x) < 0))
#define VERSION_STRING "0.2.3 "
#define VERSION_STRING "0.2.3"
#define VERSION 0.2
//#define VERBOSE 1