summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/zh_CN/mplayer.14
-rwxr-xr-xconfigure2
-rw-r--r--libmpcodecs/mp_image.c11
-rw-r--r--libmpcodecs/vd_dmo.c3
-rw-r--r--libmpcodecs/ve_x264.c1
-rw-r--r--libmpcodecs/vf.c3
-rw-r--r--libmpcodecs/vf_noise.c7
-rw-r--r--libmpcodecs/vf_screenshot.c6
-rw-r--r--libmpcodecs/vf_unsharp.c8
-rw-r--r--libmpdemux/demux_ogg.c2797
10 files changed, 1463 insertions, 1379 deletions
diff --git a/DOCS/man/zh_CN/mplayer.1 b/DOCS/man/zh_CN/mplayer.1
index cd25a33084..e1cd17f48f 100644
--- a/DOCS/man/zh_CN/mplayer.1
+++ b/DOCS/man/zh_CN/mplayer.1
@@ -1,4 +1,4 @@
-.\" sync with en/mplayer.1 rev. 30936
+.\" sync with en/mplayer.1 rev. 31028
.\" Encoding: UTF-8
.\" Reminder of hard terms which need better/final solution later:
.\" /capture; playtree in parent list; colorkey; retrace; desync; downmix;
@@ -289,6 +289,8 @@ MPlayer 有个完全可配置的, 命令驱动的控制层,
开始/停止截屏。
.IPs "I\ \ \ \ "
用 OSD 显示文件名。
+.IPs "P\ \ \ \ "
+在 OSD 上显示进度条、已播放时间以及总长度信息。
.IPs "! 和 @"
寻到前一章节/后一章节的开始处。
.IPs "D(仅用于\-vo xvmc, \-vo vdpau,\-vf yadif, \-vf kerndeint)"
diff --git a/configure b/configure
index e022c0b9cf..6bc810e3f0 100755
--- a/configure
+++ b/configure
@@ -7058,7 +7058,7 @@ if test "$_x264" = auto ; then
cat > $TMPC << EOF
#include <inttypes.h>
#include <x264.h>
-#if X264_BUILD < 79
+#if X264_BUILD < 89
#error We do not support old versions of x264. Get the latest from git.
#endif
int main(void) { x264_encoder_open((void*)0); return 0; }
diff --git a/libmpcodecs/mp_image.c b/libmpcodecs/mp_image.c
index e71821129d..898f5fac96 100644
--- a/libmpcodecs/mp_image.c
+++ b/libmpcodecs/mp_image.c
@@ -30,14 +30,15 @@
#include "libmpcodecs/mp_image.h"
#include "libvo/fastmemcpy.h"
+#include "libavutil/mem.h"
void mp_image_alloc_planes(mp_image_t *mpi) {
// IF09 - allocate space for 4. plane delta info - unused
if (mpi->imgfmt == IMGFMT_IF09) {
- mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
+ mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8+
mpi->chroma_width*mpi->chroma_height);
} else
- mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8);
+ mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8);
if (mpi->flags&MP_IMGFLAG_PLANAR) {
int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1;
// YV12/I420/YVU9/IF09. feel free to add other planar formats here...
@@ -65,7 +66,7 @@ void mp_image_alloc_planes(mp_image_t *mpi) {
} else {
mpi->stride[0]=mpi->width*mpi->bpp/8;
if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
- mpi->planes[1] = memalign(64, 1024);
+ mpi->planes[1] = av_malloc(1024);
}
mpi->flags|=MP_IMGFLAG_ALLOCATED;
}
@@ -191,9 +192,9 @@ void free_mp_image(mp_image_t* mpi){
if(!mpi) return;
if(mpi->flags&MP_IMGFLAG_ALLOCATED){
/* becouse we allocate the whole image in once */
- if(mpi->planes[0]) free(mpi->planes[0]);
+ if(mpi->planes[0]) av_free(mpi->planes[0]);
if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
- free(mpi->planes[1]);
+ av_free(mpi->planes[1]);
}
free(mpi);
}
diff --git a/libmpcodecs/vd_dmo.c b/libmpcodecs/vd_dmo.c
index 9f9c6a7a80..31d9f1e351 100644
--- a/libmpcodecs/vd_dmo.c
+++ b/libmpcodecs/vd_dmo.c
@@ -82,7 +82,7 @@ static int init(sh_video_t *sh){
if (sh->disp_w & 3)
{
ctx->stride = ((sh->disp_w * 3) + 3) & ~3;
- ctx->buffer = memalign(64, ctx->stride * sh->disp_h);
+ ctx->buffer = av_malloc(ctx->stride * sh->disp_h);
}
default:
DMO_VideoDecoder_SetDestFmt(ctx->decoder,out_fmt&255,0); // RGB/BGR
@@ -96,6 +96,7 @@ static int init(sh_video_t *sh){
static void uninit(sh_video_t *sh){
struct context *ctx = sh->context;
DMO_VideoDecoder_Destroy(ctx->decoder);
+ av_free(ctx->buffer);
free(ctx);
sh->context = NULL;
}
diff --git a/libmpcodecs/ve_x264.c b/libmpcodecs/ve_x264.c
index 832d58ac6a..4a84f8dead 100644
--- a/libmpcodecs/ve_x264.c
+++ b/libmpcodecs/ve_x264.c
@@ -152,6 +152,7 @@ static int config(struct vf_instance* vf, int width, int height, int d_width, in
param.i_height = height;
param.i_fps_num = mod->mux->h.dwRate;
param.i_fps_den = mod->mux->h.dwScale;
+ param.b_vfr_input = 0;
param.vui.i_sar_width = d_width*height;
param.vui.i_sar_height = d_height*width;
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 65c2f17a58..0f2dcc75d2 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -39,6 +39,7 @@
#include "vf.h"
#include "libvo/fastmemcpy.h"
+#include "libavutil/mem.h"
extern const vf_info_t vf_info_vo;
extern const vf_info_t vf_info_rectangle;
@@ -356,7 +357,7 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
if(mpi->flags&MP_IMGFLAG_ALLOCATED){
if(mpi->width<w2 || mpi->height<h){
// need to re-allocate buffer memory:
- free(mpi->planes[0]);
+ av_free(mpi->planes[0]);
mpi->flags&=~MP_IMGFLAG_ALLOCATED;
mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n");
}
diff --git a/libmpcodecs/vf_noise.c b/libmpcodecs/vf_noise.c
index 9242df8339..59835daf50 100644
--- a/libmpcodecs/vf_noise.c
+++ b/libmpcodecs/vf_noise.c
@@ -36,6 +36,7 @@
#include "mp_image.h"
#include "vf.h"
#include "libvo/fastmemcpy.h"
+#include "libavutil/mem.h"
#define MAX_NOISE 4096
#define MAX_SHIFT 1024
@@ -80,7 +81,7 @@ static int8_t *initNoise(FilterParam *fp){
int uniform= fp->uniform;
int averaged= fp->averaged;
int pattern= fp->pattern;
- int8_t *noise= memalign(16, MAX_NOISE*sizeof(int8_t));
+ int8_t *noise= av_malloc(MAX_NOISE*sizeof(int8_t));
int i, j;
srand(123457);
@@ -369,10 +370,10 @@ static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
static void uninit(struct vf_instance* vf){
if(!vf->priv) return;
- if(vf->priv->chromaParam.noise) free(vf->priv->chromaParam.noise);
+ if(vf->priv->chromaParam.noise) av_free(vf->priv->chromaParam.noise);
vf->priv->chromaParam.noise= NULL;
- if(vf->priv->lumaParam.noise) free(vf->priv->lumaParam.noise);
+ if(vf->priv->lumaParam.noise) av_free(vf->priv->lumaParam.noise);
vf->priv->lumaParam.noise= NULL;
free(vf->priv);
diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c
index 7ab25305ef..a2680cc6d1 100644
--- a/libmpcodecs/vf_screenshot.c
+++ b/libmpcodecs/vf_screenshot.c
@@ -131,7 +131,7 @@ static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi)
dst_stride[0] = priv->stride;
if (!priv->buffer)
- priv->buffer = memalign(16, dst_stride[0]*priv->dh);
+ priv->buffer = av_malloc(dst_stride[0]*priv->dh);
dst[0] = priv->buffer;
sws_scale(priv->ctx, mpi->planes, mpi->stride, 0, priv->dh, dst, dst_stride);
@@ -144,7 +144,7 @@ static void start_slice(struct vf_instance* vf, mp_image_t *mpi)
if (vf->priv->shot) {
vf->priv->store_slices = 1;
if (!vf->priv->buffer)
- vf->priv->buffer = memalign(16, vf->priv->stride*vf->priv->dh);
+ vf->priv->buffer = av_malloc(vf->priv->stride*vf->priv->dh);
}
}
@@ -277,7 +277,7 @@ static void uninit(vf_instance_t *vf)
avcodec_close(vf->priv->avctx);
av_freep(&vf->priv->avctx);
if(vf->priv->ctx) sws_freeContext(vf->priv->ctx);
- if (vf->priv->buffer) free(vf->priv->buffer);
+ if (vf->priv->buffer) av_free(vf->priv->buffer);
free(vf->priv->outbuffer);
free(vf->priv);
}
diff --git a/libmpcodecs/vf_unsharp.c b/libmpcodecs/vf_unsharp.c
index 2afd866342..5d6b33f290 100644
--- a/libmpcodecs/vf_unsharp.c
+++ b/libmpcodecs/vf_unsharp.c
@@ -143,7 +143,7 @@ static int config( struct vf_instance* vf,
stepsX = fp->msizeX/2;
stepsY = fp->msizeY/2;
for( z=0; z<2*stepsY; z++ )
- fp->SC[z] = memalign( 16, sizeof(*(fp->SC[z])) * (width+2*stepsX) );
+ fp->SC[z] = av_malloc(sizeof(*(fp->SC[z])) * (width+2*stepsX));
fp = &vf->priv->chromaParam;
effect = fp->amount == 0 ? "don't touch" : fp->amount < 0 ? "blur" : "sharpen";
@@ -152,7 +152,7 @@ static int config( struct vf_instance* vf,
stepsX = fp->msizeX/2;
stepsY = fp->msizeY/2;
for( z=0; z<2*stepsY; z++ )
- fp->SC[z] = memalign( 16, sizeof(*(fp->SC[z])) * (width+2*stepsX) );
+ fp->SC[z] = av_malloc(sizeof(*(fp->SC[z])) * (width+2*stepsX));
return vf_next_config( vf, width, height, d_width, d_height, flags, outfmt );
}
@@ -212,12 +212,12 @@ static void uninit( struct vf_instance* vf ) {
fp = &vf->priv->lumaParam;
for( z=0; z<sizeof(fp->SC)/sizeof(fp->SC[0]); z++ ) {
- if( fp->SC[z] ) free( fp->SC[z] );
+ if( fp->SC[z] ) av_free( fp->SC[z] );
fp->SC[z] = NULL;
}
fp = &vf->priv->chromaParam;
for( z=0; z<sizeof(fp->SC)/sizeof(fp->SC[0]); z++ ) {
- if( fp->SC[z] ) free( fp->SC[z] );
+ if( fp->SC[z] ) av_free( fp->SC[z] );
fp->SC[z] = NULL;
}
diff --git a/libmpdemux/demux_ogg.c b/libmpdemux/demux_ogg.c
index acb783d71f..e872ad5156 100644
--- a/libmpdemux/demux_ogg.c
+++ b/libmpdemux/demux_ogg.c
@@ -60,112 +60,108 @@ int _ilog (unsigned int); /* defined in many places in theora/lib/ */
*/
#ifdef CONFIG_OGGTHEORA
typedef struct theora_struct_st {
- theora_state st;
+ theora_state st;
theora_comment cc;
- theora_info inf;
+ theora_info inf;
} theora_struct_t;
#endif
//// OggDS headers
// Header for the new header format
-typedef struct stream_header_video
-{
- ogg_int32_t width;
- ogg_int32_t height;
+typedef struct stream_header_video {
+ ogg_int32_t width;
+ ogg_int32_t height;
} stream_header_video;
-typedef struct stream_header_audio
-{
- ogg_int16_t channels;
- ogg_int16_t blockalign;
- ogg_int32_t avgbytespersec;
+typedef struct stream_header_audio {
+ ogg_int16_t channels;
+ ogg_int16_t blockalign;
+ ogg_int32_t avgbytespersec;
} stream_header_audio;
-typedef struct __attribute__((__packed__)) stream_header
-{
- char streamtype[8];
- char subtype[4];
+typedef struct __attribute__((__packed__)) stream_header {
+ char streamtype[8];
+ char subtype[4];
- ogg_int32_t size; // size of the structure
+ ogg_int32_t size; // size of the structure
- ogg_int64_t time_unit; // in reference time
- ogg_int64_t samples_per_unit;
- ogg_int32_t default_len; // in media time
+ ogg_int64_t time_unit; // in reference time
+ ogg_int64_t samples_per_unit;
+ ogg_int32_t default_len; // in media time
- ogg_int32_t buffersize;
- ogg_int16_t bits_per_sample;
+ ogg_int32_t buffersize;
+ ogg_int16_t bits_per_sample;
- ogg_int16_t padding;
+ ogg_int16_t padding;
- union
- {
- // Video specific
- stream_header_video video;
- // Audio specific
- stream_header_audio audio;
- } sh;
+ union {
+ // Video specific
+ stream_header_video video;
+ // Audio specific
+ stream_header_audio audio;
+ } sh;
} stream_header;
/// Our private datas
typedef struct ogg_syncpoint {
- int64_t granulepos;
- off_t page_pos;
+ int64_t granulepos;
+ off_t page_pos;
} ogg_syncpoint_t;
/// A logical stream
typedef struct ogg_stream {
- /// Timestamping stuff
- float samplerate; /// granulpos 2 time
- int64_t lastpos;
- int32_t lastsize;
- int keyframe_frequency_force;
-
- // Logical stream state
- ogg_stream_state stream;
- int hdr_packets;
- int vorbis;
- int speex;
- int theora;
- int flac;
- int text;
- int id;
-
- vorbis_info vi;
- int vi_initialized;
-
- void *ogg_d;
+ /// Timestamping stuff
+ float samplerate; /// granulpos 2 time
+ int64_t lastpos;
+ int32_t lastsize;
+ int keyframe_frequency_force;
+
+ // Logical stream state
+ ogg_stream_state stream;
+ int hdr_packets;
+ int vorbis;
+ int speex;
+ int theora;
+ int flac;
+ int text;
+ int id;
+
+ vorbis_info vi;
+ int vi_initialized;
+
+ void *ogg_d;
} ogg_stream_t;
typedef struct ogg_demuxer {
- /// Physical stream state
- ogg_sync_state sync;
- /// Current page
- ogg_page page;
- /// Logical streams
- ogg_stream_t *subs;
- int num_sub;
- ogg_syncpoint_t* syncpoints;
- int num_syncpoint;
- off_t pos, last_size;
- int64_t initial_granulepos;
- int64_t final_granulepos;
- int64_t duration;
-
- /* Used for subtitle switching. */
- int n_text;
- int *text_ids;
- char **text_langs;
+ /// Physical stream state
+ ogg_sync_state sync;
+ /// Current page
+ ogg_page page;
+ /// Logical streams
+ ogg_stream_t *subs;
+ int num_sub;
+ ogg_syncpoint_t *syncpoints;
+ int num_syncpoint;
+ off_t pos, last_size;
+ int64_t initial_granulepos;
+ int64_t final_granulepos;
+ int64_t duration;
+
+ /* Used for subtitle switching. */
+ int n_text;
+ int *text_ids;
+ char **text_langs;
} ogg_demuxer_t;
#define NUM_VORBIS_HDR_PACKETS 3
/// Some defines from OggDS
-#define PACKET_TYPE_HEADER 0x01
-#define PACKET_TYPE_BITS 0x07
-#define PACKET_LEN_BITS01 0xc0
-#define PACKET_LEN_BITS2 0x02
-#define PACKET_IS_SYNCPOINT 0x08
+#define PACKET_TYPE_HEADER 0x01
+#define PACKET_TYPE_BITS 0x07
+#define PACKET_LEN_BITS01 0xc0
+#define PACKET_LEN_BITS2 0x02
+#define PACKET_IS_SYNCPOINT 0x08
extern char *dvdsub_lang, *audio_lang;
@@ -181,192 +177,192 @@ static subtitle ogg_sub;
static void demux_ogg_add_sub(ogg_stream_t *os, ogg_packet *pack)
{
- int lcv;
- char *packet = pack->packet;
-
- if (pack->bytes < 4)
- return;
- mp_msg(MSGT_DEMUX,MSGL_DBG2,"\ndemux_ogg_add_sub %02X %02X %02X '%s'\n",
- (unsigned char)packet[0],
- (unsigned char)packet[1],
- (unsigned char)packet[2],
- &packet[3]);
-
- if (((unsigned char)packet[0]) == 0x88) { // some subtitle text
- // Find data start
- double endpts = MP_NOPTS_VALUE;
- int32_t duration = 0;
- int16_t hdrlen = (*packet & PACKET_LEN_BITS01)>>6, i;
- hdrlen |= (*packet & PACKET_LEN_BITS2) <<1;
- lcv = 1 + hdrlen;
- if (pack->bytes < lcv)
- return;
- for (i = hdrlen; i > 0; i--) {
- duration <<= 8;
- duration |= (unsigned char)packet[i];
- }
- if (hdrlen > 0 && duration > 0) {
- float pts;
- if(pack->granulepos == -1)
- pack->granulepos = os->lastpos + os->lastsize;
- pts = (float)pack->granulepos/(float)os->samplerate;
- endpts = 1.0 + pts + (float)duration/1000.0;
+ int lcv;
+ char *packet = pack->packet;
+
+ if (pack->bytes < 4)
+ return;
+ mp_msg(MSGT_DEMUX, MSGL_DBG2, "\ndemux_ogg_add_sub %02X %02X %02X '%s'\n",
+ (unsigned char)packet[0],
+ (unsigned char)packet[1],
+ (unsigned char)packet[2],
+ &packet[3]);
+
+ if (((unsigned char)packet[0]) == 0x88) { // some subtitle text
+ // Find data start
+ double endpts = MP_NOPTS_VALUE;
+ int32_t duration = 0;
+ int16_t hdrlen = (*packet & PACKET_LEN_BITS01) >> 6, i;
+
+ hdrlen |= (*packet & PACKET_LEN_BITS2) << 1;
+ lcv = 1 + hdrlen;
+ if (pack->bytes < lcv)
+ return;
+ for (i = hdrlen; i > 0; i--) {
+ duration <<= 8;
+ duration |= (unsigned char)packet[i];
+ }
+ if (hdrlen > 0 && duration > 0) {
+ float pts;
+
+ if (pack->granulepos == -1)
+ pack->granulepos = os->lastpos + os->lastsize;
+ pts = (float)pack->granulepos / (float)os->samplerate;
+ endpts = 1.0 + pts + (float)duration / 1000.0;
+ }
+ sub_clear_text(&ogg_sub, MP_NOPTS_VALUE);
+ sub_add_text(&ogg_sub, &packet[lcv], pack->bytes - lcv, endpts);
}
- sub_clear_text(&ogg_sub, MP_NOPTS_VALUE);
- sub_add_text(&ogg_sub, &packet[lcv], pack->bytes - lcv, endpts);
- }
- mp_msg(MSGT_DEMUX,MSGL_DBG2,"Ogg sub lines: %d first: '%s'\n",
- ogg_sub.lines, ogg_sub.text[0]);
+ mp_msg(MSGT_DEMUX, MSGL_DBG2, "Ogg sub lines: %d first: '%s'\n",
+ ogg_sub.lines, ogg_sub.text[0]);
#ifdef CONFIG_ICONV
- subcp_recode(&ogg_sub);
+ subcp_recode(&ogg_sub);
#endif
- vo_sub = &ogg_sub;
- vo_osd_changed(OSDTYPE_SUBTITLE);
+ vo_sub = &ogg_sub;
+ vo_osd_changed(OSDTYPE_SUBTITLE);
}
// get the logical stream of the current page
// fill os if non NULL and return the stream id
-static int demux_ogg_get_page_stream(ogg_demuxer_t* ogg_d,ogg_stream_state** os) {
- int id,s_no;
- ogg_page* page = &ogg_d->page;
-
- s_no = ogg_page_serialno(page);
-
- for(id= 0; id < ogg_d->num_sub ; id++) {
- if(s_no == ogg_d->subs[id].stream.serialno)
- break;
- }
-
- if(id == ogg_d->num_sub) {
- // If we have only one vorbis stream allow the stream id to change
- // it's normal on radio stream (each song have an different id).
- // But we (or the codec?) should check that the samplerate, etc
- // doesn't change (for radio stream it's ok)
- if(ogg_d->num_sub == 1 && ogg_d->subs[0].vorbis) {
- ogg_stream_reset(&ogg_d->subs[0].stream);
- ogg_stream_init(&ogg_d->subs[0].stream,s_no);
- id = 0;
- } else
- return -1;
- }
+static int demux_ogg_get_page_stream(ogg_demuxer_t *ogg_d,
+ ogg_stream_state **os)
+{
+ int id, s_no;
+ ogg_page *page = &ogg_d->page;
- if(os)
- *os = &ogg_d->subs[id].stream;
+ s_no = ogg_page_serialno(page);
- return id;
+ for (id = 0; id < ogg_d->num_sub; id++)
+ if (s_no == ogg_d->subs[id].stream.serialno)
+ break;
-}
+ if (id == ogg_d->num_sub) {
+ // If we have only one vorbis stream allow the stream id to change
+ // it's normal on radio stream (each song have an different id).
+ // But we (or the codec?) should check that the samplerate, etc
+ // doesn't change (for radio stream it's ok)
+ if (ogg_d->num_sub == 1 && ogg_d->subs[0].vorbis) {
+ ogg_stream_reset(&ogg_d->subs[0].stream);
+ ogg_stream_init(&ogg_d->subs[0].stream, s_no);
+ id = 0;
+ } else
+ return -1;
+ }
-static unsigned char* demux_ogg_read_packet(ogg_stream_t* os,ogg_packet* pack,float* pts,int* flags, int samplesize) {
- unsigned char* data = pack->packet;
- int size = pack->bytes;
+ if (os)
+ *os = &ogg_d->subs[id].stream;
- *pts = MP_NOPTS_VALUE;
- *flags = 0;
+ return id;
+}
- if(os->vorbis) {
- if(*pack->packet & PACKET_TYPE_HEADER)
- os->hdr_packets++;
- else
- {
- vorbis_info *vi;
- int32_t blocksize = 0;
-
- // When we dump the audio, there is no vi, but we don't care of timestamp in this case
- vi = os->vi_initialized ? &os->vi : NULL;
- if (vi)
- blocksize = vorbis_packet_blocksize(vi,pack) / samplesize;
- // Calculate the timestamp if the packet don't have any
- if(pack->granulepos == -1) {
- pack->granulepos = os->lastpos;
- if(os->lastsize > 0)
- pack->granulepos += os->lastsize;
- } else
- *flags = 1;
- if (vi)
- *pts = pack->granulepos / (float)vi->rate;
- os->lastsize = blocksize;
- os->lastpos = pack->granulepos;
- }
- } else if (os->speex) {
- // whole packet (default)
+static unsigned char *demux_ogg_read_packet(ogg_stream_t *os, ogg_packet *pack,
+ float *pts, int *flags,
+ int samplesize)
+{
+ unsigned char *data = pack->packet;
+ int size = pack->bytes;
+
+ *pts = MP_NOPTS_VALUE;
+ *flags = 0;
+
+ if (os->vorbis) {
+ if (*pack->packet & PACKET_TYPE_HEADER) {
+ os->hdr_packets++;
+ } else {
+ vorbis_info *vi;
+ int32_t blocksize = 0;
+
+ // When we dump the audio, there is no vi, but we don't care of timestamp in this case
+ vi = os->vi_initialized ? &os->vi : NULL;
+ if (vi)
+ blocksize = vorbis_packet_blocksize(vi, pack) / samplesize;
+ // Calculate the timestamp if the packet don't have any
+ if (pack->granulepos == -1) {
+ pack->granulepos = os->lastpos;
+ if (os->lastsize > 0)
+ pack->granulepos += os->lastsize;
+ } else
+ *flags = 1;
+ if (vi)
+ *pts = pack->granulepos / (float)vi->rate;
+ os->lastsize = blocksize;
+ os->lastpos = pack->granulepos;
+ }
+ } else if (os->speex) {
+ // whole packet (default)
# ifdef CONFIG_OGGTHEORA
- } else if (os->theora) {
- /* we pass complete packets to theora, mustn't strip the header! */
- os->lastsize = 1;
-
- /* header packets begin on 1-bit: thus check (*data&0x80). We don't
- have theora_state st, until all header packets were passed to the
- decoder. */
- if (!size || !(*data&0x80))
- {
- int keyframe_granule_shift=_ilog(os->keyframe_frequency_force-1);
- int64_t iframemask = (1 << keyframe_granule_shift) - 1;
-
- if (pack->granulepos >= 0)
- {
- os->lastpos = pack->granulepos >> keyframe_granule_shift;
- os->lastpos += pack->granulepos & iframemask;
- *flags = (pack->granulepos & iframemask) == 0;
- }
- else
- {
- os->lastpos++;
- }
- pack->granulepos = os->lastpos;
- *pts = (double)os->lastpos / (double)os->samplerate;
- }
+ } else if (os->theora) {
+ /* we pass complete packets to theora, mustn't strip the header! */
+ os->lastsize = 1;
+
+ /* header packets begin on 1-bit: thus check (*data&0x80). We don't
+ have theora_state st, until all header packets were passed to the
+ decoder. */
+ if (!size || !(*data&0x80)) {
+ int keyframe_granule_shift = _ilog(os->keyframe_frequency_force - 1);
+ int64_t iframemask = (1 << keyframe_granule_shift) - 1;
+
+ if (pack->granulepos >= 0) {
+ os->lastpos = pack->granulepos >> keyframe_granule_shift;
+ os->lastpos += pack->granulepos & iframemask;
+ *flags = (pack->granulepos & iframemask) == 0;
+ } else {
+ os->lastpos++;
+ }
+ pack->granulepos = os->lastpos;
+ *pts = (double)os->lastpos / (double)os->samplerate;
+ }
#endif /* CONFIG_OGGTHEORA */
- } else if (os->flac) {
- /* we pass complete packets to flac, mustn't strip the header! */
- if (os->flac == 2 && pack->packet[0] != 0xff)
- return NULL;
- } else {
- if(*pack->packet & PACKET_TYPE_HEADER)
- os->hdr_packets++;
- else {
- // Find data start
- int16_t hdrlen = (*pack->packet & PACKET_LEN_BITS01)>>6;
- hdrlen |= (*pack->packet & PACKET_LEN_BITS2) <<1;
- data = pack->packet + 1 + hdrlen;
- // Calculate the timestamp
- if(pack->granulepos == -1)
- pack->granulepos = os->lastpos + (os->lastsize ? os->lastsize : 1);
- // If we already have a timestamp it can be a syncpoint
- if(*pack->packet & PACKET_IS_SYNCPOINT)
- *flags = 1;
- *pts = pack->granulepos/os->samplerate;
- // Save the packet length and timestamp
- os->lastsize = 0;
- while(hdrlen) {
- os->lastsize <<= 8;
- os->lastsize |= pack->packet[hdrlen];
- hdrlen--;
+ } else if (os->flac) {
+ /* we pass complete packets to flac, mustn't strip the header! */
+ if (os->flac == 2 && pack->packet[0] != 0xff)
+ return NULL;
+ } else {
+ if (*pack->packet & PACKET_TYPE_HEADER) {
+ os->hdr_packets++;
+ } else {
+ // Find data start
+ int16_t hdrlen = (*pack->packet & PACKET_LEN_BITS01) >> 6;
+
+ hdrlen |= (*pack->packet & PACKET_LEN_BITS2) << 1;
+ data = pack->packet + 1 + hdrlen;
+ // Calculate the timestamp
+ if (pack->granulepos == -1)
+ pack->granulepos = os->lastpos + (os->lastsize ? os->lastsize : 1);
+ // If we already have a timestamp it can be a syncpoint
+ if (*pack->packet & PACKET_IS_SYNCPOINT)
+ *flags = 1;
+ *pts = pack->granulepos / os->samplerate;
+ // Save the packet length and timestamp
+ os->lastsize = 0;
+ while (hdrlen) {
+ os->lastsize <<= 8;
+ os->lastsize |= pack->packet[hdrlen];
+ hdrlen--;
+ }
+ os->lastpos = pack->granulepos;
+ }
}
- os->lastpos = pack->granulepos;
- }
- }
- return data;
+ return data;
}
// check if clang has substring from comma separated langlist
static int demux_ogg_check_lang(const char *clang, const char *langlist)
{
- const char *c;
-
- if (!langlist || !*langlist)
+ const char *c;
+
+ if (!langlist || !*langlist)
+ return 0;
+ while ((c = strchr(langlist, ','))) {
+ if (!strncasecmp(clang, langlist, c - langlist))
+ return 1;
+ langlist = &c[1];
+ }
+ if (!strncasecmp(clang, langlist, strlen(langlist)))
+ return 1;
return 0;
- while ((c = strchr(langlist, ',')))
- {
- if (!strncasecmp(clang, langlist, c - langlist))
- return 1;
- langlist = &c[1];
- }
- if (!strncasecmp(clang, langlist, strlen(langlist)))
- return 1;
- return 0;
}
/** \brief Change the current subtitle stream and return its ID.
@@ -377,1216 +373,1297 @@ static int demux_ogg_check_lang(const char *clang, const char *langlist)
\returns The Ogg stream number ( = page serial number) of the newly selected
track.
-*/
+ */
static int demux_ogg_sub_id(demuxer_t *demuxer, int index)
{
- ogg_demuxer_t *ogg_d = demuxer->priv;
- return (index < 0) ? index : (index >= ogg_d->n_text) ? -1 : ogg_d->text_ids[index];
+ ogg_demuxer_t *ogg_d = demuxer->priv;
+ return (index < 0) ? index : (index >= ogg_d->n_text) ? -1 : ogg_d->text_ids[index];
}
/** \brief Translate the ogg track number into the subtitle number.
* \param demuxer The demuxer about whose subtitles we are inquiring.
* \param id The ogg track number of the subtitle track.
*/
-static int demux_ogg_sub_reverse_id(demuxer_t *demuxer, int id) {
- ogg_demuxer_t *ogg_d = demuxer->priv;
- int i;
- for (i = 0; i < ogg_d->n_text; i++)
- if (ogg_d->text_ids[i] == id) return i;
- return -1;
+static int demux_ogg_sub_reverse_id(demuxer_t *demuxer, int id)
+{
+ ogg_demuxer_t *ogg_d = demuxer->priv;
+ int i;
+
+ for (i = 0; i < ogg_d->n_text; i++)
+ if (ogg_d->text_ids[i] == id)
+ return i;
+ return -1;
}
/// Try to print out comments and also check for LANGUAGE= tag
-static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os, int id, vorbis_comment *vc)
+static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os,
+ int id, vorbis_comment *vc)
{
- const char *hdr, *val;
- char **cmt = vc->user_comments;
- int index, i;
- ogg_demuxer_t *ogg_d = d->priv;
- static const struct table {
- const char *ogg;
- const char *mp;
- } table[] = {
- { "ENCODED_USING", "Software" },
- { "ENCODER_URL", "Encoder URL" },
- { "TITLE", "Title" },
- { "ARTIST", "Artist" },
- { "COMMENT", "Comments" },
- { "DATE", "Creation Date" },
- { "GENRE", "Genre" },
- { "ALBUM", "Album" },
- { "TRACKNUMBER", "Track" },
- { NULL, NULL },
- };
-
- while(*cmt)
- {
- hdr = NULL;
- if (!strncasecmp(*cmt, "LANGUAGE=", 9))
- {
- val = *cmt + 9;
- if (ogg_d->subs[id].text)
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", ogg_d->subs[id].id, val);
- else if (id != d->video->id)
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", ogg_d->subs[id].id, val);
- if (ogg_d->subs[id].text)
- mp_msg(MSGT_DEMUX, MSGL_INFO, "[Ogg] Language for -sid %d is '-slang \"%s\"'\n", ogg_d->subs[id].id, val);
- // copy this language name into the array
- index = demux_ogg_sub_reverse_id(d, id);
- if (index >= 0) {
- sh_sub_t* sh;
- // in case of malicious files with more than one lang per track:
- if (ogg_d->text_langs[index]) free(ogg_d->text_langs[index]);
- ogg_d->text_langs[index] = strdup(val);
- sh = d->s_streams[index];
- if (sh && sh->lang) free(sh->lang);
- if (sh) sh->lang = strdup(val);
- }
- // check for -slang if subs are uninitialized yet
- if (os->text && d->sub->id < 0 && demux_ogg_check_lang(val, dvdsub_lang))
- {
- d->sub->id = index;
- d->opts->sub_id = index;
- mp_msg(MSGT_DEMUX, MSGL_V, "Ogg demuxer: Displaying subtitle stream id %d which matched -slang %s\n", id, val);
- }
- else
- hdr = "Language";
- }
- else {
- for (i = 0; table[i].ogg; i++)
- {
- if (!strncasecmp(*cmt, table[i].ogg, strlen(table[i].ogg)) &&
- (*cmt)[strlen(table[i].ogg)] == '=')
- {
- hdr = table[i].mp;
- val = *cmt + strlen(table[i].ogg) + 1;
- }
- }
+ const char *hdr, *val;
+ char **cmt = vc->user_comments;
+ int index, i;
+ ogg_demuxer_t *ogg_d = d->priv;
+ static const struct table {
+ const char *ogg;
+ const char *mp;
+ } table[] = {
+ { "ENCODED_USING", "Software" },
+ { "ENCODER_URL", "Encoder URL" },
+ { "TITLE", "Title" },
+ { "ARTIST", "Artist" },
+ { "COMMENT", "Comments" },
+ { "DATE", "Creation Date" },
+ { "GENRE", "Genre" },
+ { "ALBUM", "Album" },
+ { "TRACKNUMBER", "Track" },
+ { NULL, NULL },
+ };
+
+ while (*cmt) {
+ hdr = NULL;
+ if (!strncasecmp(*cmt, "LANGUAGE=", 9)) {
+ val = *cmt + 9;
+ if (ogg_d->subs[id].text)
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n",
+ ogg_d->subs[id].id, val);
+ else if (id != d->video->id)
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n",
+ ogg_d->subs[id].id, val);
+ if (ogg_d->subs[id].text)
+ mp_msg(MSGT_DEMUX, MSGL_INFO,
+ "[Ogg] Language for -sid %d is '-slang \"%s\"'\n",
+ ogg_d->subs[id].id, val);
+ // copy this language name into the array
+ index = demux_ogg_sub_reverse_id(d, id);
+ if (index >= 0) {
+ sh_sub_t *sh;
+
+ // in case of malicious files with more than one lang per track:
+ if (ogg_d->text_langs[index])
+ free(ogg_d->text_langs[index]);
+ ogg_d->text_langs[index] = strdup(val);
+ sh = d->s_streams[index];
+ if (sh && sh->lang)
+ free(sh->lang);
+ if (sh)
+ sh->lang = strdup(val);
+ }
+ // check for -slang if subs are uninitialized yet
+ if (os->text && d->sub->id < 0 && demux_ogg_check_lang(val, dvdsub_lang)) {
+ d->sub->id = index;
+ d->opts->sub_id = index;
+ mp_msg(MSGT_DEMUX, MSGL_V,
+ "Ogg demuxer: Displaying subtitle stream id %d which matched -slang %s\n",
+ id, val);
+ }
+ else
+ hdr = "Language";
+ }
+ else {
+ for (i = 0; table[i].ogg; i++) {
+ if (!strncasecmp(*cmt, table[i].ogg, strlen(table[i].ogg)) &&
+ (*cmt)[strlen(table[i].ogg)] == '=') {
+ hdr = table[i].mp;
+ val = *cmt + strlen(table[i].ogg) + 1;
+ }
+ }
+ }
+ if (hdr)
+ demux_info_add(d, hdr, val);
+ mp_dbg(MSGT_DEMUX, MSGL_DBG2, " %s: %s\n", hdr, val);
+ cmt++;
}
- if (hdr)