Mercurial > mplayer.hg
view libao2/ao_null.c @ 27518:e54c9b7eb0d8
Revert bad changes to SSA/ASS subtitle packet format
The following commits are reverted partially or completely:
"a valid ASS line contains 9 ',' before actual text"
"demux_mkv: output correctly formated ASS packets"
"libass: add a new ass_process_data() to process demuxed subtitle packets"
These commits converted the internal representation of SSA/ASS
subtitle packets from the format used by Matroska to a custom format
where each packet has contents exactly matching one line in complete
SSA script files. AFAIK no files natively use such a format for muxed
subtitles. The stated reason for this change was to use a format that
could in principle be muxed into a maximal number of containers. SSA
subtitles do not have an implicit duration so both start time and
duration or end time need to be specified explicitly; the new format
moved timing information inside the codec packet data so it could be
muxed without modification into containers that can represent only
start time at the container level. However such a change is wrong from
the viewpoint of program architecture. Timing information belongs to
the demuxer level, but these commits moved not only the duration but
also the authoritative value of the start time to inside the codec
data. Additionally the new format lost the value of the Matroska
ReadOrder field which is used by MPlayer.
This commit changes the internal packet format back to that used by
Matroska and makes the internal Matroska demuxer output that format
again. Libavformat still outputs the "new" format; it could be
converted back to the Matroska format in demux_lavf.c, but I'm not
adding that code at least yet. The current lavf code has similar
problems as the reverted code in MPlayer, and it also currently fails
to provide any way to access the value of the ReadOrder field. I hope
that the lavf side will be improved; if it isn't conversion can be
added later. For now I'll make MPlayer default to the internal Matroska
demuxer instead of the lavf one in a separate commit.
author | uau |
---|---|
date | Mon, 08 Sep 2008 21:26:22 +0000 |
parents | 1aec672af2d2 |
children | e45b08f2f5d3 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include "config.h" #include "libaf/af_format.h" #include "audio_out.h" #include "audio_out_internal.h" static ao_info_t info = { "Null audio output", "null", "Tobias Diedrich <ranma+mplayer@tdiedrich.de>", "" }; LIBAO_EXTERN(null) struct timeval last_tv; int buffer; static void drain(void){ struct timeval now_tv; int temp, temp2; gettimeofday(&now_tv, 0); temp = now_tv.tv_sec - last_tv.tv_sec; temp *= ao_data.bps; temp2 = now_tv.tv_usec - last_tv.tv_usec; temp2 /= 1000; temp2 *= ao_data.bps; temp2 /= 1000; temp += temp2; buffer-=temp; if (buffer<0) buffer=0; if(temp>0) last_tv = now_tv;//mplayer is fast } // to set/get/query special features/parameters static int control(int cmd,void *arg){ return -1; } // open & setup audio device // return: 1=success 0=fail static int init(int rate,int channels,int format,int flags){ int samplesize = af_fmt2bits(format) / 8; ao_data.outburst = 256 * channels * samplesize; // A "buffer" for about 0.2 seconds of audio ao_data.buffersize = (int)(rate * 0.2 / 256 + 1) * ao_data.outburst; ao_data.channels=channels; ao_data.samplerate=rate; ao_data.format=format; ao_data.bps=channels*rate*samplesize; buffer=0; gettimeofday(&last_tv, 0); return 1; } // close audio device static void uninit(int immed){ } // stop playing and empty buffers (for seeking/pause) static void reset(void){ buffer=0; } // stop playing, keep buffers (for pause) static void audio_pause(void) { // for now, just call reset(); reset(); } // resume playing, after audio_pause() static void audio_resume(void) { } // return: how many bytes can be played without blocking static int get_space(void){ drain(); return ao_data.buffersize - buffer; } // plays 'len' bytes of 'data' // it should round it down to outburst*n // return: number of bytes played static int play(void* data,int len,int flags){ int maxbursts = (ao_data.buffersize - buffer) / ao_data.outburst; int playbursts = len / ao_data.outburst; int bursts = playbursts > maxbursts ? maxbursts : playbursts; buffer += bursts * ao_data.outburst; return bursts * ao_data.outburst; } // return: delay in seconds between first and last sample in buffer static float get_delay(void){ drain(); return (float) buffer / (float) ao_data.bps; }