#include "mjpeg.h"
#include "mjpegenc.h"
-// Don't know, but let's guess 16 bits per code
-#define MJPEG_HUFFMAN_EST_BITS_PER_CODE 16
static int alloc_huffman(MpegEncContext *s)
{
size_t total_bits = 0;
size_t bytes_needed;
+ s->header_bits = get_bits_diff(s);
// Estimate the total size first
for (i = 0; i < m->huff_ncode; i++) {
table_id = m->huff_buffer[i].table_id;
}
m->huff_ncode = 0;
+ s->i_tex_bits = get_bits_diff(s);
}
/**
{
int i, is_chroma_420;
- // Number of bits used depends on future data.
- // So, nothing that relies on encoding many times and taking the
- // one with the fewest bits will work properly here.
- if (s->i_tex_bits != MJPEG_HUFFMAN_EST_BITS_PER_CODE *
- s->mjpeg_ctx->huff_ncode) {
- av_log(s->avctx, AV_LOG_ERROR, "Unsupported encoding method\n");
- return AVERROR(EINVAL);
- }
-
if (s->chroma_format == CHROMA_444) {
encode_block(s, block[0], 0);
encode_block(s, block[2], 2);
}
}
- s->i_tex_bits = MJPEG_HUFFMAN_EST_BITS_PER_CODE * s->mjpeg_ctx->huff_ncode;
return 0;
}