[FFmpeg-cvslog] lavf: deprecate AVStream.quality.

Anton Khirnov git at videolan.org
Thu Jul 7 00:15:09 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Jun 20 13:08:40 2011 +0200| [5e8d2e337e432cad00daae7a6755c994b4853e70] | committer: Anton Khirnov

lavf: deprecate AVStream.quality.

AVStream is no place for it and it's unused outside of ffmpeg anyway.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5e8d2e337e432cad00daae7a6755c994b4853e70
---

 ffmpeg.c               |   15 ++++++++-------
 libavformat/avformat.h |    4 +++-
 libavformat/ffmdec.c   |    1 -
 libavformat/ffmenc.c   |    1 -
 libavformat/version.h  |    3 +++
 tests/ref/lavf/ffm     |    2 +-
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 1a4d2a1..29d9d17 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1123,7 +1123,7 @@ static void do_video_out(AVFormatContext *s,
                          AVOutputStream *ost,
                          AVInputStream *ist,
                          AVFrame *in_picture,
-                         int *frame_size)
+                         int *frame_size, float quality)
 {
     int nb_frames, i, ret, resample_changed;
     AVFrame *final_picture, *formatted_picture;
@@ -1245,7 +1245,7 @@ static void do_video_out(AVFormatContext *s,
 
             /* handles sameq here. This is not correct because it may
                not be a global option */
-            big_picture.quality = same_quality ? ist->st->quality : ost->st->quality;
+            big_picture.quality = quality;
             if(!me_threshold)
                 big_picture.pict_type = 0;
 //            big_picture.pts = AV_NOPTS_VALUE;
@@ -1480,6 +1480,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
 #if CONFIG_AVFILTER
     int frame_available;
 #endif
+    float quality;
 
     AVPacket avpkt;
     int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt);
@@ -1560,7 +1561,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
 
                     ret = avcodec_decode_video2(ist->st->codec,
                                                 &picture, &got_output, &avpkt);
-                    ist->st->quality= picture.quality;
+                    quality = same_quality ? picture.quality : 0;
                     if (ret < 0)
                         goto fail_decode;
                     if (!got_output) {
@@ -1685,7 +1686,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
                             if (ost->picref->video && !ost->frame_aspect_ratio)
                                 ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect;
 #endif
-                            do_video_out(os, ost, ist, &picture, &frame_size);
+                            do_video_out(os, ost, ist, &picture, &frame_size,
+                                         same_quality ? quality : ost->st->codec->global_quality);
                             if (vstats_filename && frame_size)
                                 do_video_stats(os, ost, frame_size);
                             break;
@@ -3495,8 +3497,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx)
             video_enc->gop_size = 0;
         if (video_qscale || same_quality) {
             video_enc->flags |= CODEC_FLAG_QSCALE;
-            video_enc->global_quality=
-                st->quality = FF_QP2LAMBDA * video_qscale;
+            video_enc->global_quality = FF_QP2LAMBDA * video_qscale;
         }
 
         if(intra_matrix)
@@ -3614,7 +3615,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx)
 
         if (audio_qscale > QSCALE_NONE) {
             audio_enc->flags |= CODEC_FLAG_QSCALE;
-            audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
+            audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale;
         }
         if (audio_channels)
             audio_enc->channels = audio_channels;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 12490c1..9011099 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -523,12 +523,14 @@ typedef struct AVStream {
     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.
 
+#if FF_API_AVSTREAM_QUALITY
     //FIXME move stuff to a flags field?
     /**
      * Quality, as it has been removed from AVCodecContext and put in AVVideoFrame.
      * MN: dunno if that is the right place for it
      */
-    float quality;
+    attribute_deprecated float quality;
+#endif
 
     /**
      * Decoding: pts of the first frame of the stream, in stream time base.
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 91ab2e4..ed93270 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -301,7 +301,6 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
         codec->codec_id = avio_rb32(pb);
         codec->codec_type = avio_r8(pb); /* codec_type */
         codec->bit_rate = avio_rb32(pb);
-        st->quality = avio_rb32(pb);
         codec->flags = avio_rb32(pb);
         codec->flags2 = avio_rb32(pb);
         codec->debug = avio_rb32(pb);
diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
index 9a3eb40..a31ac8e 100644
--- a/libavformat/ffmenc.c
+++ b/libavformat/ffmenc.c
@@ -114,7 +114,6 @@ static int ffm_write_header(AVFormatContext *s)
         avio_wb32(pb, codec->codec_id);
         avio_w8(pb, codec->codec_type);
         avio_wb32(pb, codec->bit_rate);
-        avio_wb32(pb, st->quality);
         avio_wb32(pb, codec->flags);
         avio_wb32(pb, codec->flags2);
         avio_wb32(pb, codec->debug);
diff --git a/libavformat/version.h b/libavformat/version.h
index 3cc1718..0cf383f 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -74,5 +74,8 @@
 #ifndef FF_API_FLAG_RTP_HINT
 #define FF_API_FLAG_RTP_HINT           (LIBAVFORMAT_VERSION_MAJOR < 54)
 #endif
+#ifndef FF_API_AVSTREAM_QUALITY
+#define FF_API_AVSTREAM_QUALITY        (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
 
 #endif /* AVFORMAT_VERSION_H */
diff --git a/tests/ref/lavf/ffm b/tests/ref/lavf/ffm
index b89af6e..b20e132 100644
--- a/tests/ref/lavf/ffm
+++ b/tests/ref/lavf/ffm
@@ -1,3 +1,3 @@
-b6acf782a38d313153b68c4ca204fc90 *./tests/data/lavf/lavf.ffm
+f9bee27ea1b6b83a06b5f9efb0a4ac1f *./tests/data/lavf/lavf.ffm
 376832 ./tests/data/lavf/lavf.ffm
 ./tests/data/lavf/lavf.ffm CRC=0xf361ed74



More information about the ffmpeg-cvslog mailing list