Skip to content

Commit 5edab1d

Browse files
committed
cmdutils: remove sws_opts usage, simplify code
It has become unused as all code was switched to AVDictionary Signed-off-by: Michael Niedermayer <[email protected]>
1 parent 408c9cf commit 5edab1d

File tree

3 files changed

+13
-28
lines changed

3 files changed

+13
-28
lines changed

cmdutils.c

-24
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363

6464
static int init_report(const char *env);
6565

66-
struct SwsContext *sws_opts;
6766
AVDictionary *sws_dict;
6867
AVDictionary *swr_opts;
6968
AVDictionary *format_opts, *codec_opts, *resample_opts;
@@ -74,20 +73,11 @@ int hide_banner = 0;
7473

7574
void init_opts(void)
7675
{
77-
78-
if(CONFIG_SWSCALE)
79-
sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,
80-
NULL, NULL, NULL);
8176
av_dict_set(&sws_dict, "flags", "bicubic", 0);
8277
}
8378

8479
void uninit_opts(void)
8580
{
86-
#if CONFIG_SWSCALE
87-
sws_freeContext(sws_opts);
88-
sws_opts = NULL;
89-
#endif
90-
9181
av_dict_free(&swr_opts);
9282
av_dict_free(&sws_dict);
9383
av_dict_free(&format_opts);
@@ -577,11 +567,6 @@ int opt_default(void *optctx, const char *opt, const char *arg)
577567
av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
578568
return ret;
579569
}
580-
ret = av_opt_set(sws_opts, opt, arg, 0);
581-
if (ret < 0) {
582-
av_log(NULL, AV_LOG_ERROR, "Error setting option %s for sws_opts.\n", opt);
583-
return ret;
584-
}
585570

586571
av_dict_set(&sws_dict, opt, arg, FLAGS);
587572

@@ -658,9 +643,6 @@ static void finish_group(OptionParseContext *octx, int group_idx,
658643
*g = octx->cur_group;
659644
g->arg = arg;
660645
g->group_def = l->group_def;
661-
#if CONFIG_SWSCALE
662-
g->sws_opts = sws_opts;
663-
#endif
664646
g->sws_dict = sws_dict;
665647
g->swr_opts = swr_opts;
666648
g->codec_opts = codec_opts;
@@ -670,9 +652,6 @@ static void finish_group(OptionParseContext *octx, int group_idx,
670652
codec_opts = NULL;
671653
format_opts = NULL;
672654
resample_opts = NULL;
673-
#if CONFIG_SWSCALE
674-
sws_opts = NULL;
675-
#endif
676655
sws_dict = NULL;
677656
swr_opts = NULL;
678657
init_opts();
@@ -729,9 +708,6 @@ void uninit_parse_context(OptionParseContext *octx)
729708
av_dict_free(&l->groups[j].codec_opts);
730709
av_dict_free(&l->groups[j].format_opts);
731710
av_dict_free(&l->groups[j].resample_opts);
732-
#if CONFIG_SWSCALE
733-
sws_freeContext(l->groups[j].sws_opts);
734-
#endif
735711

736712
av_dict_free(&l->groups[j].sws_dict);
737713
av_dict_free(&l->groups[j].swr_opts);

cmdutils.h

-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ extern const int program_birth_year;
4646

4747
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
4848
extern AVFormatContext *avformat_opts;
49-
extern struct SwsContext *sws_opts;
5049
extern AVDictionary *sws_dict;
5150
extern AVDictionary *swr_opts;
5251
extern AVDictionary *format_opts, *codec_opts, *resample_opts;
@@ -278,7 +277,6 @@ typedef struct OptionGroup {
278277
AVDictionary *codec_opts;
279278
AVDictionary *format_opts;
280279
AVDictionary *resample_opts;
281-
struct SwsContext *sws_opts;
282280
AVDictionary *sws_dict;
283281
AVDictionary *swr_opts;
284282
} OptionGroup;

ffplay.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const int program_birth_year = 2003;
102102

103103
#define CURSOR_HIDE_DELAY 1000000
104104

105-
static int64_t sws_flags = SWS_BICUBIC;
105+
static unsigned sws_flags = SWS_BICUBIC;
106106

107107
typedef struct MyAVPacketList {
108108
AVPacket pkt;
@@ -1677,7 +1677,18 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, double
16771677
av_picture_copy(&pict, (AVPicture *)src_frame,
16781678
src_frame->format, vp->width, vp->height);
16791679
#else
1680-
av_opt_get_int(sws_opts, "sws_flags", 0, &sws_flags);
1680+
{
1681+
AVDictionaryEntry *e = av_dict_get(sws_dict, "sws_flags", NULL, 0);
1682+
if (e) {
1683+
const AVClass *class = sws_get_class();
1684+
const AVOption *o = av_opt_find(&class, "sws_flags", NULL, 0,
1685+
AV_OPT_SEARCH_FAKE_OBJ);
1686+
int ret = av_opt_eval_flags(&class, o, e->value, &sws_flags);
1687+
if (ret < 0)
1688+
exit(1);
1689+
}
1690+
}
1691+
16811692
is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
16821693
vp->width, vp->height, src_frame->format, vp->width, vp->height,
16831694
AV_PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);

0 commit comments

Comments
 (0)