summaryrefslogtreecommitdiffstats
path: root/codec-cfg.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-01-12 14:05:46 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-01-12 14:05:46 +0000
commitd63fb8ba992a6b610615bde9c678f4b111bba667 (patch)
tree6ffd89cc8a88b2c37a2a55daffa3d27c03c61b25 /codec-cfg.c
parenteb96cc741e216ac2d0383671f280fe7484cfd334 (diff)
downloadmpv-d63fb8ba992a6b610615bde9c678f4b111bba667.tar.bz2
mpv-d63fb8ba992a6b610615bde9c678f4b111bba667.tar.xz
Replace the persistent CODECS_FLAG_SELECTED by a local "stringset" with
an almost-trivial implementation. This allows making the builtin codec structs const, and it also makes clearer that this "selected" status is not used outside the init functions. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25689 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'codec-cfg.c')
-rw-r--r--codec-cfg.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/codec-cfg.c b/codec-cfg.c
index 2d3e119601..945fb8b285 100644
--- a/codec-cfg.c
+++ b/codec-cfg.c
@@ -818,36 +818,30 @@ codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,
return NULL;
}
-void select_codec(char* codecname,int audioflag){
- int i;
- codecs_t *c;
-// printf("select_codec('%s')\n",codecname);
- if (audioflag) {
- i = nr_acodecs;
- c = audio_codecs;
- } else {
- i = nr_vcodecs;
- c = video_codecs;
- }
- if(i)
- for (/* NOTHING */; i--; c++)
- if(!strcmp(c->name,codecname))
- c->flags|=CODECS_FLAG_SELECTED;
+void stringset_init(stringset_t *set) {
+ *set = calloc(1, sizeof(char *));
}
-void codecs_reset_selection(int audioflag){
- int i;
- codecs_t *c;
- if (audioflag) {
- i = nr_acodecs;
- c = audio_codecs;
- } else {
- i = nr_vcodecs;
- c = video_codecs;
- }
- if(i)
- for (/* NOTHING */; i--; c++)
- c->flags&=(~CODECS_FLAG_SELECTED);
+void stringset_free(stringset_t *set) {
+ free(*set);
+ *set = NULL;
+}
+
+void stringset_add(stringset_t *set, const char *str) {
+ int count = 0;
+ while ((*set)[count]) count++;
+ count++;
+ *set = realloc(*set, sizeof(char *) * (count + 1));
+ (*set)[count - 1] = strdup(str);
+ (*set)[count] = NULL;
+}
+
+int stringset_test(stringset_t *set, const char *str) {
+ stringset_t s;
+ for (s = *set; *s; s++)
+ if (strcmp(*s, str) == 0)
+ return 1;
+ return 0;
}
void list_codecs(int audioflag){