diff rm.c @ 820:feca73904e67 libavformat

changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
author michael
date Sun, 17 Jul 2005 22:24:36 +0000
parents c5077fdab490
children 66cc656ea404
line wrap: on
line diff
--- a/rm.c	Sun Jul 17 00:28:12 2005 +0000
+++ b/rm.c	Sun Jul 17 22:24:36 2005 +0000
@@ -298,7 +298,7 @@
 
     for(n=0;n<s->nb_streams;n++) {
         s->streams[n]->id = n;
-        codec = &s->streams[n]->codec;
+        codec = s->streams[n]->codec;
         stream = &rm->streams[n];
         memset(stream, 0, sizeof(StreamInfo));
         stream->num = n;
@@ -399,7 +399,7 @@
 
 static int rm_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    if (s->streams[pkt->stream_index]->codec.codec_type == 
+    if (s->streams[pkt->stream_index]->codec->codec_type == 
         CODEC_TYPE_AUDIO)
         return rm_write_audio(s, pkt->data, pkt->size, pkt->flags);
     else
@@ -495,10 +495,10 @@
         get_str8(pb, s->comment, sizeof(s->comment));
         get_byte(pb);
         get_str8(pb, buf, sizeof(buf));
-        st->codec.sample_rate = 8000;
-        st->codec.channels = 1;
-        st->codec.codec_type = CODEC_TYPE_AUDIO;
-        st->codec.codec_id = CODEC_ID_RA_144;
+        st->codec->sample_rate = 8000;
+        st->codec->channels = 1;
+        st->codec->codec_type = CODEC_TYPE_AUDIO;
+        st->codec->codec_id = CODEC_ID_RA_144;
     } else {
         int flavor, sub_packet_h, coded_framesize;
         /* old version (4) */
@@ -512,30 +512,30 @@
         get_be32(pb); /* ??? */
         get_be32(pb); /* ??? */
         sub_packet_h= get_be16(pb); /* 1 */ 
-        st->codec.block_align= get_be16(pb); /* frame size */
+        st->codec->block_align= get_be16(pb); /* frame size */
         get_be16(pb); /* sub packet size */
         get_be16(pb); /* ??? */
-        st->codec.sample_rate = get_be16(pb);
+        st->codec->sample_rate = get_be16(pb);
         get_be32(pb);
-        st->codec.channels = get_be16(pb);
+        st->codec->channels = get_be16(pb);
         get_str8(pb, buf, sizeof(buf)); /* desc */
         get_str8(pb, buf, sizeof(buf)); /* desc */
-        st->codec.codec_type = CODEC_TYPE_AUDIO;
+        st->codec->codec_type = CODEC_TYPE_AUDIO;
         if (!strcmp(buf, "dnet")) {
-            st->codec.codec_id = CODEC_ID_AC3;
+            st->codec->codec_id = CODEC_ID_AC3;
         } else if (!strcmp(buf, "28_8")) {
-            st->codec.codec_id = CODEC_ID_RA_288;
-            st->codec.extradata_size= 10;
-            st->codec.extradata= av_mallocz(st->codec.extradata_size);
+            st->codec->codec_id = CODEC_ID_RA_288;
+            st->codec->extradata_size= 10;
+            st->codec->extradata= av_mallocz(st->codec->extradata_size);
             /* this is completly braindead and broken, the idiot who added this codec and endianness
                specific reordering to mplayer and libavcodec/ra288.c should be drowned in a see of cola */
             //FIXME pass the unpermutated extradata
-            ((uint16_t*)st->codec.extradata)[1]= sub_packet_h;
-            ((uint16_t*)st->codec.extradata)[2]= flavor;
-            ((uint16_t*)st->codec.extradata)[3]= coded_framesize;
+            ((uint16_t*)st->codec->extradata)[1]= sub_packet_h;
+            ((uint16_t*)st->codec->extradata)[2]= flavor;
+            ((uint16_t*)st->codec->extradata)[3]= coded_framesize;
         } else {
-            st->codec.codec_id = CODEC_ID_NONE;
-            pstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name),
+            st->codec->codec_id = CODEC_ID_NONE;
+            pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name),
                     buf);
         }
         if (read_all) {
@@ -635,7 +635,7 @@
                 goto fail;
             st->id = get_be16(pb);
             get_be32(pb); /* max bit rate */
-            st->codec.bit_rate = get_be32(pb); /* bit rate */
+            st->codec->bit_rate = get_be32(pb); /* bit rate */
             get_be32(pb); /* max packet size */
             get_be32(pb); /* avg packet size */
             start_time = get_be32(pb); /* start time */
@@ -647,7 +647,7 @@
             get_str8(pb, buf, sizeof(buf)); /* mimetype */
             codec_data_size = get_be32(pb);
             codec_pos = url_ftell(pb);
-            st->codec.codec_type = CODEC_TYPE_DATA;
+            st->codec->codec_type = CODEC_TYPE_DATA;
             av_set_pts_info(st, 64, 1, 1000);
 
             v = get_be32(pb);
@@ -658,43 +658,43 @@
                 int fps, fps2;
                 if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
                 fail1:
-                    av_log(&st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
+                    av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
                     goto skip;
                 }
-                st->codec.codec_tag = get_le32(pb);
-//                av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec.codec_tag, MKTAG('R', 'V', '2', '0'));
-                if (   st->codec.codec_tag != MKTAG('R', 'V', '1', '0')
-                    && st->codec.codec_tag != MKTAG('R', 'V', '2', '0')
-                    && st->codec.codec_tag != MKTAG('R', 'V', '3', '0')
-                    && st->codec.codec_tag != MKTAG('R', 'V', '4', '0'))
+                st->codec->codec_tag = get_le32(pb);
+//                av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
+                if (   st->codec->codec_tag != MKTAG('R', 'V', '1', '0')
+                    && st->codec->codec_tag != MKTAG('R', 'V', '2', '0')
+                    && st->codec->codec_tag != MKTAG('R', 'V', '3', '0')
+                    && st->codec->codec_tag != MKTAG('R', 'V', '4', '0'))
                     goto fail1;
-                st->codec.width = get_be16(pb);
-                st->codec.height = get_be16(pb);
-                st->codec.time_base.num= 1;
+                st->codec->width = get_be16(pb);
+                st->codec->height = get_be16(pb);
+                st->codec->time_base.num= 1;
                 fps= get_be16(pb);
-                st->codec.codec_type = CODEC_TYPE_VIDEO;
+                st->codec->codec_type = CODEC_TYPE_VIDEO;
                 get_be32(pb);
                 fps2= get_be16(pb);
                 get_be16(pb);
                 
-                st->codec.extradata_size= codec_data_size - (url_ftell(pb) - codec_pos);
-                st->codec.extradata= av_malloc(st->codec.extradata_size);
-                get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
+                st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos);
+                st->codec->extradata= av_malloc(st->codec->extradata_size);
+                get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
                 
 //                av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
