Mercurial > mplayer.hg
comparison libmpcodecs/ve.c @ 32476:af9ef007bec6
Add the -force-key-frames option.
author | cigaes |
---|---|
date | Fri, 29 Oct 2010 13:50:05 +0000 |
parents | 4614728cab25 |
children |
comparison
equal
deleted
inserted
replaced
32475:87d55484ceaa | 32476:af9ef007bec6 |
---|---|
24 #include "mp_msg.h" | 24 #include "mp_msg.h" |
25 | 25 |
26 #include "img_format.h" | 26 #include "img_format.h" |
27 #include "mp_image.h" | 27 #include "mp_image.h" |
28 #include "vf.h" | 28 #include "vf.h" |
29 #include "ve.h" | |
29 | 30 |
30 extern const vf_info_t ve_info_lavc; | 31 extern const vf_info_t ve_info_lavc; |
31 extern const vf_info_t ve_info_vfw; | 32 extern const vf_info_t ve_info_vfw; |
32 extern const vf_info_t ve_info_raw; | 33 extern const vf_info_t ve_info_raw; |
33 extern const vf_info_t ve_info_libdv; | 34 extern const vf_info_t ve_info_libdv; |
71 | 72 |
72 vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args){ | 73 vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args){ |
73 char* vf_args[] = { "_oldargs_", args, NULL }; | 74 char* vf_args[] = { "_oldargs_", args, NULL }; |
74 return vf_open_plugin(encoder_list,next,name,vf_args); | 75 return vf_open_plugin(encoder_list,next,name,vf_args); |
75 } | 76 } |
77 | |
78 static double *forced_key_frames_ts; | |
79 static int forced_key_frames_number; | |
80 static int forced_key_frames_idx; | |
81 | |
82 int parse_forced_key_frames(const m_option_t *opt, const char *arg) | |
83 { | |
84 double ts; | |
85 const char *p; | |
86 int nts = 1, idx = 0, len; | |
87 | |
88 for (p = arg; *p; p++) | |
89 nts += *p == ','; | |
90 free(forced_key_frames_ts); | |
91 forced_key_frames_ts = calloc(sizeof(*forced_key_frames_ts), nts); | |
92 p = arg; | |
93 while (1) { | |
94 len = parse_timestring(p, &ts, ','); | |
95 if (!len) { | |
96 mp_msg(MSGT_CFGPARSER, MSGL_ERR, | |
97 "Option force-key-frames: invalid time: '%s'\n", p); | |
98 return M_OPT_INVALID; | |
99 } | |
100 forced_key_frames_ts[idx++] = ts; | |
101 if (!p[len]) | |
102 break; | |
103 p += len + 1; | |
104 } | |
105 forced_key_frames_number = idx; | |
106 forced_key_frames_idx = 0; | |
107 for (idx = 1; idx < forced_key_frames_number; idx++) { | |
108 if (forced_key_frames_ts[idx - 1] >= forced_key_frames_ts[idx]) { | |
109 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option force-key-frames: " | |
110 "timestamps are not in ascending order\n"); | |
111 return M_OPT_INVALID; | |
112 } | |
113 } | |
114 return 0; | |
115 } | |
116 | |
117 int is_forced_key_frame(double pts) | |
118 { | |
119 if (forced_key_frames_idx < forced_key_frames_number && | |
120 pts >= forced_key_frames_ts[forced_key_frames_idx]) { | |
121 forced_key_frames_idx++; | |
122 if (forced_key_frames_idx >= forced_key_frames_number) { | |
123 free(forced_key_frames_ts); | |
124 forced_key_frames_number = 0; | |
125 } | |
126 return 1; | |
127 } | |
128 return 0; | |
129 } |