Mercurial > mplayer.hg
annotate tremor/synthesis.c @ 34757:da38eb1e2069
subassconvert: handle "\r\n" line ends
Previously the code converting text subtitles to ASS format converted newline
characters, and only those, to ASS "new line" markup. If the subtitles
contained "\r\n", the "\r" was thus left in the text. In previous libass
versions the "\r" was not visible, but in the current one it produces an empty
box. Improve the conversion to remove the "\r" in that case. Also treat a lone
"\r" as a newline.
Picked from mplayer2/3e0a2705
author | cboesch |
---|---|
date | Sat, 07 Apr 2012 11:17:09 +0000 |
parents | e83eef58b30a |
children |
rev | line source |
---|---|
14280 | 1 /******************************************************************** |
2 * * | |
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * | |
4 * * | |
19251
cd6b211be811
Replace tremor files that had old headers saying "ALL REDISTRIBUTION
uau
parents:
14280
diff
changeset
|
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
cd6b211be811
Replace tremor files that had old headers saying "ALL REDISTRIBUTION
uau
parents:
14280
diff
changeset
|
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
cd6b211be811
Replace tremor files that had old headers saying "ALL REDISTRIBUTION
uau
parents:
14280
diff
changeset
|
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
cd6b211be811
Replace tremor files that had old headers saying "ALL REDISTRIBUTION
uau
parents:
14280
diff
changeset
|
8 * * |
14280 | 9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * | |
11 * * | |
12 ******************************************************************** | |
13 | |
14 function: single-block PCM synthesis | |
15 last mod: $Id$ | |
16 | |
17 ********************************************************************/ | |
18 | |
19 #include <stdio.h> | |
20 #include "ogg.h" | |
21 #include "ivorbiscodec.h" | |
22 #include "codec_internal.h" | |
23 #include "registry.h" | |
24 #include "misc.h" | |
25 #include "os.h" | |
24796
8dfda4d651ec
_vorbis_block_alloc() is used w/o prototype, this will crash on ia64.
diego
parents:
19251
diff
changeset
|
26 #include "block.h" |
14280 | 27 |
28 int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ | |
29 vorbis_dsp_state *vd=vb->vd; | |
30 backend_lookup_state *b=(backend_lookup_state *)vd->backend_state; | |
31 vorbis_info *vi=vd->vi; | |
32 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | |
33 oggpack_buffer *opb=&vb->opb; | |
34 int type,mode,i; | |
29264
e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents:
24796
diff
changeset
|
35 |
14280 | 36 /* first things first. Make sure decode is ready */ |
37 _vorbis_block_ripcord(vb); | |
38 oggpack_readinit(opb,op->packet,op->bytes); | |
39 | |
40 /* Check the packet type */ | |
41 if(oggpack_read(opb,1)!=0){ | |
42 /* Oops. This is not an audio data packet */ | |
43 return(OV_ENOTAUDIO); | |
44 } | |
45 | |
46 /* read our mode and pre/post windowsize */ | |
47 mode=oggpack_read(opb,b->modebits); | |
48 if(mode==-1)return(OV_EBADPACKET); | |
29264
e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents:
24796
diff
changeset
|
49 |
14280 | 50 vb->mode=mode; |
51 vb->W=ci->mode_param[mode]->blockflag; | |
52 if(vb->W){ | |
53 vb->lW=oggpack_read(opb,1); | |
54 vb->nW=oggpack_read(opb,1); | |
55 if(vb->nW==-1) return(OV_EBADPACKET); | |
56 }else{ | |
57 vb->lW=0; | |
58 vb->nW=0; | |
59 } | |
29264
e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents:
24796
diff
changeset
|
60 |
14280 | 61 /* more setup */ |
62 vb->granulepos=op->granulepos; | |
63 vb->sequence=op->packetno-3; /* first block is third packet */ | |
64 vb->eofflag=op->e_o_s; | |
65 | |
66 /* alloc pcm passback storage */ | |
67 vb->pcmend=ci->blocksizes[vb->W]; | |
68 vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); | |
69 for(i=0;i<vi->channels;i++) | |
70 vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); | |
71 | |
72 /* unpack_header enforces range checking */ | |
73 type=ci->map_type[ci->mode_param[mode]->mapping]; | |
74 | |
75 return(_mapping_P[type]->inverse(vb,b->mode[mode])); | |
76 } | |
77 | |
78 long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ | |
79 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | |
80 oggpack_buffer opb; | |
81 int mode; | |
29264
e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents:
24796
diff
changeset
|
82 |
14280 | 83 oggpack_readinit(&opb,op->packet,op->bytes); |
84 | |
85 /* Check the packet type */ | |
86 if(oggpack_read(&opb,1)!=0){ | |
87 /* Oops. This is not an audio data packet */ | |
88 return(OV_ENOTAUDIO); | |
89 } | |
90 | |
91 { | |
92 int modebits=0; | |
93 int v=ci->modes; | |
94 while(v>1){ | |
95 modebits++; | |
96 v>>=1; | |
97 } | |
98 | |
99 /* read our mode and pre/post windowsize */ | |
100 mode=oggpack_read(&opb,modebits); | |
101 } | |
102 if(mode==-1)return(OV_EBADPACKET); | |
103 return(ci->blocksizes[ci->mode_param[mode]->blockflag]); | |
104 } | |
105 | |
106 |