@@ -23,23 +23,22 @@
/**
* @file
* Dirac Decoder
- * @author Marco Gerards <marco@gnu.org>, David Conrad, Jordi Ortiz <nenjordi@gmail.com>
+ * @author Marco Gerards <marco@gnu.org>, David Conrad, Jordi Ortiz
+ * <nenjordi@gmail.com>
*/
#include "diracdec.h"
+#include "config_components.h"
#include "hwaccels.h"
#include "hwconfig.h"
#include "libavutil/imgutils.c"
-#include "config_components.h"
/* magic number division by 3 from schroedinger */
-static inline int divide3(int x)
-{
- return (int)((x+1U)*21845 + 10922) >> 16;
+static inline int divide3(int x) {
+ return (int)((x + 1U) * 21845 + 10922) >> 16;
}
-static DiracFrame *remove_frame(DiracFrame *framelist[], unsigned picnum)
-{
+static DiracFrame *remove_frame(DiracFrame *framelist[], unsigned picnum) {
DiracFrame *remove_pic = NULL;
int i, remove_idx = -1;
@@ -51,13 +50,13 @@ static DiracFrame *remove_frame(DiracFrame *framelist[], unsigned picnum)
if (remove_pic)
for (i = remove_idx; framelist[i]; i++)
- framelist[i] = framelist[i+1];
+ framelist[i] = framelist[i + 1];
return remove_pic;
}
-static int add_frame(DiracFrame *framelist[], int maxframes, DiracFrame *frame)
-{
+static int add_frame(DiracFrame *framelist[], int maxframes,
+ DiracFrame *frame) {
int i;
for (i = 0; i < maxframes; i++)
if (!framelist[i]) {
@@ -67,9 +66,8 @@ static int add_frame(DiracFrame *framelist[], int maxframes, DiracFrame *frame)
return -1;
}
-static int alloc_sequence_buffers(DiracContext *s)
-{
- int sbwidth = DIVRNDUP(s->seq.width, 4);
+static int alloc_sequence_buffers(DiracContext *s) {
+ int sbwidth = DIVRNDUP(s->seq.width, 4);
int sbheight = DIVRNDUP(s->seq.height, 4);
int i, w, h, top_padding;
@@ -77,7 +75,7 @@ static int alloc_sequence_buffers(DiracContext *s)
for (i = 0; i < 3; i++) {
int max_xblen = MAX_BLOCKSIZE >> (i ? s->chroma_x_shift : 0);
int max_yblen = MAX_BLOCKSIZE >> (i ? s->chroma_y_shift : 0);
- w = s->seq.width >> (i ? s->chroma_x_shift : 0);
+ w = s->seq.width >> (i ? s->chroma_x_shift : 0);
h = s->seq.height >> (i ? s->chroma_y_shift : 0);
/* we allocate the max we support here since num decompositions can
@@ -85,28 +83,31 @@ static int alloc_sequence_buffers(DiracContext *s)
* 1<<MAX_DWT_LEVELS top padding to avoid if(y>0) in arith decoding
* MAX_BLOCKSIZE padding for MC: blocks can spill up to half of that
* on each side */
- top_padding = FFMAX(1<<MAX_DWT_LEVELS, max_yblen/2);
- w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); /* FIXME: Should this be 16 for SSE??? */
- h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen/2;
-
- s->plane[i].idwt.buf_base = av_calloc(w + max_xblen, h * (2 << s->pshift));
- s->plane[i].idwt.tmp = av_malloc_array((w+16), 2 << s->pshift);
- s->plane[i].idwt.buf = s->plane[i].idwt.buf_base + (top_padding*w)*(2 << s->pshift);
+ top_padding = FFMAX(1 << MAX_DWT_LEVELS, max_yblen / 2);
+ w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS),
+ 8); /* FIXME: Should this be 16 for SSE??? */
+ h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen / 2;
+
+ s->plane[i].idwt.buf_base =
+ av_calloc(w + max_xblen, h * (2 << s->pshift));
+ s->plane[i].idwt.tmp = av_malloc_array((w + 16), 2 << s->pshift);
+ s->plane[i].idwt.buf =
+ s->plane[i].idwt.buf_base + (top_padding * w) * (2 << s->pshift);
if (!s->plane[i].idwt.buf_base || !s->plane[i].idwt.tmp)
return AVERROR(ENOMEM);
}
/* fixme: allocate using real stride here */
- s->sbsplit = av_malloc_array(sbwidth, sbheight);
- s->blmotion = av_malloc_array(sbwidth, sbheight * 16 * sizeof(*s->blmotion));
+ s->sbsplit = av_malloc_array(sbwidth, sbheight);
+ s->blmotion =
+ av_malloc_array(sbwidth, sbheight * 16 * sizeof(*s->blmotion));
if (!s->sbsplit || !s->blmotion)
return AVERROR(ENOMEM);
return 0;
}
-static int alloc_buffers(DiracContext *s, int stride)
-{
+static int alloc_buffers(DiracContext *s, int stride) {
int w = s->seq.width;
int h = s->seq.height;
@@ -124,7 +125,8 @@ static int alloc_buffers(DiracContext *s, int stride)
s->edge_emu_buffer_base = av_malloc_array(stride, MAX_BLOCKSIZE);
- s->mctmp = av_malloc_array((stride+MAX_BLOCKSIZE), (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
+ s->mctmp = av_malloc_array((stride + MAX_BLOCKSIZE),
+ (h + MAX_BLOCKSIZE) * sizeof(*s->mctmp));
s->mcscratch = av_malloc_array(stride, MAX_BLOCKSIZE);
if (!s->edge_emu_buffer_base || !s->mctmp || !s->mcscratch)
@@ -134,14 +136,14 @@ static int alloc_buffers(DiracContext *s, int stride)
return 0;
}
-static void free_sequence_buffers(DiracContext *s)
-{
+static void free_sequence_buffers(DiracContext *s) {
int i, j, k;
for (i = 0; i < MAX_FRAMES; i++) {
if (s->all_frames[i].avframe->data[0]) {
av_frame_unref(s->all_frames[i].avframe);
- memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
+ memset(s->all_frames[i].interpolated, 0,
+ sizeof(s->all_frames[i].interpolated));
}
for (j = 0; j < 3; j++)
@@ -168,8 +170,7 @@ static void free_sequence_buffers(DiracContext *s)
static AVOnce dirac_arith_init = AV_ONCE_INIT;
-static av_cold int dirac_decode_init(AVCodecContext *avctx)
-{
+static av_cold int dirac_decode_init(AVCodecContext *avctx) {
DiracContext *s = avctx->priv_data;
int i, ret;
@@ -199,16 +200,14 @@ static av_cold int dirac_decode_init(AVCodecContext *avctx)
return 0;
}
-static void dirac_decode_flush(AVCodecContext *avctx)
-{
+static void dirac_decode_flush(AVCodecContext *avctx) {
DiracContext *s = avctx->priv_data;
free_sequence_buffers(s);
s->seen_sequence_header = 0;
s->frame_number = -1;
}
-static av_cold int dirac_decode_end(AVCodecContext *avctx)
-{
+static av_cold int dirac_decode_end(AVCodecContext *avctx) {
DiracContext *s = avctx->priv_data;
int i;
@@ -222,46 +221,46 @@ static av_cold int dirac_decode_end(AVCodecContext *avctx)
return 0;
}
-static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset)
-{
+static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor,
+ int qoffset) {
int coeff = dirac_get_se_golomb(gb);
const unsigned sign = FFSIGN(coeff);
if (coeff)
- coeff = sign*((sign * coeff * qfactor + qoffset) >> 2);
+ coeff = sign * ((sign * coeff * qfactor + qoffset) >> 2);
return coeff;
}
#define SIGN_CTX(x) (CTX_SIGN_ZERO + ((x) > 0) - ((x) < 0))
-#define UNPACK_ARITH(n, type) \
- static inline void coeff_unpack_arith_##n(DiracArith *c, int qfactor, int qoffset, \
- SubBand *b, type *buf, int x, int y) \
- { \
- int sign, sign_pred = 0, pred_ctx = CTX_ZPZN_F1; \
- unsigned coeff; \
- const int mstride = -(b->stride >> (1+b->pshift)); \
- if (b->parent) { \
- const type *pbuf = (type *)b->parent->ibuf; \
- const int stride = b->parent->stride >> (1+b->parent->pshift); \
- pred_ctx += !!pbuf[stride * (y>>1) + (x>>1)] << 1; \
- } \
- if (b->orientation == subband_hl) \
- sign_pred = buf[mstride]; \
- if (x) { \
- pred_ctx += !(buf[-1] | buf[mstride] | buf[-1 + mstride]); \
- if (b->orientation == subband_lh) \
- sign_pred = buf[-1]; \
- } else { \
- pred_ctx += !buf[mstride]; \
- } \
- coeff = dirac_get_arith_uint(c, pred_ctx, CTX_COEFF_DATA); \
- if (coeff) { \
- coeff = (coeff * qfactor + qoffset) >> 2; \
- sign = dirac_get_arith_bit(c, SIGN_CTX(sign_pred)); \
- coeff = (coeff ^ -sign) + sign; \
- } \
- *buf = coeff; \
- } \
+#define UNPACK_ARITH(n, type) \
+ static inline void coeff_unpack_arith_##n(DiracArith *c, int qfactor, \
+ int qoffset, SubBand *b, \
+ type *buf, int x, int y) { \
+ int sign, sign_pred = 0, pred_ctx = CTX_ZPZN_F1; \
+ unsigned coeff; \
+ const int mstride = -(b->stride >> (1 + b->pshift)); \
+ if (b->parent) { \
+ const type *pbuf = (type *)b->parent->ibuf; \
+ const int stride = b->parent->stride >> (1 + b->parent->pshift); \
+ pred_ctx += !!pbuf[stride * (y >> 1) + (x >> 1)] << 1; \
+ } \
+ if (b->orientation == subband_hl) \
+ sign_pred = buf[mstride]; \
+ if (x) { \
+ pred_ctx += !(buf[-1] | buf[mstride] | buf[-1 + mstride]); \
+ if (b->orientation == subband_lh) \
+ sign_pred = buf[-1]; \
+ } else { \
+ pred_ctx += !buf[mstride]; \
+ } \
+ coeff = dirac_get_arith_uint(c, pred_ctx, CTX_COEFF_DATA); \
+ if (coeff) { \
+ coeff = (coeff * qfactor + qoffset) >> 2; \
+ sign = dirac_get_arith_bit(c, SIGN_CTX(sign_pred)); \
+ coeff = (coeff ^ -sign) + sign; \
+ } \
+ *buf = coeff; \
+ }
UNPACK_ARITH(8, int16_t)
UNPACK_ARITH(10, int32_t)
@@ -271,10 +270,9 @@ UNPACK_ARITH(10, int32_t)
* [DIRAC_STD] 13.4.3.2 Codeblock unpacking loop. codeblock()
*/
static inline int codeblock(const DiracContext *s, SubBand *b,
- GetBitContext *gb, DiracArith *c,
- int left, int right, int top, int bottom,
- int blockcnt_one, int is_arith)
-{
+ GetBitContext *gb, DiracArith *c, int left,
+ int right, int top, int bottom, int blockcnt_one,
+ int is_arith) {
int x, y, zero_block;
int qoffset, qfactor;
uint8_t *buf;
@@ -323,9 +321,11 @@ static inline int codeblock(const DiracContext *s, SubBand *b,
return c->error;
for (x = left; x < right; x++) {
if (b->pshift) {
- coeff_unpack_arith_10(c, qfactor, qoffset, b, (int32_t*)(buf)+x, x, y);
+ coeff_unpack_arith_10(c, qfactor, qoffset, b,
+ (int32_t *)(buf) + x, x, y);
} else {
- coeff_unpack_arith_8(c, qfactor, qoffset, b, (int16_t*)(buf)+x, x, y);
+ coeff_unpack_arith_8(c, qfactor, qoffset, b,
+ (int16_t *)(buf) + x, x, y);
}
}
buf += b->stride;
@@ -337,41 +337,42 @@ static inline int codeblock(const DiracContext *s, SubBand *b,
for (x = left; x < right; x++) {
int val = coeff_unpack_golomb(gb, qfactor, qoffset);
if (b->pshift) {
- AV_WN32(&buf[4*x], val);
+ AV_WN32(&buf[4 * x], val);
} else {
- AV_WN16(&buf[2*x], val);
+ AV_WN16(&buf[2 * x], val);
}
}
buf += b->stride;
- }
- }
- return 0;
+ }
+ }
+ return 0;
}
/**
* Dirac Specification ->
* 13.3 intra_dc_prediction(band)
*/
-#define INTRA_DC_PRED(n, type) \
- static inline void intra_dc_prediction_##n(SubBand *b) \
- { \
- type *buf = (type*)b->ibuf; \
- int x, y; \
- \
- for (x = 1; x < b->width; x++) \
- buf[x] += buf[x-1]; \
- buf += (b->stride >> (1+b->pshift)); \
- \
- for (y = 1; y < b->height; y++) { \
- buf[0] += buf[-(b->stride >> (1+b->pshift))]; \
- \
- for (x = 1; x < b->width; x++) { \
- int pred = buf[x - 1] + buf[x - (b->stride >> (1+b->pshift))] + buf[x - (b->stride >> (1+b->pshift))-1]; \
- buf[x] += divide3(pred); \
- } \
- buf += (b->stride >> (1+b->pshift)); \
- } \
- } \
+#define INTRA_DC_PRED(n, type) \
+ static inline void intra_dc_prediction_##n(SubBand *b) { \
+ type *buf = (type *)b->ibuf; \
+ int x, y; \
+ \
+ for (x = 1; x < b->width; x++) \
+ buf[x] += buf[x - 1]; \
+ buf += (b->stride >> (1 + b->pshift)); \
+ \
+ for (y = 1; y < b->height; y++) { \
+ buf[0] += buf[-(b->stride >> (1 + b->pshift))]; \
+ \
+ for (x = 1; x < b->width; x++) { \
+ int pred = buf[x - 1] + \
+ buf[x - (b->stride >> (1 + b->pshift))] + \
+ buf[x - (b->stride >> (1 + b->pshift)) - 1]; \
+ buf[x] += divide3(pred); \
+ } \
+ buf += (b->stride >> (1 + b->pshift)); \
+ } \
+ }
INTRA_DC_PRED(8, int16_t)
INTRA_DC_PRED(10, uint32_t)
@@ -381,13 +382,14 @@ INTRA_DC_PRED(10, uint32_t)
* 13.4.2 Non-skipped subbands. subband_coeffs()
*/
static av_always_inline int decode_subband_internal(const DiracContext *s,
- SubBand *b, int is_arith)
-{
+ SubBand *b, int is_arith) {
int cb_x, cb_y, left, right, top, bottom;
DiracArith c;
GetBitContext gb;
- int cb_width = s->codeblock[b->level + (b->orientation != subband_ll)].width;
- int cb_height = s->codeblock[b->level + (b->orientation != subband_ll)].height;
+ int cb_width =
+ s->codeblock[b->level + (b->orientation != subband_ll)].width;
+ int cb_height =
+ s->codeblock[b->level + (b->orientation != subband_ll)].height;
int blockcnt_one = (cb_width + cb_height) == 2;
int ret;
@@ -401,11 +403,12 @@ static av_always_inline int decode_subband_internal(const DiracContext *s,
top = 0;
for (cb_y = 0; cb_y < cb_height; cb_y++) {
- bottom = (b->height * (cb_y+1LL)) / cb_height;
+ bottom = (b->height * (cb_y + 1LL)) / cb_height;
left = 0;
for (cb_x = 0; cb_x < cb_width; cb_x++) {
- right = (b->width * (cb_x+1LL)) / cb_width;
- ret = codeblock(s, b, &gb, &c, left, right, top, bottom, blockcnt_one, is_arith);
+ right = (b->width * (cb_x + 1LL)) / cb_width;
+ ret = codeblock(s, b, &gb, &c, left, right, top, bottom,
+ blockcnt_one, is_arith);
if (ret < 0)
return ret;
left = right;
@@ -423,16 +426,14 @@ static av_always_inline int decode_subband_internal(const DiracContext *s,
return 0;
}
-static int decode_subband_arith(AVCodecContext *avctx, void *b)
-{
+static int decode_subband_arith(AVCodecContext *avctx, void *b) {
const DiracContext *s = avctx->priv_data;
return decode_subband_internal(s, b, 1);
}
-static int decode_subband_golomb(AVCodecContext *avctx, void *arg)
-{
+static int decode_subband_golomb(AVCodecContext *avctx, void *arg) {
const DiracContext *s = avctx->priv_data;
- SubBand **b = arg;
+ SubBand **b = arg;
return decode_subband_internal(s, *b, 0);
}
@@ -440,13 +441,12 @@ static int decode_subband_golomb(AVCodecContext *avctx, void *arg)
* Dirac Specification ->
* [DIRAC_STD] 13.4.1 core_transform_data()
*/
-static int decode_component(DiracContext *s, int comp)
-{
+static int decode_component(DiracContext *s, int comp) {
AVCodecContext *avctx = s->avctx;
- SubBand *bands[3*MAX_DWT_LEVELS+1];
+ SubBand *bands[3 * MAX_DWT_LEVELS + 1];
enum dirac_subband orientation;
int level, num_bands = 0;
- int ret[3*MAX_DWT_LEVELS+1];
+ int ret[3 * MAX_DWT_LEVELS + 1];
int i;
int damaged_count = 0;
@@ -462,63 +462,68 @@ static int decode_component(DiracContext *s, int comp)
if (b->length) {
b->quant = get_interleaved_ue_golomb(&s->gb);
if (b->quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
- av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", b->quant);
+ av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n",
+ b->quant);
b->quant = 0;
return AVERROR_INVALIDDATA;
}
align_get_bits(&s->gb);
- b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8;
- if (b->length > FFMAX(get_bits_left(&s->gb)/8, 0)) {
- b->length = FFMAX(get_bits_left(&s->gb)/8, 0);
- damaged_count ++;
+ b->coeff_data = s->gb.buffer + get_bits_count(&s->gb) / 8;
+ if (b->length > FFMAX(get_bits_left(&s->gb) / 8, 0)) {
+ b->length = FFMAX(get_bits_left(&s->gb) / 8, 0);
+ damaged_count++;
}
- skip_bits_long(&s->gb, b->length*8);
+ skip_bits_long(&s->gb, b->length * 8);
}
}
- /* arithmetic coding has inter-level dependencies, so we can only execute one level at a time */
+ /* arithmetic coding has inter-level dependencies, so we can only
+ * execute one level at a time */
if (s->is_arith)
- avctx->execute(avctx, decode_subband_arith, &s->plane[comp].band[level][!!level],
- ret + 3*level + !!level, 4-!!level, sizeof(SubBand));
+ avctx->execute(avctx, decode_subband_arith,
+ &s->plane[comp].band[level][!!level],
+ ret + 3 * level + !!level, 4 - !!level,
+ sizeof(SubBand));
}
- /* golomb coding has no inter-level dependencies, so we can execute all subbands in parallel */
+ /* golomb coding has no inter-level dependencies, so we can execute all
+ * subbands in parallel */
if (!s->is_arith)
- avctx->execute(avctx, decode_subband_golomb, bands, ret, num_bands, sizeof(SubBand*));
+ avctx->execute(avctx, decode_subband_golomb, bands, ret, num_bands,
+ sizeof(SubBand *));
for (i = 0; i < s->wavelet_depth * 3 + 1; i++) {
if (ret[i] < 0)
damaged_count++;
}
- if (damaged_count > (s->wavelet_depth * 3 + 1) /2)
+ if (damaged_count > (s->wavelet_depth * 3 + 1) / 2)
return AVERROR_INVALIDDATA;
return 0;
}
-#define PARSE_VALUES(type, x, gb, ebits, buf1, buf2) \
- type *buf = (type *)buf1; \
- buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); \
- if (get_bits_count(gb) >= ebits) \
- return; \
- if (buf2) { \
- buf = (type *)buf2; \
- buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); \
- if (get_bits_count(gb) >= ebits) \
- return; \
- } \
+#define PARSE_VALUES(type, x, gb, ebits, buf1, buf2) \
+ type *buf = (type *)buf1; \
+ buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); \
+ if (get_bits_count(gb) >= ebits) \
+ return; \
+ if (buf2) { \
+ buf = (type *)buf2; \
+ buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); \
+ if (get_bits_count(gb) >= ebits) \
+ return; \
+ }
static void decode_subband(const DiracContext *s, GetBitContext *gb, int quant,
int slice_x, int slice_y, int bits_end,
- const SubBand *b1, const SubBand *b2)
-{
- int left = b1->width * slice_x / s->num_x;
- int right = b1->width *(slice_x+1) / s->num_x;
- int top = b1->height * slice_y / s->num_y;
- int bottom = b1->height *(slice_y+1) / s->num_y;
+ const SubBand *b1, const SubBand *b2) {
+ int left = b1->width * slice_x / s->num_x;
+ int right = b1->width * (slice_x + 1) / s->num_x;
+ int top = b1->height * slice_y / s->num_y;
+ int bottom = b1->height * (slice_y + 1) / s->num_y;
int qfactor, qoffset;
- uint8_t *buf1 = b1->ibuf + top * b1->stride;
- uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride: NULL;
+ uint8_t *buf1 = b1->ibuf + top * b1->stride;
+ uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride : NULL;
int x, y;
if (quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
@@ -541,8 +546,7 @@ static void decode_subband(const DiracContext *s, GetBitContext *gb, int quant,
if (buf2)
buf2 += b2->stride;
}
- }
- else {
+ } else {
for (y = top; y < bottom; y++) {
for (x = left; x < right; x++) {
PARSE_VALUES(int16_t, x, gb, bits_end, buf1, buf2);
@@ -558,38 +562,40 @@ static void decode_subband(const DiracContext *s, GetBitContext *gb, int quant,
* Dirac Specification ->
* 13.5.2 Slices. slice(sx,sy)
*/
-static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
-{
+static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg) {
const DiracContext *s = avctx->priv_data;
DiracSlice *slice = arg;
GetBitContext *gb = &slice->gb;
enum dirac_subband orientation;
int level, quant, chroma_bits, chroma_end;
- int quant_base = get_bits(gb, 7); /*[DIRAC_STD] qindex */
- int length_bits = av_log2(8 * slice->bytes)+1;
- int luma_bits = get_bits_long(gb, length_bits);
- int luma_end = get_bits_count(gb) + FFMIN(luma_bits, get_bits_left(gb));
+ int quant_base = get_bits(gb, 7); /*[DIRAC_STD] qindex */
+ int length_bits = av_log2(8 * slice->bytes) + 1;
+ int luma_bits = get_bits_long(gb, length_bits);
+ int luma_end = get_bits_count(gb) + FFMIN(luma_bits, get_bits_left(gb));
/* [DIRAC_STD] 13.5.5.2 luma_slice_band */
for (level = 0; level < s->wavelet_depth; level++)
for (orientation = !!level; orientation < 4; orientation++) {
- quant = FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0);
- decode_subband(s, gb, quant, slice->slice_x, slice->slice_y, luma_end,
- &s->plane[0].band[level][orientation], NULL);
+ quant =
+ FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0);
+ decode_subband(s, gb, quant, slice->slice_x, slice->slice_y,
+ luma_end, &s->plane[0].band[level][orientation],
+ NULL);
}
/* consume any unused bits from luma */
skip_bits_long(gb, get_bits_count(gb) - luma_end);
- chroma_bits = 8*slice->bytes - 7 - length_bits - luma_bits;
- chroma_end = get_bits_count(gb) + FFMIN(chroma_bits, get_bits_left(gb));
+ chroma_bits = 8 * slice->bytes - 7 - length_bits - luma_bits;
+ chroma_end = get_bits_count(gb) + FFMIN(chroma_bits, get_bits_left(gb));
/* [DIRAC_STD] 13.5.5.3 chroma_slice_band */
for (level = 0; level < s->wavelet_depth; level++)
for (orientation = !!level; orientation < 4; orientation++) {
- quant = FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0);
- decode_subband(s, gb, quant, slice->slice_x, slice->slice_y, chroma_end,
- &s->plane[1].band[level][orientation],
+ quant =
+ FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0);
+ decode_subband(s, gb, quant, slice->slice_x, slice->slice_y,
+ chroma_end, &s->plane[1].band[level][orientation],
&s->plane[2].band[level][orientation]);
}
@@ -597,18 +603,18 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
}
static int subband_coeffs(const DiracContext *s, int x, int y, int p,
- SliceCoeffs c[MAX_DWT_LEVELS])
-{
+ SliceCoeffs c[MAX_DWT_LEVELS]) {
int level, coef = 0;
for (level = 0; level < s->wavelet_depth; level++) {
SliceCoeffs *o = &c[level];
- const SubBand *b = &s->plane[p].band[level][3]; /* orientation doens't matter */
- o->top = b->height * y / s->num_y;
- o->left = b->width * x / s->num_x;
- o->tot_h = ((b->width * (x + 1)) / s->num_x) - o->left;
+ const SubBand *b =
+ &s->plane[p].band[level][3]; /* orientation doens't matter */
+ o->top = b->height * y / s->num_y;
+ o->left = b->width * x / s->num_x;
+ o->tot_h = ((b->width * (x + 1)) / s->num_x) - o->left;
o->tot_v = ((b->height * (y + 1)) / s->num_y) - o->top;
- o->tot = o->tot_h*o->tot_v;
- coef += o->tot * (4 - !!level);
+ o->tot = o->tot_h * o->tot_v;
+ coef += o->tot * (4 - !!level);
}
return coef;
}
@@ -617,25 +623,27 @@ static int subband_coeffs(const DiracContext *s, int x, int y, int p,
* VC-2 Specification ->
* 13.5.3 hq_slice(sx,sy)
*/
-static int decode_hq_slice(const DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
-{
+static int decode_hq_slice(const DiracContext *s, DiracSlice *slice,
+ uint8_t *tmp_buf) {
int i, level, orientation, quant_idx;
int qfactor[MAX_DWT_LEVELS][4], qoffset[MAX_DWT_LEVELS][4];
GetBitContext *gb = &slice->gb;
SliceCoeffs coeffs_num[MAX_DWT_LEVELS];
- skip_bits_long(gb, 8*s->highquality.prefix_bytes);
+ skip_bits_long(gb, 8 * s->highquality.prefix_bytes);
quant_idx = get_bits(gb, 8);
if (quant_idx > DIRAC_MAX_QUANT_INDEX - 1) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid quantization index - %i\n", quant_idx);
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid quantization index - %i\n",
+ quant_idx);
return AVERROR_INVALIDDATA;
}
/* Slice quantization (slice_quantizers() in the specs) */
for (level = 0; level < s->wavelet_depth; level++) {
for (orientation = !!level; orientation < 4; orientation++) {
- const int quant = FFMAX(quant_idx - s->lowdelay.quant[level][orientation], 0);
+ const int quant =
+ FFMAX(quant_idx - s->lowdelay.quant[level][orientation], 0);
qfactor[level][orientation] = ff_dirac_qscale_tab[quant];
qoffset[level][orientation] = ff_dirac_qoffset_intra_tab[quant] + 2;
}
@@ -644,27 +652,28 @@ static int decode_hq_slice(const DiracContext *s, DiracSlice *slice, uint8_t *tm
/* Luma + 2 Chroma planes */
for (i = 0; i < 3; i++) {
int coef_num, coef_par, off = 0;
- int64_t length = s->highquality.size_scaler*get_bits(gb, 8);
- int64_t bits_end = get_bits_count(gb) + 8*length;
+ int64_t length = s->highquality.size_scaler * get_bits(gb, 8);
+ int64_t bits_end = get_bits_count(gb) + 8 * length;
const uint8_t *addr = align_get_bits(gb);
- if (length*8 > get_bits_left(gb)) {
+ if (length * 8 > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "end too far away\n");
return AVERROR_INVALIDDATA;
}
- coef_num = subband_coeffs(s, slice->slice_x, slice->slice_y, i, coeffs_num);
+ coef_num =
+ subband_coeffs(s, slice->slice_x, slice->slice_y, i, coeffs_num);
if (s->pshift)
- coef_par = ff_dirac_golomb_read_32bit(addr, length,
- tmp_buf, coef_num);
+ coef_par =
+ ff_dirac_golomb_read_32bit(addr, length, tmp_buf, coef_num);
else
- coef_par = ff_dirac_golomb_read_16bit(addr, length,
- tmp_buf, coef_num);
+ coef_par =
+ ff_dirac_golomb_read_16bit(addr, length, tmp_buf, coef_num);
if (coef_num > coef_par) {
const int start_b = coef_par * (1 << (s->pshift + 1));
- const int end_b = coef_num * (1 << (s->pshift + 1));
+ const int end_b = coef_num * (1 << (s->pshift + 1));
memset(&tmp_buf[start_b], 0, end_b - start_b);
}
@@ -672,14 +681,14 @@ static int decode_hq_slice(const DiracContext *s, DiracSlice *slice, uint8_t *tm
const SliceCoeffs *c = &coeffs_num[level];
for (orientation = !!level; orientation < 4; orientation++) {
const SubBand *b1 = &s->plane[i].band[level][orientation];
- uint8_t *buf = b1->ibuf + c->top * b1->stride + (c->left << (s->pshift + 1));
+ uint8_t *buf = b1->ibuf + c->top * b1->stride +
+ (c->left << (s->pshift + 1));
/* Change to c->tot_h <= 4 for AVX2 dequantization */
- const int qfunc = s->pshift + 2*(c->tot_h <= 2);
- s->diracdsp.dequant_subband[qfunc](&tmp_buf[off], buf, b1->stride,
- qfactor[level][orientation],
- qoffset[level][orientation],
- c->tot_v, c->tot_h);
+ const int qfunc = s->pshift + 2 * (c->tot_h <= 2);
+ s->diracdsp.dequant_subband[qfunc](
+ &tmp_buf[off], buf, b1->stride, qfactor[level][orientation],
+ qoffset[level][orientation], c->tot_v, c->tot_h);
off += c->tot << (s->pshift + 1);
}
@@ -691,12 +700,12 @@ static int decode_hq_slice(const DiracContext *s, DiracSlice *slice, uint8_t *tm
return 0;
}
-static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
-{
+static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr,
+ int threadnr) {
int i;
const DiracContext *s = avctx->priv_data;
- DiracSlice *slices = ((DiracSlice *)arg) + s->num_x*jobnr;
- uint8_t *thread_buf = &s->thread_buf[s->thread_buf_size*threadnr];
+ DiracSlice *slices = ((DiracSlice *)arg) + s->num_x * jobnr;
+ uint8_t *thread_buf = &s->thread_buf[s->thread_buf_size * threadnr];
for (i = 0; i < s->num_x; i++)
decode_hq_slice(s, &slices[i], thread_buf);
return 0;
@@ -706,8 +715,7 @@ static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr, int
* Dirac Specification ->
* 13.5.1 low_delay_transform_data()
*/
-static int decode_lowdelay(DiracContext *s)
-{
+static int decode_lowdelay(DiracContext *s) {
AVCodecContext *avctx = s->avctx;
int slice_x, slice_y, bufsize;
int64_t coef_buf_size, bytes = 0;
@@ -717,9 +725,11 @@ static int decode_lowdelay(DiracContext *s)
int slice_num = 0;
if (s->slice_params_num_buf != (s->num_x * s->num_y)) {
- s->slice_params_buf = av_realloc_f(s->slice_params_buf, s->num_x * s->num_y, sizeof(DiracSlice));
+ s->slice_params_buf = av_realloc_f(
+ s->slice_params_buf, s->num_x * s->num_y, sizeof(DiracSlice));
if (!s->slice_params_buf) {
- av_log(s->avctx, AV_LOG_ERROR, "slice params buffer allocation failure\n");
+ av_log(s->avctx, AV_LOG_ERROR,
+ "slice params buffer allocation failure\n");
s->slice_params_num_buf = 0;
return AVERROR(ENOMEM);
}
@@ -734,18 +744,20 @@ static int decode_lowdelay(DiracContext *s)
if (s->threads_num_buf != avctx->thread_count ||
s->thread_buf_size != coef_buf_size) {
- s->threads_num_buf = avctx->thread_count;
- s->thread_buf_size = coef_buf_size;
- s->thread_buf = av_realloc_f(s->thread_buf, avctx->thread_count, s->thread_buf_size);
+ s->threads_num_buf = avctx->thread_count;
+ s->thread_buf_size = coef_buf_size;
+ s->thread_buf = av_realloc_f(s->thread_buf, avctx->thread_count,
+ s->thread_buf_size);
if (!s->thread_buf) {
- av_log(s->avctx, AV_LOG_ERROR, "thread buffer allocation failure\n");
+ av_log(s->avctx, AV_LOG_ERROR,
+ "thread buffer allocation failure\n");
return AVERROR(ENOMEM);
}
}
align_get_bits(&s->gb);
/*[DIRAC_STD] 13.5.2 Slices. slice(sx,sy) */
- buf = s->gb.buffer + get_bits_count(&s->gb)/8;
+ buf = s->gb.buffer + get_bits_count(&s->gb) / 8;
bufsize = get_bits_left(&s->gb);
if (s->hq_picture) {
@@ -755,29 +767,29 @@ static int decode_lowdelay(DiracContext *s)
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)
+ if (bytes <= bufsize / 8)
bytes += buf[bytes] * s->highquality.size_scaler + 1;
}
- if (bytes >= INT_MAX || bytes*8 > bufsize) {
+ if (bytes >= INT_MAX || bytes * 8 > bufsize) {
av_log(s->avctx, AV_LOG_ERROR, "too many bytes\n");
return AVERROR_INVALIDDATA;
}
- slices[slice_num].bytes = bytes;
+ 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;
+ buf += bytes;
+ if (bufsize / 8 >= bytes)
+ bufsize -= bytes * 8;
else
bufsize = 0;
}
}
- if (s->num_x*s->num_y != slice_num) {
+ if (s->num_x * s->num_y != slice_num) {
av_log(s->avctx, AV_LOG_ERROR, "too few slices\n");
return AVERROR_INVALIDDATA;
}
@@ -789,21 +801,23 @@ static int decode_lowdelay(DiracContext *s)
} 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++) {
- bytes = (slice_num+1) * (int64_t)s->lowdelay.bytes.num / s->lowdelay.bytes.den
- - slice_num * (int64_t)s->lowdelay.bytes.num / s->lowdelay.bytes.den;
- if (bytes >= INT_MAX || bytes*8 > bufsize) {
+ bytes = (slice_num + 1) * (int64_t)s->lowdelay.bytes.num /
+ s->lowdelay.bytes.den -
+ slice_num * (int64_t)s->lowdelay.bytes.num /
+ s->lowdelay.bytes.den;
+ if (bytes >= INT_MAX || bytes * 8 > bufsize) {
av_log(s->avctx, AV_LOG_ERROR, "too many bytes\n");
return AVERROR_INVALIDDATA;
}
- slices[slice_num].bytes = bytes;
+ 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;
+ buf += bytes;
+ if (bufsize / 8 >= bytes)
+ bufsize -= bytes * 8;
else
bufsize = 0;
}
@@ -814,9 +828,15 @@ static int decode_lowdelay(DiracContext *s)
if (s->dc_prediction) {
if (s->pshift) {
- intra_dc_prediction_10(&s->plane[0].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
- intra_dc_prediction_10(&s->plane[1].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
- intra_dc_prediction_10(&s->plane[2].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
+ intra_dc_prediction_10(
+ &s->plane[0]
+ .band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
+ intra_dc_prediction_10(
+ &s->plane[1]
+ .band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
+ intra_dc_prediction_10(
+ &s->plane[2]
+ .band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */
} else {
intra_dc_prediction_8(&s->plane[0].band[0][0]);
intra_dc_prediction_8(&s->plane[1].band[0][0]);
@@ -827,40 +847,39 @@ static int decode_lowdelay(DiracContext *s)
return 0;
}
-static void init_planes(DiracContext *s)
-{
+static void init_planes(DiracContext *s) {
int i, w, h, level, orientation;
for (i = 0; i < 3; i++) {
Plane *p = &s->plane[i];
- p->width = s->seq.width >> (i ? s->chroma_x_shift : 0);
- p->height = s->seq.height >> (i ? s->chroma_y_shift : 0);
- p->idwt.width = w = CALC_PADDING(p->width , s->wavelet_depth);
+ p->width = s->seq.width >> (i ? s->chroma_x_shift : 0);
+ p->height = s->seq.height >> (i ? s->chroma_y_shift : 0);
+ p->idwt.width = w = CALC_PADDING(p->width, s->wavelet_depth);
p->idwt.height = h = CALC_PADDING(p->height, s->wavelet_depth);
p->idwt.stride = FFALIGN(p->idwt.width, 8) << (1 + s->pshift);
- for (level = s->wavelet_depth-1; level >= 0; level--) {
- w = w>>1;
- h = h>>1;
+ for (level = s->wavelet_depth - 1; level >= 0; level--) {
+ w = w >> 1;
+ h = h >> 1;
for (orientation = !!level; orientation < 4; orientation++) {
SubBand *b = &p->band[level][orientation];
b->pshift = s->pshift;
- b->ibuf = p->idwt.buf;
- b->level = level;
+ b->ibuf = p->idwt.buf;
+ b->level = level;
b->stride = p->idwt.stride << (s->wavelet_depth - level);
- b->width = w;
+ b->width = w;
b->height = h;
b->orientation = orientation;
if (orientation & 1)
- b->ibuf += w << (1+b->pshift);
+ b->ibuf += w << (1 + b->pshift);
if (orientation > 1)
- b->ibuf += (b->stride>>1);
+ b->ibuf += (b->stride >> 1);
if (level)
- b->parent = &p->band[level-1][orientation];
+ b->parent = &p->band[level - 1][orientation];
}
}
@@ -871,8 +890,8 @@ static void init_planes(DiracContext *s)
p->ybsep = s->plane[0].ybsep >> s->chroma_y_shift;
}
- p->xoffset = (p->xblen - p->xbsep)/2;
- p->yoffset = (p->yblen - p->ybsep)/2;
+ p->xoffset = (p->xblen - p->xbsep) / 2;
+ p->yoffset = (p->yblen - p->ybsep) / 2;
}
}
@@ -881,9 +900,8 @@ static void init_planes(DiracContext *s)
* Dirac Specification ->
* 11.2 Picture prediction data. picture_prediction()
*/
-static int dirac_unpack_prediction_parameters(DiracContext *s)
-{
- static const uint8_t default_blen[] = { 4, 12, 16, 24 };
+static int dirac_unpack_prediction_parameters(DiracContext *s) {
+ static const uint8_t default_blen[] = {4, 12, 16, 24};
GetBitContext *gb = &s->gb;
unsigned idx, ref;
@@ -905,8 +923,8 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
s->plane[0].ybsep = get_interleaved_ue_golomb(gb);
} else {
/*[DIRAC_STD] preset_block_params(index). Table 11.1 */
- s->plane[0].xblen = default_blen[idx-1];
- s->plane[0].yblen = default_blen[idx-1];
+ s->plane[0].xblen = default_blen[idx - 1];
+ s->plane[0].yblen = default_blen[idx - 1];
s->plane[0].xbsep = 4 * idx;
s->plane[0].ybsep = 4 * idx;
}
@@ -916,16 +934,21 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
if (s->plane[0].xblen % (1 << s->chroma_x_shift) != 0 ||
s->plane[0].yblen % (1 << s->chroma_y_shift) != 0 ||
!s->plane[0].xblen || !s->plane[0].yblen) {
- av_log(s->avctx, AV_LOG_ERROR,
- "invalid x/y block length (%d/%d) for x/y chroma shift (%d/%d)\n",
- s->plane[0].xblen, s->plane[0].yblen, s->chroma_x_shift, s->chroma_y_shift);
+ av_log(
+ s->avctx, AV_LOG_ERROR,
+ "invalid x/y block length (%d/%d) for x/y chroma shift (%d/%d)\n",
+ s->plane[0].xblen, s->plane[0].yblen, s->chroma_x_shift,
+ s->chroma_y_shift);
return AVERROR_INVALIDDATA;
}
- if (!s->plane[0].xbsep || !s->plane[0].ybsep || s->plane[0].xbsep < s->plane[0].xblen/2 || s->plane[0].ybsep < s->plane[0].yblen/2) {
+ if (!s->plane[0].xbsep || !s->plane[0].ybsep ||
+ s->plane[0].xbsep < s->plane[0].xblen / 2 ||
+ s->plane[0].ybsep < s->plane[0].yblen / 2) {
av_log(s->avctx, AV_LOG_ERROR, "Block separation too small\n");
return AVERROR_INVALIDDATA;
}
- if (s->plane[0].xbsep > s->plane[0].xblen || s->plane[0].ybsep > s->plane[0].yblen) {
+ if (s->plane[0].xbsep > s->plane[0].xblen ||
+ s->plane[0].ybsep > s->plane[0].yblen) {
av_log(s->avctx, AV_LOG_ERROR, "Block separation greater than size\n");
return AVERROR_INVALIDDATA;
}
@@ -956,7 +979,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
/* [DIRAC_STD] zoom_rotate_shear(gparams)
zoom/rotation/shear parameters */
if (get_bits1(gb)) {
- s->globalmc[ref].zrs_exp = get_interleaved_ue_golomb(gb);
+ s->globalmc[ref].zrs_exp = get_interleaved_ue_golomb(gb);
s->globalmc[ref].zrs[0][0] = dirac_get_se_golomb(gb);
s->globalmc[ref].zrs[0][1] = dirac_get_se_golomb(gb);
s->globalmc[ref].zrs[1][0] = dirac_get_se_golomb(gb);
@@ -967,14 +990,16 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
}
/* [DIRAC_STD] perspective(gparams) */
if (get_bits1(gb)) {
- s->globalmc[ref].perspective_exp = get_interleaved_ue_golomb(gb);
- s->globalmc[ref].perspective[0] = dirac_get_se_golomb(gb);
- s->globalmc[ref].perspective[1] = dirac_get_se_golomb(gb);
+ s->globalmc[ref].perspective_exp =
+ get_interleaved_ue_golomb(gb);
+ s->globalmc[ref].perspective[0] = dirac_get_se_golomb(gb);
+ s->globalmc[ref].perspective[1] = dirac_get_se_golomb(gb);
}
- if (s->globalmc[ref].perspective_exp + (uint64_t)s->globalmc[ref].zrs_exp > 30) {
+ if (s->globalmc[ref].perspective_exp +
+ (uint64_t)s->globalmc[ref].zrs_exp >
+ 30) {
return AVERROR_INVALIDDATA;
}
-
}
}
@@ -988,13 +1013,14 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
/* [DIRAC_STD] 11.2.8 Reference picture weight. reference_picture_weights()
just data read, weight calculation will be done later on. */
s->weight_log2denom = 1;
- s->weight[0] = 1;
- s->weight[1] = 1;
+ s->weight[0] = 1;
+ s->weight[1] = 1;
if (get_bits1(gb)) {
s->weight_log2denom = get_interleaved_ue_golomb(gb);
if (s->weight_log2denom < 1 || s->weight_log2denom > 8) {
- av_log(s->avctx, AV_LOG_ERROR, "weight_log2denom unsupported or invalid\n");
+ av_log(s->avctx, AV_LOG_ERROR,
+ "weight_log2denom unsupported or invalid\n");
s->weight_log2denom = 1;
return AVERROR_INVALIDDATA;
}
@@ -1009,18 +1035,17 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
* Dirac Specification ->
* 11.3 Wavelet transform data. wavelet_transform()
*/
-static int dirac_unpack_idwt_params(DiracContext *s)
-{
+static int dirac_unpack_idwt_params(DiracContext *s) {
GetBitContext *gb = &s->gb;
int i, level;
unsigned tmp;
-#define CHECKEDREAD(dst, cond, errmsg) \
- tmp = get_interleaved_ue_golomb(gb); \
- if (cond) { \
- av_log(s->avctx, AV_LOG_ERROR, errmsg); \
- return AVERROR_INVALIDDATA; \
- }\
+#define CHECKEDREAD(dst, cond, errmsg) \
+ tmp = get_interleaved_ue_golomb(gb); \
+ if (cond) { \
+ av_log(s->avctx, AV_LOG_ERROR, errmsg); \
+ return AVERROR_INVALIDDATA; \
+ } \
dst = tmp;
align_get_bits(gb);
@@ -1032,33 +1057,37 @@ static int dirac_unpack_idwt_params(DiracContext *s)
/*[DIRAC_STD] 11.3.1 Transform parameters. transform_parameters() */
CHECKEDREAD(s->wavelet_idx, tmp > 6, "wavelet_idx is too big\n")
- CHECKEDREAD(s->wavelet_depth, tmp > MAX_DWT_LEVELS || tmp < 1, "invalid number of DWT decompositions\n")
+ CHECKEDREAD(s->wavelet_depth, tmp > MAX_DWT_LEVELS || tmp < 1,
+ "invalid number of DWT decompositions\n")
if (!s->low_delay) {
/* Codeblock parameters (core syntax only) */
if (get_bits1(gb)) {
for (i = 0; i <= s->wavelet_depth; i++) {
- CHECKEDREAD(s->codeblock[i].width , tmp < 1 || tmp > (s->avctx->width >>s->wavelet_depth-i), "codeblock width invalid\n")
- CHECKEDREAD(s->codeblock[i].height, tmp < 1 || tmp > (s->avctx->height>>s->wavelet_depth-i), "codeblock height invalid\n")
+ CHECKEDREAD(s->codeblock[i].width,
+ tmp < 1 ||
+ tmp > (s->avctx->width >> s->wavelet_depth - i),
+ "codeblock width invalid\n")
+ CHECKEDREAD(
+ s->codeblock[i].height,
+ tmp < 1 || tmp > (s->avctx->height >> s->wavelet_depth - i),
+ "codeblock height invalid\n")
}
CHECKEDREAD(s->codeblock_mode, tmp > 1, "unknown codeblock mode\n")
- }
- else {
+ } else {
for (i = 0; i <= s->wavelet_depth; i++)
s->codeblock[i].width = s->codeblock[i].height = 1;
}
- }
- else {
- s->num_x = get_interleaved_ue_golomb(gb);
- s->num_y = get_interleaved_ue_golomb(gb);
- if (s->num_x * s->num_y == 0 || s->num_x * (uint64_t)s->num_y > INT_MAX ||
- s->num_x * (uint64_t)s->avctx->width > INT_MAX ||
+ } else {
+ s->num_x = get_interleaved_ue_golomb(gb);
+ s->num_y = get_interleaved_ue_golomb(gb);
+ if (s->num_x * s->num_y == 0 ||
+ s->num_x * (uint64_t)s->num_y > INT_MAX ||
+ s->num_x * (uint64_t)s->avctx->width > INT_MAX ||
s->num_y * (uint64_t)s->avctx->height > INT_MAX ||
- s->num_x > s->avctx->width ||
- s->num_y > s->avctx->height
- ) {
- av_log(s->avctx,AV_LOG_ERROR,"Invalid numx/y\n");
+ s->num_x > s->avctx->width || s->num_y > s->avctx->height) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid numx/y\n");
s->num_x = s->num_y = 0;
return AVERROR_INVALIDDATA;
}
@@ -1066,21 +1095,23 @@ static int dirac_unpack_idwt_params(DiracContext *s)
s->lowdelay.bytes.num = get_interleaved_ue_golomb(gb);
s->lowdelay.bytes.den = get_interleaved_ue_golomb(gb);
if (s->lowdelay.bytes.den <= 0) {
- av_log(s->avctx,AV_LOG_ERROR,"Invalid lowdelay.bytes.den\n");
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid lowdelay.bytes.den\n");
return AVERROR_INVALIDDATA;
}
} else if (s->hq_picture) {
s->highquality.prefix_bytes = get_interleaved_ue_golomb(gb);
- s->highquality.size_scaler = get_interleaved_ue_golomb(gb);
+ s->highquality.size_scaler = get_interleaved_ue_golomb(gb);
if (s->highquality.prefix_bytes >= INT_MAX / 8) {
- av_log(s->avctx,AV_LOG_ERROR,"too many prefix bytes\n");
+ av_log(s->avctx, AV_LOG_ERROR, "too many prefix bytes\n");
return AVERROR_INVALIDDATA;
}
}
- /* [DIRAC_STD] 11.3.5 Quantisation matrices (low-delay syntax). quant_matrix() */
+ /* [DIRAC_STD] 11.3.5 Quantisation matrices (low-delay syntax).
+ * quant_matrix() */
if (get_bits1(gb)) {
- av_log(s->avctx,AV_LOG_DEBUG,"Low Delay: Has Custom Quantization Matrix!\n");
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "Low Delay: Has Custom Quantization Matrix!\n");
/* custom quantization matrix */
for (level = 0; level < s->wavelet_depth; level++) {
for (i = !!level; i < 4; i++) {
@@ -1089,41 +1120,45 @@ static int dirac_unpack_idwt_params(DiracContext *s)
}
} else {
if (s->wavelet_depth > 4) {
- av_log(s->avctx,AV_LOG_ERROR,"Mandatory custom low delay matrix missing for depth %d\n", s->wavelet_depth);
+ av_log(
+ s->avctx, AV_LOG_ERROR,
+ "Mandatory custom low delay matrix missing for depth %d\n",
+ s->wavelet_depth);
return AVERROR_INVALIDDATA;
}
/* default quantization matrix */
for (level = 0; level < s->wavelet_depth; level++)
for (i = 0; i < 4; i++) {
- s->lowdelay.quant[level][i] = ff_dirac_default_qmat[s->wavelet_idx][level][i];
+ s->lowdelay.quant[level][i] =
+ ff_dirac_default_qmat[s->wavelet_idx][level][i];
/* haar with no shift differs for different depths */
if (s->wavelet_idx == 3)
- s->lowdelay.quant[level][i] += 4*(s->wavelet_depth-1 - level);
+ s->lowdelay.quant[level][i] +=
+ 4 * (s->wavelet_depth - 1 - level);
}
}
}
return 0;
}
-static inline int pred_sbsplit(uint8_t *sbsplit, int stride, int x, int y)
-{
- static const uint8_t avgsplit[7] = { 0, 0, 1, 1, 1, 2, 2 };
+static inline int pred_sbsplit(uint8_t *sbsplit, int stride, int x, int y) {
+ static const uint8_t avgsplit[7] = {0, 0, 1, 1, 1, 2, 2};
- if (!(x|y))
+ if (!(x | y))
return 0;
else if (!y)
return sbsplit[-1];
else if (!x)
return sbsplit[-stride];
- return avgsplit[sbsplit[-1] + sbsplit[-stride] + sbsplit[-stride-1]];
+ return avgsplit[sbsplit[-1] + sbsplit[-stride] + sbsplit[-stride - 1]];
}
-static inline int pred_block_mode(DiracBlock *block, int stride, int x, int y, int refmask)
-{
+static inline int pred_block_mode(DiracBlock *block, int stride, int x, int y,
+ int refmask) {
int pred;
- if (!(x|y))
+ if (!(x | y))
return 0;
else if (!y)
return block[-1].ref & refmask;
@@ -1131,12 +1166,12 @@ static inline int pred_block_mode(DiracBlock *block, int stride, int x, int y, i
return block[-stride].ref & refmask;
/* return the majority */
- pred = (block[-1].ref & refmask) + (block[-stride].ref & refmask) + (block[-stride-1].ref & refmask);
+ pred = (block[-1].ref & refmask) + (block[-stride].ref & refmask) +
+ (block[-stride - 1].ref & refmask);
return (pred >> 1) & refmask;
}
-static inline void pred_block_dc(DiracBlock *block, int stride, int x, int y)
-{
+static inline void pred_block_dc(DiracBlock *block, int stride, int x, int y) {
int i, n = 0;
memset(block->u.dc, 0, sizeof(block->u.dc));
@@ -1153,25 +1188,25 @@ static inline void pred_block_dc(DiracBlock *block, int stride, int x, int y)
n++;
}
- if (x && y && !(block[-1-stride].ref & 3)) {
+ if (x && y && !(block[-1 - stride].ref & 3)) {
for (i = 0; i < 3; i++)
- block->u.dc[i] += block[-1-stride].u.dc[i];
+ block->u.dc[i] += block[-1 - stride].u.dc[i];
n++;
}
if (n == 2) {
for (i = 0; i < 3; i++)
- block->u.dc[i] = (block->u.dc[i]+1)>>1;
+ block->u.dc[i] = (block->u.dc[i] + 1) >> 1;
} else if (n == 3) {
for (i = 0; i < 3; i++)
block->u.dc[i] = divide3(block->u.dc[i]);
}
}
-static inline void pred_mv(DiracBlock *block, int stride, int x, int y, int ref)
-{
+static inline void pred_mv(DiracBlock *block, int stride, int x, int y,
+ int ref) {
int16_t *pred[3];
- int refmask = ref+1;
+ int refmask = ref + 1;
int mask = refmask | DIRAC_REF_MASK_GLOBAL; /* exclude gmc blocks */
int n = 0;
@@ -1181,8 +1216,8 @@ static inline void pred_mv(DiracBlock *block, int stride, int x, int y, int ref)
if (y && (block[-stride].ref & mask) == refmask)
pred[n++] = block[-stride].u.mv[ref];
- if (x && y && (block[-stride-1].ref & mask) == refmask)
- pred[n++] = block[-stride-1].u.mv[ref];
+ if (x && y && (block[-stride - 1].ref & mask) == refmask)
+ pred[n++] = block[-stride - 1].u.mv[ref];
switch (n) {
case 0:
@@ -1204,28 +1239,29 @@ static inline void pred_mv(DiracBlock *block, int stride, int x, int y, int ref)
}
}
-static void global_mv(DiracContext *s, DiracBlock *block, int x, int y, int ref)
-{
- int ez = s->globalmc[ref].zrs_exp;
- int ep = s->globalmc[ref].perspective_exp;
- int (*A)[2] = s->globalmc[ref].zrs;
- int *b = s->globalmc[ref].pan_tilt;
- int *c = s->globalmc[ref].perspective;
-
- int64_t m = (1<<ep) - (c[0]*(int64_t)x + c[1]*(int64_t)y);
- int64_t mx = m * (uint64_t)((A[0][0] * (int64_t)x + A[0][1]*(int64_t)y) + (1LL<<ez) * b[0]);
- int64_t my = m * (uint64_t)((A[1][0] * (int64_t)x + A[1][1]*(int64_t)y) + (1LL<<ez) * b[1]);
-
- block->u.mv[ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep);
- block->u.mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep);
+static void global_mv(DiracContext *s, DiracBlock *block, int x, int y,
+ int ref) {
+ int ez = s->globalmc[ref].zrs_exp;
+ int ep = s->globalmc[ref].perspective_exp;
+ int(*A)[2] = s->globalmc[ref].zrs;
+ int *b = s->globalmc[ref].pan_tilt;
+ int *c = s->globalmc[ref].perspective;
+
+ int64_t m = (1 << ep) - (c[0] * (int64_t)x + c[1] * (int64_t)y);
+ int64_t mx = m * (uint64_t)((A[0][0] * (int64_t)x + A[0][1] * (int64_t)y) +
+ (1LL << ez) * b[0]);
+ int64_t my = m * (uint64_t)((A[1][0] * (int64_t)x + A[1][1] * (int64_t)y) +
+ (1LL << ez) * b[1]);
+
+ block->u.mv[ref][0] = (mx + (1 << (ez + ep))) >> (ez + ep);
+ block->u.mv[ref][1] = (my + (1 << (ez + ep))) >> (ez + ep);
}
-static void decode_block_params(DiracContext *s, DiracArith arith[8], DiracBlock *block,
- int stride, int x, int y)
-{
+static void decode_block_params(DiracContext *s, DiracArith arith[8],
+ DiracBlock *block, int stride, int x, int y) {
int i;
- block->ref = pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_REF1);
+ block->ref = pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_REF1);
block->ref ^= dirac_get_arith_bit(arith, CTX_PMODE_REF1);
if (s->num_refs == 2) {
@@ -1236,32 +1272,36 @@ static void decode_block_params(DiracContext *s, DiracArith arith[8], DiracBlock
if (!block->ref) {
pred_block_dc(block, stride, x, y);
for (i = 0; i < 3; i++)
- block->u.dc[i] += (unsigned)dirac_get_arith_int(arith+1+i, CTX_DC_F1, CTX_DC_DATA);
+ block->u.dc[i] += (unsigned)dirac_get_arith_int(
+ arith + 1 + i, CTX_DC_F1, CTX_DC_DATA);
return;
}
if (s->globalmc_flag) {
- block->ref |= pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_GLOBAL);
+ block->ref |=
+ pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_GLOBAL);
block->ref ^= dirac_get_arith_bit(arith, CTX_GLOBAL_BLOCK) << 2;
}
for (i = 0; i < s->num_refs; i++)
- if (block->ref & (i+1)) {
+ if (block->ref & (i + 1)) {
if (block->ref & DIRAC_REF_MASK_GLOBAL) {
global_mv(s, block, x, y, i);
} else {
pred_mv(block, stride, x, y, i);
- block->u.mv[i][0] += (unsigned)dirac_get_arith_int(arith + 4 + 2 * i, CTX_MV_F1, CTX_MV_DATA);
- block->u.mv[i][1] += (unsigned)dirac_get_arith_int(arith + 5 + 2 * i, CTX_MV_F1, CTX_MV_DATA);
+ block->u.mv[i][0] += (unsigned)dirac_get_arith_int(
+ arith + 4 + 2 * i, CTX_MV_F1, CTX_MV_DATA);
+ block->u.mv[i][1] += (unsigned)dirac_get_arith_int(
+ arith + 5 + 2 * i, CTX_MV_F1, CTX_MV_DATA);
}
}
}
/**
- * Copies the current block to the other blocks covered by the current superblock split mode
+ * Copies the current block to the other blocks covered by the current
+ * superblock split mode
*/
-static void propagate_block_data(DiracBlock *block, int stride, int size)
-{
+static void propagate_block_data(DiracBlock *block, int stride, int size) {
int x, y;
DiracBlock *dst = block;
@@ -1279,8 +1319,7 @@ static void propagate_block_data(DiracBlock *block, int stride, int size)
* Dirac Specification ->
* 12. Block motion data syntax
*/
-static int dirac_unpack_block_motion_data(DiracContext *s)
-{
+static int dirac_unpack_block_motion_data(DiracContext *s) {
GetBitContext *gb = &s->gb;
uint8_t *sbsplit = s->sbsplit;
int i, x, y, q, p;
@@ -1289,20 +1328,25 @@ static int dirac_unpack_block_motion_data(DiracContext *s)
align_get_bits(gb);
/* [DIRAC_STD] 11.2.4 and 12.2.1 Number of blocks and superblocks */
- s->sbwidth = DIVRNDUP(s->seq.width, 4*s->plane[0].xbsep);
- s->sbheight = DIVRNDUP(s->seq.height, 4*s->plane[0].ybsep);
- s->blwidth = 4 * s->sbwidth;
+ s->sbwidth = DIVRNDUP(s->seq.width, 4 * s->plane[0].xbsep);
+ s->sbheight = DIVRNDUP(s->seq.height, 4 * s->plane[0].ybsep);
+ s->blwidth = 4 * s->sbwidth;
s->blheight = 4 * s->sbheight;
/* [DIRAC_STD] 12.3.1 Superblock splitting modes. superblock_split_modes()
decode superblock split modes */
- ff_dirac_init_arith_decoder(arith, gb, get_interleaved_ue_golomb(gb)); /* get_interleaved_ue_golomb(gb) is the length */
+ ff_dirac_init_arith_decoder(
+ arith, gb,
+ get_interleaved_ue_golomb(
+ gb)); /* get_interleaved_ue_golomb(gb) is the length */
for (y = 0; y < s->sbheight; y++) {
for (x = 0; x < s->sbwidth; x++) {
- unsigned int split = dirac_get_arith_uint(arith, CTX_SB_F1, CTX_SB_DATA);
+ unsigned int split =
+ dirac_get_arith_uint(arith, CTX_SB_F1, CTX_SB_DATA);
if (split > 2)
return AVERROR_INVALIDDATA;
- sbsplit[x] = (split + pred_sbsplit(sbsplit+x, s->sbwidth, x, y)) % 3;
+ sbsplit[x] =
+ (split + pred_sbsplit(sbsplit + x, s->sbwidth, x, y)) % 3;
}
sbsplit += s->sbwidth;
}
@@ -1310,28 +1354,31 @@ static int dirac_unpack_block_motion_data(DiracContext *s)
/* setup arith decoding */
ff_dirac_init_arith_decoder(arith, gb, get_interleaved_ue_golomb(gb));
for (i = 0; i < s->num_refs; i++) {
- ff_dirac_init_arith_decoder(arith + 4 + 2 * i, gb, get_interleaved_ue_golomb(gb));
- ff_dirac_init_arith_decoder(arith + 5 + 2 * i, gb, get_interleaved_ue_golomb(gb));
+ ff_dirac_init_arith_decoder(arith + 4 + 2 * i, gb,
+ get_interleaved_ue_golomb(gb));
+ ff_dirac_init_arith_decoder(arith + 5 + 2 * i, gb,
+ get_interleaved_ue_golomb(gb));
}
for (i = 0; i < 3; i++)
- ff_dirac_init_arith_decoder(arith+1+i, gb, get_interleaved_ue_golomb(gb));
+ ff_dirac_init_arith_decoder(arith + 1 + i, gb,
+ get_interleaved_ue_golomb(gb));
for (y = 0; y < s->sbheight; y++)
for (x = 0; x < s->sbwidth; x++) {
int blkcnt = 1 << s->sbsplit[y * s->sbwidth + x];
- int step = 4 >> s->sbsplit[y * s->sbwidth + x];
+ int step = 4 >> s->sbsplit[y * s->sbwidth + x];
for (q = 0; q < blkcnt; q++)
for (p = 0; p < blkcnt; p++) {
- int bx = 4 * x + p*step;
- int by = 4 * y + q*step;
- DiracBlock *block = &s->blmotion[by*s->blwidth + bx];
+ int bx = 4 * x + p * step;
+ int by = 4 * y + q * step;
+ DiracBlock *block = &s->blmotion[by * s->blwidth + bx];
decode_block_params(s, arith, block, s->blwidth, bx, by);
propagate_block_data(block, s->blwidth, step);
}
}
- for (i = 0; i < 4 + 2*s->num_refs; i++) {
+ for (i = 0; i < 4 + 2 * s->num_refs; i++) {
if (arith[i].error)
return arith[i].error;
}
@@ -1339,35 +1386,33 @@ static int dirac_unpack_block_motion_data(DiracContext *s)
return 0;
}
-static int weight(int i, int blen, int offset)
-{
-#define ROLLOFF(i) offset == 1 ? ((i) ? 5 : 3) : \
- (1 + (6*(i) + offset - 1) / (2*offset - 1))
+static int weight(int i, int blen, int offset) {
+#define ROLLOFF(i) \
+ offset == 1 ? ((i) ? 5 : 3) \
+ : (1 + (6 * (i) + offset - 1) / (2 * offset - 1))
- if (i < 2*offset)
+ if (i < 2 * offset)
return ROLLOFF(i);
- else if (i > blen-1 - 2*offset)
- return ROLLOFF(blen-1 - i);
+ else if (i > blen - 1 - 2 * offset)
+ return ROLLOFF(blen - 1 - i);
return 8;
}
static void init_obmc_weight_row(Plane *p, uint8_t *obmc_weight, int stride,
- int left, int right, int wy)
-{
+ int left, int right, int wy) {
int x;
for (x = 0; left && x < p->xblen >> 1; x++)
- obmc_weight[x] = wy*8;
+ obmc_weight[x] = wy * 8;
for (; x < p->xblen >> right; x++)
- obmc_weight[x] = wy*weight(x, p->xblen, p->xoffset);
+ obmc_weight[x] = wy * weight(x, p->xblen, p->xoffset);
for (; x < p->xblen; x++)
- obmc_weight[x] = wy*8;
+ obmc_weight[x] = wy * 8;
for (; x < stride; x++)
obmc_weight[x] = 0;
}
static void init_obmc_weight(Plane *p, uint8_t *obmc_weight, int stride,
- int left, int right, int top, int bottom)
-{
+ int left, int right, int top, int bottom) {
int y;
for (y = 0; top && y < p->yblen >> 1; y++) {
init_obmc_weight_row(p, obmc_weight, stride, left, right, 8);
@@ -1384,37 +1429,27 @@ static void init_obmc_weight(Plane *p, uint8_t *obmc_weight, int stride,
}
}
-static void init_obmc_weights(DiracContext *s, Plane *p, int by)
-{
+static void init_obmc_weights(DiracContext *s, Plane *p, int by) {
int top = !by;
- int bottom = by == s->blheight-1;
+ int bottom = by == s->blheight - 1;
- /* don't bother re-initing for rows 2 to blheight-2, the weights don't change */
+ /* don't bother re-initing for rows 2 to blheight-2, the weights don't
+ * change */
if (top || bottom || by == 1) {
- init_obmc_weight(p, s->obmc_weight[0], MAX_BLOCKSIZE, 1, 0, top, bottom);
- init_obmc_weight(p, s->obmc_weight[1], MAX_BLOCKSIZE, 0, 0, top, bottom);
- init_obmc_weight(p, s->obmc_weight[2], MAX_BLOCKSIZE, 0, 1, top, bottom);
+ init_obmc_weight(p, s->obmc_weight[0], MAX_BLOCKSIZE, 1, 0, top,
+ bottom);
+ init_obmc_weight(p, s->obmc_weight[1], MAX_BLOCKSIZE, 0, 0, top,
+ bottom);
+ init_obmc_weight(p, s->obmc_weight[2], MAX_BLOCKSIZE, 0, 1, top,
+ bottom);
}
}
static const uint8_t epel_weights[4][4][4] = {
- {{ 16, 0, 0, 0 },
- { 12, 4, 0, 0 },
- { 8, 8, 0, 0 },
- { 4, 12, 0, 0 }},
- {{ 12, 0, 4, 0 },
- { 9, 3, 3, 1 },
- { 6, 6, 2, 2 },
- { 3, 9, 1, 3 }},
- {{ 8, 0, 8, 0 },
- { 6, 2, 6, 2 },
- { 4, 4, 4, 4 },
- { 2, 6, 2, 6 }},
- {{ 4, 0, 12, 0 },
- { 3, 1, 9, 3 },
- { 2, 2, 6, 6 },
- { 1, 3, 3, 9 }}
-};
+ {{16, 0, 0, 0}, {12, 4, 0, 0}, {8, 8, 0, 0}, {4, 12, 0, 0}},
+ {{12, 0, 4, 0}, {9, 3, 3, 1}, {6, 6, 2, 2}, {3, 9, 1, 3}},
+ {{8, 0, 8, 0}, {6, 2, 6, 2}, {4, 4, 4, 4}, {2, 6, 2, 6}},
+ {{4, 0, 12, 0}, {3, 1, 9, 3}, {2, 2, 6, 6}, {1, 3, 3, 9}}};
/**
* For block x,y, determine which of the hpel planes to do bilinear
@@ -1422,11 +1457,11 @@ static const uint8_t epel_weights[4][4][4] = {
* to MC from.
*
* @return the index of the put_dirac_pixels_tab function to use
- * 0 for 1 plane (fpel,hpel), 1 for 2 planes (qpel), 2 for 4 planes (qpel), and 3 for epel
+ * 0 for 1 plane (fpel,hpel), 1 for 2 planes (qpel), 2 for 4 planes (qpel), and
+ * 3 for epel
*/
static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
- int x, int y, int ref, int plane)
-{
+ int x, int y, int ref, int plane) {
Plane *p = &s->plane[plane];
uint8_t **ref_hpel = s->ref_pics[ref]->hpel[plane];
int motion_x = block->u.mv[ref][0];
@@ -1438,31 +1473,32 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
motion_y >>= s->chroma_y_shift;
}
- mx = motion_x & ~(-1U << s->mv_precision);
- my = motion_y & ~(-1U << s->mv_precision);
+ mx = motion_x & ~(-1U << s->mv_precision);
+ my = motion_y & ~(-1U << s->mv_precision);
motion_x >>= s->mv_precision;
motion_y >>= s->mv_precision;
/* normalize subpel coordinates to epel */
/* TODO: template this function? */
- mx <<= 3 - s->mv_precision;
- my <<= 3 - s->mv_precision;
+ mx <<= 3 - s->mv_precision;
+ my <<= 3 - s->mv_precision;
x += motion_x;
y += motion_y;
- epel = (mx|my)&1;
+ epel = (mx | my) & 1;
/* hpel position */
- if (!((mx|my)&3)) {
+ if (!((mx | my) & 3)) {
nplanes = 1;
- src[0] = ref_hpel[(my>>1)+(mx>>2)] + y*p->stride + x;
+ src[0] = ref_hpel[(my >> 1) + (mx >> 2)] + y * p->stride + x;
} else {
/* qpel or epel */
nplanes = 4;
for (i = 0; i < 4; i++)
- src[i] = ref_hpel[i] + y*p->stride + x;
+ src[i] = ref_hpel[i] + y * p->stride + x;
- /* if we're interpolating in the right/bottom halves, adjust the planes as needed
- we increment x/y because the edge changes for half of the pixels */
+ /* if we're interpolating in the right/bottom halves, adjust the planes
+ as needed we increment x/y because the edge changes for half of the
+ pixels */
if (mx > 4) {
src[0] += 1;
src[2] += 1;
@@ -1480,14 +1516,14 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
if (!epel) {
/* check if we really only need 2 planes since either mx or my is
a hpel position. (epel weights of 0 handle this there) */
- if (!(mx&3)) {
+ if (!(mx & 3)) {
/* mx == 0: average [0] and [2]
mx == 4: average [1] and [3] */
src[!mx] = src[2 + !!mx];
nplanes = 2;
- } else if (!(my&3)) {
- src[0] = src[(my>>1) ];
- src[1] = src[(my>>1)+1];
+ } else if (!(my & 3)) {
+ src[0] = src[(my >> 1)];
+ src[1] = src[(my >> 1) + 1];
nplanes = 2;
}
} else {
@@ -1500,56 +1536,53 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
FFSWAP(const uint8_t *, src[0], src[2]);
FFSWAP(const uint8_t *, src[1], src[3]);
}
- src[4] = epel_weights[my&3][mx&3];
+ src[4] = epel_weights[my & 3][mx & 3];
}
}
/* fixme: v/h _edge_pos */
- if (x + p->xblen > p->width +EDGE_WIDTH/2 ||
- y + p->yblen > p->height+EDGE_WIDTH/2 ||
- x < 0 || y < 0) {
+ if (x + p->xblen > p->width + EDGE_WIDTH / 2 ||
+ y + p->yblen > p->height + EDGE_WIDTH / 2 || x < 0 || y < 0) {
for (i = 0; i < nplanes; i++) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer[i], src[i],
- p->stride, p->stride,
- p->xblen, p->yblen, x, y,
- p->width+EDGE_WIDTH/2, p->height+EDGE_WIDTH/2);
+ s->vdsp.emulated_edge_mc(s->edge_emu_buffer[i], src[i], p->stride,
+ p->stride, p->xblen, p->yblen, x, y,
+ p->width + EDGE_WIDTH / 2,
+ p->height + EDGE_WIDTH / 2);
src[i] = s->edge_emu_buffer[i];
}
}
- return (nplanes>>1) + epel;
+ return (nplanes >> 1) + epel;
}
-static void add_dc(uint16_t *dst, int dc, int stride,
- uint8_t *obmc_weight, int xblen, int yblen)
-{
+static void add_dc(uint16_t *dst, int dc, int stride, uint8_t *obmc_weight,
+ int xblen, int yblen) {
int x, y;
dc += 128;
for (y = 0; y < yblen; y++) {
for (x = 0; x < xblen; x += 2) {
- dst[x ] += dc * obmc_weight[x ];
- dst[x+1] += dc * obmc_weight[x+1];
+ dst[x] += dc * obmc_weight[x];
+ dst[x + 1] += dc * obmc_weight[x + 1];
}
- dst += stride;
- obmc_weight += MAX_BLOCKSIZE;
+ dst += stride;
+ obmc_weight += MAX_BLOCKSIZE;
}
}
-static void block_mc(DiracContext *s, DiracBlock *block,
- uint16_t *mctmp, uint8_t *obmc_weight,
- int plane, int dstx, int dsty)
-{
+static void block_mc(DiracContext *s, DiracBlock *block, uint16_t *mctmp,
+ uint8_t *obmc_weight, int plane, int dstx, int dsty) {
Plane *p = &s->plane[plane];
const uint8_t *src[5];
int idx;
- switch (block->ref&3) {
+ switch (block->ref & 3) {
case 0: /* DC */
- add_dc(mctmp, block->u.dc[plane], p->stride, obmc_weight, p->xblen, p->yblen);
+ add_dc(mctmp, block->u.dc[plane], p->stride, obmc_weight, p->xblen,
+ p->yblen);
return;
case 1:
case 2:
- idx = mc_subpel(s, block, src, dstx, dsty, (block->ref&3)-1, plane);
+ idx = mc_subpel(s, block, src, dstx, dsty, (block->ref & 3) - 1, plane);
s->put_pixels_tab[idx](s->mcscratch, src, p->stride, p->yblen);
if (s->weight_func)
s->weight_func(s->mcscratch, p->stride, s->weight_log2denom,
@@ -1562,8 +1595,9 @@ static void block_mc(DiracContext *s, DiracBlock *block,
if (s->biweight_func) {
/* fixme: +32 is a quick hack */
s->put_pixels_tab[idx](s->mcscratch + 32, src, p->stride, p->yblen);
- s->biweight_func(s->mcscratch, s->mcscratch+32, p->stride, s->weight_log2denom,
- s->weight[0], s->weight[1], p->yblen);
+ s->biweight_func(s->mcscratch, s->mcscratch + 32, p->stride,
+ s->weight_log2denom, s->weight[0], s->weight[1],
+ p->yblen);
} else
s->avg_pixels_tab[idx](s->mcscratch, src, p->stride, p->yblen);
break;
@@ -1571,51 +1605,57 @@ static void block_mc(DiracContext *s, DiracBlock *block,
s->add_obmc(mctmp, s->mcscratch, p->stride, obmc_weight, p->yblen);
}
-static void mc_row(DiracContext *s, DiracBlock *block, uint16_t *mctmp, int plane, int dsty)
-{
+static void mc_row(DiracContext *s, DiracBlock *block, uint16_t *mctmp,
+ int plane, int dsty) {
Plane *p = &s->plane[plane];
int x, dstx = p->xbsep - p->xoffset;
block_mc(s, block, mctmp, s->obmc_weight[0], plane, -p->xoffset, dsty);
mctmp += p->xbsep;
- for (x = 1; x < s->blwidth-1; x++) {
- block_mc(s, block+x, mctmp, s->obmc_weight[1], plane, dstx, dsty);
- dstx += p->xbsep;
+ for (x = 1; x < s->blwidth - 1; x++) {
+ block_mc(s, block + x, mctmp, s->obmc_weight[1], plane, dstx, dsty);
+ dstx += p->xbsep;
mctmp += p->xbsep;
}
- block_mc(s, block+x, mctmp, s->obmc_weight[2], plane, dstx, dsty);
+ block_mc(s, block + x, mctmp, s->obmc_weight[2], plane, dstx, dsty);
}
-static void select_dsp_funcs(DiracContext *s, int width, int height, int xblen, int yblen)
-{
+static void select_dsp_funcs(DiracContext *s, int width, int height, int xblen,
+ int yblen) {
int idx = 0;
if (xblen > 8)
idx = 1;
if (xblen > 16)
idx = 2;
- memcpy(s->put_pixels_tab, s->diracdsp.put_dirac_pixels_tab[idx], sizeof(s->put_pixels_tab));
- memcpy(s->avg_pixels_tab, s->diracdsp.avg_dirac_pixels_tab[idx], sizeof(s->avg_pixels_tab));
+ memcpy(s->put_pixels_tab, s->diracdsp.put_dirac_pixels_tab[idx],
+ sizeof(s->put_pixels_tab));
+ memcpy(s->avg_pixels_tab, s->diracdsp.avg_dirac_pixels_tab[idx],
+ sizeof(s->avg_pixels_tab));
s->add_obmc = s->diracdsp.add_dirac_obmc[idx];
if (s->weight_log2denom > 1 || s->weight[0] != 1 || s->weight[1] != 1) {
- s->weight_func = s->diracdsp.weight_dirac_pixels_tab[idx];
+ s->weight_func = s->diracdsp.weight_dirac_pixels_tab[idx];
s->biweight_func = s->diracdsp.biweight_dirac_pixels_tab[idx];
} else {
- s->weight_func = NULL;
+ s->weight_func = NULL;
s->biweight_func = NULL;
}
}
-static int interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height)
-{
+static int interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane,
+ int width, int height) {
/* chroma allocates an edge of 8 when subsampled
which for 4:2:2 means an h edge of 16 and v edge of 8
just use 8 for everything for the moment */
- int i, edge = EDGE_WIDTH/2;
+ int i, edge = EDGE_WIDTH / 2;
ref->hpel[plane][0] = ref->avframe->data[plane];
- s->mpvencdsp.draw_edges(ref->hpel[plane][0], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to make it build, this needs to be ensured */
+ s->mpvencdsp.draw_edges(
+ ref->hpel[plane][0], ref->avframe->linesize[plane], width, height, edge,
+ edge,
+ EDGE_TOP | EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to
+ make it build, this needs to be ensured */
/* no need for hpel if we only have fpel vectors */
if (!s->mv_precision)
@@ -1623,21 +1663,29 @@ static int interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int
for (i = 1; i < 4; i++) {
if (!ref->hpel_base[plane][i])
- ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe->linesize[plane] + 32);
+ ref->hpel_base[plane][i] = av_malloc(
+ (height + 2 * edge) * ref->avframe->linesize[plane] + 32);
if (!ref->hpel_base[plane][i]) {
return AVERROR(ENOMEM);
}
/* we need to be 16-byte aligned even for chroma */
- ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe->linesize[plane] + 16;
+ ref->hpel[plane][i] = ref->hpel_base[plane][i] +
+ edge * ref->avframe->linesize[plane] + 16;
}
if (!ref->interpolated[plane]) {
- s->diracdsp.dirac_hpel_filter(ref->hpel[plane][1], ref->hpel[plane][2],
- ref->hpel[plane][3], ref->hpel[plane][0],
- ref->avframe->linesize[plane], width, height);
- s->mpvencdsp.draw_edges(ref->hpel[plane][1], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
- s->mpvencdsp.draw_edges(ref->hpel[plane][2], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
- s->mpvencdsp.draw_edges(ref->hpel[plane][3], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
+ s->diracdsp.dirac_hpel_filter(
+ ref->hpel[plane][1], ref->hpel[plane][2], ref->hpel[plane][3],
+ ref->hpel[plane][0], ref->avframe->linesize[plane], width, height);
+ s->mpvencdsp.draw_edges(ref->hpel[plane][1],
+ ref->avframe->linesize[plane], width, height,
+ edge, edge, EDGE_TOP | EDGE_BOTTOM);
+ s->mpvencdsp.draw_edges(ref->hpel[plane][2],
+ ref->avframe->linesize[plane], width, height,
+ edge, edge, EDGE_TOP | EDGE_BOTTOM);
+ s->mpvencdsp.draw_edges(ref->hpel[plane][3],
+ ref->avframe->linesize[plane], width, height,
+ edge, edge, EDGE_TOP | EDGE_BOTTOM);
}
ref->interpolated[plane] = 1;
@@ -1648,8 +1696,7 @@ static int interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int
* Dirac Specification ->
* 13.0 Transform data syntax. transform_data()
*/
-static int dirac_decode_frame_internal(DiracContext *s)
-{
+static int dirac_decode_frame_internal(DiracContext *s) {
DWTContext d;
int y, i, comp, dsty;
int ret = -1;
@@ -1675,30 +1722,32 @@ static int dirac_decode_frame_internal(DiracContext *s)
}
if (s->avctx->hwaccel) {
- ret = ffhwaccel(s->avctx->hwaccel)->end_frame(s->avctx);
+ // ret = ffhwaccel(s->avctx->hwaccel)->end_frame(s->avctx);
+ ret = FF_HW_SIMPLE_CALL(s->avctx, end_frame);
if (ret == 0) {
/* Hwaccel failed - fall back on software decoder */
- }
return ret;
+ }
}
for (comp = 0; comp < 3; comp++) {
- Plane *p = &s->plane[comp];
+ Plane *p = &s->plane[comp];
uint8_t *frame = s->current_picture->avframe->data[comp];
/* FIXME: small resolutions */
for (i = 0; i < 4; i++)
- s->edge_emu_buffer[i] = s->edge_emu_buffer_base + i*FFALIGN(p->width, 16);
+ s->edge_emu_buffer[i] =
+ s->edge_emu_buffer_base + i * FFALIGN(p->width, 16);
- if (!s->zero_res && !s->low_delay)
- {
+ if (!s->zero_res && !s->low_delay) {
memset(p->idwt.buf, 0, p->idwt.stride * p->idwt.height);
- ret = decode_component(s, comp); /* [DIRAC_STD] 13.4.1 core_transform_data() */
+ ret = decode_component(
+ s, comp); /* [DIRAC_STD] 13.4.1 core_transform_data() */
if (ret < 0)
return ret;
}
- ret = ff_spatial_idwt_init(&d, &p->idwt, s->wavelet_idx+2,
+ ret = ff_spatial_idwt_init(&d, &p->idwt, s->wavelet_idx + 2,
s->wavelet_depth, s->bit_depth);
if (ret < 0)
return ret;
@@ -1706,62 +1755,63 @@ static int dirac_decode_frame_internal(DiracContext *s)
if (!s->num_refs) { /* intra */
for (y = 0; y < p->height; y += 16) {
int idx = (s->bit_depth - 8) >> 1;
- ff_spatial_idwt_slice2(&d, y+16); /* decode */
- s->diracdsp.put_signed_rect_clamped[idx](frame + y*p->stride,
- p->stride,
- p->idwt.buf + y*p->idwt.stride,
- p->idwt.stride, p->width, 16);
+ ff_spatial_idwt_slice2(&d, y + 16); /* decode */
+ s->diracdsp.put_signed_rect_clamped[idx](
+ frame + y * p->stride, p->stride,
+ p->idwt.buf + y * p->idwt.stride, p->idwt.stride, p->width,
+ 16);
}
} else { /* inter */
- int rowheight = p->ybsep*p->stride;
+ int rowheight = p->ybsep * p->stride;
select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen);
for (i = 0; i < s->num_refs; i++) {
- int ret = interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height);
+ int ret = interpolate_refplane(s, s->ref_pics[i], comp,
+ p->width, p->height);
if (ret < 0)
return ret;
}
- memset(s->mctmp, 0, 4*p->yoffset*p->stride);
+ memset(s->mctmp, 0, 4 * p->yoffset * p->stride);
dsty = -p->yoffset;
for (y = 0; y < s->blheight; y++) {
- int h = 0,
- start = FFMAX(dsty, 0);
- uint16_t *mctmp = s->mctmp + y*rowheight;
- DiracBlock *blocks = s->blmotion + y*s->blwidth;
+ int h = 0, start = FFMAX(dsty, 0);
+ uint16_t *mctmp = s->mctmp + y * rowheight;
+ DiracBlock *blocks = s->blmotion + y * s->blwidth;
init_obmc_weights(s, p, y);
- if (y == s->blheight-1 || start+p->ybsep > p->height)
+ if (y == s->blheight - 1 || start + p->ybsep > p->height)
h = p->height - start;
else
h = p->ybsep - (start - dsty);
if (h < 0)
break;
- memset(mctmp+2*p->yoffset*p->stride, 0, 2*rowheight);
+ memset(mctmp + 2 * p->yoffset * p->stride, 0, 2 * rowheight);
mc_row(s, blocks, mctmp, comp, dsty);
- mctmp += (start - dsty)*p->stride + p->xoffset;
+ mctmp += (start - dsty) * p->stride + p->xoffset;
ff_spatial_idwt_slice2(&d, start + h); /* decode */
- /* NOTE: add_rect_clamped hasn't been templated hence the shifts.
- * idwt.stride is passed as pixels, not in bytes as in the rest of the decoder */
- s->diracdsp.add_rect_clamped(frame + start*p->stride, mctmp, p->stride,
- (int16_t*)(p->idwt.buf) + start*(p->idwt.stride >> 1), (p->idwt.stride >> 1), p->width, h);
+ /* NOTE: add_rect_clamped hasn't been templated hence the
+ * shifts. idwt.stride is passed as pixels, not in bytes as in
+ * the rest of the decoder */
+ s->diracdsp.add_rect_clamped(
+ frame + start * p->stride, mctmp, p->stride,
+ (int16_t *)(p->idwt.buf) + start * (p->idwt.stride >> 1),
+ (p->idwt.stride >> 1), p->width, h);
dsty += p->ybsep;
}
}
}
-
return 0;
}
-static int get_buffer_with_edge(AVCodecContext *avctx, AVFrame *f, int flags)
-{
+static int get_buffer_with_edge(AVCodecContext *avctx, AVFrame *f, int flags) {
int ret, i;
int chroma_x_shift, chroma_y_shift;
DiracContext *s = avctx->priv_data;
@@ -1770,25 +1820,19 @@ static int get_buffer_with_edge(AVCodecContext *avctx, AVFrame *f, int flags)
if (ret < 0)
return ret;
- /*if (avctx->hwaccel) {*/
- /* f->width = s->plane[0].width;*/
- /* f->height = s->plane[0].height;*/
- /* ret = ff_get_buffer(avctx, f, flags);*/
- /* return ret;*/
- /*}*/
-
- f->width = avctx->width + 2 * EDGE_WIDTH;
+ f->width = avctx->width + 2 * EDGE_WIDTH;
f->height = avctx->height + 2 * EDGE_WIDTH + 2;
ret = ff_get_buffer(avctx, f, flags);
if (ret < 0 || avctx->hwaccel)
return ret;
for (i = 0; f->data[i]; i++) {
- int offset = (EDGE_WIDTH >> (i && i<3 ? chroma_y_shift : 0)) *
- f->linesize[i] + 32;
+ int offset =
+ (EDGE_WIDTH >> (i && i < 3 ? chroma_y_shift : 0)) * f->linesize[i] +
+ 32;
f->data[i] += offset;
}
- f->width = avctx->width;
+ f->width = avctx->width;
f->height = avctx->height;
return 0;
@@ -1798,8 +1842,7 @@ static int get_buffer_with_edge(AVCodecContext *avctx, AVFrame *f, int flags)
* Dirac Specification ->
* 11.1.1 Picture Header. picture_header()
*/
-static int dirac_decode_picture_header(DiracContext *s)
-{
+static int dirac_decode_picture_header(DiracContext *s) {
unsigned retire, picnum;
int i, j, ret;
int64_t refdist, refnum;
@@ -1808,8 +1851,7 @@ static int dirac_decode_picture_header(DiracContext *s)
/* [DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM */
picnum = s->current_picture->picture_number = get_bits_long(gb, 32);
-
- av_log(s->avctx,AV_LOG_DEBUG,"PICTURE_NUM: %d\n",picnum);
+ av_log(s->avctx, AV_LOG_DEBUG, "PICTURE_NUM: %d\n", picnum);
/* if this is the first keyframe after a sequence header, start our
reordering from here */
@@ -1824,8 +1866,8 @@ static int dirac_decode_picture_header(DiracContext *s)
/* find the closest reference to the one we want */
/* Jordi: this is needed if the referenced picture hasn't yet arrived */
for (j = 0; j < MAX_REFERENCE_FRAMES && refdist; j++)
- if (s->ref_frames[j]
- && FFABS(s->ref_frames[j]->picture_number - refnum) < refdist) {
+ if (s->ref_frames[j] &&
+ FFABS(s->ref_frames[j]->picture_number - refnum) < refdist) {
s->ref_pics[i] = s->ref_frames[j];
refdist = FFABS(s->ref_frames[j]->picture_number - refnum);
}
@@ -1838,17 +1880,19 @@ static int dirac_decode_picture_header(DiracContext *s)
for (j = 0; j < MAX_FRAMES; j++)
if (!s->all_frames[j].avframe->data[0]) {
s->ref_pics[i] = &s->all_frames[j];
- ret = get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
+ ret =
+ get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe,
+ AV_GET_BUFFER_FLAG_REF);
if (ret < 0)
return ret;
break;
}
if (!s->ref_pics[i]) {
- av_log(s->avctx, AV_LOG_ERROR, "Reference could not be allocated\n");
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Reference could not be allocated\n");
return AVERROR_INVALIDDATA;
}
-
}
/* retire the reference frames that are not used anymore */
@@ -1864,21 +1908,27 @@ static int dirac_decode_picture_header(DiracContext *s)
}
/* if reference array is full, remove the oldest as per the spec */
- while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES, s->current_picture)) {
+ while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES,
+ s->current_picture)) {
av_log(s->avctx, AV_LOG_ERROR, "Reference frame overflow\n");
- remove_frame(s->ref_frames, s->ref_frames[0]->picture_number)->reference &= DELAYED_PIC_REF;
+ remove_frame(s->ref_frames, s->ref_frames[0]->picture_number)
+ ->reference &= DELAYED_PIC_REF;
}
}
if (s->num_refs) {
- ret = dirac_unpack_prediction_parameters(s); /* [DIRAC_STD] 11.2 Picture Prediction Data. picture_prediction() */
+ ret = dirac_unpack_prediction_parameters(
+ s); /* [DIRAC_STD] 11.2 Picture Prediction Data.
+ picture_prediction() */
if (ret < 0)
return ret;
- ret = dirac_unpack_block_motion_data(s); /* [DIRAC_STD] 12. Block motion data syntax */
+ ret = dirac_unpack_block_motion_data(
+ s); /* [DIRAC_STD] 12. Block motion data syntax */
if (ret < 0)
return ret;
}
- ret = dirac_unpack_idwt_params(s); /* [DIRAC_STD] 11.3 Wavelet transform data */
+ ret = dirac_unpack_idwt_params(
+ s); /* [DIRAC_STD] 11.3 Wavelet transform data */
if (ret < 0)
return ret;
@@ -1886,25 +1936,24 @@ static int dirac_decode_picture_header(DiracContext *s)
return 0;
}
-static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
-{
+static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame) {
DiracFrame *out = s->delay_frames[0];
- int i, out_idx = 0;
+ int i, out_idx = 0;
int ret;
/* find frame with lowest picture number */
for (i = 1; s->delay_frames[i]; i++)
if (s->delay_frames[i]->picture_number < out->picture_number) {
- out = s->delay_frames[i];
+ out = s->delay_frames[i];
out_idx = i;
}
for (i = out_idx; s->delay_frames[i]; i++)
- s->delay_frames[i] = s->delay_frames[i+1];
+ s->delay_frames[i] = s->delay_frames[i + 1];
if (out) {
out->reference ^= DELAYED_PIC_REF;
- if((ret = av_frame_ref(picture, out->avframe)) < 0)
+ if ((ret = av_frame_ref(picture, out->avframe)) < 0)
return ret;
*got_frame = 1;
}
@@ -1919,12 +1968,12 @@ static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
*/
#define DATA_UNIT_HEADER_SIZE 13
-/* [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3
- inside the function parse_sequence() */
-static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int size)
-{
- DiracContext *s = avctx->priv_data;
- DiracFrame *pic = NULL;
+/* [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined
+ in 9.3 inside the function parse_sequence() */
+static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf,
+ int size) {
+ DiracContext *s = avctx->priv_data;
+ DiracFrame *pic = NULL;
AVDiracSeqHeader *dsh;
int ret, i;
uint8_t parse_code;
@@ -1935,7 +1984,7 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
parse_code = buf[4];
- init_get_bits(&s->gb, &buf[13], 8*(size - DATA_UNIT_HEADER_SIZE));
+ init_get_bits(&s->gb, &buf[13], 8 * (size - DATA_UNIT_HEADER_SIZE));
if (parse_code == DIRAC_PCODE_SEQ_HEADER) {
enum AVPixelFormat *pix_fmts;
@@ -1943,13 +1992,17 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
return 0;
/* [DIRAC_STD] 10. Sequence header */
- ret = av_dirac_parse_sequence_header(&dsh, buf + DATA_UNIT_HEADER_SIZE, size - DATA_UNIT_HEADER_SIZE, avctx);
+ ret =
+ av_dirac_parse_sequence_header(&dsh, buf + DATA_UNIT_HEADER_SIZE,
+ size - DATA_UNIT_HEADER_SIZE, avctx);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "error parsing sequence header");
return ret;
}
- if (CALC_PADDING((int64_t)dsh->width, MAX_DWT_LEVELS) * CALC_PADDING((int64_t)dsh->height, MAX_DWT_LEVELS) * 5LL > avctx->max_pixels)
+ if (CALC_PADDING((int64_t)dsh->width, MAX_DWT_LEVELS) *
+ CALC_PADDING((int64_t)dsh->height, MAX_DWT_LEVELS) * 5LL >
+ avctx->max_pixels)
ret = AVERROR(ERANGE);
if (ret >= 0)
ret = ff_set_dimensions(avctx, dsh->width, dsh->height);
@@ -1959,39 +2012,34 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
}
ff_set_sar(avctx, dsh->sample_aspect_ratio);
- s->sof_pix_fmt = dsh->pix_fmt;
- avctx->pix_fmt = dsh->pix_fmt;
- avctx->color_range = dsh->color_range;
- avctx->color_trc = dsh->color_trc;
+ s->sof_pix_fmt = dsh->pix_fmt;
+ avctx->pix_fmt = dsh->pix_fmt;
+ avctx->color_range = dsh->color_range;
+ avctx->color_trc = dsh->color_trc;
avctx->color_primaries = dsh->color_primaries;
- avctx->colorspace = dsh->colorspace;
- avctx->profile = dsh->profile;
- avctx->level = dsh->level;
- avctx->framerate = dsh->framerate;
- s->bit_depth = dsh->bit_depth;
- s->version.major = dsh->version.major;
- s->version.minor = dsh->version.minor;
- s->seq = *dsh;
+ avctx->colorspace = dsh->colorspace;
+ avctx->profile = dsh->profile;
+ avctx->level = dsh->level;
+ avctx->framerate = dsh->framerate;
+ s->bit_depth = dsh->bit_depth;
+ s->version.major = dsh->version.major;
+ s->version.minor = dsh->version.minor;
+ s->seq = *dsh;
av_freep(&dsh);
s->pshift = s->bit_depth > 8;
- /*if (s->pshift) {*/
- /* avctx->pix_fmt = s->sof_pix_fmt;*/
- /*} else {*/
- pix_fmts = (enum AVPixelFormat[]){
+ pix_fmts = (enum AVPixelFormat[]){
#if CONFIG_DIRAC_VULKAN_HWACCEL
- AV_PIX_FMT_VULKAN,
+ AV_PIX_FMT_VULKAN,
#endif
- s->sof_pix_fmt,
- AV_PIX_FMT_NONE,
- };
- avctx->pix_fmt = ff_get_format(s->avctx, pix_fmts);
- /*}*/
-
- ret = av_pix_fmt_get_chroma_sub_sample(s->sof_pix_fmt,
- &s->chroma_x_shift,
- &s->chroma_y_shift);
+ s->sof_pix_fmt,
+ AV_PIX_FMT_NONE,
+ };
+ avctx->pix_fmt = ff_get_format(s->avctx, pix_fmts);
+
+ ret = av_pix_fmt_get_chroma_sub_sample(
+ s->sof_pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
if (ret < 0)
return ret;
@@ -2000,26 +2048,29 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
return ret;
s->seen_sequence_header = 1;
- } else if (parse_code == DIRAC_PCODE_END_SEQ) { /* [DIRAC_STD] End of Sequence */
+ } else if (parse_code ==
+ DIRAC_PCODE_END_SEQ) { /* [DIRAC_STD] End of Sequence */
free_sequence_buffers(s);
s->seen_sequence_header = 0;
} else if (parse_code == DIRAC_PCODE_AUX) {
- if (buf[13] == 1) { /* encoder implementation/version */
+ if (buf[13] == 1) { /* encoder implementation/version */
int ver[3];
/* versions older than 1.0.8 don't store quant delta for
subbands with only one codeblock */
- if (sscanf(buf+14, "Schroedinger %d.%d.%d", ver, ver+1, ver+2) == 3)
+ if (sscanf(buf + 14, "Schroedinger %d.%d.%d", ver, ver + 1,
+ ver + 2) == 3)
if (ver[0] == 1 && ver[1] == 0 && ver[2] <= 7)
s->old_delta_quant = 1;
}
- } else if (parse_code & 0x8) { /* picture data unit */
+ } else if (parse_code & 0x8) { /* picture data unit */
if (!s->seen_sequence_header) {
- av_log(avctx, AV_LOG_DEBUG, "Dropping frame without sequence header\n");
+ av_log(avctx, AV_LOG_DEBUG,
+ "Dropping frame without sequence header\n");
return AVERROR_INVALIDDATA;
}
/* find an unused frame */
- for (i = 0; i < MAX_FRAMES; i++)
+ for (i = 0; i < MAX_FRAMES; i++)
if (s->all_frames[i].avframe->data[0] == NULL)
pic = &s->all_frames[i];
@@ -2031,35 +2082,44 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
av_frame_unref(pic->avframe);
/* [DIRAC_STD] Defined in 9.6.1 ... */
- tmp = parse_code & 0x03; /* [DIRAC_STD] num_refs() */
+ tmp = parse_code & 0x03; /* [DIRAC_STD] num_refs() */
if (tmp > 2) {
av_log(avctx, AV_LOG_ERROR, "num_refs of 3\n");
return AVERROR_INVALIDDATA;
}
- s->num_refs = tmp;
- s->is_arith = (parse_code & 0x48) == 0x08; /* [DIRAC_STD] using_ac() */
- s->low_delay = (parse_code & 0x88) == 0x88; /* [DIRAC_STD] is_low_delay() */
- s->core_syntax = (parse_code & 0x88) == 0x08; /* [DIRAC_STD] is_core_syntax() */
- s->ld_picture = (parse_code & 0xF8) == 0xC8; /* [DIRAC_STD] is_ld_picture() */
- s->hq_picture = (parse_code & 0xF8) == 0xE8; /* [DIRAC_STD] is_hq_picture() */
- s->dc_prediction = (parse_code & 0x28) == 0x08; /* [DIRAC_STD] using_dc_prediction() */
- pic->reference = (parse_code & 0x0C) == 0x0C; /* [DIRAC_STD] is_reference() */
- if (s->num_refs == 0) /* [DIRAC_STD] is_intra() */
- pic->avframe->flags |= AV_FRAME_FLAG_KEY;
+ s->num_refs = tmp;
+ s->is_arith = (parse_code & 0x48) == 0x08; /* [DIRAC_STD] using_ac() */
+ s->low_delay =
+ (parse_code & 0x88) == 0x88; /* [DIRAC_STD] is_low_delay() */
+ s->core_syntax =
+ (parse_code & 0x88) == 0x08; /* [DIRAC_STD] is_core_syntax() */
+ s->ld_picture =
+ (parse_code & 0xF8) == 0xC8; /* [DIRAC_STD] is_ld_picture() */
+ s->hq_picture =
+ (parse_code & 0xF8) == 0xE8; /* [DIRAC_STD] is_hq_picture() */
+ s->dc_prediction =
+ (parse_code & 0x28) == 0x08; /* [DIRAC_STD] using_dc_prediction() */
+ pic->reference =
+ (parse_code & 0x0C) == 0x0C; /* [DIRAC_STD] is_reference() */
+ if (s->num_refs == 0) /* [DIRAC_STD] is_intra() */
+ pic->avframe->flags |= AV_FRAME_FLAG_KEY;
else
- pic->avframe->flags &= ~AV_FRAME_FLAG_KEY;
- pic->avframe->pict_type = s->num_refs + 1; /* Definition of AVPictureType in avutil.h */
+ pic->avframe->flags &= ~AV_FRAME_FLAG_KEY;
+ pic->avframe->pict_type =
+ s->num_refs + 1; /* Definition of AVPictureType in avutil.h */
/* VC-2 Low Delay has a different parse code than the Dirac Low Delay */
if (s->version.minor == 2 && parse_code == 0x88)
s->ld_picture = 1;
- if (s->low_delay && !(s->ld_picture || s->hq_picture) ) {
+ if (s->low_delay && !(s->ld_picture || s->hq_picture)) {
av_log(avctx, AV_LOG_ERROR, "Invalid low delay flag\n");
return AVERROR_INVALIDDATA;
}
- if ((ret = get_buffer_with_edge(avctx, pic->avframe, (parse_code & 0x0C) == 0x0C ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
+ if ((ret = get_buffer_with_edge(
+ avctx, pic->avframe,
+ (parse_code & 0x0C) == 0x0C ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
return ret;
s->current_picture = pic;
@@ -2081,7 +2141,9 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
s->plane[1].stride = pic->avframe->linesize[1];
s->plane[2].stride = pic->avframe->linesize[2];
- if (alloc_buffers(s, FFMAX3(FFABS(s->plane[0].stride), FFABS(s->plane[1].stride), FFABS(s->plane[2].stride))) < 0)
+ if (alloc_buffers(s, FFMAX3(FFABS(s->plane[0].stride),
+ FFABS(s->plane[1].stride),
+ FFABS(s->plane[2].stride))) < 0)
return AVERROR(ENOMEM);
}
@@ -2099,12 +2161,11 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
}
static int dirac_decode_frame(AVCodecContext *avctx, AVFrame *picture,
- int *got_frame, AVPacket *pkt)
-{
- DiracContext *s = avctx->priv_data;
- const uint8_t *buf = pkt->data;
- int buf_size = pkt->size;
- int i, buf_idx = 0;
+ int *got_frame, AVPacket *pkt) {
+ DiracContext *s = avctx->priv_data;
+ const uint8_t *buf = pkt->data;
+ int buf_size = pkt->size;
+ int i, buf_idx = 0;
int ret;
unsigned data_unit_size;
@@ -2112,7 +2173,8 @@ static int dirac_decode_frame(AVCodecContext *avctx, AVFrame *picture,
for (i = 0; i < MAX_FRAMES; i++)
if (s->all_frames[i].avframe->data[0] && !s->all_frames[i].reference) {
av_frame_unref(s->all_frames[i].avframe);
- memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
+ memset(s->all_frames[i].interpolated, 0,
+ sizeof(s->all_frames[i].interpolated));
}
s->current_picture = NULL;
@@ -2127,28 +2189,29 @@ static int dirac_decode_frame(AVCodecContext *avctx, AVFrame *picture,
[DIRAC_STD] PARSE_INFO_PREFIX = "BBCD" as defined in ISO/IEC 646
BBCD start code search */
for (; buf_idx + DATA_UNIT_HEADER_SIZE < buf_size; buf_idx++) {
- if (buf[buf_idx ] == 'B' && buf[buf_idx+1] == 'B' &&
- buf[buf_idx+2] == 'C' && buf[buf_idx+3] == 'D')
+ if (buf[buf_idx] == 'B' && buf[buf_idx + 1] == 'B' &&
+ buf[buf_idx + 2] == 'C' && buf[buf_idx + 3] == 'D')
break;
}
/* BBCD found or end of data */
if (buf_idx + DATA_UNIT_HEADER_SIZE >= buf_size)
break;
- data_unit_size = AV_RB32(buf+buf_idx+5);
+ data_unit_size = AV_RB32(buf + buf_idx + 5);
if (data_unit_size > buf_size - buf_idx || !data_unit_size) {
- if(data_unit_size > buf_size - buf_idx)
- av_log(s->avctx, AV_LOG_ERROR,
- "Data unit with size %d is larger than input buffer, discarding\n",
- data_unit_size);
+ if (data_unit_size > buf_size - buf_idx)
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Data unit with size %d is larger than input buffer, "
+ "discarding\n",
+ data_unit_size);
buf_idx += 4;
continue;
}
- /* [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3 inside the function parse_sequence() */
- ret = dirac_decode_data_unit(avctx, buf+buf_idx, data_unit_size);
- if (ret < 0)
- {
- av_log(s->avctx, AV_LOG_ERROR,"Error in dirac_decode_data_unit\n");
+ /* [DIRAC_STD] dirac_decode_data_unit makes reference to the while
+ * defined in 9.3 inside the function parse_sequence() */
+ ret = dirac_decode_data_unit(avctx, buf + buf_idx, data_unit_size);
+ if (ret < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Error in dirac_decode_data_unit\n");
return ret;
}
buf_idx += data_unit_size;
@@ -2158,13 +2221,15 @@ static int dirac_decode_frame(AVCodecContext *avctx, AVFrame *picture,
return buf_size;
if (s->current_picture->picture_number > s->frame_number) {
- DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);
+ DiracFrame *delayed_frame =
+ remove_frame(s->delay_frames, s->frame_number);
s->current_picture->reference |= DELAYED_PIC_REF;
if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
unsigned min_num = s->delay_frames[0]->picture_number;
- /* Too many delayed frames, so we display the frame with the lowest pts */
+ /* Too many delayed frames, so we display the frame with the lowest
+ * pts */
av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
for (i = 1; s->delay_frames[i]; i++)
@@ -2177,14 +2242,14 @@ static int dirac_decode_frame(AVCodecContext *avctx, AVFrame *picture,
if (delayed_frame) {
delayed_frame->reference ^= DELAYED_PIC_REF;
- if((ret = av_frame_ref(picture, delayed_frame->avframe)) < 0)
+ if ((ret = av_frame_ref(picture, delayed_frame->avframe)) < 0)
return ret;
s->frame_number = delayed_frame->picture_number + 1LL;
*got_frame = 1;
}
} else if (s->current_picture->picture_number == s->frame_number) {
/* The right frame at the right time :-) */
- if((ret = av_frame_ref(picture, s->current_picture->avframe)) < 0)
+ if ((ret = av_frame_ref(picture, s->current_picture->avframe)) < 0)
return ret;
s->frame_number = s->current_picture->picture_number + 1LL;
*got_frame = 1;
@@ -2193,22 +2258,22 @@ static int dirac_decode_frame(AVCodecContext *avctx, AVFrame *picture,
return buf_idx;
}
-
const FFCodec ff_dirac_decoder = {
- .p.name = "dirac",
+ .p.name = "dirac",
CODEC_LONG_NAME("BBC Dirac VC-2"),
- .p.type = AVMEDIA_TYPE_VIDEO,
- .p.id = AV_CODEC_ID_DIRAC,
+ .p.type = AVMEDIA_TYPE_VIDEO,
+ .p.id = AV_CODEC_ID_DIRAC,
.priv_data_size = sizeof(DiracContext),
- .init = dirac_decode_init,
- .close = dirac_decode_end,
+ .init = dirac_decode_init,
+ .close = dirac_decode_end,
FF_CODEC_DECODE_CB(dirac_decode_frame),
- .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_DR1,
- .flush = dirac_decode_flush,
- .hw_configs = (const AVCodecHWConfigInternal *const []) {
+ .p.capabilities =
+ AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_DR1,
+ .flush = dirac_decode_flush,
+ .hw_configs =
+ (const AVCodecHWConfigInternal *const[]){
#if CONFIG_DIRAC_VULKAN_HWACCEL
- HWACCEL_VULKAN(dirac),
+ HWACCEL_VULKAN(dirac),
#endif
- NULL
- },
+ NULL},
};
@@ -135,13 +135,7 @@ static void free_common(AVCodecContext *avctx) {
ff_vk_pipeline_free(s, &dec->horiz_wavelet_pl[i]);
ff_vk_shader_free(s, &dec->horiz_wavelet_shd[i]);
}
- // TODO: Add freeing all pipelines and shaders for wavelets
- //
- // if (dec->yuv_sampler)
- // vk->DestroySamplerYcbcrConversion(s->hwctx->act_dev,
- // dec->yuv_sampler,
- // s->hwctx->alloc);
if (dec->sampler)
vk->DestroySampler(s->hwctx->act_dev, dec->sampler, s->hwctx->alloc);
@@ -225,8 +219,6 @@ static inline int alloc_tmp_bufs(DiracContext *ctx,
static inline int alloc_host_mapped_buf(DiracVulkanDecodeContext *dec,
size_t req_size, void **mem,
AVBufferRef **avbuf, FFVkBuffer **buf) {
- // FFVulkanFunctions *vk = &dec->vkctx.vkfn;
- // VkResult ret;
int err;
err = ff_vk_create_avbuf(&dec->vkctx, avbuf, req_size, NULL, NULL,
@@ -307,7 +299,6 @@ static int alloc_quant_buf(DiracContext *ctx, DiracVulkanDecodeContext *dec) {
subband_coeffs(ctx, ctx->num_x - 1, ctx->num_y - 1, 0, 0, tmp) + 8;
coef_buf_size = coef_buf_size + 512;
dec->slice_vals_size = coef_buf_size / sizeof(int32_t);
- // coef_buf_size *= sizeof(int32_t);
if (dec->quant_val_buf_vk_ptr) {
av_buffer_unref(&dec->av_quant_val_buf);
@@ -364,7 +355,6 @@ static int init_cpy_shd(DiracVulkanDecodeContext *s, FFVkSPIRVCompiler *spv,
.stages = VK_SHADER_STAGE_COMPUTE_BIT,
.type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
.mem_quali = "writeonly",
- // .mem_layout = ff_vk_shader_rep_fmt(vkctx->output_format),
.mem_layout = "rgba16f",
.dimensions = 2,
.elems = planes,
@@ -1477,7 +1467,6 @@ static int init_wavelet_shd_daub97_vert(DiracVulkanDecodeContext *s,
.stages = VK_SHADER_STAGE_COMPUTE_BIT,
.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
.buf_content = "int32_t inBuf[];",
- /*.mem_quali = "readonly",*/
.dimensions = 1,
},
{
@@ -2988,7 +2977,6 @@ static int init_quant_shd(DiracVulkanDecodeContext *s, FFVkSPIRVCompiler *spv) {
uint8_t *spv_data;
size_t spv_len;
void *spv_opaque = NULL;
- // const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
FFVulkanContext *vkctx = &s->vkctx;
FFVulkanDescriptorSetBinding *desc;
FFVkSPIRVShader *shd = &s->quant_shd;
@@ -3219,11 +3207,6 @@ static av_always_inline int inline quant_pl_pass(
}
static int vulkan_dirac_uninit(AVCodecContext *avctx) {
- // DiracContext *d = avctx->priv_data;
- // if (d->hwaccel_picture_private) {
- // av_freep(d->hwaccel_picture_private);
- // }
-
free_common(avctx);
return 0;
@@ -3326,8 +3309,9 @@ static int vulkan_dirac_init(AVCodecContext *avctx) {
s = &dec->vkctx;
err = ff_vk_init(s, avctx, NULL, avctx->hw_frames_ctx);
- if (err < 0)
- return err;
+ if (err < 0) {
+ goto fail;
+ }
/* Create queue context */
ff_vk_qf_init(s, &dec->qf, VK_QUEUE_COMPUTE_BIT);
@@ -3384,13 +3368,15 @@ static int vulkan_dirac_init(AVCodecContext *avctx) {
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
- if (err < 0)
- return err;
+ if (err < 0) {
+ goto fail;
+ }
err = ff_vk_map_buffer(&dec->vkctx, &dec->subband_info,
(uint8_t **)&dec->subband_info_ptr, 0);
- if (err < 0)
- return err;
+ if (err < 0) {
+ goto fail;
+ }
return 0;
@@ -3444,7 +3430,6 @@ static int vulkan_dirac_frame_params(AVCodecContext *avctx,
}
static void vulkan_dirac_free_frame_priv(FFRefStructOpaque _hwctx, void *data) {
- // AVHWDeviceContext *hwctx = _hwctx.nc;
DiracVulkanDecodePicture *dp = data;
/* Free frame resources */
@@ -3473,11 +3458,6 @@ static void setup_subbands(DiracContext *ctx, DiracVulkanDecodeContext *dec) {
off->base_off += w;
if (orient > 1)
off->base_off += (s >> 1);
-
- /*SubBand *b = &p->band[level][orient];*/
- /*int w = (b->ibuf - p->idwt.buf) >> (1 + b->pshift);*/
- /*off->stride = b->stride >> (1 + b->pshift);*/
- /*off->base_off = w;*/
}
}
}
@@ -3607,6 +3587,8 @@ static int vulkan_dirac_end_frame(AVCodecContext *avctx) {
err = AVERROR_PATCHWELCOME;
break;
}
+ if (err < 0)
+ goto fail;
err = cpy_to_image_pass(dec, ctx, exec, views, buf_bar, &nb_buf_bar,
img_bar, &nb_img_bar, (ctx->bit_depth - 8) >> 1);
@@ -3690,13 +3672,15 @@ static int vulkan_dirac_update_thread_context(AVCodecContext *dst,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
- if (err < 0)
- return err;
+ if (err < 0) {
+ goto fail;
+ }
err = ff_vk_map_buffer(&dst_ctx->vkctx, &dst_ctx->subband_info,
(uint8_t **)&dst_ctx->subband_info_ptr, 0);
- if (err < 0)
- return err;
+ if (err < 0) {
+ goto fail;
+ }
return 0;
@@ -3787,7 +3771,6 @@ static int vulkan_dirac_decode_slice(AVCodecContext *avctx, const uint8_t *data,
uint32_t size) {
DiracContext *s = avctx->priv_data;
- /*avctx->execute2(avctx, decode_hq_slice_row, NULL, NULL, s->num_y);*/
for (int i = 0; i < s->num_y; i++) {
decode_hq_slice_row(avctx, NULL, i, 0);
}
@@ -3812,6 +3795,5 @@ const FFHWAccel ff_dirac_vulkan_hwaccel = {
.flush = &ff_vk_decode_flush,
.update_thread_context = &vulkan_dirac_update_thread_context,
.priv_data_size = sizeof(DiracVulkanDecodeContext),
- // .caps_internal = HWACCEL_CAP_ASYNC_SAFE | HWACCEL_CAP_THREAD_SAFE,
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
};
Thanks for the review! Sorry about the mistakes, fixed them Signed-off-by: Petro Mozil <mozil.petryk@gmail.com> --- libavcodec/diracdec.c | 1275 +++++++++++++++++++------------------ libavcodec/vulkan_dirac.c | 52 +- 2 files changed, 687 insertions(+), 640 deletions(-)