clang-format: Apply formatting
Code submissions have continually suffered from formatting inconsistencies that constantly have to be addressed. Using clang-format simplifies this by making code formatting more consistent, and allows automation of the code formatting so that maintainers can focus more on the code itself instead of code formatting.
This commit is contained in:
@@ -54,7 +54,7 @@ static inline bool init_input(media_remux_job_t job, const char *in_filename)
|
||||
int ret = avformat_open_input(&job->ifmt_ctx, in_filename, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "media_remux: Could not open input file '%s'",
|
||||
in_filename);
|
||||
in_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -76,16 +76,16 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
|
||||
int ret;
|
||||
|
||||
avformat_alloc_output_context2(&job->ofmt_ctx, NULL, NULL,
|
||||
out_filename);
|
||||
out_filename);
|
||||
if (!job->ofmt_ctx) {
|
||||
blog(LOG_ERROR, "media_remux: Could not create output context");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < job->ifmt_ctx->nb_streams; i++) {
|
||||
AVStream *in_stream = job->ifmt_ctx->streams[i];
|
||||
AVStream *out_stream = avformat_new_stream(job->ofmt_ctx,
|
||||
in_stream->codec->codec);
|
||||
AVStream *in_stream = job->ifmt_ctx->streams[i];
|
||||
AVStream *out_stream = avformat_new_stream(
|
||||
job->ofmt_ctx, in_stream->codec->codec);
|
||||
if (!out_stream) {
|
||||
blog(LOG_ERROR, "media_remux: Failed to allocate output"
|
||||
" stream");
|
||||
@@ -97,7 +97,7 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
|
||||
ret = avcodec_parameters_from_context(par, in_stream->codec);
|
||||
if (ret == 0)
|
||||
ret = avcodec_parameters_to_context(out_stream->codec,
|
||||
par);
|
||||
par);
|
||||
avcodec_parameters_free(&par);
|
||||
#else
|
||||
ret = avcodec_copy_context(out_stream->codec, in_stream->codec);
|
||||
@@ -124,8 +124,10 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
|
||||
ret = avio_open(&job->ofmt_ctx->pb, out_filename,
|
||||
AVIO_FLAG_WRITE);
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "media_remux: Failed to open output"
|
||||
" file '%s'", out_filename);
|
||||
blog(LOG_ERROR,
|
||||
"media_remux: Failed to open output"
|
||||
" file '%s'",
|
||||
out_filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -134,7 +136,7 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename)
|
||||
}
|
||||
|
||||
bool media_remux_job_create(media_remux_job_t *job, const char *in_filename,
|
||||
const char *out_filename)
|
||||
const char *out_filename)
|
||||
{
|
||||
if (!job)
|
||||
return false;
|
||||
@@ -167,23 +169,23 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void process_packet(AVPacket *pkt,
|
||||
AVStream *in_stream, AVStream *out_stream)
|
||||
static inline void process_packet(AVPacket *pkt, AVStream *in_stream,
|
||||
AVStream *out_stream)
|
||||
{
|
||||
pkt->pts = av_rescale_q_rnd(pkt->pts, in_stream->time_base,
|
||||
out_stream->time_base,
|
||||
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
out_stream->time_base,
|
||||
AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);
|
||||
pkt->dts = av_rescale_q_rnd(pkt->dts, in_stream->time_base,
|
||||
out_stream->time_base,
|
||||
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
pkt->duration = (int)av_rescale_q(pkt->duration,
|
||||
in_stream->time_base, out_stream->time_base);
|
||||
out_stream->time_base,
|
||||
AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);
|
||||
pkt->duration = (int)av_rescale_q(pkt->duration, in_stream->time_base,
|
||||
out_stream->time_base);
|
||||
pkt->pos = -1;
|
||||
|
||||
}
|
||||
|
||||
static inline int process_packets(media_remux_job_t job,
|
||||
media_remux_progress_callback callback, void *data)
|
||||
media_remux_progress_callback callback,
|
||||
void *data)
|
||||
{
|
||||
AVPacket pkt;
|
||||
|
||||
@@ -192,9 +194,10 @@ static inline int process_packets(media_remux_job_t job,
|
||||
ret = av_read_frame(job->ifmt_ctx, &pkt);
|
||||
if (ret < 0) {
|
||||
if (ret != AVERROR_EOF)
|
||||
blog(LOG_ERROR, "media_remux: Error reading"
|
||||
" packet: %s",
|
||||
av_err2str(ret));
|
||||
blog(LOG_ERROR,
|
||||
"media_remux: Error reading"
|
||||
" packet: %s",
|
||||
av_err2str(ret));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -206,14 +209,14 @@ static inline int process_packets(media_remux_job_t job,
|
||||
}
|
||||
|
||||
process_packet(&pkt, job->ifmt_ctx->streams[pkt.stream_index],
|
||||
job->ofmt_ctx->streams[pkt.stream_index]);
|
||||
job->ofmt_ctx->streams[pkt.stream_index]);
|
||||
|
||||
ret = av_interleaved_write_frame(job->ofmt_ctx, &pkt);
|
||||
av_packet_unref(&pkt);
|
||||
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "media_remux: Error muxing packet: %s",
|
||||
av_err2str(ret));
|
||||
av_err2str(ret));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -222,7 +225,7 @@ static inline int process_packets(media_remux_job_t job,
|
||||
}
|
||||
|
||||
bool media_remux_job_process(media_remux_job_t job,
|
||||
media_remux_progress_callback callback, void *data)
|
||||
media_remux_progress_callback callback, void *data)
|
||||
{
|
||||
int ret;
|
||||
bool success = false;
|
||||
@@ -233,7 +236,7 @@ bool media_remux_job_process(media_remux_job_t job,
|
||||
ret = avformat_write_header(job->ofmt_ctx, NULL);
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "media_remux: Error opening output file: %s",
|
||||
av_err2str(ret));
|
||||
av_err2str(ret));
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -246,7 +249,7 @@ bool media_remux_job_process(media_remux_job_t job,
|
||||
ret = av_write_trailer(job->ofmt_ctx);
|
||||
if (ret < 0) {
|
||||
blog(LOG_ERROR, "media_remux: av_write_trailer: %s",
|
||||
av_err2str(ret));
|
||||
av_err2str(ret));
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user