changeset 241:3d92f793fd67 libavformat

64 bit pts for writing - more const usage
author bellard
date Wed, 10 Sep 2003 22:37:33 +0000
parents e6f99d238179
children 3c299d432ca4
files asf.c au.c audio.c avformat.h avienc.c crc.c dv.c dvcore.c dvcore.h ffm.c flvenc.c gif.c img.c movenc.c mp3.c mpeg.c mpegtsenc.c mpjpeg.c nut.c raw.c rm.c rtp.c swf.c wav.c yuv4mpeg.c
diffstat 25 files changed, 53 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/asf.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/asf.c	Wed Sep 10 22:37:33 2003 +0000
@@ -584,7 +584,7 @@
    crap. They have misread the MPEG Systems spec !
  */
 static void put_frame(AVFormatContext *s, ASFStream *stream, int timestamp,
-                      uint8_t *buf, int payload_size)
+                      const uint8_t *buf, int payload_size)
 {
     ASFContext *asf = s->priv_data;
     int frag_pos, frag_len, frag_len1;
@@ -617,7 +617,7 @@
 
 
 static int asf_write_packet(AVFormatContext *s, int stream_index,
-                            uint8_t *buf, int size, int timestamp)
+                            const uint8_t *buf, int size, int64_t timestamp)
 {
     ASFContext *asf = s->priv_data;
     ASFStream *stream;
--- a/au.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/au.c	Wed Sep 10 22:37:33 2003 +0000
@@ -72,7 +72,7 @@
 }
 
 static int au_write_packet(AVFormatContext *s, int stream_index_ptr,
-                           uint8_t *buf, int size, int force_pts)
+                           const uint8_t *buf, int size, int64_t pts)
 {
     ByteIOContext *pb = &s->pb;
     put_buffer(pb, buf, size);
--- a/audio.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/audio.c	Wed Sep 10 22:37:33 2003 +0000
@@ -165,7 +165,7 @@
 }
 
 static int audio_write_packet(AVFormatContext *s1, int stream_index,
-                              uint8_t *buf, int size, int force_pts)
+                              const uint8_t *buf, int size, int64_t pts)
 {
     AudioData *s = s1->priv_data;
     int len, ret;
--- a/avformat.h	Wed Sep 10 13:00:24 2003 +0000
+++ b/avformat.h	Wed Sep 10 22:37:33 2003 +0000
@@ -7,8 +7,8 @@
 
 #define LIBAVFORMAT_VERSION_INT 0x000408
 #define LIBAVFORMAT_VERSION     "0.4.8"
-#define LIBAVFORMAT_BUILD       4607
-#define LIBAVFORMAT_BUILD_STR   "4607"
+#define LIBAVFORMAT_BUILD       4608
+#define LIBAVFORMAT_BUILD_STR   "4608"
 
 #define LIBAVFORMAT_IDENT	"FFmpeg" LIBAVFORMAT_VERSION "b" LIBAVFORMAT_BUILD_STR
 
@@ -124,10 +124,9 @@
     enum CodecID audio_codec; /* default audio codec */
     enum CodecID video_codec; /* default video codec */
     int (*write_header)(struct AVFormatContext *);
-    /* XXX: change prototype for 64 bit pts */
     int (*write_packet)(struct AVFormatContext *, 
                         int stream_index,
-                        unsigned char *buf, int size, int force_pts);
+                        const uint8_t *buf, int size, int64_t pts);
     int (*write_trailer)(struct AVFormatContext *);
     /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
     int flags;
