comparison mencoder.c @ 18312:3b5b7e78b9af

Make EDL compilation unconditional
author uau
date Thu, 27 Apr 2006 12:40:29 +0000
parents 21cafb27aa03
children 5766a9d21992
comparison
equal deleted inserted replaced
18311:6727756ba981 18312:3b5b7e78b9af
266 */ 266 */
267 static int slowseek(float end_pts, demux_stream_t *d_video, demux_stream_t *d_audio, muxer_stream_t* mux_a, s_frame_data * frame_data, int framecopy, int print_info); 267 static int slowseek(float end_pts, demux_stream_t *d_video, demux_stream_t *d_audio, muxer_stream_t* mux_a, s_frame_data * frame_data, int framecopy, int print_info);
268 /// Deletes audio or video as told by -delay to sync 268 /// Deletes audio or video as told by -delay to sync
269 static void fixdelay(demux_stream_t *d_video, demux_stream_t *d_audio, muxer_stream_t* mux_a, s_frame_data * frame_data, int framecopy); 269 static void fixdelay(demux_stream_t *d_video, demux_stream_t *d_audio, muxer_stream_t* mux_a, s_frame_data * frame_data, int framecopy);
270 270
271 #ifdef USE_EDL
272 #include "edl.h" 271 #include "edl.h"
273 static edl_record_ptr edl_records = NULL; ///< EDL entries memory area 272 static edl_record_ptr edl_records = NULL; ///< EDL entries memory area
274 static edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records 273 static edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records
275 static short edl_muted; ///< Stores whether EDL is currently in muted mode. 274 static short edl_muted; ///< Stores whether EDL is currently in muted mode.
276 static short edl_seeking; ///< When non-zero, stream is seekable. 275 static short edl_seeking; ///< When non-zero, stream is seekable.
277 static short edl_seek_type; ///< When non-zero, frames are discarded instead of seeking. 276 static short edl_seek_type; ///< When non-zero, frames are discarded instead of seeking.
278 /** \brief Seeks for EDL 277 /** \brief Seeks for EDL
279 \return 1 for success, 0 for failure, 2 for EOF. 278 \return 1 for success, 0 for failure, 2 for EOF.
280 */ 279 */
281 static int edl_seek(edl_record_ptr next_edl_record, demuxer_t* demuxer, demux_stream_t *d_audio, muxer_stream_t* mux_a, s_frame_data * frame_data, int framecopy); 280 static int edl_seek(edl_record_ptr next_edl_record, demuxer_t* demuxer, demux_stream_t *d_audio, muxer_stream_t* mux_a, s_frame_data * frame_data, int framecopy);
282 #endif
283 281
284 #include "cfg-mencoder.h" 282 #include "cfg-mencoder.h"
285 283
286 #ifdef USE_DVDREAD 284 #ifdef USE_DVDREAD
287 #include "spudec.h" 285 #include "spudec.h"
1072 } 1070 }
1073 1071
1074 play_n_frames=play_n_frames_mf; 1072 play_n_frames=play_n_frames_mf;
1075 if (curfile && end_at_type == END_AT_TIME) end_at += mux_v->timer; 1073 if (curfile && end_at_type == END_AT_TIME) end_at += mux_v->timer;
1076 1074
1077 #ifdef USE_EDL
1078 if (edl_records) free_edl(edl_records); 1075 if (edl_records) free_edl(edl_records);
1079 next_edl_record = edl_records = NULL; 1076 next_edl_record = edl_records = NULL;
1080 edl_muted = 0; 1077 edl_muted = 0;
1081 edl_seeking = 1; 1078 edl_seeking = 1;
1082 if (edl_filename) { 1079 if (edl_filename) {
1083 next_edl_record = edl_records = edl_parse_file(); 1080 next_edl_record = edl_records = edl_parse_file();
1084 } 1081 }
1085 #endif
1086 1082
1087 if (sh_audio && audio_delay != 0.) fixdelay(d_video, d_audio, mux_a, &frame_data, mux_v->codec==VCODEC_COPY); 1083 if (sh_audio && audio_delay != 0.) fixdelay(d_video, d_audio, mux_a, &frame_data, mux_v->codec==VCODEC_COPY);
1088 1084
1089 while(!at_eof){ 1085 while(!at_eof){
1090 1086
1100 if(play_n_frames>=0){ 1096 if(play_n_frames>=0){
1101 --play_n_frames; 1097 --play_n_frames;
1102 if(play_n_frames<0) break; 1098 if(play_n_frames<0) break;
1103 } 1099 }
1104 1100
1105 #ifdef USE_EDL
1106 goto_redo_edl: 1101 goto_redo_edl:
1107 if (next_edl_record && sh_video && sh_video->pts >= next_edl_record->start_sec) { 1102 if (next_edl_record && sh_video && sh_video->pts >= next_edl_record->start_sec) {
1108 if (next_edl_record->action == EDL_SKIP && edl_seeking) { 1103 if (next_edl_record->action == EDL_SKIP && edl_seeking) {
1109 float last_pos = d_video->pts; 1104 float last_pos = d_video->pts;
1110 int result; 1105 int result;
1138 edl_muted = !edl_muted; // This variable does nothing for now. 1133 edl_muted = !edl_muted; // This variable does nothing for now.
1139 mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_MUTE: [%f]\n", next_edl_record->start_sec ); 1134 mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_MUTE: [%f]\n", next_edl_record->start_sec );
1140 next_edl_record=next_edl_record->next; 1135 next_edl_record=next_edl_record->next;
1141 } 1136 }
1142 } 1137 }
1143 #endif
1144 1138
1145 1139
1146 if(sh_audio){ 1140 if(sh_audio){
1147 // get audio: 1141 // get audio:
1148 while(mux_a->timer-audio_preload<mux_v->timer){ 1142 while(mux_a->timer-audio_preload<mux_v->timer){
1653 1647
1654 static float stop_time(demuxer_t* demuxer, muxer_stream_t* mux_v) { 1648 static float stop_time(demuxer_t* demuxer, muxer_stream_t* mux_v) {
1655 float timeleft = -1; 1649 float timeleft = -1;
1656 if (play_n_frames >= 0) timeleft = mux_v->timer + play_n_frames * (double)(mux_v->h.dwScale) / mux_v->h.dwRate; 1650 if (play_n_frames >= 0) timeleft = mux_v->timer + play_n_frames * (double)(mux_v->h.dwScale) / mux_v->h.dwRate;
1657 if (end_at_type == END_AT_TIME && (timeleft > end_at || timeleft == -1)) timeleft = end_at; 1651 if (end_at_type == END_AT_TIME && (timeleft > end_at || timeleft == -1)) timeleft = end_at;
1658 #ifdef USE_EDL
1659 if (next_edl_record && demuxer && demuxer->video) { // everything is OK to be checked 1652 if (next_edl_record && demuxer && demuxer->video) { // everything is OK to be checked
1660 float tmp = mux_v->timer + next_edl_record->start_sec - demuxer->video->pts; 1653 float tmp = mux_v->timer + next_edl_record->start_sec - demuxer->video->pts;
1661 if (timeleft == -1 || timeleft > tmp) { 1654 if (timeleft == -1 || timeleft > tmp) {
1662 // There's less time in EDL than what we already know 1655 // There's less time in EDL than what we already know
1663 if (next_edl_record->action == EDL_SKIP && edl_seeking) { 1656 if (next_edl_record->action == EDL_SKIP && edl_seeking) {
1666 //timeleft = next_edl_record->start_sec - demuxer->video->pts; 1659 //timeleft = next_edl_record->start_sec - demuxer->video->pts;
1667 // For the moment (and probably forever) EDL mute doesn't work in MEncoder 1660 // For the moment (and probably forever) EDL mute doesn't work in MEncoder
1668 } 1661 }
1669 } 1662 }
1670 } 1663 }
1671 #endif
1672 return timeleft; 1664 return timeleft;
1673 } 1665 }
1674 1666
1675 static float calc_a_pts(demux_stream_t *d_audio) { 1667 static float calc_a_pts(demux_stream_t *d_audio) {
1676 sh_audio_t * sh_audio = d_audio ? d_audio->sh : NULL; 1668 sh_audio_t * sh_audio = d_audio ? d_audio->sh : NULL;
1741 if (vfilter) { 1733 if (vfilter) {
1742 int softskip = (vfilter->control(vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) == CONTROL_TRUE); 1734 int softskip = (vfilter->control(vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) == CONTROL_TRUE);
1743 decode_video(sh_video, frame_data->start, frame_data->in_size, !softskip, MP_NOPTS_VALUE); 1735 decode_video(sh_video, frame_data->start, frame_data->in_size, !softskip, MP_NOPTS_VALUE);
1744 } 1736 }
1745 1737
1746 #ifdef USE_EDL
1747 if (print_info) mp_msg(MSGT_MENCODER, MSGL_STATUS, 1738 if (print_info) mp_msg(MSGT_MENCODER, MSGL_STATUS,
1748 "EDL SKIP: Start: %.2f End: %.2f Current: V: %.2f A: %.2f \r", 1739 "EDL SKIP: Start: %.2f End: %.2f Current: V: %.2f A: %.2f \r",
1749 next_edl_record->start_sec, next_edl_record->stop_sec, 1740 next_edl_record->start_sec, next_edl_record->stop_sec,
1750 sh_video->pts, a_pts); 1741 sh_video->pts, a_pts);
1751 #endif
1752 } 1742 }
1753 if (interrupted) return 2; 1743 if (interrupted) return 2;
1754 return 1; 1744 return 1;
1755 } 1745 }
1756 1746
1773 else if (sh_video->pts - frame_data->frame_time + audio_delay >= a_pts) return; 1763 else if (sh_video->pts - frame_data->frame_time + audio_delay >= a_pts) return;
1774 1764
1775 slowseek(a_pts - audio_delay, d_video, d_audio, mux_a, frame_data, framecopy, 0); 1765 slowseek(a_pts - audio_delay, d_video, d_audio, mux_a, frame_data, framecopy, 0);
1776 } 1766 }
1777 1767
1778 #ifdef USE_EDL
1779 static int edl_seek(edl_record_ptr next_edl_record, demuxer_t* demuxer, demux_stream_t *d_audio, muxer_stream_t* mux_a, s_frame_data * frame_data, int framecopy) { 1768 static int edl_seek(edl_record_ptr next_edl_record, demuxer_t* demuxer, demux_stream_t *d_audio, muxer_stream_t* mux_a, s_frame_data * frame_data, int framecopy) {
1780 sh_video_t * sh_video = demuxer->video ? demuxer->video->sh : NULL; 1769 sh_video_t * sh_video = demuxer->video ? demuxer->video->sh : NULL;
1781 1770
1782 if (!sh_video) return 0; 1771 if (!sh_video) return 0;
1783 if (sh_video->pts >= next_edl_record->stop_sec) return 1; // nothing to do... 1772 if (sh_video->pts >= next_edl_record->stop_sec) return 1; // nothing to do...
1797 1786
1798 // slow seek, read every frame. 1787 // slow seek, read every frame.
1799 1788
1800 return slowseek(next_edl_record->stop_sec, demuxer->video, d_audio, mux_a, frame_data, framecopy, 1); 1789 return slowseek(next_edl_record->stop_sec, demuxer->video, d_audio, mux_a, frame_data, framecopy, 1);
1801 } 1790 }
1802 #endif