Browse code

kill obnoxious ogg_packet passing from demuxer to decoder

Originally committed as revision 2953 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2004/04/04 11:07:15
Showing 2 changed files
... ...
@@ -19,6 +19,7 @@ typedef struct OggVorbisContext {
19 19
 
20 20
     /* decoder */
21 21
     vorbis_comment vc ;
22
+    ogg_packet op;
22 23
 } OggVorbisContext ;
23 24
 
24 25
 
... ...
@@ -146,6 +147,7 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) {
146 146
 
147 147
     vorbis_info_init(&context->vi) ;
148 148
     vorbis_comment_init(&context->vc) ;
149
+    context->op.packetno= 0;
149 150
 
150 151
     return 0 ;
151 152
 }
... ...
@@ -181,8 +183,8 @@ static int oggvorbis_decode_frame(AVCodecContext *avccontext,
181 181
                         uint8_t *buf, int buf_size)
182 182
 {
183 183
     OggVorbisContext *context = avccontext->priv_data ;
184
-    ogg_packet *op = (ogg_packet*)buf ;
185 184
     float **pcm ;
185
+    ogg_packet *op= &context->op;    
186 186
     int samples, total_samples, total_bytes,i;
187 187
  
188 188
     if(!buf_size){
... ...
@@ -191,14 +193,15 @@ static int oggvorbis_decode_frame(AVCodecContext *avccontext,
191 191
         return 0;
192 192
     }
193 193
     
194
-    op->packet = (char*)op + sizeof(ogg_packet) ; /* correct data pointer */
194
+    op->packet = buf;
195
+    op->bytes  = buf_size;
196
+    op->b_o_s  = op->packetno == 0;
195 197
 
196 198
 //    av_log(avccontext, AV_LOG_DEBUG, "%d %d %d %lld %lld %d %d\n", op->bytes, op->b_o_s, op->e_o_s, op->granulepos, op->packetno, buf_size, context->vi.rate);
197 199
     
198 200
 /*    for(i=0; i<op->bytes; i++)
199 201
       av_log(avccontext, AV_LOG_DEBUG, "%02X ", op->packet[i]);
200 202
     av_log(avccontext, AV_LOG_DEBUG, "\n");*/
201
-//    op->b_o_s= op->packetno == 0;
202 203
     if(op->packetno < 3) {
203 204
 	if(vorbis_synthesis_headerin(&context->vi, &context->vc, op)<0){
204 205
             av_log(avccontext, AV_LOG_ERROR, "%lld. vorbis header damaged\n", op->packetno+1);
... ...
@@ -206,6 +209,7 @@ static int oggvorbis_decode_frame(AVCodecContext *avccontext,
206 206
         }
207 207
 	avccontext->channels = context->vi.channels ;
208 208
 	avccontext->sample_rate = context->vi.rate ;
209
+        op->packetno++;
209 210
 	return buf_size ;
210 211
     }
211 212
 
... ...
@@ -230,6 +234,7 @@ static int oggvorbis_decode_frame(AVCodecContext *avccontext,
230 230
         vorbis_synthesis_read(&context->vd, samples) ;
231 231
     }
232 232
 
233
+    op->packetno++;
233 234
     *data_size = total_bytes ;   
234 235
     return buf_size ;
235 236
 }
... ...
@@ -226,13 +226,12 @@ static int ogg_read_packet(AVFormatContext *avfcontext, AVPacket *pkt) {
226 226
 
227 227
     if(next_packet(avfcontext, &op)) 
228 228
 	return -EIO ;
229
-    if(av_new_packet(pkt, sizeof(ogg_packet) + op.bytes) < 0)
229
+    if(av_new_packet(pkt, op.bytes) < 0)
230 230
 	return -EIO ;
231 231
     pkt->stream_index = 0 ;
232
-    memcpy(pkt->data, &op, sizeof(ogg_packet)) ;
233
-    memcpy(pkt->data + sizeof(ogg_packet), op.packet, op.bytes) ;
232
+    memcpy(pkt->data, op.packet, op.bytes);
234 233
 
235
-    return sizeof(ogg_packet) + op.bytes ;
234
+    return op.bytes;
236 235
 }
237 236
 
238 237