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.
... | ... |
@@ -1228,15 +1228,12 @@ typedef struct AVCodecContext { |
1228 | 1228 |
*/ |
1229 | 1229 |
unsigned int stream_codec_tag; |
1230 | 1230 |
|
1231 |
+#if FF_API_SUB_ID |
|
1231 | 1232 |
/** |
1232 |
- * Some codecs need additional format info. It is stored here. |
|
1233 |
- * If any muxer uses this then ALL demuxers/parsers AND encoders for the |
|
1234 |
- * specific codec MUST set it correctly otherwise stream copy breaks. |
|
1235 |
- * In general use of this field by muxers is not recommended. |
|
1236 |
- * - encoding: Set by libavcodec. |
|
1237 |
- * - decoding: Set by libavcodec. (FIXME: Is this OK?) |
|
1233 |
+ * @deprecated this field is unused |
|
1238 | 1234 |
*/ |
1239 |
- int sub_id; |
|
1235 |
+ attribute_deprecated int sub_id; |
|
1236 |
+#endif |
|
1240 | 1237 |
|
1241 | 1238 |
void *priv_data; |
1242 | 1239 |
|
... | ... |
@@ -1237,7 +1237,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) |
1237 | 1237 |
* that behave like P-frames. */ |
1238 | 1238 |
avctx->has_b_frames = !s->low_delay; |
1239 | 1239 |
|
1240 |
- assert((avctx->sub_id == 1) == (avctx->codec_id == CODEC_ID_MPEG1VIDEO)); |
|
1241 | 1240 |
if (avctx->codec_id == CODEC_ID_MPEG1VIDEO) { |
1242 | 1241 |
//MPEG-1 fps |
1243 | 1242 |
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) |
1382 | 1382 |
|
1383 | 1383 |
av_dlog(s->avctx, "sequence extension\n"); |
1384 | 1384 |
s->codec_id = s->avctx->codec_id = CODEC_ID_MPEG2VIDEO; |
1385 |
- s->avctx->sub_id = 2; /* indicates MPEG-2 found */ |
|
1386 | 1385 |
|
1387 | 1386 |
if (s->avctx->debug & FF_DEBUG_PICT_INFO) |
1388 | 1387 |
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, |
2000 | 2000 |
s->frame_pred_frame_dct = 1; |
2001 | 2001 |
s->chroma_format = 1; |
2002 | 2002 |
s->codec_id = s->avctx->codec_id = CODEC_ID_MPEG1VIDEO; |
2003 |
- avctx->sub_id = 1; /* indicates MPEG-1 */ |
|
2004 | 2003 |
s->out_format = FMT_MPEG1; |
2005 | 2004 |
s->swap_uv = 0; // AFAIK VCR2 does not have SEQ_HEADER |
2006 | 2005 |
if (s->flags & CODEC_FLAG_LOW_DELAY) |
... | ... |
@@ -2060,7 +2057,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx) |
2060 | 2060 |
s->frame_pred_frame_dct = 1; |
2061 | 2061 |
s->chroma_format = 1; |
2062 | 2062 |
s->codec_id = s->avctx->codec_id = CODEC_ID_MPEG2VIDEO; |
2063 |
- avctx->sub_id = 2; /* indicates MPEG-2 */ |
|
2064 | 2063 |
s1->save_width = s->width; |
2065 | 2064 |
s1->save_height = s->height; |
2066 | 2065 |
s1->save_progressive_seq = s->progressive_sequence; |
... | ... |
@@ -1660,7 +1660,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, |
1660 | 1660 |
avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; |
1661 | 1661 |
if (!avctx->bit_rate) |
1662 | 1662 |
avctx->bit_rate = s->bit_rate; |
1663 |
- avctx->sub_id = s->layer; |
|
1664 | 1663 |
|
1665 | 1664 |
if (s->frame_size <= 0 || s->frame_size > buf_size) { |
1666 | 1665 |
av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); |
... | ... |
@@ -1733,7 +1732,6 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, |
1733 | 1733 |
avctx->channels = s->nb_channels; |
1734 | 1734 |
if (!avctx->bit_rate) |
1735 | 1735 |
avctx->bit_rate = s->bit_rate; |
1736 |
- avctx->sub_id = s->layer; |
|
1737 | 1736 |
|
1738 | 1737 |
s->frame_size = len; |
1739 | 1738 |
|
... | ... |
@@ -69,7 +69,6 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, |
69 | 69 |
pc->frame_rate.num = avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_index].den; |
70 | 70 |
avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; |
71 | 71 |
avctx->codec_id = CODEC_ID_MPEG1VIDEO; |
72 |
- avctx->sub_id = 1; |
|
73 | 72 |
} |
74 | 73 |
break; |
75 | 74 |
case EXT_START_CODE: |
... | ... |
@@ -94,7 +93,6 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, |
94 | 94 |
avctx->time_base.den = pc->frame_rate.den * (frame_rate_ext_n + 1) * 2; |
95 | 95 |
avctx->time_base.num = pc->frame_rate.num * (frame_rate_ext_d + 1); |
96 | 96 |
avctx->codec_id = CODEC_ID_MPEG2VIDEO; |
97 |
- avctx->sub_id = 2; /* forces MPEG2 */ |
|
98 | 97 |
} |
99 | 98 |
break; |
100 | 99 |
case 0x8: /* picture coding extension */ |
... | ... |
@@ -109,7 +109,9 @@ static const AVOption options[]={ |
109 | 109 |
#endif |
110 | 110 |
{"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"}, |
111 | 111 |
{"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"}, |
112 |
+#if FF_API_SUB_ID |
|
112 | 113 |
{"sub_id", NULL, OFFSET(sub_id), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, |
114 |
+#endif |
|
113 | 115 |
{"me_method", "set motion estimation method", OFFSET(me_method), AV_OPT_TYPE_INT, {.dbl = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"}, |
114 | 116 |
{"zero", "zero motion estimation (fastest)", 0, AV_OPT_TYPE_CONST, {.dbl = ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" }, |
115 | 117 |
{"full", "full motion estimation (slowest)", 0, AV_OPT_TYPE_CONST, {.dbl = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" }, |
... | ... |
@@ -402,7 +402,6 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, |
402 | 402 |
int err = 0; |
403 | 403 |
|
404 | 404 |
if (dst != src) { |
405 |
- dst->sub_id = src->sub_id; |
|
406 | 405 |
dst->time_base = src->time_base; |
407 | 406 |
dst->width = src->width; |
408 | 407 |
dst->height = src->height; |
... | ... |
@@ -40,6 +40,11 @@ |
40 | 40 |
|
41 | 41 |
#define DC_VLC_BITS 14 //FIXME find a better solution |
42 | 42 |
|
43 |
+typedef struct RVDecContext { |
|
44 |
+ MpegEncContext m; |
|
45 |
+ int sub_id; |
|
46 |
+} RVDecContext; |
|
47 |
+ |
|
43 | 48 |
static const uint16_t rv_lum_code[256] = |
44 | 49 |
{ |
45 | 50 |
0x3e7f, 0x0f00, 0x0f01, 0x0f02, 0x0f03, 0x0f04, 0x0f05, 0x0f06, |
... | ... |
@@ -293,8 +298,9 @@ static int rv10_decode_picture_header(MpegEncContext *s) |
293 | 293 |
return mb_count; |
294 | 294 |
} |
295 | 295 |
|
296 |
-static int rv20_decode_picture_header(MpegEncContext *s) |
|
296 |
+static int rv20_decode_picture_header(RVDecContext *rv) |
|
297 | 297 |
{ |
298 |
+ MpegEncContext *s = &rv->m; |
|
298 | 299 |
int seq, mb_pos, i; |
299 | 300 |
int rpr_bits; |
300 | 301 |
|
... | ... |
@@ -325,10 +331,10 @@ static int rv20_decode_picture_header(MpegEncContext *s) |
325 | 325 |
return -1; |
326 | 326 |
} |
327 | 327 |
|
328 |
- if(RV_GET_MINOR_VER(s->avctx->sub_id) >= 2) |
|
328 |
+ if(RV_GET_MINOR_VER(rv->sub_id) >= 2) |
|
329 | 329 |
s->loop_filter = get_bits1(&s->gb); |
330 | 330 |
|
331 |
- if(RV_GET_MINOR_VER(s->avctx->sub_id) <= 1) |
|
331 |
+ if(RV_GET_MINOR_VER(rv->sub_id) <= 1) |
|
332 | 332 |
seq = get_bits(&s->gb, 8) << 7; |
333 | 333 |
else |
334 | 334 |
seq = get_bits(&s->gb, 13) << 2; |
... | ... |
@@ -393,7 +399,7 @@ static int rv20_decode_picture_header(MpegEncContext *s) |
393 | 393 |
av_log(s->avctx, AV_LOG_DEBUG, "\n");*/ |
394 | 394 |
s->no_rounding= get_bits1(&s->gb); |
395 | 395 |
|
396 |
- if(RV_GET_MINOR_VER(s->avctx->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B) |
|
396 |
+ if(RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B) |
|
397 | 397 |
skip_bits(&s->gb, 5); // binary decoder reads 3+2 bits here but they don't seem to be used |
398 | 398 |
|
399 | 399 |
s->f_code = 1; |
... | ... |
@@ -418,7 +424,8 @@ av_log(s->avctx, AV_LOG_DEBUG, "\n");*/ |
418 | 418 |
|
419 | 419 |
static av_cold int rv10_decode_init(AVCodecContext *avctx) |
420 | 420 |
{ |
421 |
- MpegEncContext *s = avctx->priv_data; |
|
421 |
+ RVDecContext *rv = avctx->priv_data; |
|
422 |
+ MpegEncContext *s = &rv->m; |
|
422 | 423 |
static int done=0; |
423 | 424 |
int major_ver, minor_ver, micro_ver; |
424 | 425 |
|
... | ... |
@@ -438,11 +445,11 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) |
438 | 438 |
s->orig_height= s->height = avctx->coded_height; |
439 | 439 |
|
440 | 440 |
s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1; |
441 |
- avctx->sub_id= AV_RB32((uint8_t*)avctx->extradata + 4); |
|
441 |
+ rv->sub_id = AV_RB32((uint8_t*)avctx->extradata + 4); |
|
442 | 442 |
|
443 |
- major_ver = RV_GET_MAJOR_VER(avctx->sub_id); |
|
444 |
- minor_ver = RV_GET_MINOR_VER(avctx->sub_id); |
|
445 |
- micro_ver = RV_GET_MICRO_VER(avctx->sub_id); |
|
443 |
+ major_ver = RV_GET_MAJOR_VER(rv->sub_id); |
|
444 |
+ minor_ver = RV_GET_MINOR_VER(rv->sub_id); |
|
445 |
+ micro_ver = RV_GET_MICRO_VER(rv->sub_id); |
|
446 | 446 |
|
447 | 447 |
s->low_delay = 1; |
448 | 448 |
switch (major_ver) { |
... | ... |
@@ -457,13 +464,13 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) |
457 | 457 |
} |
458 | 458 |
break; |
459 | 459 |
default: |
460 |
- av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", avctx->sub_id); |
|
460 |
+ av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", rv->sub_id); |
|
461 | 461 |
av_log_missing_feature(avctx, "RV1/2 version", 1); |
462 | 462 |
return AVERROR_PATCHWELCOME; |
463 | 463 |
} |
464 | 464 |
|
465 | 465 |
if(avctx->debug & FF_DEBUG_PICT_INFO){ |
466 |
- av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", avctx->sub_id, avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1); |
|
466 |
+ av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id, avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1); |
|
467 | 467 |
} |
468 | 468 |
|
469 | 469 |
avctx->pix_fmt = PIX_FMT_YUV420P; |
... | ... |
@@ -498,7 +505,8 @@ static av_cold int rv10_decode_end(AVCodecContext *avctx) |
498 | 498 |
static int rv10_decode_packet(AVCodecContext *avctx, |
499 | 499 |
const uint8_t *buf, int buf_size, int buf_size2) |
500 | 500 |
{ |
501 |
- MpegEncContext *s = avctx->priv_data; |
|
501 |
+ RVDecContext *rv = avctx->priv_data; |
|
502 |
+ MpegEncContext *s = &rv->m; |
|
502 | 503 |
int mb_count, mb_pos, left, start_mb_x, active_bits_size; |
503 | 504 |
|
504 | 505 |
active_bits_size = buf_size * 8; |
... | ... |
@@ -506,7 +514,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, |
506 | 506 |
if(s->codec_id ==CODEC_ID_RV10) |
507 | 507 |
mb_count = rv10_decode_picture_header(s); |
508 | 508 |
else |
509 |
- mb_count = rv20_decode_picture_header(s); |
|
509 |
+ mb_count = rv20_decode_picture_header(rv); |
|
510 | 510 |
if (mb_count < 0) { |
511 | 511 |
av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n"); |
512 | 512 |
return -1; |
... | ... |
@@ -714,7 +722,7 @@ AVCodec ff_rv10_decoder = { |
714 | 714 |
.name = "rv10", |
715 | 715 |
.type = AVMEDIA_TYPE_VIDEO, |
716 | 716 |
.id = CODEC_ID_RV10, |
717 |
- .priv_data_size = sizeof(MpegEncContext), |
|
717 |
+ .priv_data_size = sizeof(RVDecContext), |
|
718 | 718 |
.init = rv10_decode_init, |
719 | 719 |
.close = rv10_decode_end, |
720 | 720 |
.decode = rv10_decode_frame, |
... | ... |
@@ -728,7 +736,7 @@ AVCodec ff_rv20_decoder = { |
728 | 728 |
.name = "rv20", |
729 | 729 |
.type = AVMEDIA_TYPE_VIDEO, |
730 | 730 |
.id = CODEC_ID_RV20, |
731 |
- .priv_data_size = sizeof(MpegEncContext), |
|
731 |
+ .priv_data_size = sizeof(RVDecContext), |
|
732 | 732 |
.init = rv10_decode_init, |
733 | 733 |
.close = rv10_decode_end, |
734 | 734 |
.decode = rv10_decode_frame, |