1 --- /dev/null 2008-11-20 00:48:23.364006051 -0600
2 +++ mplayer-1.0_rc2_p27725/libmpcodecs/vf_fixpts.c 2008-12-17 14:07:32.000000000 -0600
5 + Copyright (C) 2007 Nicolas George <nicolas.george@normalesup.org>
7 + This program is free software; you can redistribute it and/or modify
8 + it under the terms of the GNU General Public License as published by
9 + the Free Software Foundation; either version 2 of the License, or
10 + (at your option) any later version.
12 + This program is distributed in the hope that it will be useful,
13 + but WITHOUT ANY WARRANTY; without even the implied warranty of
14 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 + GNU General Public License for more details.
17 + You should have received a copy of the GNU General Public License
18 + along with this program; if not, write to the Free Software
19 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 +#include <inttypes.h>
31 +#include "img_format.h"
32 +#include "mp_image.h"
40 + unsigned have_step: 1;
44 +static int put_image(vf_instance_t *vf, mp_image_t *src, double pts)
46 + struct vf_priv_s *p = vf->priv;
49 + if(pts == MP_NOPTS_VALUE)
50 + printf("PTS: undef\n");
52 + printf("PTS: %f\n", pts);
54 + if(pts != MP_NOPTS_VALUE && p->autostart != 0) {
56 + if(p->autostart > 0)
58 + } else if(pts != MP_NOPTS_VALUE && p->autostep > 0) {
59 + p->step = pts - p->current;
63 + } else if(p->have_step) {
64 + p->current += p->step;
67 + pts = MP_NOPTS_VALUE;
69 + return vf_next_put_image(vf, src, pts);
72 +static void uninit(vf_instance_t *vf)
77 +static int parse_args(struct vf_priv_s *p, const char *args)
80 + double num, denom = 1;
85 + if(sscanf(args, "print%n", &pos) == 0 && pos > 0) {
87 + } else if(sscanf(args, "fps=%lf%n/%lf%n", &num, &pos, &denom, &pos) >= 1
89 + p->step = denom / num;
91 + } else if(sscanf(args, "start=%lf%n", &num, &pos) >= 1 && pos > 0) {
93 + } else if(sscanf(args, "autostart=%d%n", &iarg, &pos) == 1 && pos > 0) {
94 + p->autostart = iarg;
95 + } else if(sscanf(args, "autofps=%d%n", &iarg, &pos) == 1 && pos > 0) {
98 + mp_msg(MSGT_VFILTER, MSGL_FATAL,
99 + "fixpts: unknown suboption: %s\n", args);
109 +static int open(vf_instance_t *vf, char *args)
111 + struct vf_priv_s *p;
112 + struct vf_priv_s ptmp = {
121 + if(!parse_args(&ptmp, args == NULL ? "" : args))
124 + vf->put_image = put_image;
125 + vf->uninit = uninit;
126 + vf->priv = p = malloc(sizeof(struct vf_priv_s));
128 + p->current = -p->step;
133 +vf_info_t vf_info_fixpts = {
134 + "Fix presentation timestamps",
141 diff -ur mplayer-1.0_rc2_p27725-orig/cfg-mencoder.h mplayer-1.0_rc2_p27725/cfg-mencoder.h
142 --- mplayer-1.0_rc2_p27725-orig/cfg-mencoder.h 2008-08-12 09:30:37.000000000 -0500
143 +++ mplayer-1.0_rc2_p27725/cfg-mencoder.h 2008-12-17 14:07:37.000000000 -0600
146 {"odml", &write_odml, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
147 {"noodml", &write_odml, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
149 + {"keep-pts", &keep_pts, CONF_TYPE_FLAG, 0, 0, 1, NULL},
150 + {"nokeep-pts", &keep_pts, CONF_TYPE_FLAG, 0, 1, 0, NULL},
152 // info header strings
153 {"info", info_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
154 diff -ur mplayer-1.0_rc2_p27725-orig/DOCS/man/en/mplayer.1 mplayer-1.0_rc2_p27725/DOCS/man/en/mplayer.1
155 --- mplayer-1.0_rc2_p27725-orig/DOCS/man/en/mplayer.1 2008-10-06 20:04:15.000000000 -0500
156 +++ mplayer-1.0_rc2_p27725/DOCS/man/en/mplayer.1 2008-12-17 14:07:42.000000000 -0600
157 @@ -7171,6 +7171,48 @@
158 Threshold below which a pixel value is considered black (default: 32).
163 +Fixes the presentation timestamps (PTS) of the frames.
164 +By default, the PTS passed to the next filter is dropped, but the following
165 +options can change that:
168 +Print the incoming PTS.
170 +Specify a frame per second value.
172 +Specify an initial value for the PTS.
176 +incoming PTS as the initial PTS.
177 +All previous pts are kept, so setting a huge value or \-1 keeps the PTS
182 +incoming PTS after the end of autostart to determine the framerate.
190 +.IPs "\-vf fixpts=fps=24000/1001,ass,fixpts"
191 +Generates a new sequence of PTS, uses it for ASS subtitles, then drops it.
192 +Generating a new sequence is useful when the timestamps are reset during the
193 +program; this is frequent on DVDs.
194 +Dropping it may be necessary to avoid confusing encoders.
200 +Using this filter together with any sort of seeking (including -ss and EDLs)
201 +may make demons fly out of your nose.
205 .SH "GENERAL ENCODING OPTIONS (MENCODER ONLY)"
206 @@ -7293,6 +7335,14 @@
207 Do not write OpenDML index for AVI files >1GB.
211 +Send the original presentation timestamp (PTS) down the filter and encoder
213 +This may cause incorrect output ("badly interleaved") if the original PTS
214 +are wrong or the framerate is changed, but can be necessary for certain
215 +filters (such as ASS).
221 diff -ur mplayer-1.0_rc2_p27725-orig/libass/ass_cache.c mplayer-1.0_rc2_p27725/libass/ass_cache.c
222 --- mplayer-1.0_rc2_p27725-orig/libass/ass_cache.c 2008-05-28 15:17:52.000000000 -0500
223 +++ mplayer-1.0_rc2_p27725/libass/ass_cache.c 2008-12-17 14:07:45.000000000 -0600
228 +static int glyph_compare(void* key1, void* key2, size_t key_size) {
229 + glyph_hash_key_t* a = key1;
230 + glyph_hash_key_t* b = key2;
232 + a->font == b->font &&
233 + a->size == b->size &&
235 + a->bold == b->bold &&
236 + a->italic == b->italic &&
237 + a->scale_x == b->scale_x &&
238 + a->scale_y == b->scale_y &&
239 + a->advance.x == b->advance.x &&
240 + a->advance.y == b->advance.y &&
241 + a->outline == b->outline;
244 +static unsigned glyph_hash(void* buf, size_t len)
246 + glyph_hash_key_t* g = buf;
247 + unsigned hval = FNV1_32A_INIT;
248 + hval = fnv_32a_buf(&g->font, sizeof(g->font), hval);
249 + hval = fnv_32a_buf(&g->size, sizeof(g->size), hval);
250 + hval = fnv_32a_buf(&g->ch, sizeof(g->ch), hval);
251 + hval = fnv_32a_buf(&g->bold, sizeof(g->bold), hval);
252 + hval = fnv_32a_buf(&g->italic, sizeof(g->italic), hval);
253 + hval = fnv_32a_buf(&g->scale_x, sizeof(g->scale_x), hval);
254 + hval = fnv_32a_buf(&g->scale_y, sizeof(g->scale_y), hval);
255 + hval = fnv_32a_buf(&g->advance.x, sizeof(g->advance.x), hval);
256 + hval = fnv_32a_buf(&g->advance.y, sizeof(g->advance.y), hval);
257 + hval = fnv_32a_buf(&g->outline, sizeof(g->outline), hval);
261 void* cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val)
263 return hashmap_insert(glyph_cache, key, val);
265 glyph_cache = hashmap_init(sizeof(glyph_hash_key_t),
266 sizeof(glyph_hash_val_t),
268 - glyph_hash_dtor, NULL, NULL);
274 void ass_glyph_cache_done(void)
275 diff -ur mplayer-1.0_rc2_p27725-orig/libmpcodecs/vf.c mplayer-1.0_rc2_p27725/libmpcodecs/vf.c
276 --- mplayer-1.0_rc2_p27725-orig/libmpcodecs/vf.c 2008-08-12 09:30:35.000000000 -0500
277 +++ mplayer-1.0_rc2_p27725/libmpcodecs/vf.c 2008-12-17 14:07:37.000000000 -0600
279 extern const vf_info_t vf_info_blackframe;
280 extern const vf_info_t vf_info_geq;
281 extern const vf_info_t vf_info_ow;
282 +extern const vf_info_t vf_info_fixpts;
284 // list of available filters:
285 static const vf_info_t* const filter_list[]={
294 diff -ur mplayer-1.0_rc2_p27725-orig/Makefile mplayer-1.0_rc2_p27725/Makefile
295 --- mplayer-1.0_rc2_p27725-orig/Makefile 2008-10-06 20:04:16.000000000 -0500
296 +++ mplayer-1.0_rc2_p27725/Makefile 2008-12-17 14:07:37.000000000 -0600
298 libmpcodecs/vf_field.c \
299 libmpcodecs/vf_fil.c \
300 libmpcodecs/vf_filmdint.c \
301 + libmpcodecs/vf_fixpts.c \
302 libmpcodecs/vf_flip.c \
303 libmpcodecs/vf_format.c \
304 libmpcodecs/vf_framestep.c \
305 diff -ur mplayer-1.0_rc2_p27725-orig/mencoder.c mplayer-1.0_rc2_p27725/mencoder.c
306 --- mplayer-1.0_rc2_p27725-orig/mencoder.c 2008-08-12 09:30:37.000000000 -0500
307 +++ mplayer-1.0_rc2_p27725/mencoder.c 2008-12-17 14:07:45.000000000 -0600
311 int encode_duplicates=1;
314 // infos are empty by default
315 char *info_name=NULL;
318 static muxer_t* muxer=NULL;
320 +void add_subtitles(char *filename, float fps, int silent)
324 + ass_track_t *asst = 0;
327 + if (filename == NULL) return;
329 + subd = sub_read_file(filename, fps);
333 + asst = ass_read_file(ass_library, filename, sub_cp);
335 + asst = ass_read_file(ass_library, filename, 0);
337 + if (ass_enabled && subd && !asst)
338 + asst = ass_read_subdata(ass_library, subd, fps);
340 + if (!asst && !subd && !silent)
342 + if(!subd && !silent)
344 + mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadSub,
345 + filename_recode(filename));
348 + if (!asst && !subd) return;
353 + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n",
354 + filename_recode(filename));
358 extern void print_wave_header(WAVEFORMATEX *h, int verbose_level);
360 int main(int argc,char* argv[]){
362 m_entry_set_options(mconfig,&filelist[curfile]);
363 filename = filelist[curfile].name;
366 + ass_library = ass_init();
370 mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_MissingFilename);
371 mencoder_exit(1,NULL);
376 -// after reading video params we should load subtitles because
377 -// we know fps so now we can adjust subtitles time to ~6 seconds AST
379 -// current_module="read_subtitles_file";
380 - if(sub_name && sub_name[0]){
381 - subdata=sub_read_file(sub_name[0], sh_video->fps);
382 - if(!subdata) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name[0]);
384 - if(sub_auto && filename) { // auto load sub file ...
387 - char *psub = get_path( "sub/" );
388 - tmp = sub_filenames((psub ? psub : ""), filename);
390 - subdata=sub_read_file(tmp[0], sh_video->fps);
396 // set up video encoder:
398 if (!curfile) { // curfile is non zero when a second file is opened
399 @@ -885,12 +908,72 @@
400 ve = sh_video->vfilter;
401 } else sh_video->vfilter = ve;
402 // append 'expand' filter, it fixes stride problems and renders osd:
404 + if (auto_expand && !ass_enabled) { /* we do not want both */
408 char* vf_args[] = { "osd", "1", NULL };
409 sh_video->vfilter=vf_open_filter(sh_video->vfilter,"expand",vf_args);
417 + for (i = 0; vf_settings[i].name; ++i)
418 + if (strcmp(vf_settings[i].name, "ass") == 0) {
423 + extern vf_info_t vf_info_ass;
424 + vf_info_t* libass_vfs[] = {&vf_info_ass, NULL};
425 + char* vf_arg[] = {"auto", "1", NULL};
426 + vf_instance_t* vf_ass = vf_open_plugin(libass_vfs,sh_video->vfilter,"ass",vf_arg);
428 + sh_video->vfilter=(void*)vf_ass;
430 + mp_msg(MSGT_CPLAYER,MSGL_ERR, "ASS: cannot add video filter\n");
434 + mp_msg(MSGT_MENCODER, MSGL_WARN, "Warning: -ass implies -keep-pts, "
435 + "which may cause \"badly interleaved\" files.\n");
440 sh_video->vfilter=append_filters(sh_video->vfilter);
444 + ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_INIT_EOSD, ass_library);
447 +// after reading video params we should load subtitles because
448 +// we know fps so now we can adjust subtitles time to ~6 seconds AST
450 +// current_module="read_subtitles_file";
451 + if(sub_name && sub_name[0]){
452 + for (i = 0; sub_name[i] != NULL; ++i)
453 + add_subtitles (sub_name[i], sh_video->fps, 0);
455 + if(sub_auto && filename) { // auto load sub file ...
458 + char *psub = get_path( "sub/" );
459 + tmp = sub_filenames((psub ? psub : ""), filename);
463 + add_subtitles (tmp[i], sh_video->fps, 0);
469 mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
470 init_best_video_codec(sh_video,video_codec_list,video_fm_list);
471 mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
472 @@ -1346,7 +1429,8 @@
473 // decode_video will callback down to ve_*.c encoders, through the video filters
474 {void *decoded_frame = decode_video(sh_video,frame_data.start,frame_data.in_size,
475 skip_flag>0 && (!sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE), MP_NOPTS_VALUE);
476 - blit_frame = decoded_frame && filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE);}
477 + blit_frame = decoded_frame && filter_video(sh_video, decoded_frame,
478 + keep_pts ? sh_video->pts : MP_NOPTS_VALUE);}
480 if (sh_video->vf_initialized < 0) mencoder_exit(1, NULL);
482 Only in mplayer-1.0_rc2_p27725: mencoder.c.orig