Commit 01f4c717 authored by clang-format's avatar clang-format Committed by James Zern

webm{dec,enc}.cc,debug_util.c: apply clang-format

top-level *.cc were missed in the original change
debug_util.c was checked in with some warnings

Change-Id: I72999bf94d734ffc127bf6f96a8d17f9c313d5a0
parent d9f9a34b
......@@ -33,7 +33,7 @@ int bitstream_queue_get_write(void) { return queue_w; }
int bitstream_queue_get_read(void) { return queue_r; }
void bitstream_queue_pop(int* result, int* prob) {
void bitstream_queue_pop(int *result, int *prob) {
if (!skip_r) {
if (queue_w == queue_r) {
printf("buffer underflow queue_w %d queue_r %d\n", queue_w, queue_r);
......
......@@ -21,12 +21,12 @@ namespace {
void reset(struct WebmInputContext *const webm_ctx) {
if (webm_ctx->reader != NULL) {
mkvparser::MkvReader *const reader =
reinterpret_cast<mkvparser::MkvReader*>(webm_ctx->reader);
reinterpret_cast<mkvparser::MkvReader *>(webm_ctx->reader);
delete reader;
}
if (webm_ctx->segment != NULL) {
mkvparser::Segment *const segment =
reinterpret_cast<mkvparser::Segment*>(webm_ctx->segment);
reinterpret_cast<mkvparser::Segment *>(webm_ctx->segment);
delete segment;
}
if (webm_ctx->buffer != NULL) {
......@@ -46,7 +46,7 @@ void reset(struct WebmInputContext *const webm_ctx) {
void get_first_cluster(struct WebmInputContext *const webm_ctx) {
mkvparser::Segment *const segment =
reinterpret_cast<mkvparser::Segment*>(webm_ctx->segment);
reinterpret_cast<mkvparser::Segment *>(webm_ctx->segment);
const mkvparser::Cluster *const cluster = segment->GetFirst();
webm_ctx->cluster = cluster;
}
......@@ -72,7 +72,7 @@ int file_is_webm(struct WebmInputContext *webm_ctx,
return 0;
}
mkvparser::Segment* segment;
mkvparser::Segment *segment;
if (mkvparser::Segment::CreateInstance(reader, pos, segment)) {
rewind_and_reset(webm_ctx, vpx_ctx);
return 0;
......@@ -84,11 +84,11 @@ int file_is_webm(struct WebmInputContext *webm_ctx,
}
const mkvparser::Tracks *const tracks = segment->GetTracks();
const mkvparser::VideoTrack* video_track = NULL;
const mkvparser::VideoTrack *video_track = NULL;
for (unsigned long i = 0; i < tracks->GetTracksCount(); ++i) {
const mkvparser::Track* const track = tracks->GetTrackByIndex(i);
const mkvparser::Track *const track = tracks->GetTrackByIndex(i);
if (track->GetType() == mkvparser::Track::kVideo) {
video_track = static_cast<const mkvparser::VideoTrack*>(track);
video_track = static_cast<const mkvparser::VideoTrack *>(track);
webm_ctx->video_track_index = track->GetNumber();
break;
}
......@@ -120,8 +120,7 @@ int file_is_webm(struct WebmInputContext *webm_ctx,
return 1;
}
int webm_read_frame(struct WebmInputContext *webm_ctx,
uint8_t **buffer,
int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer,
size_t *buffer_size) {
// This check is needed for frame parallel decoding, in which case this
// function could be called even after it has reached end of input stream.
......@@ -129,13 +128,13 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
return 1;
}
mkvparser::Segment *const segment =
reinterpret_cast<mkvparser::Segment*>(webm_ctx->segment);
const mkvparser::Cluster* cluster =
reinterpret_cast<const mkvparser::Cluster*>(webm_ctx->cluster);
reinterpret_cast<mkvparser::Segment *>(webm_ctx->segment);
const mkvparser::Cluster *cluster =
reinterpret_cast<const mkvparser::Cluster *>(webm_ctx->cluster);
const mkvparser::Block *block =
reinterpret_cast<const mkvparser::Block*>(webm_ctx->block);
reinterpret_cast<const mkvparser::Block *>(webm_ctx->block);
const mkvparser::BlockEntry *block_entry =
reinterpret_cast<const mkvparser::BlockEntry*>(webm_ctx->block_entry);
reinterpret_cast<const mkvparser::BlockEntry *>(webm_ctx->block_entry);
bool block_entry_eos = false;
do {
long status = 0;
......@@ -177,11 +176,11 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
webm_ctx->block_entry = block_entry;
webm_ctx->block = block;
const mkvparser::Block::Frame& frame =
const mkvparser::Block::Frame &frame =
block->GetFrame(webm_ctx->block_frame_index);
++webm_ctx->block_frame_index;
if (frame.len > static_cast<long>(*buffer_size)) {
delete[] *buffer;
delete[] * buffer;
*buffer = new uint8_t[frame.len];
if (*buffer == NULL) {
return -1;
......@@ -193,7 +192,7 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
webm_ctx->is_key_frame = block->IsKey();
mkvparser::MkvReader *const reader =
reinterpret_cast<mkvparser::MkvReader*>(webm_ctx->reader);
reinterpret_cast<mkvparser::MkvReader *>(webm_ctx->reader);
return frame.Read(reader, *buffer) ? -1 : 0;
}
......@@ -223,6 +222,4 @@ int webm_guess_framerate(struct WebmInputContext *webm_ctx,
return 0;
}
void webm_free(struct WebmInputContext *webm_ctx) {
reset(webm_ctx);
}
void webm_free(struct WebmInputContext *webm_ctx) { reset(webm_ctx); }
......@@ -23,8 +23,7 @@ const int kVideoTrackNumber = 1;
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,
stereo_format_t stereo_fmt, unsigned int fourcc,
const struct VpxRational *par) {
mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(webm_ctx->stream);
mkvmuxer::Segment *const segment = new mkvmuxer::Segment();
......@@ -43,34 +42,23 @@ void write_webm_file_header(struct WebmOutputContext *webm_ctx,
const uint64_t video_track_id =
segment->AddVideoTrack(static_cast<int>(cfg->g_w),
static_cast<int>(cfg->g_h),
kVideoTrackNumber);
mkvmuxer::VideoTrack* const video_track =
static_cast<mkvmuxer::VideoTrack*>(
segment->GetTrackByNumber(video_track_id));
static_cast<int>(cfg->g_h), kVideoTrackNumber);
mkvmuxer::VideoTrack *const video_track = static_cast<mkvmuxer::VideoTrack *>(
segment->GetTrackByNumber(video_track_id));
video_track->SetStereoMode(stereo_fmt);
const char *codec_id;
switch (fourcc) {
case VP8_FOURCC:
codec_id = "V_VP8";
break;
case VP9_FOURCC:
codec_id = "V_VP9";
break;
case VP10_FOURCC:
codec_id = "V_VP10";
break;
default:
codec_id = "V_VP10";
break;
case VP8_FOURCC: codec_id = "V_VP8"; break;
case VP9_FOURCC: codec_id = "V_VP9"; break;
case VP10_FOURCC: codec_id = "V_VP10"; break;
default: codec_id = "V_VP10"; break;
}
video_track->set_codec_id(codec_id);
if (par->numerator > 1 || par->denominator > 1) {
// TODO(fgalligan): Add support of DisplayUnit, Display Aspect Ratio type
// to WebM format.
const uint64_t display_width =
static_cast<uint64_t>(((cfg->g_w * par->numerator * 1.0) /
par->denominator) + .5);
const uint64_t display_width = static_cast<uint64_t>(
((cfg->g_w * par->numerator * 1.0) / par->denominator) + .5);
video_track->set_display_width(display_width);
video_track->set_display_height(cfg->g_h);
}
......@@ -85,25 +73,22 @@ 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*>(webm_ctx->segment);
int64_t pts_ns = pkt->data.frame.pts * 1000000000ll *
cfg->g_timebase.num / cfg->g_timebase.den;
if (pts_ns <= webm_ctx->last_pts_ns)
pts_ns = webm_ctx->last_pts_ns + 1000000;
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 <= 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,
kVideoTrackNumber,
pts_ns,
segment->AddFrame(static_cast<uint8_t *>(pkt->data.frame.buf),
pkt->data.frame.sz, kVideoTrackNumber, pts_ns,
pkt->data.frame.flags & VPX_FRAME_IS_KEY);
}
void write_webm_file_footer(struct WebmOutputContext *webm_ctx) {
mkvmuxer::MkvWriter *const writer =
reinterpret_cast<mkvmuxer::MkvWriter*>(webm_ctx->writer);
reinterpret_cast<mkvmuxer::MkvWriter *>(webm_ctx->writer);
mkvmuxer::Segment *const segment =
reinterpret_cast<mkvmuxer::Segment*>(webm_ctx->segment);
reinterpret_cast<mkvmuxer::Segment *>(webm_ctx->segment);
segment->Finalize();
delete segment;
delete writer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment