History

Merge commit '3b266da3d35f3f7a61258b78384dfe920d875d29'

* commit '3b266da3d35f3f7a61258b78384dfe920d875d29': avconv: add support for complex filtergraphs. avconv: make filtergraphs global. avconv: move filtered_frame from InputStream to OutputStream. avconv: don't set output width/height directly from input value. avconv: move resample_{width,height,pix_fmt} to InputStream. avconv: remove a useless variable from OutputStream. avconv: get output pixel format from lavfi. graphparser: fix the order in which unlabeled input links are returned. avconv: change {input,output}_{streams,files} into arrays of pointers. avconv: don't pass input/output streams to some functions. Conflicts: cmdutils.c cmdutils.h doc/ffmpeg.texi ffmpeg.c ffplay.c

Michael Niedermayer committed 14 years ago

Commit 47787832 parents dcd207c 3b266da11 files · +924 −415Browse files

Unified · Split

11 files
  1. cmdutils.h +1 −0
  2. doc/ffmpeg.texi +46 −1
  3. doc/filters.texi +1 −0
  4. ffmpeg.c +864 −352
  5. ffplay.c +1 −1
  6. libavfilter/graphparser.c +1 −1
  7. libavfilter/sink_buffer.c +7 −3
  8. tests/codec-regression.sh +3 −3
  9. tests/ref/seek/mpeg2reuse_mpg +0 −46
  10. tests/ref/vsynth1/mpeg2thread_ilace +0 −4
  11. tests/ref/vsynth2/mpeg2thread_ilace +0 −4
