]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avisynth.c
h264: K&R formatting cosmetics
[ffmpeg] / libavformat / avisynth.c
index 10a07401b9d0a215e0d4dad257fbce5ed4d0bc67..f94f7b786d73543c2d476bb7c7809faf5cbb0e96 100644 (file)
@@ -303,6 +303,7 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
     st->codec->channels    = avs->vi->nchannels;
     st->time_base          = (AVRational) { 1,
                                             avs->vi->audio_samples_per_second };
+    st->duration           = avs->vi->num_audio_samples;
 
     switch (avs->vi->sample_type) {
     case AVS_SAMPLE_INT8:
@@ -423,10 +424,10 @@ static void avisynth_next_stream(AVFormatContext *s, AVStream **st,
 {
     AviSynthContext *avs = s->priv_data;
 
-    pkt->stream_index = avs->curr_stream++;
+    avs->curr_stream++;
     avs->curr_stream %= s->nb_streams;
 
-    *st = s->streams[pkt->stream_index];
+    *st = s->streams[avs->curr_stream];
     if ((*st)->discard == AVDISCARD_ALL)
         *discard = 1;
     else
@@ -454,10 +455,6 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
     if (discard)
         return 0;
 
-    pkt->pts      = n;
-    pkt->dts      = n;
-    pkt->duration = 1;
-
 #ifdef USING_AVISYNTH
     /* Define the bpp values for the new AviSynth 2.6 colorspaces.
      * Since AvxSynth doesn't have these functions, special-case
@@ -485,6 +482,11 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
     if (av_new_packet(pkt, pkt->size) < 0)
         return AVERROR(ENOMEM);
 
+    pkt->pts      = n;
+    pkt->dts      = n;
+    pkt->duration = 1;
+    pkt->stream_index = avs->curr_stream;
+
     frame = avs_library.avs_get_frame(avs->clip, n);
     error = avs_library.avs_clip_get_error(avs->clip);
     if (error) {
@@ -561,10 +563,6 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt,
     if (discard)
         return 0;
 
-    pkt->pts      = n;
-    pkt->dts      = n;
-    pkt->duration = samples;
-
     pkt->size = avs_bytes_per_channel_sample(avs->vi) *
                 samples * avs->vi->nchannels;
     if (!pkt->size)
@@ -573,6 +571,11 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt,
     if (av_new_packet(pkt, pkt->size) < 0)
         return AVERROR(ENOMEM);
 
+    pkt->pts      = n;
+    pkt->dts      = n;
+    pkt->duration = samples;
+    pkt->stream_index = avs->curr_stream;
+
     avs_library.avs_get_audio(avs->clip, pkt->data, n, samples);
     error = avs_library.avs_clip_get_error(avs->clip);
     if (error) {