Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 917591 | Differences between
and this patch

Collapse All | Expand All

(-)a/libavcodec/dovi_rpu.c (-4 / +42 lines)
Lines 174-179 static inline int64_t get_se_coef(GetBitContext *gb, const AVDOVIRpuDataHeader * Link Here
174
    return 0; /* unreachable */
174
    return 0; /* unreachable */
175
}
175
}
176
176
177
static inline unsigned get_variable_bits(GetBitContext *gb, int n)
178
{
179
    unsigned int value = get_bits(gb, n);
180
    int read_more = get_bits1(gb);
181
    while (read_more) {
182
        value = (value + 1) << n;
183
        value |= get_bits(gb, n);
184
        read_more = get_bits1(gb);
185
    }
186
    return value;
187
}
188
177
#define VALIDATE(VAR, MIN, MAX)                                                 \
189
#define VALIDATE(VAR, MIN, MAX)                                                 \
178
    do {                                                                        \
190
    do {                                                                        \
179
        if (VAR < MIN || VAR > MAX) {                                           \
191
        if (VAR < MIN || VAR > MAX) {                                           \
Lines 200-208 int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size) Link Here
200
    if ((ret = init_get_bits8(gb, rpu, rpu_size)) < 0)
212
    if ((ret = init_get_bits8(gb, rpu, rpu_size)) < 0)
201
        return ret;
213
        return ret;
202
214
203
    /* RPU header, common values */
215
    /* Container header */
204
    nal_prefix = get_bits(gb, 8);
216
    if (s->dv_profile == 10 /* dav1.10 */) {
205
    VALIDATE(nal_prefix, 25, 25);
217
        /* DV inside AV1 re-uses an EMDF container skeleton, but with fixed
218
         * values - so we can effectively treat this as a magic byte sequence.
219
         *
220
         * The exact fields are, as follows:
221
         *   emdf_version            : f(2) = 0
222
         *   key_id                  : f(3) = 6
223
         *   emdf_payload_id         : f(5) = 31
224
         *   emdf_payload_id_ext     : var(5) = 225
225
         *   smploffste              : f(1) = 0
226
         *   duratione               : f(1) = 0
227
         *   groupide                : f(1) = 0
228
         *   codecdatae              : f(1) = 0
229
         *   discard_unknown_payload : f(1) = 1
230
         */
231
        const unsigned header_magic = 0x01be6841u;
232
        unsigned header, emdf_payload_size;
233
        header = get_bits_long(gb, 27);
234
        VALIDATE(header, header_magic, header_magic);
235
        emdf_payload_size = get_variable_bits(gb, 8);
236
        VALIDATE(emdf_payload_size, 6, 512);
237
        if (emdf_payload_size * 8 > get_bits_left(gb))
238
            return AVERROR_INVALIDDATA;
239
    } else {
240
        nal_prefix = get_bits(gb, 8);
241
        VALIDATE(nal_prefix, 25, 25);
242
    }
243
244
    /* RPU header */
206
    rpu_type = get_bits(gb, 6);
245
    rpu_type = get_bits(gb, 6);
207
    if (rpu_type != 2) {
246
    if (rpu_type != 2) {
208
        av_log(s->logctx, AV_LOG_WARNING, "Unrecognized RPU type "
247
        av_log(s->logctx, AV_LOG_WARNING, "Unrecognized RPU type "
209
- 

Return to bug 917591