ist->sub2video.frame->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w;
ist->sub2video.frame->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h;
ist->sub2video.frame->format = AV_PIX_FMT_RGB32;
- if ((ret = av_frame_get_buffer(frame, 32)) < 0)
+ if ((ret = av_frame_get_buffer(frame, 0)) < 0)
return ret;
memset(frame->data[0], 0, frame->height * frame->linesize[0]);
return 0;
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
for (j = 0; j < fg->nb_inputs; j++) {
- while (av_fifo_size(fg->inputs[j]->frame_queue)) {
+ InputFilter *ifilter = fg->inputs[j];
+ struct InputStream *ist = ifilter->ist;
+
+ while (av_fifo_size(ifilter->frame_queue)) {
AVFrame *frame;
- av_fifo_generic_read(fg->inputs[j]->frame_queue, &frame,
+ av_fifo_generic_read(ifilter->frame_queue, &frame,
sizeof(frame), NULL);
av_frame_free(&frame);
}
- av_fifo_freep(&fg->inputs[j]->frame_queue);
- if (fg->inputs[j]->ist->sub2video.sub_queue) {
- while (av_fifo_size(fg->inputs[j]->ist->sub2video.sub_queue)) {
+ av_fifo_freep(&ifilter->frame_queue);
+ if (ist->sub2video.sub_queue) {
+ while (av_fifo_size(ist->sub2video.sub_queue)) {
AVSubtitle sub;
- av_fifo_generic_read(fg->inputs[j]->ist->sub2video.sub_queue,
+ av_fifo_generic_read(ist->sub2video.sub_queue,
&sub, sizeof(sub), NULL);
avsubtitle_free(&sub);
}
- av_fifo_freep(&fg->inputs[j]->ist->sub2video.sub_queue);
+ av_fifo_freep(&ist->sub2video.sub_queue);
}
- av_buffer_unref(&fg->inputs[j]->hw_frames_ctx);
- av_freep(&fg->inputs[j]->name);
+ av_buffer_unref(&ifilter->hw_frames_ctx);
+ av_freep(&ifilter->name);
av_freep(&fg->inputs[j]);
}
av_freep(&fg->inputs);
for (j = 0; j < fg->nb_outputs; j++) {
- av_freep(&fg->outputs[j]->name);
- av_freep(&fg->outputs[j]->formats);
- av_freep(&fg->outputs[j]->channel_layouts);
- av_freep(&fg->outputs[j]->sample_rates);
+ OutputFilter *ofilter = fg->outputs[j];
+
+ avfilter_inout_free(&ofilter->out_tmp);
+ av_freep(&ofilter->name);
+ av_freep(&ofilter->formats);
+ av_freep(&ofilter->channel_layouts);
+ av_freep(&ofilter->sample_rates);
av_freep(&fg->outputs[j]);
}
av_freep(&fg->outputs);
if (!ost)
continue;
- for (j = 0; j < ost->nb_bitstream_filters; j++)
- av_bsf_free(&ost->bsf_ctx[j]);
- av_freep(&ost->bsf_ctx);
+ av_bsf_free(&ost->bsf_ctx);
av_frame_free(&ost->filtered_frame);
av_frame_free(&ost->last_frame);
{
int ret = 0;
- /* apply the output bitstream filters, if any */
- if (ost->nb_bitstream_filters) {
- int idx;
-
- ret = av_bsf_send_packet(ost->bsf_ctx[0], eof ? NULL : pkt);
+ /* apply the output bitstream filters */
+ if (ost->bsf_ctx) {
+ ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt);
if (ret < 0)
goto finish;
-
- eof = 0;
- idx = 1;
- while (idx) {
- /* get a packet from the previous filter up the chain */
- ret = av_bsf_receive_packet(ost->bsf_ctx[idx - 1], pkt);
- if (ret == AVERROR(EAGAIN)) {
- ret = 0;
- idx--;
- continue;
- } else if (ret == AVERROR_EOF) {
- eof = 1;
- } else if (ret < 0)
- goto finish;
-
- /* send it to the next filter down the chain or to the muxer */
- if (idx < ost->nb_bitstream_filters) {
- ret = av_bsf_send_packet(ost->bsf_ctx[idx], eof ? NULL : pkt);
- if (ret < 0)
- goto finish;
- idx++;
- eof = 0;
- } else if (eof)
- goto finish;
- else
- write_packet(of, pkt, ost, 0);
- }
+ while ((ret = av_bsf_receive_packet(ost->bsf_ctx, pkt)) >= 0)
+ write_packet(of, pkt, ost, 0);
+ if (ret == AVERROR(EAGAIN))
+ ret = 0;
} else if (!eof)
write_packet(of, pkt, ost, 0);
av_log(ist->dec_ctx, AV_LOG_WARNING,
"video_delay is larger in decoder than demuxer %d > %d.\n"
"If you want to help, upload a sample "
- "of this file to ftp://upload.ffmpeg.org/incoming/ "
+ "of this file to https://streams.videolan.org/upload/ "
"and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n",
ist->dec_ctx->has_b_frames,
ist->st->codecpar->video_delay);
static int init_output_bsfs(OutputStream *ost)
{
- AVBSFContext *ctx;
- int i, ret;
+ AVBSFContext *ctx = ost->bsf_ctx;
+ int ret;
- if (!ost->nb_bitstream_filters)
+ if (!ctx)
return 0;
- for (i = 0; i < ost->nb_bitstream_filters; i++) {
- ctx = ost->bsf_ctx[i];
-
- ret = avcodec_parameters_copy(ctx->par_in,
- i ? ost->bsf_ctx[i - 1]->par_out : ost->st->codecpar);
- if (ret < 0)
- return ret;
+ ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar);
+ if (ret < 0)
+ return ret;
- ctx->time_base_in = i ? ost->bsf_ctx[i - 1]->time_base_out : ost->st->time_base;
+ ctx->time_base_in = ost->st->time_base;
- ret = av_bsf_init(ctx);
- if (ret < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n",
- ost->bsf_ctx[i]->filter->name);
- return ret;
- }
+ ret = av_bsf_init(ctx);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n",
+ ctx->filter->name);
+ return ret;
}
- ctx = ost->bsf_ctx[ost->nb_bitstream_filters - 1];
ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out);
if (ret < 0)
return ret;
-
ost->st->time_base = ctx->time_base_out;
return 0;
int ret;
InputFile *f = input_files[i];
- if (nb_input_files == 1)
+ if (f->thread_queue_size < 0)
+ f->thread_queue_size = (nb_input_files > 1 ? 8 : 0);
+ if (!f->thread_queue_size)
return 0;
if (f->ctx->pb ? !f->ctx->pb->seekable :
}
#if HAVE_THREADS
- if (nb_input_files > 1)
+ if (f->thread_queue_size)
return get_input_packet_mt(f, pkt);
#endif
return av_read_frame(f->ctx, pkt);
av_freep(&ost->enc_ctx->stats_in);
}
total_packets_written += ost->packets_written;
+ if (!ost->packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM)) {
+ av_log(NULL, AV_LOG_FATAL, "Empty output on stream %d.\n", i);
+ exit_program(1);
+ }
}
if (!total_packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT)) {
}
}
- av_buffer_unref(&hw_device_ctx);
hw_device_free_all();
/* finished ! */