-                st->codec.time_base.den = fps * st->codec.time_base.num;
+                st->codec->time_base.den = fps * st->codec->time_base.num;
                 /* modification of h263 codec version (!) */
 #ifdef WORDS_BIGENDIAN
-                h263_hack_version = ((uint32_t*)st->codec.extradata)[1];
+                h263_hack_version = ((uint32_t*)st->codec->extradata)[1];
 #else
-                h263_hack_version = bswap_32(((uint32_t*)st->codec.extradata)[1]);
+                h263_hack_version = bswap_32(((uint32_t*)st->codec->extradata)[1]);
 #endif
-                st->codec.sub_id = h263_hack_version;
+                st->codec->sub_id = h263_hack_version;
                 switch((h263_hack_version>>28)){
-                case 1: st->codec.codec_id = CODEC_ID_RV10; break;
-                case 2: st->codec.codec_id = CODEC_ID_RV20; break;
-                case 3: st->codec.codec_id = CODEC_ID_RV30; break;
-                case 4: st->codec.codec_id = CODEC_ID_RV40; break;
+                case 1: st->codec->codec_id = CODEC_ID_RV10; break;
+                case 2: st->codec->codec_id = CODEC_ID_RV20; break;
+                case 3: st->codec->codec_id = CODEC_ID_RV30; break;
+                case 4: st->codec->codec_id = CODEC_ID_RV40; break;
                 default: goto fail1;
                 }
             }
@@ -827,7 +827,7 @@
             return AVERROR_IO;
         st = s->streams[i];
 
-        if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
+        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
             int h, pic_num, len2, pos;
 
             h= get_byte(pb); len--;
@@ -862,8 +862,8 @@
         pkt->stream_index = i;
 
 #if 0
-        if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
-            if(st->codec.codec_id == CODEC_ID_RV20){
+        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+            if(st->codec->codec_id == CODEC_ID_RV20){
                 int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
                 av_log(NULL, AV_LOG_DEBUG, "%d %Ld %d\n", timestamp, timestamp*512LL/25, seq);
 
@@ -882,7 +882,7 @@
     }
 
     /* for AC3, needs to swap bytes */
-    if (st->codec.codec_id == CODEC_ID_AC3) {
+    if (st->codec->codec_id == CODEC_ID_AC3) {
         ptr = pkt->data;
         for(j=0;j<len;j+=2) {
             tmp = ptr[0];
@@ -937,7 +937,7 @@
             return AV_NOPTS_VALUE;
 
         st = s->streams[stream_index2];
-        if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
+        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
             h= get_byte(&s->pb); len--;
             if(!(h & 0x40)){
                 seq = get_byte(&s->pb); len--;