In most places where it's used, it's as a pointless write-only field.

Only rv10 decoder actually reads from it, but it stores some internal
version info in it. There is no reason for it to be in a public field.
---
 libavcodec/avcodec.h            |   11 ++++-------
 libavcodec/mpeg12.c             |    4 ----
 libavcodec/mpegaudiodec.c       |    2 --
 libavcodec/mpegaudiodecheader.c |    1 -
 libavcodec/mpegvideo.h          |    2 ++
 libavcodec/mpegvideo_parser.c   |    2 --
 libavcodec/options.c            |    2 ++
 libavcodec/pthread.c            |    1 -
 libavcodec/rv10.c               |   18 +++++++++---------
 libavcodec/version.h            |    3 +++
 10 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5677c0b..0b77b95 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1209,15 +1209,12 @@ typedef struct AVCodecContext {
      */
     unsigned int stream_codec_tag;
 
+#if FF_API_SUB_ID
     /**
-     * Some codecs need additional format info. It is stored here.
-     * If any muxer uses this then ALL demuxers/parsers AND encoders for the
-     * specific codec MUST set it correctly otherwise stream copy breaks.
-     * In general use of this field by muxers is not recommended.
-     * - encoding: Set by libavcodec.
-     * - decoding: Set by libavcodec. (FIXME: Is this OK?)
+     * @deprecated this field is unused
      */
-    int sub_id;
+    attribute_deprecated int sub_id;
+#endif
 
     void *priv_data;
 
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 4b526eb..f87e617 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1237,7 +1237,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
          * that behave like P-frames. */
         avctx->has_b_frames = !s->low_delay;
 
-        assert((avctx->sub_id == 1) == (avctx->codec_id == 
CODEC_ID_MPEG1VIDEO));
         if (avctx->codec_id == CODEC_ID_MPEG1VIDEO) {
             //MPEG-1 fps
             avctx->time_base.den = 
avpriv_frame_rate_tab[s->frame_rate_index].num;
@@ -1382,7 +1381,6 @@ static void mpeg_decode_sequence_extension(Mpeg1Context 
*s1)
 
     av_dlog(s->avctx, "sequence extension\n");
     s->codec_id      = s->avctx->codec_id = CODEC_ID_MPEG2VIDEO;
-    s->avctx->sub_id = 2; /* indicates MPEG-2 found */
 
     if (s->avctx->debug & FF_DEBUG_PICT_INFO)
         av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d vbv buffer: %d, 
bitrate:%d\n",
@@ -2000,7 +1998,6 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
     s->frame_pred_frame_dct = 1;
     s->chroma_format        = 1;
     s->codec_id             = s->avctx->codec_id = CODEC_ID_MPEG1VIDEO;
-    avctx->sub_id           = 1; /* indicates MPEG-1 */
     s->out_format           = FMT_MPEG1;
     s->swap_uv              = 0; // AFAIK VCR2 does not have SEQ_HEADER
     if (s->flags & CODEC_FLAG_LOW_DELAY)
@@ -2060,7 +2057,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
     s->frame_pred_frame_dct  = 1;
     s->chroma_format         = 1;
     s->codec_id              = s->avctx->codec_id = CODEC_ID_MPEG2VIDEO;
-    avctx->sub_id            = 2; /* indicates MPEG-2 */
     s1->save_width           = s->width;
     s1->save_height          = s->height;
     s1->save_progressive_seq = s->progressive_sequence;
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index d82432c..c00c15f 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -1653,7 +1653,6 @@ static int decode_frame(AVCodecContext * avctx, void 
*data, int *got_frame_ptr,
     avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : 
AV_CH_LAYOUT_STEREO;
     if (!avctx->bit_rate)
         avctx->bit_rate = s->bit_rate;
-    avctx->sub_id = s->layer;
 
     if (s->frame_size <= 0 || s->frame_size > buf_size) {
         av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
@@ -1726,7 +1725,6 @@ static int decode_frame_adu(AVCodecContext *avctx, void 
*data,
     avctx->channels    = s->nb_channels;
     if (!avctx->bit_rate)
         avctx->bit_rate = s->bit_rate;
-    avctx->sub_id = s->layer;
 
     s->frame_size = len;
 
diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c
index dbd67ff..428137d 100644
--- a/libavcodec/mpegaudiodecheader.c
+++ b/libavcodec/mpegaudiodecheader.c
@@ -142,6 +142,5 @@ int avpriv_mpa_decode_header(AVCodecContext *avctx, 
uint32_t head, int *sample_r
     *sample_rate = s->sample_rate;
     *channels = s->nb_channels;
     *bit_rate = s->bit_rate;
-    avctx->sub_id = s->layer;
     return s->frame_size;
 }
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 4ec4190..3521a12 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -691,6 +691,8 @@ typedef struct MpegEncContext {
     void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block);
 
     int mpv_flags;      ///< flags set by private options
+
+    int rv10_id;        ///< a version identifier used by the rv10 decoder
 } MpegEncContext;
 
 #define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
index f0b3b20..af4b6e4 100644
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -69,7 +69,6 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
                 pc->frame_rate.num = avctx->time_base.num = 
avpriv_frame_rate_tab[frame_rate_index].den;
                 avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | 
(buf[6]>>6))*400;
                 avctx->codec_id = CODEC_ID_MPEG1VIDEO;
-                avctx->sub_id = 1;
             }
             break;
         case EXT_START_CODE:
@@ -94,7 +93,6 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
                         avctx->time_base.den = pc->frame_rate.den * 
(frame_rate_ext_n + 1) * 2;
                         avctx->time_base.num = pc->frame_rate.num * 
(frame_rate_ext_d + 1);
                         avctx->codec_id = CODEC_ID_MPEG2VIDEO;
-                        avctx->sub_id = 2; /* forces MPEG2 */
                     }
                     break;
                 case 0x8: /* picture coding extension */
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 6b5b148..3567c3d 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -109,7 +109,9 @@ static const AVOption options[]={
 #endif
 {"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.dbl = 
CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"},
 {"local_header", "place global headers at every keyframe instead of in 
extradata", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, 
INT_MAX, V|E, "flags2"},
+#if FF_API_SUB_ID
 {"sub_id", NULL, OFFSET(sub_id), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, 
INT_MAX},
+#endif
 {"me_method", "set motion estimation method", OFFSET(me_method), 
AV_OPT_TYPE_INT, {.dbl = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"},
 {"zero", "zero motion estimation (fastest)", 0, AV_OPT_TYPE_CONST, {.dbl = 
ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" },
 {"full", "full motion estimation (slowest)", 0, AV_OPT_TYPE_CONST, {.dbl = 
ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" },
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index f17f34e..4a02823 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -402,7 +402,6 @@ static int update_context_from_thread(AVCodecContext *dst, 
AVCodecContext *src,
     int err = 0;
 
     if (dst != src) {
-        dst->sub_id    = src->sub_id;
         dst->time_base = src->time_base;
         dst->width     = src->width;
         dst->height    = src->height;
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 75d529f..9d096da 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -325,10 +325,10 @@ static int rv20_decode_picture_header(MpegEncContext *s)
         return -1;
     }
 
-    if(RV_GET_MINOR_VER(s->avctx->sub_id) >= 2)
+    if(RV_GET_MINOR_VER(s->rv10_id) >= 2)
         s->loop_filter = get_bits1(&s->gb);
 
-    if(RV_GET_MINOR_VER(s->avctx->sub_id) <= 1)
+    if(RV_GET_MINOR_VER(s->rv10_id) <= 1)
         seq = get_bits(&s->gb, 8) << 7;
     else
         seq = get_bits(&s->gb, 13) << 2;
@@ -393,7 +393,7 @@ static int rv20_decode_picture_header(MpegEncContext *s)
 av_log(s->avctx, AV_LOG_DEBUG, "\n");*/
     s->no_rounding= get_bits1(&s->gb);
 
-    if(RV_GET_MINOR_VER(s->avctx->sub_id) <= 1 && s->pict_type == 
AV_PICTURE_TYPE_B)
+    if(RV_GET_MINOR_VER(s->rv10_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)
         skip_bits(&s->gb, 5); // binary decoder reads 3+2 bits here but they 
don't seem to be used
 
     s->f_code = 1;
@@ -438,11 +438,11 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
     s->orig_height= s->height = avctx->coded_height;
 
     s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1;
-    avctx->sub_id= AV_RB32((uint8_t*)avctx->extradata + 4);
+    s->rv10_id = AV_RB32((uint8_t*)avctx->extradata + 4);
 
-    major_ver = RV_GET_MAJOR_VER(avctx->sub_id);
-    minor_ver = RV_GET_MINOR_VER(avctx->sub_id);
-    micro_ver = RV_GET_MICRO_VER(avctx->sub_id);
+    major_ver = RV_GET_MAJOR_VER(s->rv10_id);
+    minor_ver = RV_GET_MINOR_VER(s->rv10_id);
+    micro_ver = RV_GET_MICRO_VER(s->rv10_id);
 
     s->low_delay = 1;
     switch (major_ver) {
@@ -457,13 +457,13 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
         }
         break;
     default:
-        av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", avctx->sub_id);
+        av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", s->rv10_id);
         av_log_missing_feature(avctx, "RV1/2 version", 1);
         return AVERROR_PATCHWELCOME;
     }
 
     if(avctx->debug & FF_DEBUG_PICT_INFO){
-        av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", avctx->sub_id, 
avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
+        av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", s->rv10_id, 
avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
     }
 
     avctx->pix_fmt = PIX_FMT_YUV420P;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index ffce895..386f287 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -53,5 +53,8 @@
 #ifndef FF_API_MPV_GLOBAL_OPTS
 #define FF_API_MPV_GLOBAL_OPTS  (LIBAVCODEC_VERSION_MAJOR < 55)
 #endif
+#ifndef FF_API_SUB_ID
+#define FF_API_SUB_ID           (LIBAVCODEC_VERSION_MAJOR < 55)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
-- 
1.7.9

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

Reply via email to