New upstream version 24.0.1+dfsg1

This commit is contained in:
Sebastian Ramacher 2019-09-22 23:19:10 +02:00
parent b14f9eae6d
commit 5a730d6ec3
842 changed files with 42245 additions and 33385 deletions

View file

@ -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;
@ -152,7 +154,9 @@ bool media_remux_job_create(media_remux_job_t *job, const char *in_filename,
init_size(*job, in_filename);
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
#endif
if (!init_input(*job, in_filename))
goto fail;
@ -167,23 +171,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 +196,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 +211,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 +227,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 +238,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 +251,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;
}