TODO cleanup: s/EbmlGlobal/WebmOutputContext/

This brings the struct's name in line with WebmInputContext.

Change-Id: I1a1c7ae60b006ae5de8253177d6d996f5867866d
This commit is contained in:
Vignesh Venkatasubramanian 2016-04-25 13:28:24 -07:00
Родитель ef4a132cc4
Коммит 9441f10b51
3 изменённых файлов: 30 добавлений и 31 удалений

Просмотреть файл

@ -790,7 +790,7 @@ static int compare_img(const vpx_image_t *const img1,
#if !CONFIG_WEBM_IO
typedef int stereo_format_t;
struct EbmlGlobal { int debug; };
struct WebmOutputContext { int debug; };
#endif
/* Per-stream configuration */
@ -818,7 +818,7 @@ struct stream_state {
struct stream_config config;
FILE *file;
struct rate_hist *rate_hist;
struct EbmlGlobal ebml;
struct WebmOutputContext webm_ctx;
uint64_t psnr_sse_total;
uint64_t psnr_samples_total;
double psnr_totals[4];
@ -1061,13 +1061,13 @@ static struct stream_state *new_stream(struct VpxEncoderConfig *global,
stream->config.write_webm = 1;
#if CONFIG_WEBM_IO
stream->config.stereo_fmt = STEREO_FORMAT_MONO;
stream->ebml.last_pts_ns = -1;
stream->ebml.writer = NULL;
stream->ebml.segment = NULL;
stream->webm_ctx.last_pts_ns = -1;
stream->webm_ctx.writer = NULL;
stream->webm_ctx.segment = NULL;
#endif
/* 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 */
if (global->deadline == VPX_DL_REALTIME)
@ -1449,8 +1449,8 @@ static void open_output_file(struct stream_state *stream,
#if CONFIG_WEBM_IO
if (stream->config.write_webm) {
stream->ebml.stream = stream->file;
write_webm_file_header(&stream->ebml, cfg,
stream->webm_ctx.stream = stream->file;
write_webm_file_header(&stream->webm_ctx, cfg,
&global->framerate,
stream->config.stereo_fmt,
global->codec->fourcc,
@ -1475,7 +1475,7 @@ static void close_output_file(struct stream_state *stream,
#if CONFIG_WEBM_IO
if (stream->config.write_webm) {
write_webm_file_footer(&stream->ebml);
write_webm_file_footer(&stream->webm_ctx);
}
#endif
@ -1702,7 +1702,7 @@ static void get_cx_data(struct stream_state *stream,
update_rate_histogram(stream->rate_hist, cfg, pkt);
#if CONFIG_WEBM_IO
if (stream->config.write_webm) {
write_webm_block(&stream->ebml, cfg, pkt);
write_webm_block(&stream->webm_ctx, cfg, pkt);
}
#endif
if (!stream->config.write_webm) {

Просмотреть файл

@ -20,13 +20,13 @@ const uint64_t kDebugTrackUid = 0xDEADBEEF;
const int kVideoTrackNumber = 1;
} // 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 struct vpx_rational *fps,
stereo_format_t stereo_fmt,
unsigned int fourcc,
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();
segment->Init(writer);
segment->set_mode(mkvmuxer::Segment::kFile);
@ -36,7 +36,7 @@ void write_webm_file_header(struct EbmlGlobal *glob,
const uint64_t kTimecodeScale = 1000000;
info->set_timecode_scale(kTimecodeScale);
std::string version = "vpxenc";
if (!glob->debug) {
if (!webm_ctx->debug) {
version.append(std::string(" ") + vpx_codec_version_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_height(cfg->g_h);
}
if (glob->debug) {
if (webm_ctx->debug) {
video_track->set_uid(kDebugTrackUid);
}
glob->writer = writer;
glob->segment = segment;
webm_ctx->writer = writer;
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_cx_pkt_t *pkt) {
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 *
cfg->g_timebase.num / cfg->g_timebase.den;
if (pts_ns <= glob->last_pts_ns)
pts_ns = glob->last_pts_ns + 1000000;
glob->last_pts_ns = pts_ns;
if (pts_ns <= webm_ctx->last_pts_ns)
pts_ns = webm_ctx->last_pts_ns + 1000000;
webm_ctx->last_pts_ns = pts_ns;
segment->AddFrame(static_cast<uint8_t*>(pkt->data.frame.buf),
pkt->data.frame.sz,
@ -99,14 +99,14 @@ void write_webm_block(struct EbmlGlobal *glob,
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 =
reinterpret_cast<mkvmuxer::MkvWriter*>(glob->writer);
reinterpret_cast<mkvmuxer::MkvWriter*>(webm_ctx->writer);
mkvmuxer::Segment *const segment =
reinterpret_cast<mkvmuxer::Segment*>(glob->segment);
reinterpret_cast<mkvmuxer::Segment*>(webm_ctx->segment);
segment->Finalize();
delete segment;
delete writer;
glob->writer = NULL;
glob->segment = NULL;
webm_ctx->writer = NULL;
webm_ctx->segment = NULL;
}

Просмотреть файл

@ -20,8 +20,7 @@
extern "C" {
#endif
/* TODO(vigneshv): Rename this struct */
struct EbmlGlobal {
struct WebmOutputContext {
int debug;
FILE *stream;
int64_t last_pts_ns;
@ -38,18 +37,18 @@ typedef enum stereo_format {
STEREO_FORMAT_RIGHT_LEFT = 11
} 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 struct vpx_rational *fps,
stereo_format_t stereo_fmt,
unsigned int fourcc,
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_cx_pkt_t *pkt);
void write_webm_file_footer(struct EbmlGlobal *glob);
void write_webm_file_footer(struct WebmOutputContext *webm_ctx);
#ifdef __cplusplus
} // extern "C"