diff avidec.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 128838bc4bb6
line wrap: on
line diff
--- a/avidec.c	Sun Jul 17 00:28:12 2005 +0000
+++ b/avidec.c	Sun Jul 17 22:24:36 2005 +0000
@@ -178,7 +178,7 @@
 	           goto fail;
                 
 		ast = s->streams[0]->priv_data;
-		av_freep(&s->streams[0]->codec.extradata);
+		av_freep(&s->streams[0]->codec->extradata);
 		av_freep(&s->streams[0]);
 		s->nb_streams = 0;
 	        avi->dv_demux = dv_init_demux(s);
@@ -199,7 +199,7 @@
             } 
             st = s->streams[stream_index];
             ast = st->priv_data;
-            st->codec.stream_codec_tag= handler;
+            st->codec->stream_codec_tag= handler;
 
             get_le32(pb); /* flags */
             get_le16(pb); /* priority */
@@ -259,10 +259,10 @@
                 switch(codec_type) {
                 case CODEC_TYPE_VIDEO:
                     get_le32(pb); /* size */
-                    st->codec.width = get_le32(pb);
-                    st->codec.height = get_le32(pb);
+                    st->codec->width = get_le32(pb);
+                    st->codec->height = get_le32(pb);
                     get_le16(pb); /* panes */
-                    st->codec.bits_per_sample= get_le16(pb); /* depth */
+                    st->codec->bits_per_sample= get_le16(pb); /* depth */
                     tag1 = get_le32(pb);
                     get_le32(pb); /* ImageSize */
                     get_le32(pb); /* XPelsPerMeter */
@@ -271,41 +271,41 @@
                     get_le32(pb); /* ClrImportant */
 
                  if(size > 10*4 && size<(1<<30)){
-                    st->codec.extradata_size= size - 10*4;
-                    st->codec.extradata= av_malloc(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
-                    get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
+                    st->codec->extradata_size= size - 10*4;
+                    st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+                    get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
                  }
                     
-                    if(st->codec.extradata_size & 1) //FIXME check if the encoder really did this correctly
+                    if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
                         get_byte(pb);
 
                     /* Extract palette from extradata if bpp <= 8 */
                     /* This code assumes that extradata contains only palette */
                     /* This is true for all paletted codecs implemented in ffmpeg */
-                    if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) {
-                        st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl));
+                    if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) {
+                        st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
 #ifdef WORDS_BIGENDIAN
-                        for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++)
-                            st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]);
+                        for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
+                            st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]);
 #else
-                        memcpy(st->codec.palctrl->palette, st->codec.extradata,
-                               FFMIN(st->codec.extradata_size, AVPALETTE_SIZE));
+                        memcpy(st->codec->palctrl->palette, st->codec->extradata,
+                               FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
 #endif
-                        st->codec.palctrl->palette_changed = 1;
+                        st->codec->palctrl->palette_changed = 1;
                     }
 
 #ifdef DEBUG
                     print_tag("video", tag1, 0);
 #endif
-                    st->codec.codec_type = CODEC_TYPE_VIDEO;
-                    st->codec.codec_tag = tag1;
-                    st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1);
-                    if (st->codec.codec_id == CODEC_ID_XAN_WC4)
+                    st->codec->codec_type = CODEC_TYPE_VIDEO;
+                    st->codec->codec_tag = tag1;
+                    st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
+                    if (st->codec->codec_id == CODEC_ID_XAN_WC4)
                         xan_video = 1;
 //                    url_fskip(pb, size - 5 * 4);
                     break;
                 case CODEC_TYPE_AUDIO:
-                    get_wav_header(pb, &st->codec, size);
+                    get_wav_header(pb, st->codec, size);
                     if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
                         url_fskip(pb, 1);
                     /* special case time: To support Xan DPCM, hardcode
@@ -314,12 +314,12 @@
                     /* force parsing as several audio frames can be in
                        one packet */
                     if (xan_video)
-                        st->codec.codec_id = CODEC_ID_XAN_DPCM;
+                        st->codec->codec_id = CODEC_ID_XAN_DPCM;
                     break;
                 default:
-                    st->codec.codec_type = CODEC_TYPE_DATA;
-                    st->codec.codec_id= CODEC_ID_NONE;
-                    st->codec.codec_tag= 0;
+                    st->codec->codec_type = CODEC_TYPE_DATA;
+                    st->codec->codec_id= CODEC_ID_NONE;
+                    st->codec->codec_tag= 0;
                     url_fskip(pb, size);
                     break;
                 }
@@ -337,7 +337,7 @@
     if (stream_index != s->nb_streams - 1) {
     fail:
         for(i=0;i<s->nb_streams;i++) {
-            av_freep(&s->streams[i]->codec.extradata);
+            av_freep(&s->streams[i]->codec->extradata);
             av_freep(&s->streams[i]);
         }
         return -1;
@@ -440,7 +440,7 @@
 //av_log(NULL, AV_LOG_DEBUG, "dts:%Ld offset:%d %d/%d smpl_siz:%d base:%d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, ast->sample_size, AV_TIME_BASE, n, size);
             pkt->stream_index = avi->stream_index;
 
-            if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
+            if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
                 if(st->index_entries){
                     AVIndexEntry *e;
                     int index;
@@ -580,9 +580,9 @@
                 g = get_byte(pb);
                 b = get_byte(pb);
                     get_byte(pb);
-                st->codec.palctrl->palette[k] = b + (g << 8) + (r << 16);
+                st->codec->palctrl->palette[k] = b + (g << 8) + (r << 16);
             }
-            st->codec.palctrl->palette_changed = 1;
+            st->codec->palctrl->palette_changed = 1;
             goto resync;
         }
 
@@ -786,8 +786,8 @@
         AVStream *st = s->streams[i];
         AVIStream *ast = st->priv_data;
         av_free(ast);
-        av_free(st->codec.extradata);
-        av_free(st->codec.palctrl);
+        av_free(st->codec->extradata);
+        av_free(st->codec->palctrl);
     }
 
     if (avi->dv_demux)