From: Frank Barchard <[email protected]>
Signed-off-by: Ronald S. Bultje <[email protected]>
---
cmdutils.c | 8 ++++++++
configure | 2 +-
ffmpeg.c | 18 +++++++++++++++++-
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/cmdutils.c b/cmdutils.c
index 943a77c..1ffebe9 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -54,7 +54,9 @@ const char **opt_values;
static int opt_name_count;
AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
AVFormatContext *avformat_opts;
+#if CONFIG_SWSCALE
struct SwsContext *sws_opts;
+#endif
AVDictionary *format_opts, *video_opts, *audio_opts, *sub_opts;
static const int this_year = 2011;
@@ -314,6 +316,7 @@ static int opt_default2(const char *opt, const char *arg)
av_dict_set(&sub_opts, opt, arg, FLAGS);
} else if ((o = av_opt_find(avformat_opts, opt, NULL, 0,
AV_OPT_SEARCH_CHILDREN)))
av_dict_set(&format_opts, opt, arg, FLAGS);
+#if CONFIG_SWSCALE
else if ((o = av_opt_find(sws_opts, opt, NULL, 0,
AV_OPT_SEARCH_CHILDREN))) {
// XXX we only support sws_flags, not arbitrary sws options
int ret = av_set_string3(sws_opts, opt, arg, 1, NULL);
@@ -322,6 +325,7 @@ static int opt_default2(const char *opt, const char *arg)
return ret;
}
}
+#endif
if (!o) {
SET_PREFIXED_OPTS('v', AV_OPT_FLAG_VIDEO_PARAM, video_opts)
@@ -348,8 +352,10 @@ int opt_default(const char *opt, const char *arg){
}
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' && avcodec_opts[AVMEDIA_TYPE_AUDIO])
ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg,
1, &o);
@@ -525,7 +531,9 @@ static void print_all_libs_info(FILE* outstream, int flags)
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);
}
diff --git a/configure b/configure
index a1cc59a..bb3180f 100755
--- a/configure
+++ b/configure
@@ -1486,7 +1486,7 @@ avformat_deps="avcodec"
postproc_deps="gpl"
# programs
-ffmpeg_deps="avcodec avformat swscale"
+ffmpeg_deps="avcodec avformat"
ffmpeg_select="buffer_filter"
ffplay_deps="avcodec avformat swscale sdl"
ffplay_select="rdft"
diff --git a/ffmpeg.c b/ffmpeg.c
index 9f2d5b9..1ab1125 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -265,7 +265,9 @@ typedef struct AVOutputStream {
/* video only */
int video_resample;
AVFrame pict_tmp; /* temporary image for resampling */
+#if CONFIG_SWSCALE
struct SwsContext *img_resample_ctx; /* for image resampling */
+#endif
int resample_height;
int resample_width;
int resample_pix_fmt;
@@ -665,7 +667,11 @@ static AVOutputStream *new_output_stream(AVFormatContext
*oc, int file_idx)
ost->file_index = file_idx;
ost->index = idx;
+#if CONFIG_SWSCALE
ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
+#else
+ ost->sws_flags = 0;
+#endif
return ost;
}
@@ -1187,6 +1193,7 @@ static void do_video_out(AVFormatContext *s,
#if !CONFIG_AVFILTER
if (ost->video_resample) {
+#if CONFIG_SWSCALE
final_picture = &ost->pict_tmp;
if (resample_changed) {
/* initialize a new scaler context */
@@ -1206,6 +1213,11 @@ static void do_video_out(AVFormatContext *s,
}
sws_scale(ost->img_resample_ctx, formatted_picture->data,
formatted_picture->linesize,
0, ost->resample_height, final_picture->data,
final_picture->linesize);
+#else
+ av_log(NULL, AV_LOG_ERROR,
+ "Image resampling needed, please compile with swscale\n");
+ exit(1);
+#endif
}
#endif
@@ -2210,7 +2222,7 @@ static int transcode(AVFormatContext **output_files,
codec->height != icodec->height ||
codec->pix_fmt != icodec->pix_fmt;
if (ost->video_resample) {
-#if !CONFIG_AVFILTER
+#if !CONFIG_AVFILTER && CONFIG_SWSCALE
avcodec_get_frame_defaults(&ost->pict_tmp);
if(avpicture_alloc((AVPicture*)&ost->pict_tmp,
codec->pix_fmt,
codec->width, codec->height)) {
@@ -2725,8 +2737,10 @@ static int transcode(AVFormatContext **output_files,
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->pict_tmp.data[0]);
av_free(ost->forced_kf_pts);
+#if CONFIG_SWSCALE
if (ost->video_resample)
sws_freeContext(ost->img_resample_ctx);
+#endif
if (ost->resample)
audio_resample_close(ost->resample);
if (ost->reformat_ctx)
@@ -4051,7 +4065,9 @@ static void show_help(void)
}
}
+#if CONFIG_SWSCALE
av_opt_show2(sws_opts, NULL,
AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0);
+#endif
}
static int opt_target(const char *opt, const char *arg)
--
1.7.5.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel