changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext...
[libav.git] / libavformat / nsvdec.c
index 7157eb7..27c7abc 100644 (file)
@@ -300,8 +300,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
     PRINT(("NSV NSVf chunk_size %ld\n", size));
     PRINT(("NSV NSVf file_size %Ld\n", file_size));
 
-    duration = get_le32(pb); /* in ms */
-    nsv->duration = duration * AV_TIME_BASE / 1000; /* convert */
+    nsv->duration = duration = get_le32(pb); /* in ms */
     PRINT(("NSV NSVf duration %Ld ms\n", duration));
     // XXX: store it in AVStreams
 
@@ -440,18 +439,16 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
             if (!nst)
                 goto fail;
             st->priv_data = nst;
-            st->codec.codec_type = CODEC_TYPE_VIDEO;
-            st->codec.codec_tag = vtag;
-            st->codec.codec_id = codec_get_id(nsv_codec_video_tags, vtag);
-            st->codec.width = vwidth;
-            st->codec.height = vheight;
-            st->codec.bits_per_sample = 24; /* depth XXX */
+            st->codec->codec_type = CODEC_TYPE_VIDEO;
+            st->codec->codec_tag = vtag;
+            st->codec->codec_id = codec_get_id(nsv_codec_video_tags, vtag);
+            st->codec->width = vwidth;
+            st->codec->height = vheight;
+            st->codec->bits_per_sample = 24; /* depth XXX */
 
             av_set_pts_info(st, 64, framerate.den, framerate.num);
-            st->codec.frame_rate = framerate.num;
-            st->codec.frame_rate_base = framerate.den;
             st->start_time = 0;
-            st->duration = nsv->duration;
+            st->duration = av_rescale(nsv->duration, framerate.num, 1000*framerate.den);
         }
         if (atag != T_NONE) {
 #ifndef DISABLE_AUDIO
@@ -463,17 +460,17 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
             if (!nst)
                 goto fail;
             st->priv_data = nst;
-            st->codec.codec_type = CODEC_TYPE_AUDIO;
-            st->codec.codec_tag = atag;
-            st->codec.codec_id = codec_get_id(nsv_codec_audio_tags, atag);
+            st->codec->codec_type = CODEC_TYPE_AUDIO;
+            st->codec->codec_tag = atag;
+            st->codec->codec_id = codec_get_id(nsv_codec_audio_tags, atag);
             st->start_time = 0;
-            st->duration = nsv->duration;
+//            st->duration = nsv->duration; //FIXME
             
             st->need_parsing = 1; /* for PCM we will read a chunk later and put correct info */
             /* XXX:FIXME */
-            //st->codec.channels = 2; //XXX:channels;
-            //st->codec.sample_rate = 1000;
-            //av_set_pts_info(st, 64, 1, st->codec.sample_rate);
+            //st->codec->channels = 2; //XXX:channels;
+            //st->codec->sample_rate = 1000;
+            //av_set_pts_info(st, 64, 1, st->codec->sample_rate);
 
 #endif
         }
@@ -595,8 +592,7 @@ null_chunk_retry:
     if (vsize/* && st[NSV_ST_VIDEO]*/) {
         nst = st[NSV_ST_VIDEO]->priv_data;
         pkt = &nsv->ahead[NSV_ST_VIDEO];
-        av_new_packet(pkt, vsize);
-        get_buffer(pb, pkt->data, vsize);
+        av_get_packet(pb, pkt, vsize);
         pkt->stream_index = st[NSV_ST_VIDEO]->index;//NSV_ST_VIDEO;
         pkt->dts = nst->frame_offset++;
         pkt->flags |= PKT_FLAG_KEY; /* stupid format has no way to tell XXX: try the index */
@@ -610,7 +606,7 @@ null_chunk_retry:
         pkt = &nsv->ahead[NSV_ST_AUDIO];
         /* read raw audio specific header on the first audio chunk... */
         /* on ALL audio chunks ?? seems so! */
-        if (asize && st[NSV_ST_AUDIO]->codec.codec_tag == MKTAG('P', 'C', 'M', ' ')/* && fill_header*/) {
+        if (asize && st[NSV_ST_AUDIO]->codec->codec_tag == MKTAG('P', 'C', 'M', ' ')/* && fill_header*/) {
             uint8_t bps;
             uint8_t channels;
             uint16_t samplerate;
@@ -626,19 +622,17 @@ null_chunk_retry:
                 }
                 bps /= channels; // ???
                 if (bps == 8)
-                    st[NSV_ST_AUDIO]->codec.codec_id = CODEC_ID_PCM_U8;
+                    st[NSV_ST_AUDIO]->codec->codec_id = CODEC_ID_PCM_U8;
                 samplerate /= 4;/* UGH ??? XXX */
                 channels = 1;
-                st[NSV_ST_AUDIO]->codec.channels = channels;
-                st[NSV_ST_AUDIO]->codec.sample_rate = samplerate;
+                st[NSV_ST_AUDIO]->codec->channels = channels;
+                st[NSV_ST_AUDIO]->codec->sample_rate = samplerate;
                 av_set_pts_info(st[NSV_ST_AUDIO], 64, 1, 
-                                st[NSV_ST_AUDIO]->codec.sample_rate);
+                                st[NSV_ST_AUDIO]->codec->sample_rate);
                 PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %ld\n", bps, channels, samplerate));
             }
         }
-        av_new_packet(pkt, asize);
-        if (asize)
-            get_buffer(pb, pkt->data, asize);
+        av_get_packet(pb, pkt, asize);
         pkt->stream_index = st[NSV_ST_AUDIO]->index;//NSV_ST_AUDIO;
         //pkt->dts = nst->frame_offset;
         //if (nst->sample_size)
@@ -710,8 +704,8 @@ static int nsv_read_close(AVFormatContext *s)
             av_free(ast->index_entries);
             av_free(ast);
         }
-        av_free(st->codec.extradata);
-        av_free(st->codec.palctrl);
+        av_free(st->codec->extradata);
+        av_free(st->codec->palctrl);
     }
 
 #endif