TODO cleanup: s/EbmlGlobal/WebmOutputContext/
This brings the struct's name in line with WebmInputContext. Change-Id: I1a1c7ae60b006ae5de8253177d6d996f5867866d
This commit is contained in:
Родитель
ef4a132cc4
Коммит
9441f10b51
20
vpxenc.c
20
vpxenc.c
|
@ -790,7 +790,7 @@ static int compare_img(const vpx_image_t *const img1,
|
||||||
|
|
||||||
#if !CONFIG_WEBM_IO
|
#if !CONFIG_WEBM_IO
|
||||||
typedef int stereo_format_t;
|
typedef int stereo_format_t;
|
||||||
struct EbmlGlobal { int debug; };
|
struct WebmOutputContext { int debug; };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Per-stream configuration */
|
/* Per-stream configuration */
|
||||||
|
@ -818,7 +818,7 @@ struct stream_state {
|
||||||
struct stream_config config;
|
struct stream_config config;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
struct rate_hist *rate_hist;
|
struct rate_hist *rate_hist;
|
||||||
struct EbmlGlobal ebml;
|
struct WebmOutputContext webm_ctx;
|
||||||
uint64_t psnr_sse_total;
|
uint64_t psnr_sse_total;
|
||||||
uint64_t psnr_samples_total;
|
uint64_t psnr_samples_total;
|
||||||
double psnr_totals[4];
|
double psnr_totals[4];
|
||||||
|
@ -1061,13 +1061,13 @@ static struct stream_state *new_stream(struct VpxEncoderConfig *global,
|
||||||
stream->config.write_webm = 1;
|
stream->config.write_webm = 1;
|
||||||
#if CONFIG_WEBM_IO
|
#if CONFIG_WEBM_IO
|
||||||
stream->config.stereo_fmt = STEREO_FORMAT_MONO;
|
stream->config.stereo_fmt = STEREO_FORMAT_MONO;
|
||||||
stream->ebml.last_pts_ns = -1;
|
stream->webm_ctx.last_pts_ns = -1;
|
||||||
stream->ebml.writer = NULL;
|
stream->webm_ctx.writer = NULL;
|
||||||
stream->ebml.segment = NULL;
|
stream->webm_ctx.segment = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Allows removal of the application version from the EBML tags */
|
/* Allows removal of the application version from the EBML tags */
|
||||||
stream->ebml.debug = global->debug;
|
stream->webm_ctx.debug = global->debug;
|
||||||
|
|
||||||
/* Default lag_in_frames is 0 in realtime mode */
|
/* Default lag_in_frames is 0 in realtime mode */
|
||||||
if (global->deadline == VPX_DL_REALTIME)
|
if (global->deadline == VPX_DL_REALTIME)
|
||||||
|
@ -1449,8 +1449,8 @@ static void open_output_file(struct stream_state *stream,
|
||||||
|
|
||||||
#if CONFIG_WEBM_IO
|
#if CONFIG_WEBM_IO
|
||||||
if (stream->config.write_webm) {
|
if (stream->config.write_webm) {
|
||||||
stream->ebml.stream = stream->file;
|
stream->webm_ctx.stream = stream->file;
|
||||||
write_webm_file_header(&stream->ebml, cfg,
|
write_webm_file_header(&stream->webm_ctx, cfg,
|
||||||
&global->framerate,
|
&global->framerate,
|
||||||
stream->config.stereo_fmt,
|
stream->config.stereo_fmt,
|
||||||
global->codec->fourcc,
|
global->codec->fourcc,
|
||||||
|
@ -1475,7 +1475,7 @@ static void close_output_file(struct stream_state *stream,
|
||||||
|
|
||||||
#if CONFIG_WEBM_IO
|
#if CONFIG_WEBM_IO
|
||||||
if (stream->config.write_webm) {
|
if (stream->config.write_webm) {
|
||||||
write_webm_file_footer(&stream->ebml);
|
write_webm_file_footer(&stream->webm_ctx);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1702,7 +1702,7 @@ static void get_cx_data(struct stream_state *stream,
|
||||||
update_rate_histogram(stream->rate_hist, cfg, pkt);
|
update_rate_histogram(stream->rate_hist, cfg, pkt);
|
||||||
#if CONFIG_WEBM_IO
|
#if CONFIG_WEBM_IO
|
||||||
if (stream->config.write_webm) {
|
if (stream->config.write_webm) {
|
||||||
write_webm_block(&stream->ebml, cfg, pkt);
|
write_webm_block(&stream->webm_ctx, cfg, pkt);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!stream->config.write_webm) {
|
if (!stream->config.write_webm) {
|
||||||
|
|
32
webmenc.cc
32
webmenc.cc
|
@ -20,13 +20,13 @@ const uint64_t kDebugTrackUid = 0xDEADBEEF;
|
||||||
const int kVideoTrackNumber = 1;
|
const int kVideoTrackNumber = 1;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void write_webm_file_header(struct EbmlGlobal *glob,
|
void write_webm_file_header(struct WebmOutputContext *webm_ctx,
|
||||||
const vpx_codec_enc_cfg_t *cfg,
|
const vpx_codec_enc_cfg_t *cfg,
|
||||||
const struct vpx_rational *fps,
|
const struct vpx_rational *fps,
|
||||||
stereo_format_t stereo_fmt,
|
stereo_format_t stereo_fmt,
|
||||||
unsigned int fourcc,
|
unsigned int fourcc,
|
||||||
const struct VpxRational *par) {
|
const struct VpxRational *par) {
|
||||||
mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(glob->stream);
|
mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(webm_ctx->stream);
|
||||||
mkvmuxer::Segment *const segment = new mkvmuxer::Segment();
|
mkvmuxer::Segment *const segment = new mkvmuxer::Segment();
|
||||||
segment->Init(writer);
|
segment->Init(writer);
|
||||||
segment->set_mode(mkvmuxer::Segment::kFile);
|
segment->set_mode(mkvmuxer::Segment::kFile);
|
||||||
|
@ -36,7 +36,7 @@ void write_webm_file_header(struct EbmlGlobal *glob,
|
||||||
const uint64_t kTimecodeScale = 1000000;
|
const uint64_t kTimecodeScale = 1000000;
|
||||||
info->set_timecode_scale(kTimecodeScale);
|
info->set_timecode_scale(kTimecodeScale);
|
||||||
std::string version = "vpxenc";
|
std::string version = "vpxenc";
|
||||||
if (!glob->debug) {
|
if (!webm_ctx->debug) {
|
||||||
version.append(std::string(" ") + vpx_codec_version_str());
|
version.append(std::string(" ") + vpx_codec_version_str());
|
||||||
}
|
}
|
||||||
info->set_writing_app(version.c_str());
|
info->set_writing_app(version.c_str());
|
||||||
|
@ -74,23 +74,23 @@ void write_webm_file_header(struct EbmlGlobal *glob,
|
||||||
video_track->set_display_width(display_width);
|
video_track->set_display_width(display_width);
|
||||||
video_track->set_display_height(cfg->g_h);
|
video_track->set_display_height(cfg->g_h);
|
||||||
}
|
}
|
||||||
if (glob->debug) {
|
if (webm_ctx->debug) {
|
||||||
video_track->set_uid(kDebugTrackUid);
|
video_track->set_uid(kDebugTrackUid);
|
||||||
}
|
}
|
||||||
glob->writer = writer;
|
webm_ctx->writer = writer;
|
||||||
glob->segment = segment;
|
webm_ctx->segment = segment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_webm_block(struct EbmlGlobal *glob,
|
void write_webm_block(struct WebmOutputContext *webm_ctx,
|
||||||
const vpx_codec_enc_cfg_t *cfg,
|
const vpx_codec_enc_cfg_t *cfg,
|
||||||
const vpx_codec_cx_pkt_t *pkt) {
|
const vpx_codec_cx_pkt_t *pkt) {
|
||||||
mkvmuxer::Segment *const segment =
|
mkvmuxer::Segment *const segment =
|
||||||
reinterpret_cast<mkvmuxer::Segment*>(glob->segment);
|
reinterpret_cast<mkvmuxer::Segment*>(webm_ctx->segment);
|
||||||
int64_t pts_ns = pkt->data.frame.pts * 1000000000ll *
|
int64_t pts_ns = pkt->data.frame.pts * 1000000000ll *
|
||||||
cfg->g_timebase.num / cfg->g_timebase.den;
|
cfg->g_timebase.num / cfg->g_timebase.den;
|
||||||
if (pts_ns <= glob->last_pts_ns)
|
if (pts_ns <= webm_ctx->last_pts_ns)
|
||||||
pts_ns = glob->last_pts_ns + 1000000;
|
pts_ns = webm_ctx->last_pts_ns + 1000000;
|
||||||
glob->last_pts_ns = pts_ns;
|
webm_ctx->last_pts_ns = pts_ns;
|
||||||
|
|
||||||
segment->AddFrame(static_cast<uint8_t*>(pkt->data.frame.buf),
|
segment->AddFrame(static_cast<uint8_t*>(pkt->data.frame.buf),
|
||||||
pkt->data.frame.sz,
|
pkt->data.frame.sz,
|
||||||
|
@ -99,14 +99,14 @@ void write_webm_block(struct EbmlGlobal *glob,
|
||||||
pkt->data.frame.flags & VPX_FRAME_IS_KEY);
|
pkt->data.frame.flags & VPX_FRAME_IS_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_webm_file_footer(struct EbmlGlobal *glob) {
|
void write_webm_file_footer(struct WebmOutputContext *webm_ctx) {
|
||||||
mkvmuxer::MkvWriter *const writer =
|
mkvmuxer::MkvWriter *const writer =
|
||||||
reinterpret_cast<mkvmuxer::MkvWriter*>(glob->writer);
|
reinterpret_cast<mkvmuxer::MkvWriter*>(webm_ctx->writer);
|
||||||
mkvmuxer::Segment *const segment =
|
mkvmuxer::Segment *const segment =
|
||||||
reinterpret_cast<mkvmuxer::Segment*>(glob->segment);
|
reinterpret_cast<mkvmuxer::Segment*>(webm_ctx->segment);
|
||||||
segment->Finalize();
|
segment->Finalize();
|
||||||
delete segment;
|
delete segment;
|
||||||
delete writer;
|
delete writer;
|
||||||
glob->writer = NULL;
|
webm_ctx->writer = NULL;
|
||||||
glob->segment = NULL;
|
webm_ctx->segment = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* TODO(vigneshv): Rename this struct */
|
struct WebmOutputContext {
|
||||||
struct EbmlGlobal {
|
|
||||||
int debug;
|
int debug;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
int64_t last_pts_ns;
|
int64_t last_pts_ns;
|
||||||
|
@ -38,18 +37,18 @@ typedef enum stereo_format {
|
||||||
STEREO_FORMAT_RIGHT_LEFT = 11
|
STEREO_FORMAT_RIGHT_LEFT = 11
|
||||||
} stereo_format_t;
|
} stereo_format_t;
|
||||||
|
|
||||||
void write_webm_file_header(struct EbmlGlobal *glob,
|
void write_webm_file_header(struct WebmOutputContext *webm_ctx,
|
||||||
const vpx_codec_enc_cfg_t *cfg,
|
const vpx_codec_enc_cfg_t *cfg,
|
||||||
const struct vpx_rational *fps,
|
const struct vpx_rational *fps,
|
||||||
stereo_format_t stereo_fmt,
|
stereo_format_t stereo_fmt,
|
||||||
unsigned int fourcc,
|
unsigned int fourcc,
|
||||||
const struct VpxRational *par);
|
const struct VpxRational *par);
|
||||||
|
|
||||||
void write_webm_block(struct EbmlGlobal *glob,
|
void write_webm_block(struct WebmOutputContext *webm_ctx,
|
||||||
const vpx_codec_enc_cfg_t *cfg,
|
const vpx_codec_enc_cfg_t *cfg,
|
||||||
const vpx_codec_cx_pkt_t *pkt);
|
const vpx_codec_cx_pkt_t *pkt);
|
||||||
|
|
||||||
void write_webm_file_footer(struct EbmlGlobal *glob);
|
void write_webm_file_footer(struct WebmOutputContext *webm_ctx);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче