Mercurial > mplayer.hg
comparison libvo/vo_mpegpes.c @ 2706:3066369adb32
audio packet writting added
author | arpi |
---|---|
date | Mon, 05 Nov 2001 02:55:00 +0000 |
parents | b2ce5d6d7d4f |
children | 73838acce666 |
comparison
equal
deleted
inserted
replaced
2705:013e84f44cf5 | 2706:3066369adb32 |
---|---|
1 #undef HAVE_DVB | 1 #define HAVE_DVB |
2 #define PES_MAX_SIZE 2048 | 2 #define PES_MAX_SIZE 2048 |
3 /* | 3 /* |
4 * Based on: | 4 * Based on: |
5 * | 5 * |
6 * test_av.c - Test program for new API | 6 * test_av.c - Test program for new API |
289 #endif | 289 #endif |
290 } | 290 } |
291 | 291 |
292 static unsigned char pes_header[PES_MAX_SIZE]; | 292 static unsigned char pes_header[PES_MAX_SIZE]; |
293 | 293 |
294 static void send_pes_packet(unsigned char* data,int len,int id,int timestamp){ | 294 void send_pes_packet(unsigned char* data,int len,int id,int timestamp){ |
295 int x; | 295 int x; |
296 | 296 |
297 pes_header[0]=pes_header[1]=0; | 297 pes_header[0]=pes_header[1]=0; |
298 pes_header[2]=id>>8; pes_header[3]=id&255; | 298 pes_header[2]=id>>8; pes_header[3]=id&255; |
299 | 299 |
325 | 325 |
326 // printf("PES: draw frame! pts=%d size=%d \n",timestamp,len); | 326 // printf("PES: draw frame! pts=%d size=%d \n",timestamp,len); |
327 | 327 |
328 } | 328 } |
329 | 329 |
330 void send_lpcm_packet(unsigned char* data,int len,int id,int timestamp){ | |
331 int x; | |
332 | |
333 pes_header[0]=pes_header[1]=0; | |
334 pes_header[2]=1; pes_header[3]=0xBD; | |
335 | |
336 while(len>=4){ | |
337 int payload_size; | |
338 | |
339 payload_size=PES_MAX_SIZE-6-20; // max possible data len | |
340 if(payload_size>len) payload_size=len; | |
341 payload_size&=(~3); // align! | |
342 | |
343 payload_size+=20; // PTS+headers | |
344 | |
345 //if(6+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-6; | |
346 | |
347 // construct PES header: (code from ffmpeg's libav) | |
348 // startcode: | |
349 // packetsize: | |
350 pes_header[4]=(payload_size)>>8; | |
351 pes_header[5]=(payload_size)&255; | |
352 // stuffing: | |
353 pes_header[6]=0x81; | |
354 pes_header[7]=0x80; | |
355 pes_header[8]=10; // hdrlen | |
356 // presentation time stamp: | |
357 x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1; | |
358 pes_header[9]=x; | |
359 x=((((timestamp >> 15) & 0x7fff) << 1) | 1); | |
360 pes_header[10]=x>>8; pes_header[11]=x&255; | |
361 x=((((timestamp) & 0x7fff) << 1) | 1); | |
362 pes_header[12]=x>>8; pes_header[13]=x&255; | |
363 | |
364 pes_header[14]= | |
365 pes_header[15]= | |
366 pes_header[16]= | |
367 pes_header[17]= | |
368 pes_header[18]=0xFF; // stuffing | |
369 | |
370 pes_header[19]=id; | |
371 | |
372 pes_header[20]=0x07; // dunnowhat | |
373 pes_header[21]=0x00; | |
374 pes_header[22]=0x04; | |
375 pes_header[23]=0x0C; | |
376 | |
377 pes_header[24]=0x01; // LPCM id | |
378 pes_header[25]=0x80; | |
379 | |
380 payload_size-=20; | |
381 memcpy(&pes_header[6+20],data,payload_size); | |
382 my_write(pes_header,6+20+payload_size); | |
383 | |
384 len-=payload_size; data+=payload_size; | |
385 if(len<=0) break; | |
386 } | |
387 | |
388 // printf("PES: draw frame! pts=%d size=%d \n",timestamp,len); | |
389 | |
390 } | |
391 | |
392 | |
330 static uint32_t draw_frame(uint8_t * src[]) | 393 static uint32_t draw_frame(uint8_t * src[]) |
331 { | 394 { |
332 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; | 395 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; |
333 unsigned char *data=p->data; | 396 unsigned char *data=p->data; |
334 // int tmp=-1; | 397 // int tmp=-1; |
398 | 461 |
399 | 462 |
400 static uint32_t | 463 static uint32_t |
401 query_format(uint32_t format) | 464 query_format(uint32_t format) |
402 { | 465 { |
403 if(format==IMGFMT_MPEGPES) return 1; | 466 if(format==IMGFMT_MPEGPES) return 1|256; |
404 #ifdef USE_LIBAVCODEC | 467 #ifdef USE_LIBAVCODEC |
405 if(format==IMGFMT_YV12) return 1; | 468 if(format==IMGFMT_YV12) return 1|256; |
406 #endif | 469 #endif |
407 return 0; | 470 return 0; |
408 } | 471 } |
409 | 472 |
410 static void | 473 static void |