--- a/avienc.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/avienc.c	Wed Sep 10 22:37:33 2003 +0000
@@ -590,7 +590,7 @@
 }
 
 static int avi_write_packet(AVFormatContext *s, int stream_index,
-                            uint8_t *buf, int size, int force_pts)
+                            const uint8_t *buf, int size, int64_t pts)
 {
     AVIContext *avi = s->priv_data;
     ByteIOContext *pb = &s->pb;
--- a/crc.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/crc.c	Wed Sep 10 22:37:33 2003 +0000
@@ -33,7 +33,7 @@
 #define DO8(buf)  DO4(buf); DO4(buf);
 #define DO16(buf) DO8(buf); DO8(buf);
 
-static uint32_t adler32(uint32_t adler, uint8_t *buf, unsigned int len)
+static uint32_t adler32(uint32_t adler, const uint8_t *buf, unsigned int len)
 {
     unsigned long s1 = adler & 0xffff;
     unsigned long s2 = (adler >> 16) & 0xffff;
@@ -73,7 +73,7 @@
 
 static int crc_write_packet(struct AVFormatContext *s, 
                             int stream_index,
-                            unsigned char *buf, int size, int force_pts)
+                            const uint8_t *buf, int size, int64_t pts)
 {
     CRCState *crc = s->priv_data;
     crc->crcval = adler32(crc->crcval, buf, size);
--- a/dv.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/dv.c	Wed Sep 10 22:37:33 2003 +0000
@@ -102,8 +102,8 @@
 }
 
 int dv_write_packet(struct AVFormatContext *s, 
-                     int stream_index,
-                     unsigned char *buf, int size, int force_pts)
+                    int stream_index,
+                    const uint8_t *buf, int size, int64_t pts)
 {
     DVMuxContext *c = s->priv_data;
    
--- a/dvcore.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/dvcore.c	Wed Sep 10 22:37:33 2003 +0000
@@ -418,7 +418,7 @@
     }
 }
 
-void dv_inject_audio(DVMuxContext *c, uint8_t* pcm, uint8_t* frame_ptr)
+void dv_inject_audio(DVMuxContext *c, const uint8_t* pcm, uint8_t* frame_ptr)
 {
     int i, j, d, of;
     for (i = 0; i < c->sys->difseg_size; i++) {
@@ -434,7 +434,7 @@
     }
 }
 
-void dv_inject_video(DVMuxContext *c, uint8_t* video_data, uint8_t* frame_ptr)
+void dv_inject_video(DVMuxContext *c, const uint8_t* video_data, uint8_t* frame_ptr)
 {
     int i, j;
     int ptr = 0;
@@ -565,7 +565,7 @@
 }
 
 /* FIXME: The following three functions could be underengineered ;-) */
-void dv_assemble_frame(DVMuxContext *c, uint8_t* video, uint8_t* audio, int asize)
+void dv_assemble_frame(DVMuxContext *c, const uint8_t* video, const uint8_t* audio, int asize)
 {
     uint8_t pcm[8192];
     uint8_t* frame = &c->frame_buf[0];
@@ -604,7 +604,7 @@
         /* FIXME: we have to have more sensible approach than this one */
         if (fifo_size(&c->audio_data, c->audio_data.rptr) + asize >= AVCODEC_MAX_AUDIO_FRAME_SIZE)
 	    fprintf(stderr, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
-	fifo_write(&c->audio_data, audio, asize, &c->audio_data.wptr);
+	fifo_write(&c->audio_data, (uint8_t *)audio, asize, &c->audio_data.wptr);
     }
 }
 
--- a/dvcore.h	Wed Sep 10 13:00:24 2003 +0000
+++ b/dvcore.h	Wed Sep 10 22:37:33 2003 +0000
@@ -59,14 +59,14 @@
 } DVMuxContext;
 
 void dv_format_frame(DVMuxContext *, uint8_t*);
-void dv_inject_audio(DVMuxContext *, uint8_t*, uint8_t*);
-void dv_inject_video(DVMuxContext *, uint8_t*, uint8_t*);
+void dv_inject_audio(DVMuxContext *, const uint8_t*, uint8_t*);
+void dv_inject_video(DVMuxContext *, const uint8_t*, uint8_t*);
 
 int  dv_extract_audio(uint8_t*, uint8_t*, AVCodecContext*);
 
 int  dv_audio_frame_size(const DVprofile*, int);
 
-void dv_assemble_frame(DVMuxContext *, uint8_t*, uint8_t*, int);
+void dv_assemble_frame(DVMuxContext *c, const uint8_t*, const uint8_t*, int);
 int  dv_core_init(DVMuxContext *, AVStream*[]);
 void dv_core_delete(DVMuxContext *);
 
