mirror of https://git.ffmpeg.org/ffmpeg.git
diracdec: Add slice threading to HQ profile
This commit is contained in:
parent
699c2ee560
commit
bfc8a4dabe
|
@ -832,11 +832,13 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
|
|||
* VC-2 Specification ->
|
||||
* 13.5.3 hq_slice(sx,sy)
|
||||
*/
|
||||
static int decode_hq_slice(DiracContext *s, GetBitContext *gb,
|
||||
int slice_x, int slice_y)
|
||||
static int decode_hq_slice(AVCodecContext *avctx, void *arg)
|
||||
{
|
||||
int i, quant, level, orientation, quant_idx;
|
||||
uint8_t quants[MAX_DWT_LEVELS][4];
|
||||
DiracContext *s = avctx->priv_data;
|
||||
DiracSlice *slice = arg;
|
||||
GetBitContext *gb = &slice->gb;
|
||||
|
||||
skip_bits_long(gb, 8*s->highquality.prefix_bytes);
|
||||
quant_idx = get_bits(gb, 8);
|
||||
|
@ -856,7 +858,7 @@ static int decode_hq_slice(DiracContext *s, GetBitContext *gb,
|
|||
int bits_end = get_bits_count(gb) + bits_left;
|
||||
for (level = 0; level < s->wavelet_depth; level++) {
|
||||
for (orientation = !!level; orientation < 4; orientation++) {
|
||||
decode_subband(s, gb, quants[level][orientation], slice_x, slice_y, bits_end,
|
||||
decode_subband(s, gb, quants[level][orientation], slice->slice_x, slice->slice_y, bits_end,
|
||||
&s->plane[i].band[level][orientation], NULL);
|
||||
}
|
||||
}
|
||||
|
@ -873,7 +875,7 @@ static int decode_hq_slice(DiracContext *s, GetBitContext *gb,
|
|||
static int decode_lowdelay(DiracContext *s)
|
||||
{
|
||||
AVCodecContext *avctx = s->avctx;
|
||||
int slice_x, slice_y, bytes, bufsize;
|
||||
int slice_x, slice_y, bytes = 0, bufsize;
|
||||
const uint8_t *buf;
|
||||
DiracSlice *slices;
|
||||
int slice_num = 0;
|
||||
|
@ -888,11 +890,31 @@ static int decode_lowdelay(DiracContext *s)
|
|||
bufsize = get_bits_left(&s->gb);
|
||||
|
||||
if (s->hq_picture) {
|
||||
for (slice_y = 0; slice_y < s->num_y; slice_y++) {
|
||||
for (slice_x = 0; slice_x < s->num_x; slice_x++) {
|
||||
decode_hq_slice(s, &s->gb, slice_x, slice_y);
|
||||
int i;
|
||||
|
||||
for (slice_y = 0; bufsize > 0 && slice_y < s->num_y; slice_y++) {
|
||||
for (slice_x = 0; bufsize > 0 && slice_x < s->num_x; slice_x++) {
|
||||
bytes = s->highquality.prefix_bytes + 1;
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (bytes <= bufsize/8)
|
||||
bytes += buf[bytes] * s->highquality.size_scaler + 1;
|
||||
}
|
||||
|
||||
slices[slice_num].bytes = bytes;
|
||||
slices[slice_num].slice_x = slice_x;
|
||||
slices[slice_num].slice_y = slice_y;
|
||||
init_get_bits(&slices[slice_num].gb, buf, bufsize);
|
||||
slice_num++;
|
||||
|
||||
buf += bytes;
|
||||
if (bufsize/8 >= bytes)
|
||||
bufsize -= bytes*8;
|
||||
else
|
||||
bufsize = 0;
|
||||
}
|
||||
}
|
||||
avctx->execute(avctx, decode_hq_slice, slices, NULL, slice_num,
|
||||
sizeof(DiracSlice));
|
||||
} else {
|
||||
for (slice_y = 0; bufsize > 0 && slice_y < s->num_y; slice_y++) {
|
||||
for (slice_x = 0; bufsize > 0 && slice_x < s->num_x; slice_x++) {
|
||||
|
@ -2199,6 +2221,6 @@ AVCodec ff_dirac_decoder = {
|
|||
.init = dirac_decode_init,
|
||||
.close = dirac_decode_end,
|
||||
.decode = dirac_decode_frame,
|
||||
.capabilities = AV_CODEC_CAP_DELAY,
|
||||
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_DR1,
|
||||
.flush = dirac_decode_flush,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue