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; } ...@@ -33,7 +33,7 @@ int bitstream_queue_get_write(void) { return queue_w; }
int bitstream_queue_get_read(void) { return queue_r; } 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 (!skip_r) {
if (queue_w == queue_r) { if (queue_w == queue_r) {
printf("buffer underflow queue_w %d queue_r %d\n", queue_w, queue_r); printf("buffer underflow queue_w %d queue_r %d\n", queue_w, queue_r);
......
...@@ -21,12 +21,12 @@ namespace { ...@@ -21,12 +21,12 @@ namespace {
void reset(struct WebmInputContext *const webm_ctx) { void reset(struct WebmInputContext *const webm_ctx) {
if (webm_ctx->reader != NULL) { if (webm_ctx->reader != NULL) {
mkvparser::MkvReader *const reader = mkvparser::MkvReader *const reader =
reinterpret_cast<mkvparser::MkvReader*>(webm_ctx->reader); reinterpret_cast<mkvparser::MkvReader *>(webm_ctx->reader);
delete reader; delete reader;
} }
if (webm_ctx->segment != NULL) { if (webm_ctx->segment != NULL) {
mkvparser::Segment *const segment = mkvparser::Segment *const segment =
reinterpret_cast<mkvparser::Segment*>(webm_ctx->segment); reinterpret_cast<mkvparser::Segment *>(webm_ctx->segment);
delete segment; delete segment;
} }
if (webm_ctx->buffer != NULL) { if (webm_ctx->buffer != NULL) {
...@@ -46,7 +46,7 @@ void reset(struct WebmInputContext *const webm_ctx) { ...@@ -46,7 +46,7 @@ void reset(struct WebmInputContext *const webm_ctx) {
void get_first_cluster(struct WebmInputContext *const webm_ctx) { void get_first_cluster(struct WebmInputContext *const webm_ctx) {
mkvparser::Segment *const segment = 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(); const mkvparser::Cluster *const cluster = segment->GetFirst();
webm_ctx->cluster = cluster; webm_ctx->cluster = cluster;
} }
...@@ -72,7 +72,7 @@ int file_is_webm(struct WebmInputContext *webm_ctx, ...@@ -72,7 +72,7 @@ int file_is_webm(struct WebmInputContext *webm_ctx,
return 0; return 0;
} }
mkvparser::Segment* segment; mkvparser::Segment *segment;
if (mkvparser::Segment::CreateInstance(reader, pos, segment)) { if (mkvparser::Segment::CreateInstance(reader, pos, segment)) {
rewind_and_reset(webm_ctx, vpx_ctx); rewind_and_reset(webm_ctx, vpx_ctx);
return 0; return 0;
...@@ -84,11 +84,11 @@ int file_is_webm(struct WebmInputContext *webm_ctx, ...@@ -84,11 +84,11 @@ int file_is_webm(struct WebmInputContext *webm_ctx,
} }
const mkvparser::Tracks *const tracks = segment->GetTracks(); 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) { 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) { 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(); webm_ctx->video_track_index = track->GetNumber();
break; break;
} }
...@@ -120,8 +120,7 @@ int file_is_webm(struct WebmInputContext *webm_ctx, ...@@ -120,8 +120,7 @@ int file_is_webm(struct WebmInputContext *webm_ctx,
return 1; return 1;
} }
int webm_read_frame(struct WebmInputContext *webm_ctx, int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer,
uint8_t **buffer,
size_t *buffer_size) { size_t *buffer_size) {
// This check is needed for frame parallel decoding, in which case this // 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. // 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, ...@@ -129,13 +128,13 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
return 1; return 1;
} }
mkvparser::Segment *const segment = mkvparser::Segment *const segment =
reinterpret_cast<mkvparser::Segment*>(webm_ctx->segment); reinterpret_cast<mkvparser::Segment *>(webm_ctx->segment);
const mkvparser::Cluster* cluster = const mkvparser::Cluster *cluster =
reinterpret_cast<const mkvparser::Cluster*>(webm_ctx->cluster); reinterpret_cast<const mkvparser::Cluster *>(webm_ctx->cluster);
const mkvparser::Block *block = 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 = 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; bool block_entry_eos = false;
do { do {
long status = 0; long status = 0;
...@@ -177,11 +176,11 @@ int webm_read_frame(struct WebmInputContext *webm_ctx, ...@@ -177,11 +176,11 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
webm_ctx->block_entry = block_entry; webm_ctx->block_entry = block_entry;
webm_ctx->block = block; webm_ctx->block = block;
const mkvparser::Block::Frame& frame = const mkvparser::Block::Frame &frame =
block->GetFrame(webm_ctx->block_frame_index); block->GetFrame(webm_ctx->block_frame_index);
++webm_ctx->block_frame_index; ++webm_ctx->block_frame_index;
if (frame.len > static_cast<long>(*buffer_size)) { if (frame.len > static_cast<long>(*buffer_size)) {
delete[] *buffer; delete[] * buffer;
*buffer = new uint8_t[frame.len]; *buffer = new uint8_t[frame.len];
if (*buffer == NULL) { if (*buffer == NULL) {
return -1; return -1;
...@@ -193,7 +192,7 @@ int webm_read_frame(struct WebmInputContext *webm_ctx, ...@@ -193,7 +192,7 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
webm_ctx->is_key_frame = block->IsKey(); webm_ctx->is_key_frame = block->IsKey();
mkvparser::MkvReader *const reader = 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; return frame.Read(reader, *buffer) ? -1 : 0;
} }
...@@ -223,6 +222,4 @@ int webm_guess_framerate(struct WebmInputContext *webm_ctx, ...@@ -223,6 +222,4 @@ int webm_guess_framerate(struct WebmInputContext *webm_ctx,
return 0; return 0;
} }
void webm_free(struct WebmInputContext *webm_ctx) { void webm_free(struct WebmInputContext *webm_ctx) { reset(webm_ctx); }
reset(webm_ctx);
}
...@@ -23,8 +23,7 @@ const int kVideoTrackNumber = 1; ...@@ -23,8 +23,7 @@ const int kVideoTrackNumber = 1;
void write_webm_file_header(struct WebmOutputContext *webm_ctx, 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(webm_ctx->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();
...@@ -43,34 +42,23 @@ void write_webm_file_header(struct WebmOutputContext *webm_ctx, ...@@ -43,34 +42,23 @@ void write_webm_file_header(struct WebmOutputContext *webm_ctx,
const uint64_t video_track_id = const uint64_t video_track_id =
segment->AddVideoTrack(static_cast<int>(cfg->g_w), segment->AddVideoTrack(static_cast<int>(cfg->g_w),
static_cast<int>(cfg->g_h), static_cast<int>(cfg->g_h), kVideoTrackNumber);
kVideoTrackNumber); mkvmuxer::VideoTrack *const video_track = static_cast<mkvmuxer::VideoTrack *>(
mkvmuxer::VideoTrack* const video_track = segment->GetTrackByNumber(video_track_id));
static_cast<mkvmuxer::VideoTrack*>(
segment->GetTrackByNumber(video_track_id));
video_track->SetStereoMode(stereo_fmt); video_track->SetStereoMode(stereo_fmt);
const char *codec_id; const char *codec_id;
switch (fourcc) { switch (fourcc) {
case VP8_FOURCC: case VP8_FOURCC: codec_id = "V_VP8"; break;
codec_id = "V_VP8"; case VP9_FOURCC: codec_id = "V_VP9"; break;
break; case VP10_FOURCC: codec_id = "V_VP10"; break;
case VP9_FOURCC: default: codec_id = "V_VP10"; break;
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); video_track->set_codec_id(codec_id);
if (par->numerator > 1 || par->denominator > 1) { if (par->numerator > 1 || par->denominator > 1) {
// TODO(fgalligan): Add support of DisplayUnit, Display Aspect Ratio type // TODO(fgalligan): Add support of DisplayUnit, Display Aspect Ratio type
// to WebM format. // to WebM format.
const uint64_t display_width = const uint64_t display_width = static_cast<uint64_t>(
static_cast<uint64_t>(((cfg->g_w * par->numerator * 1.0) / ((cfg->g_w * par->numerator * 1.0) / par->denominator) + .5);
par->denominator) + .5);
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);
} }
...@@ -85,25 +73,22 @@ void write_webm_block(struct WebmOutputContext *webm_ctx, ...@@ -85,25 +73,22 @@ 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*>(webm_ctx->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.num / cfg->g_timebase.den; cfg->g_timebase.den;
if (pts_ns <= webm_ctx->last_pts_ns) if (pts_ns <= webm_ctx->last_pts_ns) pts_ns = webm_ctx->last_pts_ns + 1000000;
pts_ns = webm_ctx->last_pts_ns + 1000000;
webm_ctx->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, kVideoTrackNumber, pts_ns,
kVideoTrackNumber,
pts_ns,
pkt->data.frame.flags & VPX_FRAME_IS_KEY); pkt->data.frame.flags & VPX_FRAME_IS_KEY);
} }
void write_webm_file_footer(struct WebmOutputContext *webm_ctx) { void write_webm_file_footer(struct WebmOutputContext *webm_ctx) {
mkvmuxer::MkvWriter *const writer = mkvmuxer::MkvWriter *const writer =
reinterpret_cast<mkvmuxer::MkvWriter*>(webm_ctx->writer); reinterpret_cast<mkvmuxer::MkvWriter *>(webm_ctx->writer);
mkvmuxer::Segment *const segment = mkvmuxer::Segment *const segment =
reinterpret_cast<mkvmuxer::Segment*>(webm_ctx->segment); reinterpret_cast<mkvmuxer::Segment *>(webm_ctx->segment);
segment->Finalize(); segment->Finalize();
delete segment; delete segment;
delete writer; 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