--- a/ffm.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/ffm.c	Wed Sep 10 22:37:33 2003 +0000
@@ -82,7 +82,7 @@
 
 /* 'first' is true if first data of a frame */
 static void ffm_write_data(AVFormatContext *s,
-                           uint8_t *buf, int size,
+                           const uint8_t *buf, int size,
                            int64_t pts, int first)
 {
     FFMContext *ffm = s->priv_data;
@@ -215,7 +215,7 @@
 }
 
 static int ffm_write_packet(AVFormatContext *s, int stream_index,
-                            uint8_t *buf, int size, int force_pts)
+                            const uint8_t *buf, int size, int64_t force_pts)
 {
     AVStream *st = s->streams[stream_index];
     FFMStream *fst = st->priv_data;
--- a/flvenc.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/flvenc.c	Wed Sep 10 22:37:33 2003 +0000
@@ -242,7 +242,7 @@
 }
 
 static int flv_write_packet(AVFormatContext *s, int stream_index,
-                            uint8_t *buf, int size, int timestamp)
+                            const uint8_t *buf, int size, int64_t timestamp)
 {
     ByteIOContext *pb = &s->pb;
     AVCodecContext *enc = &s->streams[stream_index]->codec;
--- a/gif.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/gif.c	Wed Sep 10 22:37:33 2003 +0000
@@ -220,12 +220,12 @@
 
 static int gif_image_write_image(ByteIOContext *pb, 
                                  int x1, int y1, int width, int height,
-                                 uint8_t *buf, int linesize, int pix_fmt)
+                                 const uint8_t *buf, int linesize, int pix_fmt)
 {
     PutBitContext p;
     uint8_t buffer[200]; /* 100 * 9 / 8 = 113 */
     int i, left, w, v;
-    uint8_t *ptr;
+    const uint8_t *ptr;
     /* image block */
 
     put_byte(pb, 0x2c);
@@ -331,7 +331,7 @@
 }
 
 static int gif_write_video(AVFormatContext *s, 
-                           AVCodecContext *enc, uint8_t *buf, int size)
+                           AVCodecContext *enc, const uint8_t *buf, int size)
 {
     ByteIOContext *pb = &s->pb;
     GIFContext *gif = s->priv_data;
@@ -366,7 +366,7 @@
 }
 
 static int gif_write_packet(AVFormatContext *s, int stream_index, 
-                           uint8_t *buf, int size, int force_pts)
+                            const uint8_t *buf, int size, int64_t pts)
 {
     AVCodecContext *codec = &s->streams[stream_index]->codec;
     if (codec->codec_type == CODEC_TYPE_AUDIO)
--- a/img.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/img.c	Wed Sep 10 22:37:33 2003 +0000
@@ -301,7 +301,7 @@
 }
 
 static int img_write_packet(AVFormatContext *s, int stream_index,
-                            uint8_t *buf, int size, int force_pts)
+                            const uint8_t *buf, int size, int64_t pts)
 {
     VideoData *img = s->priv_data;
     AVStream *st = s->streams[stream_index];
--- a/movenc.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/movenc.c	Wed Sep 10 22:37:33 2003 +0000
@@ -675,7 +675,7 @@
 }
 
 static int mov_write_packet(AVFormatContext *s, int stream_index,
-                            uint8_t *buf, int size, int force_pts)
+                            const uint8_t *buf, int size, int64_t pts)
 {
     MOVContext *mov = s->priv_data;
     ByteIOContext *pb = &s->pb;
--- a/mp3.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/mp3.c	Wed Sep 10 22:37:33 2003 +0000
@@ -323,7 +323,7 @@
 }
 
 static int mp3_write_packet(struct AVFormatContext *s, int stream_index,
-			    unsigned char *buf, int size, int force_pts)
+			    const uint8_t *buf, int size, int64_t pts)
 {
     put_buffer(&s->pb, buf, size);
     put_flush_packet(&s->pb);
--- a/mpeg.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/mpeg.c	Wed Sep 10 22:37:33 2003 +0000
@@ -347,7 +347,7 @@
 }
 
 static int mpeg_mux_write_packet(AVFormatContext *ctx, int stream_index,
-                                 uint8_t *buf, int size, int pts)
+                                 const uint8_t *buf, int size, int64_t pts)
 {
     MpegMuxContext *s = ctx->priv_data;
     AVStream *st = ctx->streams[stream_index];
--- a/mpegtsenc.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/mpegtsenc.c	Wed Sep 10 22:37:33 2003 +0000
@@ -22,7 +22,7 @@
 
 /* write DVB SI sections */
 
-static uint32_t crc_table[256] = {
+static const uint32_t crc_table[256] = {
 	0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
 	0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
 	0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
@@ -454,7 +454,7 @@
 }
 
 static int mpegts_write_packet(AVFormatContext *s, int stream_index,
-                               uint8_t *buf, int size, int pts1)
+                               const uint8_t *buf, int size, int64_t pts1)
 {
     AVStream *st = s->streams[stream_index];
     MpegTSWriteStream *ts_st = st->priv_data;
--- a/mpjpeg.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/mpjpeg.c	Wed Sep 10 22:37:33 2003 +0000
@@ -33,7 +33,7 @@
 }
 
 static int mpjpeg_write_packet(AVFormatContext *s, int stream_index, 
-                               uint8_t *buf, int size, int force_pts)
+                               const uint8_t *buf, int size, int64_t pts)
 {
     uint8_t buf1[256];
 
@@ -75,7 +75,7 @@
 }
 
 static int single_jpeg_write_packet(AVFormatContext *s, int stream_index,
-                            uint8_t *buf, int size, int force_pts)
+                                    const uint8_t *buf, int size, int64_t pts)
 {
     put_buffer(&s->pb, buf, size);
     put_flush_packet(&s->pb);
--- a/nut.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/nut.c	Wed Sep 10 22:37:33 2003 +0000
@@ -344,7 +344,7 @@
 }
 
 static int nut_write_packet(AVFormatContext *s, int stream_index, 
-			    uint8_t *buf, int size, int force_pts)
+			    const uint8_t *buf, int size, int64_t pts)
 {
     NUTContext *nut = s->priv_data;
     ByteIOContext *bc = &s->pb;
@@ -372,7 +372,7 @@
 
     put_packetheader(nut, bc, size+20);
     put_v(bc, stream_index);
-    put_s(bc, force_pts); /* lsb_timestamp */
+    put_s(bc, pts); /* lsb_timestamp */
     update_packetheader(nut, bc, size);
     
     put_buffer(bc, buf, size);
--- a/raw.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/raw.c	Wed Sep 10 22:37:33 2003 +0000
@@ -25,7 +25,7 @@
 }
 
 static int raw_write_packet(struct AVFormatContext *s, int stream_index,
-			    unsigned char *buf, int size, int force_pts)
+			    const uint8_t *buf, int size, int64_t pts)
 {
     put_buffer(&s->pb, buf, size);
     put_flush_packet(&s->pb);
@@ -459,7 +459,7 @@
 
 static int null_write_packet(struct AVFormatContext *s, 
                              int stream_index,
-                             unsigned char *buf, int size, int force_pts)
+                             const uint8_t *buf, int size, int64_t pts)
 {
     return 0;
 }