cmdutils.h+1−0
@@ -370,6 +370,7 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size); · 369 unmodified lines
370FILE *get_preset_file(char *filename, size_t filename_size,370FILE *get_preset_file(char *filename, size_t filename_size,
371 const char *preset_name, int is_path, const char *codec_name);371 const char *preset_name, int is_path, const char *codec_name);
372 372
373
373/**374/**
374 * Do all the necessary cleanup and abort.375 * Do all the necessary cleanup and abort.
375 * This function is implemented in the avtools, not cmdutils.376 * This function is implemented in the avtools, not cmdutils.
doc/ffmpeg.texi+46−1
@@ -224,6 +224,9 @@ codec-dependent. · 223 unmodified lines
224@var{filter_graph} is a description of the filter graph to apply to224@var{filter_graph} is a description of the filter graph to apply to
225the stream. Use @code{-filters} to show all the available filters225the stream. Use @code{-filters} to show all the available filters
226(including also sources and sinks).226(including also sources and sinks).
227
228See also the @option{-filter_complex} option if you want to create filter graphs
229with multiple inputs and/or outputs.
227@item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})230@item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
228Specify the preset for matching stream(s).231Specify the preset for matching stream(s).
229 232
@@ -522,7 +525,7 @@ Synchronize read on input. · 292 unmodified lines
522@section Advanced options525@section Advanced options
523 526
524@table @option527@table @option
525@item -map [-]@var{input_file_id}[:@var{stream_specifier}][,@var{sync_file_id}[:@var{stream_specifier}]] (@emph{output})528@item -map [-]@var{input_file_id}[:@var{stream_specifier}][,@var{sync_file_id}[:@var{stream_specifier}]] | @var{[linklabel]} (@emph{output})
526 529
527Designate one or more input streams as a source for the output file. Each input530Designate one or more input streams as a source for the output file. Each input
528stream is identified by the input file index @var{input_file_id} and531stream is identified by the input file index @var{input_file_id} and
@@ -538,6 +541,10 @@ the source for output stream 1, etc. · 9 unmodified lines
538A @code{-} character before the stream identifier creates a "negative" mapping.541A @code{-} character before the stream identifier creates a "negative" mapping.
539It disables matching streams from already created mappings.542It disables matching streams from already created mappings.
540 543
544An alternative @var{[linklabel]} form will map outputs from complex filter
545graphs (see the @option{-filter_complex} option) to the output file.
546@var{linklabel} must correspond to a defined output link label in the graph.
547
541For example, to map ALL streams from the first input file to output548For example, to map ALL streams from the first input file to output
542@example549@example
543ffmpeg -i INPUT -map 0 output550ffmpeg -i INPUT -map 0 output
@@ -832,6 +839,44 @@ Specify Timecode for writing. @var{SEP} is ':' for non drop timecode and ';' · 288 unmodified lines
832@example839@example
833ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg840ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
834@end example841@end example
842
843@item -filter_complex @var{filtergraph} (@emph{global})
844Define a complex filter graph, i.e. one with arbitrary number of inputs and/or
845outputs. For simple graphs -- those with one input and one output of the same
846type -- see the @option{-filter} options. @var{filtergraph} is a description of
847the filter graph, as described in @ref{Filtergraph syntax}.
848
849Input link labels must refer to input streams using the
850@code{[file_index:stream_specifier]} syntax (i.e. the same as @option{-map}
851uses). If @var{stream_specifier} matches multiple streams, the first one will be
852used. An unlabeled input will be connected to the first unused input stream of
853the matching type.
854
855Output link labels are referred to with @option{-map}. Unlabeled outputs are
856added to the first output file.
857
858For example, to overlay an image over video
859@example
860ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
861'[out]' out.mkv
862@end example
863Here @code{[0:v]} refers to the first video stream in the first input file,
864which is linked to the first (main) input of the overlay filter. Similarly the
865first video stream in the second input is linked to the second (overlay) input
866of overlay.
867
868Assuming there is only one video stream in each input file, we can omit input
869labels, so the above is equivalent to
870@example
871ffmpeg -i video.mkv -i image.png -filter_complex 'overlay[out]' -map
872'[out]' out.mkv
873@end example
874
875Furthermore we can omit the output label and the single output from the filter
876graph will be added to the output file automatically, so we can simply write
877@example
878ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
879@end example
835@end table880@end table
836 881
837@section Preset files882@section Preset files
doc/filters.texi+1−0
@@ -14,6 +14,7 @@ number of input and output pads of the filter. · 13 unmodified lines
14A filter with no input pads is called a "source", a filter with no14A filter with no input pads is called a "source", a filter with no
15output pads is called a "sink".15output pads is called a "sink".
16 16
17@anchor{Filtergraph syntax}
17@section Filtergraph syntax18@section Filtergraph syntax
18 19
19A filtergraph can be represented using a textual representation, which20A filtergraph can be represented using a textual representation, which
ffmpeg.c+864−352
@@ -108,6 +108,7 @@ typedef struct StreamMap { · 107 unmodified lines
108 int stream_index;108 int stream_index;
109 int sync_file_index;109 int sync_file_index;
110 int sync_stream_index;110 int sync_stream_index;
111 char *linklabel; /** name of an output link, for mapping lavfi outputs */
111} StreamMap;112} StreamMap;
112 113
113typedef struct {114typedef struct {
@@ -175,6 +176,33 @@ static unsigned int allocated_async_buf_size; · 61 unmodified lines
175 176
176#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"177#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
177 178
179typedef struct InputFilter {
180 AVFilterContext *filter;
181 struct InputStream *ist;
182 struct FilterGraph *graph;
183} InputFilter;
184
185typedef struct OutputFilter {
186 AVFilterContext *filter;
187 struct OutputStream *ost;
188 struct FilterGraph *graph;
189
190 /* temporary storage until stream maps are processed */
191 AVFilterInOut *out_tmp;
192} OutputFilter;
193
194typedef struct FilterGraph {
195 int index;
196 const char *graph_desc;
197
198 AVFilterGraph *graph;
199
200 InputFilter **inputs;
201 int nb_inputs;
202 OutputFilter **outputs;
203 int nb_outputs;
204} FilterGraph;
205
178typedef struct FrameBuffer {206typedef struct FrameBuffer {
179 uint8_t *base[4];207 uint8_t *base[4];
180 uint8_t *data[4];208 uint8_t *data[4];
@@ -195,7 +223,6 @@ typedef struct InputStream { · 14 unmodified lines
195 int decoding_needed; /* true if the packets must be decoded in 'raw_fifo' */223 int decoding_needed; /* true if the packets must be decoded in 'raw_fifo' */
196 AVCodec *dec;224 AVCodec *dec;
197 AVFrame *decoded_frame;225 AVFrame *decoded_frame;
198 AVFrame *filtered_frame;
199 226
200 int64_t start; /* time when read started */227 int64_t start; /* time when read started */
201 /* predicted dts of the next packet read for this stream or (when there are228 /* predicted dts of the next packet read for this stream or (when there are
@@ -211,9 +238,18 @@ typedef struct InputStream { · 9 unmodified lines
211 int showed_multi_packet_warning;238 int showed_multi_packet_warning;
212 AVDictionary *opts;239 AVDictionary *opts;
213 240
241 int resample_height;
242 int resample_width;
243 int resample_pix_fmt;
244
214 /* a pool of free buffers for decoded data */245 /* a pool of free buffers for decoded data */
215 FrameBuffer *buffer_pool;246 FrameBuffer *buffer_pool;
216 int dr1;247 int dr1;
248
249 /* decoded data from this stream goes into all those filters
250 * currently video only */
251 InputFilter **filters;
252 int nb_filters;
217} InputStream;253} InputStream;
218 254
219typedef struct InputFile {255typedef struct InputFile {
@@ -242,17 +278,15 @@ typedef struct OutputStream { · 22 unmodified lines
242 AVCodec *enc;278 AVCodec *enc;
243 int64_t max_frames;279 int64_t max_frames;
244 AVFrame *output_frame;280 AVFrame *output_frame;
281 AVFrame *filtered_frame;
245 282
246 /* video only */283 /* video only */
247 int video_resample;
248 int resample_height;
249 int resample_width;
250 int resample_pix_fmt;
251 AVRational frame_rate;284 AVRational frame_rate;
252 int force_fps;285 int force_fps;
253 int top_field_first;286 int top_field_first;
254 287
255 float frame_aspect_ratio;288 float frame_aspect_ratio;
289 float last_quality;
256 290
257 /* forced key frames */291 /* forced key frames */
258 int64_t *forced_kf_pts;292 int64_t *forced_kf_pts;
@@ -272,10 +306,8 @@ typedef struct OutputStream { · 13 unmodified lines
272 306
273 SwrContext *swr;307 SwrContext *swr;
274 308
275 AVFilterContext *output_video_filter;309 OutputFilter *filter;
276 AVFilterContext *input_video_filter;
277 char *avfilter;310 char *avfilter;
278 AVFilterGraph *graph;
279 311
280 int64_t sws_flags;312 int64_t sws_flags;
281 int64_t swr_dither_method;313 int64_t swr_dither_method;
@@ -285,6 +317,8 @@ typedef struct OutputStream { · 3 unmodified lines
285 int stream_copy;317 int stream_copy;
286 const char *attachment_filename;318 const char *attachment_filename;
287 int copy_initial_nonkeyframes;319 int copy_initial_nonkeyframes;
320
321 enum PixelFormat pix_fmts[2];
288} OutputStream;322} OutputStream;
289 323
290 324
@@ -304,15 +338,18 @@ typedef struct OutputFile { · 13 unmodified lines
304 uint64_t limit_filesize; /* filesize limit expressed in bytes */338 uint64_t limit_filesize; /* filesize limit expressed in bytes */
305} OutputFile;339} OutputFile;
306 340
307static InputStream *input_streams = NULL;341static InputStream **input_streams = NULL;
308static int nb_input_streams = 0;342static int nb_input_streams = 0;
309static InputFile *input_files = NULL;343static InputFile **input_files = NULL;
310static int nb_input_files = 0;344static int nb_input_files = 0;
311 345
312static OutputStream *output_streams = NULL;346static OutputStream **output_streams = NULL;
313static int nb_output_streams = 0;347static int nb_output_streams = 0;
314static OutputFile *output_files = NULL;348static OutputFile **output_files = NULL;
315static int nb_output_files = 0;349static int nb_output_files = 0;
350
351static FilterGraph **filtergraphs;
352int nb_filtergraphs;
316 353
317typedef struct OptionsContext {354typedef struct OptionsContext {
318 /* input/output options */355 /* input/output options */
@@ -457,6 +494,7 @@ static void reset_options(OptionsContext *o, int is_input) · 138 unmodified lines
457{494{
458 const OptionDef *po = options;495 const OptionDef *po = options;
459 OptionsContext bak= *o;496 OptionsContext bak= *o;
497 int i;
460 498
461 /* all OPT_SPEC and OPT_STRING can be freed in generic way */499 /* all OPT_SPEC and OPT_STRING can be freed in generic way */
462 while (po->name) {500 while (po->name) {
@@ -477,6 +515,8 @@ static void reset_options(OptionsContext *o, int is_input) · 14 unmodified lines
477 po++;515 po++;
478 }516 }
479 517
518 for (i = 0; i < o->nb_stream_maps; i++)
519 av_freep(&o->stream_maps[i].linklabel);
480 av_freep(&o->stream_maps);520 av_freep(&o->stream_maps);
481 av_freep(&o->audio_channel_maps);521 av_freep(&o->audio_channel_maps);
482 av_freep(&o->streamid_map);522 av_freep(&o->streamid_map);
@@ -627,20 +667,64 @@ static void filter_release_buffer(AVFilterBuffer *fb) · 144 unmodified lines
627 unref_buffer(buf->ist, buf);667 unref_buffer(buf->ist, buf);
628}668}
629 669
630static int configure_video_filters(InputStream *ist, OutputStream *ost)670static void choose_pixel_fmt(AVStream *st, AVCodec *codec)
631{671{
672 if (codec && codec->pix_fmts) {
673 const enum PixelFormat *p = codec->pix_fmts;
674 int has_alpha= av_pix_fmt_descriptors[st->codec->pix_fmt].nb_components % 2 == 0;
675 enum PixelFormat best= PIX_FMT_NONE;
676 if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
677 if (st->codec->codec_id == CODEC_ID_MJPEG) {
678 p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };
679 } else if (st->codec->codec_id == CODEC_ID_LJPEG) {
680 p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,
681 PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };
682 }
683 }
684 for (; *p != PIX_FMT_NONE; p++) {
685 best= avcodec_find_best_pix_fmt2(best, *p, st->codec->pix_fmt, has_alpha, NULL);
686 if (*p == st->codec->pix_fmt)
687 break;
688 }
689 if (*p == PIX_FMT_NONE) {
690 if (st->codec->pix_fmt != PIX_FMT_NONE)
691 av_log(NULL, AV_LOG_WARNING,
692 "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
693 av_pix_fmt_descriptors[st->codec->pix_fmt].name,
694 codec->name,
695 av_pix_fmt_descriptors[best].name);
696 st->codec->pix_fmt = best;
697 }
698 }
699}
700
701static const enum PixelFormat *choose_pixel_fmts(OutputStream *ost)
702{
703 if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {
704 ost->pix_fmts[0] = ost->st->codec->pix_fmt;
705 return ost->pix_fmts;
706 } else if (ost->enc->pix_fmts)
707 return ost->enc->pix_fmts;
708 else
709 return NULL;
710}
711
712static int configure_video_filters(FilterGraph *fg)
713{
714 InputStream *ist = fg->inputs[0]->ist;
715 OutputStream *ost = fg->outputs[0]->ost;
632 AVFilterContext *last_filter, *filter;716 AVFilterContext *last_filter, *filter;
633 /** filter graph containing all filters including input & output */717 /** filter graph containing all filters including input & output */
634 AVCodecContext *codec = ost->st->codec;718 AVCodecContext *codec = ost->st->codec;
635 AVCodecContext *icodec = ist->st->codec;719 enum PixelFormat *pix_fmts = choose_pixel_fmts(ost);
636 enum PixelFormat pix_fmts[] = { codec->pix_fmt, PIX_FMT_NONE };
637 AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();720 AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
638 AVRational sample_aspect_ratio;721 AVRational sample_aspect_ratio;
639 char args[255];722 char args[255];
640 int ret;723 int ret;
641 724
642 ost->graph = avfilter_graph_alloc();725 avfilter_graph_free(&fg->graph);
643 if (!ost->graph)726 fg->graph = avfilter_graph_alloc();
727 if (!fg->graph)
644 return AVERROR(ENOMEM);728 return AVERROR(ENOMEM);
645 729
646 if (ist->st->sample_aspect_ratio.num) {730 if (ist->st->sample_aspect_ratio.num) {
@@ -650,34 +734,35 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) · 3 unmodified lines
650 734
651 snprintf(args, 255, "%d:%d:%d:%d:%d:%d:%d:flags=%d", ist->st->codec->width,735 snprintf(args, 255, "%d:%d:%d:%d:%d:%d:%d:flags=%d", ist->st->codec->width,
652 ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE,736 ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE,
653 sample_aspect_ratio.num, sample_aspect_ratio.den, SWS_BILINEAR + ((icodec->flags&CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));737 sample_aspect_ratio.num, sample_aspect_ratio.den, SWS_BILINEAR + ((ist->st->codec->flags&CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
654 738
655 ret = avfilter_graph_create_filter(&ost->input_video_filter, avfilter_get_by_name("buffer"),739 ret = avfilter_graph_create_filter(&fg->inputs[0]->filter,
656 "src", args, NULL, ost->graph);740 avfilter_get_by_name("buffer"),
741 "src", args, NULL, fg->graph);
657 if (ret < 0)742 if (ret < 0)
658 return ret;743 return ret;
659 744
660#if FF_API_OLD_VSINK_API745#if FF_API_OLD_VSINK_API
661 ret = avfilter_graph_create_filter(&ost->output_video_filter, avfilter_get_by_name("buffersink"),746 ret = avfilter_graph_create_filter(&fg->outputs[0]->filter, avfilter_get_by_name("buffersink"),
662 "out", NULL, pix_fmts, ost->graph);747 "out", NULL, pix_fmts, fg->graph);
663#else748#else
664 buffersink_params->pixel_fmts = pix_fmts;749 buffersink_params->pixel_fmts = pix_fmts;
665 ret = avfilter_graph_create_filter(&ost->output_video_filter, avfilter_get_by_name("buffersink"),750 ret = avfilter_graph_create_filter(&fg->outputs[0]->filter, avfilter_get_by_name("buffersink"),
666 "out", NULL, buffersink_params, ost->graph);751 "out", NULL, buffersink_params, fg->graph);
667#endif752#endif
668 av_freep(&buffersink_params);753 av_freep(&buffersink_params);
669 754
670 if (ret < 0)755 if (ret < 0)
671 return ret;756 return ret;
672 last_filter = ost->input_video_filter;757 last_filter = fg->inputs[0]->filter;
673 758
674 if (codec->width != icodec->width || codec->height != icodec->height) {759 if (codec->width || codec->height) {
675 snprintf(args, 255, "%d:%d:flags=0x%X",760 snprintf(args, 255, "%d:%d:flags=0x%X",
676 codec->width,761 codec->width,
677 codec->height,762 codec->height,
678 (unsigned)ost->sws_flags);763 (unsigned)ost->sws_flags);
679 if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),764 if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
680 NULL, args, NULL, ost->graph)) < 0)765 NULL, args, NULL, fg->graph)) < 0)
681 return ret;766 return ret;
682 if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)767 if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
683 return ret;768 return ret;
@@ -685,7 +770,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) · 1 unmodified line
685 }770 }
686 771
687 snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);772 snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);
688 ost->graph->scale_sws_opts = av_strdup(args);773 fg->graph->scale_sws_opts = av_strdup(args);
689 774
690 if (ost->avfilter) {775 if (ost->avfilter) {
691 AVFilterInOut *outputs = avfilter_inout_alloc();776 AVFilterInOut *outputs = avfilter_inout_alloc();
@@ -697,31 +782,258 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) · 5 unmodified lines
697 outputs->next = NULL;782 outputs->next = NULL;
698 783
699 inputs->name = av_strdup("out");784 inputs->name = av_strdup("out");
700 inputs->filter_ctx = ost->output_video_filter;785 inputs->filter_ctx = fg->outputs[0]->filter;
701 inputs->pad_idx = 0;786 inputs->pad_idx = 0;
702 inputs->next = NULL;787 inputs->next = NULL;
703 788
704 if ((ret = avfilter_graph_parse(ost->graph, ost->avfilter, &inputs, &outputs, NULL)) < 0)789 if ((ret = avfilter_graph_parse(fg->graph, ost->avfilter, &inputs, &outputs, NULL)) < 0)
705 return ret;790 return ret;
706 av_freep(&ost->avfilter);791 av_freep(&ost->avfilter);
707 } else {792 } else {
708 if ((ret = avfilter_link(last_filter, 0, ost->output_video_filter, 0)) < 0)793 if ((ret = avfilter_link(last_filter, 0, fg->outputs[0]->filter, 0)) < 0)
709 return ret;794 return ret;
710 }795 }
711 796
712 if ((ret = avfilter_graph_config(ost->graph, NULL)) < 0)797 if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
713 return ret;798 return ret;
714 799
715 codec->width = ost->output_video_filter->inputs[0]->w;800 ost->filter = fg->outputs[0];
716 codec->height = ost->output_video_filter->inputs[0]->h;
717 codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
718 ost->frame_aspect_ratio ? // overridden by the -aspect cli option
719 av_d2q(ost->frame_aspect_ratio * codec->height/codec->width, 255) :
720 ost->output_video_filter->inputs[0]->sample_aspect_ratio;
721 801
722 return 0;802 return 0;
723}803}
724 804
805static FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost)
806{
807 FilterGraph *fg = av_mallocz(sizeof(*fg));
808
809 if (!fg)
810 exit_program(1);
811 fg->index = nb_filtergraphs;
812
813 fg->outputs = grow_array(fg->outputs, sizeof(*fg->outputs), &fg->nb_outputs,
814 fg->nb_outputs + 1);
815 if (!(fg->outputs[0] = av_mallocz(sizeof(*fg->outputs[0]))))
816 exit_program(1);
817 fg->outputs[0]->ost = ost;
818 fg->outputs[0]->graph = fg;
819
820 fg->inputs = grow_array(fg->inputs, sizeof(*fg->inputs), &fg->nb_inputs,
821 fg->nb_inputs + 1);
822 if (!(fg->inputs[0] = av_mallocz(sizeof(*fg->inputs[0]))))
823 exit_program(1);
824 fg->inputs[0]->ist = ist;
825 fg->inputs[0]->graph = fg;
826
827 ist->filters = grow_array(ist->filters, sizeof(*ist->filters),
828 &ist->nb_filters, ist->nb_filters + 1);
829 ist->filters[ist->nb_filters - 1] = fg->inputs[0];
830
831 filtergraphs = grow_array(filtergraphs, sizeof(*filtergraphs),
832 &nb_filtergraphs, nb_filtergraphs + 1);
833 filtergraphs[nb_filtergraphs - 1] = fg;
834
835 return fg;
836}
837
838static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
839{
840 InputStream *ist;
841 enum AVMediaType type = in->filter_ctx->input_pads[in->pad_idx].type;
842 int i;
843
844 // TODO: support other filter types
845 if (type != AVMEDIA_TYPE_VIDEO) {
846 av_log(NULL, AV_LOG_FATAL, "Only video filters supported currently.\n");
847 exit_program(1);
848 }
849
850 if (in->name) {
851 AVFormatContext *s;
852 AVStream *st = NULL;
853 char *p;
854 int file_idx = strtol(in->name, &p, 0);
855
856 if (file_idx < 0 || file_idx > nb_input_files) {
857 av_log(NULL, AV_LOG_FATAL, "Invalid file index %d in filtegraph description %s.\n",
858 file_idx, fg->graph_desc);
859 exit_program(1);
860 }
861 s = input_files[file_idx]->ctx;
862
863 for (i = 0; i < s->nb_streams; i++) {
864 if (s->streams[i]->codec->codec_type != type)
865 continue;
866 if (check_stream_specifier(s, s->streams[i], *p == ':' ? p + 1 : p) == 1) {
867 st = s->streams[i];
868 break;
869 }
870 }
871 if (!st) {
872 av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
873 "matches no streams.\n", p, fg->graph_desc);
874 exit_program(1);
875 }
876 ist = input_streams[input_files[file_idx]->ist_index + st->index];
877 } else {
878 /* find the first unused stream of corresponding type */
879 for (i = 0; i < nb_input_streams; i++) {
880 ist = input_streams[i];
881 if (ist->st->codec->codec_type == type && ist->discard)
882 break;
883 }
884 if (i == nb_input_streams) {
885 av_log(NULL, AV_LOG_FATAL, "Cannot find a matching stream for "
886 "unlabeled input pad %d on filter %s", in->pad_idx,
887 in->filter_ctx->name);
888 exit_program(1);
889 }
890 }
891 ist->discard = 0;
892 ist->decoding_needed = 1;
893 ist->st->discard = AVDISCARD_NONE;
894
895 fg->inputs = grow_array(fg->inputs, sizeof(*fg->inputs),
896 &fg->nb_inputs, fg->nb_inputs + 1);
897 if (!(fg->inputs[fg->nb_inputs - 1] = av_mallocz(sizeof(*fg->inputs[0]))))
898 exit_program(1);
899 fg->inputs[fg->nb_inputs - 1]->ist = ist;
900 fg->inputs[fg->nb_inputs - 1]->graph = fg;
901
902 ist->filters = grow_array(ist->filters, sizeof(*ist->filters),
903 &ist->nb_filters, ist->nb_filters + 1);
904 ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1];
905}
906
907static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
908{
909 AVCodecContext *codec = ofilter->ost->st->codec;
910 AVFilterContext *last_filter = out->filter_ctx;
911 int pad_idx = out->pad_idx;
912 int ret;
913 enum PixelFormat *pix_fmts = choose_pixel_fmts(ofilter->ost);
914 AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
915
916#if FF_API_OLD_VSINK_API
917 ret = avfilter_graph_create_filter(&ofilter->filter, avfilter_get_by_name("buffersink"),
918 "out", NULL, pix_fmts, fg->graph);
919#else
920 buffersink_params->pixel_fmts = pix_fmts;
921 ret = avfilter_graph_create_filter(&ofilter->filter, avfilter_get_by_name("buffersink"),
922 "out", NULL, buffersink_params, fg->graph);
923#endif
924 av_freep(&buffersink_params);
925
926 if (ret < 0)
927 return ret;
928
929 if (codec->width || codec->height) {
930 char args[255];
931 snprintf(args, sizeof(args), "%d:%d:flags=0x%X",
932 codec->width,
933 codec->height,
934 (unsigned)ofilter->ost->sws_flags);
935 if ((ret = avfilter_graph_create_filter(&last_filter, avfilter_get_by_name("scale"),
936 NULL, args, NULL, fg->graph)) < 0)
937 return ret;
938 if ((ret = avfilter_link(out->filter_ctx, out->pad_idx, last_filter, 0)) < 0)
939 return ret;
940 pad_idx = 0;
941 }
942
943 if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
944 return ret;
945
946 return 0;
947}
948
949static int configure_complex_filter(FilterGraph *fg)
950{
951 AVFilterInOut *inputs, *outputs, *cur;
952 int ret, i, init = !fg->graph;
953
954 avfilter_graph_free(&fg->graph);
955 if (!(fg->graph = avfilter_graph_alloc()))
956 return AVERROR(ENOMEM);
957
958 if ((ret = avfilter_graph_parse2(fg->graph, fg->graph_desc, &inputs, &outputs)) < 0)
959 return ret;
960
961 for (cur = inputs; init && cur; cur = cur->next)
962 init_input_filter(fg, cur);
963
964 for (cur = inputs, i = 0; cur; cur = cur->next, i++) {
965 InputFilter *ifilter = fg->inputs[i];
966 InputStream *ist = ifilter->ist;
967 AVRational sar;
968 char args[255];
969
970 sar = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
971 ist->st->codec->sample_aspect_ratio;
972 snprintf(args, sizeof(args), "%d:%d:%d:%d:%d:%d:%d", ist->st->codec->width,
973 ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE,
974 sar.num, sar.den);
975
976 if ((ret = avfilter_graph_create_filter(&ifilter->filter,
977 avfilter_get_by_name("buffer"), cur->name,
978 args, NULL, fg->graph)) < 0)
979 return ret;
980 if ((ret = avfilter_link(ifilter->filter, 0,
981 cur->filter_ctx, cur->pad_idx)) < 0)
982 return ret;
983 }
984 avfilter_inout_free(&inputs);
985
986 if (!init) {
987 /* we already know the mappings between lavfi outputs and output streams,
988 * so we can finish the setup */
989 for (cur = outputs, i = 0; cur; cur = cur->next, i++)
990 configure_output_filter(fg, fg->outputs[i], cur);
991 avfilter_inout_free(&outputs);
992
993 if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
994 return ret;
995 } else {
996 /* wait until output mappings are processed */
997 for (cur = outputs; cur;) {
998 fg->outputs = grow_array(fg->outputs, sizeof(*fg->outputs),
999 &fg->nb_outputs, fg->nb_outputs + 1);
1000 if (!(fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0]))))
1001 exit_program(1);
1002 fg->outputs[fg->nb_outputs - 1]->graph = fg;
1003 fg->outputs[fg->nb_outputs - 1]->out_tmp = cur;
1004 cur = cur->next;
1005 fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL;
1006 }
1007 }
1008
1009 return 0;
1010}
1011
1012static int configure_complex_filters(void)
1013{
1014 int i, ret = 0;
1015
1016 for (i = 0; i < nb_filtergraphs; i++)
1017 if (!filtergraphs[i]->graph &&
1018 (ret = configure_complex_filter(filtergraphs[i])) < 0)
1019 return ret;
1020 return 0;
1021}
1022
1023static int configure_filtergraph(FilterGraph *fg)
1024{
1025 return fg->graph_desc ? configure_complex_filter(fg) : configure_video_filters(fg);
1026}
1027
1028static int ist_in_filtergraph(FilterGraph *fg, InputStream *ist)
1029{
1030 int i;
1031 for (i = 0; i < fg->nb_inputs; i++)
1032 if (fg->inputs[i]->ist == ist)
1033 return 1;
1034 return 0;
1035}
1036
725static void term_exit(void)1037static void term_exit(void)
726{1038{
727 av_log(NULL, AV_LOG_QUIET, "%s", "");1039 av_log(NULL, AV_LOG_QUIET, "%s", "");
@@ -839,40 +1151,57 @@ static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; · 111 unmodified lines
839 1151
840void av_noreturn exit_program(int ret)1152void av_noreturn exit_program(int ret)
841{1153{
842 int i;1154 int i, j;
1155
1156 for (i = 0; i < nb_filtergraphs; i++) {
1157 avfilter_graph_free(&filtergraphs[i]->graph);
1158 for (j = 0; j < filtergraphs[i]->nb_inputs; j++)
1159 av_freep(&filtergraphs[i]->inputs[j]);
1160 av_freep(&filtergraphs[i]->inputs);
1161 for (j = 0; j < filtergraphs[i]->nb_outputs; j++)
1162 av_freep(&filtergraphs[i]->outputs[j]);
1163 av_freep(&filtergraphs[i]->outputs);
1164 av_freep(&filtergraphs[i]);
1165 }
1166 av_freep(&filtergraphs);
843 1167
844 /* close files */1168 /* close files */
845 for (i = 0; i < nb_output_files; i++) {1169 for (i = 0; i < nb_output_files; i++) {
846 AVFormatContext *s = output_files[i].ctx;1170 AVFormatContext *s = output_files[i]->ctx;
847 if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)1171 if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
848 avio_close(s->pb);1172 avio_close(s->pb);
849 avformat_free_context(s);1173 avformat_free_context(s);
850 av_dict_free(&output_files[i].opts);1174 av_dict_free(&output_files[i]->opts);
1175 av_freep(&output_files[i]);
851 }1176 }
852 for (i = 0; i < nb_output_streams; i++) {1177 for (i = 0; i < nb_output_streams; i++) {
853 AVBitStreamFilterContext *bsfc = output_streams[i].bitstream_filters;1178 AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters;
854 while (bsfc) {1179 while (bsfc) {
855 AVBitStreamFilterContext *next = bsfc->next;1180 AVBitStreamFilterContext *next = bsfc->next;
856 av_bitstream_filter_close(bsfc);1181 av_bitstream_filter_close(bsfc);
857 bsfc = next;1182 bsfc = next;
858 }1183 }
859 output_streams[i].bitstream_filters = NULL;1184 output_streams[i]->bitstream_filters = NULL;
860 1185
861 if (output_streams[i].output_frame) {1186 if (output_streams[i]->output_frame) {
862 AVFrame *frame = output_streams[i].output_frame;1187 AVFrame *frame = output_streams[i]->output_frame;
863 if (frame->extended_data != frame->data)1188 if (frame->extended_data != frame->data)
864 av_freep(&frame->extended_data);1189 av_freep(&frame->extended_data);
865 av_freep(&frame);1190 av_freep(&frame);
866 }1191 }
1192 av_freep(&output_streams[i]->filtered_frame);
1193 av_freep(&output_streams[i]);
867 }1194 }
868 for (i = 0; i < nb_input_files; i++) {1195 for (i = 0; i < nb_input_files; i++) {
869 avformat_close_input(&input_files[i].ctx);1196 avformat_close_input(&input_files[i]->ctx);
1197 av_freep(&input_files[i]);
870 }1198 }
871 for (i = 0; i < nb_input_streams; i++) {1199 for (i = 0; i < nb_input_streams; i++) {
872 av_freep(&input_streams[i].decoded_frame);1200 av_freep(&input_streams[i]->decoded_frame);
873 av_freep(&input_streams[i].filtered_frame);1201 av_dict_free(&input_streams[i]->opts);
874 av_dict_free(&input_streams[i].opts);1202 free_buffer_pool(input_streams[i]);
875 free_buffer_pool(&input_streams[i]);1203 av_freep(&input_streams[i]->filters);
1204 av_freep(&input_streams[i]);
876 }1205 }
877 1206
878 if (vstats_file)1207 if (vstats_file)
@@ -981,41 +1310,10 @@ static void choose_sample_rate(AVStream *st, AVCodec *codec) · 102 unmodified lines
981 }1310 }
982}1311}
983 1312
984static void choose_pixel_fmt(AVStream *st, AVCodec *codec)
985{
986 if (codec && codec->pix_fmts) {
987 const enum PixelFormat *p = codec->pix_fmts;
988 int has_alpha= av_pix_fmt_descriptors[st->codec->pix_fmt].nb_components % 2 == 0;
989 enum PixelFormat best= PIX_FMT_NONE;
990 if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
991 if (st->codec->codec_id == CODEC_ID_MJPEG) {
992 p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };
993 } else if (st->codec->codec_id == CODEC_ID_LJPEG) {
994 p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,
995 PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };
996 }
997 }
998 for (; *p != PIX_FMT_NONE; p++) {
999 best= avcodec_find_best_pix_fmt2(best, *p, st->codec->pix_fmt, has_alpha, NULL);
1000 if (*p == st->codec->pix_fmt)
1001 break;
1002 }
1003 if (*p == PIX_FMT_NONE) {
1004 if (st->codec->pix_fmt != PIX_FMT_NONE)
1005 av_log(NULL, AV_LOG_WARNING,
1006 "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
1007 av_pix_fmt_descriptors[st->codec->pix_fmt].name,
1008 codec->name,
1009 av_pix_fmt_descriptors[best].name);
1010 st->codec->pix_fmt = best;
1011 }
1012 }
1013}
1014
1015static double1313static double
1016get_sync_ipts(const OutputStream *ost, int64_t pts)1314get_sync_ipts(const OutputStream *ost, int64_t pts)
1017{1315{
1018 OutputFile *of = &output_files[ost->file_index];1316 OutputFile *of = output_files[ost->file_index];
1019 return (double)(pts - of->start_time) / AV_TIME_BASE;1317 return (double)(pts - of->start_time) / AV_TIME_BASE;
1020}1318}
1021 1319
@@ -1518,19 +1816,21 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost, · 496 unmodified lines
1518 1816
1519 1817
1520static void do_video_out(AVFormatContext *s, OutputStream *ost,1818static void do_video_out(AVFormatContext *s, OutputStream *ost,
1521 InputStream *ist, AVFrame *in_picture)1819 AVFrame *in_picture, float quality)
1522{1820{
1523 int nb_frames, i, ret, format_video_sync;1821 int nb_frames, i, ret, format_video_sync;
1524 AVCodecContext *enc;1822 AVCodecContext *enc;
1525 double sync_ipts, delta;1823 double sync_ipts, delta;
1526 double duration = 0;1824 double duration = 0;
1527 int frame_size = 0;1825 int frame_size = 0;
1528 float quality = same_quant ? in_picture->quality1826 InputStream *ist = NULL;
1529 : ost->st->codec->global_quality;1827
1828 if (ost->source_index >= 0)
1829 ist = input_streams[ost->source_index];
1530 1830
1531 enc = ost->st->codec;1831 enc = ost->st->codec;
1532 1832
1533 if (ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE) {1833 if (ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE) {
1534 duration = FFMAX(av_q2d(ist->st->time_base), av_q2d(ist->st->codec->time_base));1834 duration = FFMAX(av_q2d(ist->st->time_base), av_q2d(ist->st->codec->time_base));
1535 if(ist->st->r_frame_rate.num)1835 if(ist->st->r_frame_rate.num)
1536 duration= FFMAX(duration, 1/av_q2d(ist->st->r_frame_rate));1836 duration= FFMAX(duration, 1/av_q2d(ist->st->r_frame_rate));
@@ -1672,12 +1972,66 @@ static void do_video_out(AVFormatContext *s, OutputStream *ost, · 135 unmodified lines
1672 ost->frame_number++;1972 ost->frame_number++;
1673 }1973 }
1674 if (vstats_filename && frame_size)1974 if (vstats_filename && frame_size)
1675 do_video_stats(output_files[ost->file_index].ctx, ost, frame_size);1975 do_video_stats(output_files[ost->file_index]->ctx, ost, frame_size);
1676}1976}
1677 1977
1678static void print_report(OutputFile *output_files,1978/* check for new output on any of the filtergraphs */
1679 OutputStream *ost_table, int nb_ostreams,1979static int poll_filters(void)
1680 int is_last_report, int64_t timer_start, int64_t cur_time)1980{
1981 AVFilterBufferRef *picref;
1982 AVFrame *filtered_frame = NULL;
1983 int i, ret;
1984
1985 for (i = 0; i < nb_output_streams; i++) {
1986 OutputStream *ost = output_streams[i];
1987 OutputFile *of = output_files[ost->file_index];
1988
1989 if (!ost->filter || ost->is_past_recording_time)
1990 continue;
1991
1992 if (!ost->filtered_frame && !(ost->filtered_frame = avcodec_alloc_frame())) {
1993 return AVERROR(ENOMEM);
1994 } else
1995 avcodec_get_frame_defaults(ost->filtered_frame);
1996 filtered_frame = ost->filtered_frame;
1997
1998 while (avfilter_poll_frame(ost->filter->filter->inputs[0])) {
1999 AVRational ist_pts_tb = ost->filter->filter->inputs[0]->time_base;
2000 if ((ret = av_buffersink_get_buffer_ref(ost->filter->filter,
2001 &picref,
2002 0)) < 0) {
2003 av_log(NULL, AV_LOG_WARNING, "AV Filter told us it has a frame available but failed to output one\n");
2004 return ret;
2005 }
2006 filtered_frame->pts = av_rescale_q(picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
2007// if (ost->source_index >= 0)
2008// *filtered_frame= *input_streams[ost->source_index]->decoded_frame; //for me_threshold
2009
2010 if (of->start_time && filtered_frame->pts < of->start_time)
2011 return 0;
2012
2013 switch (ost->filter->filter->inputs[0]->type) {
2014 case AVMEDIA_TYPE_VIDEO:
2015 avfilter_fill_frame_from_video_buffer_ref(filtered_frame, picref);
2016 if (!ost->frame_aspect_ratio)
2017 ost->st->codec->sample_aspect_ratio = picref->video->sample_aspect_ratio;
2018
2019 do_video_out(of->ctx, ost, filtered_frame,
2020 same_quant ? ost->last_quality :
2021 ost->st->codec->global_quality);
2022 break;
2023 default:
2024 // TODO support audio/subtitle filters
2025 av_assert0(0);
2026 }
2027
2028 avfilter_unref_buffer(picref);
2029 }
2030 }
2031 return 0;
2032}
2033
2034static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time)
1681{2035{
1682 char buf[1024];2036 char buf[1024];
1683 OutputStream *ost;2037 OutputStream *ost;
@@ -1705,7 +2059,7 @@ static void print_report(OutputFile *output_files, · 21 unmodified lines
1705 }2059 }
1706 2060
1707 2061
1708 oc = output_files[0].ctx;2062 oc = output_files[0]->ctx;
1709 2063
1710 total_size = avio_size(oc->pb);2064 total_size = avio_size(oc->pb);
1711 if (total_size < 0) { // FIXME improve avio_size() so it works with non seekable output too2065 if (total_size < 0) { // FIXME improve avio_size() so it works with non seekable output too
@@ -1716,9 +2070,9 @@ static void print_report(OutputFile *output_files, · 4 unmodified lines
1716 2070
1717 buf[0] = '\0';2071 buf[0] = '\0';
1718 vid = 0;2072 vid = 0;
1719 for (i = 0; i < nb_ostreams; i++) {2073 for (i = 0; i < nb_output_streams; i++) {
1720 float q = -1;2074 float q = -1;
1721 ost = &ost_table[i];2075 ost = output_streams[i];
1722 enc = ost->st->codec;2076 enc = ost->st->codec;
1723 if (!ost->stream_copy && enc->coded_frame)2077 if (!ost->stream_copy && enc->coded_frame)
1724 q = enc->coded_frame->quality / (float)FF_QP2LAMBDA;2078 q = enc->coded_frame->quality / (float)FF_QP2LAMBDA;
@@ -1811,14 +2165,14 @@ static void print_report(OutputFile *output_files, · 86 unmodified lines
1811 }2165 }
1812}2166}
1813 2167
1814static void flush_encoders(OutputStream *ost_table, int nb_ostreams)2168static void flush_encoders(void)
1815{2169{
1816 int i, ret;2170 int i, ret;
1817 2171
1818 for (i = 0; i < nb_ostreams; i++) {2172 for (i = 0; i < nb_output_streams; i++) {
1819 OutputStream *ost = &ost_table[i];2173 OutputStream *ost = output_streams[i];
1820 AVCodecContext *enc = ost->st->codec;2174 AVCodecContext *enc = ost->st->codec;
1821 AVFormatContext *os = output_files[ost->file_index].ctx;2175 AVFormatContext *os = output_files[ost->file_index]->ctx;
1822 int stop_encoding = 0;2176 int stop_encoding = 0;
1823 2177
1824 if (!ost->encoding_needed)2178 if (!ost->encoding_needed)
@@ -1899,8 +2253,8 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams) · 74 unmodified lines
1899 */2253 */
1900static int check_output_constraints(InputStream *ist, OutputStream *ost)2254static int check_output_constraints(InputStream *ist, OutputStream *ost)
1901{2255{
1902 OutputFile *of = &output_files[ost->file_index];2256 OutputFile *of = output_files[ost->file_index];
1903 int ist_index = ist - input_streams;2257 int ist_index = input_files[ist->file_index]->ist_index + ist->st->index;
1904 2258
1905 if (ost->source_index != ist_index)2259 if (ost->source_index != ist_index)
1906 return 0;2260 return 0;
@@ -1920,7 +2274,7 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost) · 13 unmodified lines
1920 2274
1921static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)2275static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)
1922{2276{
1923 OutputFile *of = &output_files[ost->file_index];2277 OutputFile *of = output_files[ost->file_index];
1924 int64_t ost_tb_start_time = av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base);2278 int64_t ost_tb_start_time = av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base);
1925 AVPicture pict;2279 AVPicture pict;
1926 AVPacket opkt;2280 AVPacket opkt;
@@ -1980,7 +2334,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p · 53 unmodified lines
1980 2334
1981static void rate_emu_sleep(InputStream *ist)2335static void rate_emu_sleep(InputStream *ist)
1982{2336{
1983 if (input_files[ist->file_index].rate_emu) {2337 if (input_files[ist->file_index]->rate_emu) {
1984 int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);2338 int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
1985 int64_t now = av_gettime() - ist->start;2339 int64_t now = av_gettime() - ist->start;
1986 if (pts > now)2340 if (pts > now)
@@ -2091,11 +2445,11 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output) · 104 unmodified lines
2091 rate_emu_sleep(ist);2445 rate_emu_sleep(ist);
2092 2446
2093 for (i = 0; i < nb_output_streams; i++) {2447 for (i = 0; i < nb_output_streams; i++) {
2094 OutputStream *ost = &output_streams[i];2448 OutputStream *ost = output_streams[i];
2095 2449
2096 if (!check_output_constraints(ist, ost) || !ost->encoding_needed)2450 if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
2097 continue;2451 continue;
2098 do_audio_out(output_files[ost->file_index].ctx, ost, ist, decoded_frame);2452 do_audio_out(output_files[ost->file_index]->ctx, ost, ist, decoded_frame);
2099 }2453 }
2100 2454
2101 return ret;2455 return ret;
@@ -2105,9 +2459,10 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int · 3 unmodified lines
2105{2459{
2106 AVFrame *decoded_frame;2460 AVFrame *decoded_frame;
2107 void *buffer_to_free = NULL;2461 void *buffer_to_free = NULL;
2108 int i, ret = 0;2462 int i, ret = 0, resample_changed;
2109 int64_t *best_effort_timestamp;2463 int64_t *best_effort_timestamp;
2110 AVRational *frame_sample_aspect;2464 AVRational *frame_sample_aspect;
2465 float quality;
2111 2466
2112 if (!ist->decoded_frame && !(ist->decoded_frame = avcodec_alloc_frame()))2467 if (!ist->decoded_frame && !(ist->decoded_frame = avcodec_alloc_frame()))
2113 return AVERROR(ENOMEM);2468 return AVERROR(ENOMEM);
@@ -2125,6 +2480,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int · 11 unmodified lines
2125 if (ret < 0)2480 if (ret < 0)
2126 return ret;2481 return ret;
2127 2482
2483 quality = same_quant ? decoded_frame->quality : 0;
2128 if (!*got_output) {2484 if (!*got_output) {
2129 /* no picture yet */2485 /* no picture yet */
2130 return ret;2486 return ret;
@@ -2138,75 +2494,66 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int · 7 unmodified lines
2138 2494
2139 pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free);2495 pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free);
2140 2496
2141 frame_sample_aspect= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "sample_aspect_ratio");
2142 for(i=0;i<nb_output_streams;i++) {
2143 OutputStream *ost = ost = &output_streams[i];
2144 if(check_output_constraints(ist, ost) && ost->encoding_needed){
2145 int changed = ist->st->codec->width != ost->input_video_filter->outputs[0]->w
2146 || ist->st->codec->height != ost->input_video_filter->outputs[0]->h
2147 || ist->st->codec->pix_fmt != ost->input_video_filter->outputs[0]->format;
2148 if (!frame_sample_aspect->num)
2149 *frame_sample_aspect = ist->st->sample_aspect_ratio;
2150 decoded_frame->pts = ist->pts;
2151 if (ist->dr1 && decoded_frame->type==FF_BUFFER_TYPE_USER && !changed) {
2152 FrameBuffer *buf = decoded_frame->opaque;
2153 AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays(
2154 decoded_frame->data, decoded_frame->linesize,
2155 AV_PERM_READ | AV_PERM_PRESERVE,
2156 ist->st->codec->width, ist->st->codec->height,
2157 ist->st->codec->pix_fmt);
2158
2159 avfilter_copy_frame_props(fb, decoded_frame);
2160 fb->buf->priv = buf;
2161 fb->buf->free = filter_release_buffer;
2162
2163 buf->refcount++;
2164 av_buffersrc_buffer(ost->input_video_filter, fb);
2165 } else
2166 if((av_vsrc_buffer_add_frame(ost->input_video_filter, decoded_frame, AV_VSRC_BUF_FLAG_OVERWRITE)) < 0){
2167 av_log(NULL, AV_LOG_FATAL, "Failed to inject frame into filter network\n");
2168 exit_program(1);
2169 }
2170 }
2171 }
2172
2173 rate_emu_sleep(ist);2497 rate_emu_sleep(ist);
2174 2498
2175 if (ist->st->sample_aspect_ratio.num)2499 if (ist->st->sample_aspect_ratio.num)
2176 decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;2500 decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
2177 2501
2178 for (i = 0; i < nb_output_streams; i++) {2502 resample_changed = ist->resample_width != decoded_frame->width ||
2179 OutputStream *ost = &output_streams[i];2503 ist->resample_height != decoded_frame->height ||
2180 2504 ist->resample_pix_fmt != decoded_frame->format;
2181 if (!check_output_constraints(ist, ost) || !ost->encoding_needed)2505 if (resample_changed) {
2182 continue;2506 av_log(NULL, AV_LOG_INFO,
2183 2507 "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
2184 while (av_buffersink_poll_frame(ost->output_video_filter)) {2508 ist->file_index, ist->st->index,
2185 AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;2509 ist->resample_width, ist->resample_height, av_get_pix_fmt_name(ist->resample_pix_fmt),
2186 AVFrame *filtered_frame;2510 decoded_frame->width, decoded_frame->height, av_get_pix_fmt_name(decoded_frame->format));
2187 AVFilterBufferRef *picref;2511
2188 2512 ist->resample_width = decoded_frame->width;
2189 if (av_buffersink_get_buffer_ref(ost->output_video_filter, &picref, 0) < 0){2513 ist->resample_height = decoded_frame->height;
2190 av_log(NULL, AV_LOG_WARNING, "AV Filter told us it has a frame available but failed to output one\n");2514 ist->resample_pix_fmt = decoded_frame->format;
2191 goto cont;2515
2192 }2516 for (i = 0; i < nb_filtergraphs; i++)
2193 if (!ist->filtered_frame && !(ist->filtered_frame = avcodec_alloc_frame())) {2517 if (ist_in_filtergraph(filtergraphs[i], ist) &&
2194 ret = AVERROR(ENOMEM);2518 configure_filtergraph(filtergraphs[i]) < 0) {
2195 goto fail;2519 av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n");
2520 exit_program(1);
2196 }2521 }
2197 filtered_frame = ist->filtered_frame;2522 }
2198 *filtered_frame= *decoded_frame; //for me_threshold2523
2199 avfilter_fill_frame_from_video_buffer_ref(filtered_frame, picref);2524 frame_sample_aspect= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "sample_aspect_ratio");
2200 filtered_frame->pts = av_rescale_q(picref->pts, ist_pts_tb, AV_TIME_BASE_Q);2525 for (i = 0; i < ist->nb_filters; i++) {
2201 if (!ost->frame_aspect_ratio)2526 int changed = ist->st->codec->width != ist->filters[i]->filter->outputs[0]->w
2202 ost->st->codec->sample_aspect_ratio = picref->video->sample_aspect_ratio;2527 || ist->st->codec->height != ist->filters[i]->filter->outputs[0]->h
2203 do_video_out(output_files[ost->file_index].ctx, ost, ist, filtered_frame);2528 || ist->st->codec->pix_fmt != ist->filters[i]->filter->outputs[0]->format;
2204 cont:2529 // XXX what an ugly hack
2205 avfilter_unref_buffer(picref);2530 if (ist->filters[i]->graph->nb_outputs == 1)
2531 ist->filters[i]->graph->outputs[0]->ost->last_quality = quality;
2532
2533 if (!frame_sample_aspect->num)
2534 *frame_sample_aspect = ist->st->sample_aspect_ratio;
2535 if (ist->dr1 && decoded_frame->type==FF_BUFFER_TYPE_USER && !changed) {
2536 FrameBuffer *buf = decoded_frame->opaque;
2537 AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays(
2538 decoded_frame->data, decoded_frame->linesize,
2539 AV_PERM_READ | AV_PERM_PRESERVE,
2540 ist->st->codec->width, ist->st->codec->height,
2541 ist->st->codec->pix_fmt);
2542
2543 avfilter_copy_frame_props(fb, decoded_frame);
2544 fb->buf->priv = buf;
2545 fb->buf->free = filter_release_buffer;
2546
2547 buf->refcount++;
2548 av_buffersrc_buffer(ist->filters[i]->filter, fb);
2549 } else
2550 if(av_vsrc_buffer_add_frame(ist->filters[i]->filter, decoded_frame,AV_VSRC_BUF_FLAG_OVERWRITE)<0) {
2551 av_log(NULL, AV_LOG_FATAL, "Failed to inject frame into filter network\n");
2552 exit_program(1);
2206 }2553 }
2554
2207 }2555 }
2208 2556
2209fail:
2210 av_free(buffer_to_free);2557 av_free(buffer_to_free);
2211 return ret;2558 return ret;
2212}2559}
@@ -2224,12 +2571,12 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) · 11 unmodified lines
2224 rate_emu_sleep(ist);2571 rate_emu_sleep(ist);
2225 2572
2226 for (i = 0; i < nb_output_streams; i++) {2573 for (i = 0; i < nb_output_streams; i++) {
2227 OutputStream *ost = &output_streams[i];2574 OutputStream *ost = output_streams[i];
2228 2575
2229 if (!check_output_constraints(ist, ost) || !ost->encoding_needed)2576 if (!check_output_constraints(ist, ost) || !ost->encoding_needed)
2230 continue;2577 continue;
2231 2578
2232 do_subtitle_out(output_files[ost->file_index].ctx, ost, ist, &subtitle, pkt->pts);2579 do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle, pkt->pts);
2233 }2580 }
2234 2581
2235 avsubtitle_free(&subtitle);2582 avsubtitle_free(&subtitle);
@@ -2237,9 +2584,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) · 1 unmodified line
2237}2584}
2238 2585
2239/* pkt = NULL means EOF (needed to flush decoder buffers) */2586/* pkt = NULL means EOF (needed to flush decoder buffers) */
2240static int output_packet(InputStream *ist,2587static int output_packet(InputStream *ist, const AVPacket *pkt)
2241 OutputStream *ost_table, int nb_ostreams,
2242 const AVPacket *pkt)
2243{2588{
2244 int ret = 0, i;2589 int ret = 0, i;
2245 int got_output;2590 int got_output;
@@ -2356,8 +2701,8 @@ static int output_packet(InputStream *ist, · 110 unmodified lines
2356 ist->pts = ist->dts;2701 ist->pts = ist->dts;
2357 ist->next_pts = ist->next_dts;2702 ist->next_pts = ist->next_dts;
2358 }2703 }
2359 for (i = 0; pkt && i < nb_ostreams; i++) {2704 for (i = 0; pkt && i < nb_output_streams; i++) {
2360 OutputStream *ost = &ost_table[i];2705 OutputStream *ost = output_streams[i];
2361 2706
2362 if (!check_output_constraints(ist, ost) || ost->encoding_needed)2707 if (!check_output_constraints(ist, ost) || ost->encoding_needed)
2363 continue;2708 continue;
@@ -2368,18 +2713,18 @@ static int output_packet(InputStream *ist, · 4 unmodified lines
2368 return 0;2713 return 0;
2369}2714}
2370 2715
2371static void print_sdp(OutputFile *output_files, int n)2716static void print_sdp(void)
2372{2717{
2373 char sdp[2048];2718 char sdp[2048];
2374 int i;2719 int i;
2375 AVFormatContext **avc = av_malloc(sizeof(*avc) * n);2720 AVFormatContext **avc = av_malloc(sizeof(*avc) * nb_output_files);
2376 2721
2377 if (!avc)2722 if (!avc)
2378 exit_program(1);2723 exit_program(1);
2379 for (i = 0; i < n; i++)2724 for (i = 0; i < nb_output_files; i++)
2380 avc[i] = output_files[i].ctx;2725 avc[i] = output_files[i]->ctx;
2381 2726
2382 av_sdp_create(avc, n, sdp, sizeof(sdp));2727 av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp));
2383 printf("SDP:\n%s\n", sdp);2728 printf("SDP:\n%s\n", sdp);
2384 fflush(stdout);2729 fflush(stdout);
2385 av_freep(&avc);2730 av_freep(&avc);
@@ -2430,11 +2775,10 @@ static void get_default_channel_layouts(OutputStream *ost, InputStream *ist) · 44 unmodified lines
2430}2775}
2431 2776
2432 2777
2433static int init_input_stream(int ist_index, OutputStream *output_streams, int nb_output_streams,2778static int init_input_stream(int ist_index, char *error, int error_len)
2434 char *error, int error_len)
2435{2779{
2436 InputStream *ist = &input_streams[ist_index];
2437 int i;2780 int i;
2781 InputStream *ist = input_streams[ist_index];
2438 2782
2439 if (ist->decoding_needed) {2783 if (ist->decoding_needed) {
2440 AVCodec *codec = ist->dec;2784 AVCodec *codec = ist->dec;
@@ -2463,7 +2807,7 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb · 22 unmodified lines
2463 2807
2464 if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {2808 if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
2465 for (i = 0; i < nb_output_streams; i++) {2809 for (i = 0; i < nb_output_streams; i++) {
2466 OutputStream *ost = &output_streams[i];2810 OutputStream *ost = output_streams[i];
2467 if (ost->source_index == ist_index) {2811 if (ost->source_index == ist_index) {
2468 if (!ist->st->codec->channel_layout || !ost->st->codec->channel_layout)2812 if (!ist->st->codec->channel_layout || !ost->st->codec->channel_layout)
2469 get_default_channel_layouts(ost, ist);2813 get_default_channel_layouts(ost, ist);
@@ -2481,8 +2825,24 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb · 11 unmodified lines
2481 return 0;2825 return 0;
2482}2826}
2483 2827
2484static int transcode_init(OutputFile *output_files, int nb_output_files,2828static InputStream *get_input_stream(OutputStream *ost)
2485 InputFile *input_files, int nb_input_files)2829{
2830 if (ost->source_index >= 0)
2831 return input_streams[ost->source_index];
2832
2833 if (ost->filter) {
2834 FilterGraph *fg = ost->filter->graph;
2835 int i;
2836
2837 for (i = 0; i < fg->nb_inputs; i++)
2838 if (fg->inputs[i]->ist->st->codec->codec_type == ost->st->codec->codec_type)
2839 return fg->inputs[i]->ist;
2840 }
2841
2842 return NULL;
2843}
2844
2845static int transcode_init(void)
2486{2846{
2487 int ret = 0, i, j, k;2847 int ret = 0, i, j, k;
2488 AVFormatContext *oc;2848 AVFormatContext *oc;
@@ -2494,15 +2854,15 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 5 unmodified lines
2494 2854
2495 /* init framerate emulation */2855 /* init framerate emulation */
2496 for (i = 0; i < nb_input_files; i++) {2856 for (i = 0; i < nb_input_files; i++) {
2497 InputFile *ifile = &input_files[i];2857 InputFile *ifile = input_files[i];
2498 if (ifile->rate_emu)2858 if (ifile->rate_emu)
2499 for (j = 0; j < ifile->nb_streams; j++)2859 for (j = 0; j < ifile->nb_streams; j++)
2500 input_streams[j + ifile->ist_index].start = av_gettime();2860 input_streams[j + ifile->ist_index]->start = av_gettime();
2501 }2861 }
2502 2862
2503 /* output stream init */2863 /* output stream init */
2504 for (i = 0; i < nb_output_files; i++) {2864 for (i = 0; i < nb_output_files; i++) {
2505 oc = output_files[i].ctx;2865 oc = output_files[i]->ctx;
2506 if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {2866 if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
2507 av_dump_format(oc, i, oc->filename, 1);2867 av_dump_format(oc, i, oc->filename, 1);
2508 av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", i);2868 av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", i);
@@ -2510,21 +2870,29 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 1 unmodified line
2510 }2870 }
2511 }2871 }
2512 2872
2873 /* init complex filtergraphs */
2874 for (i = 0; i < nb_filtergraphs; i++)
2875 if ((ret = avfilter_graph_config(filtergraphs[i]->graph, NULL)) < 0)
2876 return ret;
2877
2513 /* for each output stream, we compute the right encoding parameters */2878 /* for each output stream, we compute the right encoding parameters */
2514 for (i = 0; i < nb_output_streams; i++) {2879 for (i = 0; i < nb_output_streams; i++) {
2515 ost = &output_streams[i];2880 ost = output_streams[i];
2516 oc = output_files[ost->file_index].ctx;2881 oc = output_files[ost->file_index]->ctx;
2517 ist = &input_streams[ost->source_index];2882 ist = get_input_stream(ost);
2518 2883
2519 if (ost->attachment_filename)2884 if (ost->attachment_filename)
2520 continue;2885 continue;
2521 2886
2522 codec = ost->st->codec;2887 codec = ost->st->codec;
2523 icodec = ist->st->codec;
2524 2888
2525 ost->st->disposition = ist->st->disposition;2889 if (ist) {
2526 codec->bits_per_raw_sample = icodec->bits_per_raw_sample;2890 icodec = ist->st->codec;
2527 codec->chroma_sample_location = icodec->chroma_sample_location;2891
2892 ost->st->disposition = ist->st->disposition;
2893 codec->bits_per_raw_sample = icodec->bits_per_raw_sample;
2894 codec->chroma_sample_location = icodec->chroma_sample_location;
2895 }
2528 2896
2529 if (ost->stream_copy) {2897 if (ost->stream_copy) {
2530 uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;2898 uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;
@@ -2625,7 +2993,8 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 94 unmodified lines
2625 if (!ost->enc)2993 if (!ost->enc)
2626 ost->enc = avcodec_find_encoder(codec->codec_id);2994 ost->enc = avcodec_find_encoder(codec->codec_id);
2627 2995
2628 ist->decoding_needed = 1;2996 if (ist)
2997 ist->decoding_needed = 1;
2629 ost->encoding_needed = 1;2998 ost->encoding_needed = 1;
2630 2999
2631 switch (codec->codec_type) {3000 switch (codec->codec_type) {
@@ -2675,32 +3044,16 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 43 unmodified lines
2675 ost->resample_channels = icodec->channels;3044 ost->resample_channels = icodec->channels;
2676 break;3045 break;
2677 case AVMEDIA_TYPE_VIDEO:3046 case AVMEDIA_TYPE_VIDEO:
2678 if (codec->pix_fmt == PIX_FMT_NONE)3047 if (!ost->filter) {
2679 codec->pix_fmt = icodec->pix_fmt;3048 FilterGraph *fg;
2680 choose_pixel_fmt(ost->st, ost->enc);3049 fg = init_simple_filtergraph(ist, ost);
2681 3050 if (configure_video_filters(fg)) {
2682 if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {3051 av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
2683 av_log(NULL, AV_LOG_FATAL, "Video pixel format is unknown, stream cannot be encoded\n");3052 exit(1);
2684 exit_program(1);3053 }
2685 }
2686
2687 if (!codec->width || !codec->height) {
2688 codec->width = icodec->width;
2689 codec->height = icodec->height;
2690 }
2691
2692 ost->video_resample = codec->width != icodec->width ||
2693 codec->height != icodec->height ||
2694 codec->pix_fmt != icodec->pix_fmt;
2695 if (ost->video_resample) {
2696 codec->bits_per_raw_sample = frame_bits_per_raw_sample;
2697 }3054 }
2698 3055
2699 ost->resample_height = icodec->height;3056 if (ist && !ost->frame_rate.num)
2700 ost->resample_width = icodec->width;
2701 ost->resample_pix_fmt = icodec->pix_fmt;
2702
2703 if (!ost->frame_rate.num)
2704 ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational) { 25, 1 };3057 ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational) { 25, 1 };
2705 if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) {3058 if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) {
2706 int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);3059 int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
@@ -2717,10 +3070,20 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 10 unmodified lines
2717 AV_TIME_BASE_Q,3070 AV_TIME_BASE_Q,
2718 codec->time_base);3071 codec->time_base);
2719 3072
2720 if (configure_video_filters(ist, ost)) {3073 codec->width = ost->filter->filter->inputs[0]->w;
2721 av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");3074 codec->height = ost->filter->filter->inputs[0]->h;
2722 exit_program(1);3075 codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
3076 ost->frame_aspect_ratio ? // overridden by the -aspect cli option
3077 av_d2q(ost->frame_aspect_ratio * codec->height/codec->width, 255) :
3078 ost->filter->filter->inputs[0]->sample_aspect_ratio;
3079 codec->pix_fmt = ost->filter->filter->inputs[0]->format;
3080
3081 if (codec->width != icodec->width ||
3082 codec->height != icodec->height ||
3083 codec->pix_fmt != icodec->pix_fmt) {
3084 codec->bits_per_raw_sample = frame_bits_per_raw_sample;
2723 }3085 }
3086
2724 break;3087 break;
2725 case AVMEDIA_TYPE_SUBTITLE:3088 case AVMEDIA_TYPE_SUBTITLE:
2726 codec->time_base = (AVRational){1, 1000};3089 codec->time_base = (AVRational){1, 1000};
@@ -2766,17 +3129,20 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 39 unmodified lines
2766 3129
2767 /* open each encoder */3130 /* open each encoder */
2768 for (i = 0; i < nb_output_streams; i++) {3131 for (i = 0; i < nb_output_streams; i++) {
2769 ost = &output_streams[i];3132 ost = output_streams[i];
2770 if (ost->encoding_needed) {3133 if (ost->encoding_needed) {
2771 AVCodec *codec = ost->enc;3134 AVCodec *codec = ost->enc;
2772 AVCodecContext *dec = input_streams[ost->source_index].st->codec;3135 AVCodecContext *dec = NULL;
2773 if (!codec) {3136 if (!codec) {
2774 snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d:%d",3137 snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d:%d",
2775 avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);3138 avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
2776 ret = AVERROR(EINVAL);3139 ret = AVERROR(EINVAL);
2777 goto dump_format;3140 goto dump_format;
2778 }3141 }
2779 if (dec->subtitle_header) {3142
3143 if ((ist = get_input_stream(ost)))
3144 dec = ist->st->codec;
3145 if (dec && dec->subtitle_header) {
2780 ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);3146 ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
2781 if (!ost->st->codec->subtitle_header) {3147 if (!ost->st->codec->subtitle_header) {
2782 ret = AVERROR(ENOMEM);3148 ret = AVERROR(ENOMEM);
@@ -2801,24 +3167,24 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 18 unmodified lines
2801 extra_size += ost->st->codec->extradata_size;3167 extra_size += ost->st->codec->extradata_size;
2802 3168
2803 if (ost->st->codec->me_threshold)3169 if (ost->st->codec->me_threshold)
2804 input_streams[ost->source_index].st->codec->debug |= FF_DEBUG_MV;3170 input_streams[ost->source_index]->st->codec->debug |= FF_DEBUG_MV;
2805 }3171 }
2806 }3172 }
2807 3173
2808 /* init input streams */3174 /* init input streams */
2809 for (i = 0; i < nb_input_streams; i++)3175 for (i = 0; i < nb_input_streams; i++)
2810 if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error))) < 0)3176 if ((ret = init_input_stream(i, error, sizeof(error))) < 0)
2811 goto dump_format;3177 goto dump_format;
2812 3178
2813 /* discard unused programs */3179 /* discard unused programs */
2814 for (i = 0; i < nb_input_files; i++) {3180 for (i = 0; i < nb_input_files; i++) {
2815 InputFile *ifile = &input_files[i];3181 InputFile *ifile = input_files[i];
2816 for (j = 0; j < ifile->ctx->nb_programs; j++) {3182 for (j = 0; j < ifile->ctx->nb_programs; j++) {
2817 AVProgram *p = ifile->ctx->programs[j];3183 AVProgram *p = ifile->ctx->programs[j];
2818 int discard = AVDISCARD_ALL;3184 int discard = AVDISCARD_ALL;
2819 3185
2820 for (k = 0; k < p->nb_stream_indexes; k++)3186 for (k = 0; k < p->nb_stream_indexes; k++)
2821 if (!input_streams[ifile->ist_index + p->stream_index[k]].discard) {3187 if (!input_streams[ifile->ist_index + p->stream_index[k]]->discard) {
2822 discard = AVDISCARD_DEFAULT;3188 discard = AVDISCARD_DEFAULT;
2823 break;3189 break;
2824 }3190 }
@@ -2828,14 +3194,14 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 3 unmodified lines
2828 3194
2829 /* open files and write file headers */3195 /* open files and write file headers */
2830 for (i = 0; i < nb_output_files; i++) {3196 for (i = 0; i < nb_output_files; i++) {
2831 oc = output_files[i].ctx;3197 oc = output_files[i]->ctx;
2832 oc->interrupt_callback = int_cb;3198 oc->interrupt_callback = int_cb;
2833 if (avformat_write_header(oc, &output_files[i].opts) < 0) {3199 if (avformat_write_header(oc, &output_files[i]->opts) < 0) {
2834 snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);3200 snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
2835 ret = AVERROR(EINVAL);3201 ret = AVERROR(EINVAL);
2836 goto dump_format;3202 goto dump_format;
2837 }3203 }
2838// assert_avoptions(output_files[i].opts);3204// assert_avoptions(output_files[i]->opts);
2839 if (strcmp(oc->oformat->name, "rtp")) {3205 if (strcmp(oc->oformat->name, "rtp")) {
2840 want_sdp = 0;3206 want_sdp = 0;
2841 }3207 }
@@ -2845,13 +3211,31 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 3 unmodified lines
2845 /* dump the file output parameters - cannot be done before in case3211 /* dump the file output parameters - cannot be done before in case
2846 of stream copy */3212 of stream copy */
2847 for (i = 0; i < nb_output_files; i++) {3213 for (i = 0; i < nb_output_files; i++) {
2848 av_dump_format(output_files[i].ctx, i, output_files[i].ctx->filename, 1);3214 av_dump_format(output_files[i]->ctx, i, output_files[i]->ctx->filename, 1);
2849 }3215 }
2850 3216
2851 /* dump the stream mapping */3217 /* dump the stream mapping */
2852 av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");3218 av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
3219 for (i = 0; i < nb_input_streams; i++) {
3220 ist = input_streams[i];
3221
3222 for (j = 0; j < ist->nb_filters; j++) {
3223 AVFilterLink *link = ist->filters[j]->filter->outputs[0];
3224 if (ist->filters[j]->graph->graph_desc) {
3225 av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
3226 ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?",
3227 link->dst->filter->name);
3228 if (link->dst->input_count > 1)
3229 av_log(NULL, AV_LOG_INFO, ":%s", link->dstpad->name);
3230 if (nb_filtergraphs > 1)
3231 av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
3232 av_log(NULL, AV_LOG_INFO, "\n");
3233 }
3234 }
3235 }
3236
2853 for (i = 0; i < nb_output_streams; i++) {3237 for (i = 0; i < nb_output_streams; i++) {
2854 ost = &output_streams[i];3238 ost = output_streams[i];
2855 3239
2856 if (ost->attachment_filename) {3240 if (ost->attachment_filename) {
2857 /* an attached file */3241 /* an attached file */
@@ -2859,9 +3243,24 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 1 unmodified line
2859 ost->attachment_filename, ost->file_index, ost->index);3243 ost->attachment_filename, ost->file_index, ost->index);
2860 continue;3244 continue;
2861 }3245 }
3246
3247 if (ost->filter && ost->filter->graph->graph_desc) {
3248 /* output from a complex graph */
3249 AVFilterLink *link = ost->filter->filter->inputs[0];
3250 av_log(NULL, AV_LOG_INFO, " %s", link->src->filter->name);
3251 if (link->src->output_count > 1)
3252 av_log(NULL, AV_LOG_INFO, ":%s", link->srcpad->name);
3253 if (nb_filtergraphs > 1)
3254 av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
3255
3256 av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index,
3257 ost->index, ost->enc ? ost->enc->name : "?");
3258 continue;
3259 }
3260
2862 av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",3261 av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
2863 input_streams[ost->source_index].file_index,3262 input_streams[ost->source_index]->file_index,
2864 input_streams[ost->source_index].st->index,3263 input_streams[ost->source_index]->st->index,
2865 ost->file_index,3264 ost->file_index,
2866 ost->index);3265 ost->index);
2867 if (ost->audio_channels_mapped) {3266 if (ost->audio_channels_mapped) {
@@ -2873,15 +3272,15 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 5 unmodified lines
2873 av_log(NULL, AV_LOG_INFO, " %d", ost->audio_channels_map[j]);3272 av_log(NULL, AV_LOG_INFO, " %d", ost->audio_channels_map[j]);
2874 av_log(NULL, AV_LOG_INFO, "]");3273 av_log(NULL, AV_LOG_INFO, "]");
2875 }3274 }
2876 if (ost->sync_ist != &input_streams[ost->source_index])3275 if (ost->sync_ist != input_streams[ost->source_index])
2877 av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]",3276 av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]",
2878 ost->sync_ist->file_index,3277 ost->sync_ist->file_index,
2879 ost->sync_ist->st->index);3278 ost->sync_ist->st->index);
2880 if (ost->stream_copy)3279 if (ost->stream_copy)
2881 av_log(NULL, AV_LOG_INFO, " (copy)");3280 av_log(NULL, AV_LOG_INFO, " (copy)");
2882 else3281 else
2883 av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index].dec ?3282 av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index]->dec ?
2884 input_streams[ost->source_index].dec->name : "?",3283 input_streams[ost->source_index]->dec->name : "?",
2885 ost->enc ? ost->enc->name : "?");3284 ost->enc ? ost->enc->name : "?");
2886 av_log(NULL, AV_LOG_INFO, "\n");3285 av_log(NULL, AV_LOG_INFO, "\n");
2887 }3286 }
@@ -2892,7 +3291,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 4 unmodified lines
2892 }3291 }
2893 3292
2894 if (want_sdp) {3293 if (want_sdp) {
2895 print_sdp(output_files, nb_output_files);3294 print_sdp();
2896 }3295 }
2897 3296
2898 return 0;3297 return 0;
@@ -2901,8 +3300,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 2 unmodified lines
2901/*3300/*
2902 * The following code is the main loop of the file converter3301 * The following code is the main loop of the file converter
2903 */3302 */
2904static int transcode(OutputFile *output_files, int nb_output_files,3303static int transcode(void)
2905 InputFile *input_files, int nb_input_files)
2906{3304{
2907 int ret, i;3305 int ret, i;
2908 AVFormatContext *is, *os;3306 AVFormatContext *is, *os;
@@ -2916,7 +3314,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 7 unmodified lines
2916 if (!(no_packet = av_mallocz(nb_input_files)))3314 if (!(no_packet = av_mallocz(nb_input_files)))
2917 exit_program(1);3315 exit_program(1);
2918 3316
2919 ret = transcode_init(output_files, nb_output_files, input_files, nb_input_files);3317 ret = transcode_init();
2920 if (ret < 0)3318 if (ret < 0)
2921 goto fail;3319 goto fail;
2922 3320
@@ -2927,14 +3325,12 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 4 unmodified lines
2927 timer_start = av_gettime();3325 timer_start = av_gettime();
2928 3326
2929 for (; received_sigterm == 0;) {3327 for (; received_sigterm == 0;) {
2930 int file_index, ist_index;3328 int file_index, ist_index, past_recording_time = 1;
2931 AVPacket pkt;3329 AVPacket pkt;
2932 int64_t ipts_min;3330 int64_t ipts_min;
2933 double opts_min;
2934 int64_t cur_time= av_gettime();3331 int64_t cur_time= av_gettime();
2935 3332
2936 ipts_min = INT64_MAX;3333 ipts_min = INT64_MAX;
2937 opts_min = 1e100;
2938 /* if 'q' pressed, exits */3334 /* if 'q' pressed, exits */
2939 if (!using_stdin) {3335 if (!using_stdin) {
2940 static int64_t last_time;3336 static int64_t last_time;
@@ -2974,15 +3370,15 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 33 unmodified lines
2974 (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {3370 (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
2975 av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",3371 av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
2976 target, time, command, arg);3372 target, time, command, arg);
2977 for (i = 0; i < nb_output_streams; i++) {3373 for (i = 0; i < nb_filtergraphs; i++) {
2978 ost = &output_streams[i];3374 FilterGraph *fg = filtergraphs[i];
2979 if (ost->graph) {3375 if (fg->graph) {
2980 if (time < 0) {3376 if (time < 0) {
2981 ret = avfilter_graph_send_command(ost->graph, target, command, arg, buf, sizeof(buf),3377 ret = avfilter_graph_send_command(fg->graph, target, command, arg, buf, sizeof(buf),
2982 key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);3378 key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
2983 fprintf(stderr, "Command reply for stream %d: ret:%d res:%s\n", i, ret, buf);3379 fprintf(stderr, "Command reply for stream %d: ret:%d res:%s\n", i, ret, buf);
2984 } else {3380 } else {
2985 ret = avfilter_graph_queue_command(ost->graph, target, command, arg, 0, time);3381 ret = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time);
2986 }3382 }
2987 }3383 }
2988 }3384 }
@@ -2995,7 +3391,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 6 unmodified lines
2995 if (key == 'd' || key == 'D'){3391 if (key == 'd' || key == 'D'){
2996 int debug=0;3392 int debug=0;
2997 if(key == 'D') {3393 if(key == 'D') {
2998 debug = input_streams[0].st->codec->debug<<1;3394 debug = input_streams[0]->st->codec->debug<<1;
2999 if(!debug) debug = 1;3395 if(!debug) debug = 1;
3000 while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash3396 while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash
3001 debug += debug;3397 debug += debug;
@@ -3003,10 +3399,10 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 1 unmodified line
3003 if(scanf("%d", &debug)!=1)3399 if(scanf("%d", &debug)!=1)
3004 fprintf(stderr,"error parsing debug value\n");3400 fprintf(stderr,"error parsing debug value\n");
3005 for(i=0;i<nb_input_streams;i++) {3401 for(i=0;i<nb_input_streams;i++) {
3006 input_streams[i].st->codec->debug = debug;3402 input_streams[i]->st->codec->debug = debug;
3007 }3403 }
3008 for(i=0;i<nb_output_streams;i++) {3404 for(i=0;i<nb_output_streams;i++) {
3009 ost = &output_streams[i];3405 ost = output_streams[i];
3010 ost->st->codec->debug = debug;3406 ost->st->codec->debug = debug;
3011 }3407 }
3012 if(debug) av_log_set_level(AV_LOG_DEBUG);3408 if(debug) av_log_set_level(AV_LOG_DEBUG);
@@ -3026,38 +3422,40 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 13 unmodified lines
3026 }3422 }
3027 }3423 }
3028 3424
3029 /* select the stream that we must read now by looking at the3425 /* check if there's any stream where output is still needed */
3030 smallest output pts */
3031 file_index = -1;
3032 for (i = 0; i < nb_output_streams; i++) {3426 for (i = 0; i < nb_output_streams; i++) {
3033 OutputFile *of;3427 OutputFile *of;
3034 int64_t ipts;3428 ost = output_streams[i];
3035 double opts;3429 of = output_files[ost->file_index];
3036 ost = &output_streams[i];3430 os = output_files[ost->file_index]->ctx;
3037 of = &output_files[ost->file_index];3431 if (ost->is_past_recording_time ||
3038 os = output_files[ost->file_index].ctx;
3039 ist = &input_streams[ost->source_index];
3040 if (ost->is_past_recording_time || no_packet[ist->file_index] ||
3041 (os->pb && avio_tell(os->pb) >= of->limit_filesize))3432 (os->pb && avio_tell(os->pb) >= of->limit_filesize))
3042 continue;3433 continue;
3043 opts = ost->st->pts.val * av_q2d(ost->st->time_base);3434 if (ost->frame_number > ost->max_frames) {
3435 int j;
3436 for (j = 0; j < of->ctx->nb_streams; j++)
3437 output_streams[of->ost_index + j]->is_past_recording_time = 1;
3438 continue;
3439 }
3440 past_recording_time = 0;
3441 }
3442 if (past_recording_time)
3443 break;
3444
3445 /* select the stream that we must read now by looking at the
3446 smallest output pts */
3447 file_index = -1;
3448 for (i = 0; i < nb_input_streams; i++) {
3449 int64_t ipts;
3450 ist = input_streams[i];
3044 ipts = ist->pts;3451 ipts = ist->pts;
3045 if (!input_files[ist->file_index].eof_reached) {3452 if (ist->discard || no_packet[ist->file_index])
3453 continue;
3454 if (!input_files[ist->file_index]->eof_reached) {
3046 if (ipts < ipts_min) {3455 if (ipts < ipts_min) {
3047 ipts_min = ipts;3456 ipts_min = ipts;
3048 if (input_sync)3457 file_index = ist->file_index;
3049 file_index = ist->file_index;
3050 }3458 }
3051 if (opts < opts_min) {
3052 opts_min = opts;
3053 if (!input_sync) file_index = ist->file_index;
3054 }
3055 }
3056 if (ost->frame_number >= ost->max_frames) {
3057 int j;
3058 for (j = 0; j < of->ctx->nb_streams; j++)
3059 output_streams[of->ost_index + j].is_past_recording_time = 1;
3060 continue;
3061 }3459 }
3062 }3460 }
3063 /* if none, if is finished */3461 /* if none, if is finished */
@@ -3072,7 +3470,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 8 unmodified lines
3072 }3470 }
3073 3471
3074 /* read a frame from it and output it in the fifo */3472 /* read a frame from it and output it in the fifo */
3075 is = input_files[file_index].ctx;3473 is = input_files[file_index]->ctx;
3076 ret = av_read_frame(is, &pkt);3474 ret = av_read_frame(is, &pkt);
3077 if (ret == AVERROR(EAGAIN)) {3475 if (ret == AVERROR(EAGAIN)) {
3078 no_packet[file_index] = 1;3476 no_packet[file_index] = 1;
@@ -3080,7 +3478,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 1 unmodified line
3080 continue;3478 continue;
3081 }3479 }
3082 if (ret < 0) {3480 if (ret < 0) {
3083 input_files[file_index].eof_reached = 1;3481 input_files[file_index]->eof_reached = 1;
3084 if (opt_shortest)3482 if (opt_shortest)
3085 break;3483 break;
3086 else3484 else
@@ -3096,17 +3494,17 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 9 unmodified lines
3096 }3494 }
3097 /* the following test is needed in case new streams appear3495 /* the following test is needed in case new streams appear
3098 dynamically in stream : we ignore them */3496 dynamically in stream : we ignore them */
3099 if (pkt.stream_index >= input_files[file_index].nb_streams)3497 if (pkt.stream_index >= input_files[file_index]->nb_streams)
3100 goto discard_packet;3498 goto discard_packet;
3101 ist_index = input_files[file_index].ist_index + pkt.stream_index;3499 ist_index = input_files[file_index]->ist_index + pkt.stream_index;
3102 ist = &input_streams[ist_index];3500 ist = input_streams[ist_index];
3103 if (ist->discard)3501 if (ist->discard)
3104 goto discard_packet;3502 goto discard_packet;
3105 3503
3106 if (pkt.dts != AV_NOPTS_VALUE)3504 if (pkt.dts != AV_NOPTS_VALUE)
3107 pkt.dts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);3505 pkt.dts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
3108 if (pkt.pts != AV_NOPTS_VALUE)3506 if (pkt.pts != AV_NOPTS_VALUE)
3109 pkt.pts += av_rescale_q(input_files[ist->file_index].ts_offset, AV_TIME_BASE_Q, ist->st->time_base);3507 pkt.pts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
3110 3508
3111 if (pkt.pts != AV_NOPTS_VALUE)3509 if (pkt.pts != AV_NOPTS_VALUE)
3112 pkt.pts *= ist->ts_scale;3510 pkt.pts *= ist->ts_scale;
@@ -3120,7 +3518,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 7 unmodified lines
3120 av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &ist->st->time_base),3518 av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &ist->st->time_base),
3121 av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),3519 av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),
3122 av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),3520 av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),
3123 input_files[ist->file_index].ts_offset);3521 input_files[ist->file_index]->ts_offset);
3124 }3522 }
3125 3523
3126 if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) {3524 if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) {
@@ -3131,10 +3529,10 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 4 unmodified lines
3131 (delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&3529 (delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
3132 ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||3530 ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
3133 pkt_dts+1<ist->pts){3531 pkt_dts+1<ist->pts){
3134 input_files[ist->file_index].ts_offset -= delta;3532 input_files[ist->file_index]->ts_offset -= delta;
3135 av_log(NULL, AV_LOG_DEBUG,3533 av_log(NULL, AV_LOG_DEBUG,
3136 "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",3534 "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
3137 delta, input_files[ist->file_index].ts_offset);3535 delta, input_files[ist->file_index]->ts_offset);
3138 pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);3536 pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
3139 if (pkt.pts != AV_NOPTS_VALUE)3537 if (pkt.pts != AV_NOPTS_VALUE)
3140 pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);3538 pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
@@ -3160,8 +3558,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 19 unmodified lines
3160 }3558 }
3161 3559
3162 // fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size);3560 // fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size);
3163 if (output_packet(ist, output_streams, nb_output_streams, &pkt) < 0) {3561 if (output_packet(ist, &pkt) < 0 || poll_filters() < 0) {
3164
3165 av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",3562 av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
3166 ist->file_index, ist->st->index);3563 ist->file_index, ist->st->index);
3167 if (exit_on_error)3564 if (exit_on_error)
@@ -3174,42 +3571,42 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 6 unmodified lines
3174 av_free_packet(&pkt);3571 av_free_packet(&pkt);
3175 3572
3176 /* dump report by using the output first video and audio streams */3573 /* dump report by using the output first video and audio streams */
3177 print_report(output_files, output_streams, nb_output_streams, 0, timer_start, cur_time);3574 print_report(0, timer_start, cur_time);
3178 }3575 }
3179 3576
3180 /* at the end of stream, we must flush the decoder buffers */3577 /* at the end of stream, we must flush the decoder buffers */
3181 for (i = 0; i < nb_input_streams; i++) {3578 for (i = 0; i < nb_input_streams; i++) {
3182 ist = &input_streams[i];3579 ist = input_streams[i];
3183 if (ist->decoding_needed) {3580 if (ist->decoding_needed) {
3184 output_packet(ist, output_streams, nb_output_streams, NULL);3581 output_packet(ist, NULL);
3185 }3582 }
3186 }3583 }
3187 flush_encoders(output_streams, nb_output_streams);3584 poll_filters();
3585 flush_encoders();
3188 3586
3189 term_exit();3587 term_exit();
3190 3588
3191 /* write the trailer if needed and close file */3589 /* write the trailer if needed and close file */
3192 for (i = 0; i < nb_output_files; i++) {3590 for (i = 0; i < nb_output_files; i++) {
3193 os = output_files[i].ctx;3591 os = output_files[i]->ctx;
3194 av_write_trailer(os);3592 av_write_trailer(os);
3195 }3593 }
3196 3594
3197 /* dump report by using the first video and audio streams */3595 /* dump report by using the first video and audio streams */
3198 print_report(output_files, output_streams, nb_output_streams, 1, timer_start, av_gettime());3596 print_report(1, timer_start, av_gettime());
3199 3597
3200 /* close each encoder */3598 /* close each encoder */
3201 for (i = 0; i < nb_output_streams; i++) {3599 for (i = 0; i < nb_output_streams; i++) {
3202 ost = &output_streams[i];3600 ost = output_streams[i];
3203 if (ost->encoding_needed) {3601 if (ost->encoding_needed) {
3204 av_freep(&ost->st->codec->stats_in);3602 av_freep(&ost->st->codec->stats_in);
3205 avcodec_close(ost->st->codec);3603 avcodec_close(ost->st->codec);
3206 }3604 }
3207 avfilter_graph_free(&ost->graph);
3208 }3605 }
3209 3606
3210 /* close each decoder */3607 /* close each decoder */
3211 for (i = 0; i < nb_input_streams; i++) {3608 for (i = 0; i < nb_input_streams; i++) {
3212 ist = &input_streams[i];3609 ist = input_streams[i];
3213 if (ist->decoding_needed) {3610 if (ist->decoding_needed) {
3214 avcodec_close(ist->st->codec);3611 avcodec_close(ist->st->codec);
3215 }3612 }
@@ -3223,7 +3620,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 7 unmodified lines
3223 3620
3224 if (output_streams) {3621 if (output_streams) {
3225 for (i = 0; i < nb_output_streams; i++) {3622 for (i = 0; i < nb_output_streams; i++) {
3226 ost = &output_streams[i];3623 ost = output_streams[i];
3227 if (ost) {3624 if (ost) {
3228 if (ost->stream_copy)3625 if (ost->stream_copy)
3229 av_freep(&ost->st->codec->extradata);3626 av_freep(&ost->st->codec->extradata);
@@ -3314,13 +3711,13 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg) · 84 unmodified lines
3314 }3711 }
3315 if (*sync)3712 if (*sync)
3316 sync++;3713 sync++;
3317 for (i = 0; i < input_files[sync_file_idx].nb_streams; i++)3714 for (i = 0; i < input_files[sync_file_idx]->nb_streams; i++)
3318 if (check_stream_specifier(input_files[sync_file_idx].ctx,3715 if (check_stream_specifier(input_files[sync_file_idx]->ctx,
3319 input_files[sync_file_idx].ctx->streams[i], sync) == 1) {3716 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
3320 sync_stream_idx = i;3717 sync_stream_idx = i;
3321 break;3718 break;
3322 }3719 }
3323 if (i == input_files[sync_file_idx].nb_streams) {3720 if (i == input_files[sync_file_idx]->nb_streams) {
3324 av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s does not "3721 av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s does not "
3325 "match any streams.\n", arg);3722 "match any streams.\n", arg);
3326 exit_program(1);3723 exit_program(1);
@@ -3328,6 +3725,18 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg) · 1 unmodified line
3328 }3725 }
3329 3726
3330 3727
3728 if (map[0] == '[') {
3729 /* this mapping refers to lavfi output */
3730 const char *c = map + 1;
3731 o->stream_maps = grow_array(o->stream_maps, sizeof(*o->stream_maps),
3732 &o->nb_stream_maps, o->nb_stream_maps + 1);
3733 m = &o->stream_maps[o->nb_stream_maps - 1];
3734 m->linklabel = av_get_token(&c, "]");
3735 if (!m->linklabel) {
3736 av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", map);
3737 exit_program(1);
3738 }
3739 } else {
3331 file_idx = strtol(map, &p, 0);3740 file_idx = strtol(map, &p, 0);
3332 if (file_idx >= nb_input_files || file_idx < 0) {3741 if (file_idx >= nb_input_files || file_idx < 0) {
3333 av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);3742 av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);
@@ -3338,14 +3747,14 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg) · 4 unmodified lines
3338 for (i = 0; i < o->nb_stream_maps; i++) {3747 for (i = 0; i < o->nb_stream_maps; i++) {
3339 m = &o->stream_maps[i];3748 m = &o->stream_maps[i];
3340 if (file_idx == m->file_index &&3749 if (file_idx == m->file_index &&
3341 check_stream_specifier(input_files[m->file_index].ctx,3750 check_stream_specifier(input_files[m->file_index]->ctx,
3342 input_files[m->file_index].ctx->streams[m->stream_index],3751 input_files[m->file_index]->ctx->streams[m->stream_index],
3343 *p == ':' ? p + 1 : p) > 0)3752 *p == ':' ? p + 1 : p) > 0)
3344 m->disabled = 1;3753 m->disabled = 1;
3345 }3754 }
3346 else3755 else
3347 for (i = 0; i < input_files[file_idx].nb_streams; i++) {3756 for (i = 0; i < input_files[file_idx]->nb_streams; i++) {
3348 if (check_stream_specifier(input_files[file_idx].ctx, input_files[file_idx].ctx->streams[i],3757 if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],
3349 *p == ':' ? p + 1 : p) <= 0)3758 *p == ':' ? p + 1 : p) <= 0)
3350 continue;3759 continue;
3351 o->stream_maps = grow_array(o->stream_maps, sizeof(*o->stream_maps),3760 o->stream_maps = grow_array(o->stream_maps, sizeof(*o->stream_maps),
@@ -3363,6 +3772,7 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg) · 11 unmodified lines
3363 m->sync_stream_index = i;3772 m->sync_stream_index = i;
3364 }3773 }
3365 }3774 }
3775 }
3366 3776
3367 if (!m) {3777 if (!m) {
3368 av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n", arg);3778 av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n", arg);
@@ -3422,12 +3832,12 @@ static int opt_map_channel(OptionsContext *o, const char *opt, const char *arg) · 53 unmodified lines
3422 exit_program(1);3832 exit_program(1);
3423 }3833 }
3424 if (m->stream_idx < 0 ||3834 if (m->stream_idx < 0 ||
3425 m->stream_idx >= input_files[m->file_idx].nb_streams) {3835 m->stream_idx >= input_files[m->file_idx]->nb_streams) {
3426 av_log(NULL, AV_LOG_FATAL, "mapchan: invalid input file stream index #%d.%d\n",3836 av_log(NULL, AV_LOG_FATAL, "mapchan: invalid input file stream index #%d.%d\n",
3427 m->file_idx, m->stream_idx);3837 m->file_idx, m->stream_idx);
3428 exit_program(1);3838 exit_program(1);
3429 }3839 }
3430 st = input_files[m->file_idx].ctx->streams[m->stream_idx];3840 st = input_files[m->file_idx]->ctx->streams[m->stream_idx];
3431 if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {3841 if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
3432 av_log(NULL, AV_LOG_FATAL, "mapchan: stream #%d.%d is not an audio stream.\n",3842 av_log(NULL, AV_LOG_FATAL, "mapchan: stream #%d.%d is not an audio stream.\n",
3433 m->file_idx, m->stream_idx);3843 m->file_idx, m->stream_idx);
@@ -3614,10 +4024,14 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) · 180 unmodified lines
3614 for (i = 0; i < ic->nb_streams; i++) {4024 for (i = 0; i < ic->nb_streams; i++) {
3615 AVStream *st = ic->streams[i];4025 AVStream *st = ic->streams[i];
3616 AVCodecContext *dec = st->codec;4026 AVCodecContext *dec = st->codec;
3617 InputStream *ist;4027 InputStream *ist = av_mallocz(sizeof(*ist));
4028
4029 if (!ist)
4030 exit_program(1);
3618 4031
3619 input_streams = grow_array(input_streams, sizeof(*input_streams), &nb_input_streams, nb_input_streams + 1);4032 input_streams = grow_array(input_streams, sizeof(*input_streams), &nb_input_streams, nb_input_streams + 1);
3620 ist = &input_streams[nb_input_streams - 1];4033 input_streams[nb_input_streams - 1] = ist;
4034
3621 ist->st = st;4035 ist->st = st;
3622 ist->file_index = nb_input_files;4036 ist->file_index = nb_input_files;
3623 ist->discard = 1;4037 ist->discard = 1;
@@ -3645,6 +4059,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) · 21 unmodified lines
3645 dec->flags |= CODEC_FLAG_EMU_EDGE;4059 dec->flags |= CODEC_FLAG_EMU_EDGE;
3646 }4060 }
3647 4061
4062 ist->resample_height = dec->height;
4063 ist->resample_width = dec->width;
4064 ist->resample_pix_fmt = dec->pix_fmt;
4065
3648 break;4066 break;
3649 case AVMEDIA_TYPE_AUDIO:4067 case AVMEDIA_TYPE_AUDIO:
3650 case AVMEDIA_TYPE_DATA:4068 case AVMEDIA_TYPE_DATA:
@@ -3819,11 +4237,14 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena · 168 unmodified lines
3819 av_dump_format(ic, nb_input_files, filename, 0);4237 av_dump_format(ic, nb_input_files, filename, 0);
3820 4238
3821 input_files = grow_array(input_files, sizeof(*input_files), &nb_input_files, nb_input_files + 1);4239 input_files = grow_array(input_files, sizeof(*input_files), &nb_input_files, nb_input_files + 1);
3822 input_files[nb_input_files - 1].ctx = ic;4240 if (!(input_files[nb_input_files - 1] = av_mallocz(sizeof(*input_files[0]))))
3823 input_files[nb_input_files - 1].ist_index = nb_input_streams - ic->nb_streams;4241 exit_program(1);
3824 input_files[nb_input_files - 1].ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);4242
3825 input_files[nb_input_files - 1].nb_streams = ic->nb_streams;4243 input_files[nb_input_files - 1]->ctx = ic;
3826 input_files[nb_input_files - 1].rate_emu = o->rate_emu;4244 input_files[nb_input_files - 1]->ist_index = nb_input_streams - ic->nb_streams;
4245 input_files[nb_input_files - 1]->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);
4246 input_files[nb_input_files - 1]->nb_streams = ic->nb_streams;
4247 input_files[nb_input_files - 1]->rate_emu = o->rate_emu;
3827 4248
3828 for (i = 0; i < o->nb_dump_attachment; i++) {4249 for (i = 0; i < o->nb_dump_attachment; i++) {
3829 int j;4250 int j;
@@ -3947,7 +4368,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 117 unmodified lines
3947 4368
3948 output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,4369 output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,
3949 nb_output_streams + 1);4370 nb_output_streams + 1);
3950 ost = &output_streams[nb_output_streams - 1];4371 if (!(ost = av_mallocz(sizeof(*ost))))
4372 exit_program(1);
4373 output_streams[nb_output_streams - 1] = ost;
4374
3951 ost->file_index = nb_output_files;4375 ost->file_index = nb_output_files;
3952 ost->index = idx;4376 ost->index = idx;
3953 ost->st = st;4377 ost->st = st;
@@ -4028,11 +4452,13 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 74 unmodified lines
4028 4452
4029 ost->source_index = source_index;4453 ost->source_index = source_index;
4030 if (source_index >= 0) {4454 if (source_index >= 0) {
4031 ost->sync_ist = &input_streams[source_index];4455 ost->sync_ist = input_streams[source_index];
4032 input_streams[source_index].discard = 0;4456 input_streams[source_index]->discard = 0;
4033 input_streams[source_index].st->discard = AVDISCARD_NONE;4457 input_streams[source_index]->st->discard = AVDISCARD_NONE;
4034 }4458 }
4035 4459
4460 ost->pix_fmts[0] = ost->pix_fmts[1] = PIX_FMT_NONE;
4461
4036 return ost;4462 return ost;
4037}4463}
4038 4464
@@ -4216,7 +4642,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in · 177 unmodified lines
4216 /* check for channel mapping for this audio stream */4642 /* check for channel mapping for this audio stream */
4217 for (n = 0; n < o->nb_audio_channel_maps; n++) {4643 for (n = 0; n < o->nb_audio_channel_maps; n++) {
4218 AudioChannelMap *map = &o->audio_channel_maps[n];4644 AudioChannelMap *map = &o->audio_channel_maps[n];
4219 InputStream *ist = &input_streams[ost->source_index];4645 InputStream *ist = input_streams[ost->source_index];
4220 if ((map->channel_idx == -1 || (ist->file_index == map->file_idx && ist->st->index == map->stream_idx)) &&4646 if ((map->channel_idx == -1 || (ist->file_index == map->file_idx && ist->st->index == map->stream_idx)) &&
4221 (map->ofile_idx == -1 || ost->file_index == map->ofile_idx) &&4647 (map->ofile_idx == -1 || ost->file_index == map->ofile_idx) &&
4222 (map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) {4648 (map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) {
@@ -4370,15 +4796,43 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch · 147 unmodified lines
4370 return 0;4796 return 0;
4371}4797}
4372 4798
4799static void init_output_filter(OutputFilter *ofilter, OptionsContext *o,
4800 AVFormatContext *oc)
4801{
4802 OutputStream *ost;
4803
4804 if (ofilter->out_tmp->filter_ctx->output_pads[ofilter->out_tmp->pad_idx].type != AVMEDIA_TYPE_VIDEO) {
4805 av_log(NULL, AV_LOG_FATAL, "Only video filters are supported currently.\n");
4806 exit_program(1);
4807 }
4808
4809 ost = new_video_stream(o, oc, -1);
4810 ost->source_index = -1;
4811 ost->filter = ofilter;
4812
4813 ofilter->ost = ost;
4814
4815 if (configure_output_filter(ofilter->graph, ofilter, ofilter->out_tmp) < 0) {
4816 av_log(NULL, AV_LOG_FATAL, "Error configuring filter.\n");
4817 exit_program(1);
4818 }
4819 avfilter_inout_free(&ofilter->out_tmp);
4820}
4821
4373static void opt_output_file(void *optctx, const char *filename)4822static void opt_output_file(void *optctx, const char *filename)
4374{4823{
4375 OptionsContext *o = optctx;4824 OptionsContext *o = optctx;
4376 AVFormatContext *oc;4825 AVFormatContext *oc;
4377 int i, err;4826 int i, j, err;
4378 AVOutputFormat *file_oformat;4827 AVOutputFormat *file_oformat;
4379 OutputStream *ost;4828 OutputStream *ost;
4380 InputStream *ist;4829 InputStream *ist;
4381 4830
4831 if (configure_complex_filters() < 0) {
4832 av_log(NULL, AV_LOG_FATAL, "Error configuring filters.\n");
4833 exit_program(1);
4834 }
4835
4382 if (!strcmp(filename, "-"))4836 if (!strcmp(filename, "-"))
4383 filename = "pipe:";4837 filename = "pipe:";
4384 4838
@@ -4390,6 +4844,24 @@ static void opt_output_file(void *optctx, const char *filename) · 5 unmodified lines
4390 file_oformat= oc->oformat;4844 file_oformat= oc->oformat;
4391 oc->interrupt_callback = int_cb;4845 oc->interrupt_callback = int_cb;
4392 4846
4847 /* create streams for all unlabeled output pads */
4848 for (i = 0; i < nb_filtergraphs; i++) {
4849 FilterGraph *fg = filtergraphs[i];
4850 for (j = 0; j < fg->nb_outputs; j++) {
4851 OutputFilter *ofilter = fg->outputs[j];
4852
4853 if (!ofilter->out_tmp || ofilter->out_tmp->name)
4854 continue;
4855
4856 switch (ofilter->out_tmp->filter_ctx->output_pads[ofilter->out_tmp->pad_idx].type) {
4857 case AVMEDIA_TYPE_VIDEO: o->video_disable = 1; break;
4858 case AVMEDIA_TYPE_AUDIO: o->audio_disable = 1; break;
4859 case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break;
4860 }
4861 init_output_filter(ofilter, o, oc);
4862 }
4863 }
4864
4393 if (!strcmp(file_oformat->name, "ffm") &&4865 if (!strcmp(file_oformat->name, "ffm") &&
4394 av_strstart(filename, "http:", NULL)) {4866 av_strstart(filename, "http:", NULL)) {
4395 int j;4867 int j;
@@ -4401,9 +4873,9 @@ static void opt_output_file(void *optctx, const char *filename) · 5 unmodified lines
4401 exit_program(1);4873 exit_program(1);
4402 }4874 }
4403 for(j = nb_output_streams - oc->nb_streams; j < nb_output_streams; j++) {4875 for(j = nb_output_streams - oc->nb_streams; j < nb_output_streams; j++) {
4404 ost = &output_streams[j];4876 ost = output_streams[j];
4405 for (i = 0; i < nb_input_streams; i++) {4877 for (i = 0; i < nb_input_streams; i++) {
4406 ist = &input_streams[i];4878 ist = input_streams[i];
4407 if(ist->st->codec->codec_type == ost->st->codec->codec_type){4879 if(ist->st->codec->codec_type == ost->st->codec->codec_type){
4408 ost->sync_ist= ist;4880 ost->sync_ist= ist;
4409 ost->source_index= i;4881 ost->source_index= i;
@@ -4424,7 +4896,7 @@ static void opt_output_file(void *optctx, const char *filename) · 14 unmodified lines
4424 if (!o->video_disable && oc->oformat->video_codec != CODEC_ID_NONE) {4896 if (!o->video_disable && oc->oformat->video_codec != CODEC_ID_NONE) {
4425 int area = 0, idx = -1;4897 int area = 0, idx = -1;
4426 for (i = 0; i < nb_input_streams; i++) {4898 for (i = 0; i < nb_input_streams; i++) {
4427 ist = &input_streams[i];4899 ist = input_streams[i];
4428 if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&4900 if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
4429 ist->st->codec->width * ist->st->codec->height > area) {4901 ist->st->codec->width * ist->st->codec->height > area) {
4430 area = ist->st->codec->width * ist->st->codec->height;4902 area = ist->st->codec->width * ist->st->codec->height;
@@ -4439,7 +4911,7 @@ static void opt_output_file(void *optctx, const char *filename) · 8 unmodified lines
4439 if (!o->audio_disable && oc->oformat->audio_codec != CODEC_ID_NONE) {4911 if (!o->audio_disable && oc->oformat->audio_codec != CODEC_ID_NONE) {
4440 int channels = 0, idx = -1;4912 int channels = 0, idx = -1;
4441 for (i = 0; i < nb_input_streams; i++) {4913 for (i = 0; i < nb_input_streams; i++) {
4442 ist = &input_streams[i];4914 ist = input_streams[i];
4443 if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&4915 if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
4444 ist->st->codec->channels > channels) {4916 ist->st->codec->channels > channels) {
4445 channels = ist->st->codec->channels;4917 channels = ist->st->codec->channels;
@@ -4453,7 +4925,7 @@ static void opt_output_file(void *optctx, const char *filename) · 7 unmodified lines
4453 /* subtitles: pick first */4925 /* subtitles: pick first */
4454 if (!o->subtitle_disable && (oc->oformat->subtitle_codec != CODEC_ID_NONE || subtitle_codec_name)) {4926 if (!o->subtitle_disable && (oc->oformat->subtitle_codec != CODEC_ID_NONE || subtitle_codec_name)) {
4455 for (i = 0; i < nb_input_streams; i++)4927 for (i = 0; i < nb_input_streams; i++)
4456 if (input_streams[i].st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {4928 if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
4457 new_subtitle_stream(o, oc, i);4929 new_subtitle_stream(o, oc, i);
4458 break;4930 break;
4459 }4931 }
@@ -4462,12 +4934,35 @@ static void opt_output_file(void *optctx, const char *filename) · 2 unmodified lines
4462 } else {4934 } else {
4463 for (i = 0; i < o->nb_stream_maps; i++) {4935 for (i = 0; i < o->nb_stream_maps; i++) {
4464 StreamMap *map = &o->stream_maps[i];4936 StreamMap *map = &o->stream_maps[i];
4465 int src_idx = input_files[map->file_index].ist_index + map->stream_index;4937 int src_idx = input_files[map->file_index]->ist_index + map->stream_index;
4466 4938
4467 if (map->disabled)4939 if (map->disabled)
4468 continue;4940 continue;
4469 4941
4470 ist = &input_streams[input_files[map->file_index].ist_index + map->stream_index];4942 if (map->linklabel) {
4943 FilterGraph *fg;
4944 OutputFilter *ofilter = NULL;
4945 int j, k;
4946
4947 for (j = 0; j < nb_filtergraphs; j++) {
4948 fg = filtergraphs[j];
4949 for (k = 0; k < fg->nb_outputs; k++) {
4950 AVFilterInOut *out = fg->outputs[k]->out_tmp;
4951 if (out && !strcmp(out->name, map->linklabel)) {
4952 ofilter = fg->outputs[k];
4953 goto loop_end;
4954 }
4955 }
4956 }
4957loop_end:
4958 if (!ofilter) {
4959 av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist "
4960 "in any defined filter graph.\n", map->linklabel);
4961 exit_program(1);
4962 }
4963 init_output_filter(ofilter, o, oc);
4964 } else {
4965 ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];
4471 if(o->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)4966 if(o->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
4472 continue;4967 continue;
4473 if(o-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)4968 if(o-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
@@ -4488,13 +4983,15 @@ static void opt_output_file(void *optctx, const char *filename) · 14 unmodified lines
4488 map->file_index, map->stream_index);4983 map->file_index, map->stream_index);
4489 exit_program(1);4984 exit_program(1);
4490 }4985 }
4986
4987 }
4491 }4988 }
4492 }4989 }
4493 4990
4494 4991
4495 for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) { //for all streams of this output file4992 for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) { //for all streams of this output file
4496 AVDictionaryEntry *e;4993 AVDictionaryEntry *e;
4497 ost = &output_streams[i];4994 ost = output_streams[i];
4498 4995
4499 if ( ost->stream_copy4996 if ( ost->stream_copy
4500 && (e = av_dict_get(codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))4997 && (e = av_dict_get(codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX))
@@ -4539,14 +5036,17 @@ static void opt_output_file(void *optctx, const char *filename) · 38 unmodified lines
4539 }5036 }
4540 5037
4541 output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1);5038 output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1);
4542 output_files[nb_output_files - 1].ctx = oc;5039 if (!(output_files[nb_output_files - 1] = av_mallocz(sizeof(*output_files[0]))))
4543 output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams;5040 exit_program(1);
4544 output_files[nb_output_files - 1].recording_time = o->recording_time;5041
5042 output_files[nb_output_files - 1]->ctx = oc;
5043 output_files[nb_output_files - 1]->ost_index = nb_output_streams - oc->nb_streams;
5044 output_files[nb_output_files - 1]->recording_time = o->recording_time;
4545 if (o->recording_time != INT64_MAX)5045 if (o->recording_time != INT64_MAX)
4546 oc->duration = o->recording_time;5046 oc->duration = o->recording_time;
4547 output_files[nb_output_files - 1].start_time = o->start_time;5047 output_files[nb_output_files - 1]->start_time = o->start_time;
4548 output_files[nb_output_files - 1].limit_filesize = o->limit_filesize;5048 output_files[nb_output_files - 1]->limit_filesize = o->limit_filesize;
4549 av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0);5049 av_dict_copy(&output_files[nb_output_files - 1]->opts, format_opts, 0);
4550 5050
4551 /* check filename in case of an image number is expected */5051 /* check filename in case of an image number is expected */
4552 if (oc->oformat->flags & AVFMT_NEEDNUMBER) {5052 if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
@@ -4563,7 +5063,7 @@ static void opt_output_file(void *optctx, const char *filename) · 10 unmodified lines
4563 /* open the file */5063 /* open the file */
4564 if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,5064 if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
4565 &oc->interrupt_callback,5065 &oc->interrupt_callback,
4566 &output_files[nb_output_files - 1].opts)) < 0) {5066 &output_files[nb_output_files - 1]->opts)) < 0) {
4567 print_error(filename, err);5067 print_error(filename, err);
4568 exit_program(1);5068 exit_program(1);
4569 }5069 }
@@ -4572,7 +5072,7 @@ static void opt_output_file(void *optctx, const char *filename) · 2 unmodified lines
4572 if (o->mux_preload) {5072 if (o->mux_preload) {
4573 uint8_t buf[64];5073 uint8_t buf[64];
4574 snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE));5074 snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE));
4575 av_dict_set(&output_files[nb_output_files - 1].opts, "preload", buf, 0);5075 av_dict_set(&output_files[nb_output_files - 1]->opts, "preload", buf, 0);
4576 }5076 }
4577 oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);5077 oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);
4578 5078
@@ -4585,7 +5085,7 @@ static void opt_output_file(void *optctx, const char *filename) · 6 unmodified lines
4585 av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index);5085 av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index);
4586 exit_program(1);5086 exit_program(1);
4587 }5087 }
4588 copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc, in_file_index >= 0 ? input_files[in_file_index].ctx : NULL, o);5088 copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc, in_file_index >= 0 ? input_files[in_file_index]->ctx : NULL, o);
4589 }5089 }
4590 5090
4591 /* copy chapters */5091 /* copy chapters */
@@ -4594,7 +5094,7 @@ static void opt_output_file(void *optctx, const char *filename) · 2 unmodified lines
4594 /* copy chapters from the first input file that has them*/5094 /* copy chapters from the first input file that has them*/
4595 o->chapters_input_file = -1;5095 o->chapters_input_file = -1;
4596 for (i = 0; i < nb_input_files; i++)5096 for (i = 0; i < nb_input_files; i++)
4597 if (input_files[i].ctx->nb_chapters) {5097 if (input_files[i]->ctx->nb_chapters) {
4598 o->chapters_input_file = i;5098 o->chapters_input_file = i;
4599 break;5099 break;
4600 }5100 }
@@ -4605,23 +5105,23 @@ static void opt_output_file(void *optctx, const char *filename) · 4 unmodified lines
4605 }5105 }
4606 }5106 }
4607 if (o->chapters_input_file >= 0)5107 if (o->chapters_input_file >= 0)
4608 copy_chapters(&input_files[o->chapters_input_file], &output_files[nb_output_files - 1],5108 copy_chapters(input_files[o->chapters_input_file], output_files[nb_output_files - 1],
4609 !o->metadata_chapters_manual);5109 !o->metadata_chapters_manual);
4610 5110
4611 /* copy global metadata by default */5111 /* copy global metadata by default */
4612 if (!o->metadata_global_manual && nb_input_files){5112 if (!o->metadata_global_manual && nb_input_files){
4613 av_dict_copy(&oc->metadata, input_files[0].ctx->metadata,5113 av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata,
4614 AV_DICT_DONT_OVERWRITE);5114 AV_DICT_DONT_OVERWRITE);
4615 if(o->recording_time != INT64_MAX)5115 if(o->recording_time != INT64_MAX)
4616 av_dict_set(&oc->metadata, "duration", NULL, 0);5116 av_dict_set(&oc->metadata, "duration", NULL, 0);
4617 }5117 }
4618 if (!o->metadata_streams_manual)5118 if (!o->metadata_streams_manual)
4619 for (i = output_files[nb_output_files - 1].ost_index; i < nb_output_streams; i++) {5119 for (i = output_files[nb_output_files - 1]->ost_index; i < nb_output_streams; i++) {
4620 InputStream *ist;5120 InputStream *ist;
4621 if (output_streams[i].source_index < 0) /* this is true e.g. for attached files */5121 if (output_streams[i]->source_index < 0) /* this is true e.g. for attached files */
4622 continue;5122 continue;
4623 ist = &input_streams[output_streams[i].source_index];5123 ist = input_streams[output_streams[i]->source_index];
4624 av_dict_copy(&output_streams[i].st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);5124 av_dict_copy(&output_streams[i]->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);
4625 }5125 }
4626 5126
4627 /* process manually set metadata */5127 /* process manually set metadata */
@@ -4764,8 +5264,8 @@ static int opt_target(OptionsContext *o, const char *opt, const char *arg) · 136 unmodified lines
4764 if (nb_input_files) {5264 if (nb_input_files) {
4765 int i, j, fr;5265 int i, j, fr;
4766 for (j = 0; j < nb_input_files; j++) {5266 for (j = 0; j < nb_input_files; j++) {
4767 for (i = 0; i < input_files[j].nb_streams; i++) {5267 for (i = 0; i < input_files[j]->nb_streams; i++) {
4768 AVCodecContext *c = input_files[j].ctx->streams[i]->codec;5268 AVCodecContext *c = input_files[j]->ctx->streams[i]->codec;
4769 if (c->codec_type != AVMEDIA_TYPE_VIDEO)5269 if (c->codec_type != AVMEDIA_TYPE_VIDEO)
4770 continue;5270 continue;
4771 fr = c->time_base.den * 1000 / c->time_base.num;5271 fr = c->time_base.den * 1000 / c->time_base.num;
@@ -5080,6 +5580,17 @@ static int opt_channel_layout(OptionsContext *o, const char *opt, const char *ar · 308 unmodified lines
5080 return ret;5580 return ret;
5081}5581}
5082 5582
5583static int opt_filter_complex(const char *opt, const char *arg)
5584{
5585 filtergraphs = grow_array(filtergraphs, sizeof(*filtergraphs),
5586 &nb_filtergraphs, nb_filtergraphs + 1);
5587 if (!(filtergraphs[nb_filtergraphs - 1] = av_mallocz(sizeof(*filtergraphs[0]))))
5588 return AVERROR(ENOMEM);
5589 filtergraphs[nb_filtergraphs - 1]->index = nb_filtergraphs - 1;
5590 filtergraphs[nb_filtergraphs - 1]->graph_desc = arg;
5591 return 0;
5592}
5593
5083#define OFFSET(x) offsetof(OptionsContext, x)5594#define OFFSET(x) offsetof(OptionsContext, x)
5084static const OptionDef options[] = {5595static const OptionDef options[] = {
5085 /* main options */5596 /* main options */
@@ -5131,6 +5642,7 @@ static const OptionDef options[] = { · 45 unmodified lines
5131 { "qscale", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_qscale}, "use fixed quality scale (VBR)", "q" },5642 { "qscale", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_qscale}, "use fixed quality scale (VBR)", "q" },
5132 { "profile", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_profile}, "set profile", "profile" },5643 { "profile", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_profile}, "set profile", "profile" },
5133 { "filter", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(filters)}, "set stream filterchain", "filter_list" },5644 { "filter", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(filters)}, "set stream filterchain", "filter_list" },
5645 { "filter_complex", HAS_ARG | OPT_EXPERT, {(void*)opt_filter_complex}, "create a complex filtergraph", "graph_description" },
5134 { "stats", OPT_BOOL, {&print_stats}, "print progress report during encoding", },5646 { "stats", OPT_BOOL, {&print_stats}, "print progress report during encoding", },
5135 { "attach", HAS_ARG | OPT_FUNC2, {(void*)opt_attach}, "add an attachment to the output file", "filename" },5647 { "attach", HAS_ARG | OPT_FUNC2, {(void*)opt_attach}, "add an attachment to the output file", "filename" },
5136 { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(dump_attachment)}, "extract an attachment into a file", "filename" },5648 { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(dump_attachment)}, "extract an attachment into a file", "filename" },
@@ -5274,7 +5786,7 @@ int main(int argc, char **argv) · 137 unmodified lines
5274 }5786 }
5275 5787
5276 current_time = ti = getutime();5788 current_time = ti = getutime();
5277 if (transcode(output_files, nb_output_files, input_files, nb_input_files) < 0)5789 if (transcode() < 0)
5278 exit_program(1);5790 exit_program(1);
5279 ti = getutime() - ti;5791 ti = getutime() - ti;
5280 if (do_benchmark) {5792 if (do_benchmark) {
ffplay.c+1−1
@@ -1740,9 +1740,9 @@ static AVFilter input_filter = · 1739 unmodified lines
1740 1740
1741static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters)1741static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters)
1742{1742{
1743 static const enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
1743 char sws_flags_str[128];1744 char sws_flags_str[128];
1744 int ret;1745 int ret;
1745 enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
1746 AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();1746 AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
1747 AVFilterContext *filt_src = NULL, *filt_out = NULL;1747 AVFilterContext *filt_src = NULL, *filt_out = NULL;
1748 snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);1748 snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
libavfilter/graphparser.c+1−1
@@ -242,7 +242,7 @@ static int link_filter_inouts(AVFilterContext *filt_ctx, · 241 unmodified lines
242 } else {242 } else {
243 p->filter_ctx = filt_ctx;243 p->filter_ctx = filt_ctx;
244 p->pad_idx = pad;244 p->pad_idx = pad;
245 insert_inout(open_inputs, p);245 append_inout(open_inputs, &p);
246 }246 }
247 }247 }
248 248
libavfilter/sink_buffer.c+7−3
@@ -165,9 +165,9 @@ static av_cold int vsink_init(AVFilterContext *ctx, const char *args, void *opaq · 164 unmodified lines
165 av_unused AVBufferSinkParams *params;165 av_unused AVBufferSinkParams *params;
166 166
167 if (!opaque) {167 if (!opaque) {
168 av_log(ctx, AV_LOG_ERROR,168 av_log(ctx, AV_LOG_WARNING,
169 "No opaque field provided\n");169 "No opaque field provided\n");
170 return AVERROR(EINVAL);170 buf->pixel_fmts = NULL;
171 } else {171 } else {
172#if FF_API_OLD_VSINK_API172#if FF_API_OLD_VSINK_API
173 const int *pixel_fmts = (const enum PixelFormat *)opaque;173 const int *pixel_fmts = (const enum PixelFormat *)opaque;
@@ -194,7 +194,11 @@ static int vsink_query_formats(AVFilterContext *ctx) · 20 unmodified lines
194{194{
195 BufferSinkContext *buf = ctx->priv;195 BufferSinkContext *buf = ctx->priv;
196 196
197 avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(buf->pixel_fmts));197 if (buf->pixel_fmts)
198 avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(buf->pixel_fmts));
199 else
200 avfilter_default_query_formats(ctx);
201
198 return 0;202 return 0;
199}203}
200 204
tests/codec-regression.sh+3−3
@@ -73,9 +73,9 @@ do_video_encoding mpeg2threadivlc.mpg "-qscale 10 -vcodec mpeg2video -f mpeg1vid · 72 unmodified lines
73do_video_decoding73do_video_decoding
74 74
75# mpeg2 encoding interlaced75# mpeg2 encoding interlaced
76file=${outfile}mpeg2reuse.mpg76#file=${outfile}mpeg2reuse.mpg
77do_avconv $file $DEC_OPTS -me_threshold 256 -i ${target_path}/${outfile}mpeg2thread.mpg $ENC_OPTS -same_quant -me_threshold 256 -mb_threshold 1024 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 477#do_avconv $file $DEC_OPTS -me_threshold 256 -i ${target_path}/${outfile}mpeg2thread.mpg $ENC_OPTS -same_quant -me_threshold 256 -mb_threshold 1024 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4
78do_video_decoding78#do_video_decoding
79fi79fi
80 80
81if [ -n "$do_msmpeg4v2" ] ; then81if [ -n "$do_msmpeg4v2" ] ; then
tests/ref/seek/mpeg2reuse_mpg+0−46
@@ -1,46 +0,0 @@
1ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
2ret: 0 st:-1 flags:0 ts:-1.000000
3ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
4ret: 0 st:-1 flags:1 ts: 1.894167
5ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
6ret: 0 st: 0 flags:0 ts: 0.788334
7ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141401 size: 23537
8ret:-1 st: 0 flags:1 ts:-0.317499
9ret:-1 st:-1 flags:0 ts: 2.576668
10ret: 0 st:-1 flags:1 ts: 1.470835
11ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 232037 size: 26192
12ret: 0 st: 0 flags:0 ts: 0.365002
13ret: 0 st: 0 flags:1 dts: 0.400000 pts: NOPTS pos: 63793 size: 21295
14ret:-1 st: 0 flags:1 ts:-0.740831
15ret:-1 st:-1 flags:0 ts: 2.153336
16ret: 0 st:-1 flags:1 ts: 1.047503
17ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141401 size: 23537
18ret: 0 st: 0 flags:0 ts:-0.058330
19ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
20ret: 0 st: 0 flags:1 ts: 2.835837
21ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
22ret: 0 st:-1 flags:0 ts: 1.730004
23ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
24ret: 0 st:-1 flags:1 ts: 0.624171
25ret: 0 st: 0 flags:1 dts: 0.400000 pts: NOPTS pos: 63793 size: 21295
26ret: 0 st: 0 flags:0 ts:-0.481662
27ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
28ret: 0 st: 0 flags:1 ts: 2.412505
29ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
30ret: 0 st:-1 flags:0 ts: 1.306672
31ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 232037 size: 26192
32ret: 0 st:-1 flags:1 ts: 0.200839
33ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
34ret: 0 st: 0 flags:0 ts:-0.904994
35ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
36ret: 0 st: 0 flags:1 ts: 1.989173
37ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
38ret: 0 st:-1 flags:0 ts: 0.883340
39ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 232037 size: 26192
40ret:-1 st:-1 flags:1 ts:-0.222493
41ret:-1 st: 0 flags:0 ts: 2.671674
42ret: 0 st: 0 flags:1 ts: 1.565841
43ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 232037 size: 26192
44ret: 0 st:-1 flags:0 ts: 0.460008
45ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141401 size: 23537
46ret:-1 st:-1 flags:1 ts:-0.645825
tests/ref/vsynth1/mpeg2thread_ilace+0−4
@@ -2,7 +2,3 @@ · 1 unmodified line
2791773 ./tests/data/vsynth1/mpeg2threadivlc.mpg2791773 ./tests/data/vsynth1/mpeg2threadivlc.mpg
3d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread_ilace.vsynth1.out.yuv3d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread_ilace.vsynth1.out.yuv
4stddev: 7.63 PSNR: 30.48 MAXDIFF: 110 bytes: 7603200/ 76032004stddev: 7.63 PSNR: 30.48 MAXDIFF: 110 bytes: 7603200/ 7603200
5d119fe917dd81d1ff758b4ce684a8d9d *./tests/data/vsynth1/mpeg2reuse.mpg
62074636 ./tests/data/vsynth1/mpeg2reuse.mpg
792ced6afe8c02304943c400cce51a5f4 *./tests/data/mpeg2thread_ilace.vsynth1.out.yuv
8stddev: 7.66 PSNR: 30.44 MAXDIFF: 111 bytes: 7603200/ 7603200
tests/ref/vsynth2/mpeg2thread_ilace+0−4
@@ -2,7 +2,3 @@ · 1 unmodified line
2178801 ./tests/data/vsynth2/mpeg2threadivlc.mpg2178801 ./tests/data/vsynth2/mpeg2threadivlc.mpg
38c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread_ilace.vsynth2.out.yuv38c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread_ilace.vsynth2.out.yuv
4stddev: 4.72 PSNR: 34.65 MAXDIFF: 72 bytes: 7603200/ 76032004stddev: 4.72 PSNR: 34.65 MAXDIFF: 72 bytes: 7603200/ 7603200
5864d6bf2982a61e510003a518be65a2d *./tests/data/vsynth2/mpeg2reuse.mpg
6383419 ./tests/data/vsynth2/mpeg2reuse.mpg
7bb20fa080cfd2b0a687ea7376ff4f902 *./tests/data/mpeg2thread_ilace.vsynth2.out.yuv
8stddev: 4.73 PSNR: 34.63 MAXDIFF: 72 bytes: 7603200/ 7603200

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t