*/
#include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
#include "internal.h"
#include "libavutil/attributes.h"
}
}
-static int decode_run_2bit(GetBitContext *gb, int *color)
+static int decode_run_2bit(BitstreamContext *bc, int *color)
{
unsigned int v, t;
v = 0;
for (t = 1; v < t && t <= 0x40; t <<= 2)
- v = (v << 4) | get_bits(gb, 4);
+ v = (v << 4) | bitstream_read(bc, 4);
*color = v & 3;
if (v < 4) { /* Code for fill rest of line */
return INT_MAX;
return v >> 2;
}
-static int decode_run_8bit(GetBitContext *gb, int *color)
+static int decode_run_8bit(BitstreamContext *bc, int *color)
{
int len;
- int has_run = get_bits1(gb);
- if (get_bits1(gb))
- *color = get_bits(gb, 8);
+ int has_run = bitstream_read_bit(bc);
+ if (bitstream_read_bit(bc))
+ *color = bitstream_read(bc, 8);
else
- *color = get_bits(gb, 2);
+ *color = bitstream_read(bc, 2);
if (has_run) {
- if (get_bits1(gb)) {
- len = get_bits(gb, 7);
+ if (bitstream_read_bit(bc)) {
+ len = bitstream_read(bc, 7);
if (len == 0)
len = INT_MAX;
else
len += 9;
} else
- len = get_bits(gb, 3) + 2;
+ len = bitstream_read(bc, 3) + 2;
} else
len = 1;
return len;
static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
const uint8_t *buf, int start, int buf_size, int is_8bit)
{
- GetBitContext gb;
+ BitstreamContext bc;
int bit_len;
int x, y, len, color;
uint8_t *d;
bit_len = (buf_size - start) * 8;
- init_get_bits(&gb, buf + start, bit_len);
+ bitstream_init(&bc, buf + start, bit_len);
x = 0;
y = 0;
d = bitmap;
for(;;) {
- if (get_bits_count(&gb) > bit_len)
+ if (bitstream_tell(&bc) > bit_len)
return -1;
if (is_8bit)
- len = decode_run_8bit(&gb, &color);
+ len = decode_run_8bit(&bc, &color);
else
- len = decode_run_2bit(&gb, &color);
+ len = decode_run_2bit(&bc, &color);
len = FFMIN(len, w - x);
memset(d + x, color, len);
x += len;
d += linesize;
x = 0;
/* byte align */
- align_get_bits(&gb);
+ bitstream_align(&bc);
}
}
return 0;
alpha[1] = buf[pos + 1] >> 4;
alpha[0] = buf[pos + 1] & 0x0f;
pos += 2;
- ff_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
+ ff_dlog(NULL, "alpha=%"PRIx8"%"PRIx8"%"PRIx8"%"PRIx8"\n",
+ alpha[0], alpha[1], alpha[2], alpha[3]);
break;
case 0x05:
case 0x85:
goto fail;
offset1 = AV_RB16(buf + pos);
offset2 = AV_RB16(buf + pos + 2);
- ff_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
+ ff_dlog(NULL, "offset1=0x%04"PRIx64" offset2=0x%04"PRIx64"\n", offset1, offset2);
pos += 4;
break;
case 0x86:
goto fail;
offset1 = AV_RB32(buf + pos);
offset2 = AV_RB32(buf + pos + 4);
- ff_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
+ ff_dlog(NULL, "offset1=0x%04"PRIx64" offset2=0x%04"PRIx64"\n", offset1, offset2);
pos += 8;
break;
if (h < 0)
h = 0;
if (w > 0 && h > 0) {
- int j;
- AVSubtitleRect *rect;
if (sub_header->rects) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->data[0]);
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
+{
+ int j;
+ AVSubtitleRect *rect;
rect = sub_header->rects[0];
for (j = 0; j < 4; j++) {
rect->pict.data[j] = rect->data[j];
rect->pict.linesize[j] = rect->linesize[j];
}
+}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
goto no_subtitle;
#if defined(DEBUG)
- ff_dlog(NULL, "start=%d ms end =%d ms\n",
+ ff_dlog(NULL, "start=%"PRIu32" ms end =%"PRIu32" ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save("/tmp/a.ppm", sub->rects[0]->data[0],