--- a/rm.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/rm.c	Wed Sep 10 22:37:33 2003 +0000
@@ -323,7 +323,7 @@
     return 0;
 }
 
-static int rm_write_audio(AVFormatContext *s, uint8_t *buf, int size)
+static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size)
 {
     uint8_t *buf1;
     RMContext *rm = s->priv_data;
@@ -348,7 +348,7 @@
     return 0;
 }
 
-static int rm_write_video(AVFormatContext *s, uint8_t *buf, int size)
+static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size)
 {
     RMContext *rm = s->priv_data;
     ByteIOContext *pb = &s->pb;
@@ -389,7 +389,7 @@
 }
 
 static int rm_write_packet(AVFormatContext *s, int stream_index, 
-                           uint8_t *buf, int size, int force_pts)
+                           const uint8_t *buf, int size, int64_t pts)
 {
     if (s->streams[stream_index]->codec.codec_type == 
         CODEC_TYPE_AUDIO)
--- a/rtp.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/rtp.c	Wed Sep 10 22:37:33 2003 +0000
@@ -425,7 +425,7 @@
 
 /* send an rtp packet. sequence number is incremented, but the caller
    must update the timestamp itself */
-static void rtp_send_data(AVFormatContext *s1, uint8_t *buf1, int len)
+static void rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len)
 {
     RTPContext *s = s1->priv_data;
 
@@ -451,7 +451,7 @@
 /* send an integer number of samples and compute time stamp and fill
    the rtp send buffer before sending. */
 static void rtp_send_samples(AVFormatContext *s1,
-                             uint8_t *buf1, int size, int sample_size)
+                             const uint8_t *buf1, int size, int sample_size)
 {
     RTPContext *s = s1->priv_data;
     int len, max_packet_size, n;
@@ -484,7 +484,7 @@
 /* NOTE: we suppose that exactly one frame is given as argument here */
 /* XXX: test it */
 static void rtp_send_mpegaudio(AVFormatContext *s1,
-                               uint8_t *buf1, int size)
+                               const uint8_t *buf1, int size)
 {
     RTPContext *s = s1->priv_data;
     AVStream *st = s1->streams[0];
@@ -540,7 +540,7 @@
 /* NOTE: a single frame must be passed with sequence header if
    needed. XXX: use slices. */
 static void rtp_send_mpegvideo(AVFormatContext *s1,
-                               uint8_t *buf1, int size)
+                               const uint8_t *buf1, int size)
 {
     RTPContext *s = s1->priv_data;
     AVStream *st = s1->streams[0];
@@ -587,7 +587,7 @@
 }
 
 static void rtp_send_raw(AVFormatContext *s1,
-                         uint8_t *buf1, int size)
+                         const uint8_t *buf1, int size)
 {
     RTPContext *s = s1->priv_data;
     AVStream *st = s1->streams[0];
@@ -613,7 +613,7 @@
 
 /* write an RTP packet. 'buf1' must contain a single specific frame. */
 static int rtp_write_packet(AVFormatContext *s1, int stream_index,
-                            uint8_t *buf1, int size, int force_pts)
+                            const uint8_t *buf1, int size, int64_t pts)
 {
     RTPContext *s = s1->priv_data;
     AVStream *st = s1->streams[0];
@@ -630,7 +630,7 @@
     if (s->first_packet || rtcp_bytes >= 28) {
         /* compute NTP time */
         /* XXX: 90 kHz timestamp hardcoded */
-        ntp_time = ((int64_t)force_pts << 28) / 5625;
+        ntp_time = (pts << 28) / 5625;
         rtcp_send_sr(s1, ntp_time); 
         s->last_octet_count = s->octet_count;
         s->first_packet = 0;
--- a/swf.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/swf.c	Wed Sep 10 22:37:33 2003 +0000
@@ -318,7 +318,7 @@
 }
 
 static int swf_write_video(AVFormatContext *s, 
-                           AVCodecContext *enc, uint8_t *buf, int size)
+                           AVCodecContext *enc, const uint8_t *buf, int size)
 {
     ByteIOContext *pb = &s->pb;
     static int tag_id = 0;
@@ -366,7 +366,7 @@
     return 0;
 }
 
