Commit bfc8a4da authored by Kieran Kunhya's avatar Kieran Kunhya Committed by Rostislav Pehlivanov

diracdec: Add slice threading to HQ profile

parent 699c2ee5
...@@ -832,11 +832,13 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg) ...@@ -832,11 +832,13 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
* VC-2 Specification -> * VC-2 Specification ->
* 13.5.3 hq_slice(sx,sy) * 13.5.3 hq_slice(sx,sy)
*/ */
static int decode_hq_slice(DiracContext *s, GetBitContext *gb, static int decode_hq_slice(AVCodecContext *avctx, void *arg)
int slice_x, int slice_y)
{ {
int i, quant, level, orientation, quant_idx; int i, quant, level, orientation, quant_idx;
uint8_t quants[MAX_DWT_LEVELS][4]; 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); skip_bits_long(gb, 8*s->highquality.prefix_bytes);
quant_idx = get_bits(gb, 8); quant_idx = get_bits(gb, 8);
...@@ -856,7 +858,7 @@ static int decode_hq_slice(DiracContext *s, GetBitContext *gb, ...@@ -856,7 +858,7 @@ static int decode_hq_slice(DiracContext *s, GetBitContext *gb,
int bits_end = get_bits_count(gb) + bits_left; int bits_end = get_bits_count(gb) + bits_left;
for (level = 0; level < s->wavelet_depth; level++) { for (level = 0; level < s->wavelet_depth; level++) {
for (orientation = !!level; orientation < 4; orientation++) { 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); &s->plane[i].band[level][orientation], NULL);
} }
} }
...@@ -873,7 +875,7 @@ static int decode_hq_slice(DiracContext *s, GetBitContext *gb, ...@@ -873,7 +875,7 @@ static int decode_hq_slice(DiracContext *s, GetBitContext *gb,
static int decode_lowdelay(DiracContext *s) static int decode_lowdelay(DiracContext *s)
{ {
AVCodecContext *avctx = s->avctx; AVCodecContext *avctx = s->avctx;
int slice_x, slice_y, bytes, bufsize; int slice_x, slice_y, bytes = 0, bufsize;
const uint8_t *buf; const uint8_t *buf;
DiracSlice *slices; DiracSlice *slices;
int slice_num = 0; int slice_num = 0;
...@@ -888,11 +890,31 @@ static int decode_lowdelay(DiracContext *s) ...@@ -888,11 +890,31 @@ static int decode_lowdelay(DiracContext *s)
bufsize = get_bits_left(&s->gb); bufsize = get_bits_left(&s->gb);
if (s->hq_picture) { if (s->hq_picture) {
for (slice_y = 0; slice_y < s->num_y; slice_y++) { int i;
for (slice_x = 0; slice_x < s->num_x; slice_x++) {
decode_hq_slice(s, &s->gb, slice_x, slice_y); 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 { } else {
for (slice_y = 0; bufsize > 0 && slice_y < s->num_y; slice_y++) { 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++) { for (slice_x = 0; bufsize > 0 && slice_x < s->num_x; slice_x++) {
...@@ -2199,6 +2221,6 @@ AVCodec ff_dirac_decoder = { ...@@ -2199,6 +2221,6 @@ AVCodec ff_dirac_decoder = {
.init = dirac_decode_init, .init = dirac_decode_init,
.close = dirac_decode_end, .close = dirac_decode_end,
.decode = dirac_decode_frame, .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, .flush = dirac_decode_flush,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment