AVStream is no place for such things.

Breaking API and ABI without deprecations because it was explicitly
declared as ffmpeg private and the tree is still unstable.
---
 ffmpeg.c               |   22 +++++++++++-----------
 libavformat/avformat.h |    2 --
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index d3a85dd..43f1071 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -264,6 +264,7 @@ typedef struct AVOutputStream {
     int source_index;        /* AVInputStream index */
     AVStream *st;            /* stream in the output file */
     int encoding_needed;     /* true if encoding needed for this stream */
+    int stream_copy;         /* true if the stream shouldn't be reencoded */
     int frame_number;
     /* input pts and corresponding output pts
        for A/V sync */
@@ -628,6 +629,7 @@ static int read_ffserver_streams(AVFormatContext *s, const 
char *filename)
     for(i=0;i<ic->nb_streams;i++) {
         AVStream *st;
         AVCodec *codec;
+        AVOutputStream *ost = new_output_stream(s, nb_output_files);
 
         s->nb_streams++;
 
@@ -645,20 +647,18 @@ static int read_ffserver_streams(AVFormatContext *s, 
const char *filename)
         codec = avcodec_find_encoder(st->codec->codec_id);
         if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
             if (audio_stream_copy) {
-                st->stream_copy = 1;
+                ost->stream_copy = 1;
             } else
                 choose_sample_fmt(st, codec);
         } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
             if (video_stream_copy) {
-                st->stream_copy = 1;
+                ost->stream_copy = 1;
             } else
                 choose_pixel_fmt(st, codec);
         }
 
         if(st->codec->flags & CODEC_FLAG_BITEXACT)
             nopts = 1;
-
-        new_output_stream(s, nb_output_files);
     }
 
     if (!nopts)
@@ -1319,7 +1319,7 @@ static void print_report(AVFormatContext **output_files,
         enc = ost->st->codec;
         if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
             snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ",
-                     !ost->st->stream_copy ?
+                     !ost->stream_copy ?
                      enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
         }
         if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
@@ -1328,7 +1328,7 @@ static void print_report(AVFormatContext **output_files,
             frame_number = ost->frame_number;
             snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d 
fps=%3d q=%3.1f ",
                      frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
-                     !ost->st->stream_copy ?
+                     !ost->stream_copy ?
                      enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
             if(is_last_report)
                 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
@@ -2076,7 +2076,7 @@ static int transcode(AVFormatContext **output_files,
         codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
         codec->chroma_sample_location = icodec->chroma_sample_location;
 
-        if (ost->st->stream_copy) {
+        if (ost->stream_copy) {
             uint64_t extra_size = (uint64_t)icodec->extradata_size + 
FF_INPUT_BUFFER_PADDING_SIZE;
 
             if (extra_size > INT_MAX)
@@ -2671,7 +2671,7 @@ static int transcode(AVFormatContext **output_files,
         for(i=0;i<nb_ostreams;i++) {
             ost = ost_table[i];
             if (ost) {
-                if (ost->st->stream_copy)
+                if (ost->stream_copy)
                     av_freep(&ost->st->codec->extradata);
                 if (ost->logfile) {
                     fclose(ost->logfile);
@@ -3382,7 +3382,7 @@ static void new_video_stream(AVFormatContext *oc, int 
file_idx)
     }
 
     if (video_stream_copy) {
-        st->stream_copy = 1;
+        ost->stream_copy = 1;
         video_enc->codec_type = AVMEDIA_TYPE_VIDEO;
         video_enc->sample_aspect_ratio =
         st->sample_aspect_ratio = 
av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);
@@ -3524,7 +3524,7 @@ static void new_audio_stream(AVFormatContext *oc, int 
file_idx)
         avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
     }
     if (audio_stream_copy) {
-        st->stream_copy = 1;
+        ost->stream_copy = 1;
         audio_enc->channels = audio_channels;
         audio_enc->sample_rate = audio_sample_rate;
     } else {
@@ -3597,7 +3597,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int 
file_idx)
         avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->flags |= CODEC_FLAG_GLOBAL_HEADER;
     }
     if (subtitle_stream_copy) {
-        st->stream_copy = 1;
+        ost->stream_copy = 1;
     } else {
         subtitle_enc->codec_id = codec_id;
         set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, 
AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 7327562..5a3348d 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -501,8 +501,6 @@ typedef struct AVStream {
      */
     AVRational time_base;
     int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) 
*/
-    /* ffmpeg.c private use */
-    int stream_copy; /**< If set, just copy stream. */
     enum AVDiscard discard; ///< Selects which packets can be discarded at 
will and do not need to be demuxed.
 
     //FIXME move stuff to a flags field?
-- 
1.7.4.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to