comparison mpeg.c @ 541:23a5448ade32 libavformat

simplify put_padding_packet()
author michael
date Fri, 01 Oct 2004 20:05:04 +0000
parents 26a477a5ebda
children be81a0f1974d
comparison
equal deleted inserted replaced
540:26a477a5ebda 541:23a5448ade32
53 int is_svcd; 53 int is_svcd;
54 int scr_stream_index; /* stream from which the system clock is 54 int scr_stream_index; /* stream from which the system clock is
55 computed (VBR case) */ 55 computed (VBR case) */
56 int64_t last_scr; /* current system clock */ 56 int64_t last_scr; /* current system clock */
57 57
58 double vcd_padding_bitrate; 58 double vcd_padding_bitrate; //FIXME floats
59 int64_t vcd_padding_bytes_written; 59 int64_t vcd_padding_bytes_written;
60 60
61 } MpegMuxContext; 61 } MpegMuxContext;
62 62
63 #define PACK_START_CODE ((unsigned int)0x000001ba) 63 #define PACK_START_CODE ((unsigned int)0x000001ba)
528 } 528 }
529 return s->packet_size - buf_index; 529 return s->packet_size - buf_index;
530 } 530 }
531 531
532 /* Write an MPEG padding packet header. */ 532 /* Write an MPEG padding packet header. */
533 static int put_padding_header(AVFormatContext *ctx,uint8_t* buf, int full_padding_size) 533 static void put_padding_packet(AVFormatContext *ctx, ByteIOContext *pb,int packet_bytes)
534 { 534 {
535 MpegMuxContext *s = ctx->priv_data; 535 MpegMuxContext *s = ctx->priv_data;
536 int size = full_padding_size - 6; /* subtract header length */ 536 int i;
537 537
538 buf[0] = (uint8_t)(PADDING_STREAM >> 24); 538 put_be32(pb, PADDING_STREAM);
539 buf[1] = (uint8_t)(PADDING_STREAM >> 16); 539 put_be16(pb, packet_bytes - 6);
540 buf[2] = (uint8_t)(PADDING_STREAM >> 8);
541 buf[3] = (uint8_t)(PADDING_STREAM);
542 buf[4] = (uint8_t)(size >> 8);
543 buf[5] = (uint8_t)(size & 0xff);
544
545 if (!s->is_mpeg2) { 540 if (!s->is_mpeg2) {
546 buf[6] = 0x0f; 541 put_byte(pb, 0x0f);
547 return 7; 542 packet_bytes -= 7;
548 } else 543 } else
549 return 6; 544 packet_bytes -= 6;
550 }
551
552 static void put_padding_packet(AVFormatContext *ctx, ByteIOContext *pb,int packet_bytes)
553 {
554 uint8_t buffer[7];
555 int size, i;
556
557 size = put_padding_header(ctx,buffer, packet_bytes);
558 put_buffer(pb, buffer, size);
559 packet_bytes -= size;
560 545
561 for(i=0;i<packet_bytes;i++) 546 for(i=0;i<packet_bytes;i++)
562 put_byte(pb, 0xff); 547 put_byte(pb, 0xff);
563 } 548 }
564 549