summaryrefslogtreecommitdiffstats
path: root/mencoder.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-04-26 17:11:04 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-04-26 17:11:04 +0300
commit95fba94860a02be5b50c4050f9ba2ac41daea3c2 (patch)
tree79ebb3fb8b351e8347c092e62331cd50b2a06a7b /mencoder.c
parent3c2d6d9a8e28900300d20830c309eea2d511cfc8 (diff)
parent0426d5d72df81217f32147d039f3eb29c009af12 (diff)
downloadmpv-95fba94860a02be5b50c4050f9ba2ac41daea3c2.tar.bz2
mpv-95fba94860a02be5b50c4050f9ba2ac41daea3c2.tar.xz
Merge svn changes up to r30917
Diffstat (limited to 'mencoder.c')
-rw-r--r--mencoder.c104
1 files changed, 32 insertions, 72 deletions
diff --git a/mencoder.c b/mencoder.c
index 0336c7086c..d449572851 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -65,6 +65,10 @@
#include "mp_fifo.h"
#include "get_path.h"
+#ifdef CONFIG_WIN32DLL
+#include "loader/drv.h" // for SetCodecPath()
+#endif
+
#include "stream/stream.h"
#include "libmpdemux/aviprint.h"
#include "libmpdemux/demuxer.h"
@@ -141,12 +145,6 @@ static int out_audio_codec=-1;
static int out_video_codec=-1;
int out_file_format=MUXER_TYPE_AVI; // default to AVI
-
-// audio stream skip/resync functions requires only for seeking.
-// (they should be implemented in the audio codec layer)
-//void skip_audio_frame(sh_audio_t *sh_audio){}
-//void resync_audio_stream(sh_audio_t *sh_audio){}
-
int quiet=0;
double video_time_usage=0;
double vout_time_usage=0;
@@ -247,14 +245,6 @@ void set_osd_subtitle(struct MPContext *mpctx, subtitle *subs) {
vo_osd_changed(OSDTYPE_SUBTITLE);
}
-//char *out_audio_codec=NULL; // override audio codec
-//char *out_video_codec=NULL; // override video codec
-
-//#include "libmpeg2/mpeg2.h"
-//#include "libmpeg2/mpeg2_internal.h"
-
-//static int vo_w=0, vo_h=0;
-
//-------------------------- config stuff:
m_config_t* mconfig;
@@ -279,29 +269,12 @@ typedef struct {
int already_read;
} s_frame_data;
-/// Returns a_pts
-static float calc_a_pts(demux_stream_t *d_audio);
-/** \brief Seeks audio forward to pts by dumping audio packets
- \return The current audio pts.
-*/
-static float forward_audio(float pts, demux_stream_t *d_audio, muxer_stream_t* mux_a);
-/** \brief Seeks slowly by dumping frames.
- \return 1 for success, 2 for EOF.
-*/
-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);
-/// Deletes audio or video as told by -delay to sync
-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);
-
#include "edl.h"
static edl_record_ptr edl_records = NULL; ///< EDL entries memory area
static edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records
static short edl_muted; ///< Stores whether EDL is currently in muted mode.
static short edl_seeking; ///< When non-zero, stream is seekable.
static short edl_seek_type; ///< When non-zero, frames are discarded instead of seeking.
-/** \brief Seeks for EDL
- \return 1 for success, 0 for failure, 2 for EOF.
-*/
-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);
#include "cfg-mencoder.h"
@@ -358,10 +331,6 @@ static int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){
//---------------------------------------------------------------------------
-// this function returns the absoloute time for which MEncoder will switch files or move in the file.
-// so audio can be cut correctly. -1 if there is no limit.
-static float stop_time(demuxer_t* demuxer, muxer_stream_t* mux_v);
-
static volatile int at_eof=0;
static volatile int interrupted=0;
@@ -410,7 +379,10 @@ void add_subtitles(char *filename, float fps, int silent)
subdata = subd;
}
-static float stop_time(demuxer_t* demuxer, muxer_stream_t* mux_v) {
+/* This function returns the absolute time for which MEncoder will switch files
+ * or move in the file so audio can be cut correctly. -1 if there is no limit. */
+static float stop_time(demuxer_t* demuxer, muxer_stream_t* mux_v)
+{
float timeleft = -1;
if (play_n_frames >= 0) timeleft = mux_v->timer + play_n_frames * (double)(mux_v->h.dwScale) / mux_v->h.dwRate;
if (end_at.type == END_AT_TIME && (timeleft > end_at.pos || timeleft == -1)) timeleft = end_at.pos;
@@ -429,7 +401,9 @@ static float stop_time(demuxer_t* demuxer, muxer_stream_t* mux_v) {
return timeleft;
}
-static float calc_a_pts(demux_stream_t *d_audio) {
+/// Returns a_pts
+static float calc_a_pts(demux_stream_t *d_audio)
+{
sh_audio_t * sh_audio = d_audio ? d_audio->sh : NULL;
float a_pts = 0.;
if (sh_audio)
@@ -437,7 +411,10 @@ static float calc_a_pts(demux_stream_t *d_audio) {
return a_pts;
}
-static float forward_audio(float pts, demux_stream_t *d_audio, muxer_stream_t* mux_a) {
+/** \brief Seeks audio forward to pts by dumping audio packets
+ * \return The current audio pts. */
+static float forward_audio(float pts, demux_stream_t *d_audio, muxer_stream_t* mux_a)
+{
sh_audio_t * sh_audio = d_audio ? d_audio->sh : NULL;
int samplesize, avg;
float a_pts = calc_a_pts(d_audio);
@@ -472,7 +449,12 @@ static float forward_audio(float pts, demux_stream_t *d_audio, muxer_stream_t* m
return a_pts;
}
-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) {
+/** \brief Seeks slowly by dumping frames.
+ * \return 1 for success, 2 for EOF. */
+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)
+{
sh_video_t * sh_video = d_video->sh;
vf_instance_t * vfilter = sh_video ? sh_video->vfilter : NULL;
int done = 0;
@@ -520,7 +502,11 @@ static int slowseek(float end_pts, demux_stream_t *d_video, demux_stream_t *d_au
return 1;
}
-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) {
+/// Deletes audio or video as told by -delay to sync
+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)
+{
// TODO: Find a way to encode silence instead of deleting video
sh_video_t * sh_video = d_video->sh;
float a_pts;
@@ -541,7 +527,12 @@ static void fixdelay(demux_stream_t *d_video, demux_stream_t *d_audio, muxer_str
slowseek(a_pts - audio_delay, d_video, d_audio, mux_a, frame_data, framecopy, 0);
}
-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) {
+/** \brief Seeks for EDL
+ * \return 1 for success, 0 for failure, 2 for EOF. */
+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)
+{
sh_video_t * sh_video = demuxer->video ? demuxer->video->sh : NULL;
if (!sh_video) return 0;
@@ -768,7 +759,6 @@ if(stream->type==STREAMTYPE_DVDNAV){
if(demuxer2) opts.audio_id=-2; /* do NOT read audio packets... */
- //demuxer=demux_open(stream,file_format,opts.video_id,opts.audio_id,opts.sub_id);
demuxer=demux_open(&opts, stream,file_format,opts.audio_id,opts.video_id,opts.sub_id,filename);
if(!demuxer){
mp_tmsg(MSGT_DEMUXER, MSGL_FATAL, FormatNotRecognized);
@@ -1516,7 +1506,6 @@ if(demuxer2){ // 3-pass encoding, read control file (frameno.avi)
if(len==4) next_frameno=start[0];
}
if(at_eof) break;
- // if(skip_flag) printf("!!!!!!!!!!!!\n");
skip_flag=next_frameno-decoded_frameno;
// find next frame:
while(next_frameno<=decoded_frameno){
@@ -1526,13 +1515,10 @@ if(demuxer2){ // 3-pass encoding, read control file (frameno.avi)
if(len==0) --skip_flag; else // duplicate
if(len==4) next_frameno=start[0];
}
-// if(at_eof) break;
-// printf("Current fno=%d requested=%d skip=%d \n",decoded_frameno,fno,skip_flag);
} else {
// check frame duplicate/drop:
-//printf("\r### %5.3f ###\n",v_timer_corr);
float mux_frametime = (float)mux_v->h.dwScale/mux_v->h.dwRate;
if (v_timer_corr >= mux_frametime && (skip_limit<0 || skip_flag < skip_limit)) {
@@ -1640,7 +1626,6 @@ if(sh_audio && !demuxer2){
unsigned int samples=(sh_audio->audio.dwSampleSize)?
((ds_tell(d_audio)-sh_audio->a_in_buffer_len)/sh_audio->audio.dwSampleSize) :
(d_audio->block_no); // <- used for VBR audio
-// printf("samples=%d \n",samples);
a_pts=samples*(float)sh_audio->audio.dwScale/(float)sh_audio->audio.dwRate;
delay_corrected=1;
} else
@@ -1649,7 +1634,6 @@ if(sh_audio && !demuxer2){
// PTS = (last timestamp) + (bytes after last timestamp)/(bytes per sec)
a_pts=d_audio->pts;
if(!delay_corrected) if(a_pts) delay_corrected=1;
- //printf("*** %5.3f ***\n",a_pts);
a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
}
v_pts=sh_video ? sh_video->pts : d_video->pts;
@@ -1674,23 +1658,6 @@ if(sh_audio && !demuxer2){
v_pts_corr+=x;
}
-// printf("A:%6.1f V:%6.1f A-V:%7.3f oAV:%7.3f diff:%7.3f ct:%7.3f vpc:%7.3f \r",
-// a_pts,v_pts,a_pts-v_pts,
-// (float)(mux_a->timer-mux_v->timer),
-// AV_delay, c_total, v_pts_corr );
-// printf("V:%6.1f \r", d_video->pts );
-
-#if 0
- mp_msg(MSGT_AVSYNC,MSGL_STATUS,"A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f %3d/%3d %2d%% %2d%% %4.1f%% %d%%\r",
- a_pts,v_pts,a_pts-v_pts,c_total,
- (int)sh_video->num_frames,(int)sh_video->num_frames_decoded,
- (sh_video->timer>0.5)?(int)(100.0*video_time_usage/(double)sh_video->timer):0,
- (sh_video->timer>0.5)?(int)(100.0*vout_time_usage/(double)sh_video->timer):0,
- (sh_video->timer>0.5)?(100.0*audio_time_usage/(double)sh_video->timer):0
- ,cache_fill_status
- );
-#endif
-
{ float t=(GetTimerMS()-timer_start)*0.001f;
float len=(demuxer->movi_end-demuxer->movi_start);
off_t pos = demuxer->filepos >= 0 ? demuxer->filepos : stream_tell(demuxer->stream);
@@ -1702,12 +1669,6 @@ if(sh_audio && !demuxer2){
/ (float)(sh_audio->audio.dwLength);
}
#endif
-#if 0
- mp_msg(MSGT_AVSYNC,MSGL_STATUS,"%d < %d < %d \r",
- (int)demuxer->movi_start,
- (int)demuxer->filepos,
- (int)demuxer->movi_end);
-#else
if(!quiet) {
if( mp_msg_test(MSGT_STATUSLINE,MSGL_V) ) {
mp_msg(MSGT_STATUSLINE,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb A-V:%5.3f [%d:%d] A/Vms %d/%d D/B/S %d/%d/%d \r",
@@ -1732,7 +1693,6 @@ if(sh_audio && !demuxer2){
(mux_a && mux_a->timer>1) ? (int)(mux_a->size/mux_a->timer/125) : 0
);
}
-#endif
}
fflush(stdout);