History

avcodec/h263dec: Stop using MpegEncContext.gb

Add a GetBitContext to H263DecContext instead. This is in preparation for removing MpegEncContext.gb. Also move last_resync_gb to H263DecContext.

Andreas Rheinhardt committed 1 year ago

Commit 8a4accc1 parent 77add2613 files · +588 −583Browse files

Unified · Split

13 files
  1. libavcodec/flvdec.c +12 −12
  2. libavcodec/h263dec.c +26 −26
  3. libavcodec/h263dec.h +5 −0
  4. libavcodec/intelh263dec.c +32 −32
  5. libavcodec/ituh263dec.c +170 −169
  6. libavcodec/mpeg12dec.c +5 −5
  7. libavcodec/mpeg4videodec.c +160 −160
  8. libavcodec/mpegvideo.h +0 −1
  9. libavcodec/mpegvideodec.h +3 −3
  10. libavcodec/msmpeg4dec.c +94 −94
  11. libavcodec/rv10.c +31 −31
  12. libavcodec/vaapi_mpeg4.c +4 −4
  13. libavcodec/wmv2dec.c +46 −46
libavcodec/flvdec.c+12−12
@@ -31,26 +31,26 @@ int ff_flv_decode_picture_header(H263DecContext *const h) · 30 unmodified lines
3131 int format, width, height;
3232
3333 /* picture header */
34− if (get_bits(&h->c.gb, 17) != 1) {
34+ if (get_bits(&h->gb, 17) != 1) {
3535 av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture start code\n");
3636 return AVERROR_INVALIDDATA;
3737 }
38− format = get_bits(&h->c.gb, 5);
38+ format = get_bits(&h->gb, 5);
3939 if (format != 0 && format != 1) {
4040 av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture format\n");
4141 return AVERROR_INVALIDDATA;
4242 }
4343 h->c.h263_flv = format + 1;
44− h->c.picture_number = get_bits(&h->c.gb, 8); /* picture timestamp */
45− format = get_bits(&h->c.gb, 3);
44+ h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
45+ format = get_bits(&h->gb, 3);
4646 switch (format) {
4747 case 0:
48− width = get_bits(&h->c.gb, 8);
49− height = get_bits(&h->c.gb, 8);
48+ width = get_bits(&h->gb, 8);
49+ height = get_bits(&h->gb, 8);
5050 break;
5151 case 1:
52− width = get_bits(&h->c.gb, 16);
53− height = get_bits(&h->c.gb, 16);
52+ width = get_bits(&h->gb, 16);
53+ height = get_bits(&h->gb, 16);
5454 break;
5555 case 2:
5656 width = 352;
@@ -81,18 +81,18 @@ int ff_flv_decode_picture_header(H263DecContext *const h) · 24 unmodified lines
8181 h->c.width = width;
8282 h->c.height = height;
8383
84− h->c.pict_type = AV_PICTURE_TYPE_I + get_bits(&h->c.gb, 2);
84+ h->c.pict_type = AV_PICTURE_TYPE_I + get_bits(&h->gb, 2);
8585 h->c.droppable = h->c.pict_type > AV_PICTURE_TYPE_P;
8686 if (h->c.droppable)
8787 h->c.pict_type = AV_PICTURE_TYPE_P;
8888
89− skip_bits1(&h->c.gb); /* deblocking flag */
90− h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
89+ skip_bits1(&h->gb); /* deblocking flag */
90+ h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
9191
9292 h->c.h263_long_vectors = 0;
9393
9494 /* PEI */
95− if (skip_1stop_8data_bits(&h->c.gb) < 0)
95+ if (skip_1stop_8data_bits(&h->gb) < 0)
9696 return AVERROR_INVALIDDATA;
9797
9898 if (h->c.ehc_mode)
libavcodec/h263dec.c+26−26
@@ -187,7 +187,7 @@ static int decode_slice(H263DecContext *const h) · 186 unmodified lines
187187 const int mb_size = 16 >> h->c.avctx->lowres;
188188 int ret;
189189
190− h->c.last_resync_gb = h->c.gb;
190+ h->last_resync_gb = h->gb;
191191 h->c.first_slice_line = 1;
192192 h->c.resync_mb_x = h->c.mb_x;
193193 h->c.resync_mb_y = h->c.mb_y;
@@ -200,8 +200,8 @@ static int decode_slice(H263DecContext *const h) · 6 unmodified lines
200200 }
201201
202202 if (h->c.avctx->hwaccel) {
203− const uint8_t *start = h->c.gb.buffer + get_bits_count(&h->c.gb) / 8;
204− ret = FF_HW_CALL(h->c.avctx, decode_slice, start, h->c.gb.buffer_end - start);
203+ const uint8_t *start = h->gb.buffer + get_bits_count(&h->gb) / 8;
204+ ret = FF_HW_CALL(h->c.avctx, decode_slice, start, h->gb.buffer_end - start);
205205 // ensure we exit decode loop
206206 h->c.mb_y = h->c.mb_height;
207207 return ret;
@@ -253,7 +253,7 @@ static int decode_slice(H263DecContext *const h) · 45 unmodified lines
253253 h->c.mv_dir = MV_DIR_FORWARD;
254254 h->c.mv_type = MV_TYPE_16X16;
255255 ff_dlog(h->c.avctx, "%d %06X\n",
256− get_bits_count(&h->c.gb), show_bits(&h->c.gb, 24));
256+ get_bits_count(&h->gb), show_bits(&h->gb, 24));
257257
258258 ff_tlog(NULL, "Decoding MB at %dx%d\n", h->c.mb_x, h->c.mb_y);
259259 ret = h->decode_mb(h);
@@ -300,7 +300,7 @@ static int decode_slice(H263DecContext *const h) · 40 unmodified lines
300300 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y,
301301 h->c.mb_x, h->c.mb_y, ER_MB_ERROR & part_mask);
302302
303− if ((h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&h->c.gb) > 0)
303+ if ((h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&h->gb) > 0)
304304 continue;
305305 return AVERROR_INVALIDDATA;
306306 }
@@ -321,29 +321,29 @@ static int decode_slice(H263DecContext *const h) · 14 unmodified lines
321321 // Detect incorrect padding with wrong stuffing codes used by NEC N-02B
322322 if (h->c.codec_id == AV_CODEC_ID_MPEG4 &&
323323 (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
324− get_bits_left(&h->c.gb) >= 48 &&
325− show_bits(&h->c.gb, 24) == 0x4010 &&
324+ get_bits_left(&h->gb) >= 48 &&
325+ show_bits(&h->gb, 24) == 0x4010 &&
326326 !h->c.data_partitioning)
327327 h->c.padding_bug_score += 32;
328328
329329 /* try to detect the padding bug */
330330 if (h->c.codec_id == AV_CODEC_ID_MPEG4 &&
331331 (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
332− get_bits_left(&h->c.gb) >= 0 &&
333− get_bits_left(&h->c.gb) < 137 &&
332+ get_bits_left(&h->gb) >= 0 &&
333+ get_bits_left(&h->gb) < 137 &&
334334 !h->c.data_partitioning) {
335− const int bits_count = get_bits_count(&h->c.gb);
336− const int bits_left = h->c.gb.size_in_bits - bits_count;
335+ const int bits_count = get_bits_count(&h->gb);
336+ const int bits_left = h->gb.size_in_bits - bits_count;
337337
338338 if (bits_left == 0) {
339339 h->c.padding_bug_score += 16;
340340 } else if (bits_left != 1) {
341− int v = show_bits(&h->c.gb, 8);
341+ int v = show_bits(&h->gb, 8);
342342 v |= 0x7F >> (7 - (bits_count & 7));
343343
344344 if (v == 0x7F && bits_left <= 8)
345345 h->c.padding_bug_score--;
346− else if (v == 0x7F && ((get_bits_count(&h->c.gb) + 8) & 8) &&
346+ else if (v == 0x7F && ((get_bits_count(&h->gb) + 8) & 8) &&
347347 bits_left <= 16)
348348 h->c.padding_bug_score += 4;
349349 else
@@ -353,10 +353,10 @@ static int decode_slice(H263DecContext *const h) · 3 unmodified lines
353353
354354 if (h->c.codec_id == AV_CODEC_ID_H263 &&
355355 (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
356− get_bits_left(&h->c.gb) >= 8 &&
357− get_bits_left(&h->c.gb) < 300 &&
356+ get_bits_left(&h->gb) >= 8 &&
357+ get_bits_left(&h->gb) < 300 &&
358358 h->c.pict_type == AV_PICTURE_TYPE_I &&
359− show_bits(&h->c.gb, 8) == 0 &&
359+ show_bits(&h->gb, 8) == 0 &&
360360 !h->c.data_partitioning) {
361361
362362 h->c.padding_bug_score += 32;
@@ -364,8 +364,8 @@ static int decode_slice(H263DecContext *const h) · 1 unmodified line
364364
365365 if (h->c.codec_id == AV_CODEC_ID_H263 &&
366366 (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
367− get_bits_left(&h->c.gb) >= 64 &&
368− AV_RB64(h->c.gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) {
367+ get_bits_left(&h->gb) >= 64 &&
368+ AV_RB64(h->gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) {
369369
370370 h->c.padding_bug_score += 32;
371371 }
@@ -380,7 +380,7 @@ static int decode_slice(H263DecContext *const h) · 8 unmodified lines
380380
381381 // handle formats which don't have unique end markers
382382 if (h->c.msmpeg4_version != MSMP4_UNUSED || (h->c.workaround_bugs & FF_BUG_NO_PADDING)) { // FIXME perhaps solve this more cleanly
383− int left = get_bits_left(&h->c.gb);
383+ int left = get_bits_left(&h->gb);
384384 int max_extra = 7;
385385
386386 /* no markers in M$ crap */
@@ -398,7 +398,7 @@ static int decode_slice(H263DecContext *const h) · 11 unmodified lines
398398 if (left > max_extra)
399399 av_log(h->c.avctx, AV_LOG_ERROR,
400400 "discarding %d junk bits at end, next would be %X\n",
401− left, show_bits(&h->c.gb, 24));
401+ left, show_bits(&h->gb, 24));
402402 else if (left < 0)
403403 av_log(h->c.avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
404404 else
@@ -410,7 +410,7 @@ static int decode_slice(H263DecContext *const h) · 5 unmodified lines
410410
411411 av_log(h->c.avctx, AV_LOG_ERROR,
412412 "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
413− get_bits_left(&h->c.gb), show_bits(&h->c.gb, 24), h->c.padding_bug_score);
413+ get_bits_left(&h->gb), show_bits(&h->gb, 24), h->c.padding_bug_score);
414414
415415 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, h->c.mb_x, h->c.mb_y,
416416 ER_MB_END & part_mask);
@@ -452,8 +452,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 35 unmodified lines
452452 return 0;
453453 }
454454
455− // h->c.gb might be overridden in ff_mpeg4_decode_picture_header() below.
456− ret = init_get_bits8(&h->c.gb, buf, buf_size);
455+ // h->gb might be overridden in ff_mpeg4_decode_picture_header() below.
456+ ret = init_get_bits8(&h->gb, buf, buf_size);
457457 if (ret < 0)
458458 return ret;
459459
@@ -504,7 +504,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 44 unmodified lines
504504 avctx->has_b_frames = !h->c.low_delay;
505505
506506 if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
507− if (h->c.pict_type != AV_PICTURE_TYPE_B && h->c.mb_num/2 > get_bits_left(&h->c.gb))
507+ if (h->c.pict_type != AV_PICTURE_TYPE_B && h->c.mb_num/2 > get_bits_left(&h->gb))
508508 return AVERROR_INVALIDDATA;
509509 ff_mpeg4_workaround_bugs(avctx);
510510 if (h->c.studio_profile != (h->c.idsp.idct == NULL))
@@ -554,7 +554,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 43 unmodified lines
554554
555555 if (avctx->hwaccel) {
556556 ret = FF_HW_CALL(avctx, start_frame, NULL,
557− h->c.gb.buffer, h->c.gb.buffer_end - h->c.gb.buffer);
557+ h->gb.buffer, h->gb.buffer_end - h->gb.buffer);
558558 if (ret < 0 )
559559 return ret;
560560 }
@@ -582,7 +582,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 21 unmodified lines
582582 while (h->c.mb_y < h->c.mb_height) {
583583 if (h->c.msmpeg4_version != MSMP4_UNUSED) {
584584 if (h->c.slice_height == 0 || h->c.mb_x != 0 || slice_ret < 0 ||
585− (h->c.mb_y % h->c.slice_height) != 0 || get_bits_left(&h->c.gb) < 0)
585+ (h->c.mb_y % h->c.slice_height) != 0 || get_bits_left(&h->gb) < 0)
586586 break;
587587 } else {
588588 int prev_x = h->c.mb_x, prev_y = h->c.mb_y;
libavcodec/h263dec.h+5−0
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 #ifndef AVCODEC_H263DEC_H
2121 #define AVCODEC_H263DEC_H
2222
23+#include "get_bits.h"
2324 #include "mpegvideo.h"
2425 #include "vlc.h"
2526 #include "libavutil/mem_internal.h"
@@ -47,8 +48,12 @@ extern VLCElem ff_h263_mv_vlc[]; · 21 unmodified lines
4748 typedef struct H263DecContext {
4849 MPVContext c;
4950
51+ GetBitContext gb;
52+
5053 int (*decode_mb)(struct H263DecContext *h);
5154
55+ GetBitContext last_resync_gb; ///< used to search for the next resync marker
56+
5257 DECLARE_ALIGNED_32(int16_t, block)[6][64];
5358 } H263DecContext;
5459
libavcodec/intelh263dec.c+32−32
@@ -30,44 +30,44 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h) · 29 unmodified lines
3030 {
3131 int format;
3232
33− if (get_bits_left(&h->c.gb) == 64) { /* special dummy frames */
33+ if (get_bits_left(&h->gb) == 64) { /* special dummy frames */
3434 return FRAME_SKIPPED;
3535 }
3636
3737 /* picture header */
38− if (get_bits(&h->c.gb, 22) != 0x20) {
38+ if (get_bits(&h->gb, 22) != 0x20) {
3939 av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture start code\n");
4040 return -1;
4141 }
42− h->c.picture_number = get_bits(&h->c.gb, 8); /* picture timestamp */
42+ h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
4343
44− if (check_marker(h->c.avctx, &h->c.gb, "after picture_number") != 1) {
44+ if (check_marker(h->c.avctx, &h->gb, "after picture_number") != 1) {
4545 return -1; /* marker */
4646 }
47− if (get_bits1(&h->c.gb) != 0) {
47+ if (get_bits1(&h->gb) != 0) {
4848 av_log(h->c.avctx, AV_LOG_ERROR, "Bad H.263 id\n");
4949 return -1; /* H.263 id */
5050 }
51− skip_bits1(&h->c.gb); /* split screen off */
52− skip_bits1(&h->c.gb); /* camera off */
53− skip_bits1(&h->c.gb); /* freeze picture release off */
51+ skip_bits1(&h->gb); /* split screen off */
52+ skip_bits1(&h->gb); /* camera off */
53+ skip_bits1(&h->gb); /* freeze picture release off */
5454
55− format = get_bits(&h->c.gb, 3);
55+ format = get_bits(&h->gb, 3);
5656 if (format == 0 || format == 6) {
5757 av_log(h->c.avctx, AV_LOG_ERROR, "Intel H.263 free format not supported\n");
5858 return -1;
5959 }
6060
61− h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->c.gb);
61+ h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->gb);
6262
63− h->c.h263_long_vectors = get_bits1(&h->c.gb);
63+ h->c.h263_long_vectors = get_bits1(&h->gb);
6464
65− if (get_bits1(&h->c.gb) != 0) {
65+ if (get_bits1(&h->gb) != 0) {
6666 av_log(h->c.avctx, AV_LOG_ERROR, "SAC not supported\n");
6767 return -1; /* SAC: off */
6868 }
69− h->c.obmc = get_bits1(&h->c.gb);
70− h->c.pb_frame = get_bits1(&h->c.gb);
69+ h->c.obmc = get_bits1(&h->gb);
70+ h->c.pb_frame = get_bits1(&h->gb);
7171
7272 if (format < 6) {
7373 h->c.width = ff_h263_format[format][0];
@@ -75,31 +75,31 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h) · 1 unmodified line
7575 h->c.avctx->sample_aspect_ratio.num = 12;
7676 h->c.avctx->sample_aspect_ratio.den = 11;
7777 } else {
78− format = get_bits(&h->c.gb, 3);
78+ format = get_bits(&h->gb, 3);
7979 if(format == 0 || format == 7){
8080 av_log(h->c.avctx, AV_LOG_ERROR, "Wrong Intel H.263 format\n");
8181 return -1;
8282 }
83− if (get_bits(&h->c.gb, 2))
83+ if (get_bits(&h->gb, 2))
8484 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
85− h->c.loop_filter = get_bits1(&h->c.gb) * !h->c.avctx->lowres;
86− if (get_bits1(&h->c.gb))
85+ h->c.loop_filter = get_bits1(&h->gb) * !h->c.avctx->lowres;
86+ if (get_bits1(&h->gb))
8787 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
88− if (get_bits1(&h->c.gb))
88+ if (get_bits1(&h->gb))
8989 h->c.pb_frame = 2;
90− if (get_bits(&h->c.gb, 5))
90+ if (get_bits(&h->gb, 5))
9191 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
92− if (get_bits(&h->c.gb, 5) != 1)
92+ if (get_bits(&h->gb, 5) != 1)
9393 av_log(h->c.avctx, AV_LOG_ERROR, "Invalid marker\n");
9494 }
9595 if(format == 6){
96− int ar = get_bits(&h->c.gb, 4);
97− skip_bits(&h->c.gb, 9); // display width
98− check_marker(h->c.avctx, &h->c.gb, "in dimensions");
99− skip_bits(&h->c.gb, 9); // display height
96+ int ar = get_bits(&h->gb, 4);
97+ skip_bits(&h->gb, 9); // display width
98+ check_marker(h->c.avctx, &h->gb, "in dimensions");
99+ skip_bits(&h->gb, 9); // display height
100100 if (ar == 15) {
101− h->c.avctx->sample_aspect_ratio.num = get_bits(&h->c.gb, 8); // aspect ratio - width
102− h->c.avctx->sample_aspect_ratio.den = get_bits(&h->c.gb, 8); // aspect ratio - height
101+ h->c.avctx->sample_aspect_ratio.num = get_bits(&h->gb, 8); // aspect ratio - width
102+ h->c.avctx->sample_aspect_ratio.den = get_bits(&h->gb, 8); // aspect ratio - height
103103 } else {
104104 h->c.avctx->sample_aspect_ratio = ff_h263_pixel_aspect[ar];
105105 }
@@ -107,16 +107,16 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h) · 1 unmodified line
107107 av_log(h->c.avctx, AV_LOG_ERROR, "Invalid aspect ratio.\n");
108108 }
109109
110− h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
111− skip_bits1(&h->c.gb); /* Continuous Presence Multipoint mode: off */
110+ h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
111+ skip_bits1(&h->gb); /* Continuous Presence Multipoint mode: off */
112112
113113 if (h->c.pb_frame) {
114− skip_bits(&h->c.gb, 3); //temporal reference for B-frame
115− skip_bits(&h->c.gb, 2); //dbquant
114+ skip_bits(&h->gb, 3); //temporal reference for B-frame
115+ skip_bits(&h->gb, 2); //dbquant
116116 }
117117
118118 /* PEI */
119− if (skip_1stop_8data_bits(&h->c.gb) < 0)
119+ if (skip_1stop_8data_bits(&h->gb) < 0)
120120 return AVERROR_INVALIDDATA;
121121
122122 h->c.gob_index = H263_GOB_HEIGHT(h->c.height);
libavcodec/ituh263dec.c+170−169
@@ -82,7 +82,7 @@ void ff_h263_show_pict_info(H263DecContext *const h, int h263_plus) · 81 unmodified lines
8282 if (h->c.avctx->debug&FF_DEBUG_PICT_INFO) {
8383 av_log(h->c.avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n",
8484 h->c.qscale, av_get_picture_type_char(h->c.pict_type),
85− h->c.gb.size_in_bits, 1-h->c.no_rounding,
85+ h->gb.size_in_bits, 1-h->c.no_rounding,
8686 h->c.obmc ? " AP" : "",
8787 h->c.umvplus ? " UMV" : "",
8888 h->c.h263_long_vectors ? " LONG" : "",
@@ -146,7 +146,7 @@ int ff_h263_decode_mba(H263DecContext *const h) · 57 unmodified lines
146146 for (i = 0; i < 6; i++)
147147 if (h->c.mb_num - 1 <= ff_mba_max[i])
148148 break;
149− mb_pos = get_bits(&h->c.gb, ff_mba_length[i]);
149+ mb_pos = get_bits(&h->gb, ff_mba_length[i]);
150150 h->c.mb_x = mb_pos % h->c.mb_width;
151151 h->c.mb_y = mb_pos / h->c.mb_width;
152152
@@ -163,41 +163,42 @@ static int h263_decode_gob_header(H263DecContext *const h) · 10 unmodified lines
163163 int left;
164164
165165 /* Check for GOB Start Code */
166− val = show_bits(&h->c.gb, 16);
166+ val = show_bits(&h->gb, 16);
167167 if(val)
168168 return -1;
169169
170170 /* We have a GBSC probably with GSTUFF */
171− skip_bits(&h->c.gb, 16); /* Drop the zeros */
172− left = get_bits_left(&h->c.gb);
171+ skip_bits(&h->gb, 16); /* Drop the zeros */
172+ left = get_bits_left(&h->gb);
173173 left = FFMIN(left, 32);
174174 //MN: we must check the bits left or we might end in an infinite loop (or segfault)
175175 for(;left>13; left--){
176− if (get_bits1(&h->c.gb)) break; /* Seek the '1' bit */
176+ if (get_bits1(&h->gb))
177+ break; /* Seek the '1' bit */
177178 }
178179 if(left<=13)
179180 return -1;
180181
181182 if (h->c.h263_slice_structured) {
182− if (check_marker(h->c.avctx, &h->c.gb, "before MBA")==0)
183+ if (check_marker(h->c.avctx, &h->gb, "before MBA")==0)
183184 return -1;
184185
185186 ff_h263_decode_mba(h);
186187
187188 if (h->c.mb_num > 1583)
188− if (check_marker(h->c.avctx, &h->c.gb, "after MBA")==0)
189+ if (check_marker(h->c.avctx, &h->gb, "after MBA")==0)
189190 return -1;
190191
191− h->c.qscale = get_bits(&h->c.gb, 5); /* SQUANT */
192− if (check_marker(h->c.avctx, &h->c.gb, "after SQUANT")==0)
192+ h->c.qscale = get_bits(&h->gb, 5); /* SQUANT */
193+ if (check_marker(h->c.avctx, &h->gb, "after SQUANT")==0)
193194 return -1;
194− skip_bits(&h->c.gb, 2); /* GFID */
195+ skip_bits(&h->gb, 2); /* GFID */
195196 }else{
196− gob_number = get_bits(&h->c.gb, 5); /* GN */
197+ gob_number = get_bits(&h->gb, 5); /* GN */
197198 h->c.mb_x = 0;
198199 h->c.mb_y = h->c.gob_index* gob_number;
199− skip_bits(&h->c.gb, 2); /* GFID */
200− h->c.qscale = get_bits(&h->c.gb, 5); /* GQUANT */
200+ skip_bits(&h->gb, 2); /* GFID */
201+ h->c.qscale = get_bits(&h->gb, 5); /* GQUANT */
201202 }
202203
203204 if (h->c.mb_y >= h->c.mb_height)
@@ -220,25 +221,25 @@ int ff_h263_resync(H263DecContext *const h) · 16 unmodified lines
220221 /* In MPEG-4 studio mode look for a new slice startcode
221222 * and decode slice header */
222223 if (h->c.codec_id==AV_CODEC_ID_MPEG4 && h->c.studio_profile) {
223− align_get_bits(&h->c.gb);
224+ align_get_bits(&h->gb);
224225
225− while (get_bits_left(&h->c.gb) >= 32 && show_bits_long(&h->c.gb, 32) != SLICE_STARTCODE) {
226− get_bits(&h->c.gb, 8);
226+ while (get_bits_left(&h->gb) >= 32 && show_bits_long(&h->gb, 32) != SLICE_STARTCODE) {
227+ get_bits(&h->gb, 8);
227228 }
228229
229− if (get_bits_left(&h->c.gb) >= 32 && show_bits_long(&h->c.gb, 32) == SLICE_STARTCODE)
230− return get_bits_count(&h->c.gb);
230+ if (get_bits_left(&h->gb) >= 32 && show_bits_long(&h->gb, 32) == SLICE_STARTCODE)
231+ return get_bits_count(&h->gb);
231232 else
232233 return -1;
233234 }
234235
235236 if (h->c.codec_id==AV_CODEC_ID_MPEG4){
236− skip_bits1(&h->c.gb);
237− align_get_bits(&h->c.gb);
237+ skip_bits1(&h->gb);
238+ align_get_bits(&h->gb);
238239 }
239240
240− if (show_bits(&h->c.gb, 16) ==0) {
241− pos = get_bits_count(&h->c.gb);
241+ if (show_bits(&h->gb, 16) ==0) {
242+ pos = get_bits_count(&h->gb);
242243 if(CONFIG_MPEG4_DECODER && h->c.codec_id==AV_CODEC_ID_MPEG4)
243244 ret = ff_mpeg4_decode_video_packet_header(h);
244245 else
@@ -247,15 +248,15 @@ int ff_h263_resync(H263DecContext *const h) · 2 unmodified lines
247248 return pos;
248249 }
249250 //OK, it's not where it is supposed to be ...
250− h->c.gb = h->c.last_resync_gb;
251− align_get_bits(&h->c.gb);
252− left = get_bits_left(&h->c.gb);
251+ h->gb = h->last_resync_gb;
252+ align_get_bits(&h->gb);
253+ left = get_bits_left(&h->gb);
253254
254255 for(;left>16+1+5+5; left-=8){
255− if (show_bits(&h->c.gb, 16) == 0){
256− GetBitContext bak = h->c.gb;
256+ if (show_bits(&h->gb, 16) == 0){
257+ GetBitContext bak = h->gb;
257258
258− pos = get_bits_count(&h->c.gb);
259+ pos = get_bits_count(&h->gb);
259260 if(CONFIG_MPEG4_DECODER && h->c.codec_id==AV_CODEC_ID_MPEG4)
260261 ret = ff_mpeg4_decode_video_packet_header(h);
261262 else
@@ -263,9 +264,9 @@ int ff_h263_resync(H263DecContext *const h) · 1 unmodified line
263264 if(ret>=0)
264265 return pos;
265266
266− h->c.gb = bak;
267+ h->gb = bak;
267268 }
268− skip_bits(&h->c.gb, 8);
269+ skip_bits(&h->gb, 8);
269270 }
270271
271272 return -1;
@@ -274,19 +275,19 @@ int ff_h263_resync(H263DecContext *const h) · 2 unmodified lines
274275 int ff_h263_decode_motion(H263DecContext *const h, int pred, int f_code)
275276 {
276277 int code, val, sign, shift;
277− code = get_vlc2(&h->c.gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
278+ code = get_vlc2(&h->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
278279
279280 if (code == 0)
280281 return pred;
281282 if (code < 0)
282283 return 0xffff;
283284
284− sign = get_bits1(&h->c.gb);
285+ sign = get_bits1(&h->gb);
285286 shift = f_code - 1;
286287 val = code;
287288 if (shift) {
288289 val = (val - 1) << shift;
289− val |= get_bits(&h->c.gb, shift);
290+ val |= get_bits(&h->gb, shift);
290291 val++;
291292 }
292293 if (sign)
@@ -313,15 +314,15 @@ static int h263p_decode_umotion(H263DecContext *const h, int pred) · 20 unmodified lines
313314 {
314315 int code = 0, sign;
315316
316− if (get_bits1(&h->c.gb)) /* Motion difference = 0 */
317+ if (get_bits1(&h->gb)) /* Motion difference = 0 */
317318 return pred;
318319
319− code = 2 + get_bits1(&h->c.gb);
320+ code = 2 + get_bits1(&h->gb);
320321
321− while (get_bits1(&h->c.gb))
322+ while (get_bits1(&h->gb))
322323 {
323324 code <<= 1;
324− code += get_bits1(&h->c.gb);
325+ code += get_bits1(&h->gb);
325326 if (code >= 32768) {
326327 avpriv_request_sample(h->c.avctx, "Huge DMV");
327328 return 0xffff;
@@ -341,7 +342,7 @@ static int h263p_decode_umotion(H263DecContext *const h, int pred) · 13 unmodified lines
341342 */
342343 static void preview_obmc(H263DecContext *const h)
343344 {
344− GetBitContext gb = h->c.gb;
345+ GetBitContext gb = h->gb;
345346
346347 int cbpc, i, pred_x, pred_y, mx, my;
347348 int16_t *mot_val;
@@ -357,7 +358,7 @@ static void preview_obmc(H263DecContext *const h) · 9 unmodified lines
357358 av_assert2(h->c.pict_type == AV_PICTURE_TYPE_P);
358359
359360 do{
360− if (get_bits1(&h->c.gb)) {
361+ if (get_bits1(&h->gb)) {
361362 /* skip mb */
362363 mot_val = h->c.cur_pic.motion_val[0][h->c.block_index[0]];
363364 mot_val[0 ]= mot_val[2 ]=
@@ -368,15 +369,15 @@ static void preview_obmc(H263DecContext *const h) · 4 unmodified lines
368369 h->c.cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
369370 goto end;
370371 }
371− cbpc = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
372+ cbpc = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
372373 }while(cbpc == 20);
373374
374375 if(cbpc & 4){
375376 h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA;
376377 }else{
377− get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
378+ get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
378379 if (cbpc & 8) {
379− skip_bits(&h->c.gb, h->c.modified_quant ? (get_bits1(&h->c.gb) ? 1 : 5) : 2);
380+ skip_bits(&h->gb, h->c.modified_quant ? (get_bits1(&h->gb) ? 1 : 5) : 2);
380381 }
381382
382383 if ((cbpc & 16) == 0) {
@@ -411,7 +412,7 @@ static void preview_obmc(H263DecContext *const h) · 28 unmodified lines
411412 else
412413 my = ff_h263_decode_motion(h, pred_y, 1);
413414 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
414− skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
415+ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
415416 mot_val[0] = mx;
416417 mot_val[1] = my;
417418 }
@@ -425,7 +426,7 @@ end: · 7 unmodified lines
425426 h->c.block_index[i] -= 1;
426427 h->c.mb_x--;
427428
428− h->c.gb = gb;
429+ h->gb = gb;
429430 }
430431
431432 static void h263_decode_dquant(H263DecContext *const h)
@@ -434,12 +435,12 @@ static void h263_decode_dquant(H263DecContext *const h) · 2 unmodified lines
434435 int qscale;
435436
436437 if (h->c.modified_quant) {
437− if (get_bits1(&h->c.gb))
438− qscale = ff_modified_quant_tab[get_bits1(&h->c.gb)][h->c.qscale];
438+ if (get_bits1(&h->gb))
439+ qscale = ff_modified_quant_tab[get_bits1(&h->gb)][h->c.qscale];
439440 else
440− qscale = get_bits(&h->c.gb, 5);
441+ qscale = get_bits(&h->gb, 5);
441442 }else
442− qscale = h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)];
443+ qscale = h->c.qscale + quant_tab[get_bits(&h->gb, 2)];
443444 ff_set_qscale(&h->c, qscale);
444445 }
445446
@@ -527,7 +528,7 @@ static int h263_decode_block(H263DecContext *const h, int16_t block[64], · 81 unmodified lines
527528 int level, i, j, run;
528529 const RLTable *rl = &ff_h263_rl_inter;
529530 const uint8_t *scan_table;
530− GetBitContext gb = h->c.gb;
531+ GetBitContext gb = h->gb;
531532
532533 scan_table = h->c.intra_scantable.permutated;
533534 if (h->c.h263_aic && h->c.mb_intra) {
@@ -558,12 +559,12 @@ static int h263_decode_block(H263DecContext *const h, int16_t block[64], · 24 unmodified lines
558559 h->c.rv10_first_dc_coded[component] = 1;
559560 }
560561 } else {
561− level = get_bits(&h->c.gb, 8);
562+ level = get_bits(&h->gb, 8);
562563 if (level == 255)
563564 level = 128;
564565 }
565566 }else{
566− level = get_bits(&h->c.gb, 8);
567+ level = get_bits(&h->gb, 8);
567568 if((level&0x7F) == 0){
568569 av_log(h->c.avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n",
569570 level, h->c.mb_x, h->c.mb_y);
@@ -584,60 +585,60 @@ static int h263_decode_block(H263DecContext *const h, int16_t block[64], · 14 unmodified lines
584585 }
585586 retry:
586587 {
587− OPEN_READER(re, &h->c.gb);
588+ OPEN_READER(re, &h->gb);
588589 i--; // offset by -1 to allow direct indexing of scan_table
589590 for(;;) {
590− UPDATE_CACHE(re, &h->c.gb);
591− GET_RL_VLC(level, run, re, &h->c.gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
591+ UPDATE_CACHE(re, &h->gb);
592+ GET_RL_VLC(level, run, re, &h->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
592593 if (run == 66) {
593594 if (level){
594− CLOSE_READER(re, &h->c.gb);
595+ CLOSE_READER(re, &h->gb);
595596 av_log(h->c.avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n",
596597 h->c.mb_x, h->c.mb_y);
597598 return -1;
598599 }
599600 /* escape */
600601 if (CONFIG_FLV_DECODER && h->c.h263_flv > 1) {
601− int is11 = SHOW_UBITS(re, &h->c.gb, 1);
602− SKIP_CACHE(re, &h->c.gb, 1);
603− run = SHOW_UBITS(re, &h->c.gb, 7) + 1;
602+ int is11 = SHOW_UBITS(re, &h->gb, 1);
603+ SKIP_CACHE(re, &h->gb, 1);
604+ run = SHOW_UBITS(re, &h->gb, 7) + 1;
604605 if (is11) {
605− SKIP_COUNTER(re, &h->c.gb, 1 + 7);
606− UPDATE_CACHE(re, &h->c.gb);
607− level = SHOW_SBITS(re, &h->c.gb, 11);
608− SKIP_COUNTER(re, &h->c.gb, 11);
606+ SKIP_COUNTER(re, &h->gb, 1 + 7);
607+ UPDATE_CACHE(re, &h->gb);
608+ level = SHOW_SBITS(re, &h->gb, 11);
609+ SKIP_COUNTER(re, &h->gb, 11);
609610 } else {
610− SKIP_CACHE(re, &h->c.gb, 7);
611− level = SHOW_SBITS(re, &h->c.gb, 7);
612− SKIP_COUNTER(re, &h->c.gb, 1 + 7 + 7);
611+ SKIP_CACHE(re, &h->gb, 7);
612+ level = SHOW_SBITS(re, &h->gb, 7);
613+ SKIP_COUNTER(re, &h->gb, 1 + 7 + 7);
613614 }
614615 } else {
615− run = SHOW_UBITS(re, &h->c.gb, 7) + 1;
616− SKIP_CACHE(re, &h->c.gb, 7);
617− level = (int8_t)SHOW_UBITS(re, &h->c.gb, 8);
618− SKIP_COUNTER(re, &h->c.gb, 7 + 8);
616+ run = SHOW_UBITS(re, &h->gb, 7) + 1;
617+ SKIP_CACHE(re, &h->gb, 7);
618+ level = (int8_t)SHOW_UBITS(re, &h->gb, 8);
619+ SKIP_COUNTER(re, &h->gb, 7 + 8);
619620 if(level == -128){
620− UPDATE_CACHE(re, &h->c.gb);
621+ UPDATE_CACHE(re, &h->gb);
621622 if (h->c.codec_id == AV_CODEC_ID_RV10) {
622623 /* XXX: should patch encoder too */
623− level = SHOW_SBITS(re, &h->c.gb, 12);
624− SKIP_COUNTER(re, &h->c.gb, 12);
624+ level = SHOW_SBITS(re, &h->gb, 12);
625+ SKIP_COUNTER(re, &h->gb, 12);
625626 }else{
626− level = SHOW_UBITS(re, &h->c.gb, 5);
627− SKIP_CACHE(re, &h->c.gb, 5);
628− level |= SHOW_SBITS(re, &h->c.gb, 6) * (1<<5);
629− SKIP_COUNTER(re, &h->c.gb, 5 + 6);
627+ level = SHOW_UBITS(re, &h->gb, 5);
628+ SKIP_CACHE(re, &h->gb, 5);
629+ level |= SHOW_SBITS(re, &h->gb, 6) * (1<<5);
630+ SKIP_COUNTER(re, &h->gb, 5 + 6);
630631 }
631632 }
632633 }
633634 } else {
634− if (SHOW_UBITS(re, &h->c.gb, 1))
635+ if (SHOW_UBITS(re, &h->gb, 1))
635636 level = -level;
636− SKIP_COUNTER(re, &h->c.gb, 1);
637+ SKIP_COUNTER(re, &h->gb, 1);
637638 }
638639 i += run;
639640 if (i >= 64){
640− CLOSE_READER(re, &h->c.gb);
641+ CLOSE_READER(re, &h->gb);
641642 // redo update without last flag, revert -1 offset
642643 i = i - run + ((run-1)&63) + 1;
643644 if (i < 64) {
@@ -649,7 +650,7 @@ retry: · 5 unmodified lines
649650 //Looks like a hack but no, it's the way it is supposed to work ...
650651 rl = &ff_rl_intra_aic;
651652 i = 0;
652− h->c.gb = gb;
653+ h->gb = gb;
653654 h->c.bdsp.clear_block(block);
654655 goto retry;
655656 }
@@ -787,7 +788,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 131 unmodified lines
787788
788789 if (h->c.pict_type == AV_PICTURE_TYPE_P) {
789790 do{
790− if (get_bits1(&h->c.gb)) {
791+ if (get_bits1(&h->gb)) {
791792 /* skip mb */
792793 h->c.mb_intra = 0;
793794 for(i=0;i<6;i++)
@@ -800,7 +801,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 6 unmodified lines
800801 h->c.mb_skipped = !(h->c.obmc | h->c.loop_filter);
801802 goto end;
802803 }
803− cbpc = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
804+ cbpc = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
804805 if (cbpc < 0){
805806 av_log(h->c.avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n",
806807 h->c.mb_x, h->c.mb_y);
@@ -815,9 +816,9 @@ int ff_h263_decode_mb(H263DecContext *const h) · 8 unmodified lines
815816 if (h->c.mb_intra)
816817 goto intra;
817818
818− if(h->c.pb_frame && get_bits1(&h->c.gb))
819− pb_mv_count = h263_get_modb(&h->c.gb, h->c.pb_frame, &cbpb);
820− cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
819+ if (h->c.pb_frame && get_bits1(&h->gb))
820+ pb_mv_count = h263_get_modb(&h->gb, h->c.pb_frame, &cbpb);
821+ cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
821822
822823 if (cbpy < 0) {
823824 av_log(h->c.avctx, AV_LOG_ERROR, "cbpy damaged at %d %d\n",
@@ -858,7 +859,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 34 unmodified lines
858859 h->c.mv[0][0][1] = my;
859860
860861 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
861− skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
862+ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
862863 } else {
863864 h->c.cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
864865 h->c.mv_type = MV_TYPE_8X8;
@@ -880,7 +881,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 15 unmodified lines
880881 h->c.mv[0][i][0] = mx;
881882 h->c.mv[0][i][1] = my;
882883 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
883− skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
884+ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
884885 mot_val[0] = mx;
885886 mot_val[1] = my;
886887 }
@@ -899,7 +900,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 12 unmodified lines
899900 mot_val1[1 ]= mot_val1[3 ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
900901
901902 do{
902− mb_type = get_vlc2(&h->c.gb, h263_mbtype_b_vlc,
903+ mb_type = get_vlc2(&h->gb, h263_mbtype_b_vlc,
903904 H263_MBTYPE_B_VLC_BITS, 2);
904905 if (mb_type < 0){
905906 av_log(h->c.avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n",
@@ -911,13 +912,13 @@ int ff_h263_decode_mb(H263DecContext *const h) · 5 unmodified lines
911912 h->c.mb_intra = IS_INTRA(mb_type);
912913 if(HAS_CBP(mb_type)){
913914 h->c.bdsp.clear_blocks(h->block[0]);
914− cbpc = get_vlc2(&h->c.gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1);
915+ cbpc = get_vlc2(&h->gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1);
915916 if (h->c.mb_intra) {
916917 dquant = IS_QUANT(mb_type);
917918 goto intra;
918919 }
919920
920− cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
921+ cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
921922
922923 if (cbpy < 0){
923924 av_log(h->c.avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n",
@@ -965,7 +966,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 41 unmodified lines
965966 return SLICE_ERROR;
966967
967968 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
968− skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
969+ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
969970
970971 h->c.mv[0][0][0] = mx;
971972 h->c.mv[0][0][1] = my;
@@ -992,7 +993,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 20 unmodified lines
992993 return SLICE_ERROR;
993994
994995 if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
995− skip_bits1(&h->c.gb); /* Bit stuffing to prevent PSC */
996+ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
996997
997998 h->c.mv[1][0][0] = mx;
998999 h->c.mv[1][0][1] = my;
@@ -1004,7 +1005,7 @@ int ff_h263_decode_mb(H263DecContext *const h) · 5 unmodified lines
10041005 h->c.cur_pic.mb_type[xy] = mb_type;
10051006 } else { /* I-Frame */
10061007 do{
1007− cbpc = get_vlc2(&h->c.gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
1008+ cbpc = get_vlc2(&h->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
10081009 if (cbpc < 0){
10091010 av_log(h->c.avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n",
10101011 h->c.mb_x, h->c.mb_y);
@@ -1019,18 +1020,18 @@ int ff_h263_decode_mb(H263DecContext *const h) · 8 unmodified lines
10191020 intra:
10201021 h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA;
10211022 if (h->c.h263_aic) {
1022− h->c.ac_pred = get_bits1(&h->c.gb);
1023+ h->c.ac_pred = get_bits1(&h->gb);
10231024 if (h->c.ac_pred) {
10241025 h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
10251026
1026− h->c.h263_aic_dir = get_bits1(&h->c.gb);
1027+ h->c.h263_aic_dir = get_bits1(&h->gb);
10271028 }
10281029 }else
10291030 h->c.ac_pred = 0;
10301031
1031− if (h->c.pb_frame && get_bits1(&h->c.gb))
1032− pb_mv_count = h263_get_modb(&h->c.gb, h->c.pb_frame, &cbpb);
1033− cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
1032+ if (h->c.pb_frame && get_bits1(&h->gb))
1033+ pb_mv_count = h263_get_modb(&h->gb, h->c.pb_frame, &cbpb);
1034+ cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
10341035 if(cbpy<0){
10351036 av_log(h->c.avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n",
10361037 h->c.mb_x, h->c.mb_y);
@@ -1065,15 +1066,15 @@ intra: · 28 unmodified lines
10651066 }
10661067 end:
10671068
1068− if (get_bits_left(&h->c.gb) < 0)
1069+ if (get_bits_left(&h->gb) < 0)
10691070 return AVERROR_INVALIDDATA;
10701071
10711072 /* per-MB end of slice check */
10721073 {
1073− int v = show_bits(&h->c.gb, 16);
1074+ int v = show_bits(&h->gb, 16);
10741075
1075− if (get_bits_left(&h->c.gb) < 16) {
1076− v >>= 16 - get_bits_left(&h->c.gb);
1076+ if (get_bits_left(&h->gb) < 16) {
1077+ v >>= 16 - get_bits_left(&h->gb);
10771078 }
10781079
10791080 if(v==0)
@@ -1089,16 +1090,16 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 9 unmodified lines
10891090 int width, height, i, ret;
10901091 int h263_plus;
10911092
1092− align_get_bits(&h->c.gb);
1093+ align_get_bits(&h->gb);
10931094
1094− if (show_bits(&h->c.gb, 2) == 2 && h->c.avctx->frame_num == 0) {
1095+ if (show_bits(&h->gb, 2) == 2 && h->c.avctx->frame_num == 0) {
10951096 av_log(h->c.avctx, AV_LOG_WARNING, "Header looks like RTP instead of H.263\n");
10961097 }
10971098
1098− uint32_t startcode = get_bits(&h->c.gb, 22-8);
1099+ uint32_t startcode = get_bits(&h->gb, 22-8);
10991100
1100− for (i = get_bits_left(&h->c.gb); i>24; i -= 8) {
1101− startcode = ((startcode << 8) | get_bits(&h->c.gb, 8)) & 0x003FFFFF;
1101+ for (i = get_bits_left(&h->gb); i>24; i -= 8) {
1102+ startcode = ((startcode << 8) | get_bits(&h->gb, 8)) & 0x003FFFFF;
11021103
11031104 if(startcode == 0x20)
11041105 break;
@@ -1109,25 +1110,25 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 4 unmodified lines
11091110 return -1;
11101111 }
11111112 /* temporal reference */
1112− i = get_bits(&h->c.gb, 8); /* picture timestamp */
1113+ i = get_bits(&h->gb, 8); /* picture timestamp */
11131114
11141115 i -= (i - (h->c.picture_number & 0xFF) + 128) & ~0xFF;
11151116
11161117 h->c.picture_number = (h->c.picture_number&~0xFF) + i;
11171118
11181119 /* PTYPE starts here */
1119− if (check_marker(h->c.avctx, &h->c.gb, "in PTYPE") != 1) {
1120+ if (check_marker(h->c.avctx, &h->gb, "in PTYPE") != 1) {
11201121 return -1;
11211122 }
1122− if (get_bits1(&h->c.gb) != 0) {
1123+ if (get_bits1(&h->gb) != 0) {
11231124 av_log(h->c.avctx, AV_LOG_ERROR, "Bad H.263 id\n");
11241125 return -1; /* H.263 id */
11251126 }
1126− skip_bits1(&h->c.gb); /* split screen off */
1127− skip_bits1(&h->c.gb); /* camera off */
1128− skip_bits1(&h->c.gb); /* freeze picture release off */
1127+ skip_bits1(&h->gb); /* split screen off */
1128+ skip_bits1(&h->gb); /* camera off */
1129+ skip_bits1(&h->gb); /* freeze picture release off */
11291130
1130− int format = get_bits(&h->c.gb, 3);
1131+ int format = get_bits(&h->gb, 3);
11311132 /*
11321133 0 forbidden
11331134 1 sub-QCIF
@@ -1143,19 +1144,19 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 9 unmodified lines
11431144 if (!width)
11441145 return -1;
11451146
1146− h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->c.gb);
1147+ h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->gb);
11471148
1148− h->c.h263_long_vectors = get_bits1(&h->c.gb);
1149+ h->c.h263_long_vectors = get_bits1(&h->gb);
11491150
1150− if (get_bits1(&h->c.gb) != 0) {
1151+ if (get_bits1(&h->gb) != 0) {
11511152 av_log(h->c.avctx, AV_LOG_ERROR, "H.263 SAC not supported\n");
11521153 return -1; /* SAC: off */
11531154 }
1154− h->c.obmc = get_bits1(&h->c.gb); /* Advanced prediction mode */
1155+ h->c.obmc = get_bits1(&h->gb); /* Advanced prediction mode */
11551156
1156− h->c.pb_frame = get_bits1(&h->c.gb);
1157− h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
1158− skip_bits1(&h->c.gb); /* Continuous Presence Multipoint mode: off */
1157+ h->c.pb_frame = get_bits1(&h->gb);
1158+ h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
1159+ skip_bits1(&h->gb); /* Continuous Presence Multipoint mode: off */
11591160
11601161 h->c.width = width;
11611162 h->c.height = height;
@@ -1166,46 +1167,46 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 4 unmodified lines
11661167
11671168 /* H.263v2 */
11681169 h263_plus = 1;
1169− ufep = get_bits(&h->c.gb, 3); /* Update Full Extended PTYPE */
1170+ ufep = get_bits(&h->gb, 3); /* Update Full Extended PTYPE */
11701171
11711172 /* ufep other than 0 and 1 are reserved */
11721173 if (ufep == 1) {
11731174 /* OPPTYPE */
1174− format = get_bits(&h->c.gb, 3);
1175+ format = get_bits(&h->gb, 3);
11751176 ff_dlog(h->c.avctx, "ufep=1, format: %d\n", format);
1176− h->c.custom_pcf = get_bits1(&h->c.gb);
1177− h->c.umvplus = get_bits1(&h->c.gb); /* Unrestricted Motion Vector */
1178− if (get_bits1(&h->c.gb) != 0) {
1177+ h->c.custom_pcf = get_bits1(&h->gb);
1178+ h->c.umvplus = get_bits1(&h->gb); /* Unrestricted Motion Vector */
1179+ if (get_bits1(&h->gb) != 0) {
11791180 av_log(h->c.avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
11801181 }
1181− h->c.obmc = get_bits1(&h->c.gb); /* Advanced prediction mode */
1182− h->c.h263_aic = get_bits1(&h->c.gb); /* Advanced Intra Coding (AIC) */
1183− h->c.loop_filter = get_bits1(&h->c.gb);
1182+ h->c.obmc = get_bits1(&h->gb); /* Advanced prediction mode */
1183+ h->c.h263_aic = get_bits1(&h->gb); /* Advanced Intra Coding (AIC) */
1184+ h->c.loop_filter = get_bits1(&h->gb);
11841185 if (h->c.avctx->lowres)
11851186 h->c.loop_filter = 0;
11861187
1187− h->c.h263_slice_structured= get_bits1(&h->c.gb);
1188− if (get_bits1(&h->c.gb) != 0) {
1188+ h->c.h263_slice_structured = get_bits1(&h->gb);
1189+ if (get_bits1(&h->gb) != 0) {
11891190 av_log(h->c.avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
11901191 }
1191− if (get_bits1(&h->c.gb) != 0) {
1192+ if (get_bits1(&h->gb) != 0) {
11921193 av_log(h->c.avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
11931194 }
1194− h->c.alt_inter_vlc = get_bits1(&h->c.gb);
1195− h->c.modified_quant = get_bits1(&h->c.gb);
1195+ h->c.alt_inter_vlc = get_bits1(&h->gb);
1196+ h->c.modified_quant = get_bits1(&h->gb);
11961197 if (h->c.modified_quant)
11971198 h->c.chroma_qscale_table= ff_h263_chroma_qscale_table;
11981199
1199− skip_bits(&h->c.gb, 1); /* Prevent start code emulation */
1200+ skip_bits(&h->gb, 1); /* Prevent start code emulation */
12001201
1201− skip_bits(&h->c.gb, 3); /* Reserved */
1202+ skip_bits(&h->gb, 3); /* Reserved */
12021203 } else if (ufep != 0) {
12031204 av_log(h->c.avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
12041205 return -1;
12051206 }
12061207
12071208 /* MPPTYPE */
1208− h->c.pict_type = get_bits(&h->c.gb, 3);
1209+ h->c.pict_type = get_bits(&h->gb, 3);
12091210 switch (h->c.pict_type) {
12101211 case 0: h->c.pict_type = AV_PICTURE_TYPE_I; break;
12111212 case 1: h->c.pict_type = AV_PICTURE_TYPE_P; break;
@@ -1215,15 +1216,15 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 3 unmodified lines
12151216 default:
12161217 return -1;
12171218 }
1218− skip_bits(&h->c.gb, 2);
1219− h->c.no_rounding = get_bits1(&h->c.gb);
1220− skip_bits(&h->c.gb, 4);
1219+ skip_bits(&h->gb, 2);
1220+ h->c.no_rounding = get_bits1(&h->gb);
1221+ skip_bits(&h->gb, 4);
12211222
12221223 /* Get the picture dimensions */
12231224 if (ufep) {
12241225 if (format == 6) {
12251226 /* Custom Picture Format (CPFMT) */
1226− int aspect_ratio_info = get_bits(&h->c.gb, 4);
1227+ int aspect_ratio_info = get_bits(&h->gb, 4);
12271228 ff_dlog(h->c.avctx, "aspect: %d\n", aspect_ratio_info);
12281229 /* aspect ratios:
12291230 0 - forbidden
@@ -1234,14 +1235,14 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 4 unmodified lines
12341235 5 - 40:33 (525-type 16:9)
12351236 6-14 - reserved
12361237 */
1237− width = (get_bits(&h->c.gb, 9) + 1) * 4;
1238− check_marker(h->c.avctx, &h->c.gb, "in dimensions");
1239− height = get_bits(&h->c.gb, 9) * 4;
1238+ width = (get_bits(&h->gb, 9) + 1) * 4;
1239+ check_marker(h->c.avctx, &h->gb, "in dimensions");
1240+ height = get_bits(&h->gb, 9) * 4;
12401241 ff_dlog(h->c.avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
12411242 if (aspect_ratio_info == FF_ASPECT_EXTENDED) {
12421243 /* expected dimensions */
1243− h->c.avctx->sample_aspect_ratio.num = get_bits(&h->c.gb, 8);
1244− h->c.avctx->sample_aspect_ratio.den = get_bits(&h->c.gb, 8);
1244+ h->c.avctx->sample_aspect_ratio.num = get_bits(&h->gb, 8);
1245+ h->c.avctx->sample_aspect_ratio.den = get_bits(&h->gb, 8);
12451246 }else{
12461247 h->c.avctx->sample_aspect_ratio= ff_h263_pixel_aspect[aspect_ratio_info];
12471248 }
@@ -1258,8 +1259,8 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 10 unmodified lines
12581259
12591260 if (h->c.custom_pcf) {
12601261 h->c.avctx->framerate.num = 1800000;
1261− h->c.avctx->framerate.den = 1000 + get_bits1(&h->c.gb);
1262− h->c.avctx->framerate.den *= get_bits(&h->c.gb, 7);
1262+ h->c.avctx->framerate.den = 1000 + get_bits1(&h->gb);
1263+ h->c.avctx->framerate.den *= get_bits(&h->gb, 7);
12631264 if (h->c.avctx->framerate.den == 0) {
12641265 av_log(h->c.avctx, AV_LOG_ERROR, "zero framerate\n");
12651266 return -1;
@@ -1273,30 +1274,30 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 7 unmodified lines
12731274 }
12741275
12751276 if (h->c.custom_pcf)
1276− skip_bits(&h->c.gb, 2); //extended Temporal reference
1277+ skip_bits(&h->gb, 2); //extended Temporal reference
12771278
12781279 if (ufep) {
12791280 if (h->c.umvplus) {
1280− if(get_bits1(&h->c.gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
1281− skip_bits1(&h->c.gb);
1281+ if (get_bits1(&h->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
1282+ skip_bits1(&h->gb);
12821283 }
12831284 if (h->c.h263_slice_structured) {
1284− if (get_bits1(&h->c.gb) != 0) {
1285+ if (get_bits1(&h->gb) != 0) {
12851286 av_log(h->c.avctx, AV_LOG_ERROR, "rectangular slices not supported\n");
12861287 }
1287− if (get_bits1(&h->c.gb) != 0) {
1288+ if (get_bits1(&h->gb) != 0) {
12881289 av_log(h->c.avctx, AV_LOG_ERROR, "unordered slices not supported\n");
12891290 }
12901291 }
12911292 if (h->c.pict_type == AV_PICTURE_TYPE_B) {
1292− skip_bits(&h->c.gb, 4); //ELNUM
1293+ skip_bits(&h->gb, 4); //ELNUM
12931294 if (ufep == 1) {
1294− skip_bits(&h->c.gb, 4); // RLNUM
1295+ skip_bits(&h->gb, 4); // RLNUM
12951296 }
12961297 }
12971298 }
12981299
1299− h->c.qscale = get_bits(&h->c.gb, 5);
1300+ h->c.qscale = get_bits(&h->gb, 5);
13001301 }
13011302
13021303 ret = av_image_check_size(h->c.width, h->c.height, 0, h->c.avctx);
@@ -1304,7 +1305,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 1 unmodified line
13041305 return ret;
13051306
13061307 if (!(h->c.avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
1307− if ((h->c.width * h->c.height / 256 / 8) > get_bits_left(&h->c.gb))
1308+ if ((h->c.width * h->c.height / 256 / 8) > get_bits_left(&h->gb))
13081309 return AVERROR_INVALIDDATA;
13091310 }
13101311
@@ -1315,10 +1316,10 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 4 unmodified lines
13151316 h->c.gob_index = H263_GOB_HEIGHT(h->c.height);
13161317
13171318 if (h->c.pb_frame) {
1318− skip_bits(&h->c.gb, 3); /* Temporal reference for B-pictures */
1319+ skip_bits(&h->gb, 3); /* Temporal reference for B-pictures */
13191320 if (h->c.custom_pcf)
1320− skip_bits(&h->c.gb, 2); //extended Temporal reference
1321− skip_bits(&h->c.gb, 2); /* Quantization information for B-pictures */
1321+ skip_bits(&h->gb, 2); //extended Temporal reference
1322+ skip_bits(&h->gb, 2); /* Quantization information for B-pictures */
13221323 }
13231324
13241325 if (h->c.pict_type!=AV_PICTURE_TYPE_B) {
@@ -1338,17 +1339,17 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 13 unmodified lines
13381339 }
13391340
13401341 /* PEI */
1341− if (skip_1stop_8data_bits(&h->c.gb) < 0)
1342+ if (skip_1stop_8data_bits(&h->gb) < 0)
13421343 return AVERROR_INVALIDDATA;
13431344
13441345 if (h->c.h263_slice_structured) {
1345− if (check_marker(h->c.avctx, &h->c.gb, "SEPB1") != 1) {
1346+ if (check_marker(h->c.avctx, &h->gb, "SEPB1") != 1) {
13461347 return -1;
13471348 }
13481349
13491350 ff_h263_decode_mba(h);
13501351
1351− if (check_marker(h->c.avctx, &h->c.gb, "SEPB2") != 1) {
1352+ if (check_marker(h->c.avctx, &h->gb, "SEPB2") != 1) {
13521353 return -1;
13531354 }
13541355 }
@@ -1366,19 +1367,19 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 11 unmodified lines
13661367
13671368 ff_h263_show_pict_info(h, h263_plus);
13681369
1369− if (h->c.pict_type == AV_PICTURE_TYPE_I && h->c.codec_tag == AV_RL32("ZYGO") && get_bits_left(&h->c.gb) >= 85 + 13*3*16 + 50){
1370+ if (h->c.pict_type == AV_PICTURE_TYPE_I && h->c.codec_tag == AV_RL32("ZYGO") && get_bits_left(&h->gb) >= 85 + 13*3*16 + 50){
13701371 int i,j;
1371− for(i=0; i<85; i++) av_log(h->c.avctx, AV_LOG_DEBUG, "%d", get_bits1(&h->c.gb));
1372+ for(i=0; i<85; i++) av_log(h->c.avctx, AV_LOG_DEBUG, "%d", get_bits1(&h->gb));
13721373 av_log(h->c.avctx, AV_LOG_DEBUG, "\n");
13731374 for(i=0; i<13; i++){
13741375 for(j=0; j<3; j++){
1375− int v= get_bits(&h->c.gb, 8);
1376− v |= get_sbits(&h->c.gb, 8) * (1 << 8);
1376+ int v= get_bits(&h->gb, 8);
1377+ v |= get_sbits(&h->gb, 8) * (1 << 8);
13771378 av_log(h->c.avctx, AV_LOG_DEBUG, " %5d", v);
13781379 }
13791380 av_log(h->c.avctx, AV_LOG_DEBUG, "\n");
13801381 }
1381− for(i=0; i<50; i++) av_log(h->c.avctx, AV_LOG_DEBUG, "%d", get_bits1(&h->c.gb));
1382+ for(i=0; i<50; i++) av_log(h->c.avctx, AV_LOG_DEBUG, "%d", get_bits1(&h->gb));
13821383 }
13831384
13841385 return 0;
libavcodec/mpeg12dec.c+5−5
@@ -479,7 +479,7 @@ static int mpeg_decode_mb(MPVContext *const s) · 478 unmodified lines
479479 s->interlaced_dct = get_bits1(&s->gb);
480480
481481 if (IS_QUANT(mb_type))
482− s->qscale = mpeg_get_qscale(s);
482+ s->qscale = mpeg_get_qscale(&s->gb, s->q_scale_type);
483483
484484 if (s->concealment_motion_vectors) {
485485 /* just parse them */
@@ -537,7 +537,7 @@ static int mpeg_decode_mb(MPVContext *const s) · 51 unmodified lines
537537 }
538538
539539 if (IS_QUANT(mb_type))
540− s->qscale = mpeg_get_qscale(s);
540+ s->qscale = mpeg_get_qscale(&s->gb, s->q_scale_type);
541541
542542 s->last_mv[0][0][0] = 0;
543543 s->last_mv[0][0][1] = 0;
@@ -558,7 +558,7 @@ static int mpeg_decode_mb(MPVContext *const s) · 14 unmodified lines
558558 }
559559
560560 if (IS_QUANT(mb_type))
561− s->qscale = mpeg_get_qscale(s);
561+ s->qscale = mpeg_get_qscale(&s->gb, s->q_scale_type);
562562
563563 /* motion vectors */
564564 s->mv_dir = MB_TYPE_MV_2_MV_DIR(mb_type);
@@ -1370,7 +1370,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y, · 805 unmodified lines
13701370 ff_mpeg1_clean_buffers(s);
13711371 s->interlaced_dct = 0;
13721372
1373− s->qscale = mpeg_get_qscale(s);
1373+ s->qscale = mpeg_get_qscale(&s->gb, s->q_scale_type);
13741374
13751375 if (s->qscale == 0) {
13761376 av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
@@ -2805,7 +2805,7 @@ static int ipu_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1428 unmodified lines
28052805 skip_bits1(gb);
28062806
28072807 if (intraquant)
2808− m->qscale = mpeg_get_qscale(m);
2808+ m->qscale = mpeg_get_qscale(&m->gb, m->q_scale_type);
28092809
28102810 memset(s->block, 0, sizeof(s->block));
28112811
libavcodec/mpeg4videodec.c+160−160
@@ -383,8 +383,8 @@ void ff_mpeg4_pred_ac(H263DecContext *const h, int16_t *block, int n, int dir) · 382 unmodified lines
383383 static inline int mpeg4_is_resync(Mpeg4DecContext *ctx)
384384 {
385385 H263DecContext *const h = &ctx->h;
386− int bits_count = get_bits_count(&h->c.gb);
387− int v = show_bits(&h->c.gb, 16);
386+ int bits_count = get_bits_count(&h->gb);
387+ int v = show_bits(&h->gb, 16);
388388
389389 if (h->c.workaround_bugs & FF_BUG_NO_PADDING && !ctx->resync_marker)
390390 return 0;
@@ -393,12 +393,12 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) · 2 unmodified lines
393393 if (h->c.pict_type == AV_PICTURE_TYPE_B ||
394394 (v >> (8 - h->c.pict_type) != 1) || h->c.partitioned_frame)
395395 break;
396− skip_bits(&h->c.gb, 8 + h->c.pict_type);
396+ skip_bits(&h->gb, 8 + h->c.pict_type);
397397 bits_count += 8 + h->c.pict_type;
398− v = show_bits(&h->c.gb, 16);
398+ v = show_bits(&h->gb, 16);
399399 }
400400
401− if (bits_count + 8 >= h->c.gb.size_in_bits) {
401+ if (bits_count + 8 >= h->gb.size_in_bits) {
402402 v >>= 8;
403403 v |= 0x7F >> (7 - (bits_count & 7));
404404
@@ -412,20 +412,20 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) · 7 unmodified lines
412412 if (v == mpeg4_resync_prefix[bits_count & 7]) {
413413 int len, mb_num;
414414 int mb_num_bits = av_log2(h->c.mb_num - 1) + 1;
415− GetBitContext gb = h->c.gb;
415+ GetBitContext gb = h->gb;
416416
417− skip_bits(&h->c.gb, 1);
418− align_get_bits(&h->c.gb);
417+ skip_bits(&h->gb, 1);
418+ align_get_bits(&h->gb);
419419
420420 for (len = 0; len < 32; len++)
421− if (get_bits1(&h->c.gb))
421+ if (get_bits1(&h->gb))
422422 break;
423423
424− mb_num = get_bits(&h->c.gb, mb_num_bits);
425− if (!mb_num || mb_num > h->c.mb_num || get_bits_count(&h->c.gb) + 6 > h->c.gb.size_in_bits)
424+ mb_num = get_bits(&h->gb, mb_num_bits);
425+ if (!mb_num || mb_num > h->c.mb_num || get_bits_count(&h->gb) + 6 > h->gb.size_in_bits)
426426 mb_num= -1;
427427
428− h->c.gb = gb;
428+ h->gb = gb;
429429
430430 if (len >= ff_mpeg4_get_video_packet_prefix_length(h->c.pict_type, ctx->f_code, ctx->b_code))
431431 return mb_num;
@@ -713,11 +713,11 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h) · 281 unmodified lines
713713 int header_extension = 0, mb_num, len;
714714
715715 /* is there enough space left for a video packet + header */
716− if (get_bits_count(&h->c.gb) > h->c.gb.size_in_bits - 20)
716+ if (get_bits_count(&h->gb) > h->gb.size_in_bits - 20)
717717 return AVERROR_INVALIDDATA;
718718
719719 for (len = 0; len < 32; len++)
720− if (get_bits1(&h->c.gb))
720+ if (get_bits1(&h->gb))
721721 break;
722722
723723 if (len != ff_mpeg4_get_video_packet_prefix_length(h->c.pict_type, ctx->f_code, ctx->b_code)) {
@@ -726,11 +726,11 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h) · 2 unmodified lines
726726 }
727727
728728 if (ctx->shape != RECT_SHAPE) {
729− header_extension = get_bits1(&h->c.gb);
729+ header_extension = get_bits1(&h->gb);
730730 // FIXME more stuff here
731731 }
732732
733− mb_num = get_bits(&h->c.gb, mb_num_bits);
733+ mb_num = get_bits(&h->gb, mb_num_bits);
734734 if (mb_num >= h->c.mb_num || !mb_num) {
735735 av_log(h->c.avctx, AV_LOG_ERROR,
736736 "illegal mb_num in video packet (%d %d) \n", mb_num, h->c.mb_num);
@@ -741,31 +741,31 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h) · 4 unmodified lines
741741 h->c.mb_y = mb_num / h->c.mb_width;
742742
743743 if (ctx->shape != BIN_ONLY_SHAPE) {
744− int qscale = get_bits(&h->c.gb, ctx->quant_precision);
744+ int qscale = get_bits(&h->gb, ctx->quant_precision);
745745 if (qscale)
746746 h->c.chroma_qscale = h->c.qscale = qscale;
747747 }
748748
749749 if (ctx->shape == RECT_SHAPE)
750− header_extension = get_bits1(&h->c.gb);
750+ header_extension = get_bits1(&h->gb);
751751
752752 if (header_extension) {
753− while (get_bits1(&h->c.gb) != 0)
753+ while (get_bits1(&h->gb) != 0)
754754 ;
755755
756− check_marker(h->c.avctx, &h->c.gb, "before time_increment in video packed header");
757− skip_bits(&h->c.gb, ctx->time_increment_bits); /* time_increment */
758− check_marker(h->c.avctx, &h->c.gb, "before vop_coding_type in video packed header");
756+ check_marker(h->c.avctx, &h->gb, "before time_increment in video packed header");
757+ skip_bits(&h->gb, ctx->time_increment_bits); /* time_increment */
758+ check_marker(h->c.avctx, &h->gb, "before vop_coding_type in video packed header");
759759
760− skip_bits(&h->c.gb, 2); /* vop coding type */
760+ skip_bits(&h->gb, 2); /* vop coding type */
761761 // FIXME not rect stuff here
762762
763763 if (ctx->shape != BIN_ONLY_SHAPE) {
764− skip_bits(&h->c.gb, 3); /* intra dc vlc threshold */
764+ skip_bits(&h->gb, 3); /* intra dc vlc threshold */
765765 // FIXME don't just ignore everything
766766 if (h->c.pict_type == AV_PICTURE_TYPE_S &&
767767 ctx->vol_sprite_usage == GMC_SPRITE) {
768− if (mpeg4_decode_sprite_trajectory(ctx, &h->c.gb) < 0)
768+ if (mpeg4_decode_sprite_trajectory(ctx, &h->gb) < 0)
769769 return AVERROR_INVALIDDATA;
770770 av_log(h->c.avctx, AV_LOG_ERROR, "untested\n");
771771 }
@@ -773,13 +773,13 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h) · 1 unmodified line
773773 // FIXME reduced res stuff here
774774
775775 if (h->c.pict_type != AV_PICTURE_TYPE_I) {
776− int f_code = get_bits(&h->c.gb, 3); /* fcode_for */
776+ int f_code = get_bits(&h->gb, 3); /* fcode_for */
777777 if (f_code == 0)
778778 av_log(h->c.avctx, AV_LOG_ERROR,
779779 "Error, video packet header damaged (f_code=0)\n");
780780 }
781781 if (h->c.pict_type == AV_PICTURE_TYPE_B) {
782− int b_code = get_bits(&h->c.gb, 3);
782+ int b_code = get_bits(&h->gb, 3);
783783 if (b_code == 0)
784784 av_log(h->c.avctx, AV_LOG_ERROR,
785785 "Error, video packet header damaged (b_code=0)\n");
@@ -787,7 +787,7 @@ int ff_mpeg4_decode_video_packet_header(H263DecContext *const h) · 1 unmodified line
787787 }
788788 }
789789 if (ctx->new_pred)
790− decode_new_pred(ctx, &h->c.gb);
790+ decode_new_pred(ctx, &h->gb);
791791
792792 return 0;
793793 }
@@ -808,7 +808,7 @@ static void reset_studio_dc_predictors(Mpeg4DecContext *const ctx) · 14 unmodified lines
808808 int ff_mpeg4_decode_studio_slice_header(H263DecContext *const h)
809809 {
810810 Mpeg4DecContext *const ctx = h263_to_mpeg4(h);
811− GetBitContext *gb = &h->c.gb;
811+ GetBitContext *gb = &h->gb;
812812 unsigned vlc_len;
813813 uint16_t mb_num;
814814
@@ -823,7 +823,7 @@ int ff_mpeg4_decode_studio_slice_header(H263DecContext *const h) · 8 unmodified lines
823823 h->c.mb_y = mb_num / h->c.mb_width;
824824
825825 if (ctx->shape != BIN_ONLY_SHAPE)
826− h->c.qscale = mpeg_get_qscale(&h->c);
826+ h->c.qscale = mpeg_get_qscale(&h->gb, h->c.q_scale_type);
827827
828828 if (get_bits1(gb)) { /* slice_extension_flag */
829829 skip_bits1(gb); /* intra_slice */
@@ -985,9 +985,9 @@ static inline int mpeg4_decode_dc(H263DecContext *const h, int n, int *dir_ptr) · 155 unmodified lines
985985 int level, code, pred;
986986
987987 if (n < 4)
988− code = get_vlc2(&h->c.gb, dc_lum, DC_VLC_BITS, 1);
988+ code = get_vlc2(&h->gb, dc_lum, DC_VLC_BITS, 1);
989989 else
990− code = get_vlc2(&h->c.gb, dc_chrom, DC_VLC_BITS, 1);
990+ code = get_vlc2(&h->gb, dc_chrom, DC_VLC_BITS, 1);
991991
992992 if (code < 0) {
993993 av_log(h->c.avctx, AV_LOG_ERROR, "illegal dc vlc\n");
@@ -999,19 +999,19 @@ static inline int mpeg4_decode_dc(H263DecContext *const h, int n, int *dir_ptr) · 5 unmodified lines
999999 } else {
10001000 if (IS_3IV1) {
10011001 if (code == 1)
1002− level = 2 * get_bits1(&h->c.gb) - 1;
1002+ level = 2 * get_bits1(&h->gb) - 1;
10031003 else {
1004− if (get_bits1(&h->c.gb))
1005− level = get_bits(&h->c.gb, code - 1) + (1 << (code - 1));
1004+ if (get_bits1(&h->gb))
1005+ level = get_bits(&h->gb, code - 1) + (1 << (code - 1));
10061006 else
1007− level = -get_bits(&h->c.gb, code - 1) - (1 << (code - 1));
1007+ level = -get_bits(&h->gb, code - 1) - (1 << (code - 1));
10081008 }
10091009 } else {
1010− level = get_xbits(&h->c.gb, code);
1010+ level = get_xbits(&h->gb, code);
10111011 }
10121012
10131013 if (code > 8) {
1014− if (get_bits1(&h->c.gb) == 0) { /* marker */
1014+ if (get_bits1(&h->gb) == 0) { /* marker */
10151015 if (h->c.avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)) {
10161016 av_log(h->c.avctx, AV_LOG_ERROR, "dc marker bit missing\n");
10171017 return AVERROR_INVALIDDATA;
@@ -1052,10 +1052,10 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx) · 34 unmodified lines
10521052 int i;
10531053
10541054 do {
1055− if (show_bits(&h->c.gb, 19) == DC_MARKER)
1055+ if (show_bits(&h->gb, 19) == DC_MARKER)
10561056 return mb_num - 1;
10571057
1058− cbpc = get_vlc2(&h->c.gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
1058+ cbpc = get_vlc2(&h->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
10591059 if (cbpc < 0) {
10601060 av_log(h->c.avctx, AV_LOG_ERROR,
10611061 "mcbpc corrupted at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1068,7 +1068,7 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx) · 6 unmodified lines
10681068 h->c.mb_intra = 1;
10691069
10701070 if (cbpc & 4)
1071− ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
1071+ ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
10721072
10731073 h->c.cur_pic.qscale_table[xy] = h->c.qscale;
10741074
@@ -1092,11 +1092,11 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx) · 17 unmodified lines
10921092 const int stride = h->c.b8_stride * 2;
10931093
10941094 try_again:
1095− bits = show_bits(&h->c.gb, 17);
1095+ bits = show_bits(&h->gb, 17);
10961096 if (bits == MOTION_MARKER)
10971097 return mb_num - 1;
10981098
1099− skip_bits1(&h->c.gb);
1099+ skip_bits1(&h->gb);
11001100 if (bits & 0x10000) {
11011101 /* skip mb */
11021102 if (h->c.pict_type == AV_PICTURE_TYPE_S &&
@@ -1126,7 +1126,7 @@ try_again: · 23 unmodified lines
11261126 continue;
11271127 }
11281128
1129− cbpc = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
1129+ cbpc = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
11301130 if (cbpc < 0) {
11311131 av_log(h->c.avctx, AV_LOG_ERROR,
11321132 "mcbpc corrupted at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1156,7 +1156,7 @@ try_again: · 23 unmodified lines
11561156 if (h->c.pict_type == AV_PICTURE_TYPE_S &&
11571157 ctx->vol_sprite_usage == GMC_SPRITE &&
11581158 (cbpc & 16) == 0)
1159− h->c.mcsel = get_bits1(&h->c.gb);
1159+ h->c.mcsel = get_bits1(&h->gb);
11601160 else
11611161 h->c.mcsel = 0;
11621162
@@ -1238,8 +1238,8 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count) · 75 unmodified lines
12381238 h->c.first_slice_line = 0;
12391239
12401240 if (h->c.pict_type == AV_PICTURE_TYPE_I) {
1241− int ac_pred = get_bits1(&h->c.gb);
1242− int cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
1241+ int ac_pred = get_bits1(&h->gb);
1242+ int cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
12431243 if (cbpy < 0) {
12441244 av_log(h->c.avctx, AV_LOG_ERROR,
12451245 "cbpy corrupted at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1252,8 +1252,8 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count) · 6 unmodified lines
12521252 if (IS_INTRA(h->c.cur_pic.mb_type[xy])) {
12531253 int i;
12541254 int dir = 0;
1255− int ac_pred = get_bits1(&h->c.gb);
1256− int cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
1255+ int ac_pred = get_bits1(&h->gb);
1256+ int cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
12571257
12581258 if (cbpy < 0) {
12591259 av_log(h->c.avctx, AV_LOG_ERROR,
@@ -1262,7 +1262,7 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count) · 2 unmodified lines
12621262 }
12631263
12641264 if (h->c.cbp_table[xy] & 8)
1265− ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
1265+ ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
12661266 h->c.cur_pic.qscale_table[xy] = h->c.qscale;
12671267
12681268 for (i = 0; i < 6; i++) {
@@ -1285,7 +1285,7 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count) · 16 unmodified lines
12851285 h->c.cur_pic.qscale_table[xy] = h->c.qscale;
12861286 h->c.cbp_table[xy] = 0;
12871287 } else {
1288− int cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
1288+ int cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
12891289
12901290 if (cbpy < 0) {
12911291 av_log(h->c.avctx, AV_LOG_ERROR,
@@ -1294,7 +1294,7 @@ static int mpeg4_decode_partition_b(H263DecContext *const h, int mb_count) · 2 unmodified lines
12941294 }
12951295
12961296 if (h->c.cbp_table[xy] & 8)
1297− ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
1297+ ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
12981298 h->c.cur_pic.qscale_table[xy] = h->c.qscale;
12991299
13001300 h->c.cbp_table[xy] &= 3; // remove dquant
@@ -1338,18 +1338,18 @@ int ff_mpeg4_decode_partitions(H263DecContext *const h) · 37 unmodified lines
13381338 h->c.mb_num_left = mb_num;
13391339
13401340 if (h->c.pict_type == AV_PICTURE_TYPE_I) {
1341− while (show_bits(&h->c.gb, 9) == 1)
1342− skip_bits(&h->c.gb, 9);
1343− if (get_bits(&h->c.gb, 19) != DC_MARKER) {
1341+ while (show_bits(&h->gb, 9) == 1)
1342+ skip_bits(&h->gb, 9);
1343+ if (get_bits(&h->gb, 19) != DC_MARKER) {
13441344 av_log(h->c.avctx, AV_LOG_ERROR,
13451345 "marker missing after first I partition at %d %d\n",
13461346 h->c.mb_x, h->c.mb_y);
13471347 return AVERROR_INVALIDDATA;
13481348 }
13491349 } else {
1350− while (show_bits(&h->c.gb, 10) == 1)
1351− skip_bits(&h->c.gb, 10);
1352− if (get_bits(&h->c.gb, 17) != MOTION_MARKER) {
1350+ while (show_bits(&h->gb, 10) == 1)
1351+ skip_bits(&h->gb, 10);
1352+ if (get_bits(&h->gb, 17) != MOTION_MARKER) {
13531353 av_log(h->c.avctx, AV_LOG_ERROR,
13541354 "marker missing after first P partition at %d %d\n",
13551355 h->c.mb_x, h->c.mb_y);
@@ -1463,52 +1463,52 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 107 unmodified lines
14631463 }
14641464 }
14651465 {
1466− OPEN_READER(re, &h->c.gb);
1466+ OPEN_READER(re, &h->gb);
14671467 for (;;) {
1468− UPDATE_CACHE(re, &h->c.gb);
1469− GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 0);
1468+ UPDATE_CACHE(re, &h->gb);
1469+ GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
14701470 if (level == 0) {
14711471 /* escape */
14721472 if (rvlc) {
1473− if (SHOW_UBITS(re, &h->c.gb, 1) == 0) {
1473+ if (SHOW_UBITS(re, &h->gb, 1) == 0) {
14741474 av_log(h->c.avctx, AV_LOG_ERROR,
14751475 "1. marker bit missing in rvlc esc\n");
14761476 return AVERROR_INVALIDDATA;
14771477 }
1478− SKIP_CACHE(re, &h->c.gb, 1);
1478+ SKIP_CACHE(re, &h->gb, 1);
14791479
1480− last = SHOW_UBITS(re, &h->c.gb, 1);
1481− SKIP_CACHE(re, &h->c.gb, 1);
1482− run = SHOW_UBITS(re, &h->c.gb, 6);
1483− SKIP_COUNTER(re, &h->c.gb, 1 + 1 + 6);
1484− UPDATE_CACHE(re, &h->c.gb);
1480+ last = SHOW_UBITS(re, &h->gb, 1);
1481+ SKIP_CACHE(re, &h->gb, 1);
1482+ run = SHOW_UBITS(re, &h->gb, 6);
1483+ SKIP_COUNTER(re, &h->gb, 1 + 1 + 6);
1484+ UPDATE_CACHE(re, &h->gb);
14851485
1486− if (SHOW_UBITS(re, &h->c.gb, 1) == 0) {
1486+ if (SHOW_UBITS(re, &h->gb, 1) == 0) {
14871487 av_log(h->c.avctx, AV_LOG_ERROR,
14881488 "2. marker bit missing in rvlc esc\n");
14891489 return AVERROR_INVALIDDATA;
14901490 }
1491− SKIP_CACHE(re, &h->c.gb, 1);
1491+ SKIP_CACHE(re, &h->gb, 1);
14921492
1493− level = SHOW_UBITS(re, &h->c.gb, 11);
1494− SKIP_CACHE(re, &h->c.gb, 11);
1493+ level = SHOW_UBITS(re, &h->gb, 11);
1494+ SKIP_CACHE(re, &h->gb, 11);
14951495
1496− if (SHOW_UBITS(re, &h->c.gb, 5) != 0x10) {
1496+ if (SHOW_UBITS(re, &h->gb, 5) != 0x10) {
14971497 av_log(h->c.avctx, AV_LOG_ERROR, "reverse esc missing\n");
14981498 return AVERROR_INVALIDDATA;
14991499 }
1500− SKIP_CACHE(re, &h->c.gb, 5);
1500+ SKIP_CACHE(re, &h->gb, 5);
15011501
15021502 level = level * qmul + qadd;
1503− level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
1504− SKIP_COUNTER(re, &h->c.gb, 1 + 11 + 5 + 1);
1503+ level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
1504+ SKIP_COUNTER(re, &h->gb, 1 + 11 + 5 + 1);
15051505
15061506 i += run + 1;
15071507 if (last)
15081508 i += 192;
15091509 } else {
15101510 int cache;
1511− cache = GET_CACHE(re, &h->c.gb);
1511+ cache = GET_CACHE(re, &h->gb);
15121512
15131513 if (IS_3IV1)
15141514 cache ^= 0xC0000000;
@@ -1516,36 +1516,36 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 1 unmodified line
15161516 if (cache & 0x80000000) {
15171517 if (cache & 0x40000000) {
15181518 /* third escape */
1519− SKIP_CACHE(re, &h->c.gb, 2);
1520− last = SHOW_UBITS(re, &h->c.gb, 1);
1521− SKIP_CACHE(re, &h->c.gb, 1);
1522− run = SHOW_UBITS(re, &h->c.gb, 6);
1523− SKIP_COUNTER(re, &h->c.gb, 2 + 1 + 6);
1524− UPDATE_CACHE(re, &h->c.gb);
1519+ SKIP_CACHE(re, &h->gb, 2);
1520+ last = SHOW_UBITS(re, &h->gb, 1);
1521+ SKIP_CACHE(re, &h->gb, 1);
1522+ run = SHOW_UBITS(re, &h->gb, 6);
1523+ SKIP_COUNTER(re, &h->gb, 2 + 1 + 6);
1524+ UPDATE_CACHE(re, &h->gb);
15251525
15261526 if (IS_3IV1) {
1527− level = SHOW_SBITS(re, &h->c.gb, 12);
1528− LAST_SKIP_BITS(re, &h->c.gb, 12);
1527+ level = SHOW_SBITS(re, &h->gb, 12);
1528+ LAST_SKIP_BITS(re, &h->gb, 12);
15291529 } else {
1530− if (SHOW_UBITS(re, &h->c.gb, 1) == 0) {
1530+ if (SHOW_UBITS(re, &h->gb, 1) == 0) {
15311531 av_log(h->c.avctx, AV_LOG_ERROR,
15321532 "1. marker bit missing in 3. esc\n");
1533− if (!(h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&h->c.gb) <= 0)
1533+ if (!(h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&h->gb) <= 0)
15341534 return AVERROR_INVALIDDATA;
15351535 }
1536− SKIP_CACHE(re, &h->c.gb, 1);
1536+ SKIP_CACHE(re, &h->gb, 1);
15371537
1538− level = SHOW_SBITS(re, &h->c.gb, 12);
1539− SKIP_CACHE(re, &h->c.gb, 12);
1538+ level = SHOW_SBITS(re, &h->gb, 12);
1539+ SKIP_CACHE(re, &h->gb, 12);
15401540
1541− if (SHOW_UBITS(re, &h->c.gb, 1) == 0) {
1541+ if (SHOW_UBITS(re, &h->gb, 1) == 0) {
15421542 av_log(h->c.avctx, AV_LOG_ERROR,
15431543 "2. marker bit missing in 3. esc\n");
1544− if (!(h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&h->c.gb) <= 0)
1544+ if (!(h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&h->gb) <= 0)
15451545 return AVERROR_INVALIDDATA;
15461546 }
15471547
1548− SKIP_COUNTER(re, &h->c.gb, 1 + 12 + 1);
1548+ SKIP_COUNTER(re, &h->gb, 1 + 12 + 1);
15491549 }
15501550
15511551 #if 0
@@ -1592,26 +1592,26 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 40 unmodified lines
15921592 i += 192;
15931593 } else {
15941594 /* second escape */
1595− SKIP_BITS(re, &h->c.gb, 2);
1596− GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 1);
1595+ SKIP_BITS(re, &h->gb, 2);
1596+ GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
15971597 i += run + rl->max_run[run >> 7][level / qmul] + 1; // FIXME opt indexing
1598− level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
1599− LAST_SKIP_BITS(re, &h->c.gb, 1);
1598+ level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
1599+ LAST_SKIP_BITS(re, &h->gb, 1);
16001600 }
16011601 } else {
16021602 /* first escape */
1603− SKIP_BITS(re, &h->c.gb, 1);
1604− GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 1);
1603+ SKIP_BITS(re, &h->gb, 1);
1604+ GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
16051605 i += run;
16061606 level = level + rl->max_level[run >> 7][(run - 1) & 63] * qmul; // FIXME opt indexing
1607− level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
1608− LAST_SKIP_BITS(re, &h->c.gb, 1);
1607+ level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
1608+ LAST_SKIP_BITS(re, &h->gb, 1);
16091609 }
16101610 }
16111611 } else {
16121612 i += run;
1613− level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
1614− LAST_SKIP_BITS(re, &h->c.gb, 1);
1613+ level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
1614+ LAST_SKIP_BITS(re, &h->gb, 1);
16151615 }
16161616 ff_tlog(h->c.avctx, "dct[%d][%d] = %- 4d end?:%d\n", scan_table[i&63]&7, scan_table[i&63] >> 3, level, i>62);
16171617 if (i > 62) {
@@ -1628,7 +1628,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 10 unmodified lines
16281628
16291629 block[scan_table[i]] = level;
16301630 }
1631− CLOSE_READER(re, &h->c.gb);
1631+ CLOSE_READER(re, &h->gb);
16321632 }
16331633
16341634 not_coded:
@@ -1751,7 +1751,7 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 116 unmodified lines
17511751 if (h->c.pict_type == AV_PICTURE_TYPE_P ||
17521752 h->c.pict_type == AV_PICTURE_TYPE_S) {
17531753 do {
1754− if (get_bits1(&h->c.gb)) {
1754+ if (get_bits1(&h->gb)) {
17551755 /* skip mb */
17561756 h->c.mb_intra = 0;
17571757 for (i = 0; i < 6; i++)
@@ -1780,7 +1780,7 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 22 unmodified lines
17801780 }
17811781 goto end;
17821782 }
1783− cbpc = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
1783+ cbpc = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
17841784 if (cbpc < 0) {
17851785 av_log(h->c.avctx, AV_LOG_ERROR,
17861786 "mcbpc damaged at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1796,10 +1796,10 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 9 unmodified lines
17961796
17971797 if (h->c.pict_type == AV_PICTURE_TYPE_S &&
17981798 ctx->vol_sprite_usage == GMC_SPRITE && (cbpc & 16) == 0)
1799− h->c.mcsel = get_bits1(&h->c.gb);
1799+ h->c.mcsel = get_bits1(&h->gb);
18001800 else
18011801 h->c.mcsel = 0;
1802− cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1) ^ 0x0F;
1802+ cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1) ^ 0x0F;
18031803 if (cbpy < 0) {
18041804 av_log(h->c.avctx, AV_LOG_ERROR,
18051805 "P cbpy damaged at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -1808,10 +1808,10 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 2 unmodified lines
18081808
18091809 cbp = (cbpc & 3) | (cbpy << 2);
18101810 if (dquant)
1811− ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
1811+ ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
18121812 if ((!h->c.progressive_sequence) &&
18131813 (cbp || (h->c.workaround_bugs & FF_BUG_XVID_ILACE)))
1814− h->c.interlaced_dct = get_bits1(&h->c.gb);
1814+ h->c.interlaced_dct = get_bits1(&h->gb);
18151815
18161816 h->c.mv_dir = MV_DIR_FORWARD;
18171817 if ((cbpc & 16) == 0) {
@@ -1824,14 +1824,14 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 6 unmodified lines
18241824 my = get_amv(ctx, 1);
18251825 h->c.mv[0][0][0] = mx;
18261826 h->c.mv[0][0][1] = my;
1827− } else if ((!h->c.progressive_sequence) && get_bits1(&h->c.gb)) {
1827+ } else if ((!h->c.progressive_sequence) && get_bits1(&h->gb)) {
18281828 h->c.cur_pic.mb_type[xy] = MB_TYPE_16x8 | MB_TYPE_FORWARD_MV |
18291829 MB_TYPE_INTERLACED;
18301830 /* 16x8 field motion prediction */
18311831 h->c.mv_type = MV_TYPE_FIELD;
18321832
1833− h->c.field_select[0][0] = get_bits1(&h->c.gb);
1834− h->c.field_select[0][1] = get_bits1(&h->c.gb);
1833+ h->c.field_select[0][0] = get_bits1(&h->gb);
1834+ h->c.field_select[0][1] = get_bits1(&h->gb);
18351835
18361836 ff_h263_pred_motion(&h->c, 0, 0, &pred_x, &pred_y);
18371837
@@ -1921,14 +1921,14 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 83 unmodified lines
19211921 goto end;
19221922 }
19231923
1924− modb1 = get_bits1(&h->c.gb);
1924+ modb1 = get_bits1(&h->gb);
19251925 if (modb1) {
19261926 // like MB_TYPE_B_DIRECT but no vectors coded
19271927 mb_type = MB_TYPE_DIRECT2 | MB_TYPE_SKIP | MB_TYPE_BIDIR_MV;
19281928 cbp = 0;
19291929 } else {
1930− modb2 = get_bits1(&h->c.gb);
1931− mb_type = get_vlc2(&h->c.gb, mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 1);
1930+ modb2 = get_bits1(&h->gb);
1931+ mb_type = get_vlc2(&h->gb, mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 1);
19321932 if (mb_type < 0) {
19331933 av_log(h->c.avctx, AV_LOG_ERROR, "illegal MB_type\n");
19341934 return AVERROR_INVALIDDATA;
@@ -1937,29 +1937,29 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 2 unmodified lines
19371937 cbp = 0;
19381938 } else {
19391939 h->c.bdsp.clear_blocks(h->block[0]);
1940− cbp = get_bits(&h->c.gb, 6);
1940+ cbp = get_bits(&h->gb, 6);
19411941 }
19421942
19431943 if ((!IS_DIRECT(mb_type)) && cbp) {
1944− if (get_bits1(&h->c.gb))
1945− ff_set_qscale(&h->c, h->c.qscale + get_bits1(&h->c.gb) * 4 - 2);
1944+ if (get_bits1(&h->gb))
1945+ ff_set_qscale(&h->c, h->c.qscale + get_bits1(&h->gb) * 4 - 2);
19461946 }
19471947
19481948 if (!h->c.progressive_sequence) {
19491949 if (cbp)
1950− h->c.interlaced_dct = get_bits1(&h->c.gb);
1950+ h->c.interlaced_dct = get_bits1(&h->gb);
19511951
1952− if (!IS_DIRECT(mb_type) && get_bits1(&h->c.gb)) {
1952+ if (!IS_DIRECT(mb_type) && get_bits1(&h->gb)) {
19531953 mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
19541954 mb_type &= ~MB_TYPE_16x16;
19551955
19561956 if (HAS_FORWARD_MV(mb_type)) {
1957− h->c.field_select[0][0] = get_bits1(&h->c.gb);
1958− h->c.field_select[0][1] = get_bits1(&h->c.gb);
1957+ h->c.field_select[0][0] = get_bits1(&h->gb);
1958+ h->c.field_select[0][1] = get_bits1(&h->gb);
19591959 }
19601960 if (HAS_BACKWARD_MV(mb_type)) {
1961− h->c.field_select[1][0] = get_bits1(&h->c.gb);
1962− h->c.field_select[1][1] = get_bits1(&h->c.gb);
1961+ h->c.field_select[1][0] = get_bits1(&h->gb);
1962+ h->c.field_select[1][1] = get_bits1(&h->gb);
19631963 }
19641964 }
19651965 }
@@ -2039,7 +2039,7 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 73 unmodified lines
20392039 int use_intra_dc_vlc;
20402040
20412041 do {
2042− cbpc = get_vlc2(&h->c.gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
2042+ cbpc = get_vlc2(&h->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
20432043 if (cbpc < 0) {
20442044 av_log(h->c.avctx, AV_LOG_ERROR,
20452045 "I cbpc damaged at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -2051,13 +2051,13 @@ static int mpeg4_decode_mb(H263DecContext *const h) · 5 unmodified lines
20512051 h->c.mb_intra = 1;
20522052
20532053 intra:
2054− h->c.ac_pred = get_bits1(&h->c.gb);
2054+ h->c.ac_pred = get_bits1(&h->gb);
20552055 if (h->c.ac_pred)
20562056 h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
20572057 else
20582058 h->c.cur_pic.mb_type[xy] = MB_TYPE_INTRA;
20592059
2060− cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
2060+ cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
20612061 if (cbpy < 0) {
20622062 av_log(h->c.avctx, AV_LOG_ERROR,
20632063 "I cbpy damaged at %d %d\n", h->c.mb_x, h->c.mb_y);
@@ -2068,10 +2068,10 @@ intra: · 4 unmodified lines
20682068 use_intra_dc_vlc = h->c.qscale < ctx->intra_dc_threshold;
20692069
20702070 if (dquant)
2071− ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->c.gb, 2)]);
2071+ ff_set_qscale(&h->c, h->c.qscale + quant_tab[get_bits(&h->gb, 2)]);
20722072
20732073 if (!h->c.progressive_sequence)
2074− h->c.interlaced_dct = get_bits1(&h->c.gb);
2074+ h->c.interlaced_dct = get_bits1(&h->gb);
20752075
20762076 h->c.bdsp.clear_blocks(h->block[0]);
20772077 /* decode each block */
@@ -2173,24 +2173,24 @@ static int mpeg4_decode_studio_block(Mpeg4DecContext *const ctx, int32_t block[6 · 95 unmodified lines
21732173
21742174 if (n < 4) {
21752175 cc = 0;
2176− dct_dc_size = get_vlc2(&h->c.gb, studio_luma_dc, STUDIO_INTRA_BITS, 2);
2176+ dct_dc_size = get_vlc2(&h->gb, studio_luma_dc, STUDIO_INTRA_BITS, 2);
21772177 quant_matrix = h->c.intra_matrix;
21782178 } else {
21792179 cc = (n & 1) + 1;
21802180 if (ctx->rgb)
2181− dct_dc_size = get_vlc2(&h->c.gb, studio_luma_dc, STUDIO_INTRA_BITS, 2);
2181+ dct_dc_size = get_vlc2(&h->gb, studio_luma_dc, STUDIO_INTRA_BITS, 2);
21822182 else
2183− dct_dc_size = get_vlc2(&h->c.gb, studio_chroma_dc, STUDIO_INTRA_BITS, 2);
2183+ dct_dc_size = get_vlc2(&h->gb, studio_chroma_dc, STUDIO_INTRA_BITS, 2);
21842184 quant_matrix = h->c.chroma_intra_matrix;
21852185 }
21862186
21872187 if (dct_dc_size == 0) {
21882188 dct_diff = 0;
21892189 } else {
2190− dct_diff = get_xbits(&h->c.gb, dct_dc_size);
2190+ dct_diff = get_xbits(&h->gb, dct_dc_size);
21912191
21922192 if (dct_dc_size > 8) {
2193− if(!check_marker(h->c.avctx, &h->c.gb, "dct_dc_size > 8"))
2193+ if(!check_marker(h->c.avctx, &h->gb, "dct_dc_size > 8"))
21942194 return AVERROR_INVALIDDATA;
21952195 }
21962196
@@ -2209,7 +2209,7 @@ static int mpeg4_decode_studio_block(Mpeg4DecContext *const ctx, int32_t block[6 · 12 unmodified lines
22092209
22102210 /* AC Coefficients */
22112211 while (1) {
2212− group = get_vlc2(&h->c.gb, cur_vlc, STUDIO_INTRA_BITS, 2);
2212+ group = get_vlc2(&h->gb, cur_vlc, STUDIO_INTRA_BITS, 2);
22132213
22142214 if (group < 0) {
22152215 av_log(h->c.avctx, AV_LOG_ERROR, "illegal ac coefficient group vlc\n");
@@ -2226,12 +2226,12 @@ static int mpeg4_decode_studio_block(Mpeg4DecContext *const ctx, int32_t block[6 · 10 unmodified lines
22262226 /* Zero run length (Table B.47) */
22272227 run = 1 << additional_code_len;
22282228 if (additional_code_len)
2229− run += get_bits(&h->c.gb, additional_code_len);
2229+ run += get_bits(&h->gb, additional_code_len);
22302230 idx += run;
22312231 continue;
22322232 } else if (group >= 7 && group <= 12) {
22332233 /* Zero run length and +/-1 level (Table B.48) */
2234− code = get_bits(&h->c.gb, additional_code_len);
2234+ code = get_bits(&h->gb, additional_code_len);
22352235 sign = code & 1;
22362236 code >>= 1;
22372237 run = (1 << (additional_code_len - 1)) + code;
@@ -2245,14 +2245,14 @@ static int mpeg4_decode_studio_block(Mpeg4DecContext *const ctx, int32_t block[6 · 7 unmodified lines
22452245 if (idx > 63)
22462246 return AVERROR_INVALIDDATA;
22472247 j = scantable[idx++];
2248− block[j] = get_xbits(&h->c.gb, additional_code_len);
2248+ block[j] = get_xbits(&h->gb, additional_code_len);
22492249 } else if (group == 21) {
22502250 /* Escape */
22512251 if (idx > 63)
22522252 return AVERROR_INVALIDDATA;
22532253 j = scantable[idx++];
22542254 additional_code_len = h->c.avctx->bits_per_raw_sample + ctx->dct_precision + 4;
2255− flc = get_bits(&h->c.gb, additional_code_len);
2255+ flc = get_bits(&h->gb, additional_code_len);
22562256 if (flc >> (additional_code_len-1))
22572257 block[j] = -1 * (( flc ^ ((1 << additional_code_len) -1)) + 1);
22582258 else
@@ -2278,14 +2278,14 @@ static int mpeg4_decode_dpcm_macroblock(Mpeg4DecContext *const ctx, · 19 unmodified lines
22782278 height = 16 >> (n ? h->c.chroma_y_shift : 0);
22792279 w = 16 >> (n ? h->c.chroma_x_shift : 0);
22802280
2281− block_mean = get_bits(&h->c.gb, h->c.avctx->bits_per_raw_sample);
2281+ block_mean = get_bits(&h->gb, h->c.avctx->bits_per_raw_sample);
22822282 if (block_mean == 0){
22832283 av_log(h->c.avctx, AV_LOG_ERROR, "Forbidden block_mean\n");
22842284 return AVERROR_INVALIDDATA;
22852285 }
22862286 h->c.last_dc[n] = block_mean * (1 << (ctx->dct_precision + h->c.intra_dc_precision));
22872287
2288− rice_parameter = get_bits(&h->c.gb, 4);
2288+ rice_parameter = get_bits(&h->gb, 4);
22892289 if (rice_parameter == 0) {
22902290 av_log(h->c.avctx, AV_LOG_ERROR, "Forbidden rice_parameter\n");
22912291 return AVERROR_INVALIDDATA;
@@ -2307,17 +2307,17 @@ static int mpeg4_decode_dpcm_macroblock(Mpeg4DecContext *const ctx, · 15 unmodified lines
23072307 left = output;
23082308 topleft = top;
23092309
2310− rice_prefix_code = get_unary(&h->c.gb, 1, 12);
2310+ rice_prefix_code = get_unary(&h->gb, 1, 12);
23112311
23122312 /* Escape */
23132313 if (rice_prefix_code == 11)
2314− dpcm_residual = get_bits(&h->c.gb, h->c.avctx->bits_per_raw_sample);
2314+ dpcm_residual = get_bits(&h->gb, h->c.avctx->bits_per_raw_sample);
23152315 else {
23162316 if (rice_prefix_code == 12) {
23172317 av_log(h->c.avctx, AV_LOG_ERROR, "Forbidden rice_prefix_code\n");
23182318 return AVERROR_INVALIDDATA;
23192319 }
2320− rice_suffix_code = get_bitsz(&h->c.gb, rice_parameter);
2320+ rice_suffix_code = get_bitsz(&h->gb, rice_parameter);
23212321 dpcm_residual = (rice_prefix_code << rice_parameter) + rice_suffix_code;
23222322 }
23232323
@@ -2363,12 +2363,12 @@ static int mpeg4_decode_studio_mb(H263DecContext *const h) · 39 unmodified lines
23632363 /* StudioMacroblock */
23642364 /* Assumes I-VOP */
23652365 h->c.mb_intra = 1;
2366− if (get_bits1(&h->c.gb)) { /* compression_mode */
2366+ if (get_bits1(&h->gb)) { /* compression_mode */
23672367 /* DCT */
23682368 /* macroblock_type, 1 or 2-bit VLC */
2369− if (!get_bits1(&h->c.gb)) {
2370− skip_bits1(&h->c.gb);
2371− h->c.qscale = mpeg_get_qscale(&h->c);
2369+ if (!get_bits1(&h->gb)) {
2370+ skip_bits1(&h->gb);
2371+ h->c.qscale = mpeg_get_qscale(&h->gb, h->c.q_scale_type);
23722372 }
23732373
23742374 for (i = 0; i < mpeg4_block_count[h->c.chroma_format]; i++) {
@@ -2377,25 +2377,25 @@ static int mpeg4_decode_studio_mb(H263DecContext *const h) · 2 unmodified lines
23772377 }
23782378 } else {
23792379 /* DPCM */
2380− check_marker(h->c.avctx, &h->c.gb, "DPCM block start");
2381− ctx->dpcm_direction = get_bits1(&h->c.gb) ? -1 : 1;
2380+ check_marker(h->c.avctx, &h->gb, "DPCM block start");
2381+ ctx->dpcm_direction = get_bits1(&h->gb) ? -1 : 1;
23822382 for (i = 0; i < 3; i++) {
23832383 if (mpeg4_decode_dpcm_macroblock(ctx, ctx->dpcm_macroblock[i], i) < 0)
23842384 return AVERROR_INVALIDDATA;
23852385 }
23862386 }
23872387
2388− if (get_bits_left(&h->c.gb) >= 24 && show_bits(&h->c.gb, 23) == 0) {
2389− next_start_code_studio(&h->c.gb);
2388+ if (get_bits_left(&h->gb) >= 24 && show_bits(&h->gb, 23) == 0) {
2389+ next_start_code_studio(&h->gb);
23902390 return SLICE_END;
23912391 }
23922392
23932393 //vcon-stp9L1.bits (first frame)
2394− if (get_bits_left(&h->c.gb) == 0)
2394+ if (get_bits_left(&h->gb) == 0)
23952395 return SLICE_END;
23962396
23972397 //vcon-stp2L1.bits, vcon-stp3L1.bits, vcon-stp6L1.bits, vcon-stp7L1.bits, vcon-stp8L1.bits, vcon-stp10L1.bits (first frame)
2398− if (get_bits_left(&h->c.gb) < 8U && show_bits(&h->c.gb, get_bits_left(&h->c.gb)) == 0)
2398+ if (get_bits_left(&h->gb) < 8U && show_bits(&h->gb, get_bits_left(&h->gb)) == 0)
23992399 return SLICE_END;
24002400
24012401 return SLICE_OK;
@@ -3743,9 +3743,9 @@ int ff_mpeg4_decode_picture_header(H263DecContext *const h) · 1341 unmodified lines
37433743 h->c.skipped_last_frame = 0;
37443744
37453745 if (ctx->bitstream_buffer) {
3746− int buf_size = get_bits_left(&h->c.gb) / 8U;
3746+ int buf_size = get_bits_left(&h->gb) / 8U;
37473747 int bitstream_buffer_size = ctx->bitstream_buffer->size;
3748− const uint8_t *buf = h->c.gb.buffer;
3748+ const uint8_t *buf = h->gb.buffer;
37493749
37503750 if (h->c.divx_packed) {
37513751 for (int i = 0; i < buf_size - 3; i++) {
@@ -3760,7 +3760,7 @@ int ff_mpeg4_decode_picture_header(H263DecContext *const h) · 8 unmodified lines
37603760 }
37613761 ctx->bitstream_buffer->size = 0;
37623762 if (bitstream_buffer_size && (h->c.divx_packed || buf_size <= MAX_NVOP_SIZE)) {// divx 5.01+/xvid frame reorder
3763− int ret = init_get_bits8(&h->c.gb, ctx->bitstream_buffer->data,
3763+ int ret = init_get_bits8(&h->gb, ctx->bitstream_buffer->data,
37643764 bitstream_buffer_size);
37653765 if (ret < 0)
37663766 return ret;
@@ -3768,7 +3768,7 @@ int ff_mpeg4_decode_picture_header(H263DecContext *const h) · 1 unmodified line
37683768 av_buffer_unref(&ctx->bitstream_buffer);
37693769 }
37703770
3771− return ff_mpeg4_parse_picture_header(ctx, &h->c.gb, 0, 0);
3771+ return ff_mpeg4_parse_picture_header(ctx, &h->gb, 0, 0);
37723772 }
37733773
37743774 int ff_mpeg4_frame_end(AVCodecContext *avctx, const AVPacket *pkt)
@@ -3781,7 +3781,7 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const AVPacket *pkt) · 6 unmodified lines
37813781
37823782 /* divx 5.01+ bitstream reorder stuff */
37833783 if (h->c.divx_packed) {
3784− int current_pos = ctx->bitstream_buffer && h->c.gb.buffer == ctx->bitstream_buffer->data ? 0 : (get_bits_count(&h->c.gb) >> 3);
3784+ int current_pos = ctx->bitstream_buffer && h->gb.buffer == ctx->bitstream_buffer->data ? 0 : (get_bits_count(&h->gb) >> 3);
37853785 int startcode_found = 0;
37863786 uint8_t *buf = pkt->data;
37873787 int buf_size = pkt->size;
libavcodec/mpegvideo.h+0−1
@@ -219,7 +219,6 @@ typedef struct MpegEncContext { · 218 unmodified lines
219219 /* error concealment / resync */
220220 int resync_mb_x; ///< x position of last resync marker
221221 int resync_mb_y; ///< y position of last resync marker
222− GetBitContext last_resync_gb; ///< used to search for the next resync marker
223222 int mb_num_left; ///< number of MBs left in this video packet (for partitioned Slices only)
224223
225224 /* H.263 specific */
libavcodec/mpegvideodec.h+3−3
@@ -77,10 +77,10 @@ int ff_mpv_decode_close(AVCodecContext *avctx); · 76 unmodified lines
7777
7878 void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict);
7979
80−static inline int mpeg_get_qscale(MpegEncContext *s)
80+static inline int mpeg_get_qscale(GetBitContext *const gb, int q_scale_type)
8181 {
82− int qscale = get_bits(&s->gb, 5);
83− if (s->q_scale_type)
82+ int qscale = get_bits(gb, 5);
83+ if (q_scale_type)
8484 return ff_mpeg2_non_linear_qscale[qscale];
8585 else
8686 return qscale << 1;
libavcodec/msmpeg4dec.c+94−94
@@ -78,7 +78,7 @@ static int msmpeg4v2_decode_motion(H263DecContext *const h, int pred, int f_code · 77 unmodified lines
7878 {
7979 int code, val, sign, shift;
8080
81− code = get_vlc2(&h->c.gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
81+ code = get_vlc2(&h->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
8282 ff_dlog(h->c.avctx, "MV code %d at %d %d pred: %d\n",
8383 code, h->c.mb_x,h->c.mb_y, pred);
8484 if (code < 0)
@@ -86,12 +86,12 @@ static int msmpeg4v2_decode_motion(H263DecContext *const h, int pred, int f_code · 1 unmodified line
8686
8787 if (code == 0)
8888 return pred;
89− sign = get_bits1(&h->c.gb);
89+ sign = get_bits1(&h->gb);
9090 shift = f_code - 1;
9191 val = code;
9292 if (shift) {
9393 val = (val - 1) << shift;
94− val |= get_bits(&h->c.gb, shift);
94+ val |= get_bits(&h->gb, shift);
9595 val++;
9696 }
9797 if (sign)
@@ -114,7 +114,7 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h) · 16 unmodified lines
114114
115115 if (h->c.pict_type == AV_PICTURE_TYPE_P) {
116116 if (ms->use_skip_mb_code) {
117− if (get_bits1(&h->c.gb)) {
117+ if (get_bits1(&h->gb)) {
118118 /* skip mb */
119119 h->c.mb_intra = 0;
120120 for(i=0;i<6;i++)
@@ -130,9 +130,9 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h) · 9 unmodified lines
130130 }
131131
132132 if (h->c.msmpeg4_version == MSMP4_V2)
133− code = get_vlc2(&h->c.gb, v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 1);
133+ code = get_vlc2(&h->gb, v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 1);
134134 else
135− code = get_vlc2(&h->c.gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
135+ code = get_vlc2(&h->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
136136 if(code<0 || code>7){
137137 av_log(h->c.avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n",
138138 code, h->c.mb_x, h->c.mb_y);
@@ -145,9 +145,9 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h) · 6 unmodified lines
145145 } else {
146146 h->c.mb_intra = 1;
147147 if (h->c.msmpeg4_version == MSMP4_V2)
148− cbp = get_vlc2(&h->c.gb, v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 1);
148+ cbp = get_vlc2(&h->gb, v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 1);
149149 else
150− cbp = get_vlc2(&h->c.gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
150+ cbp = get_vlc2(&h->gb, ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 2);
151151 if(cbp<0 || cbp>3){
152152 av_log(h->c.avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n",
153153 cbp, h->c.mb_x, h->c.mb_y);
@@ -158,7 +158,7 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h) · 4 unmodified lines
158158 if (!h->c.mb_intra) {
159159 int mx, my, cbpy;
160160
161− cbpy = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
161+ cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
162162 if(cbpy<0){
163163 av_log(h->c.avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n",
164164 cbp, h->c.mb_x, h->c.mb_y);
@@ -181,8 +181,8 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h) · 16 unmodified lines
181181 } else {
182182 int v;
183183 if (h->c.msmpeg4_version == MSMP4_V2) {
184− h->c.ac_pred = get_bits1(&h->c.gb);
185− v = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
184+ h->c.ac_pred = get_bits1(&h->gb);
185+ v = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
186186 if (v < 0) {
187187 av_log(h->c.avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
188188 return -1;
@@ -190,7 +190,7 @@ static int msmpeg4v12_decode_mb(H263DecContext *const h) · 1 unmodified line
190190 cbp|= v<<2;
191191 } else{
192192 h->c.ac_pred = 0;
193− v = get_vlc2(&h->c.gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
193+ v = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
194194 if (v < 0) {
195195 av_log(h->c.avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
196196 return -1;
@@ -220,12 +220,12 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h) · 23 unmodified lines
220220 uint8_t *coded_val;
221221 uint32_t * const mb_type_ptr = &h->c.cur_pic.mb_type[h->c.mb_x + h->c.mb_y*h->c.mb_stride];
222222
223− if (get_bits_left(&h->c.gb) <= 0)
223+ if (get_bits_left(&h->gb) <= 0)
224224 return AVERROR_INVALIDDATA;
225225
226226 if (h->c.pict_type == AV_PICTURE_TYPE_P) {
227227 if (ms->use_skip_mb_code) {
228− if (get_bits1(&h->c.gb)) {
228+ if (get_bits1(&h->gb)) {
229229 /* skip mb */
230230 h->c.mb_intra = 0;
231231 for(i=0;i<6;i++)
@@ -241,14 +241,14 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h) · 9 unmodified lines
241241 }
242242 }
243243
244− code = get_vlc2(&h->c.gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX], MB_NON_INTRA_VLC_BITS, 3);
244+ code = get_vlc2(&h->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX], MB_NON_INTRA_VLC_BITS, 3);
245245 //h->c.mb_intra = (code & 0x40) ? 0 : 1;
246246 h->c.mb_intra = (~code & 0x40) >> 6;
247247
248248 cbp = code & 0x3f;
249249 } else {
250250 h->c.mb_intra = 1;
251− code = get_vlc2(&h->c.gb, ff_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 2);
251+ code = get_vlc2(&h->gb, ff_msmp4_mb_i_vlc, MSMP4_MB_INTRA_VLC_BITS, 2);
252252 /* predict coded block pattern */
253253 cbp = 0;
254254 for(i=0;i<6;i++) {
@@ -265,7 +265,7 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h) · 10 unmodified lines
265265 if (!h->c.mb_intra) {
266266 int mx, my;
267267 if (ms->per_mb_rl_table && cbp) {
268− ms->rl_table_index = decode012(&h->c.gb);
268+ ms->rl_table_index = decode012(&h->gb);
269269 ms->rl_chroma_table_index = ms->rl_table_index;
270270 }
271271 ff_h263_pred_motion(&h->c, 0, 0, &mx, &my);
@@ -278,16 +278,16 @@ static int msmpeg4v34_decode_mb(H263DecContext *const h) · 6 unmodified lines
278278 } else {
279279 ff_dlog(h->c.avctx, "I at %d %d %d %06X\n", h->c.mb_x, h->c.mb_y,
280280 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
281− show_bits(&h->c.gb, 24));
282− h->c.ac_pred = get_bits1(&h->c.gb);
281+ show_bits(&h->gb, 24));
282+ h->c.ac_pred = get_bits1(&h->gb);
283283 *mb_type_ptr = MB_TYPE_INTRA;
284284 if (h->c.inter_intra_pred) {
285− h->c.h263_aic_dir = get_vlc2(&h->c.gb, ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 1);
285+ h->c.h263_aic_dir = get_vlc2(&h->gb, ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 1);
286286 ff_dlog(h->c.avctx, "%d%d %d %d/",
287287 h->c.ac_pred, h->c.h263_aic_dir, h->c.mb_x, h->c.mb_y);
288288 }
289289 if (ms->per_mb_rl_table && cbp) {
290− ms->rl_table_index = decode012(&h->c.gb);
290+ ms->rl_table_index = decode012(&h->gb);
291291 ms->rl_chroma_table_index = ms->rl_table_index;
292292 }
293293 }
@@ -409,33 +409,33 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h) · 115 unmodified lines
409409 // smallest "black/skip" frame generally contain not much recoverable content
410410 // while at the same time they have the highest computational requirements
411411 // per byte
412− if (get_bits_left(&h->c.gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
412+ if (get_bits_left(&h->gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
413413 return AVERROR_INVALIDDATA;
414414
415415 if (h->c.msmpeg4_version == MSMP4_V1) {
416− int start_code = get_bits_long(&h->c.gb, 32);
416+ int start_code = get_bits_long(&h->gb, 32);
417417 if(start_code!=0x00000100){
418418 av_log(h->c.avctx, AV_LOG_ERROR, "invalid startcode\n");
419419 return -1;
420420 }
421421
422− skip_bits(&h->c.gb, 5); // frame number */
422+ skip_bits(&h->gb, 5); // frame number */
423423 }
424424
425− h->c.pict_type = get_bits(&h->c.gb, 2) + 1;
425+ h->c.pict_type = get_bits(&h->gb, 2) + 1;
426426 if (h->c.pict_type != AV_PICTURE_TYPE_I &&
427427 h->c.pict_type != AV_PICTURE_TYPE_P){
428428 av_log(h->c.avctx, AV_LOG_ERROR, "invalid picture type\n");
429429 return -1;
430430 }
431− h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
431+ h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
432432 if (h->c.qscale == 0) {
433433 av_log(h->c.avctx, AV_LOG_ERROR, "invalid qscale\n");
434434 return -1;
435435 }
436436
437437 if (h->c.pict_type == AV_PICTURE_TYPE_I) {
438− code = get_bits(&h->c.gb, 5);
438+ code = get_bits(&h->gb, 5);
439439 if (h->c.msmpeg4_version == MSMP4_V1) {
440440 if(code==0 || code>h->c.mb_height) {
441441 av_log(h->c.avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
@@ -462,25 +462,25 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h) · 20 unmodified lines
462462 ms->dc_table_index = 0; //not used
463463 break;
464464 case MSMP4_V3:
465− ms->rl_chroma_table_index = decode012(&h->c.gb);
466− ms->rl_table_index = decode012(&h->c.gb);
465+ ms->rl_chroma_table_index = decode012(&h->gb);
466+ ms->rl_table_index = decode012(&h->gb);
467467
468− ms->dc_table_index = get_bits1(&h->c.gb);
468+ ms->dc_table_index = get_bits1(&h->gb);
469469 break;
470470 case MSMP4_WMV1:
471471 ff_msmpeg4_decode_ext_header(h, (2+5+5+17+7)/8);
472472
473473 if (ms->bit_rate > MBAC_BITRATE)
474− ms->per_mb_rl_table = get_bits1(&h->c.gb);
474+ ms->per_mb_rl_table = get_bits1(&h->gb);
475475 else
476476 ms->per_mb_rl_table = 0;
477477
478478 if (!ms->per_mb_rl_table) {
479− ms->rl_chroma_table_index = decode012(&h->c.gb);
480− ms->rl_table_index = decode012(&h->c.gb);
479+ ms->rl_chroma_table_index = decode012(&h->gb);
480+ ms->rl_table_index = decode012(&h->gb);
481481 }
482482
483− ms->dc_table_index = get_bits1(&h->c.gb);
483+ ms->dc_table_index = get_bits1(&h->gb);
484484 h->c.inter_intra_pred= 0;
485485 break;
486486 default:
@@ -502,37 +502,37 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h) · 15 unmodified lines
502502 if (h->c.msmpeg4_version == MSMP4_V1)
503503 ms->use_skip_mb_code = 1;
504504 else
505− ms->use_skip_mb_code = get_bits1(&h->c.gb);
505+ ms->use_skip_mb_code = get_bits1(&h->gb);
506506 ms->rl_table_index = 2;
507507 ms->rl_chroma_table_index = ms->rl_table_index;
508508 ms->dc_table_index = 0; //not used
509509 ms->mv_table_index = 0;
510510 break;
511511 case MSMP4_V3:
512− ms->use_skip_mb_code = get_bits1(&h->c.gb);
513− ms->rl_table_index = decode012(&h->c.gb);
512+ ms->use_skip_mb_code = get_bits1(&h->gb);
513+ ms->rl_table_index = decode012(&h->gb);
514514 ms->rl_chroma_table_index = ms->rl_table_index;
515515
516− ms->dc_table_index = get_bits1(&h->c.gb);
516+ ms->dc_table_index = get_bits1(&h->gb);
517517
518− ms->mv_table_index = get_bits1(&h->c.gb);
518+ ms->mv_table_index = get_bits1(&h->gb);
519519 break;
520520 case MSMP4_WMV1:
521− ms->use_skip_mb_code = get_bits1(&h->c.gb);
521+ ms->use_skip_mb_code = get_bits1(&h->gb);
522522
523523 if (ms->bit_rate > MBAC_BITRATE)
524− ms->per_mb_rl_table = get_bits1(&h->c.gb);
524+ ms->per_mb_rl_table = get_bits1(&h->gb);
525525 else
526526 ms->per_mb_rl_table = 0;
527527
528528 if (!ms->per_mb_rl_table) {
529− ms->rl_table_index = decode012(&h->c.gb);
529+ ms->rl_table_index = decode012(&h->gb);
530530 ms->rl_chroma_table_index = ms->rl_table_index;
531531 }
532532
533− ms->dc_table_index = get_bits1(&h->c.gb);
533+ ms->dc_table_index = get_bits1(&h->gb);
534534
535− ms->mv_table_index = get_bits1(&h->c.gb);
535+ ms->mv_table_index = get_bits1(&h->gb);
536536 h->c.inter_intra_pred = h->c.width*h->c.height < 320*240 &&
537537 ms->bit_rate <= II_BITRATE;
538538 break;
@@ -568,15 +568,15 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h) · 29 unmodified lines
568568 int ff_msmpeg4_decode_ext_header(H263DecContext *const h, int buf_size)
569569 {
570570 MSMP4DecContext *const ms = mpv_to_msmpeg4(h);
571− int left= buf_size*8 - get_bits_count(&h->c.gb);
571+ int left = buf_size*8 - get_bits_count(&h->gb);
572572 int length = h->c.msmpeg4_version >= MSMP4_V3 ? 17 : 16;
573573 /* the alt_bitstream reader could read over the end so we need to check it */
574574 if(left>=length && left<length+8)
575575 {
576− skip_bits(&h->c.gb, 5); /* fps */
577− ms->bit_rate = get_bits(&h->c.gb, 11) * 1024;
576+ skip_bits(&h->gb, 5); /* fps */
577+ ms->bit_rate = get_bits(&h->gb, 11) * 1024;
578578 if (h->c.msmpeg4_version >= MSMP4_V3)
579− ms->flipflop_rounding = get_bits1(&h->c.gb);
579+ ms->flipflop_rounding = get_bits1(&h->gb);
580580 else
581581 ms->flipflop_rounding = 0;
582582 }
@@ -601,9 +601,9 @@ static int msmpeg4_decode_dc(MSMP4DecContext *const ms, int n, int *dir_ptr) · 18 unmodified lines
601601
602602 if (h->c.msmpeg4_version <= MSMP4_V2) {
603603 if (n < 4) {
604− level = get_vlc2(&h->c.gb, v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 3);
604+ level = get_vlc2(&h->gb, v2_dc_lum_vlc, MSMP4_DC_VLC_BITS, 3);
605605 } else {
606− level = get_vlc2(&h->c.gb, v2_dc_chroma_vlc, MSMP4_DC_VLC_BITS, 3);
606+ level = get_vlc2(&h->gb, v2_dc_chroma_vlc, MSMP4_DC_VLC_BITS, 3);
607607 }
608608 if (level < 0) {
609609 av_log(h->c.avctx, AV_LOG_ERROR, "illegal dc vlc\n");
@@ -612,15 +612,15 @@ static int msmpeg4_decode_dc(MSMP4DecContext *const ms, int n, int *dir_ptr) · 2 unmodified lines
612612 }
613613 level-=256;
614614 } else {
615− level = get_vlc2(&h->c.gb, ff_msmp4_dc_vlc[ms->dc_table_index][n >= 4],
615+ level = get_vlc2(&h->gb, ff_msmp4_dc_vlc[ms->dc_table_index][n >= 4],
616616 MSMP4_DC_VLC_BITS, 3);
617617
618618 if (level == DC_MAX) {
619− level = get_bits(&h->c.gb, 8);
620− if (get_bits1(&h->c.gb))
619+ level = get_bits(&h->gb, 8);
620+ if (get_bits1(&h->gb))
621621 level = -level;
622622 } else if (level != 0) {
623− if (get_bits1(&h->c.gb))
623+ if (get_bits1(&h->gb))
624624 level = -level;
625625 }
626626 }
@@ -721,58 +721,58 @@ int ff_msmpeg4_decode_block(MSMP4DecContext *const ms, int16_t * block, · 94 unmodified lines
721721 rl_vlc= rl->rl_vlc[h->c.qscale];
722722 }
723723 {
724− OPEN_READER(re, &h->c.gb);
724+ OPEN_READER(re, &h->gb);
725725 for(;;) {
726− UPDATE_CACHE(re, &h->c.gb);
727− GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 0);
726+ UPDATE_CACHE(re, &h->gb);
727+ GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
728728 if (level==0) {
729729 int cache;
730− cache= GET_CACHE(re, &h->c.gb);
730+ cache= GET_CACHE(re, &h->gb);
731731 /* escape */
732732 if (h->c.msmpeg4_version == MSMP4_V1 || (cache&0x80000000)==0) {
733733 if (h->c.msmpeg4_version == MSMP4_V1 || (cache&0x40000000)==0) {
734734 /* third escape */
735735 if (h->c.msmpeg4_version != MSMP4_V1)
736− LAST_SKIP_BITS(re, &h->c.gb, 2);
737− UPDATE_CACHE(re, &h->c.gb);
736+ LAST_SKIP_BITS(re, &h->gb, 2);
737+ UPDATE_CACHE(re, &h->gb);
738738 if (h->c.msmpeg4_version <= MSMP4_V3) {
739− last = SHOW_UBITS(re, &h->c.gb, 1); SKIP_CACHE(re, &h->c.gb, 1);
740− run = SHOW_UBITS(re, &h->c.gb, 6); SKIP_CACHE(re, &h->c.gb, 6);
741− level = SHOW_SBITS(re, &h->c.gb, 8);
742− SKIP_COUNTER(re, &h->c.gb, 1 + 6 + 8);
739+ last = SHOW_UBITS(re, &h->gb, 1); SKIP_CACHE(re, &h->gb, 1);
740+ run = SHOW_UBITS(re, &h->gb, 6); SKIP_CACHE(re, &h->gb, 6);
741+ level = SHOW_SBITS(re, &h->gb, 8);
742+ SKIP_COUNTER(re, &h->gb, 1 + 6 + 8);
743743 }else{
744744 int sign;
745− last = SHOW_UBITS(re, &h->c.gb, 1); SKIP_BITS(re, &h->c.gb, 1);
745+ last = SHOW_UBITS(re, &h->gb, 1); SKIP_BITS(re, &h->gb, 1);
746746 if (!ms->esc3_level_length) {
747747 int ll;
748748 ff_dlog(h->c.avctx, "ESC-3 %X at %d %d\n",
749− show_bits(&h->c.gb, 24), h->c.mb_x, h->c.mb_y);
749+ show_bits(&h->gb, 24), h->c.mb_x, h->c.mb_y);
750750 if (h->c.qscale < 8) {
751− ll = SHOW_UBITS(re, &h->c.gb, 3); SKIP_BITS(re, &h->c.gb, 3);
751+ ll = SHOW_UBITS(re, &h->gb, 3); SKIP_BITS(re, &h->gb, 3);
752752 if(ll==0){
753− ll = 8+SHOW_UBITS(re, &h->c.gb, 1); SKIP_BITS(re, &h->c.gb, 1);
753+ ll = 8+SHOW_UBITS(re, &h->gb, 1); SKIP_BITS(re, &h->gb, 1);
754754 }
755755 }else{
756756 ll=2;
757− while (ll < 8 && SHOW_UBITS(re, &h->c.gb, 1) == 0) {
757+ while (ll < 8 && SHOW_UBITS(re, &h->gb, 1) == 0) {
758758 ll++;
759− SKIP_BITS(re, &h->c.gb, 1);
759+ SKIP_BITS(re, &h->gb, 1);
760760 }
761− if (ll<8) SKIP_BITS(re, &h->c.gb, 1);
761+ if (ll<8) SKIP_BITS(re, &h->gb, 1);
762762 }
763763
764764 ms->esc3_level_length = ll;
765− ms->esc3_run_length = SHOW_UBITS(re, &h->c.gb, 2) + 3; SKIP_BITS(re, &h->c.gb, 2);
766− UPDATE_CACHE(re, &h->c.gb);
765+ ms->esc3_run_length = SHOW_UBITS(re, &h->gb, 2) + 3; SKIP_BITS(re, &h->gb, 2);
766+ UPDATE_CACHE(re, &h->gb);
767767 }
768− run = SHOW_UBITS(re, &h->c.gb, ms->esc3_run_length);
769− SKIP_BITS(re, &h->c.gb, ms->esc3_run_length);
768+ run = SHOW_UBITS(re, &h->gb, ms->esc3_run_length);
769+ SKIP_BITS(re, &h->gb, ms->esc3_run_length);
770770
771− sign= SHOW_UBITS(re, &h->c.gb, 1);
772− SKIP_BITS(re, &h->c.gb, 1);
771+ sign= SHOW_UBITS(re, &h->gb, 1);
772+ SKIP_BITS(re, &h->gb, 1);
773773
774− level = SHOW_UBITS(re, &h->c.gb, ms->esc3_level_length);
775− SKIP_BITS(re, &h->c.gb, ms->esc3_level_length);
774+ level = SHOW_UBITS(re, &h->gb, ms->esc3_level_length);
775+ SKIP_BITS(re, &h->gb, ms->esc3_level_length);
776776 if(sign) level= -level;
777777 }
778778
@@ -783,30 +783,30 @@ int ff_msmpeg4_decode_block(MSMP4DecContext *const ms, int16_t * block, · 4 unmodified lines
783783 if(last) i+=192;
784784 } else {
785785 /* second escape */
786− SKIP_BITS(re, &h->c.gb, 2);
787− GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 1);
786+ SKIP_BITS(re, &h->gb, 2);
787+ GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
788788 i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
789− level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
790− LAST_SKIP_BITS(re, &h->c.gb, 1);
789+ level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
790+ LAST_SKIP_BITS(re, &h->gb, 1);
791791 }
792792 } else {
793793 /* first escape */
794− SKIP_BITS(re, &h->c.gb, 1);
795− GET_RL_VLC(level, run, re, &h->c.gb, rl_vlc, TEX_VLC_BITS, 2, 1);
794+ SKIP_BITS(re, &h->gb, 1);
795+ GET_RL_VLC(level, run, re, &h->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
796796 i+= run;
797797 level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
798− level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
799− LAST_SKIP_BITS(re, &h->c.gb, 1);
798+ level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
799+ LAST_SKIP_BITS(re, &h->gb, 1);
800800 }
801801 } else {
802802 i+= run;
803− level = (level ^ SHOW_SBITS(re, &h->c.gb, 1)) - SHOW_SBITS(re, &h->c.gb, 1);
804− LAST_SKIP_BITS(re, &h->c.gb, 1);
803+ level = (level ^ SHOW_SBITS(re, &h->gb, 1)) - SHOW_SBITS(re, &h->gb, 1);
804+ LAST_SKIP_BITS(re, &h->gb, 1);
805805 }
806806 if (i > 62){
807807 i-= 192;
808808 if(i&(~63)){
809− const int left = get_bits_left(&h->c.gb);
809+ const int left = get_bits_left(&h->gb);
810810 if (((i + 192 == 64 && level / qmul == -1) ||
811811 !(h->c.avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))) &&
812812 left >= 0) {
@@ -827,7 +827,7 @@ int ff_msmpeg4_decode_block(MSMP4DecContext *const ms, int16_t * block, · 14 unmodified lines
827827
828828 block[scan_table[i]] = level;
829829 }
830− CLOSE_READER(re, &h->c.gb);
830+ CLOSE_READER(re, &h->gb);
831831 }
832832 if (h->c.mb_intra) {
833833 not_coded:
@@ -844,14 +844,14 @@ void ff_msmpeg4_decode_motion(MSMP4DecContext *const ms, int *mx_ptr, int *my_pt · 10 unmodified lines
844844 H263DecContext *const h = &ms->h;
845845 int sym, mx, my;
846846
847− sym = get_vlc2(&h->c.gb, mv_vlc, MV_VLC_BITS, 2);
847+ sym = get_vlc2(&h->gb, mv_vlc, MV_VLC_BITS, 2);
848848 if (sym) {
849849 mx = sym >> 8;
850850 my = sym & 0xFF;
851851 } else {
852852 /* Escape */
853− mx = get_bits(&h->c.gb, 6);
854− my = get_bits(&h->c.gb, 6);
853+ mx = get_bits(&h->gb, 6);
854+ my = get_bits(&h->gb, 6);
855855 }
856856
857857 mx += *mx_ptr - 32;
libavcodec/rv10.c+31−31
@@ -85,9 +85,9 @@ int ff_rv_decode_dc(H263DecContext *const h, int n) · 84 unmodified lines
8585 int code;
8686
8787 if (n < 4) {
88− code = get_vlc2(&h->c.gb, rv_dc_lum, DC_VLC_BITS, 2);
88+ code = get_vlc2(&h->gb, rv_dc_lum, DC_VLC_BITS, 2);
8989 } else {
90− code = get_vlc2(&h->c.gb, rv_dc_chrom, DC_VLC_BITS, 2);
90+ code = get_vlc2(&h->gb, rv_dc_chrom, DC_VLC_BITS, 2);
9191 if (code < 0) {
9292 av_log(h->c.avctx, AV_LOG_ERROR, "chroma dc error\n");
9393 return -1;
@@ -101,9 +101,9 @@ static int rv10_decode_picture_header(H263DecContext *const h) · 7 unmodified lines
101101 {
102102 int mb_count, pb_frame, marker, mb_xy;
103103
104− marker = get_bits1(&h->c.gb);
104+ marker = get_bits1(&h->gb);
105105
106− if (get_bits1(&h->c.gb))
106+ if (get_bits1(&h->gb))
107107 h->c.pict_type = AV_PICTURE_TYPE_P;
108108 else
109109 h->c.pict_type = AV_PICTURE_TYPE_I;
@@ -111,7 +111,7 @@ static int rv10_decode_picture_header(H263DecContext *const h) · 1 unmodified line
111111 if (!marker)
112112 av_log(h->c.avctx, AV_LOG_ERROR, "marker missing\n");
113113
114− pb_frame = get_bits1(&h->c.gb);
114+ pb_frame = get_bits1(&h->gb);
115115
116116 ff_dlog(h->c.avctx, "pict_type=%d pb_frame=%d\n", h->c.pict_type, pb_frame);
117117
@@ -120,7 +120,7 @@ static int rv10_decode_picture_header(H263DecContext *const h) · 2 unmodified lines
120120 return AVERROR_PATCHWELCOME;
121121 }
122122
123− h->c.qscale = get_bits(&h->c.gb, 5);
123+ h->c.qscale = get_bits(&h->gb, 5);
124124 if (h->c.qscale == 0) {
125125 av_log(h->c.avctx, AV_LOG_ERROR, "Invalid qscale value: 0\n");
126126 return AVERROR_INVALIDDATA;
@@ -129,9 +129,9 @@ static int rv10_decode_picture_header(H263DecContext *const h) · 2 unmodified lines
129129 if (h->c.pict_type == AV_PICTURE_TYPE_I) {
130130 if (h->c.rv10_version == 3) {
131131 /* specific MPEG like DC coding not used */
132− h->c.last_dc[0] = get_bits(&h->c.gb, 8);
133− h->c.last_dc[1] = get_bits(&h->c.gb, 8);
134− h->c.last_dc[2] = get_bits(&h->c.gb, 8);
132+ h->c.last_dc[0] = get_bits(&h->gb, 8);
133+ h->c.last_dc[1] = get_bits(&h->gb, 8);
134+ h->c.last_dc[2] = get_bits(&h->gb, 8);
135135 ff_dlog(h->c.avctx, "DC:%d %d %d\n", h->c.last_dc[0],
136136 h->c.last_dc[1], h->c.last_dc[2]);
137137 }
@@ -140,16 +140,16 @@ static int rv10_decode_picture_header(H263DecContext *const h) · 2 unmodified lines
140140 * to display the macroblocks is coded here */
141141
142142 mb_xy = h->c.mb_x + h->c.mb_y * h->c.mb_width;
143− if (show_bits(&h->c.gb, 12) == 0 || (mb_xy && mb_xy < h->c.mb_num)) {
144− h->c.mb_x = get_bits(&h->c.gb, 6); /* mb_x */
145− h->c.mb_y = get_bits(&h->c.gb, 6); /* mb_y */
146− mb_count = get_bits(&h->c.gb, 12);
143+ if (show_bits(&h->gb, 12) == 0 || (mb_xy && mb_xy < h->c.mb_num)) {
144+ h->c.mb_x = get_bits(&h->gb, 6); /* mb_x */
145+ h->c.mb_y = get_bits(&h->gb, 6); /* mb_y */
146+ mb_count = get_bits(&h->gb, 12);
147147 } else {
148148 h->c.mb_x = 0;
149149 h->c.mb_y = 0;
150150 mb_count = h->c.mb_width * h->c.mb_height;
151151 }
152− skip_bits(&h->c.gb, 3); /* ignored */
152+ skip_bits(&h->gb, 3); /* ignored */
153153
154154 return mb_count;
155155 }
@@ -163,7 +163,7 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) · 7 unmodified lines
163163 int seq, mb_pos, ret;
164164 int rpr_max;
165165
166− h->c.pict_type = pict_types[get_bits(&h->c.gb, 2)];
166+ h->c.pict_type = pict_types[get_bits(&h->gb, 2)];
167167
168168 if (h->c.low_delay && h->c.pict_type == AV_PICTURE_TYPE_B) {
169169 av_log(h->c.avctx, AV_LOG_ERROR, "low delay B\n");
@@ -174,31 +174,31 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) · 4 unmodified lines
174174 return AVERROR_INVALIDDATA;
175175 }
176176
177− if (get_bits1(&h->c.gb)) {
177+ if (get_bits1(&h->gb)) {
178178 av_log(h->c.avctx, AV_LOG_ERROR, "reserved bit set\n");
179179 return AVERROR_INVALIDDATA;
180180 }
181181
182− h->c.qscale = get_bits(&h->c.gb, 5);
182+ h->c.qscale = get_bits(&h->gb, 5);
183183 if (h->c.qscale == 0) {
184184 av_log(h->c.avctx, AV_LOG_ERROR, "Invalid qscale value: 0\n");
185185 return AVERROR_INVALIDDATA;
186186 }
187187
188188 if (RV_GET_MINOR_VER(rv->sub_id) >= 2)
189− h->c.loop_filter = get_bits1(&h->c.gb) && !h->c.avctx->lowres;
189+ h->c.loop_filter = get_bits1(&h->gb) && !h->c.avctx->lowres;
190190
191191 if (RV_GET_MINOR_VER(rv->sub_id) <= 1)
192− seq = get_bits(&h->c.gb, 8) << 7;
192+ seq = get_bits(&h->gb, 8) << 7;
193193 else
194− seq = get_bits(&h->c.gb, 13) << 2;
194+ seq = get_bits(&h->gb, 13) << 2;
195195
196196 rpr_max = h->c.avctx->extradata[1] & 7;
197197 if (rpr_max) {
198198 int f, new_w, new_h;
199199 int rpr_bits = av_log2(rpr_max) + 1;
200200
201− f = get_bits(&h->c.gb, rpr_bits);
201+ f = get_bits(&h->gb, rpr_bits);
202202
203203 if (f) {
204204 if (h->c.avctx->extradata_size < 8 + 2 * f) {
@@ -277,11 +277,11 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size) · 72 unmodified lines
277277 ff_mpeg4_init_direct_mv(&h->c);
278278 }
279279
280− h->c.no_rounding = get_bits1(&h->c.gb);
280+ h->c.no_rounding = get_bits1(&h->gb);
281281
282282 if (RV_GET_MINOR_VER(rv->sub_id) <= 1 && h->c.pict_type == AV_PICTURE_TYPE_B)
283283 // binary decoder reads 3+2 bits here but they don't seem to be used
284− skip_bits(&h->c.gb, 5);
284+ skip_bits(&h->gb, 5);
285285
286286 h->c.h263_aic = h->c.pict_type == AV_PICTURE_TYPE_I;
287287 if (h->c.h263_aic) {
@@ -416,7 +416,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, · 128 unmodified lines
416416 int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret;
417417
418418 active_bits_size = buf_size * 8;
419− init_get_bits(&h->c.gb, buf, FFMAX(buf_size, buf_size2) * 8);
419+ init_get_bits(&h->gb, buf, FFMAX(buf_size, buf_size2) * 8);
420420 if (h->c.codec_id == AV_CODEC_ID_RV10)
421421 mb_count = rv10_decode_picture_header(h);
422422 else
@@ -492,24 +492,24 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, · 69 unmodified lines
492492
493493 // Repeat the slice end check from ff_h263_decode_mb with our active
494494 // bitstream size
495− if (ret != SLICE_ERROR && active_bits_size >= get_bits_count(&h->c.gb)) {
496− int v = show_bits(&h->c.gb, 16);
495+ if (ret != SLICE_ERROR && active_bits_size >= get_bits_count(&h->gb)) {
496+ int v = show_bits(&h->gb, 16);
497497
498− if (get_bits_count(&h->c.gb) + 16 > active_bits_size)
499− v >>= get_bits_count(&h->c.gb) + 16 - active_bits_size;
498+ if (get_bits_count(&h->gb) + 16 > active_bits_size)
499+ v >>= get_bits_count(&h->gb) + 16 - active_bits_size;
500500
501501 if (!v)
502502 ret = SLICE_END;
503503 }
504− if (ret != SLICE_ERROR && active_bits_size < get_bits_count(&h->c.gb) &&
505− 8 * buf_size2 >= get_bits_count(&h->c.gb)) {
504+ if (ret != SLICE_ERROR && active_bits_size < get_bits_count(&h->gb) &&
505+ 8 * buf_size2 >= get_bits_count(&h->gb)) {
506506 active_bits_size = buf_size2 * 8;
507507 av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n",
508508 8 * buf_size, active_bits_size);
509509 ret = SLICE_OK;
510510 }
511511
512− if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&h->c.gb)) {
512+ if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&h->gb)) {
513513 av_log(h->c.avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", h->c.mb_x,
514514 h->c.mb_y);
515515 return AVERROR_INVALIDDATA;
libavcodec/vaapi_mpeg4.c+4−4
@@ -157,8 +157,8 @@ fail: · 156 unmodified lines
157157
158158 static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
159159 {
160− MpegEncContext *s = avctx->priv_data;
161− VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private;
160+ H263DecContext *const h = avctx->priv_data;
161+ VAAPIDecodePicture *pic = h->c.cur_pic.ptr->hwaccel_picture_private;
162162 VASliceParameterBufferMPEG4 slice_param;
163163 int err;
164164
@@ -166,9 +166,9 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer · 1 unmodified line
166166 .slice_data_size = size,
167167 .slice_data_offset = 0,
168168 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
169− .macroblock_offset = get_bits_count(&s->gb) % 8,
169+ .macroblock_offset = get_bits_count(&h->gb) % 8,
170170 .macroblock_number = 0,
171− .quant_scale = s->qscale,
171+ .quant_scale = h->c.qscale,
172172 };
173173
174174 err = ff_vaapi_decode_make_slice_buffer(avctx, pic,
libavcodec/wmv2dec.c+46−46
@@ -105,7 +105,7 @@ static int parse_mb_skip(WMV2DecContext *w) · 104 unmodified lines
105105 int coded_mb_count = 0;
106106 uint32_t *const mb_type = h->c.cur_pic.mb_type;
107107
108− w->skip_type = get_bits(&h->c.gb, 2);
108+ w->skip_type = get_bits(&h->gb, 2);
109109 switch (w->skip_type) {
110110 case SKIP_TYPE_NONE:
111111 for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
@@ -114,40 +114,40 @@ static int parse_mb_skip(WMV2DecContext *w) · 2 unmodified lines
114114 MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
115115 break;
116116 case SKIP_TYPE_MPEG:
117− if (get_bits_left(&h->c.gb) < h->c.mb_height * h->c.mb_width)
117+ if (get_bits_left(&h->gb) < h->c.mb_height * h->c.mb_width)
118118 return AVERROR_INVALIDDATA;
119119 for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
120120 for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
121121 mb_type[mb_y * h->c.mb_stride + mb_x] =
122− (get_bits1(&h->c.gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
122+ (get_bits1(&h->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
123123 break;
124124 case SKIP_TYPE_ROW:
125125 for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++) {
126− if (get_bits_left(&h->c.gb) < 1)
126+ if (get_bits_left(&h->gb) < 1)
127127 return AVERROR_INVALIDDATA;
128− if (get_bits1(&h->c.gb)) {
128+ if (get_bits1(&h->gb)) {
129129 for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
130130 mb_type[mb_y * h->c.mb_stride + mb_x] =
131131 MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
132132 } else {
133133 for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
134134 mb_type[mb_y * h->c.mb_stride + mb_x] =
135− (get_bits1(&h->c.gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
135+ (get_bits1(&h->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
136136 }
137137 }
138138 break;
139139 case SKIP_TYPE_COL:
140140 for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++) {
141− if (get_bits_left(&h->c.gb) < 1)
141+ if (get_bits_left(&h->gb) < 1)
142142 return AVERROR_INVALIDDATA;
143− if (get_bits1(&h->c.gb)) {
143+ if (get_bits1(&h->gb)) {
144144 for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
145145 mb_type[mb_y * h->c.mb_stride + mb_x] =
146146 MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
147147 } else {
148148 for (int mb_y = 0; mb_y < h->c.mb_height; mb_y++)
149149 mb_type[mb_y * h->c.mb_stride + mb_x] =
150− (get_bits1(&h->c.gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
150+ (get_bits1(&h->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
151151 }
152152 }
153153 break;
@@ -157,7 +157,7 @@ static int parse_mb_skip(WMV2DecContext *w) · 3 unmodified lines
157157 for (int mb_x = 0; mb_x < h->c.mb_width; mb_x++)
158158 coded_mb_count += !IS_SKIP(mb_type[mb_y * h->c.mb_stride + mb_x]);
159159
160− if (coded_mb_count > get_bits_left(&h->c.gb))
160+ if (coded_mb_count > get_bits_left(&h->gb))
161161 return AVERROR_INVALIDDATA;
162162
163163 return 0;
@@ -205,17 +205,17 @@ int ff_wmv2_decode_picture_header(H263DecContext *const h) · 41 unmodified lines
205205 {
206206 int code;
207207
208− h->c.pict_type = get_bits1(&h->c.gb) + 1;
208+ h->c.pict_type = get_bits1(&h->gb) + 1;
209209 if (h->c.pict_type == AV_PICTURE_TYPE_I) {
210− code = get_bits(&h->c.gb, 7);
210+ code = get_bits(&h->gb, 7);
211211 av_log(h->c.avctx, AV_LOG_DEBUG, "I7:%X/\n", code);
212212 }
213− h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
213+ h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
214214 if (h->c.qscale <= 0)
215215 return AVERROR_INVALIDDATA;
216216
217− if (h->c.pict_type != AV_PICTURE_TYPE_I && show_bits(&h->c.gb, 1)) {
218− GetBitContext gb = h->c.gb;
217+ if (h->c.pict_type != AV_PICTURE_TYPE_I && show_bits(&h->gb, 1)) {
218+ GetBitContext gb = h->gb;
219219 int skip_type = get_bits(&gb, 2);
220220 int run = skip_type == SKIP_TYPE_COL ? h->c.mb_width : h->c.mb_height;
221221
@@ -241,29 +241,29 @@ int ff_wmv2_decode_secondary_picture_header(H263DecContext *const h) · 19 unmodified lines
241241 memset(h->c.cur_pic.mb_type, 0,
242242 sizeof(*h->c.cur_pic.mb_type) * h->c.mb_height * h->c.mb_stride);
243243 if (w->j_type_bit)
244− w->j_type = get_bits1(&h->c.gb);
244+ w->j_type = get_bits1(&h->gb);
245245 else
246246 w->j_type = 0; // FIXME check
247247
248248 if (!w->j_type) {
249249 if (w->per_mb_rl_bit)
250− w->ms.per_mb_rl_table = get_bits1(&h->c.gb);
250+ w->ms.per_mb_rl_table = get_bits1(&h->gb);
251251 else
252252 w->ms.per_mb_rl_table = 0;
253253
254254 if (!w->ms.per_mb_rl_table) {
255− w->ms.rl_chroma_table_index = decode012(&h->c.gb);
256− w->ms.rl_table_index = decode012(&h->c.gb);
255+ w->ms.rl_chroma_table_index = decode012(&h->gb);
256+ w->ms.rl_table_index = decode012(&h->gb);
257257 }
258258
259− w->ms.dc_table_index = get_bits1(&h->c.gb);
259+ w->ms.dc_table_index = get_bits1(&h->gb);
260260
261261 // at minimum one bit per macroblock is required at least in a valid frame,
262262 // we discard frames much smaller than this. Frames smaller than 1/8 of the
263263 // smallest "black/skip" frame generally contain not much recoverable content
264264 // while at the same time they have the highest computational requirements
265265 // per byte
266− if (get_bits_left(&h->c.gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
266+ if (get_bits_left(&h->gb) * 8LL < (h->c.width+15)/16 * ((h->c.height+15)/16))
267267 return AVERROR_INVALIDDATA;
268268 }
269269 h->c.inter_intra_pred = 0;
@@ -282,35 +282,35 @@ int ff_wmv2_decode_secondary_picture_header(H263DecContext *const h) · 12 unmodified lines
282282 ret = parse_mb_skip(w);
283283 if (ret < 0)
284284 return ret;
285− cbp_index = decode012(&h->c.gb);
285+ cbp_index = decode012(&h->gb);
286286 w->cbp_table_index = wmv2_get_cbp_table_index(h->c.qscale, cbp_index);
287287
288288 if (w->mspel_bit)
289− h->c.mspel = get_bits1(&h->c.gb);
289+ h->c.mspel = get_bits1(&h->gb);
290290 else
291291 h->c.mspel = 0; // FIXME check
292292
293293 if (w->abt_flag) {
294− w->per_mb_abt = get_bits1(&h->c.gb) ^ 1;
294+ w->per_mb_abt = get_bits1(&h->gb) ^ 1;
295295 if (!w->per_mb_abt)
296− w->abt_type = decode012(&h->c.gb);
296+ w->abt_type = decode012(&h->gb);
297297 }
298298
299299 if (w->per_mb_rl_bit)
300− w->ms.per_mb_rl_table = get_bits1(&h->c.gb);
300+ w->ms.per_mb_rl_table = get_bits1(&h->gb);
301301 else
302302 w->ms.per_mb_rl_table = 0;
303303
304304 if (!w->ms.per_mb_rl_table) {
305− w->ms.rl_table_index = decode012(&h->c.gb);
305+ w->ms.rl_table_index = decode012(&h->gb);
306306 w->ms.rl_chroma_table_index = w->ms.rl_table_index;
307307 }
308308
309− if (get_bits_left(&h->c.gb) < 2)
309+ if (get_bits_left(&h->gb) < 2)
310310 return AVERROR_INVALIDDATA;
311311
312− w->ms.dc_table_index = get_bits1(&h->c.gb);
313− w->ms.mv_table_index = get_bits1(&h->c.gb);
312+ w->ms.dc_table_index = get_bits1(&h->gb);
313+ w->ms.mv_table_index = get_bits1(&h->gb);
314314
315315 h->c.inter_intra_pred = 0; // (h->c.width * h->c.height < 320 * 240 && w->ms.bit_rate <= II_BITRATE);
316316 h->c.no_rounding ^= 1;
@@ -331,7 +331,7 @@ int ff_wmv2_decode_secondary_picture_header(H263DecContext *const h) · 14 unmodified lines
331331
332332 if (w->j_type) {
333333 ff_intrax8_decode_picture(&w->x8, h->c.cur_pic.ptr,
334− &h->c.gb, &h->c.mb_x, &h->c.mb_y,
334+ &h->gb, &h->c.mb_x, &h->c.mb_y,
335335 2 * h->c.qscale, (h->c.qscale - 1) | 1,
336336 h->c.loop_filter, h->c.low_delay);
337337
@@ -351,7 +351,7 @@ static inline void wmv2_decode_motion(WMV2DecContext *w, int *mx_ptr, int *my_pt · 13 unmodified lines
351351 ff_msmpeg4_decode_motion(&w->ms, mx_ptr, my_ptr);
352352
353353 if ((((*mx_ptr) | (*my_ptr)) & 1) && h->c.mspel)
354− w->common.hshift = get_bits1(&h->c.gb);
354+ w->common.hshift = get_bits1(&h->gb);
355355 else
356356 w->common.hshift = 0;
357357 }
@@ -376,7 +376,7 @@ static int16_t *wmv2_pred_motion(WMV2DecContext *w, int *px, int *py) · 18 unmodified lines
376376 diff = 0;
377377
378378 if (diff >= 8)
379− type = get_bits1(&h->c.gb);
379+ type = get_bits1(&h->gb);
380380 else
381381 type = 2;
382382
@@ -413,13 +413,13 @@ static inline int wmv2_decode_inter_block(WMV2DecContext *w, int16_t *block, · 30 unmodified lines
413413 }
414414
415415 if (w->per_block_abt)
416− w->abt_type = decode012(&h->c.gb);
416+ w->abt_type = decode012(&h->gb);
417417 w->abt_type_table[n] = w->abt_type;
418418
419419 if (w->abt_type) {
420420 const uint8_t *scantable = w->abt_type == 1 ? ff_wmv2_scantableA : ff_wmv2_scantableB;
421421
422− sub_cbp = sub_cbp_table[decode012(&h->c.gb)];
422+ sub_cbp = sub_cbp_table[decode012(&h->gb)];
423423
424424 if (sub_cbp & 1) {
425425 ret = ff_msmpeg4_decode_block(&w->ms, block, n, 1, scantable);
@@ -468,19 +468,19 @@ static int wmv2_decode_mb(H263DecContext *const h) · 42 unmodified lines
468468 w->common.hshift = 0;
469469 return 0;
470470 }
471− if (get_bits_left(&h->c.gb) <= 0)
471+ if (get_bits_left(&h->gb) <= 0)
472472 return AVERROR_INVALIDDATA;
473473
474− code = get_vlc2(&h->c.gb, ff_mb_non_intra_vlc[w->cbp_table_index],
474+ code = get_vlc2(&h->gb, ff_mb_non_intra_vlc[w->cbp_table_index],
475475 MB_NON_INTRA_VLC_BITS, 3);
476476 h->c.mb_intra = (~code & 0x40) >> 6;
477477
478478 cbp = code & 0x3f;
479479 } else {
480480 h->c.mb_intra = 1;
481− if (get_bits_left(&h->c.gb) <= 0)
481+ if (get_bits_left(&h->gb) <= 0)
482482 return AVERROR_INVALIDDATA;
483− code = get_vlc2(&h->c.gb, ff_msmp4_mb_i_vlc,
483+ code = get_vlc2(&h->gb, ff_msmp4_mb_i_vlc,
484484 MSMP4_MB_INTRA_VLC_BITS, 2);
485485 /* predict coded block pattern */
486486 cbp = 0;
@@ -502,14 +502,14 @@ static int wmv2_decode_mb(H263DecContext *const h) · 15 unmodified lines
502502 if (cbp) {
503503 h->c.bdsp.clear_blocks(h->block[0]);
504504 if (ms->per_mb_rl_table) {
505− ms->rl_table_index = decode012(&h->c.gb);
505+ ms->rl_table_index = decode012(&h->gb);
506506 ms->rl_chroma_table_index = ms->rl_table_index;
507507 }
508508
509509 if (w->abt_flag && w->per_mb_abt) {
510− w->per_block_abt = get_bits1(&h->c.gb);
510+ w->per_block_abt = get_bits1(&h->gb);
511511 if (!w->per_block_abt)
512− w->abt_type = decode012(&h->c.gb);
512+ w->abt_type = decode012(&h->gb);
513513 } else
514514 w->per_block_abt = 0;
515515 }
@@ -534,16 +534,16 @@ static int wmv2_decode_mb(H263DecContext *const h) · 18 unmodified lines
534534 ff_dlog(h->c.avctx, "%d%d ", h->c.inter_intra_pred, cbp);
535535 ff_dlog(h->c.avctx, "I at %d %d %d %06X\n", h->c.mb_x, h->c.mb_y,
536536 ((cbp & 3) ? 1 : 0) + ((cbp & 0x3C) ? 2 : 0),
537− show_bits(&h->c.gb, 24));
538− h->c.ac_pred = get_bits1(&h->c.gb);
537+ show_bits(&h->gb, 24));
538+ h->c.ac_pred = get_bits1(&h->gb);
539539 if (h->c.inter_intra_pred) {
540− h->c.h263_aic_dir = get_vlc2(&h->c.gb, ff_inter_intra_vlc,
540+ h->c.h263_aic_dir = get_vlc2(&h->gb, ff_inter_intra_vlc,
541541 INTER_INTRA_VLC_BITS, 1);
542542 ff_dlog(h->c.avctx, "%d%d %d %d/",
543543 h->c.ac_pred, h->c.h263_aic_dir, h->c.mb_x, h->c.mb_y);
544544 }
545545 if (ms->per_mb_rl_table && cbp) {
546− ms->rl_table_index = decode012(&h->c.gb);
546+ ms->rl_table_index = decode012(&h->gb);
547547 ms->rl_chroma_table_index = ms->rl_table_index;
548548 }
549549

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t