| Index: source/patched-ffmpeg-mt/cmdutils.c
|
| ===================================================================
|
| --- source/patched-ffmpeg-mt/cmdutils.c (revision 65184)
|
| +++ source/patched-ffmpeg-mt/cmdutils.c (working copy)
|
| @@ -32,7 +32,9 @@
|
| #include "libavformat/avformat.h"
|
| #include "libavfilter/avfilter.h"
|
| #include "libavdevice/avdevice.h"
|
| +#if CONFIG_SWSCALE
|
| #include "libswscale/swscale.h"
|
| +#endif
|
| #include "libpostproc/postprocess.h"
|
| #include "libavutil/avstring.h"
|
| #include "libavutil/pixdesc.h"
|
| @@ -53,7 +55,9 @@
|
| static int opt_name_count;
|
| AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
| AVFormatContext *avformat_opts;
|
| +#if CONFIG_SWSCALE
|
| struct SwsContext *sws_opts;
|
| +#endif
|
|
|
| const int this_year = 2010;
|
|
|
| @@ -63,7 +67,9 @@
|
| for (i = 0; i < AVMEDIA_TYPE_NB; i++)
|
| avcodec_opts[i] = avcodec_alloc_context2(i);
|
| avformat_opts = avformat_alloc_context();
|
| +#if CONFIG_SWSCALE
|
| sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, NULL, NULL, NULL);
|
| +#endif
|
| }
|
|
|
| void uninit_opts(void)
|
| @@ -73,7 +79,9 @@
|
| av_freep(&avcodec_opts[i]);
|
| av_freep(&avformat_opts->key);
|
| av_freep(&avformat_opts);
|
| +#if CONFIG_SWSCALE
|
| av_freep(&sws_opts);
|
| +#endif
|
| }
|
|
|
| void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
|
| @@ -225,8 +233,10 @@
|
| }
|
| if(!o && avformat_opts)
|
| ret = av_set_string3(avformat_opts, opt, arg, 1, &o);
|
| +#if CONFIG_SWSCALE
|
| if(!o && sws_opts)
|
| ret = av_set_string3(sws_opts, opt, arg, 1, &o);
|
| +#endif
|
| if(!o){
|
| if(opt[0] == 'a')
|
| ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o);
|
| @@ -390,7 +400,9 @@
|
| PRINT_LIB_INFO(outstream, avformat, AVFORMAT, flags);
|
| PRINT_LIB_INFO(outstream, avdevice, AVDEVICE, flags);
|
| PRINT_LIB_INFO(outstream, avfilter, AVFILTER, flags);
|
| +#if CONFIG_SWSCALE
|
| PRINT_LIB_INFO(outstream, swscale, SWSCALE, flags);
|
| +#endif
|
| PRINT_LIB_INFO(outstream, postproc, POSTPROC, flags);
|
| }
|
|
|
| @@ -747,3 +759,66 @@
|
|
|
| return pts;
|
| }
|
| +
|
| +#if CONFIG_AVFILTER
|
| +
|
| +static int ffsink_init(AVFilterContext *ctx, const char *args, void *opaque)
|
| +{
|
| + FFSinkContext *priv = ctx->priv;
|
| +
|
| + if (!opaque)
|
| + return AVERROR(EINVAL);
|
| + *priv = *(FFSinkContext *)opaque;
|
| +
|
| + return 0;
|
| +}
|
| +
|
| +static void null_end_frame(AVFilterLink *inlink) { }
|
| +
|
| +static int ffsink_query_formats(AVFilterContext *ctx)
|
| +{
|
| + FFSinkContext *priv = ctx->priv;
|
| + enum PixelFormat pix_fmts[] = { priv->pix_fmt, PIX_FMT_NONE };
|
| +
|
| + avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
|
| + return 0;
|
| +}
|
| +
|
| +AVFilter ffsink = {
|
| + .name = "ffsink",
|
| + .priv_size = sizeof(FFSinkContext),
|
| + .init = ffsink_init,
|
| +
|
| + .query_formats = ffsink_query_formats,
|
| +
|
| + .inputs = (AVFilterPad[]) {{ .name = "default",
|
| + .type = AVMEDIA_TYPE_VIDEO,
|
| + .end_frame = null_end_frame,
|
| + .min_perms = AV_PERM_READ, },
|
| + { .name = NULL }},
|
| + .outputs = (AVFilterPad[]) {{ .name = NULL }},
|
| +};
|
| +
|
| +int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
|
| + AVFilterBufferRef **picref_ptr, AVRational *tb)
|
| +{
|
| + int ret;
|
| + AVFilterBufferRef *picref;
|
| +
|
| + if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
|
| + return ret;
|
| + if (!(picref = ctx->inputs[0]->cur_buf))
|
| + return AVERROR(ENOENT);
|
| + *picref_ptr = picref;
|
| + ctx->inputs[0]->cur_buf = NULL;
|
| + *tb = ctx->inputs[0]->time_base;
|
| +
|
| + memcpy(frame->data, picref->data, sizeof(frame->data));
|
| + memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
|
| + frame->interlaced_frame = picref->video->interlaced;
|
| + frame->top_field_first = picref->video->top_field_first;
|
| +
|
| + return 1;
|
| +}
|
| +
|
| +#endif /* CONFIG_AVFILTER */
|
|
|