-static int swf_write_audio(AVFormatContext *s, uint8_t *buf, int size)
+static int swf_write_audio(AVFormatContext *s, const uint8_t *buf, int size)
 {
     ByteIOContext *pb = &s->pb;
 
@@ -380,7 +380,7 @@
 }
 
 static int swf_write_packet(AVFormatContext *s, int stream_index, 
-                           uint8_t *buf, int size, int force_pts)
+                           const uint8_t *buf, int size, int64_t pts)
 {
     AVCodecContext *codec = &s->streams[stream_index]->codec;
     if (codec->codec_type == CODEC_TYPE_AUDIO)
--- a/wav.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/wav.c	Wed Sep 10 22:37:33 2003 +0000
@@ -191,7 +191,7 @@
 }
 
 static int wav_write_packet(AVFormatContext *s, int stream_index_ptr,
-                           uint8_t *buf, int size, int force_pts)
+                            const uint8_t *buf, int size, int64_t pts)
 {
     ByteIOContext *pb = &s->pb;
     put_buffer(pb, buf, size);
--- a/yuv4mpeg.c	Wed Sep 10 13:00:24 2003 +0000
+++ b/yuv4mpeg.c	Wed Sep 10 22:37:33 2003 +0000
@@ -113,7 +113,7 @@
 }
 
 static int yuv4_write_packet(AVFormatContext *s, int stream_index,
-                             uint8_t *buf, int size, int force_pts)
+                             const uint8_t *buf, int size, int64_t pts)
 {
     AVStream *st = s->streams[stream_index];
     ByteIOContext *pb = &s->pb;