Some quick review.

+static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
+                           int qsel, int is_chroma, int is_hqa)
+{
+    const int32_t *q;
+    int val, pos = 1;
+
+    memset(block, 0, 64 * sizeof(*block));
+
+    if (!is_hqa) {
+        block[0] = get_sbits(gb, 9) << 6;
+        q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
+    } else {
+        q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
+        block[0] = get_sbits(gb, 9) << 6;
+    }
+
+    for (;;) {
+        val  = get_vlc2(gb, c->hq_ac_vlc.table, 9, 2);

is the vlc space full or it can return a negative/invalid value?


+    for (i = 0; i < profile->num_slices + 1; i++)
+        slice_off[i] = AV_RB24(src + 4 + i * 3);
+
+    next_off = 0;
+    for (slice = 0; slice < profile->num_slices; slice++) {
+        start_off = next_off;
+        next_off  = profile->tab_h * (slice + 1) / profile->num_slices;
+        perm = profile->perm_tab + start_off * profile->tab_w * 2;
+
+        if (slice_off[slice] < (profile->num_slices + 1) * 3 + 4 ||
+            slice_off[slice] >= slice_off[slice + 1] ||
+            slice_off[slice + 1] > data_size) {
+            av_log(ctx->avctx, AV_LOG_ERROR,
+                   "Invalid slice size %d.\n", data_size);
+            break;
+        }
+        init_get_bits(&gb, src + slice_off[slice],
+                      (slice_off[slice + 1] - slice_off[slice]) * 8);
+

same question.

+    ret = ff_get_buffer(ctx->avctx, pic, 0);
+    if (ret < 0) {
+        av_log(ctx->avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
+        return ret;
+    }
+
+    for (i = 0; i < num_slices + 1; i++)
+        slice_off[i] = AV_RB32(src + 12 + i * 4);
+
+    for (slice = 0; slice < num_slices; slice++) {
+        if (slice_off[slice] < (num_slices + 1) * 3 + 4 ||
+            slice_off[slice] >= slice_off[slice + 1] ||
+            slice_off[slice + 1] > data_size) {
+            av_log(ctx->avctx, AV_LOG_ERROR,
+                   "Invalid slice size %d.\n", data_size);
+            break;
+        }
+        init_get_bits(&gb, src + slice_off[slice],
+                      (slice_off[slice + 1] - slice_off[slice]) * 8);

it might fail?



+typedef struct HQContext {
+    AVCodecContext *avctx;
+
+    VLC hq_ac_vlc;
+    VLC hqa_cbp_vlc;
+    DECLARE_ALIGNED(16, int16_t, block)[12][64];
+} HQContext;
+
+typedef struct HQProfile {
+    int width, height;
+    int num_slices;
+    const uint8_t *perm_tab;
+    int tab_w, tab_h;
+} HQProfile;

Pointers first, int after please.

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to