On Thu, May 16, 2019 at 09:35:00PM +1000, Peter Ross wrote: > +static int read_mb_value(GetBitContext *gb) > +{ > + int v = 1; > + int size; > + OPEN_READER(re, gb); > + > + do { > + int bit; > + size = 0; > + > + UPDATE_CACHE(re, gb); > + bit = SHOW_UBITS(re, gb, 1); > + SKIP_BITS(re, gb, 1); > + if (!bit) > + break; > + > + do { > + bit = SHOW_UBITS(re, gb, 1); > + SKIP_BITS(re, gb, 1); > + if (!bit) > + break; > + size++; > + } while (size < 8); > + > + v += 1 << size; > + > + } while (size == 8); > + > + if (size) { > + v += SHOW_UBITS(re, gb, size); > + LAST_SKIP_BITS(re, gb, size); > + } > + > + CLOSE_READER(re, gb); > + return v; > +}
I meant that you should do something like (could maybe be made less messy, and not sure it's really necessary to use the macro version, I think it'd prefer the plain show_bits etc) int v = 0; int bits = SHOW_UBITS(re, gb, 9); while (bits == 0x1ff) { // Note: relies on 0-padding to guarantee termination! SKIP_BITS(re, gb, 9); bits = SHOW_UBITS(re, gb, 9); } if (bits < 0x100) { LAST_SKIP_BITS(re, gb, 1); v = 1; } else if (bits < 0x180) { LAST_SKIP_BITS(re, gb, 2); v = 2; } else if (bits < 0x1c0) { LAST_SKIP_BITS(re, gb, 3 + 1); v = 3 + ((bits >> 5) & 1); } else if (bits < 0x1e0) { LAST_SKIP_BITS(re, gb, 4 + 2); v = 5 + ((bits >> 3) & 3); } else if (bits < 0x1f0) { LAST_SKIP_BITS(re, gb, 5 + 3); v = 9 + ((bits >> 1) & 7); } else if (bits < 0x1f8) { SKIP_BITS(re, gb, 6); v = 17 + SHOW_UBITS(re, gb, 4); LAST_SKIP_BITS(re, gb, 4); } else if (bits < 0x1fc) { SKIP_BITS(re, gb, 7); v = 33 + SHOW_UBITS(re, gb, 5); LAST_SKIP_BITS(re, gb, 5); } else if (bits < 0x1fe) { SKIP_BITS(re, gb, 8); v = 65 + SHOW_UBITS(re, gb, 6); LAST_SKIP_BITS(re, gb, 6); } else { SKIP_BITS(re, gb, 9); v = 127 + SHOW_UBITS(re, gb, 7); LAST_SKIP_BITS(re, gb, 7); } CLOSE_READER(re, gb); return v; _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".