Commit dd53af4b authored by Anton Khirnov's avatar Anton Khirnov

avplay: drop support for building without lavfi

lavfi has been considered to be stable for a while now, so it is enabled
in most configurations. Supporting avplay without lavfi requires a lot
of nontrivial ifdef mess for no good reason.
parent 5781bfae
...@@ -37,16 +37,13 @@ ...@@ -37,16 +37,13 @@
#include "libavutil/time.h" #include "libavutil/time.h"
#include "libavformat/avformat.h" #include "libavformat/avformat.h"
#include "libavdevice/avdevice.h" #include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavresample/avresample.h" #include "libavresample/avresample.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "libavcodec/avfft.h" #include "libavcodec/avfft.h"
#if CONFIG_AVFILTER #include "libavfilter/avfilter.h"
# include "libavfilter/avfilter.h" #include "libavfilter/buffersink.h"
# include "libavfilter/buffersink.h" #include "libavfilter/buffersrc.h"
# include "libavfilter/buffersrc.h"
#endif
#include "cmdutils.h" #include "cmdutils.h"
...@@ -204,9 +201,6 @@ typedef struct PlayerState { ...@@ -204,9 +201,6 @@ typedef struct PlayerState {
int pictq_size, pictq_rindex, pictq_windex; int pictq_size, pictq_rindex, pictq_windex;
SDL_mutex *pictq_mutex; SDL_mutex *pictq_mutex;
SDL_cond *pictq_cond; SDL_cond *pictq_cond;
#if !CONFIG_AVFILTER
struct SwsContext *img_convert_ctx;
#endif
// QETimer *video_timer; // QETimer *video_timer;
char filename[1024]; char filename[1024];
...@@ -214,10 +208,8 @@ typedef struct PlayerState { ...@@ -214,10 +208,8 @@ typedef struct PlayerState {
PtsCorrectionContext pts_ctx; PtsCorrectionContext pts_ctx;
#if CONFIG_AVFILTER
AVFilterContext *in_video_filter; // the first filter in the video chain AVFilterContext *in_video_filter; // the first filter in the video chain
AVFilterContext *out_video_filter; // the last filter in the video chain AVFilterContext *out_video_filter; // the last filter in the video chain
#endif
float skip_frames; float skip_frames;
float skip_frames_index; float skip_frames_index;
...@@ -266,9 +258,7 @@ static int framedrop = 1; ...@@ -266,9 +258,7 @@ static int framedrop = 1;
static int infinite_buffer = 0; static int infinite_buffer = 0;
static int rdftspeed = 20; static int rdftspeed = 20;
#if CONFIG_AVFILTER
static char *vfilters = NULL; static char *vfilters = NULL;
#endif
static int autorotate = 1; static int autorotate = 1;
/* current context */ /* current context */
...@@ -653,21 +643,10 @@ static void video_image_display(PlayerState *is) ...@@ -653,21 +643,10 @@ static void video_image_display(PlayerState *is)
vp = &is->pictq[is->pictq_rindex]; vp = &is->pictq[is->pictq_rindex];
if (vp->bmp) { if (vp->bmp) {
#if CONFIG_AVFILTER
if (!vp->sar.num) if (!vp->sar.num)
aspect_ratio = 0; aspect_ratio = 0;
else else
aspect_ratio = av_q2d(vp->sar); aspect_ratio = av_q2d(vp->sar);
#else
/* XXX: use variable in the frame */
if (is->video_st->sample_aspect_ratio.num)
aspect_ratio = av_q2d(is->video_st->sample_aspect_ratio);
else if (is->video_st->codec->sample_aspect_ratio.num)
aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio);
else
aspect_ratio = 0;
#endif
if (aspect_ratio <= 0.0) if (aspect_ratio <= 0.0)
aspect_ratio = 1.0; aspect_ratio = 1.0;
aspect_ratio *= (float)vp->width / (float)vp->height; aspect_ratio *= (float)vp->width / (float)vp->height;
...@@ -880,15 +859,9 @@ static int video_open(PlayerState *is) ...@@ -880,15 +859,9 @@ static int video_open(PlayerState *is)
} else if (!is_full_screen && screen_width) { } else if (!is_full_screen && screen_width) {
w = screen_width; w = screen_width;
h = screen_height; h = screen_height;
#if CONFIG_AVFILTER
} else if (is->out_video_filter && is->out_video_filter->inputs[0]) { } else if (is->out_video_filter && is->out_video_filter->inputs[0]) {
w = is->out_video_filter->inputs[0]->w; w = is->out_video_filter->inputs[0]->w;
h = is->out_video_filter->inputs[0]->h; h = is->out_video_filter->inputs[0]->h;
#else
} else if (is->video_st && is->video_st->codec->width) {
w = is->video_st->codec->width;
h = is->video_st->codec->height;
#endif
} else { } else {
w = 640; w = 640;
h = 480; h = 480;
...@@ -1229,10 +1202,6 @@ static void player_close(PlayerState *is) ...@@ -1229,10 +1202,6 @@ static void player_close(PlayerState *is)
SDL_DestroyCond(is->pictq_cond); SDL_DestroyCond(is->pictq_cond);
SDL_DestroyMutex(is->subpq_mutex); SDL_DestroyMutex(is->subpq_mutex);
SDL_DestroyCond(is->subpq_cond); SDL_DestroyCond(is->subpq_cond);
#if !CONFIG_AVFILTER
if (is->img_convert_ctx)
sws_freeContext(is->img_convert_ctx);
#endif
} }
static void do_exit(void) static void do_exit(void)
...@@ -1262,15 +1231,9 @@ static void alloc_picture(void *opaque) ...@@ -1262,15 +1231,9 @@ static void alloc_picture(void *opaque)
if (vp->bmp) if (vp->bmp)
SDL_FreeYUVOverlay(vp->bmp); SDL_FreeYUVOverlay(vp->bmp);
#if CONFIG_AVFILTER
vp->width = is->out_video_filter->inputs[0]->w; vp->width = is->out_video_filter->inputs[0]->w;
vp->height = is->out_video_filter->inputs[0]->h; vp->height = is->out_video_filter->inputs[0]->h;
vp->pix_fmt = is->out_video_filter->inputs[0]->format; vp->pix_fmt = is->out_video_filter->inputs[0]->format;
#else
vp->width = is->video_st->codec->width;
vp->height = is->video_st->codec->height;
vp->pix_fmt = is->video_st->codec->pix_fmt;
#endif
vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height, vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height,
SDL_YV12_OVERLAY, SDL_YV12_OVERLAY,
...@@ -1295,9 +1258,7 @@ static void alloc_picture(void *opaque) ...@@ -1295,9 +1258,7 @@ static void alloc_picture(void *opaque)
static int queue_picture(PlayerState *is, AVFrame *src_frame, double pts, int64_t pos) static int queue_picture(PlayerState *is, AVFrame *src_frame, double pts, int64_t pos)
{ {
VideoPicture *vp; VideoPicture *vp;
#if !CONFIG_AVFILTER
int dst_pix_fmt = AV_PIX_FMT_YUV420P;
#endif
/* wait until we have space to put a new picture */ /* wait until we have space to put a new picture */
SDL_LockMutex(is->pictq_mutex); SDL_LockMutex(is->pictq_mutex);
...@@ -1319,13 +1280,8 @@ static int queue_picture(PlayerState *is, AVFrame *src_frame, double pts, int64_ ...@@ -1319,13 +1280,8 @@ static int queue_picture(PlayerState *is, AVFrame *src_frame, double pts, int64_
/* alloc or resize hardware picture buffer */ /* alloc or resize hardware picture buffer */
if (!vp->bmp || vp->reallocate || if (!vp->bmp || vp->reallocate ||
#if CONFIG_AVFILTER
vp->width != is->out_video_filter->inputs[0]->w || vp->width != is->out_video_filter->inputs[0]->w ||
vp->height != is->out_video_filter->inputs[0]->h) { vp->height != is->out_video_filter->inputs[0]->h) {
#else
vp->width != is->video_st->codec->width ||
vp->height != is->video_st->codec->height) {
#endif
SDL_Event event; SDL_Event event;
vp->allocated = 0; vp->allocated = 0;
...@@ -1364,22 +1320,10 @@ static int queue_picture(PlayerState *is, AVFrame *src_frame, double pts, int64_ ...@@ -1364,22 +1320,10 @@ static int queue_picture(PlayerState *is, AVFrame *src_frame, double pts, int64_
linesize[1] = vp->bmp->pitches[2]; linesize[1] = vp->bmp->pitches[2];
linesize[2] = vp->bmp->pitches[1]; linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER
// FIXME use direct rendering // FIXME use direct rendering
av_image_copy(data, linesize, src_frame->data, src_frame->linesize, av_image_copy(data, linesize, src_frame->data, src_frame->linesize,
vp->pix_fmt, vp->width, vp->height); vp->pix_fmt, vp->width, vp->height);
#else
av_opt_get_int(sws_opts, "sws_flags", 0, &sws_flags);
is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
dst_pix_fmt, sws_flags, NULL, NULL, NULL);
if (!is->img_convert_ctx) {
fprintf(stderr, "Cannot initialize the conversion context\n");
exit(1);
}
sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
0, vp->height, data, linesize);
#endif
/* update the bitmap content */ /* update the bitmap content */
SDL_UnlockYUVOverlay(vp->bmp); SDL_UnlockYUVOverlay(vp->bmp);
...@@ -1483,7 +1427,6 @@ static int get_video_frame(PlayerState *is, AVFrame *frame, int64_t *pts, AVPack ...@@ -1483,7 +1427,6 @@ static int get_video_frame(PlayerState *is, AVFrame *frame, int64_t *pts, AVPack
return 0; return 0;
} }
#if CONFIG_AVFILTER
static int configure_video_filters(AVFilterGraph *graph, PlayerState *is, const char *vfilters) static int configure_video_filters(AVFilterGraph *graph, PlayerState *is, const char *vfilters)
{ {
char sws_flags_str[128]; char sws_flags_str[128];
...@@ -1579,8 +1522,6 @@ static int configure_video_filters(AVFilterGraph *graph, PlayerState *is, const ...@@ -1579,8 +1522,6 @@ static int configure_video_filters(AVFilterGraph *graph, PlayerState *is, const
return ret; return ret;
} }
#endif /* CONFIG_AVFILTER */
static int video_thread(void *arg) static int video_thread(void *arg)
{ {
AVPacket pkt = { 0 }; AVPacket pkt = { 0 };
...@@ -1590,7 +1531,6 @@ static int video_thread(void *arg) ...@@ -1590,7 +1531,6 @@ static int video_thread(void *arg)
double pts; double pts;
int ret; int ret;
#if CONFIG_AVFILTER
AVFilterGraph *graph = avfilter_graph_alloc(); AVFilterGraph *graph = avfilter_graph_alloc();
AVFilterContext *filt_out = NULL, *filt_in = NULL; AVFilterContext *filt_out = NULL, *filt_in = NULL;
int last_w = is->video_st->codec->width; int last_w = is->video_st->codec->width;
...@@ -1604,19 +1544,14 @@ static int video_thread(void *arg) ...@@ -1604,19 +1544,14 @@ static int video_thread(void *arg)
goto the_end; goto the_end;
filt_in = is->in_video_filter; filt_in = is->in_video_filter;
filt_out = is->out_video_filter; filt_out = is->out_video_filter;
#endif
if (!frame) { if (!frame) {
#if CONFIG_AVFILTER
avfilter_graph_free(&graph); avfilter_graph_free(&graph);
#endif
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
for (;;) { for (;;) {
#if CONFIG_AVFILTER
AVRational tb; AVRational tb;
#endif
while (is->paused && !is->videoq.abort_request) while (is->paused && !is->videoq.abort_request)
SDL_Delay(10); SDL_Delay(10);
...@@ -1629,7 +1564,6 @@ static int video_thread(void *arg) ...@@ -1629,7 +1564,6 @@ static int video_thread(void *arg)
if (!ret) if (!ret)
continue; continue;
#if CONFIG_AVFILTER
if ( last_w != is->video_st->codec->width if ( last_w != is->video_st->codec->width
|| last_h != is->video_st->codec->height) { || last_h != is->video_st->codec->height) {
av_log(NULL, AV_LOG_TRACE, "Changing size %dx%d -> %dx%d\n", last_w, last_h, av_log(NULL, AV_LOG_TRACE, "Changing size %dx%d -> %dx%d\n", last_w, last_h,
...@@ -1669,10 +1603,6 @@ static int video_thread(void *arg) ...@@ -1669,10 +1603,6 @@ static int video_thread(void *arg)
pts = pts_int * av_q2d(is->video_st->time_base); pts = pts_int * av_q2d(is->video_st->time_base);
ret = output_picture2(is, frame, pts, 0); ret = output_picture2(is, frame, pts, 0);
} }
#else
pts = pts_int * av_q2d(is->video_st->time_base);
ret = output_picture2(is, frame, pts, pkt.pos);
#endif
if (ret < 0) if (ret < 0)
goto the_end; goto the_end;
...@@ -1683,10 +1613,8 @@ static int video_thread(void *arg) ...@@ -1683,10 +1613,8 @@ static int video_thread(void *arg)
stream_pause(player); stream_pause(player);
} }
the_end: the_end:
#if CONFIG_AVFILTER
av_freep(&vfilters); av_freep(&vfilters);
avfilter_graph_free(&graph); avfilter_graph_free(&graph);
#endif
av_packet_unref(&pkt); av_packet_unref(&pkt);
av_frame_free(&frame); av_frame_free(&frame);
return 0; return 0;
...@@ -2993,9 +2921,7 @@ static const OptionDef options[] = { ...@@ -2993,9 +2921,7 @@ static const OptionDef options[] = {
{ "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" }, { "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" },
{ "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" }, { "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" },
{ "window_title", OPT_STRING | HAS_ARG, { &window_title }, "set window title", "window title" }, { "window_title", OPT_STRING | HAS_ARG, { &window_title }, "set window title", "window title" },
#if CONFIG_AVFILTER
{ "vf", OPT_STRING | HAS_ARG, { &vfilters }, "video filters", "filter list" }, { "vf", OPT_STRING | HAS_ARG, { &vfilters }, "video filters", "filter list" },
#endif
{ "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" }, { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" },
{ "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { opt_default }, "generic catch all option", "" }, { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { opt_default }, "generic catch all option", "" },
{ "i", 0, { NULL }, "avconv compatibility dummy option", ""}, { "i", 0, { NULL }, "avconv compatibility dummy option", ""},
...@@ -3022,9 +2948,6 @@ void show_help_default(const char *opt, const char *arg) ...@@ -3022,9 +2948,6 @@ void show_help_default(const char *opt, const char *arg)
printf("\n"); printf("\n");
show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM); show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
#if !CONFIG_AVFILTER
show_help_children(sws_get_class(), AV_OPT_FLAG_ENCODING_PARAM);
#endif
printf("\nWhile playing:\n" printf("\nWhile playing:\n"
"q, ESC quit\n" "q, ESC quit\n"
"f toggle full screen\n" "f toggle full screen\n"
...@@ -3065,9 +2988,7 @@ int main(int argc, char **argv) ...@@ -3065,9 +2988,7 @@ int main(int argc, char **argv)
#if CONFIG_AVDEVICE #if CONFIG_AVDEVICE
avdevice_register_all(); avdevice_register_all();
#endif #endif
#if CONFIG_AVFILTER
avfilter_register_all(); avfilter_register_all();
#endif
av_register_all(); av_register_all();
avformat_network_init(); avformat_network_init();
......
...@@ -2400,9 +2400,9 @@ avconv_deps="avcodec avfilter avformat avresample swscale" ...@@ -2400,9 +2400,9 @@ avconv_deps="avcodec avfilter avformat avresample swscale"
avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter
fps_filter null_filter resample_filter scale_filter fps_filter null_filter resample_filter scale_filter
setpts_filter trim_filter" setpts_filter trim_filter"
avplay_deps="avcodec avformat avresample swscale sdl" avplay_deps="avcodec avfilter avformat avresample sdl"
avplay_libs='$sdl_libs' avplay_libs='$sdl_libs'
avplay_select="rdft transpose_filter hflip_filter vflip_filter" avplay_select="rdft format_filter transpose_filter hflip_filter vflip_filter"
avprobe_deps="avcodec avformat" avprobe_deps="avcodec avformat"
# documentation # documentation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment